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 <comphelper/lok.hxx>
24 
25 #include <vcl/toolbox.hxx>
26 #include <vcl/virdev.hxx>
27 
28 #include <sfx2/viewsh.hxx>
29 
30 #include <svl/itempool.hxx>
31 
32 #include <svtools/toolbarmenu.hxx>
34 
35 #include <svx/fmmodel.hxx>
36 #include <svx/strings.hrc>
37 #include <svx/svdpage.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/svdview.hxx>
40 
41 #include <svx/gallery.hxx>
42 #include <svx/fontworkgallery.hxx>
43 
44 #include <tools/UnitConversion.hxx>
45 
46 #include <algorithm>
47 #include <memory>
48 
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::beans;
52 
53 namespace svx
54 {
55 
57  : GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog")
58  , mnThemeId(0xffff)
59  , mrSdrView(rSdrView)
60  , mbInsertIntoPage(true)
61  , mppSdrObject(nullptr)
62  , mpDestModel(nullptr)
63  , maCtlFavorites(m_xBuilder->weld_icon_view("ctlFavoriteswin"))
64  , mxOKButton(m_xBuilder->weld_button("ok"))
65 {
66  Size aSize(530, 400);
67  maCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
68 
69  maCtlFavorites->connect_item_activated( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
70  mxOKButton->connect_clicked(LINK(this, FontWorkGalleryDialog, ClickOKHdl));
71 
74 }
75 
77 {
78 }
79 
80 void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
81 {
82  // the favorites are read via the gallery
83  sal_uInt32 nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId );
84 
85  // lock gallery theme
87 
88  sal_uInt32 nModelPos;
89  FmFormModel *pModel = nullptr;
90 
91  for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ )
92  {
93  BitmapEx aThumb;
94 
95  if (GalleryExplorer::GetSdrObj(nThemeId, nModelPos, pModel, &aThumb) && !aThumb.IsEmpty())
96  {
98  const Point aNull(0, 0);
99 
100  if (pVDev->GetDPIScaleFactor() > 1)
101  aThumb.Scale(pVDev->GetDPIScaleFactor(), pVDev->GetDPIScaleFactor());
102 
103  const Size aSize(aThumb.GetSizePixel());
104 
105  pVDev->SetOutputSizePixel(aSize);
106 
107  static const sal_uInt32 nLen(8);
108  static const Color aW(COL_WHITE);
109  static const Color aG(0xef, 0xef, 0xef);
110 
111  pVDev->DrawCheckered(aNull, aSize, nLen, aW, aG);
112 
113  pVDev->DrawBitmapEx(aNull, aThumb);
114  maFavoritesHorizontal.emplace_back(pVDev);
115  }
116  }
117 
118  // release gallery theme
119  GalleryExplorer::EndLocking(nThemeId);
120 }
121 
122 void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
123 {
124  mnThemeId = nThemeId;
125 
126  auto nFavCount = maFavoritesHorizontal.size();
127 
128  maCtlFavorites->clear();
129 
130  for( size_t nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
131  {
132  OUString sId = OUString::number(static_cast<sal_uInt16>(nFavorite));
133  maCtlFavorites->append(sId, "", maFavoritesHorizontal[nFavorite-1]);
134  }
135 
136  if (maCtlFavorites->n_children())
137  maCtlFavorites->select(0);
138 }
139 
141 {
142  mbInsertIntoPage = false;
143  mpDestModel = pModel;
144 }
145 
147 {
148  OUString sItemId = maCtlFavorites->get_selected_id();
149  if (sItemId.isEmpty())
150  return;
151 
152  sal_Int32 nItemId = sItemId.toInt32();
153 
154  if (nItemId == 0)
155  return;
156 
157  FmFormModel aModel;
158  aModel.GetItemPool().FreezeIdRanges();
159 
160  if( !GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, &aModel ) )
161  return;
162 
163  SdrPage* pPage = aModel.GetPage(0);
164  if( !(pPage && pPage->GetObjCount()) )
165  return;
166 
167  // tdf#116993 Calc uses a 'special' mode for this dialog in being the
168  // only caller of ::SetSdrObjectRef. Only in that case mpDestModel seems
169  // to be the correct target SdrModel.
170  // If this is not used, the correct SdrModel seems to be the one from
171  // the mrSdrView that is used to insert (InsertObjectAtView below) the
172  // cloned SdrObject.
173  const bool bUseSpecialCalcMode(!mbInsertIntoPage && nullptr != mpDestModel);
174 
175  // center shape on current view
177 
178  if (!pOutDev)
179  return;
180 
181  // Clone directly to target SdrModel (may be different due to user/caller (!))
182  SdrObject* pNewObject(
183  pPage->GetObj(0)->CloneSdrObject(
184  bUseSpecialCalcMode ? *mpDestModel : mrSdrView.getSdrModelFromSdrView()));
185 
186  pNewObject->MakeNameUnique();
187 
188  // tdf#117629
189  // Since the 'old' ::CloneSdrObject also copies the SdrPage* the
190  // SdrObject::getUnoShape() *will* create the wrong UNO API object
191  // early. This IS one of the reasons I do change these things - this
192  // error does not happen with my next change I am working on already
193  // ARGH! For now, reset the SdrPage* to nullptr.
194  // What sense does it have to copy the SdrPage* of the original SdrObject ?!?
195  // TTTT: This also *might* be the hidden reason for the strange code at the
196  // end of SdrObject::SetPage that tries to delete the SvxShape under some
197  // circumstances...
198  // pNewObject->SetPage(nullptr);
199 
200  tools::Rectangle aObjRect( pNewObject->GetLogicRect() );
201  Point aPagePos;
202  Size aFontworkSize = aObjRect.GetSize();
203 
205  {
206  SfxViewShell* pViewShell = SfxViewShell::Current();
207 
208  aPagePos = pViewShell->getLOKVisibleArea().Center();
209 
210  aPagePos.setX(convertTwipToMm100(aPagePos.X()));
211  aPagePos.setY(convertTwipToMm100(aPagePos.Y()));
212 
213  sal_Int32 nLOKViewWidth = 0.8 * convertTwipToMm100(pViewShell->getLOKVisibleArea().getWidth());
214  if (aFontworkSize.getWidth() > nLOKViewWidth)
215  {
216  double fScale = static_cast<double>(aFontworkSize.getWidth()) / nLOKViewWidth;
217  aFontworkSize.setWidth(aFontworkSize.getWidth() / fScale);
218  aFontworkSize.setHeight(aFontworkSize.getHeight() / fScale);
219  }
220  }
221  else
222  {
223  Size aSize = pOutDev->GetOutputSizePixel();
224  tools::Rectangle aPixelVisRect(Point(0,0), aSize);
225  tools::Rectangle aVisArea = pOutDev->PixelToLogic(aPixelVisRect);
226 
227  aPagePos = aVisArea.Center();
228  }
229 
230  if (aPagePos.getX() > aFontworkSize.getWidth() / 2)
231  aPagePos.AdjustX( -(aFontworkSize.getWidth() / 2) );
232  if (aPagePos.getY() > aFontworkSize.getHeight() / 2)
233  aPagePos.AdjustY( -(aFontworkSize.getHeight() / 2) );
234 
235  tools::Rectangle aNewObjectRectangle(aPagePos, aFontworkSize);
236  pNewObject->SetLogicRect(aNewObjectRectangle);
237 
238  if (bUseSpecialCalcMode)
239  {
240  mppSdrObject = pNewObject;
241  }
242  else
243  {
245 
246  if (nullptr != pPV)
247  {
248  mrSdrView.InsertObjectAtView( pNewObject, *pPV );
249  }
250  else
251  {
252  // tdf#116993 no target -> delete clone
253  SdrObject::Free(pNewObject);
254  }
255  }
256 }
257 
259 {
260  insertSelectedFontwork();
261  m_xDialog->response(RET_OK);
262 }
263 
264 IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, weld::IconView&, bool)
265 {
266  insertSelectedFontwork();
267  m_xDialog->response(RET_OK);
268  return true;
269 }
270 
271 namespace {
272 
273 class FontworkAlignmentWindow final : public WeldToolbarPopup
274 {
275 public:
276  FontworkAlignmentWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow);
277  virtual void GrabFocus() override
278  {
279  mxLeft->grab_focus();
280  }
281  virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
282 
283 private:
285  std::unique_ptr<weld::RadioButton> mxLeft;
286  std::unique_ptr<weld::RadioButton> mxCenter;
287  std::unique_ptr<weld::RadioButton> mxRight;
288  std::unique_ptr<weld::RadioButton> mxWord;
289  std::unique_ptr<weld::RadioButton> mxStretch;
290  bool mbSettingValue;
291 
292  DECL_LINK( SelectHdl, weld::Toggleable&, void );
293 
294  void implSetAlignment( int nAlignmentMode, bool bEnabled );
295 };
296 
297 }
298 
299 constexpr OUStringLiteral gsFontworkAlignment(u".uno:FontworkAlignment");
300 
301 FontworkAlignmentWindow::FontworkAlignmentWindow(svt::PopupWindowController* pControl, weld::Widget* pParent)
302  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkalignmentcontrol.ui", "FontworkAlignmentControl")
303  , mxControl(pControl)
304  , mxLeft(m_xBuilder->weld_radio_button("left"))
305  , mxCenter(m_xBuilder->weld_radio_button("center"))
306  , mxRight(m_xBuilder->weld_radio_button("right"))
307  , mxWord(m_xBuilder->weld_radio_button("word"))
308  , mxStretch(m_xBuilder->weld_radio_button("stretch"))
309  , mbSettingValue(false)
310 {
311  mxLeft->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
312  mxCenter->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
313  mxRight->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
314  mxWord->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
315  mxStretch->connect_toggled(LINK(this, FontworkAlignmentWindow, SelectHdl));
316 
317  AddStatusListener( gsFontworkAlignment );
318 }
319 
320 void FontworkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled )
321 {
322  bool bSettingValue = mbSettingValue;
323  mbSettingValue = true;
324  mxLeft->set_active(nSurface == 0 && bEnabled);
325  mxLeft->set_sensitive(bEnabled);
326  mxCenter->set_active(nSurface == 1 && bEnabled);
327  mxCenter->set_sensitive(bEnabled);
328  mxRight->set_active(nSurface == 2 && bEnabled);
329  mxRight->set_sensitive(bEnabled);
330  mxWord->set_active(nSurface == 3 && bEnabled);
331  mxWord->set_sensitive(bEnabled);
332  mxStretch->set_active(nSurface == 4 && bEnabled);
333  mxStretch->set_sensitive(bEnabled);
334  mbSettingValue = bSettingValue;
335 }
336 
337 void FontworkAlignmentWindow::statusChanged( const css::frame::FeatureStateEvent& Event )
338 {
339  if( Event.FeatureURL.Main != gsFontworkAlignment )
340  return;
341 
342  if( !Event.IsEnabled )
343  {
344  implSetAlignment( 0, false );
345  }
346  else
347  {
348  sal_Int32 nValue = 0;
349  if( Event.State >>= nValue )
350  implSetAlignment( nValue, true );
351  }
352 }
353 
354 IMPL_LINK(FontworkAlignmentWindow, SelectHdl, weld::Toggleable&, rButton, void)
355 {
356  if (mbSettingValue || !rButton.get_active())
357  return;
358 
359  sal_Int32 nAlignment;
360  if (mxLeft->get_active())
361  nAlignment = 0;
362  else if (mxCenter->get_active())
363  nAlignment = 1;
364  else if (mxRight->get_active())
365  nAlignment = 2;
366  else if (mxWord->get_active())
367  nAlignment = 3;
368  else
369  nAlignment = 4;
370 
371  Sequence< PropertyValue > aArgs( 1 );
372  aArgs[0].Name = OUString(gsFontworkAlignment).copy(5);
373  aArgs[0].Value <<= nAlignment;
374 
375  mxControl->dispatchCommand( gsFontworkAlignment, aArgs );
376 
377  implSetAlignment( nAlignment, true );
378 
379  mxControl->EndPopupMode();
380 }
381 
382 namespace {
383 
384 class FontworkAlignmentControl : public svt::PopupWindowController
385 {
386 public:
387  explicit FontworkAlignmentControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
388 
389  virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
390  virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
391 
392  // XInitialization
393  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
394 
395  // XServiceInfo
396  virtual OUString SAL_CALL getImplementationName() override;
397  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
398 };
399 
400 }
401 
402 FontworkAlignmentControl::FontworkAlignmentControl( const Reference< XComponentContext >& rxContext )
403 : svt::PopupWindowController( rxContext, Reference< css::frame::XFrame >(), ".uno:FontworkAlignment" )
404 {
405 }
406 
407 std::unique_ptr<WeldToolbarPopup> FontworkAlignmentControl::weldPopupWindow()
408 {
409  return std::make_unique<FontworkAlignmentWindow>(this, m_pToolbar);
410 }
411 
412 VclPtr<vcl::Window> FontworkAlignmentControl::createVclPopupWindow( vcl::Window* pParent )
413 {
414  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
415  std::make_unique<FontworkAlignmentWindow>(this, pParent->GetFrameWeld()));
416 
417  mxInterimPopover->Show();
418 
419  return mxInterimPopover;
420 }
421 
422 // XInitialization
423 void SAL_CALL FontworkAlignmentControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
424 {
425  svt::PopupWindowController::initialize( aArguments );
426 
427  if (m_pToolbar)
428  {
429  mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
430  m_pToolbar->set_item_popover(m_aCommandURL.toUtf8(), mxPopoverContainer->getTopLevel());
431  }
432 
433  ToolBox* pToolBox = nullptr;
435  if ( getToolboxId( nId, &pToolBox ) )
436  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
437 }
438 
439 // XServiceInfo
440 
441 
442 OUString FontworkAlignmentControl::getImplementationName()
443 {
444  return "com.sun.star.comp.svx.FontworkAlignmentController";
445 }
446 
447 
448 Sequence< OUString > FontworkAlignmentControl::getSupportedServiceNames()
449 {
450  return { "com.sun.star.frame.ToolbarController" };
451 }
452 
453 
454 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
456  css::uno::XComponentContext* xContext,
457  css::uno::Sequence<css::uno::Any> const &)
458 {
459  return cppu::acquire(new FontworkAlignmentControl(xContext));
460 }
461 
462 namespace {
463 
464 class FontworkCharacterSpacingWindow final : public WeldToolbarPopup
465 {
466 public:
467  FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow);
468  virtual void GrabFocus() override;
469 
470  virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override;
471 private:
473  std::unique_ptr<weld::RadioButton> mxVeryTight;
474  std::unique_ptr<weld::RadioButton> mxTight;
475  std::unique_ptr<weld::RadioButton> mxNormal;
476  std::unique_ptr<weld::RadioButton> mxLoose;
477  std::unique_ptr<weld::RadioButton> mxVeryLoose;
478  std::unique_ptr<weld::RadioButton> mxCustom;
479  std::unique_ptr<weld::CheckButton> mxKernPairs;
480  bool mbSettingValue;
481 
482  DECL_LINK( KernSelectHdl, weld::Toggleable&, void );
483  DECL_LINK( SelectHdl, weld::Toggleable&, void );
484 
485  void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled );
486  void implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled);
487 };
488 
489 }
490 
491 constexpr OUStringLiteral gsFontworkCharacterSpacing(u".uno:FontworkCharacterSpacing");
492 constexpr OUStringLiteral gsFontworkKernCharacterPairs(u".uno:FontworkKernCharacterPairs");
493 
494 FontworkCharacterSpacingWindow::FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParent)
495  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkcharacterspacingcontrol.ui", "FontworkCharacterSpacingControl")
496  , mxControl(pControl)
497  , mxVeryTight(m_xBuilder->weld_radio_button("verytight"))
498  , mxTight(m_xBuilder->weld_radio_button("tight"))
499  , mxNormal(m_xBuilder->weld_radio_button("normal"))
500  , mxLoose(m_xBuilder->weld_radio_button("loose"))
501  , mxVeryLoose(m_xBuilder->weld_radio_button("veryloose"))
502  , mxCustom(m_xBuilder->weld_radio_button("custom"))
503  , mxKernPairs(m_xBuilder->weld_check_button("kernpairs"))
504  , mbSettingValue(false)
505 {
506  mxVeryTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
507  mxTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
508  mxNormal->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
509  mxLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
510  mxVeryLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
511  mxCustom->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl));
512 
513  mxKernPairs->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, KernSelectHdl));
514 
515  AddStatusListener( gsFontworkCharacterSpacing );
516  AddStatusListener( gsFontworkKernCharacterPairs );
517 
518  // See TODO in svx/source/toolbars/fontworkbar.cxx for SID_FONTWORK_KERN_CHARACTER_PAIRS,
519  // the kernpairs setting is ignored, so hide the widget entirely
520  mxKernPairs->hide();
521 }
522 
523 void FontworkCharacterSpacingWindow::GrabFocus()
524 {
525  mxVeryTight->grab_focus();
526 }
527 
528 void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled )
529 {
530  bool bSettingValue = mbSettingValue;
531  mbSettingValue = true;
532 
533  mxVeryTight->set_sensitive(bEnabled);
534  mxTight->set_sensitive(bEnabled);
535  mxNormal->set_sensitive(bEnabled);
536  mxLoose->set_sensitive(bEnabled);
537  mxVeryLoose->set_sensitive(bEnabled);
538  mxCustom->set_sensitive(bEnabled);
539 
540  mxVeryTight->set_active(false);
541  mxTight->set_active(false);
542  mxNormal->set_active(false);
543  mxLoose->set_active(false);
544  mxVeryLoose->set_active(false);
545  mxCustom->set_active(true);
546 
547  switch(nCharacterSpacing)
548  {
549  case 80:
550  mxVeryTight->set_active(true);
551  break;
552  case 90:
553  mxTight->set_active(true);
554  break;
555  case 100:
556  mxNormal->set_active(true);
557  break;
558  case 120:
559  mxLoose->set_active(true);
560  break;
561  case 150:
562  mxVeryLoose->set_active(true);
563  break;
564  }
565 
566  mbSettingValue = bSettingValue;
567 }
568 
569 void FontworkCharacterSpacingWindow::implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled)
570 {
571  mxKernPairs->set_sensitive(bEnabled);
572  mxKernPairs->set_active(bKernOnOff);
573 }
574 
575 void FontworkCharacterSpacingWindow::statusChanged( const css::frame::FeatureStateEvent& Event )
576 {
577  if( Event.FeatureURL.Main == gsFontworkCharacterSpacing )
578  {
579  if( !Event.IsEnabled )
580  {
581  implSetCharacterSpacing( 0, false );
582  }
583  else
584  {
585  sal_Int32 nValue = 0;
586  if( Event.State >>= nValue )
587  implSetCharacterSpacing( nValue, true );
588  }
589  }
590  else if( Event.FeatureURL.Main == gsFontworkKernCharacterPairs )
591  {
592  if( !Event.IsEnabled )
593  {
594  implSetKernCharacterPairs(false, false);
595  }
596  else
597  {
598  bool bValue = false;
599  if( Event.State >>= bValue )
600  implSetKernCharacterPairs(bValue, true);
601  }
602  }
603 }
604 
605 IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, KernSelectHdl, weld::Toggleable&, void)
606 {
607  if (mbSettingValue)
608  return;
609 
610  Sequence< PropertyValue > aArgs( 1 );
611  aArgs[0].Name = OUString(gsFontworkKernCharacterPairs).copy(5);
612  bool bKernOnOff = mxKernPairs->get_active();
613  aArgs[0].Value <<= bKernOnOff;
614 
615  mxControl->dispatchCommand( gsFontworkKernCharacterPairs, aArgs );
616 
617  implSetKernCharacterPairs(bKernOnOff, true);
618 
619  mxControl->EndPopupMode();
620 }
621 
622 IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::Toggleable&, rButton, void)
623 {
624  if (!rButton.get_active())
625  return;
626 
627  if (mbSettingValue)
628  return;
629 
630  if (mxCustom->get_active())
631  {
632  Sequence< PropertyValue > aArgs( 1 );
633  aArgs[0].Name = OUString(gsFontworkCharacterSpacing).copy(5);
634  aArgs[0].Value <<= sal_Int32(100);
635 
636  rtl::Reference<svt::PopupWindowController> xControl(mxControl);
637  xControl->EndPopupMode();
638  xControl->dispatchCommand(".uno:FontworkCharacterSpacingDialog", aArgs);
639  }
640  else
641  {
642  sal_Int32 nCharacterSpacing;
643  if (mxVeryTight->get_active())
644  nCharacterSpacing = 80;
645  else if (mxTight->get_active())
646  nCharacterSpacing = 90;
647  else if (mxLoose->get_active())
648  nCharacterSpacing = 120;
649  else if (mxVeryLoose->get_active())
650  nCharacterSpacing = 150;
651  else
652  nCharacterSpacing = 100;
653 
654  Sequence< PropertyValue > aArgs( 1 );
655  aArgs[0].Name = OUString(gsFontworkCharacterSpacing).copy(5);
656  aArgs[0].Value <<= nCharacterSpacing;
657 
658  mxControl->dispatchCommand( gsFontworkCharacterSpacing, aArgs );
659 
660  implSetCharacterSpacing( nCharacterSpacing, true );
661  }
662 
663  mxControl->EndPopupMode();
664 }
665 
666 namespace {
667 
668 class FontworkCharacterSpacingControl : public svt::PopupWindowController
669 {
670 public:
671  explicit FontworkCharacterSpacingControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
672 
673  virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
674  virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
675 
676  // XInitialization
677  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
678 
679  // XServiceInfo
680  virtual OUString SAL_CALL getImplementationName() override;
681  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
682 };
683 
684 }
685 
686 FontworkCharacterSpacingControl::FontworkCharacterSpacingControl( const Reference< XComponentContext >& rxContext )
687 : svt::PopupWindowController( rxContext, Reference< css::frame::XFrame >(), ".uno:FontworkCharacterSpacingFloater" )
688 {
689 }
690 
691 std::unique_ptr<WeldToolbarPopup> FontworkCharacterSpacingControl::weldPopupWindow()
692 {
693  return std::make_unique<FontworkCharacterSpacingWindow>(this, m_pToolbar);
694 }
695 
696 VclPtr<vcl::Window> FontworkCharacterSpacingControl::createVclPopupWindow( vcl::Window* pParent )
697 {
698  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
699  std::make_unique<FontworkCharacterSpacingWindow>(this, pParent->GetFrameWeld()));
700 
701  mxInterimPopover->Show();
702 
703  return mxInterimPopover;
704 }
705 
706 // XInitialization
707 void SAL_CALL FontworkCharacterSpacingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
708 {
709  svt::PopupWindowController::initialize( aArguments );
710 
711  if (m_pToolbar)
712  {
713  mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
714  m_pToolbar->set_item_popover(m_aCommandURL.toUtf8(), mxPopoverContainer->getTopLevel());
715  }
716 
717  ToolBox* pToolBox = nullptr;
718  ToolBoxItemId nId;
719  if ( getToolboxId( nId, &pToolBox ) )
720  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
721 }
722 
723 // XServiceInfo
724 
725 
726 OUString FontworkCharacterSpacingControl::getImplementationName()
727 {
728  return "com.sun.star.comp.svx.FontworkCharacterSpacingController";
729 }
730 
731 
732 Sequence< OUString > FontworkCharacterSpacingControl::getSupportedServiceNames()
733 {
734  Sequence<OUString> aSNS { "com.sun.star.frame.ToolbarController" };
735  return aSNS;
736 }
737 
738 
739 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
741  css::uno::XComponentContext* xContext,
742  css::uno::Sequence<css::uno::Any> const &)
743 {
744  return cppu::acquire(new FontworkCharacterSpacingControl(xContext));
745 }
746 
747 FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog(weld::Window* pParent, sal_Int32 nScale)
748  : GenericDialogController(pParent, "svx/ui/fontworkspacingdialog.ui", "FontworkSpacingDialog")
749  , m_xMtrScale(m_xBuilder->weld_metric_spin_button("entry", FieldUnit::PERCENT))
750 {
751  m_xMtrScale->set_value(nScale, FieldUnit::PERCENT);
752 }
753 
755 {
756 }
757 
759 {
760  return static_cast<sal_Int32>(m_xMtrScale->get_value(FieldUnit::PERCENT));
761 }
762 
763 }
764 
765 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FieldUnit
std::unique_ptr< weld::IconView > maCtlFavorites
void setWidth(tools::Long nWidth)
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
tools::Long getWidth() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
virtual OUString SAL_CALL getImplementationName() override=0
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
constexpr OUStringLiteral PERCENT(u"Percent")
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:770
size_t GetObjCount() const
Definition: svdpage.cxx:764
std::unique_ptr< weld::MetricSpinButton > m_xMtrScale
Reference
sal_Int16 nId
void SetSdrObjectRef(SdrModel *pModel)
IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, KernSelectHdl, weld::Toggleable &, void)
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:473
void FreezeIdRanges()
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
Definition: svdedtv.cxx:983
constexpr auto convertTwipToMm100(N n)
constexpr tools::Long Width() const
weld::Window * GetFrameWeld() const
exports com.sun.star. frame
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
static SfxViewShell * Current()
void MakeNameUnique()
Definition: svdobj.cxx:3088
virtual void statusChanged(const css::frame::FeatureStateEvent &Event)
constexpr tools::Long getHeight() const
OutputDevice * GetFirstOutputDevice() const
Definition: svdpntv.cxx:88
IMPL_LINK_NOARG(SuggestionDisplay, SelectSuggestionValueSetHdl, ValueSet *, void)
FontWorkGalleryDialog(weld::Window *pParent, SdrView &rView)
bool IsEmpty() const
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow()
void initFavorites(sal_uInt16 nThemeId)
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
static bool BeginLocking(std::u16string_view rThemeName)
Definition: galexpl.cxx:236
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1810
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent)=0
DECL_LINK(FocusHdl, weld::Widget &, void)
std::vector< VclPtr< VirtualDevice > > maFavoritesHorizontal
virtual ~FontworkCharacterSpacingDialog() override
virtual void SetLogicRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1703
Abstract DrawObject.
Definition: svdobj.hxx:258
static bool EndLocking(std::u16string_view rThemeName)
Definition: galexpl.cxx:261
float GetDPIScaleFactor() const
void fillFavorites(sal_uInt16 nThemeId)
constexpr OUStringLiteral gsFontworkKernCharacterPairs(u".uno:FontworkKernCharacterPairs")
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 css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override=0
virtual ~FontWorkGalleryDialog() override
constexpr tools::Long Height() const
virtual tools::Rectangle getLOKVisibleArea() const
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:1080
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::Button > mxOKButton
void DrawCheckered(const Point &rPos, const Size &rSize, sal_uInt32 nLen=8, Color aStart=COL_WHITE, Color aEnd=COL_BLACK)
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:303
void setHeight(tools::Long nHeight)
OUString sId
SdrModel & getSdrModelFromSdrView() const
Definition: svdpntv.hxx:261
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:309
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 &)
constexpr OUStringLiteral gsFontworkAlignment(u".uno:FontworkAlignment")
constexpr tools::Long getWidth() const
virtual const tools::Rectangle & GetLogicRect() const
Definition: svdobj.cxx:1679
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
constexpr OUStringLiteral gsFontworkCharacterSpacing(u".uno:FontworkCharacterSpacing")
static bool GetSdrObj(std::u16string_view rThemeName, sal_uInt32 nSdrModelPos, SdrModel *pModel, BitmapEx *pThumb=nullptr)
Definition: galexpl.cxx:194
const Size & GetSizePixel() const
IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::Toggleable &, rButton, void)
virtual void GrabFocus()=0
Point Center() const
static sal_uInt32 GetSdrObjCount(std::u16string_view rThemeName)
Definition: galexpl.cxx:165
sal_Int16 nValue
Definition: fmsrccfg.cxx:81