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  return;
169 
170  std::unique_ptr<FmFormModel> pModel(new FmFormModel());
171  pModel->GetItemPool().FreezeIdRanges();
172 
173  if( !GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel.get() ) )
174  return;
175 
176  SdrPage* pPage = pModel->GetPage(0);
177  if( !(pPage && pPage->GetObjCount()) )
178  return;
179 
180  // tdf#116993 Calc uses a 'special' mode for this dialog in being the
181  // only caller of ::SetSdrObjectRef. Only in that case mpDestModel seems
182  // to be the correct target SdrModel.
183  // If this is not used, the correct SdrModel seems to be the one from
184  // the mrSdrView that is used to insert (InsertObjectAtView below) the
185  // cloned SdrObject.
186  const bool bUseSpecialCalcMode(nullptr != mppSdrObject && nullptr != mpDestModel);
187 
188  // center shape on current view
190 
191  if (!pOutDev)
192  return;
193 
194  // Clone directly to target SdrModel (may be different due to user/caller (!))
195  SdrObject* pNewObject(
196  pPage->GetObj(0)->CloneSdrObject(
197  bUseSpecialCalcMode ? *mpDestModel : mrSdrView.getSdrModelFromSdrView()));
198 
199  pNewObject->MakeNameUnique();
200 
201  // tdf#117629
202  // Since the 'old' ::CloneSdrObject also copies the SdrPage* the
203  // SdrObject::getUnoShape() *will* create the wrong UNO API object
204  // early. This IS one of the reasons I do change these things - this
205  // error does not happen with my next change I am working on already
206  // ARGH! For now, reset the SdrPage* to nullptr.
207  // What sense does it have to copy the SdrPage* of the original SdrObject ?!?
208  // TTTT: This also *might* be the hidden reason for the strange code at the
209  // end of SdrObject::SetPage that tries to delete the SvxShape under some
210  // circumstances...
211  // pNewObject->SetPage(nullptr);
212 
213  tools::Rectangle aObjRect( pNewObject->GetLogicRect() );
214  tools::Rectangle aVisArea = pOutDev->PixelToLogic(tools::Rectangle(Point(0,0), pOutDev->GetOutputSizePixel()));
215  Point aPagePos = aVisArea.Center();
216  aPagePos.AdjustX( -(aObjRect.GetWidth() / 2) );
217  aPagePos.AdjustY( -(aObjRect.GetHeight() / 2) );
218  tools::Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize());
219  pNewObject->SetLogicRect(aNewObjectRectangle);
220 
221  if (bUseSpecialCalcMode)
222  {
223  *mppSdrObject = pNewObject;
224  }
225  else
226  {
228 
229  if (nullptr != pPV)
230  {
231  mrSdrView.InsertObjectAtView( pNewObject, *pPV );
232  }
233  else
234  {
235  // tdf#116993 no target -> delete clone
236  SdrObject::Free(pNewObject);
237  }
238  }
239 }
240 
242 {
243  insertSelectedFontwork();
244  m_xDialog->response(RET_OK);
245 }
246 
247 IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, ValueSet*, void)
248 {
249  insertSelectedFontwork();
250  m_xDialog->response(RET_OK);
251 }
252 
253 namespace {
254 
255 class FontworkAlignmentWindow final : public WeldToolbarPopup
256 {
257 public:
258  FontworkAlignmentWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow);
259  virtual void GrabFocus() override
260  {
261  mxLeft->grab_focus();
262  }
263  virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
264 
265 private:
267  std::unique_ptr<weld::RadioButton> mxLeft;
268  std::unique_ptr<weld::RadioButton> mxCenter;
269  std::unique_ptr<weld::RadioButton> mxRight;
270  std::unique_ptr<weld::RadioButton> mxWord;
271  std::unique_ptr<weld::RadioButton> mxStretch;
272  bool mbSettingValue;
273 
274  DECL_LINK( SelectHdl, weld::ToggleButton&, void );
275 
276  void implSetAlignment( int nAlignmentMode, bool bEnabled );
277 };
278 
279 }
280 
281 const OUStringLiteral gsFontworkAlignment(u".uno:FontworkAlignment");
282 
283 FontworkAlignmentWindow::FontworkAlignmentWindow(svt::PopupWindowController* pControl, weld::Widget* pParent)
284  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkalignmentcontrol.ui", "FontworkAlignmentControl")
285  , mxControl(pControl)
286  , mxLeft(m_xBuilder->weld_radio_button("left"))
287  , mxCenter(m_xBuilder->weld_radio_button("center"))
288  , mxRight(m_xBuilder->weld_radio_button("right"))
289  , mxWord(m_xBuilder->weld_radio_button("word"))
290  , mxStretch(m_xBuilder->weld_radio_button("stretch"))
291  , mbSettingValue(false)
292 {
293  mxLeft->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
294  mxCenter->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
295  mxRight->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
296  mxWord->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
297  mxStretch->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
298 
299  AddStatusListener( gsFontworkAlignment );
300 }
301 
302 void FontworkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled )
303 {
304  bool bSettingValue = mbSettingValue;
305  mbSettingValue = true;
306  mxLeft->set_active(nSurface == 0 && bEnabled);
307  mxLeft->set_sensitive(bEnabled);
308  mxCenter->set_active(nSurface == 1 && bEnabled);
309  mxCenter->set_sensitive(bEnabled);
310  mxRight->set_active(nSurface == 2 && bEnabled);
311  mxRight->set_sensitive(bEnabled);
312  mxWord->set_active(nSurface == 3 && bEnabled);
313  mxWord->set_sensitive(bEnabled);
314  mxStretch->set_active(nSurface == 4 && bEnabled);
315  mxStretch->set_sensitive(bEnabled);
316  mbSettingValue = bSettingValue;
317 }
318 
319 void FontworkAlignmentWindow::statusChanged( const css::frame::FeatureStateEvent& Event )
320 {
321  if( Event.FeatureURL.Main != gsFontworkAlignment )
322  return;
323 
324  if( !Event.IsEnabled )
325  {
326  implSetAlignment( 0, false );
327  }
328  else
329  {
330  sal_Int32 nValue = 0;
331  if( Event.State >>= nValue )
332  implSetAlignment( nValue, true );
333  }
334 }
335 
336 IMPL_LINK(FontworkAlignmentWindow, SelectHdl, weld::ToggleButton&, rButton, void)
337 {
338  if (mbSettingValue || !rButton.get_active())
339  return;
340 
341  sal_Int32 nAlignment;
342  if (mxLeft->get_active())
343  nAlignment = 0;
344  else if (mxCenter->get_active())
345  nAlignment = 1;
346  else if (mxRight->get_active())
347  nAlignment = 2;
348  else if (mxWord->get_active())
349  nAlignment = 3;
350  else
351  nAlignment = 4;
352 
353  Sequence< PropertyValue > aArgs( 1 );
354  aArgs[0].Name = OUString(gsFontworkAlignment).copy(5);
355  aArgs[0].Value <<= nAlignment;
356 
357  mxControl->dispatchCommand( gsFontworkAlignment, aArgs );
358 
359  implSetAlignment( nAlignment, true );
360 
361  mxControl->EndPopupMode();
362 }
363 
364 namespace {
365 
366 class FontworkAlignmentControl : public svt::PopupWindowController
367 {
368 public:
369  explicit FontworkAlignmentControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
370 
371  virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
372  virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
373 
374  // XInitialization
375  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
376 
377  // XServiceInfo
378  virtual OUString SAL_CALL getImplementationName() override;
379  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
380 };
381 
382 }
383 
384 FontworkAlignmentControl::FontworkAlignmentControl( const Reference< XComponentContext >& rxContext )
385 : svt::PopupWindowController( rxContext, Reference< css::frame::XFrame >(), ".uno:FontworkAlignment" )
386 {
387 }
388 
389 std::unique_ptr<WeldToolbarPopup> FontworkAlignmentControl::weldPopupWindow()
390 {
391  return std::make_unique<FontworkAlignmentWindow>(this, m_pToolbar);
392 }
393 
394 VclPtr<vcl::Window> FontworkAlignmentControl::createVclPopupWindow( vcl::Window* pParent )
395 {
396  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
397  std::make_unique<FontworkAlignmentWindow>(this, pParent->GetFrameWeld()));
398 
399  mxInterimPopover->Show();
400 
401  return mxInterimPopover;
402 }
403 
404 // XInitialization
405 void SAL_CALL FontworkAlignmentControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
406 {
407  svt::PopupWindowController::initialize( aArguments );
408 
409  ToolBox* pToolBox = nullptr;
410  sal_uInt16 nId = 0;
411  if ( getToolboxId( nId, &pToolBox ) )
412  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
413 }
414 
415 // XServiceInfo
416 
417 
418 OUString FontworkAlignmentControl::getImplementationName()
419 {
420  return "com.sun.star.comp.svx.FontworkAlignmentController";
421 }
422 
423 
424 Sequence< OUString > FontworkAlignmentControl::getSupportedServiceNames()
425 {
426  return { "com.sun.star.frame.ToolbarController" };
427 }
428 
429 
430 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
432  css::uno::XComponentContext* xContext,
433  css::uno::Sequence<css::uno::Any> const &)
434 {
435  return cppu::acquire(new FontworkAlignmentControl(xContext));
436 }
437 
438 namespace {
439 
440 class FontworkCharacterSpacingWindow final : public WeldToolbarPopup
441 {
442 public:
443  FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow);
444  virtual void GrabFocus() override;
445 
446  virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
447 private:
449  std::unique_ptr<weld::RadioButton> mxVeryTight;
450  std::unique_ptr<weld::RadioButton> mxTight;
451  std::unique_ptr<weld::RadioButton> mxNormal;
452  std::unique_ptr<weld::RadioButton> mxLoose;
453  std::unique_ptr<weld::RadioButton> mxVeryLoose;
454  std::unique_ptr<weld::RadioButton> mxCustom;
455  std::unique_ptr<weld::CheckButton> mxKernPairs;
456  bool mbSettingValue;
457 
458  DECL_LINK( SelectHdl, weld::ToggleButton&, void );
459  DECL_LINK( ClickHdl, weld::Button&, void );
460 
461  void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled );
462  void implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled);
463 };
464 
465 }
466 
467 const OUStringLiteral gsFontworkCharacterSpacing(u".uno:FontworkCharacterSpacing");
468 const OUStringLiteral gsFontworkKernCharacterPairs(u".uno:FontworkKernCharacterPairs");
469 
470 FontworkCharacterSpacingWindow::FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParent)
471  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkcharacterspacingcontrol.ui", "FontworkCharacterSpacingControl")
472  , mxControl(pControl)
473  , mxVeryTight(m_xBuilder->weld_radio_button("verytight"))
474  , mxTight(m_xBuilder->weld_radio_button("tight"))
475  , mxNormal(m_xBuilder->weld_radio_button("normal"))
476  , mxLoose(m_xBuilder->weld_radio_button("loose"))
477  , mxVeryLoose(m_xBuilder->weld_radio_button("veryloose"))
478  , mxCustom(m_xBuilder->weld_radio_button("custom"))
479  , mxKernPairs(m_xBuilder->weld_check_button("kernpairs"))
480  , mbSettingValue(false)
481 {
482  mxVeryTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
483  mxTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
484  mxNormal->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
485  mxLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
486  mxVeryLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
487  mxCustom->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, ClickHdl));
488 
489  mxKernPairs->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
490 
491  AddStatusListener( gsFontworkCharacterSpacing );
492  AddStatusListener( gsFontworkKernCharacterPairs );
493 
494  // See TODO in svx/source/toolbars/fontworkbar.cxx for SID_FONTWORK_KERN_CHARACTER_PAIRS,
495  // the kernpairs setting is ignored, so hide the widget entirely
496  mxKernPairs->hide();
497 }
498 
499 void FontworkCharacterSpacingWindow::GrabFocus()
500 {
501  mxVeryTight->grab_focus();
502 }
503 
504 void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled )
505 {
506  bool bSettingValue = mbSettingValue;
507  mbSettingValue = true;
508 
509  mxVeryTight->set_sensitive(bEnabled);
510  mxTight->set_sensitive(bEnabled);
511  mxNormal->set_sensitive(bEnabled);
512  mxLoose->set_sensitive(bEnabled);
513  mxVeryLoose->set_sensitive(bEnabled);
514  mxCustom->set_sensitive(bEnabled);
515 
516  mxVeryTight->set_active(false);
517  mxTight->set_active(false);
518  mxNormal->set_active(false);
519  mxLoose->set_active(false);
520  mxVeryLoose->set_active(false);
521  mxCustom->set_active(true);
522 
523  switch(nCharacterSpacing)
524  {
525  case 80:
526  mxVeryTight->set_active(true);
527  break;
528  case 90:
529  mxTight->set_active(true);
530  break;
531  case 100:
532  mxNormal->set_active(true);
533  break;
534  case 120:
535  mxLoose->set_active(true);
536  break;
537  case 150:
538  mxVeryLoose->set_active(true);
539  break;
540  }
541 
542  mbSettingValue = bSettingValue;
543 }
544 
545 void FontworkCharacterSpacingWindow::implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled)
546 {
547  mxKernPairs->set_sensitive(bEnabled);
548  mxKernPairs->set_active(bKernOnOff);
549 }
550 
551 void FontworkCharacterSpacingWindow::statusChanged( const css::frame::FeatureStateEvent& Event )
552 {
553  if( Event.FeatureURL.Main == gsFontworkCharacterSpacing )
554  {
555  if( !Event.IsEnabled )
556  {
557  implSetCharacterSpacing( 0, false );
558  }
559  else
560  {
561  sal_Int32 nValue = 0;
562  if( Event.State >>= nValue )
563  implSetCharacterSpacing( nValue, true );
564  }
565  }
566  else if( Event.FeatureURL.Main == gsFontworkKernCharacterPairs )
567  {
568  if( !Event.IsEnabled )
569  {
570  implSetKernCharacterPairs(false, false);
571  }
572  else
573  {
574  bool bValue = false;
575  if( Event.State >>= bValue )
576  implSetKernCharacterPairs(bValue, true);
577  }
578  }
579 }
580 
581 IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, ClickHdl, weld::Button&, void)
582 {
583  SelectHdl(*mxCustom);
584 }
585 
586 IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::ToggleButton&, rButton, void)
587 {
588  if (mbSettingValue || !rButton.get_active())
589  return;
590 
591  if (&rButton == mxCustom.get())
592  {
593  Sequence< PropertyValue > aArgs( 1 );
594  aArgs[0].Name = OUString(gsFontworkCharacterSpacing).copy(5);
595  aArgs[0].Value <<= sal_Int32(100);
596 
597  rtl::Reference<svt::PopupWindowController> xControl(mxControl);
598  xControl->EndPopupMode();
599  xControl->dispatchCommand(".uno:FontworkCharacterSpacingDialog", aArgs);
600  }
601  else if (&rButton == mxKernPairs.get())
602  {
603  Sequence< PropertyValue > aArgs( 1 );
604  aArgs[0].Name = OUString(gsFontworkKernCharacterPairs).copy(5);
605  bool bKernOnOff = mxKernPairs->get_active();
606  aArgs[0].Value <<= bKernOnOff;
607 
608  mxControl->dispatchCommand( gsFontworkKernCharacterPairs, aArgs );
609 
610  implSetKernCharacterPairs(bKernOnOff, true);
611  }
612  else
613  {
614  sal_Int32 nCharacterSpacing;
615  if (&rButton == mxVeryTight.get())
616  nCharacterSpacing = 80;
617  else if (&rButton == mxTight.get())
618  nCharacterSpacing = 90;
619  else if (&rButton == mxLoose.get())
620  nCharacterSpacing = 120;
621  else if (&rButton == mxVeryLoose.get())
622  nCharacterSpacing = 150;
623  else
624  nCharacterSpacing = 100;
625 
626  Sequence< PropertyValue > aArgs( 1 );
627  aArgs[0].Name = OUString(gsFontworkCharacterSpacing).copy(5);
628  aArgs[0].Value <<= nCharacterSpacing;
629 
630  mxControl->dispatchCommand( gsFontworkCharacterSpacing, aArgs );
631 
632  implSetCharacterSpacing( nCharacterSpacing, true );
633  }
634 
635  mxControl->EndPopupMode();
636 }
637 
638 namespace {
639 
640 class FontworkCharacterSpacingControl : public svt::PopupWindowController
641 {
642 public:
643  explicit FontworkCharacterSpacingControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
644 
645  virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
646  virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
647 
648  // XInitialization
649  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
650 
651  // XServiceInfo
652  virtual OUString SAL_CALL getImplementationName() override;
653  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
654 };
655 
656 }
657 
658 FontworkCharacterSpacingControl::FontworkCharacterSpacingControl( const Reference< XComponentContext >& rxContext )
659 : svt::PopupWindowController( rxContext, Reference< css::frame::XFrame >(), ".uno:FontworkCharacterSpacingFloater" )
660 {
661 }
662 
663 std::unique_ptr<WeldToolbarPopup> FontworkCharacterSpacingControl::weldPopupWindow()
664 {
665  return std::make_unique<FontworkCharacterSpacingWindow>(this, m_pToolbar);
666 }
667 
668 VclPtr<vcl::Window> FontworkCharacterSpacingControl::createVclPopupWindow( vcl::Window* pParent )
669 {
670  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
671  std::make_unique<FontworkCharacterSpacingWindow>(this, pParent->GetFrameWeld()));
672 
673  mxInterimPopover->Show();
674 
675  return mxInterimPopover;
676 }
677 
678 // XInitialization
679 void SAL_CALL FontworkCharacterSpacingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
680 {
681  svt::PopupWindowController::initialize( aArguments );
682 
683  ToolBox* pToolBox = nullptr;
684  sal_uInt16 nId = 0;
685  if ( getToolboxId( nId, &pToolBox ) )
686  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
687 }
688 
689 // XServiceInfo
690 
691 
692 OUString FontworkCharacterSpacingControl::getImplementationName()
693 {
694  return "com.sun.star.comp.svx.FontworkCharacterSpacingController";
695 }
696 
697 
698 Sequence< OUString > FontworkCharacterSpacingControl::getSupportedServiceNames()
699 {
700  Sequence<OUString> aSNS { "com.sun.star.frame.ToolbarController" };
701  return aSNS;
702 }
703 
704 
705 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
707  css::uno::XComponentContext* xContext,
708  css::uno::Sequence<css::uno::Any> const &)
709 {
710  return cppu::acquire(new FontworkCharacterSpacingControl(xContext));
711 }
712 
713 FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog(weld::Window* pParent, sal_Int32 nScale)
714  : GenericDialogController(pParent, "svx/ui/fontworkspacingdialog.ui", "FontworkSpacingDialog")
715  , m_xMtrScale(m_xBuilder->weld_metric_spin_button("entry", FieldUnit::PERCENT))
716 {
717  m_xMtrScale->set_value(nScale, FieldUnit::PERCENT);
718 }
719 
721 {
722 }
723 
725 {
726  return static_cast<sal_Int32>(m_xMtrScale->get_value(FieldUnit::PERCENT));
727 }
728 
729 }
730 
731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const int nColCount
FieldUnit
void SetSdrObjectRef(SdrObject **, SdrModel *pModel)
static sal_uInt32 GetSdrObjCount(const OUString &rThemeName)
Definition: galexpl.cxx:165
virtual OUString SAL_CALL getImplementationName() override=0
const OUStringLiteral gsFontworkKernCharacterPairs(u".uno:FontworkKernCharacterPairs")
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
ToolBoxItemBits GetItemBits(sal_uInt16 nItemId) const
const OUStringLiteral gsFontworkAlignment(u".uno:FontworkAlignment")
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:758
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override=0
size_t GetObjCount() const
Definition: svdpage.cxx:752
std::unique_ptr< weld::MetricSpinButton > m_xMtrScale
Reference
sal_Int16 nId
static bool BeginLocking(const OUString &rThemeName)
Definition: galexpl.cxx:236
sal_uInt16 GetSelectedItemId() const
WinBits const WB_VSCROLL
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:396
static bool EndLocking(const OUString &rThemeName)
Definition: galexpl.cxx:261
std::unique_ptr< weld::CustomWeld > mxCtlFavorites
void SetStyle(WinBits nStyle)
void SetLineCount(sal_uInt16 nNewLines=0)
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
void Clear()
weld::Window * GetFrameWeld() const
sal_Int64 WinBits
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
exports com.sun.star. frame
void MakeNameUnique()
Definition: svdobj.cxx:3000
virtual void statusChanged(const css::frame::FeatureStateEvent &Event)
OutputDevice * GetFirstOutputDevice() const
Definition: svdpntv.cxx:87
WinBits GetStyle() const
void SetDoubleClickHdl(const Link< ValueSet *, void > &rLink)
std::vector< BitmapEx > maFavoritesHorizontal
IMPL_LINK_NOARG(SuggestionDisplay, SelectSuggestionValueSetHdl, ValueSet *, void)
FontWorkGalleryDialog(weld::Window *pParent, SdrView &rView)
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow()
const OUStringLiteral gsFontworkCharacterSpacing(u".uno:FontworkCharacterSpacing")
void initFavorites(sal_uInt16 nThemeId)
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)
void InsertItem(sal_uInt16 nItemId, const Image &rImage)
virtual ~FontworkCharacterSpacingDialog() override
const OUStringLiteral PERCENT(u"Percent")
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1632
Abstract DrawObject.
Definition: svdobj.hxx:312
IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::ToggleButton &, rButton, void)
void fillFavorites(sal_uInt16 nThemeId)
void SelectItem(sal_uInt16 nItemId)
void SetExtraSpacing(sal_uInt16 nNewSpacing)
size_t GetItemCount() const
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
void SetColCount(sal_uInt16 nNewCols=1)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
RET_OK
static VclPtr< reference_type > Create(Arg &&...arg)
virtual SdrObject * CloneSdrObject(SdrModel &rTargetModel) const
Definition: svdobj.cxx:974
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::Button > mxOKButton
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:304
SdrModel & getSdrModelFromSdrView() const
Definition: svdpntv.hxx:262
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:1608
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
const Size & GetSizePixel() const
const int nLineCount
void setWidth(long nWidth)
virtual void GrabFocus()=0
aStr
sal_Int16 nValue
Definition: fmsrccfg.cxx:81