21#include <com/sun/star/text/WritingMode.hpp>
57 : GenericDialogController(pParent,
"svx/ui/fontworkgallerydialog.ui",
"FontworkGalleryDialog")
60 , mbInsertIntoPage(true)
61 , mpDestModel(nullptr)
62 , maCtlFavorites(m_xBuilder->weld_icon_view(
"ctlFavoriteswin"))
63 , mxOKButton(m_xBuilder->weld_button(
"ok"))
91 for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ )
98 const Point aNull(0, 0);
100 if (pVDev->GetDPIScaleFactor() > 1)
101 aThumb.
Scale(pVDev->GetDPIScaleFactor(), pVDev->GetDPIScaleFactor());
105 pVDev->SetOutputSizePixel(aSize);
107 static const sal_uInt32 nLen(8);
109 static const Color aG(0xef, 0xef, 0xef);
111 pVDev->DrawCheckered(aNull, aSize, nLen, aW, aG);
113 pVDev->DrawBitmapEx(aNull, aThumb);
131 std::vector<OUString> aTitles;
133 assert(aTitles.size() == nFavCount);
135 for(
size_t nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
137 OUString
sId = OUString::number(
static_cast<sal_uInt16
>(nFavorite));
155 if (sItemId.isEmpty())
158 sal_Int32 nItemId = sItemId.toInt32();
192 pNewObject->MakeNameUnique();
220 if (aFontworkSize.
getWidth() > nLOKViewWidth)
222 double fScale =
static_cast<double>(aFontworkSize.
getWidth()) / nLOKViewWidth;
233 aPagePos = aVisArea.
Center();
242 pNewObject->SetLogicRect(aNewObjectRectangle);
244 if (bUseSpecialCalcMode)
261 insertSelectedFontwork();
267 insertSelectedFontwork();
274 const OUString
id = maCtlFavorites->get_id(iter);
275 auto it = maIdToTitleMap.find(
id);
276 return it != maIdToTitleMap.end() ? it->second : OUString();
287 mxLeft->grab_focus();
289 virtual void statusChanged(
const css::frame::FeatureStateEvent& Event )
override;
293 std::unique_ptr<weld::RadioButton> mxLeft;
294 std::unique_ptr<weld::RadioButton> mxCenter;
295 std::unique_ptr<weld::RadioButton> mxRight;
296 std::unique_ptr<weld::RadioButton> mxStretch;
301 void implSetAlignment(
int nAlignmentMode,
bool bEnabled );
309 :
WeldToolbarPopup(pControl->getFrameInterface(), pParent,
"svx/ui/fontworkalignmentcontrol.ui",
"FontworkAlignmentControl")
310 , mxControl(pControl)
311 , mxLeft(m_xBuilder->weld_radio_button(
"left"))
312 , mxCenter(m_xBuilder->weld_radio_button(
"center"))
313 , mxRight(m_xBuilder->weld_radio_button(
"right"))
314 , mxStretch(m_xBuilder->weld_radio_button(
"stretch"))
315 , mbSettingValue(false)
317 mxLeft->connect_toggled(
LINK(
this, FontworkAlignmentWindow, SelectHdl));
318 mxCenter->connect_toggled(
LINK(
this, FontworkAlignmentWindow, SelectHdl));
319 mxRight->connect_toggled(
LINK(
this, FontworkAlignmentWindow, SelectHdl));
320 mxStretch->connect_toggled(
LINK(
this, FontworkAlignmentWindow, SelectHdl));
325void FontworkAlignmentWindow::implSetAlignment(
int nSurface,
bool bEnabled )
327 bool bSettingValue = mbSettingValue;
328 mbSettingValue =
true;
329 mxLeft->set_active(nSurface == 0 && bEnabled);
330 mxLeft->set_sensitive(bEnabled);
331 mxCenter->set_active(nSurface == 1 && bEnabled);
332 mxCenter->set_sensitive(bEnabled);
333 mxRight->set_active(nSurface == 2 && bEnabled);
334 mxRight->set_sensitive(bEnabled);
338 mxStretch->set_active(nSurface == 4 && bEnabled);
339 mxStretch->set_sensitive(bEnabled);
340 mbSettingValue = bSettingValue;
343void FontworkAlignmentWindow::statusChanged(
const css::frame::FeatureStateEvent& Event )
348 if( !Event.IsEnabled )
350 implSetAlignment( 0,
false );
355 if( Event.State >>=
nValue )
356 implSetAlignment(
nValue,
true );
362 if (mbSettingValue || !rButton.get_active())
365 sal_Int32 nAlignment;
366 if (mxLeft->get_active())
368 else if (mxCenter->get_active())
370 else if (mxRight->get_active())
383 implSetAlignment( nAlignment,
true );
385 mxControl->EndPopupMode();
393 explicit FontworkAlignmentControl(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
399 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
408FontworkAlignmentControl::FontworkAlignmentControl(
const Reference< XComponentContext >& rxContext )
409:
svt::PopupWindowController( rxContext,
Reference< css::frame::XFrame >(),
".uno:FontworkAlignment" )
413std::unique_ptr<WeldToolbarPopup> FontworkAlignmentControl::weldPopupWindow()
415 return std::make_unique<FontworkAlignmentWindow>(
this, m_pToolbar);
421 std::make_unique<FontworkAlignmentWindow>(
this, pParent->
GetFrameWeld()));
423 mxInterimPopover->Show();
425 return mxInterimPopover;
429void SAL_CALL FontworkAlignmentControl::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
431 svt::PopupWindowController::initialize( aArguments );
436 m_pToolbar->set_item_popover(m_aCommandURL, mxPopoverContainer->getTopLevel());
441 if ( getToolboxId( nId, &pToolBox ) )
448OUString FontworkAlignmentControl::getImplementationName()
450 return "com.sun.star.comp.svx.FontworkAlignmentController";
454Sequence< OUString > FontworkAlignmentControl::getSupportedServiceNames()
456 return {
"com.sun.star.frame.ToolbarController" };
460extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
462 css::uno::XComponentContext* xContext,
463 css::uno::Sequence<css::uno::Any>
const &)
465 return cppu::acquire(
new FontworkAlignmentControl(xContext));
476 virtual void statusChanged(
const css::frame::FeatureStateEvent& Event )
override;
479 std::unique_ptr<weld::RadioButton> mxVeryTight;
480 std::unique_ptr<weld::RadioButton> mxTight;
481 std::unique_ptr<weld::RadioButton> mxNormal;
482 std::unique_ptr<weld::RadioButton> mxLoose;
483 std::unique_ptr<weld::RadioButton> mxVeryLoose;
484 std::unique_ptr<weld::RadioButton> mxCustom;
485 std::unique_ptr<weld::CheckButton> mxKernPairs;
486 sal_Int32 mnCharacterSpacing;
488 bool mbCommandDispatched;
494 void implSetCharacterSpacing( sal_Int32 nCharacterSpacing,
bool bEnabled );
495 void implSetKernCharacterPairs(
bool bKernOnOff,
bool bEnabled);
496 void DispatchSpacingDialog();
505 :
WeldToolbarPopup(pControl->getFrameInterface(), pParent,
"svx/ui/fontworkcharacterspacingcontrol.ui",
"FontworkCharacterSpacingControl")
506 , mxControl(pControl)
507 , mxVeryTight(m_xBuilder->weld_radio_button(
"verytight"))
508 , mxTight(m_xBuilder->weld_radio_button(
"tight"))
509 , mxNormal(m_xBuilder->weld_radio_button(
"normal"))
510 , mxLoose(m_xBuilder->weld_radio_button(
"loose"))
511 , mxVeryLoose(m_xBuilder->weld_radio_button(
"veryloose"))
512 , mxCustom(m_xBuilder->weld_radio_button(
"custom"))
513 , mxKernPairs(m_xBuilder->weld_check_button(
"kernpairs"))
514 , mnCharacterSpacing(0)
515 , mbSettingValue(false)
516 , mbCommandDispatched(false)
518 mxVeryTight->connect_toggled(
LINK(
this, FontworkCharacterSpacingWindow, SelectHdl));
519 mxTight->connect_toggled(
LINK(
this, FontworkCharacterSpacingWindow, SelectHdl));
520 mxNormal->connect_toggled(
LINK(
this, FontworkCharacterSpacingWindow, SelectHdl));
521 mxLoose->connect_toggled(
LINK(
this, FontworkCharacterSpacingWindow, SelectHdl));
522 mxVeryLoose->connect_toggled(
LINK(
this, FontworkCharacterSpacingWindow, SelectHdl));
523 mxCustom->connect_toggled(
LINK(
this, FontworkCharacterSpacingWindow, SelectHdl));
524 mxCustom->connect_mouse_release(
LINK(
this, FontworkCharacterSpacingWindow, MouseReleaseHdl));
526 mxKernPairs->connect_toggled(
LINK(
this, FontworkCharacterSpacingWindow, KernSelectHdl));
536void FontworkCharacterSpacingWindow::GrabFocus()
538 mxVeryTight->grab_focus();
541void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing,
bool bEnabled )
543 bool bSettingValue = mbSettingValue;
544 mbSettingValue =
true;
546 mxVeryTight->set_sensitive(bEnabled);
547 mxTight->set_sensitive(bEnabled);
548 mxNormal->set_sensitive(bEnabled);
549 mxLoose->set_sensitive(bEnabled);
550 mxVeryLoose->set_sensitive(bEnabled);
551 mxCustom->set_sensitive(bEnabled);
553 mxVeryTight->set_active(
false);
554 mxTight->set_active(
false);
555 mxNormal->set_active(
false);
556 mxLoose->set_active(
false);
557 mxVeryLoose->set_active(
false);
558 mxCustom->set_active(
true);
560 switch(nCharacterSpacing)
563 mxVeryTight->set_active(
true);
566 mxTight->set_active(
true);
569 mxNormal->set_active(
true);
572 mxLoose->set_active(
true);
575 mxVeryLoose->set_active(
true);
579 mnCharacterSpacing = nCharacterSpacing;
581 mbSettingValue = bSettingValue;
584void FontworkCharacterSpacingWindow::implSetKernCharacterPairs(
bool bKernOnOff,
bool bEnabled)
586 mxKernPairs->set_sensitive(bEnabled);
587 mxKernPairs->set_active(bKernOnOff);
590void FontworkCharacterSpacingWindow::statusChanged(
const css::frame::FeatureStateEvent& Event )
594 if( !Event.IsEnabled )
596 implSetCharacterSpacing( 0,
false );
601 if( Event.State >>=
nValue )
602 implSetCharacterSpacing(
nValue,
true );
607 if( !Event.IsEnabled )
609 implSetKernCharacterPairs(
false,
false);
614 if( Event.State >>= bValue )
615 implSetKernCharacterPairs(bValue,
true);
625 bool bKernOnOff = mxKernPairs->get_active();
630 mbCommandDispatched =
true;
632 implSetKernCharacterPairs(bKernOnOff,
true);
634 mxControl->EndPopupMode();
637void FontworkCharacterSpacingWindow::DispatchSpacingDialog()
643 xControl->EndPopupMode();
644 xControl->dispatchCommand(
".uno:FontworkCharacterSpacingDialog", aArgs);
645 mbCommandDispatched =
true;
650 if (!rButton.get_active())
659 if (mbCommandDispatched)
662 if (mxCustom->get_active())
663 DispatchSpacingDialog();
666 sal_Int32 nCharacterSpacing;
667 if (mxVeryTight->get_active())
668 nCharacterSpacing = 80;
669 else if (mxTight->get_active())
670 nCharacterSpacing = 90;
671 else if (mxLoose->get_active())
672 nCharacterSpacing = 120;
673 else if (mxVeryLoose->get_active())
674 nCharacterSpacing = 150;
676 nCharacterSpacing = 100;
682 mbCommandDispatched =
true;
684 implSetCharacterSpacing( nCharacterSpacing,
true );
687 mxControl->EndPopupMode();
700 if (mxCustom->get_active() && !mbCommandDispatched)
702 DispatchSpacingDialog();
713 explicit FontworkCharacterSpacingControl(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
719 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
override;
728FontworkCharacterSpacingControl::FontworkCharacterSpacingControl(
const Reference< XComponentContext >& rxContext )
729:
svt::PopupWindowController( rxContext,
Reference< css::frame::XFrame >(),
".uno:FontworkCharacterSpacingFloater" )
733std::unique_ptr<WeldToolbarPopup> FontworkCharacterSpacingControl::weldPopupWindow()
735 return std::make_unique<FontworkCharacterSpacingWindow>(
this, m_pToolbar);
741 std::make_unique<FontworkCharacterSpacingWindow>(
this, pParent->
GetFrameWeld()));
743 mxInterimPopover->Show();
745 return mxInterimPopover;
749void SAL_CALL FontworkCharacterSpacingControl::initialize(
const css::uno::Sequence< css::uno::Any >& aArguments )
751 svt::PopupWindowController::initialize( aArguments );
756 m_pToolbar->set_item_popover(m_aCommandURL, mxPopoverContainer->getTopLevel());
761 if ( getToolboxId( nId, &pToolBox ) )
768OUString FontworkCharacterSpacingControl::getImplementationName()
770 return "com.sun.star.comp.svx.FontworkCharacterSpacingController";
774Sequence< OUString > FontworkCharacterSpacingControl::getSupportedServiceNames()
776 Sequence<OUString> aSNS {
"com.sun.star.frame.ToolbarController" };
781extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
783 css::uno::XComponentContext* xContext,
784 css::uno::Sequence<css::uno::Any>
const &)
786 return cppu::acquire(
new FontworkCharacterSpacingControl(xContext));
789FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog(
weld::Window* pParent, sal_Int32 nScale)
790 : GenericDialogController(pParent,
"svx/ui/fontworkspacingdialog.ui",
"FontworkSpacingDialog")
791 , m_xMtrScale(m_xBuilder->weld_metric_spin_button(
"entry",
FieldUnit::
PERCENT))
793 m_xMtrScale->set_value(nScale, FieldUnit::PERCENT);
802 return static_cast<sal_Int32
>(
m_xMtrScale->get_value(FieldUnit::PERCENT));
constexpr auto convertTwipToMm100(N n)
Reference< XExecutableDialog > m_xDialog
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
const Size & GetSizePixel() const
static bool EndLocking(std::u16string_view rThemeName)
static sal_uInt32 GetSdrObjCount(std::u16string_view rThemeName)
static bool FillObjListTitle(const sal_uInt32 nThemeId, std::vector< OUString > &rList)
static bool GetSdrObj(std::u16string_view rThemeName, sal_uInt32 nSdrModelPos, SdrModel *pModel, BitmapEx *pThumb=nullptr)
static bool BeginLocking(std::u16string_view rThemeName)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Size GetOutputSizePixel() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long getX() const
constexpr tools::Long getY() const
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
const SfxItemPool & GetItemPool() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const =0
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
OutputDevice * GetFirstOutputDevice() const
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual tools::Rectangle getLOKVisibleArea() const
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static VclPtr< reference_type > Create(Arg &&... arg)
std::unique_ptr< weld::IconView > maCtlFavorites
FontWorkGalleryDialog(weld::Window *pParent, SdrView &rView)
void initFavorites(sal_uInt16 nThemeId)
void SetSdrObjectRef(SdrModel *pModel)
std::unique_ptr< weld::Button > mxOKButton
std::map< OUString, OUString > maIdToTitleMap
void fillFavorites(sal_uInt16 nThemeId)
std::vector< VclPtr< VirtualDevice > > maFavoritesHorizontal
rtl::Reference< SdrObject > mxSdrObject
virtual ~FontWorkGalleryDialog() override
void insertSelectedFontwork()
sal_Int32 getScale() const
virtual ~FontworkCharacterSpacingDialog() override
std::unique_ptr< weld::MetricSpinButton > m_xMtrScale
weld::Window * GetFrameWeld() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
#define GALLERY_THEME_FONTWORK
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
void copy(const fs::path &src, const fs::path &dest)
IMPL_LINK(HangulHanjaConversionDialog, ClickByCharacterHdl, weld::Toggleable &, rBox, void)
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 &)
IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::Toggleable &, rButton, void)
constexpr OUStringLiteral gsFontworkCharacterSpacing(u".uno:FontworkCharacterSpacing")
constexpr OUStringLiteral gsFontworkKernCharacterPairs(u".uno:FontworkKernCharacterPairs")
IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, MouseReleaseHdl, const MouseEvent &, bool)
IMPL_LINK_NOARG(SuggestionDisplay, SelectSuggestionValueSetHdl, ValueSet *, void)
constexpr OUStringLiteral gsFontworkAlignment(u".uno:FontworkAlignment")
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 &)
constexpr OUStringLiteral PERCENT(u"Percent")