1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sfx2/module.hxx>
21 #include <sfx2/dispatch.hxx>
23 #include <svx/colorbox.hxx>
24 #include <svx/dialmgr.hxx>
25 #include <svx/strings.hrc>
26 #include <svx/xftadit.hxx>
27 #include <svx/xftdiit.hxx>
28 #include <svx/xftstit.hxx>
29 #include <svx/xftmrit.hxx>
30 #include <svx/xftouit.hxx>
31 #include <svx/xftshit.hxx>
32 #include <svx/xftshcit.hxx>
33 #include <svx/xftshxy.hxx>
34 #include <svx/xtextit0.hxx>
36 #include <svtools/unitconv.hxx>
37 #include <svx/svxids.hrc>
38 #include <bitmaps.hlst>
39 #include <svx/fontwork.hxx>
40 #include <svl/itemset.hxx>
42 #define WIDTH_CHARS 10
44 SFX_IMPL_DOCKINGWINDOW_WITHID( SvxFontWorkChildWindow
, SID_FONTWORK
);
46 // ControllerItem for Fontwork
48 SvxFontWorkControllerItem::SvxFontWorkControllerItem
51 SvxFontWorkDialog
& rDlg
,
52 SfxBindings
& rBindings
55 SfxControllerItem( _nId
, rBindings
),
61 // StateChanged method for FontWork items
63 void SvxFontWorkControllerItem::StateChangedAtToolBoxControl( sal_uInt16
/*nSID*/, SfxItemState
/*eState*/,
64 const SfxPoolItem
* pItem
)
68 case SID_FORMTEXT_STYLE
:
70 const XFormTextStyleItem
* pStateItem
=
71 dynamic_cast<const XFormTextStyleItem
*>( pItem
);
72 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextStyleItem expected");
73 rFontWorkDlg
.SetStyle_Impl(pStateItem
);
76 case SID_FORMTEXT_ADJUST
:
78 const XFormTextAdjustItem
* pStateItem
=
79 dynamic_cast<const XFormTextAdjustItem
*>( pItem
);
80 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextAdjustItem expected");
81 rFontWorkDlg
.SetAdjust_Impl(pStateItem
);
84 case SID_FORMTEXT_DISTANCE
:
86 const XFormTextDistanceItem
* pStateItem
=
87 dynamic_cast<const XFormTextDistanceItem
*>( pItem
);
88 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextDistanceItem expected");
89 rFontWorkDlg
.SetDistance_Impl(pStateItem
);
92 case SID_FORMTEXT_START
:
94 const XFormTextStartItem
* pStateItem
=
95 dynamic_cast<const XFormTextStartItem
*>( pItem
);
96 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextStartItem expected");
97 rFontWorkDlg
.SetStart_Impl(pStateItem
);
100 case SID_FORMTEXT_MIRROR
:
102 const XFormTextMirrorItem
* pStateItem
=
103 dynamic_cast<const XFormTextMirrorItem
*>( pItem
);
104 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextMirrorItem expected");
105 rFontWorkDlg
.SetMirror_Impl(pStateItem
);
108 case SID_FORMTEXT_HIDEFORM
:
110 const XFormTextHideFormItem
* pStateItem
=
111 dynamic_cast<const XFormTextHideFormItem
*>( pItem
);
112 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextHideFormItem expected");
113 rFontWorkDlg
.SetShowForm_Impl(pStateItem
);
116 case SID_FORMTEXT_OUTLINE
:
118 const XFormTextOutlineItem
* pStateItem
=
119 dynamic_cast<const XFormTextOutlineItem
*>( pItem
);
120 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextOutlineItem expected");
121 rFontWorkDlg
.SetOutline_Impl(pStateItem
);
124 case SID_FORMTEXT_SHADOW
:
126 const XFormTextShadowItem
* pStateItem
=
127 dynamic_cast<const XFormTextShadowItem
*>( pItem
);
128 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextShadowItem expected");
129 rFontWorkDlg
.SetShadow_Impl(pStateItem
);
132 case SID_FORMTEXT_SHDWCOLOR
:
134 const XFormTextShadowColorItem
* pStateItem
=
135 dynamic_cast<const XFormTextShadowColorItem
*>( pItem
);
136 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextShadowColorItem expected");
137 rFontWorkDlg
.SetShadowColor_Impl(pStateItem
);
140 case SID_FORMTEXT_SHDWXVAL
:
142 const XFormTextShadowXValItem
* pStateItem
=
143 dynamic_cast<const XFormTextShadowXValItem
*>( pItem
);
144 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextShadowXValItem expected");
145 rFontWorkDlg
.SetShadowXVal_Impl(pStateItem
);
148 case SID_FORMTEXT_SHDWYVAL
:
150 const XFormTextShadowYValItem
* pStateItem
=
151 dynamic_cast<const XFormTextShadowYValItem
*>( pItem
);
152 DBG_ASSERT(pStateItem
|| pItem
== nullptr, "XFormTextShadowYValItem expected");
153 rFontWorkDlg
.SetShadowYVal_Impl(pStateItem
);
159 // Derivation from SfxChildWindow as "containers" for Fontwork dialog
161 SvxFontWorkChildWindow::SvxFontWorkChildWindow
163 vcl::Window
* _pParent
,
165 SfxBindings
* pBindings
,
166 SfxChildWinInfo
* pInfo
168 SfxChildWindow( _pParent
, nId
)
170 VclPtrInstance
<SvxFontWorkDialog
> pDlg(pBindings
, this, _pParent
);
173 pDlg
->Initialize( pInfo
);
176 // Floating Window to the attribution of text effects
177 SvxFontWorkDialog::SvxFontWorkDialog(SfxBindings
*pBindinx
,
179 vcl::Window
* _pParent
)
180 : SfxDockingWindow(pBindinx
, pCW
, _pParent
, u
"DockingFontwork"_ustr
, u
"svx/ui/dockingfontwork.ui"_ustr
)
181 , rBindings(*pBindinx
)
182 , aInputIdle("SvxFontWorkDialog Input")
185 , nSaveShadowAngle(450)
186 , nSaveShadowSize (100)
187 , m_xTbxStyle(m_xBuilder
->weld_toolbar(u
"style"_ustr
))
188 , m_xTbxAdjust(m_xBuilder
->weld_toolbar(u
"adjust"_ustr
))
189 , m_xMtrFldDistance(m_xBuilder
->weld_metric_spin_button(u
"distance"_ustr
, FieldUnit::CM
))
190 , m_xMtrFldTextStart(m_xBuilder
->weld_metric_spin_button(u
"indent"_ustr
, FieldUnit::CM
))
191 , m_xTbxShadow(m_xBuilder
->weld_toolbar(u
"shadow"_ustr
))
192 , m_xFbShadowX(m_xBuilder
->weld_image(u
"shadowx"_ustr
))
193 , m_xMtrFldShadowX(m_xBuilder
->weld_metric_spin_button(u
"distancex"_ustr
, FieldUnit::CM
))
194 , m_xFbShadowY(m_xBuilder
->weld_image(u
"shadowy"_ustr
))
195 , m_xMtrFldShadowY(m_xBuilder
->weld_metric_spin_button(u
"distancey"_ustr
, FieldUnit::CM
))
196 , m_xShadowColorLB(new ColorListBox(m_xBuilder
->weld_menu_button(u
"color"_ustr
), [this]{ return GetFrameWeld(); } ))
198 SetText(SvxResId(RID_SVXSTR_FONTWORK
));
202 pCtrlItems
[0] = new SvxFontWorkControllerItem(SID_FORMTEXT_STYLE
, *this, rBindings
);
203 pCtrlItems
[1] = new SvxFontWorkControllerItem(SID_FORMTEXT_ADJUST
, *this, rBindings
);
204 pCtrlItems
[2] = new SvxFontWorkControllerItem(SID_FORMTEXT_DISTANCE
, *this, rBindings
);
205 pCtrlItems
[3] = new SvxFontWorkControllerItem(SID_FORMTEXT_START
, *this, rBindings
);
206 pCtrlItems
[4] = new SvxFontWorkControllerItem(SID_FORMTEXT_MIRROR
, *this, rBindings
);
207 pCtrlItems
[5] = new SvxFontWorkControllerItem(SID_FORMTEXT_HIDEFORM
, *this, rBindings
);
208 pCtrlItems
[6] = new SvxFontWorkControllerItem(SID_FORMTEXT_OUTLINE
, *this, rBindings
);
209 pCtrlItems
[7] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHADOW
, *this, rBindings
);
210 pCtrlItems
[8] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWCOLOR
, *this, rBindings
);
211 pCtrlItems
[9] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWXVAL
, *this, rBindings
);
212 pCtrlItems
[10] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWYVAL
, *this, rBindings
);
214 m_xTbxStyle
->connect_clicked(LINK(this, SvxFontWorkDialog
, SelectStyleHdl_Impl
));
215 m_xTbxAdjust
->connect_clicked(LINK(this, SvxFontWorkDialog
, SelectAdjustHdl_Impl
));
216 m_xTbxShadow
->connect_clicked(LINK(this, SvxFontWorkDialog
, SelectShadowHdl_Impl
));
218 Link
<weld::MetricSpinButton
&,void> aLink
= LINK(this, SvxFontWorkDialog
, ModifyInputHdl_Impl
);
219 m_xMtrFldDistance
->connect_value_changed( aLink
);
220 m_xMtrFldTextStart
->connect_value_changed( aLink
);
221 m_xMtrFldShadowX
->connect_value_changed( aLink
);
222 m_xMtrFldShadowY
->connect_value_changed( aLink
);
225 const FieldUnit eDlgUnit
= rBindings
.GetDispatcher()->GetModule()->GetFieldUnit();
226 SetFieldUnit(*m_xMtrFldDistance
, eDlgUnit
, true);
227 SetFieldUnit(*m_xMtrFldTextStart
, eDlgUnit
, true);
228 SetFieldUnit(*m_xMtrFldShadowX
, eDlgUnit
, true);
229 SetFieldUnit(*m_xMtrFldShadowY
, eDlgUnit
, true);
230 if( eDlgUnit
== FieldUnit::MM
)
232 m_xMtrFldDistance
->set_increments(50, 500, FieldUnit::NONE
);
233 m_xMtrFldTextStart
->set_increments(50, 500, FieldUnit::NONE
);
234 m_xMtrFldShadowX
->set_increments(50, 500, FieldUnit::NONE
);
235 m_xMtrFldShadowY
->set_increments(50, 500, FieldUnit::NONE
);
239 m_xMtrFldDistance
->set_increments(10, 100, FieldUnit::NONE
);
240 m_xMtrFldTextStart
->set_increments(10, 100, FieldUnit::NONE
);
241 m_xMtrFldShadowX
->set_increments(10, 100, FieldUnit::NONE
);
242 m_xMtrFldShadowY
->set_increments(10, 100, FieldUnit::NONE
);
244 m_xMtrFldShadowX
->set_width_chars(WIDTH_CHARS
);
245 m_xMtrFldShadowY
->set_width_chars(WIDTH_CHARS
);
247 m_xShadowColorLB
->SetSelectHdl( LINK(this, SvxFontWorkDialog
, ColorSelectHdl_Impl
) );
249 aInputIdle
.SetPriority(TaskPriority::LOWEST
);
250 aInputIdle
.SetInvokeHandler(LINK(this, SvxFontWorkDialog
, InputTimeoutHdl_Impl
));
253 SvxFontWorkDialog::~SvxFontWorkDialog()
258 void SvxFontWorkDialog::dispose()
260 for (SvxFontWorkControllerItem
* pCtrlItem
: pCtrlItems
)
261 pCtrlItem
->dispose();
263 m_xTbxAdjust
.reset();
264 m_xMtrFldDistance
.reset();
265 m_xMtrFldTextStart
.reset();
266 m_xTbxShadow
.reset();
267 m_xFbShadowX
.reset();
268 m_xMtrFldShadowX
.reset();
269 m_xFbShadowY
.reset();
270 m_xMtrFldShadowY
.reset();
271 m_xShadowColorLB
.reset();
272 SfxDockingWindow::dispose();
275 SfxChildAlignment
SvxFontWorkDialog::CheckAlignment( SfxChildAlignment eActAlign
,
276 SfxChildAlignment eAlign
)
278 SfxChildAlignment eAlignment
;
282 case SfxChildAlignment::TOP
:
283 case SfxChildAlignment::HIGHESTTOP
:
284 case SfxChildAlignment::LOWESTTOP
:
285 case SfxChildAlignment::BOTTOM
:
286 case SfxChildAlignment::LOWESTBOTTOM
:
287 case SfxChildAlignment::HIGHESTBOTTOM
:
289 eAlignment
= eActAlign
;
293 case SfxChildAlignment::LEFT
:
294 case SfxChildAlignment::RIGHT
:
295 case SfxChildAlignment::FIRSTLEFT
:
296 case SfxChildAlignment::LASTLEFT
:
297 case SfxChildAlignment::FIRSTRIGHT
:
298 case SfxChildAlignment::LASTRIGHT
:
315 void SvxFontWorkDialog::SetStyle_Impl(const XFormTextStyleItem
* pItem
)
319 OUString sId
= u
"off"_ustr
;
321 switch ( pItem
->GetValue() )
323 case XFormTextStyle::Rotate
: sId
= "rotate"; break;
324 case XFormTextStyle::Upright
: sId
= "upright"; break;
325 case XFormTextStyle::SlantX
: sId
= "hori"; break;
326 case XFormTextStyle::SlantY
: sId
= "vert"; break;
327 default: ;//prevent warning
329 m_xTbxStyle
->set_sensitive(true);
331 // Make sure that there is always exactly one checked toolbox item.
332 if ( pItem
->GetValue() == XFormTextStyle::NONE
)
334 m_xTbxStyle
->set_item_active(u
"rotate"_ustr
, false);
335 m_xTbxStyle
->set_item_active(u
"upright"_ustr
, false);
336 m_xTbxStyle
->set_item_active(u
"hori"_ustr
, false);
337 m_xTbxStyle
->set_item_active(u
"vert"_ustr
, false);
339 m_xTbxStyle
->set_item_active(u
"off"_ustr
, true);
343 m_xTbxStyle
->set_item_active(u
"off"_ustr
, false);
344 m_xTbxStyle
->set_item_active(sId
, true);
347 m_sLastStyleTbxId
= sId
;
350 m_xTbxStyle
->set_sensitive(false);
353 // Set adjust buttons
355 void SvxFontWorkDialog::SetAdjust_Impl(const XFormTextAdjustItem
* pItem
)
361 m_xTbxAdjust
->set_sensitive(true);
362 m_xMtrFldDistance
->set_sensitive(true);
364 if ( pItem
->GetValue() == XFormTextAdjust::Left
|| pItem
->GetValue() == XFormTextAdjust::Right
)
366 if (pItem
->GetValue() == XFormTextAdjust::Left
)
370 m_xMtrFldTextStart
->set_sensitive(true);
374 if (pItem
->GetValue() == XFormTextAdjust::Center
)
378 m_xMtrFldTextStart
->set_sensitive(false);
381 if (!m_xTbxAdjust
->get_item_active(sId
))
382 m_xTbxAdjust
->set_item_active(sId
, true);
384 m_sLastAdjustTbxId
= sId
;
388 m_xTbxAdjust
->set_sensitive(false);
389 m_xMtrFldTextStart
->set_sensitive(false);
390 m_xMtrFldDistance
->set_sensitive(false);
394 // Enter Distance value in the edit field
396 void SvxFontWorkDialog::SetDistance_Impl(const XFormTextDistanceItem
* pItem
)
398 if (pItem
&& !m_xMtrFldDistance
->has_focus())
400 SetMetricValue(*m_xMtrFldDistance
, pItem
->GetValue(), MapUnit::Map100thMM
);
404 // Enter indent value in the edit field
406 void SvxFontWorkDialog::SetStart_Impl(const XFormTextStartItem
* pItem
)
408 if (pItem
&& !m_xMtrFldTextStart
->has_focus())
410 SetMetricValue(*m_xMtrFldTextStart
, pItem
->GetValue(), MapUnit::Map100thMM
);
414 // Set button for reversing the direction of text
416 void SvxFontWorkDialog::SetMirror_Impl(const XFormTextMirrorItem
* pItem
)
419 m_xTbxAdjust
->set_item_active(u
"orientation"_ustr
, pItem
->GetValue());
422 // Set button for contour display
424 void SvxFontWorkDialog::SetShowForm_Impl(const XFormTextHideFormItem
* pItem
)
427 m_xTbxShadow
->set_item_active(u
"contour"_ustr
, !pItem
->GetValue());
430 // Set button for text border
432 void SvxFontWorkDialog::SetOutline_Impl(const XFormTextOutlineItem
* pItem
)
435 m_xTbxShadow
->set_item_active(u
"textcontour"_ustr
, pItem
->GetValue());
438 // Set shadow buttons
440 void SvxFontWorkDialog::SetShadow_Impl(const XFormTextShadowItem
* pItem
,
447 m_xTbxShadow
->set_sensitive(true);
449 if ( pItem
->GetValue() == XFormTextShadow::NONE
)
452 m_xFbShadowX
->hide();
453 m_xFbShadowY
->hide();
454 m_xMtrFldShadowX
->set_sensitive(false);
455 m_xMtrFldShadowY
->set_sensitive(false);
456 m_xShadowColorLB
->set_sensitive(false);
460 m_xFbShadowX
->show();
461 m_xFbShadowY
->show();
462 m_xMtrFldShadowX
->set_sensitive(true);
463 m_xMtrFldShadowY
->set_sensitive(true);
464 m_xShadowColorLB
->set_sensitive(true);
466 if ( pItem
->GetValue() == XFormTextShadow::Normal
)
469 const FieldUnit eDlgUnit
= rBindings
.GetDispatcher()->GetModule()->GetFieldUnit();
471 m_xMtrFldShadowX
->set_unit( eDlgUnit
);
472 m_xMtrFldShadowX
->set_digits(2);
473 m_xMtrFldShadowX
->set_range(INT_MIN
, INT_MAX
, FieldUnit::NONE
);
474 if( eDlgUnit
== FieldUnit::MM
)
475 m_xMtrFldShadowX
->set_increments(50, 500, FieldUnit::NONE
);
477 m_xMtrFldShadowX
->set_increments(10, 100, FieldUnit::NONE
);
478 m_xMtrFldShadowX
->set_width_chars(WIDTH_CHARS
);
480 m_xMtrFldShadowY
->set_unit( eDlgUnit
);
481 m_xMtrFldShadowY
->set_digits(2);
482 m_xMtrFldShadowY
->set_range(INT_MIN
, INT_MAX
, FieldUnit::NONE
);
483 if( eDlgUnit
== FieldUnit::MM
)
484 m_xMtrFldShadowY
->set_increments(50, 500, FieldUnit::NONE
);
486 m_xMtrFldShadowY
->set_increments(10, 100, FieldUnit::NONE
);
487 m_xMtrFldShadowY
->set_width_chars(WIDTH_CHARS
);
489 if ( bRestoreValues
)
491 SetMetricValue(*m_xMtrFldShadowX
, nSaveShadowX
, MapUnit::Map100thMM
);
492 SetMetricValue(*m_xMtrFldShadowY
, nSaveShadowY
, MapUnit::Map100thMM
);
494 XFormTextShadowXValItem
aXItem( nSaveShadowX
);
495 XFormTextShadowYValItem
aYItem( nSaveShadowY
);
497 GetBindings().GetDispatcher()->ExecuteList(
498 SID_FORMTEXT_SHDWXVAL
, SfxCallMode::RECORD
,
499 { &aXItem
, &aYItem
});
506 m_xMtrFldShadowX
->set_unit(FieldUnit::DEGREE
);
507 m_xMtrFldShadowX
->set_digits(1);
508 m_xMtrFldShadowX
->set_range(-1800, 1800, FieldUnit::NONE
);
509 m_xMtrFldShadowX
->set_increments(10, 100, FieldUnit::NONE
);
510 m_xMtrFldShadowX
->set_width_chars(WIDTH_CHARS
);
512 m_xMtrFldShadowY
->set_unit(FieldUnit::PERCENT
);
513 m_xMtrFldShadowY
->set_digits(0);
514 m_xMtrFldShadowY
->set_range(-999, 999, FieldUnit::NONE
);
515 m_xMtrFldShadowY
->set_increments(10, 100, FieldUnit::NONE
);
516 m_xMtrFldShadowY
->set_width_chars(WIDTH_CHARS
);
518 if ( bRestoreValues
)
520 m_xMtrFldShadowX
->set_value(nSaveShadowAngle
, FieldUnit::NONE
);
521 m_xMtrFldShadowY
->set_value(nSaveShadowSize
, FieldUnit::NONE
);
522 XFormTextShadowXValItem
aXItem(nSaveShadowAngle
);
523 XFormTextShadowYValItem
aYItem(nSaveShadowSize
);
524 GetBindings().GetDispatcher()->ExecuteList(
525 SID_FORMTEXT_SHDWXVAL
, SfxCallMode::RECORD
,
526 { &aXItem
, &aYItem
});
531 if (!m_xTbxShadow
->get_item_active(sId
))
532 m_xTbxShadow
->set_item_active(sId
, true);
533 m_sLastShadowTbxId
= sId
;
539 m_xTbxShadow
->set_sensitive(false);
540 m_xMtrFldShadowX
->set_sensitive(false);
541 m_xMtrFldShadowY
->set_sensitive(false);
542 m_xShadowColorLB
->set_sensitive(false);
546 // Insert shadow color in listbox
548 void SvxFontWorkDialog::SetShadowColor_Impl(const XFormTextShadowColorItem
* pItem
)
551 m_xShadowColorLB
->SelectEntry(pItem
->GetColorValue());
554 // Enter X-value for shadow in edit field
555 void SvxFontWorkDialog::SetShadowXVal_Impl(const XFormTextShadowXValItem
* pItem
)
557 if (!pItem
|| m_xMtrFldShadowX
->has_focus())
561 // sal_Int32 nValue = pItem->GetValue();
564 // The two involved fields/items are used double and contain/give different
565 // values regarding to the access method. Thus, here we need to separate the access
566 // methods regarding to the kind of value accessed.
567 if (m_xTbxShadow
->get_item_active(u
"slant"_ustr
))
570 // There is no value correction necessary at all, i think this
571 // was only tried to be done without understanding that the two
572 // involved fields/items are used double and contain/give different
573 // values regarding to the access method.
574 // nValue = nValue - ( int( float( nValue ) / 360.0 ) * 360 );
575 m_xMtrFldShadowX
->set_value(pItem
->GetValue(), FieldUnit::NONE
);
579 SetMetricValue(*m_xMtrFldShadowX
, pItem
->GetValue(), MapUnit::Map100thMM
);
583 // Enter Y-value for shadow in edit field
584 void SvxFontWorkDialog::SetShadowYVal_Impl(const XFormTextShadowYValItem
* pItem
)
586 if (!pItem
|| m_xMtrFldShadowY
->has_focus())
590 // The two involved fields/items are used double and contain/give different
591 // values regarding to the access method. Thus, here we need to separate the access
592 // methods regarding to the kind of value accessed.
593 if (m_xTbxShadow
->get_item_active(u
"slant"_ustr
))
595 m_xMtrFldShadowY
->set_value(pItem
->GetValue(), FieldUnit::NONE
);
599 SetMetricValue(*m_xMtrFldShadowY
, pItem
->GetValue(), MapUnit::Map100thMM
);
603 IMPL_LINK(SvxFontWorkDialog
, SelectStyleHdl_Impl
, const OUString
&, rId
, void)
605 // Execute this block when a different toolbox item has been clicked or
606 // when the off item has been clicked. The later is necessary to
607 // override the toolbox behaviour of unchecking the item after second
608 // click on it: One of the items has to be checked at all times (when
610 if (rId
!= "off" && rId
== m_sLastStyleTbxId
)
613 XFormTextStyle eStyle
= XFormTextStyle::NONE
;
616 eStyle
= XFormTextStyle::Rotate
;
617 else if (rId
== "upright")
618 eStyle
= XFormTextStyle::Upright
;
619 else if (rId
== "hori")
620 eStyle
= XFormTextStyle::SlantX
;
621 else if (rId
== "vert")
622 eStyle
= XFormTextStyle::SlantY
;
624 XFormTextStyleItem
aItem( eStyle
);
625 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_STYLE
,
626 SfxCallMode::RECORD
, { &aItem
});
627 SetStyle_Impl( &aItem
);
628 m_sLastStyleTbxId
= rId
;
631 IMPL_LINK(SvxFontWorkDialog
, SelectAdjustHdl_Impl
, const OUString
&, rId
, void)
633 if (rId
== "orientation")
635 XFormTextMirrorItem
aItem(m_xTbxAdjust
->get_item_active(rId
));
636 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_MIRROR
,
637 SfxCallMode::SLOT
, { &aItem
});
639 else if (rId
!= m_sLastAdjustTbxId
)
641 XFormTextAdjust eAdjust
= XFormTextAdjust::AutoSize
;
644 eAdjust
= XFormTextAdjust::Left
;
645 else if (rId
== "center")
646 eAdjust
= XFormTextAdjust::Center
;
647 else if (rId
== "right")
648 eAdjust
= XFormTextAdjust::Right
;
650 XFormTextAdjustItem
aItem(eAdjust
);
651 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_ADJUST
,
652 SfxCallMode::RECORD
, { &aItem
});
653 SetAdjust_Impl(&aItem
);
654 m_sLastAdjustTbxId
= rId
;
658 IMPL_LINK(SvxFontWorkDialog
, SelectShadowHdl_Impl
, const OUString
&, rId
, void)
660 if (rId
== "contour")
662 XFormTextHideFormItem
aItem(!m_xTbxShadow
->get_item_active(rId
));
663 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_HIDEFORM
,
664 SfxCallMode::RECORD
, { &aItem
});
666 else if (rId
== "textcontour")
668 XFormTextOutlineItem
aItem(m_xTbxShadow
->get_item_active(rId
));
669 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_OUTLINE
,
670 SfxCallMode::RECORD
, { &aItem
});
672 else if (rId
!= m_sLastShadowTbxId
)
674 XFormTextShadow eShadow
= XFormTextShadow::NONE
;
676 if (m_sLastShadowTbxId
== "vertical")
678 nSaveShadowX
= GetCoreValue(*m_xMtrFldShadowX
, MapUnit::Map100thMM
);
679 nSaveShadowY
= GetCoreValue(*m_xMtrFldShadowY
, MapUnit::Map100thMM
);
681 else if (m_sLastShadowTbxId
== "slant")
683 nSaveShadowAngle
= m_xMtrFldShadowX
->get_value(FieldUnit::NONE
);
684 nSaveShadowSize
= m_xMtrFldShadowY
->get_value(FieldUnit::NONE
);
686 m_sLastShadowTbxId
= rId
;
688 if ( rId
== "vertical") eShadow
= XFormTextShadow::Normal
;
689 else if (rId
== "slant") eShadow
= XFormTextShadow::Slant
;
691 XFormTextShadowItem
aItem(eShadow
);
692 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_SHADOW
,
693 SfxCallMode::RECORD
, { &aItem
});
694 SetShadow_Impl(&aItem
, true);
698 IMPL_LINK_NOARG(SvxFontWorkDialog
, ModifyInputHdl_Impl
, weld::MetricSpinButton
&, void)
703 IMPL_LINK_NOARG(SvxFontWorkDialog
, InputTimeoutHdl_Impl
, Timer
*, void)
705 // Possibly set the Metric system again. This should be done with a
706 // listen, this is however not possible at the moment due to compatibility
708 const FieldUnit eDlgUnit
= rBindings
.GetDispatcher()->GetModule()->GetFieldUnit();
709 if( eDlgUnit
!= m_xMtrFldDistance
->get_unit() )
711 SetFieldUnit(*m_xMtrFldDistance
, eDlgUnit
, true);
712 SetFieldUnit(*m_xMtrFldTextStart
, eDlgUnit
, true);
713 if (eDlgUnit
== FieldUnit::MM
)
715 m_xMtrFldDistance
->set_increments(50, 500, FieldUnit::NONE
);
716 m_xMtrFldTextStart
->set_increments(50, 500, FieldUnit::NONE
);
720 m_xMtrFldDistance
->set_increments(10, 100, FieldUnit::NONE
);
721 m_xMtrFldTextStart
->set_increments(10, 100, FieldUnit::NONE
);
724 if( eDlgUnit
!= m_xMtrFldShadowX
->get_unit() &&
725 m_xTbxShadow
->get_item_active(u
"vertical"_ustr
) )
727 SetFieldUnit(*m_xMtrFldShadowX
, eDlgUnit
, true);
728 SetFieldUnit(*m_xMtrFldShadowY
, eDlgUnit
, true);
730 if (eDlgUnit
== FieldUnit::MM
)
732 m_xMtrFldShadowX
->set_increments(50, 500, FieldUnit::NONE
);
733 m_xMtrFldShadowY
->set_increments(50, 500, FieldUnit::NONE
);
737 m_xMtrFldShadowX
->set_increments(10, 100, FieldUnit::NONE
);
738 m_xMtrFldShadowY
->set_increments(10, 100, FieldUnit::NONE
);
742 tools::Long nValue
= GetCoreValue(*m_xMtrFldDistance
, MapUnit::Map100thMM
);
743 XFormTextDistanceItem
aDistItem( nValue
);
744 nValue
= GetCoreValue(*m_xMtrFldTextStart
, MapUnit::Map100thMM
);
745 XFormTextStartItem
aStartItem( nValue
);
747 sal_Int32
nValueX(0);
748 sal_Int32
nValueY(0);
751 // The two involved fields/items are used double and contain/give different
752 // values regarding to the access method. Thus, here we need to separate the access
753 // method regarding to the kind of value accessed.
754 if (m_sLastShadowTbxId
== "vertical")
756 nValueX
= GetCoreValue(*m_xMtrFldShadowX
, MapUnit::Map100thMM
);
757 nValueY
= GetCoreValue(*m_xMtrFldShadowY
, MapUnit::Map100thMM
);
759 else if (m_sLastShadowTbxId
== "slant")
761 nValueX
= m_xMtrFldShadowX
->get_value(FieldUnit::NONE
);
762 nValueY
= m_xMtrFldShadowY
->get_value(FieldUnit::NONE
);
765 XFormTextShadowXValItem
aShadowXItem( nValueX
);
766 XFormTextShadowYValItem
aShadowYItem( nValueY
);
768 // Slot-ID does not matter, the Exec method evaluates the entire item set
769 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_DISTANCE
,
771 { &aDistItem
, &aStartItem
, &aShadowXItem
, &aShadowYItem
});
774 IMPL_LINK_NOARG(SvxFontWorkDialog
, ColorSelectHdl_Impl
, ColorListBox
&, void)
776 XFormTextShadowColorItem
aItem( u
""_ustr
, m_xShadowColorLB
->GetSelectEntryColor() );
777 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_SHDWCOLOR
,
778 SfxCallMode::RECORD
, { &aItem
});
781 void SvxFontWorkDialog::ApplyImageList()
783 if (m_sLastShadowTbxId
== "slant")
785 m_xFbShadowX
->set_from_icon_name(RID_SVXBMP_SHADOW_ANGLE
);
786 m_xFbShadowY
->set_from_icon_name(RID_SVXBMP_SHADOW_SIZE
);
790 m_xFbShadowX
->set_from_icon_name(RID_SVXBMP_SHADOW_XDIST
);
791 m_xFbShadowY
->set_from_icon_name(RID_SVXBMP_SHADOW_YDIST
);
795 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */