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