LibreOffice Module svx (master) 1
fontwork.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#include <sfx2/module.hxx>
21#include <sfx2/dispatch.hxx>
22
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>
35
36#include <svtools/unitconv.hxx>
37#include <svx/svxids.hrc>
38#include <bitmaps.hlst>
39#include <svx/fontwork.hxx>
40
41#define WIDTH_CHARS 10
42
44
45// ControllerItem for Fontwork
46
48(
49 sal_uInt16 _nId,
51 SfxBindings& rBindings
52) :
53
54 SfxControllerItem( _nId, rBindings ),
55
56 rFontWorkDlg( rDlg )
57{
58}
59
60// StateChanged method for FontWork items
61
63 const SfxPoolItem* pItem )
64{
65 switch ( GetId() )
66 {
67 case SID_FORMTEXT_STYLE:
68 {
69 const XFormTextStyleItem* pStateItem =
70 dynamic_cast<const XFormTextStyleItem*>( pItem );
71 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextStyleItem expected");
72 rFontWorkDlg.SetStyle_Impl(pStateItem);
73 break;
74 }
75 case SID_FORMTEXT_ADJUST:
76 {
77 const XFormTextAdjustItem* pStateItem =
78 dynamic_cast<const XFormTextAdjustItem*>( pItem );
79 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextAdjustItem expected");
80 rFontWorkDlg.SetAdjust_Impl(pStateItem);
81 break;
82 }
83 case SID_FORMTEXT_DISTANCE:
84 {
85 const XFormTextDistanceItem* pStateItem =
86 dynamic_cast<const XFormTextDistanceItem*>( pItem );
87 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextDistanceItem expected");
89 break;
90 }
91 case SID_FORMTEXT_START:
92 {
93 const XFormTextStartItem* pStateItem =
94 dynamic_cast<const XFormTextStartItem*>( pItem );
95 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextStartItem expected");
96 rFontWorkDlg.SetStart_Impl(pStateItem);
97 break;
98 }
99 case SID_FORMTEXT_MIRROR:
100 {
101 const XFormTextMirrorItem* pStateItem =
102 dynamic_cast<const XFormTextMirrorItem*>( pItem );
103 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextMirrorItem expected");
104 rFontWorkDlg.SetMirror_Impl(pStateItem);
105 break;
106 }
107 case SID_FORMTEXT_HIDEFORM:
108 {
109 const XFormTextHideFormItem* pStateItem =
110 dynamic_cast<const XFormTextHideFormItem*>( pItem );
111 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextHideFormItem expected");
112 rFontWorkDlg.SetShowForm_Impl(pStateItem);
113 break;
114 }
115 case SID_FORMTEXT_OUTLINE:
116 {
117 const XFormTextOutlineItem* pStateItem =
118 dynamic_cast<const XFormTextOutlineItem*>( pItem );
119 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextOutlineItem expected");
120 rFontWorkDlg.SetOutline_Impl(pStateItem);
121 break;
122 }
123 case SID_FORMTEXT_SHADOW:
124 {
125 const XFormTextShadowItem* pStateItem =
126 dynamic_cast<const XFormTextShadowItem*>( pItem );
127 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextShadowItem expected");
128 rFontWorkDlg.SetShadow_Impl(pStateItem);
129 break;
130 }
131 case SID_FORMTEXT_SHDWCOLOR:
132 {
133 const XFormTextShadowColorItem* pStateItem =
134 dynamic_cast<const XFormTextShadowColorItem*>( pItem );
135 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextShadowColorItem expected");
137 break;
138 }
139 case SID_FORMTEXT_SHDWXVAL:
140 {
141 const XFormTextShadowXValItem* pStateItem =
142 dynamic_cast<const XFormTextShadowXValItem*>( pItem );
143 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextShadowXValItem expected");
145 break;
146 }
147 case SID_FORMTEXT_SHDWYVAL:
148 {
149 const XFormTextShadowYValItem* pStateItem =
150 dynamic_cast<const XFormTextShadowYValItem*>( pItem );
151 DBG_ASSERT(pStateItem || pItem == nullptr, "XFormTextShadowYValItem expected");
153 break;
154 }
155 }
156}
157
158// Derivation from SfxChildWindow as "containers" for Fontwork dialog
159
161(
162 vcl::Window* _pParent,
163 sal_uInt16 nId,
164 SfxBindings* pBindings,
165 SfxChildWinInfo* pInfo
166) :
167 SfxChildWindow( _pParent, nId )
168{
169 VclPtrInstance<SvxFontWorkDialog> pDlg(pBindings, this, _pParent);
170 SetWindow(pDlg);
171
172 pDlg->Initialize( pInfo );
173}
174
175// Floating Window to the attribution of text effects
177 SfxChildWindow *pCW,
178 vcl::Window* _pParent)
179 : SfxDockingWindow(pBindinx, pCW, _pParent, "DockingFontwork", "svx/ui/dockingfontwork.ui")
180 , rBindings(*pBindinx)
181 , aInputIdle("SvxFontWorkDialog Input")
182 , nSaveShadowX(0)
183 , nSaveShadowY(0)
184 , nSaveShadowAngle(450)
185 , nSaveShadowSize (100)
186 , m_xTbxStyle(m_xBuilder->weld_toolbar("style"))
187 , m_xTbxAdjust(m_xBuilder->weld_toolbar("adjust"))
188 , m_xMtrFldDistance(m_xBuilder->weld_metric_spin_button("distance", FieldUnit::CM))
189 , m_xMtrFldTextStart(m_xBuilder->weld_metric_spin_button("indent", FieldUnit::CM))
190 , m_xTbxShadow(m_xBuilder->weld_toolbar("shadow"))
191 , m_xFbShadowX(m_xBuilder->weld_image("shadowx"))
192 , m_xMtrFldShadowX(m_xBuilder->weld_metric_spin_button("distancex", FieldUnit::CM))
193 , m_xFbShadowY(m_xBuilder->weld_image("shadowy"))
194 , m_xMtrFldShadowY(m_xBuilder->weld_metric_spin_button("distancey", FieldUnit::CM))
195 , m_xShadowColorLB(new ColorListBox(m_xBuilder->weld_menu_button("color"), [this]{ return GetFrameWeld(); } ))
196{
197 SetText(SvxResId(RID_SVXSTR_FONTWORK));
198
200
201 pCtrlItems[0] = new SvxFontWorkControllerItem(SID_FORMTEXT_STYLE, *this, rBindings);
202 pCtrlItems[1] = new SvxFontWorkControllerItem(SID_FORMTEXT_ADJUST, *this, rBindings);
203 pCtrlItems[2] = new SvxFontWorkControllerItem(SID_FORMTEXT_DISTANCE, *this, rBindings);
204 pCtrlItems[3] = new SvxFontWorkControllerItem(SID_FORMTEXT_START, *this, rBindings);
205 pCtrlItems[4] = new SvxFontWorkControllerItem(SID_FORMTEXT_MIRROR, *this, rBindings);
206 pCtrlItems[5] = new SvxFontWorkControllerItem(SID_FORMTEXT_HIDEFORM, *this, rBindings);
207 pCtrlItems[6] = new SvxFontWorkControllerItem(SID_FORMTEXT_OUTLINE, *this, rBindings);
208 pCtrlItems[7] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHADOW, *this, rBindings);
209 pCtrlItems[8] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWCOLOR, *this, rBindings);
210 pCtrlItems[9] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWXVAL, *this, rBindings);
211 pCtrlItems[10] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWYVAL, *this, rBindings);
212
213 m_xTbxStyle->connect_clicked(LINK(this, SvxFontWorkDialog, SelectStyleHdl_Impl));
214 m_xTbxAdjust->connect_clicked(LINK(this, SvxFontWorkDialog, SelectAdjustHdl_Impl));
215 m_xTbxShadow->connect_clicked(LINK(this, SvxFontWorkDialog, SelectShadowHdl_Impl));
216
217 Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxFontWorkDialog, ModifyInputHdl_Impl);
218 m_xMtrFldDistance->connect_value_changed( aLink );
219 m_xMtrFldTextStart->connect_value_changed( aLink );
220 m_xMtrFldShadowX->connect_value_changed( aLink );
221 m_xMtrFldShadowY->connect_value_changed( aLink );
222
223 // Set System metric
224 const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
225 SetFieldUnit(*m_xMtrFldDistance, eDlgUnit, true);
226 SetFieldUnit(*m_xMtrFldTextStart, eDlgUnit, true);
227 SetFieldUnit(*m_xMtrFldShadowX, eDlgUnit, true);
228 SetFieldUnit(*m_xMtrFldShadowY, eDlgUnit, true);
229 if( eDlgUnit == FieldUnit::MM )
230 {
231 m_xMtrFldDistance->set_increments(50, 500, FieldUnit::NONE);
232 m_xMtrFldTextStart->set_increments(50, 500, FieldUnit::NONE);
233 m_xMtrFldShadowX->set_increments(50, 500, FieldUnit::NONE);
234 m_xMtrFldShadowY->set_increments(50, 500, FieldUnit::NONE);
235 }
236 else
237 {
238 m_xMtrFldDistance->set_increments(10, 100, FieldUnit::NONE);
239 m_xMtrFldTextStart->set_increments(10, 100, FieldUnit::NONE);
240 m_xMtrFldShadowX->set_increments(10, 100, FieldUnit::NONE);
241 m_xMtrFldShadowY->set_increments(10, 100, FieldUnit::NONE);
242 }
243 m_xMtrFldShadowX->set_width_chars(WIDTH_CHARS);
244 m_xMtrFldShadowY->set_width_chars(WIDTH_CHARS);
245
246 m_xShadowColorLB->SetSelectHdl( LINK(this, SvxFontWorkDialog, ColorSelectHdl_Impl) );
247
248 aInputIdle.SetPriority(TaskPriority::LOWEST);
249 aInputIdle.SetInvokeHandler(LINK(this, SvxFontWorkDialog, InputTimeoutHdl_Impl));
250}
251
253{
254 disposeOnce();
255}
256
258{
259 for (SvxFontWorkControllerItem* pCtrlItem : pCtrlItems)
260 pCtrlItem->dispose();
261 m_xTbxStyle.reset();
262 m_xTbxAdjust.reset();
263 m_xMtrFldDistance.reset();
264 m_xMtrFldTextStart.reset();
265 m_xTbxShadow.reset();
266 m_xFbShadowX.reset();
267 m_xMtrFldShadowX.reset();
268 m_xFbShadowY.reset();
269 m_xMtrFldShadowY.reset();
270 m_xShadowColorLB.reset();
272}
273
275 SfxChildAlignment eAlign )
276{
277 SfxChildAlignment eAlignment;
278
279 switch ( eAlign )
280 {
281 case SfxChildAlignment::TOP:
282 case SfxChildAlignment::HIGHESTTOP:
283 case SfxChildAlignment::LOWESTTOP:
284 case SfxChildAlignment::BOTTOM:
285 case SfxChildAlignment::LOWESTBOTTOM:
286 case SfxChildAlignment::HIGHESTBOTTOM:
287 {
288 eAlignment = eActAlign;
289 }
290 break;
291
292 case SfxChildAlignment::LEFT:
293 case SfxChildAlignment::RIGHT:
294 case SfxChildAlignment::FIRSTLEFT:
295 case SfxChildAlignment::LASTLEFT:
296 case SfxChildAlignment::FIRSTRIGHT:
297 case SfxChildAlignment::LASTRIGHT:
298 {
299 eAlignment = eAlign;
300 }
301 break;
302
303 default:
304 {
305 eAlignment = eAlign;
306 }
307 break;
308 }
309
310 return eAlignment;
311}
312
313// Set style buttons
315{
316 if ( pItem )
317 {
318 OUString sId = "off";
319
320 switch ( pItem->GetValue() )
321 {
322 case XFormTextStyle::Rotate : sId = "rotate"; break;
323 case XFormTextStyle::Upright: sId = "upright"; break;
324 case XFormTextStyle::SlantX : sId = "hori"; break;
325 case XFormTextStyle::SlantY : sId = "vert"; break;
326 default: ;//prevent warning
327 }
328 m_xTbxStyle->set_sensitive(true);
329
330 // Make sure that there is always exactly one checked toolbox item.
331 if ( pItem->GetValue() == XFormTextStyle::NONE )
332 {
333 m_xTbxStyle->set_item_active("rotate", false);
334 m_xTbxStyle->set_item_active("upright", false);
335 m_xTbxStyle->set_item_active("hori", false);
336 m_xTbxStyle->set_item_active("vert", false);
337
338 m_xTbxStyle->set_item_active("off", true);
339 }
340 else
341 {
342 m_xTbxStyle->set_item_active("off", false);
343 m_xTbxStyle->set_item_active(sId, true);
344 }
345
347 }
348 else
349 m_xTbxStyle->set_sensitive(false);
350}
351
352// Set adjust buttons
353
355{
356 if ( pItem )
357 {
358 OUString sId;
359
360 m_xTbxAdjust->set_sensitive(true);
361 m_xMtrFldDistance->set_sensitive(true);
362
363 if ( pItem->GetValue() == XFormTextAdjust::Left || pItem->GetValue() == XFormTextAdjust::Right )
364 {
365 if (pItem->GetValue() == XFormTextAdjust::Left)
366 sId = "left";
367 else
368 sId = "right";
369 m_xMtrFldTextStart->set_sensitive(true);
370 }
371 else
372 {
373 if (pItem->GetValue() == XFormTextAdjust::Center)
374 sId = "center";
375 else
376 sId = "autosize";
377 m_xMtrFldTextStart->set_sensitive(false);
378 }
379
380 if (!m_xTbxAdjust->get_item_active(sId))
381 m_xTbxAdjust->set_item_active(sId, true);
382
384 }
385 else
386 {
387 m_xTbxAdjust->set_sensitive(false);
388 m_xMtrFldTextStart->set_sensitive(false);
389 m_xMtrFldDistance->set_sensitive(false);
390 }
391}
392
393// Enter Distance value in the edit field
394
396{
397 if (pItem && !m_xMtrFldDistance->has_focus())
398 {
399 SetMetricValue(*m_xMtrFldDistance, pItem->GetValue(), MapUnit::Map100thMM);
400 }
401}
402
403// Enter indent value in the edit field
404
406{
407 if (pItem && !m_xMtrFldTextStart->has_focus())
408 {
409 SetMetricValue(*m_xMtrFldTextStart, pItem->GetValue(), MapUnit::Map100thMM);
410 }
411}
412
413// Set button for reversing the direction of text
414
416{
417 if ( pItem )
418 m_xTbxAdjust->set_item_active("orientation", pItem->GetValue());
419}
420
421// Set button for contour display
422
424{
425 if ( pItem )
426 m_xTbxShadow->set_item_active("contour", !pItem->GetValue());
427}
428
429// Set button for text border
430
432{
433 if ( pItem )
434 m_xTbxShadow->set_item_active("textcontour", pItem->GetValue());
435}
436
437// Set shadow buttons
438
440 bool bRestoreValues)
441{
442 if ( pItem )
443 {
444 OUString sId;
445
446 m_xTbxShadow->set_sensitive(true);
447
448 if ( pItem->GetValue() == XFormTextShadow::NONE )
449 {
450 sId = "noshadow";
451 m_xFbShadowX->hide();
452 m_xFbShadowY->hide();
453 m_xMtrFldShadowX->set_sensitive(false);
454 m_xMtrFldShadowY->set_sensitive(false);
455 m_xShadowColorLB->set_sensitive(false);
456 }
457 else
458 {
459 m_xFbShadowX->show();
460 m_xFbShadowY->show();
461 m_xMtrFldShadowX->set_sensitive(true);
462 m_xMtrFldShadowY->set_sensitive(true);
463 m_xShadowColorLB->set_sensitive(true);
464
465 if ( pItem->GetValue() == XFormTextShadow::Normal )
466 {
467 sId = "vertical";
468 const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
469
470 m_xMtrFldShadowX->set_unit( eDlgUnit );
471 m_xMtrFldShadowX->set_digits(2);
472 m_xMtrFldShadowX->set_range(INT_MIN, INT_MAX, FieldUnit::NONE);
473 if( eDlgUnit == FieldUnit::MM )
474 m_xMtrFldShadowX->set_increments(50, 500, FieldUnit::NONE);
475 else
476 m_xMtrFldShadowX->set_increments(10, 100, FieldUnit::NONE);
477 m_xMtrFldShadowX->set_width_chars(WIDTH_CHARS);
478
479 m_xMtrFldShadowY->set_unit( eDlgUnit );
480 m_xMtrFldShadowY->set_digits(2);
481 m_xMtrFldShadowY->set_range(INT_MIN, INT_MAX, FieldUnit::NONE);
482 if( eDlgUnit == FieldUnit::MM )
483 m_xMtrFldShadowY->set_increments(50, 500, FieldUnit::NONE);
484 else
485 m_xMtrFldShadowY->set_increments(10, 100, FieldUnit::NONE);
486 m_xMtrFldShadowY->set_width_chars(WIDTH_CHARS);
487
488 if ( bRestoreValues )
489 {
490 SetMetricValue(*m_xMtrFldShadowX, nSaveShadowX, MapUnit::Map100thMM);
491 SetMetricValue(*m_xMtrFldShadowY, nSaveShadowY, MapUnit::Map100thMM);
492
495
497 SID_FORMTEXT_SHDWXVAL, SfxCallMode::RECORD,
498 { &aXItem, &aYItem });
499 }
500 }
501 else
502 {
503 sId = "slant";
504
505 m_xMtrFldShadowX->set_unit(FieldUnit::DEGREE);
506 m_xMtrFldShadowX->set_digits(1);
507 m_xMtrFldShadowX->set_range(-1800, 1800, FieldUnit::NONE);
508 m_xMtrFldShadowX->set_increments(10, 100, FieldUnit::NONE);
509 m_xMtrFldShadowX->set_width_chars(WIDTH_CHARS);
510
511 m_xMtrFldShadowY->set_unit(FieldUnit::PERCENT);
512 m_xMtrFldShadowY->set_digits(0);
513 m_xMtrFldShadowY->set_range(-999, 999, FieldUnit::NONE);
514 m_xMtrFldShadowY->set_increments(10, 100, FieldUnit::NONE);
515 m_xMtrFldShadowY->set_width_chars(WIDTH_CHARS);
516
517 if ( bRestoreValues )
518 {
519 m_xMtrFldShadowX->set_value(nSaveShadowAngle, FieldUnit::NONE);
520 m_xMtrFldShadowY->set_value(nSaveShadowSize, FieldUnit::NONE);
524 SID_FORMTEXT_SHDWXVAL, SfxCallMode::RECORD,
525 { &aXItem, &aYItem });
526 }
527 }
528 }
529
530 if (!m_xTbxShadow->get_item_active(sId))
531 m_xTbxShadow->set_item_active(sId, true);
533
535 }
536 else
537 {
538 m_xTbxShadow->set_sensitive(false);
539 m_xMtrFldShadowX->set_sensitive(false);
540 m_xMtrFldShadowY->set_sensitive(false);
541 m_xShadowColorLB->set_sensitive(false);
542 }
543}
544
545// Insert shadow color in listbox
546
548{
549 if ( pItem )
550 m_xShadowColorLB->SelectEntry(pItem->GetColorValue());
551}
552
553// Enter X-value for shadow in edit field
555{
556 if (!pItem || m_xMtrFldShadowX->has_focus())
557 return;
558
559 // #i19251#
560 // sal_Int32 nValue = pItem->GetValue();
561
562 // #i19251#
563 // The two involved fields/items are used double and contain/give different
564 // values regarding to the access method. Thus, here we need to separate the access
565 // methods regarding to the kind of value accessed.
566 if (m_xTbxShadow->get_item_active("slant"))
567 {
568 // #i19251#
569 // There is no value correction necessary at all, i think this
570 // was only tried to be done without understanding that the two
571 // involved fields/items are used double and contain/give different
572 // values regarding to the access method.
573 // nValue = nValue - ( int( float( nValue ) / 360.0 ) * 360 );
574 m_xMtrFldShadowX->set_value(pItem->GetValue(), FieldUnit::NONE);
575 }
576 else
577 {
578 SetMetricValue(*m_xMtrFldShadowX, pItem->GetValue(), MapUnit::Map100thMM);
579 }
580}
581
582// Enter Y-value for shadow in edit field
584{
585 if (!pItem || m_xMtrFldShadowY->has_focus())
586 return;
587
588 // #i19251#
589 // The two involved fields/items are used double and contain/give different
590 // values regarding to the access method. Thus, here we need to separate the access
591 // methods regarding to the kind of value accessed.
592 if (m_xTbxShadow->get_item_active("slant"))
593 {
594 m_xMtrFldShadowY->set_value(pItem->GetValue(), FieldUnit::NONE);
595 }
596 else
597 {
598 SetMetricValue(*m_xMtrFldShadowY, pItem->GetValue(), MapUnit::Map100thMM);
599 }
600}
601
602IMPL_LINK(SvxFontWorkDialog, SelectStyleHdl_Impl, const OUString&, rId, void)
603{
604 // Execute this block when a different toolbox item has been clicked or
605 // when the off item has been clicked. The later is necessary to
606 // override the toolbox behaviour of unchecking the item after second
607 // click on it: One of the items has to be checked at all times (when
608 // enabled that is.)
609 if (rId != "off" && rId == m_sLastStyleTbxId)
610 return;
611
613
614 if (rId == "rotate")
615 eStyle = XFormTextStyle::Rotate;
616 else if (rId == "upright")
618 else if (rId == "hori")
619 eStyle = XFormTextStyle::SlantX;
620 else if (rId == "vert")
621 eStyle = XFormTextStyle::SlantY;
622
623 XFormTextStyleItem aItem( eStyle );
624 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_STYLE,
625 SfxCallMode::RECORD, { &aItem });
626 SetStyle_Impl( &aItem );
627 m_sLastStyleTbxId = rId;
628}
629
630IMPL_LINK(SvxFontWorkDialog, SelectAdjustHdl_Impl, const OUString&, rId, void)
631{
632 if (rId == "orientation")
633 {
634 XFormTextMirrorItem aItem(m_xTbxAdjust->get_item_active(rId));
635 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_MIRROR,
636 SfxCallMode::SLOT, { &aItem });
637 }
638 else if (rId != m_sLastAdjustTbxId)
639 {
641
642 if (rId == "left")
643 eAdjust = XFormTextAdjust::Left;
644 else if (rId == "center")
645 eAdjust = XFormTextAdjust::Center;
646 else if (rId == "right")
647 eAdjust = XFormTextAdjust::Right;
648
649 XFormTextAdjustItem aItem(eAdjust);
650 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_ADJUST,
651 SfxCallMode::RECORD, { &aItem });
652 SetAdjust_Impl(&aItem);
653 m_sLastAdjustTbxId = rId;
654 }
655}
656
657IMPL_LINK(SvxFontWorkDialog, SelectShadowHdl_Impl, const OUString&, rId, void)
658{
659 if (rId == "contour")
660 {
661 XFormTextHideFormItem aItem(!m_xTbxShadow->get_item_active(rId));
662 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_HIDEFORM,
663 SfxCallMode::RECORD, { &aItem });
664 }
665 else if (rId == "textcontour")
666 {
667 XFormTextOutlineItem aItem(m_xTbxShadow->get_item_active(rId));
668 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_OUTLINE,
669 SfxCallMode::RECORD, { &aItem });
670 }
671 else if (rId != m_sLastShadowTbxId)
672 {
674
675 if (m_sLastShadowTbxId == "vertical")
676 {
677 nSaveShadowX = GetCoreValue(*m_xMtrFldShadowX, MapUnit::Map100thMM);
678 nSaveShadowY = GetCoreValue(*m_xMtrFldShadowY, MapUnit::Map100thMM);
679 }
680 else if (m_sLastShadowTbxId == "slant")
681 {
682 nSaveShadowAngle = m_xMtrFldShadowX->get_value(FieldUnit::NONE);
683 nSaveShadowSize = m_xMtrFldShadowY->get_value(FieldUnit::NONE);
684 }
685 m_sLastShadowTbxId = rId;
686
687 if ( rId == "vertical") eShadow = XFormTextShadow::Normal;
688 else if (rId == "slant") eShadow = XFormTextShadow::Slant;
689
690 XFormTextShadowItem aItem(eShadow);
691 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_SHADOW,
692 SfxCallMode::RECORD, { &aItem });
693 SetShadow_Impl(&aItem, true);
694 }
695}
696
698{
699 aInputIdle.Start();
700}
701
702IMPL_LINK_NOARG(SvxFontWorkDialog, InputTimeoutHdl_Impl, Timer*, void)
703{
704 // Possibly set the Metric system again. This should be done with a
705 // listen, this is however not possible at the moment due to compatibility
706 // issues.
707 const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
708 if( eDlgUnit != m_xMtrFldDistance->get_unit() )
709 {
710 SetFieldUnit(*m_xMtrFldDistance, eDlgUnit, true);
711 SetFieldUnit(*m_xMtrFldTextStart, eDlgUnit, true);
712 if (eDlgUnit == FieldUnit::MM)
713 {
714 m_xMtrFldDistance->set_increments(50, 500, FieldUnit::NONE);
715 m_xMtrFldTextStart->set_increments(50, 500, FieldUnit::NONE);
716 }
717 else
718 {
719 m_xMtrFldDistance->set_increments(10, 100, FieldUnit::NONE);
720 m_xMtrFldTextStart->set_increments(10, 100, FieldUnit::NONE);
721 }
722 }
723 if( eDlgUnit != m_xMtrFldShadowX->get_unit() &&
724 m_xTbxShadow->get_item_active("vertical") )
725 {
726 SetFieldUnit(*m_xMtrFldShadowX, eDlgUnit, true);
727 SetFieldUnit(*m_xMtrFldShadowY, eDlgUnit, true);
728
729 if (eDlgUnit == FieldUnit::MM)
730 {
731 m_xMtrFldShadowX->set_increments(50, 500, FieldUnit::NONE);
732 m_xMtrFldShadowY->set_increments(50, 500, FieldUnit::NONE);
733 }
734 else
735 {
736 m_xMtrFldShadowX->set_increments(10, 100, FieldUnit::NONE);
737 m_xMtrFldShadowY->set_increments(10, 100, FieldUnit::NONE);
738 }
739 }
740
741 tools::Long nValue = GetCoreValue(*m_xMtrFldDistance, MapUnit::Map100thMM);
742 XFormTextDistanceItem aDistItem( nValue );
743 nValue = GetCoreValue(*m_xMtrFldTextStart, MapUnit::Map100thMM);
744 XFormTextStartItem aStartItem( nValue );
745
746 sal_Int32 nValueX(0);
747 sal_Int32 nValueY(0);
748
749 // #i19251#
750 // The two involved fields/items are used double and contain/give different
751 // values regarding to the access method. Thus, here we need to separate the access
752 // method regarding to the kind of value accessed.
753 if (m_sLastShadowTbxId == "vertical")
754 {
755 nValueX = GetCoreValue(*m_xMtrFldShadowX, MapUnit::Map100thMM);
756 nValueY = GetCoreValue(*m_xMtrFldShadowY, MapUnit::Map100thMM);
757 }
758 else if (m_sLastShadowTbxId == "slant")
759 {
760 nValueX = m_xMtrFldShadowX->get_value(FieldUnit::NONE);
761 nValueY = m_xMtrFldShadowY->get_value(FieldUnit::NONE);
762 }
763
764 XFormTextShadowXValItem aShadowXItem( nValueX );
765 XFormTextShadowYValItem aShadowYItem( nValueY );
766
767 // Slot-ID does not matter, the Exec method evaluates the entire item set
768 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_DISTANCE,
769 SfxCallMode::RECORD,
770 { &aDistItem, &aStartItem, &aShadowXItem, &aShadowYItem });
771}
772
773IMPL_LINK_NOARG(SvxFontWorkDialog, ColorSelectHdl_Impl, ColorListBox&, void)
774{
775 XFormTextShadowColorItem aItem( "", m_xShadowColorLB->GetSelectEntryColor() );
776 GetBindings().GetDispatcher()->ExecuteList(SID_FORMTEXT_SHDWCOLOR,
777 SfxCallMode::RECORD, { &aItem });
778}
779
781{
782 if (m_sLastShadowTbxId == "slant")
783 {
784 m_xFbShadowX->set_from_icon_name(RID_SVXBMP_SHADOW_ANGLE);
785 m_xFbShadowY->set_from_icon_name(RID_SVXBMP_SHADOW_SIZE);
786 }
787 else
788 {
789 m_xFbShadowX->set_from_icon_name(RID_SVXBMP_SHADOW_XDIST);
790 m_xFbShadowY->set_from_icon_name(RID_SVXBMP_SHADOW_YDIST);
791 }
792}
793
794/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxChildAlignment
sal_Int32 GetValue() const
SfxDispatcher * GetDispatcher() const
bool GetValue() const
void SetWindow(const VclPtr< vcl::Window > &p)
sal_uInt16 GetId() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxModule * GetModule() const
SfxBindings & GetBindings() const
virtual void dispose() override
EnumT GetValue() const
FieldUnit GetFieldUnit() const
Derived from SfxChildWindow as "container" for fontwork dialog.
Definition: fontwork.hxx:63
SvxFontWorkChildWindow(vcl::Window *, sal_uInt16, SfxBindings *, SfxChildWinInfo *)
Definition: fontwork.cxx:161
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: fontwork.cxx:62
SvxFontWorkDialog & rFontWorkDlg
Definition: fontwork.hxx:50
SvxFontWorkControllerItem(sal_uInt16 nId, SvxFontWorkDialog &, SfxBindings &)
Definition: fontwork.cxx:48
Floating window for setting attributes of text effects.
Definition: fontwork.hxx:73
void SetShadowYVal_Impl(const XFormTextShadowYValItem *)
Definition: fontwork.cxx:583
void SetShadowXVal_Impl(const XFormTextShadowXValItem *)
Definition: fontwork.cxx:554
SfxBindings & rBindings
Definition: fontwork.hxx:76
void SetOutline_Impl(const XFormTextOutlineItem *)
Definition: fontwork.cxx:431
tools::Long nSaveShadowX
Definition: fontwork.hxx:83
void SetShadowColor_Impl(const XFormTextShadowColorItem *)
Definition: fontwork.cxx:547
std::unique_ptr< weld::Image > m_xFbShadowY
Definition: fontwork.hxx:100
void SetAdjust_Impl(const XFormTextAdjustItem *)
Definition: fontwork.cxx:354
OUString m_sLastAdjustTbxId
Definition: fontwork.hxx:80
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldShadowX
Definition: fontwork.hxx:99
std::unique_ptr< ColorListBox > m_xShadowColorLB
Definition: fontwork.hxx:103
void SetMirror_Impl(const XFormTextMirrorItem *)
Definition: fontwork.cxx:415
OUString m_sLastStyleTbxId
Definition: fontwork.hxx:79
OUString m_sLastShadowTbxId
Definition: fontwork.hxx:81
void SetStyle_Impl(const XFormTextStyleItem *)
Definition: fontwork.cxx:314
void SetShadow_Impl(const XFormTextShadowItem *, bool bRestoreValues=false)
Definition: fontwork.cxx:439
void SetShowForm_Impl(const XFormTextHideFormItem *)
Definition: fontwork.cxx:423
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldTextStart
Definition: fontwork.hxx:94
virtual void dispose() override
Definition: fontwork.cxx:257
friend class SvxFontWorkControllerItem
Definition: fontwork.hxx:106
std::unique_ptr< weld::Image > m_xFbShadowX
Definition: fontwork.hxx:98
tools::Long nSaveShadowY
Definition: fontwork.hxx:84
void SetStart_Impl(const XFormTextStartItem *)
Definition: fontwork.cxx:405
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldDistance
Definition: fontwork.hxx:93
virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActAlign, SfxChildAlignment eAlign) override
Definition: fontwork.cxx:274
std::unique_ptr< weld::Toolbar > m_xTbxStyle
Definition: fontwork.hxx:90
void ApplyImageList()
Definition: fontwork.cxx:780
tools::Long nSaveShadowAngle
Definition: fontwork.hxx:85
std::unique_ptr< weld::Toolbar > m_xTbxAdjust
Definition: fontwork.hxx:91
virtual ~SvxFontWorkDialog() override
Definition: fontwork.cxx:252
std::unique_ptr< weld::Toolbar > m_xTbxShadow
Definition: fontwork.hxx:96
SvxFontWorkDialog(SfxBindings *pBinding, SfxChildWindow *pCW, vcl::Window *pParent)
Definition: fontwork.cxx:176
tools::Long nSaveShadowSize
Definition: fontwork.hxx:86
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldShadowY
Definition: fontwork.hxx:101
SvxFontWorkControllerItem * pCtrlItems[CONTROLLER_COUNT]
Definition: fontwork.hxx:88
void SetDistance_Impl(const XFormTextDistanceItem *)
Definition: fontwork.cxx:395
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
const Color & GetColorValue() const
Definition: xattr.cxx:302
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual void SetText(const OUString &rStr) override
virtual SfxBindings & GetBindings() override
FieldUnit
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
IMPL_LINK_NOARG(SvxFontWorkDialog, ModifyInputHdl_Impl, weld::MetricSpinButton &, void)
Definition: fontwork.cxx:697
#define WIDTH_CHARS
Definition: fontwork.cxx:41
SFX_IMPL_DOCKINGWINDOW_WITHID(SvxFontWorkChildWindow, SID_FONTWORK)
IMPL_LINK(SvxFontWorkDialog, SelectStyleHdl_Impl, const OUString &, rId, void)
Definition: fontwork.cxx:602
long Long
sal_Int16 nId
SfxItemState
SVT_DLLPUBLIC sal_Int64 GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
SVT_DLLPUBLIC void SetMetricValue(weld::MetricSpinButton &rField, sal_Int64 nCoreValue, MapUnit eUnit)
SVT_DLLPUBLIC void SetFieldUnit(weld::MetricSpinButton &rCtrl, FieldUnit eUnit, bool bAll=false)
OUString sId
XFormTextStyle
Definition: xenum.hxx:24
XFormTextAdjust
Definition: xenum.hxx:25
XFormTextShadow
Definition: xenum.hxx:26