LibreOffice Module svx (master)  1
fontworkgallery.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #include <com/sun/star/text/WritingMode.hpp>
22 
23 #include <vcl/toolbox.hxx>
24 #include <vcl/virdev.hxx>
25 
26 #include <svl/itempool.hxx>
27 
28 #include <svtools/toolbarmenu.hxx>
30 
31 #include <svx/fmmodel.hxx>
32 #include <svx/dialmgr.hxx>
33 #include <svx/strings.hrc>
34 #include <svx/svdpage.hxx>
35 #include <svx/svdobj.hxx>
36 #include <svx/svdview.hxx>
37 
38 #include <svx/gallery.hxx>
39 #include <svx/fontworkgallery.hxx>
40 
41 #include <algorithm>
42 #include <memory>
43 
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::beans;
47 
48 namespace svx
49 {
50 
51 const int nColCount = 4;
52 const int nLineCount = 4;
53 
55  : GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog")
56  , mnThemeId(0xffff)
57  , mrSdrView(rSdrView)
58  , mppSdrObject(nullptr)
59  , mpDestModel(nullptr)
60  , maCtlFavorites(m_xBuilder->weld_scrolled_window("ctlFavoriteswin"))
61  , mxCtlFavorites(new weld::CustomWeld(*m_xBuilder, "ctlFavorites", maCtlFavorites))
62  , mxOKButton(m_xBuilder->weld_button("ok"))
63 {
64  Size aSize(maCtlFavorites.GetDrawingArea()->get_ref_device().LogicToPixel(Size(200, 200), MapMode(MapUnit::MapAppFont)));
65  mxCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
66 
67  maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
68  mxOKButton->connect_clicked(LINK(this, FontWorkGalleryDialog, ClickOKHdl));
69 
70  maCtlFavorites.SetColCount( nColCount );
71  maCtlFavorites.SetLineCount( nLineCount );
73 
76 }
77 
79 {
80 }
81 
82 void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
83 {
84  // the favorites are read via the gallery
85  sal_uInt32 nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId );
86 
87  // lock gallery theme
89 
90  sal_uInt32 nModelPos;
91  FmFormModel *pModel = nullptr;
92 
93  for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ )
94  {
95  BitmapEx aThumb;
96 
97  if (GalleryExplorer::GetSdrObj(nThemeId, nModelPos, pModel, &aThumb) && !!aThumb)
98  {
100  const Point aNull(0, 0);
101 
102  if (pVDev->GetDPIScaleFactor() > 1)
103  aThumb.Scale(pVDev->GetDPIScaleFactor(), pVDev->GetDPIScaleFactor());
104 
105  const Size aSize(aThumb.GetSizePixel());
106 
107  pVDev->SetOutputSizePixel(aSize);
108 
109  static const sal_uInt32 nLen(8);
110  static const Color aW(COL_WHITE);
111  static const Color aG(0xef, 0xef, 0xef);
112 
113  pVDev->DrawCheckered(aNull, aSize, nLen, aW, aG);
114 
115  pVDev->DrawBitmapEx(aNull, aThumb);
116  maFavoritesHorizontal.emplace_back(pVDev->GetBitmapEx(aNull, aSize));
117  }
118  }
119 
120  // release gallery theme
121  GalleryExplorer::EndLocking(nThemeId);
122 }
123 
124 void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
125 {
126  mnThemeId = nThemeId;
127 
128  Size aThumbSize(maCtlFavorites.GetOutputSizePixel());
129  aThumbSize.setWidth( aThumbSize.Width() / nColCount );
130  aThumbSize.setHeight( aThumbSize.Height() / nLineCount );
131  aThumbSize.AdjustWidth( -12 );
132  aThumbSize.AdjustHeight( -12 );
133 
134  auto nFavCount = maFavoritesHorizontal.size();
135 
136  // ValueSet favorites
137  if( nFavCount > (nColCount * nLineCount) )
138  {
139  WinBits nWinBits = maCtlFavorites.GetStyle();
140  nWinBits |= WB_VSCROLL;
141  maCtlFavorites.SetStyle( nWinBits );
142  }
143 
145 
146  for( size_t nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
147  {
148  OUString aStr = SvxResId(RID_SVXFLOAT3D_FAVORITE) + " " + OUString::number(nFavorite);
149  Image aThumbImage( maFavoritesHorizontal[nFavorite-1] );
150  maCtlFavorites.InsertItem( static_cast<sal_uInt16>(nFavorite), aThumbImage, aStr );
151  }
152 
155 }
156 
158 {
159  mppSdrObject = ppSdrObject;
160  mpDestModel = pModel;
161 }
162 
164 {
165  sal_uInt16 nItemId = maCtlFavorites.GetSelectedItemId();
166 
167  if( nItemId > 0 )
168  {
169  std::unique_ptr<FmFormModel> pModel(new FmFormModel());
170  pModel->GetItemPool().FreezeIdRanges();
171 
172  if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel.get() ) )
173  {
174  SdrPage* pPage = pModel->GetPage(0);
175  if( pPage && pPage->GetObjCount() )
176  {
177  // tdf#116993 Calc uses a 'special' mode for this dialog in being the
178  // only caller of ::SetSdrObjectRef. Only in that case mpDestModel seems
179  // to be the correct target SdrModel.
180  // If this is not used, the correct SdrModel seems to be the one from
181  // the mrSdrView that is used to insert (InsertObjectAtView below) the
182  // cloned SdrObject.
183  const bool bUseSpecialCalcMode(nullptr != mppSdrObject && nullptr != mpDestModel);
184 
185  // center shape on current view
187 
188  if (pOutDev)
189  {
190  // Clone directly to target SdrModel (may be different due to user/caller (!))
191  SdrObject* pNewObject(
192  pPage->GetObj(0)->CloneSdrObject(
193  bUseSpecialCalcMode ? *mpDestModel : mrSdrView.getSdrModelFromSdrView()));
194 
195  // tdf#117629
196  // Since the 'old' ::CloneSdrObject also copies the SdrPage* the
197  // SdrObject::getUnoShape() *will* create the wrong UNO API object
198  // early. This IS one of the reasons I do change these things - this
199  // error does not happen with my next change I am working on already
200  // ARGH! For now, reset the SdrPage* to nullptr.
201  // What sense does it have to copy the SdrPage* of the original SdrObject ?!?
202  // TTTT: This also *might* be the hidden reason for the strange code at the
203  // end of SdrObject::SetPage that tries to delete the SvxShape under some
204  // circumstances...
205  // pNewObject->SetPage(nullptr);
206 
207  tools::Rectangle aObjRect( pNewObject->GetLogicRect() );
208  tools::Rectangle aVisArea = pOutDev->PixelToLogic(tools::Rectangle(Point(0,0), pOutDev->GetOutputSizePixel()));
209  Point aPagePos = aVisArea.Center();
210  aPagePos.AdjustX( -(aObjRect.GetWidth() / 2) );
211  aPagePos.AdjustY( -(aObjRect.GetHeight() / 2) );
212  tools::Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize());
213  pNewObject->SetLogicRect(aNewObjectRectangle);
214 
215  if (bUseSpecialCalcMode)
216  {
217  *mppSdrObject = pNewObject;
218  }
219  else
220  {
222 
223  if (nullptr != pPV)
224  {
225  mrSdrView.InsertObjectAtView( pNewObject, *pPV );
226  }
227  else
228  {
229  // tdf#116993 no target -> delete clone
230  SdrObject::Free(pNewObject);
231  }
232  }
233  }
234  }
235  }
236  }
237 }
238 
240 {
241  insertSelectedFontwork();
242  m_xDialog->response(RET_OK);
243 }
244 
245 IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, SvtValueSet*, void)
246 {
247  insertSelectedFontwork();
248  m_xDialog->response(RET_OK);
249 }
250 
251 namespace {
252 
253 class FontworkAlignmentWindow final : public WeldToolbarPopup
254 {
255 public:
256  FontworkAlignmentWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow);
257  virtual void GrabFocus() override
258  {
259  mxLeft->grab_focus();
260  }
261  virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
262 
263 private:
265  std::unique_ptr<weld::RadioButton> mxLeft;
266  std::unique_ptr<weld::RadioButton> mxCenter;
267  std::unique_ptr<weld::RadioButton> mxRight;
268  std::unique_ptr<weld::RadioButton> mxWord;
269  std::unique_ptr<weld::RadioButton> mxStretch;
270  bool mbSettingValue;
271 
272  DECL_LINK( SelectHdl, weld::ToggleButton&, void );
273 
274  void implSetAlignment( int nAlignmentMode, bool bEnabled );
275 };
276 
277 }
278 
279 static const OUStringLiteral gsFontworkAlignment(".uno:FontworkAlignment");
280 
281 FontworkAlignmentWindow::FontworkAlignmentWindow(svt::PopupWindowController* pControl, weld::Widget* pParent)
282  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkalignmentcontrol.ui", "FontworkAlignmentControl")
283  , mxControl(pControl)
284  , mxLeft(m_xBuilder->weld_radio_button("left"))
285  , mxCenter(m_xBuilder->weld_radio_button("center"))
286  , mxRight(m_xBuilder->weld_radio_button("right"))
287  , mxWord(m_xBuilder->weld_radio_button("word"))
288  , mxStretch(m_xBuilder->weld_radio_button("stretch"))
289  , mbSettingValue(false)
290 {
291  mxLeft->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
292  mxCenter->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
293  mxRight->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
294  mxWord->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
295  mxStretch->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
296 
297  AddStatusListener( gsFontworkAlignment );
298 }
299 
300 void FontworkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled )
301 {
302  bool bSettingValue = mbSettingValue;
303  mbSettingValue = true;
304  mxLeft->set_active(nSurface == 0 && bEnabled);
305  mxLeft->set_sensitive(bEnabled);
306  mxCenter->set_active(nSurface == 1 && bEnabled);
307  mxCenter->set_sensitive(bEnabled);
308  mxRight->set_active(nSurface == 2 && bEnabled);
309  mxRight->set_sensitive(bEnabled);
310  mxWord->set_active(nSurface == 3 && bEnabled);
311  mxWord->set_sensitive(bEnabled);
312  mxStretch->set_active(nSurface == 4 && bEnabled);
313  mxStretch->set_sensitive(bEnabled);
314  mbSettingValue = bSettingValue;
315 }
316 
317 void FontworkAlignmentWindow::statusChanged( const css::frame::FeatureStateEvent& Event )
318 {
319  if( Event.FeatureURL.Main == gsFontworkAlignment )
320  {
321  if( !Event.IsEnabled )
322  {
323  implSetAlignment( 0, false );
324  }
325  else
326  {
327  sal_Int32 nValue = 0;
328  if( Event.State >>= nValue )
329  implSetAlignment( nValue, true );
330  }
331  }
332 }
333 
334 IMPL_LINK(FontworkAlignmentWindow, SelectHdl, weld::ToggleButton&, rButton, void)
335 {
336  if (mbSettingValue || !rButton.get_active())
337  return;
338 
339  sal_Int32 nAlignment;
340  if (mxLeft->get_active())
341  nAlignment = 0;
342  else if (mxCenter->get_active())
343  nAlignment = 1;
344  else if (mxRight->get_active())
345  nAlignment = 2;
346  else if (mxWord->get_active())
347  nAlignment = 3;
348  else
349  nAlignment = 4;
350 
351  Sequence< PropertyValue > aArgs( 1 );
352  aArgs[0].Name = OUString(gsFontworkAlignment).copy(5);
353  aArgs[0].Value <<= nAlignment;
354 
355  mxControl->dispatchCommand( gsFontworkAlignment, aArgs );
356 
357  implSetAlignment( nAlignment, true );
358 
359  mxControl->EndPopupMode();
360 }
361 
362 namespace {
363 
364 class FontworkAlignmentControl : public svt::PopupWindowController
365 {
366 public:
367  explicit FontworkAlignmentControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
368 
369  virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
370  virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
371 
372  // XInitialization
373  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
374 
375  // XServiceInfo
376  virtual OUString SAL_CALL getImplementationName() override;
377  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
378 };
379 
380 }
381 
382 FontworkAlignmentControl::FontworkAlignmentControl( const Reference< XComponentContext >& rxContext )
383 : svt::PopupWindowController( rxContext, Reference< css::frame::XFrame >(), ".uno:FontworkAlignment" )
384 {
385 }
386 
387 std::unique_ptr<WeldToolbarPopup> FontworkAlignmentControl::weldPopupWindow()
388 {
389  return std::make_unique<FontworkAlignmentWindow>(this, m_pToolbar);
390 }
391 
392 VclPtr<vcl::Window> FontworkAlignmentControl::createVclPopupWindow( vcl::Window* pParent )
393 {
394  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
395  std::make_unique<FontworkAlignmentWindow>(this, pParent->GetFrameWeld()));
396 
397  mxInterimPopover->Show();
398 
399  return mxInterimPopover;
400 }
401 
402 // XInitialization
403 void SAL_CALL FontworkAlignmentControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
404 {
405  svt::PopupWindowController::initialize( aArguments );
406 
407  ToolBox* pToolBox = nullptr;
408  sal_uInt16 nId = 0;
409  if ( getToolboxId( nId, &pToolBox ) )
410  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
411 }
412 
413 // XServiceInfo
414 
415 
416 OUString FontworkAlignmentControl::getImplementationName()
417 {
418  return "com.sun.star.comp.svx.FontworkAlignmentController";
419 }
420 
421 
422 Sequence< OUString > FontworkAlignmentControl::getSupportedServiceNames()
423 {
424  return { "com.sun.star.frame.ToolbarController" };
425 }
426 
427 
428 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
430  css::uno::XComponentContext* xContext,
431  css::uno::Sequence<css::uno::Any> const &)
432 {
433  return cppu::acquire(new FontworkAlignmentControl(xContext));
434 }
435 
436 namespace {
437 
438 class FontworkCharacterSpacingWindow final : public WeldToolbarPopup
439 {
440 public:
441  FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow);
442  virtual void GrabFocus() override;
443 
444  virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
445 private:
447  std::unique_ptr<weld::RadioButton> mxVeryTight;
448  std::unique_ptr<weld::RadioButton> mxTight;
449  std::unique_ptr<weld::RadioButton> mxNormal;
450  std::unique_ptr<weld::RadioButton> mxLoose;
451  std::unique_ptr<weld::RadioButton> mxVeryLoose;
452  std::unique_ptr<weld::RadioButton> mxCustom;
453  std::unique_ptr<weld::CheckButton> mxKernPairs;
454  bool mbSettingValue;
455 
456  DECL_LINK( SelectHdl, weld::ToggleButton&, void );
457  DECL_LINK( ClickHdl, weld::Button&, void );
458 
459  void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled );
460  void implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled);
461 };
462 
463 }
464 
465 static const OUStringLiteral gsFontworkCharacterSpacing(".uno:FontworkCharacterSpacing");
466 static const OUStringLiteral gsFontworkKernCharacterPairs(".uno:FontworkKernCharacterPairs");
467 
468 FontworkCharacterSpacingWindow::FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParent)
469  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkcharacterspacingcontrol.ui", "FontworkCharacterSpacingControl")
470  , mxControl(pControl)
471  , mxVeryTight(m_xBuilder->weld_radio_button("verytight"))
472  , mxTight(m_xBuilder->weld_radio_button("tight"))
473  , mxNormal(m_xBuilder->weld_radio_button("normal"))
474  , mxLoose(m_xBuilder->weld_radio_button("loose"))
475  , mxVeryLoose(m_xBuilder->weld_radio_button("veryloose"))
476  , mxCustom(m_xBuilder->weld_radio_button("custom"))
477  , mxKernPairs(m_xBuilder->weld_check_button("kernpairs"))
478  , mbSettingValue(false)
479 {
480  mxVeryTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
481  mxTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
482  mxNormal->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
483  mxLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
484  mxVeryLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
485  mxCustom->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, ClickHdl));
486 
487  mxKernPairs->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
488 
489  AddStatusListener( gsFontworkCharacterSpacing );
490  AddStatusListener( gsFontworkKernCharacterPairs );
491 
492  // See TODO in svx/source/toolbars/fontworkbar.cxx for SID_FONTWORK_KERN_CHARACTER_PAIRS,
493  // the kernpairs setting is ignored, so hide the widget entirely
494  mxKernPairs->hide();
495 }
496 
497 void FontworkCharacterSpacingWindow::GrabFocus()
498 {
499  mxVeryTight->grab_focus();
500 }
501 
502 void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled )
503 {
504  bool bSettingValue = mbSettingValue;
505  mbSettingValue = true;
506 
507  mxVeryTight->set_sensitive(bEnabled);
508  mxTight->set_sensitive(bEnabled);
509  mxNormal->set_sensitive(bEnabled);
510  mxLoose->set_sensitive(bEnabled);
511  mxVeryLoose->set_sensitive(bEnabled);
512  mxCustom->set_sensitive(bEnabled);
513 
514  mxVeryTight->set_active(false);
515  mxTight->set_active(false);
516  mxNormal->set_active(false);
517  mxLoose->set_active(false);
518  mxVeryLoose->set_active(false);
519  mxCustom->set_active(true);
520 
521  switch(nCharacterSpacing)
522  {
523  case 80:
524  mxVeryTight->set_active(true);
525  break;
526  case 90:
527  mxTight->set_active(true);
528  break;
529  case 100:
530  mxNormal->set_active(true);
531  break;
532  case 120:
533  mxLoose->set_active(true);
534  break;
535  case 150:
536  mxVeryLoose->set_active(true);
537  break;
538  }
539 
540  mbSettingValue = bSettingValue;
541 }
542 
543 void FontworkCharacterSpacingWindow::implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled)
544 {
545  mxKernPairs->set_sensitive(bEnabled);
546  mxKernPairs->set_active(bKernOnOff);
547 }
548 
549 void FontworkCharacterSpacingWindow::statusChanged( const css::frame::FeatureStateEvent& Event )
550 {
551  if( Event.FeatureURL.Main == gsFontworkCharacterSpacing )
552  {
553  if( !Event.IsEnabled )
554  {
555  implSetCharacterSpacing( 0, false );
556  }
557  else
558  {
559  sal_Int32 nValue = 0;
560  if( Event.State >>= nValue )
561  implSetCharacterSpacing( nValue, true );
562  }
563  }
564  else if( Event.FeatureURL.Main == gsFontworkKernCharacterPairs )
565  {
566  if( !Event.IsEnabled )
567  {
568  implSetKernCharacterPairs(false, false);
569  }
570  else
571  {
572  bool bValue = false;
573  if( Event.State >>= bValue )
574  implSetKernCharacterPairs(bValue, true);
575  }
576  }
577 }
578 
579 IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, ClickHdl, weld::Button&, void)
580 {
581  SelectHdl(*mxCustom);
582 }
583 
584 IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::ToggleButton&, rButton, void)
585 {
586  if (mbSettingValue || !rButton.get_active())
587  return;
588 
589  if (&rButton == mxCustom.get())
590  {
591  Sequence< PropertyValue > aArgs( 1 );
592  aArgs[0].Name = OUString(gsFontworkCharacterSpacing).copy(5);
593  aArgs[0].Value <<= sal_Int32(100);
594 
595  rtl::Reference<svt::PopupWindowController> xControl(mxControl);
596  xControl->EndPopupMode();
597  xControl->dispatchCommand(".uno:FontworkCharacterSpacingDialog", aArgs);
598  }
599  else if (&rButton == mxKernPairs.get())
600  {
601  Sequence< PropertyValue > aArgs( 1 );
602  aArgs[0].Name = OUString(gsFontworkKernCharacterPairs).copy(5);
603  bool bKernOnOff = mxKernPairs->get_active();
604  aArgs[0].Value <<= bKernOnOff;
605 
606  mxControl->dispatchCommand( gsFontworkKernCharacterPairs, aArgs );
607 
608  implSetKernCharacterPairs(bKernOnOff, true);
609  }
610  else
611  {
612  sal_Int32 nCharacterSpacing;
613  if (&rButton == mxVeryTight.get())
614  nCharacterSpacing = 80;
615  else if (&rButton == mxTight.get())
616  nCharacterSpacing = 90;
617  else if (&rButton == mxLoose.get())
618  nCharacterSpacing = 120;
619  else if (&rButton == mxVeryLoose.get())
620  nCharacterSpacing = 150;
621  else
622  nCharacterSpacing = 100;
623 
624  Sequence< PropertyValue > aArgs( 1 );
625  aArgs[0].Name = OUString(gsFontworkCharacterSpacing).copy(5);
626  aArgs[0].Value <<= nCharacterSpacing;
627 
628  mxControl->dispatchCommand( gsFontworkCharacterSpacing, aArgs );
629 
630  implSetCharacterSpacing( nCharacterSpacing, true );
631  }
632 
633  mxControl->EndPopupMode();
634 }
635 
636 namespace {
637 
638 class FontworkCharacterSpacingControl : public svt::PopupWindowController
639 {
640 public:
641  explicit FontworkCharacterSpacingControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
642 
643  virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
644  virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
645 
646  // XInitialization
647  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
648 
649  // XServiceInfo
650  virtual OUString SAL_CALL getImplementationName() override;
651  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
652 };
653 
654 }
655 
656 FontworkCharacterSpacingControl::FontworkCharacterSpacingControl( const Reference< XComponentContext >& rxContext )
657 : svt::PopupWindowController( rxContext, Reference< css::frame::XFrame >(), ".uno:FontworkCharacterSpacingFloater" )
658 {
659 }
660 
661 std::unique_ptr<WeldToolbarPopup> FontworkCharacterSpacingControl::weldPopupWindow()
662 {
663  return std::make_unique<FontworkCharacterSpacingWindow>(this, m_pToolbar);
664 }
665 
666 VclPtr<vcl::Window> FontworkCharacterSpacingControl::createVclPopupWindow( vcl::Window* pParent )
667 {
668  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
669  std::make_unique<FontworkCharacterSpacingWindow>(this, pParent->GetFrameWeld()));
670 
671  mxInterimPopover->Show();
672 
673  return mxInterimPopover;
674 }
675 
676 // XInitialization
677 void SAL_CALL FontworkCharacterSpacingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
678 {
679  svt::PopupWindowController::initialize( aArguments );
680 
681  ToolBox* pToolBox = nullptr;
682  sal_uInt16 nId = 0;
683  if ( getToolboxId( nId, &pToolBox ) )
684  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
685 }
686 
687 // XServiceInfo
688 
689 
690 OUString FontworkCharacterSpacingControl::getImplementationName()
691 {
692  return "com.sun.star.comp.svx.FontworkCharacterSpacingController";
693 }
694 
695 
696 Sequence< OUString > FontworkCharacterSpacingControl::getSupportedServiceNames()
697 {
698  Sequence<OUString> aSNS { "com.sun.star.frame.ToolbarController" };
699  return aSNS;
700 }
701 
702 
703 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
705  css::uno::XComponentContext* xContext,
706  css::uno::Sequence<css::uno::Any> const &)
707 {
708  return cppu::acquire(new FontworkCharacterSpacingControl(xContext));
709 }
710 
711 FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog(weld::Window* pParent, sal_Int32 nScale)
712  : GenericDialogController(pParent, "svx/ui/fontworkspacingdialog.ui", "FontworkSpacingDialog")
713  , m_xMtrScale(m_xBuilder->weld_metric_spin_button("entry", FieldUnit::PERCENT))
714 {
715  m_xMtrScale->set_value(nScale, FieldUnit::PERCENT);
716 }
717 
719 {
720 }
721 
723 {
724  return static_cast<sal_Int32>(m_xMtrScale->get_value(FieldUnit::PERCENT));
725 }
726 
727 }
728 
729 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const int nColCount
FieldUnit
void SetSdrObjectRef(SdrObject **, SdrModel *pModel)
IMPL_LINK_NOARG(SuggestionDisplay, SelectSuggestionValueSetHdl, SvtValueSet *, void)
static sal_uInt32 GetSdrObjCount(const OUString &rThemeName)
Definition: galexpl.cxx:165
virtual OUString SAL_CALL getImplementationName() override=0
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
ToolBoxItemBits GetItemBits(sal_uInt16 nItemId) const
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:766
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override=0
size_t GetObjCount() const
Definition: svdpage.cxx:760
std::unique_ptr< weld::MetricSpinButton > m_xMtrScale
Reference
sal_Int16 nId
static bool BeginLocking(const OUString &rThemeName)
Definition: galexpl.cxx:236
virtual void statusChanged(const css::frame::FeatureStateEvent &Event)
WinBits const WB_VSCROLL
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:395
static bool EndLocking(const OUString &rThemeName)
Definition: galexpl.cxx:261
std::unique_ptr< weld::CustomWeld > mxCtlFavorites
static bool GetSdrObj(const OUString &rThemeName, sal_uInt32 nSdrModelPos, SdrModel *pModel, BitmapEx *pThumb=nullptr)
Definition: galexpl.cxx:194
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
Definition: svdedtv.cxx:955
WinBits GetStyle() const
weld::Window * GetFrameWeld() const
sal_Int64 WinBits
void SetDoubleClickHdl(const Link< SvtValueSet *, void > &rLink)
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
sal_uInt16 GetSelectedItemId() const
void Clear()
OutputDevice * GetFirstOutputDevice() const
Definition: svdpntv.cxx:87
std::vector< BitmapEx > maFavoritesHorizontal
FontWorkGalleryDialog(weld::Window *pParent, SdrView &rView)
void SetStyle(WinBits nStyle)
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow()
void initFavorites(sal_uInt16 nThemeId)
static const OUStringLiteral gsFontworkKernCharacterPairs(".uno:FontworkKernCharacterPairs")
void SetItemBits(sal_uInt16 nItemId, ToolBoxItemBits nBits)
IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, ClickHdl, weld::Button &, void)
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent)=0
DECL_LINK(FocusHdl, weld::Widget &, void)
virtual ~FontworkCharacterSpacingDialog() override
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1630
Abstract DrawObject.
Definition: svdobj.hxx:312
IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::ToggleButton &, rButton, void)
void fillFavorites(sal_uInt16 nThemeId)
void SetExtraSpacing(sal_uInt16 nNewSpacing)
void SetLineCount(sal_uInt16 nNewLines=0)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_FontworkCharacterSpacingControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
virtual ~FontWorkGalleryDialog() override
RET_OK
static VclPtr< reference_type > Create(Arg &&...arg)
virtual SdrObject * CloneSdrObject(SdrModel &rTargetModel) const
Definition: svdobj.cxx:973
Reference< XExecutableDialog > m_xDialog
const OUString PERCENT("Percent")
std::unique_ptr< weld::Button > mxOKButton
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:310
void SelectItem(sal_uInt16 nItemId)
void SetColCount(sal_uInt16 nNewCols=1)
SdrModel & getSdrModelFromSdrView() const
Definition: svdpntv.hxx:268
void InsertItem(sal_uInt16 nItemId, const Image &rImage)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_FontworkAlignmentControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
virtual const tools::Rectangle & GetLogicRect() const
Definition: svdobj.cxx:1606
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
const Size & GetSizePixel() const
const int nLineCount
void setWidth(long nWidth)
virtual void GrabFocus()=0
aStr
static const OUStringLiteral gsFontworkCharacterSpacing(".uno:FontworkCharacterSpacing")
size_t GetItemCount() const
static const OUStringLiteral gsFontworkAlignment(".uno:FontworkAlignment")
sal_Int16 nValue
Definition: fmsrccfg.cxx:81