bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / dialog / fontwork.cxx
blob32aab9e8a89c27ef067e8e3a144a238f1ddcb1be
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <tools/shl.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdopath.hxx>
26 #include <svx/svdview.hxx>
27 #include <svx/svdocirc.hxx>
28 #include <svx/xtextit.hxx>
30 #include <svx/dialmgr.hxx>
31 #include "svx/dlgutil.hxx"
33 #include <svx/dialogs.hrc>
34 #include "fontwork.hrc"
35 #include <svx/fontwork.hxx>
36 #include <editeng/outlobj.hxx>
37 #include <basegfx/polygon/b2dpolygon.hxx>
38 #include <basegfx/point/b2dpoint.hxx>
40 SFX_IMPL_DOCKINGWINDOW_WITHID( SvxFontWorkChildWindow, SID_FONTWORK );
42 // ControllerItem for Fontwork
44 SvxFontWorkControllerItem::SvxFontWorkControllerItem
46 sal_uInt16 _nId,
47 SvxFontWorkDialog& rDlg,
48 SfxBindings& rBindings
49 ) :
51 SfxControllerItem( _nId, rBindings ),
53 rFontWorkDlg( rDlg )
57 // StateChanged method for FontWork items
59 void SvxFontWorkControllerItem::StateChanged( sal_uInt16 /*nSID*/, SfxItemState /*eState*/,
60 const SfxPoolItem* pItem )
62 switch ( GetId() )
64 case SID_FORMTEXT_STYLE:
66 const XFormTextStyleItem* pStateItem =
67 PTR_CAST(XFormTextStyleItem, pItem);
68 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStyleItem expected");
69 rFontWorkDlg.SetStyle_Impl(pStateItem);
70 break;
72 case SID_FORMTEXT_ADJUST:
74 const XFormTextAdjustItem* pStateItem =
75 PTR_CAST(XFormTextAdjustItem, pItem);
76 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextAdjustItem expected");
77 rFontWorkDlg.SetAdjust_Impl(pStateItem);
78 break;
80 case SID_FORMTEXT_DISTANCE:
82 const XFormTextDistanceItem* pStateItem =
83 PTR_CAST(XFormTextDistanceItem, pItem);
84 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextDistanceItem erwartet");
85 rFontWorkDlg.SetDistance_Impl(pStateItem);
86 break;
88 case SID_FORMTEXT_START:
90 const XFormTextStartItem* pStateItem =
91 PTR_CAST(XFormTextStartItem, pItem);
92 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStartItem expected");
93 rFontWorkDlg.SetStart_Impl(pStateItem);
94 break;
96 case SID_FORMTEXT_MIRROR:
98 const XFormTextMirrorItem* pStateItem =
99 PTR_CAST(XFormTextMirrorItem, pItem);
100 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextMirrorItem expected");
101 rFontWorkDlg.SetMirror_Impl(pStateItem);
102 break;
104 case SID_FORMTEXT_STDFORM:
106 const XFormTextStdFormItem* pStateItem =
107 PTR_CAST(XFormTextStdFormItem, pItem);
108 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStdFormItem expected");
109 rFontWorkDlg.SetStdForm_Impl(pStateItem);
110 break;
112 case SID_FORMTEXT_HIDEFORM:
114 const XFormTextHideFormItem* pStateItem =
115 PTR_CAST(XFormTextHideFormItem, pItem);
116 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextHideFormItem expected");
117 rFontWorkDlg.SetShowForm_Impl(pStateItem);
118 break;
120 case SID_FORMTEXT_OUTLINE:
122 const XFormTextOutlineItem* pStateItem =
123 PTR_CAST(XFormTextOutlineItem, pItem);
124 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextOutlineItem expected");
125 rFontWorkDlg.SetOutline_Impl(pStateItem);
126 break;
128 case SID_FORMTEXT_SHADOW:
130 const XFormTextShadowItem* pStateItem =
131 PTR_CAST(XFormTextShadowItem, pItem);
132 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowItem expected");
133 rFontWorkDlg.SetShadow_Impl(pStateItem);
134 break;
136 case SID_FORMTEXT_SHDWCOLOR:
138 const XFormTextShadowColorItem* pStateItem =
139 PTR_CAST(XFormTextShadowColorItem, pItem);
140 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowColorItem expected");
141 rFontWorkDlg.SetShadowColor_Impl(pStateItem);
142 break;
144 case SID_FORMTEXT_SHDWXVAL:
146 const XFormTextShadowXValItem* pStateItem =
147 PTR_CAST(XFormTextShadowXValItem, pItem);
148 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowXValItem expected");
149 rFontWorkDlg.SetShadowXVal_Impl(pStateItem);
150 break;
152 case SID_FORMTEXT_SHDWYVAL:
154 const XFormTextShadowYValItem* pStateItem =
155 PTR_CAST(XFormTextShadowYValItem, pItem);
156 DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowYValItem expected");
157 rFontWorkDlg.SetShadowYVal_Impl(pStateItem);
158 break;
163 // Derivation from SfxChildWindow as "containers" for Fontwork dialog
165 SvxFontWorkChildWindow::SvxFontWorkChildWindow
167 Window* _pParent,
168 sal_uInt16 nId,
169 SfxBindings* pBindings,
170 SfxChildWinInfo* pInfo
173 SfxChildWindow( _pParent, nId )
176 pWindow = new SvxFontWorkDialog( pBindings, this, _pParent,
177 SVX_RES( RID_SVXDLG_FONTWORK ) );
178 SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*) pWindow;
180 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
182 pDlg->Initialize( pInfo );
185 // Floating Window to the attribution of text effects
187 SvxFontWorkDialog::SvxFontWorkDialog( SfxBindings *pBindinx,
188 SfxChildWindow *pCW,
189 Window* _pParent,
190 const ResId& rResId ) :
191 SfxDockingWindow( pBindinx, pCW, _pParent, rResId ),
193 aFormSet (this, ResId(VS_FORMS,*rResId.GetResMgr())),
195 aTbxStyle (this, ResId(TBX_STYLE,*rResId.GetResMgr())),
196 aTbxAdjust (this, ResId(TBX_ADJUST,*rResId.GetResMgr())),
198 aFbDistance (this, ResId(FB_DISTANCE,*rResId.GetResMgr())),
199 aMtrFldDistance (this, ResId(MTR_FLD_DISTANCE,*rResId.GetResMgr())),
200 aFbTextStart (this, ResId(FB_TEXTSTART,*rResId.GetResMgr())),
201 aMtrFldTextStart(this, ResId(MTR_FLD_TEXTSTART,*rResId.GetResMgr())),
203 aTbxShadow (this, ResId(TBX_SHADOW,*rResId.GetResMgr())),
205 aFbShadowX (this, ResId(FB_SHADOW_X,*rResId.GetResMgr())),
206 aMtrFldShadowX (this, ResId(MTR_FLD_SHADOW_X,*rResId.GetResMgr())),
207 aFbShadowY (this, ResId(FB_SHADOW_Y,*rResId.GetResMgr())),
208 aMtrFldShadowY (this, ResId(MTR_FLD_SHADOW_Y,*rResId.GetResMgr())),
210 aShadowColorLB (this, ResId(CLB_SHADOW_COLOR,*rResId.GetResMgr())),
211 rBindings (*pBindinx),
213 nLastStyleTbxId(0),
214 nLastAdjustTbxId(0),
215 nLastShadowTbxId(0),
216 nSaveShadowX (0),
217 nSaveShadowY (0),
218 nSaveShadowAngle(450),
219 nSaveShadowSize (100),
221 maImageList (ResId(IL_FONTWORK,*rResId.GetResMgr()))
223 FreeResource();
225 ApplyImageList();
227 pCtrlItems[0] = new SvxFontWorkControllerItem(SID_FORMTEXT_STYLE, *this, rBindings);
228 pCtrlItems[1] = new SvxFontWorkControllerItem(SID_FORMTEXT_ADJUST, *this, rBindings);
229 pCtrlItems[2] = new SvxFontWorkControllerItem(SID_FORMTEXT_DISTANCE, *this, rBindings);
230 pCtrlItems[3] = new SvxFontWorkControllerItem(SID_FORMTEXT_START, *this, rBindings);
231 pCtrlItems[4] = new SvxFontWorkControllerItem(SID_FORMTEXT_MIRROR, *this, rBindings);
232 pCtrlItems[5] = new SvxFontWorkControllerItem(SID_FORMTEXT_STDFORM, *this, rBindings);
233 pCtrlItems[6] = new SvxFontWorkControllerItem(SID_FORMTEXT_HIDEFORM, *this, rBindings);
234 pCtrlItems[7] = new SvxFontWorkControllerItem(SID_FORMTEXT_OUTLINE, *this, rBindings);
235 pCtrlItems[8] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHADOW, *this, rBindings);
236 pCtrlItems[9] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWCOLOR, *this, rBindings);
237 pCtrlItems[10] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWXVAL, *this, rBindings);
238 pCtrlItems[11] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWYVAL, *this, rBindings);
240 WinBits aNewStyle = ( aFormSet.GetStyle() | WB_VSCROLL | WB_ITEMBORDER | WB_DOUBLEBORDER );
241 aFormSet.SetStyle( aNewStyle );
243 Size aSize = aTbxStyle.CalcWindowSizePixel();
244 aTbxStyle.SetSizePixel(aSize);
245 aTbxStyle.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectStyleHdl_Impl) );
247 aTbxAdjust.SetSizePixel(aSize);
248 aTbxAdjust.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectAdjustHdl_Impl) );
250 aTbxShadow.SetSizePixel(aSize);
251 aTbxShadow.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectShadowHdl_Impl) );
253 Link aLink = LINK(this, SvxFontWorkDialog, ModifyInputHdl_Impl);
254 aMtrFldDistance.SetModifyHdl( aLink );
255 aMtrFldTextStart.SetModifyHdl( aLink );
256 aMtrFldShadowX.SetModifyHdl( aLink );
257 aMtrFldShadowY.SetModifyHdl( aLink );
259 // Set System metric
260 const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
261 SetFieldUnit( aMtrFldDistance, eDlgUnit, sal_True );
262 SetFieldUnit( aMtrFldTextStart, eDlgUnit, sal_True );
263 SetFieldUnit( aMtrFldShadowX, eDlgUnit, sal_True );
264 SetFieldUnit( aMtrFldShadowY, eDlgUnit, sal_True );
265 if( eDlgUnit == FUNIT_MM )
267 aMtrFldDistance.SetSpinSize( 50 );
268 aMtrFldTextStart.SetSpinSize( 50 );
269 aMtrFldShadowX.SetSpinSize( 50 );
270 aMtrFldShadowY.SetSpinSize( 50 );
272 else
274 aMtrFldDistance.SetSpinSize( 10 );
275 aMtrFldTextStart.SetSpinSize( 10 );
276 aMtrFldShadowX.SetSpinSize( 10 );
277 aMtrFldShadowY.SetSpinSize( 10 );
280 aShadowColorLB.SetSelectHdl( LINK(this, SvxFontWorkDialog, ColorSelectHdl_Impl) );
282 aInputTimer.SetTimeout(500);
283 aInputTimer.SetTimeoutHdl(LINK(this, SvxFontWorkDialog, InputTimoutHdl_Impl));
285 aFormSet.SetSelectHdl( LINK(this, SvxFontWorkDialog, FormSelectHdl_Impl) );
286 aFormSet.SetColCount(4);
287 aFormSet.SetLineCount(2);
289 Bitmap aBmp(SVX_RES(RID_SVXBMP_FONTWORK_FORM1));
290 aSize.Height() = aFormSet.CalcWindowSizePixel(aBmp.GetSizePixel()).Height() + 2;
291 aFormSet.SetSizePixel(aSize);
294 SvxFontWorkDialog::~SvxFontWorkDialog()
296 for (sal_uInt16 i = 0; i < CONTROLLER_COUNT; i++)
297 DELETEZ(pCtrlItems[i]);
300 void SvxFontWorkDialog::Zoom()
302 SfxDockingWindow::Roll();
305 SfxChildAlignment SvxFontWorkDialog::CheckAlignment( SfxChildAlignment eActAlign,
306 SfxChildAlignment eAlign )
308 SfxChildAlignment eAlignment;
310 switch ( eAlign )
312 case SFX_ALIGN_TOP:
313 case SFX_ALIGN_HIGHESTTOP:
314 case SFX_ALIGN_LOWESTTOP:
315 case SFX_ALIGN_BOTTOM:
316 case SFX_ALIGN_LOWESTBOTTOM:
317 case SFX_ALIGN_HIGHESTBOTTOM:
319 eAlignment = eActAlign;
321 break;
323 case SFX_ALIGN_LEFT:
324 case SFX_ALIGN_RIGHT:
325 case SFX_ALIGN_FIRSTLEFT:
326 case SFX_ALIGN_LASTLEFT:
327 case SFX_ALIGN_FIRSTRIGHT:
328 case SFX_ALIGN_LASTRIGHT:
330 eAlignment = eAlign;
332 break;
334 default:
336 eAlignment = eAlign;
338 break;
341 return eAlignment;
344 // Set style buttons
346 void SvxFontWorkDialog::SetStyle_Impl(const XFormTextStyleItem* pItem)
348 if ( pItem )
350 sal_uInt16 nId = TBI_STYLE_OFF;
352 switch ( pItem->GetValue() )
354 case XFT_ROTATE : nId = TBI_STYLE_ROTATE; break;
355 case XFT_UPRIGHT: nId = TBI_STYLE_UPRIGHT; break;
356 case XFT_SLANTX : nId = TBI_STYLE_SLANTX; break;
357 case XFT_SLANTY : nId = TBI_STYLE_SLANTY; break;
358 default: ;//prevent warning
360 aTbxStyle.Enable();
362 // Make sure that there is always exactly one checked toolbox item.
363 if ( pItem->GetValue() == XFT_NONE )
365 aTbxStyle.CheckItem(TBI_STYLE_ROTATE, sal_False);
366 aTbxStyle.CheckItem(TBI_STYLE_UPRIGHT, sal_False);
367 aTbxStyle.CheckItem(TBI_STYLE_SLANTX, sal_False);
368 aTbxStyle.CheckItem(TBI_STYLE_SLANTY, sal_False);
370 aTbxStyle.CheckItem(TBI_STYLE_OFF, sal_True);
372 else
374 aTbxStyle.CheckItem(TBI_STYLE_OFF, sal_False);
375 aTbxStyle.CheckItem(nId);
378 nLastStyleTbxId = nId;
380 else
381 aTbxStyle.Disable();
384 // Set adjust buttons
386 void SvxFontWorkDialog::SetAdjust_Impl(const XFormTextAdjustItem* pItem)
388 if ( pItem )
390 sal_uInt16 nId;
392 aTbxAdjust.Enable();
393 aMtrFldDistance.Enable();
395 if ( pItem->GetValue() == XFT_LEFT || pItem->GetValue() == XFT_RIGHT )
397 if ( pItem->GetValue() == XFT_LEFT ) nId = TBI_ADJUST_LEFT;
398 else nId = TBI_ADJUST_RIGHT;
399 aMtrFldTextStart.Enable();
401 else
403 if ( pItem->GetValue() == XFT_CENTER ) nId = TBI_ADJUST_CENTER;
404 else nId = TBI_ADJUST_AUTOSIZE;
405 aMtrFldTextStart.Disable();
408 if ( !aTbxAdjust.IsItemChecked(nId) )
410 aTbxAdjust.CheckItem(nId);
412 nLastAdjustTbxId = nId;
414 else
416 aTbxAdjust.Disable();
417 aMtrFldTextStart.Disable();
418 aMtrFldDistance.Disable();
422 // Enter Distance value in the edit field
424 void SvxFontWorkDialog::SetDistance_Impl(const XFormTextDistanceItem* pItem)
426 // Use HasChildPathFocus() instead of HasFocus() at SpinFields
427 if ( pItem && !aMtrFldDistance.HasChildPathFocus() )
429 SetMetricValue( aMtrFldDistance, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
433 // Enter indent value in the edit field
435 void SvxFontWorkDialog::SetStart_Impl(const XFormTextStartItem* pItem)
437 // Use HasChildPathFocus() instead of HasFocus() at SpinFields
438 if ( pItem && !aMtrFldTextStart.HasChildPathFocus() )
440 SetMetricValue( aMtrFldTextStart, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
444 // Set button for reversing the direction of text
446 void SvxFontWorkDialog::SetMirror_Impl(const XFormTextMirrorItem* pItem)
448 if ( pItem )
449 aTbxAdjust.CheckItem(TBI_ADJUST_MIRROR, pItem->GetValue());
452 // Standard form in ValueSet View
454 void SvxFontWorkDialog::SetStdForm_Impl(const XFormTextStdFormItem* pItem)
456 if ( pItem )
458 aFormSet.Enable();
459 aFormSet.SetNoSelection();
461 if ( pItem->GetValue() != XFTFORM_NONE )
462 aFormSet.SelectItem(
463 sal::static_int_cast< sal_uInt16 >(pItem->GetValue()));
465 else
466 aFormSet.Disable();
469 // Set button for contour display
471 void SvxFontWorkDialog::SetShowForm_Impl(const XFormTextHideFormItem* pItem)
473 if ( pItem )
474 aTbxShadow.CheckItem(TBI_SHOWFORM, !pItem->GetValue());
477 // Set button for text border
479 void SvxFontWorkDialog::SetOutline_Impl(const XFormTextOutlineItem* pItem)
481 if ( pItem )
482 aTbxShadow.CheckItem(TBI_OUTLINE, pItem->GetValue());
485 // Set shadow buttons
487 void SvxFontWorkDialog::SetShadow_Impl(const XFormTextShadowItem* pItem,
488 bool bRestoreValues)
490 if ( pItem )
492 sal_uInt16 nId;
494 aTbxShadow.Enable();
496 if ( pItem->GetValue() == XFTSHADOW_NONE )
498 nId = TBI_SHADOW_OFF;
499 aFbShadowX.Hide();
500 aFbShadowY.Hide();
501 aMtrFldShadowX.Disable();
502 aMtrFldShadowY.Disable();
503 aShadowColorLB.Disable();
505 else
507 aFbShadowX.Show();
508 aFbShadowY.Show();
509 aMtrFldShadowX.Enable();
510 aMtrFldShadowY.Enable();
511 aShadowColorLB.Enable();
513 if ( pItem->GetValue() == XFTSHADOW_NORMAL )
515 nId = TBI_SHADOW_NORMAL;
516 const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
518 aMtrFldShadowX.SetUnit( eDlgUnit );
519 aMtrFldShadowX.SetDecimalDigits(2);
520 aMtrFldShadowX.SetMin(LONG_MIN);
521 aMtrFldShadowX.SetMax(LONG_MAX);
522 if( eDlgUnit == FUNIT_MM )
523 aMtrFldShadowX.SetSpinSize( 50 );
524 else
525 aMtrFldShadowX.SetSpinSize( 10 );
527 aMtrFldShadowY.SetUnit( eDlgUnit );
528 aMtrFldShadowY.SetDecimalDigits(2);
529 aMtrFldShadowY.SetMin(LONG_MIN);
530 aMtrFldShadowY.SetMax(LONG_MAX);
531 if( eDlgUnit == FUNIT_MM )
532 aMtrFldShadowY.SetSpinSize( 50 );
533 else
534 aMtrFldShadowY.SetSpinSize( 10 );
536 if ( bRestoreValues )
538 SetMetricValue( aMtrFldShadowX, nSaveShadowX, SFX_MAPUNIT_100TH_MM );
539 SetMetricValue( aMtrFldShadowY, nSaveShadowY, SFX_MAPUNIT_100TH_MM );
541 XFormTextShadowXValItem aXItem( nSaveShadowX );
542 XFormTextShadowYValItem aYItem( nSaveShadowY );
544 GetBindings().GetDispatcher()->Execute(
545 SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
548 else
550 nId = TBI_SHADOW_SLANT;
552 aMtrFldShadowX.SetUnit(FUNIT_CUSTOM);
553 aMtrFldShadowX.SetDecimalDigits(1);
554 aMtrFldShadowX.SetMin(-1800);
555 aMtrFldShadowX.SetMax( 1800);
556 aMtrFldShadowX.SetSpinSize(10);
558 aMtrFldShadowY.SetUnit(FUNIT_CUSTOM);
559 aMtrFldShadowY.SetDecimalDigits(0);
560 aMtrFldShadowY.SetMin(-999);
561 aMtrFldShadowY.SetMax( 999);
562 aMtrFldShadowY.SetSpinSize(10);
564 if ( bRestoreValues )
566 aMtrFldShadowX.SetValue(nSaveShadowAngle);
567 aMtrFldShadowY.SetValue(nSaveShadowSize);
568 XFormTextShadowXValItem aXItem(nSaveShadowAngle);
569 XFormTextShadowYValItem aYItem(nSaveShadowSize);
570 GetBindings().GetDispatcher()->Execute(
571 SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
576 if ( !aTbxShadow.IsItemChecked(nId) )
578 aTbxShadow.CheckItem(nId);
580 nLastShadowTbxId = nId;
582 ApplyImageList();
584 else
586 aTbxShadow.Disable();
587 aMtrFldShadowX.Disable();
588 aMtrFldShadowY.Disable();
589 aShadowColorLB.Disable();
593 // Insert shadow color in listbox
595 void SvxFontWorkDialog::SetShadowColor_Impl(const XFormTextShadowColorItem* pItem)
597 if ( pItem )
598 aShadowColorLB.SelectEntry(pItem->GetColorValue());
601 // Enter X-value for shadow in edit field
603 void SvxFontWorkDialog::SetShadowXVal_Impl(const XFormTextShadowXValItem* pItem)
605 // Use HasChildPathFocus() instead of HasFocus() at SpinFields
606 if ( pItem && !aMtrFldShadowX.HasChildPathFocus() )
608 // #i19251#
609 // sal_Int32 nValue = pItem->GetValue();
611 // #i19251#
612 // The two involved fields/items are used double and contain/give different
613 // values regarding to the access method. Thus, here we need to separate the access
614 // methos regarding to the kind of value accessed.
615 if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
617 // #i19251#
618 // There is no value correction necessary at all, i think this
619 // was only tried to be done without understanding that the two
620 // involved fields/items are used double and contain/give different
621 // values regarding to the access method.
622 // nValue = nValue - ( int( float( nValue ) / 360.0 ) * 360 );
623 aMtrFldShadowX.SetValue(pItem->GetValue());
625 else
627 SetMetricValue( aMtrFldShadowX, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
632 // Enter Y-value for shadow in edit field
634 void SvxFontWorkDialog::SetShadowYVal_Impl(const XFormTextShadowYValItem* pItem)
636 // Use HasChildPathFocus() instead of HasFocus() at SpinFields
637 if ( pItem && !aMtrFldShadowY.HasChildPathFocus() )
639 // #i19251#
640 // The two involved fields/items are used double and contain/give different
641 // values regarding to the access method. Thus, here we need to separate the access
642 // methos regarding to the kind of value accessed.
643 if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
645 aMtrFldShadowY.SetValue(pItem->GetValue());
647 else
649 SetMetricValue( aMtrFldShadowY, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
654 IMPL_LINK_NOARG(SvxFontWorkDialog, SelectStyleHdl_Impl)
656 sal_uInt16 nId = aTbxStyle.GetCurItemId();
658 // Execute this block when a different toolbox item has been clicked or
659 // when the off item has been clicked. The later is necessary to
660 // override the toolbox behaviour of unchecking the item after second
661 // click on it: One of the items has to be checked at all times (when
662 // enabled that is.)
663 if (nId == TBI_STYLE_OFF || nId != nLastStyleTbxId )
665 XFormTextStyle eStyle = XFT_NONE;
667 switch ( nId )
669 case TBI_STYLE_ROTATE : eStyle = XFT_ROTATE; break;
670 case TBI_STYLE_UPRIGHT : eStyle = XFT_UPRIGHT; break;
671 case TBI_STYLE_SLANTX : eStyle = XFT_SLANTX; break;
672 case TBI_STYLE_SLANTY : eStyle = XFT_SLANTY; break;
674 XFormTextStyleItem aItem( eStyle );
675 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_STYLE, SFX_CALLMODE_RECORD, &aItem, 0L );
676 SetStyle_Impl( &aItem );
677 nLastStyleTbxId = nId;
679 return 0;
682 IMPL_LINK_NOARG(SvxFontWorkDialog, SelectAdjustHdl_Impl)
684 sal_uInt16 nId = aTbxAdjust.GetCurItemId();
686 if ( nId == TBI_ADJUST_MIRROR )
688 XFormTextMirrorItem aItem(aTbxAdjust.IsItemChecked(nId));
689 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_MIRROR, SFX_CALLMODE_SLOT, &aItem, 0L );
691 else if ( nId != nLastAdjustTbxId )
693 XFormTextAdjust eAdjust = XFT_AUTOSIZE;
695 switch ( nId )
697 case TBI_ADJUST_LEFT : eAdjust = XFT_LEFT; break;
698 case TBI_ADJUST_CENTER : eAdjust = XFT_CENTER; break;
699 case TBI_ADJUST_RIGHT : eAdjust = XFT_RIGHT; break;
701 XFormTextAdjustItem aItem(eAdjust);
702 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_ADJUST, SFX_CALLMODE_RECORD, &aItem, 0L );
703 SetAdjust_Impl(&aItem);
704 nLastAdjustTbxId = nId;
706 return 0;
709 IMPL_LINK_NOARG(SvxFontWorkDialog, SelectShadowHdl_Impl)
711 sal_uInt16 nId = aTbxShadow.GetCurItemId();
713 if ( nId == TBI_SHOWFORM )
715 XFormTextHideFormItem aItem(!aTbxShadow.IsItemChecked(nId));
716 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_HIDEFORM, SFX_CALLMODE_RECORD, &aItem, 0L );
718 else if ( nId == TBI_OUTLINE )
720 XFormTextOutlineItem aItem(aTbxShadow.IsItemChecked(nId));
721 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_OUTLINE, SFX_CALLMODE_RECORD, &aItem, 0L );
723 else if ( nId != nLastShadowTbxId )
725 XFormTextShadow eShadow = XFTSHADOW_NONE;
727 if ( nLastShadowTbxId == TBI_SHADOW_NORMAL )
729 nSaveShadowX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
730 nSaveShadowY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
732 else if ( nLastShadowTbxId == TBI_SHADOW_SLANT )
734 nSaveShadowAngle = static_cast<long>(aMtrFldShadowX.GetValue());
735 nSaveShadowSize = static_cast<long>(aMtrFldShadowY.GetValue());
737 nLastShadowTbxId = nId;
739 if ( nId == TBI_SHADOW_NORMAL ) eShadow = XFTSHADOW_NORMAL;
740 else if ( nId == TBI_SHADOW_SLANT ) eShadow = XFTSHADOW_SLANT;
742 XFormTextShadowItem aItem(eShadow);
743 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHADOW, SFX_CALLMODE_RECORD, &aItem, 0L );
744 SetShadow_Impl(&aItem, true);
746 return 0;
749 IMPL_LINK_NOARG_INLINE_START(SvxFontWorkDialog, ModifyInputHdl_Impl)
751 aInputTimer.Start();
752 return 0;
754 IMPL_LINK_NOARG_INLINE_END(SvxFontWorkDialog, ModifyInputHdl_Impl)
756 IMPL_LINK_NOARG(SvxFontWorkDialog, InputTimoutHdl_Impl)
758 // Possibly set the Metric system again. This should be done with a
759 // listen, this is however not possible at the moment due to compabillity
760 // issues.
761 const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
762 if( eDlgUnit != aMtrFldDistance.GetUnit() )
764 SetFieldUnit( aMtrFldDistance, eDlgUnit, sal_True );
765 SetFieldUnit( aMtrFldTextStart, eDlgUnit, sal_True );
766 aMtrFldDistance.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
767 aMtrFldTextStart.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
769 if( eDlgUnit != aMtrFldShadowX.GetUnit() &&
770 aTbxShadow.IsItemChecked( TBI_SHADOW_NORMAL ) )
772 SetFieldUnit( aMtrFldShadowX, eDlgUnit, sal_True );
773 SetFieldUnit( aMtrFldShadowY, eDlgUnit, sal_True );
774 aMtrFldShadowX.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
775 aMtrFldShadowY.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
778 long nValue = GetCoreValue( aMtrFldDistance, SFX_MAPUNIT_100TH_MM );
779 XFormTextDistanceItem aDistItem( nValue );
780 nValue = GetCoreValue( aMtrFldTextStart, SFX_MAPUNIT_100TH_MM );
781 XFormTextStartItem aStartItem( nValue );
783 sal_Int32 nValueX(0L);
784 sal_Int32 nValueY(0L);
786 // #i19251#
787 // The two involved fields/items are used double and contain/give different
788 // values regarding to the access method. Thus, here we need to separate the access
789 // methos regarding to the kind of value accessed.
790 if(nLastShadowTbxId == TBI_SHADOW_NORMAL)
792 nValueX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
793 nValueY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
795 else if(nLastShadowTbxId == TBI_SHADOW_SLANT)
797 nValueX = static_cast<long>(aMtrFldShadowX.GetValue());
798 nValueY = static_cast<long>(aMtrFldShadowY.GetValue());
801 XFormTextShadowXValItem aShadowXItem( nValueX );
802 XFormTextShadowYValItem aShadowYItem( nValueY );
804 // Slot-ID does not matter, the Exec method evaluates the entire item set
805 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_DISTANCE, SFX_CALLMODE_RECORD, &aDistItem,
806 &aStartItem, &aShadowXItem, &aShadowYItem, 0L );
807 return 0;
810 IMPL_LINK_NOARG(SvxFontWorkDialog, FormSelectHdl_Impl)
812 XFormTextStdFormItem aItem;
814 if ( aFormSet.IsNoSelection() )
815 aItem.SetValue(XFTFORM_NONE);
816 else
817 aItem.SetValue(aFormSet.GetSelectItemId());
818 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_STDFORM, SFX_CALLMODE_RECORD, &aItem, 0L );
819 aFormSet.SetNoSelection();
820 return 0;
823 IMPL_LINK_NOARG(SvxFontWorkDialog, ColorSelectHdl_Impl)
825 XFormTextShadowColorItem aItem( (const String &) String(),
826 (const Color &) aShadowColorLB.GetSelectEntryColor() );
827 GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHDWCOLOR, SFX_CALLMODE_RECORD, &aItem, 0L );
828 return 0;
831 void SvxFontWorkDialog::SetColorList(const XColorListRef &pList)
833 if ( pList.is() && pList != pColorList )
835 pColorList = pList;
836 aShadowColorLB.Clear();
837 aShadowColorLB.Fill(pColorList);
841 void SvxFontWorkDialog::SetActive(bool /*bActivate*/)
845 // Create standard fontWork Object
847 void SvxFontWorkDialog::CreateStdFormObj(SdrView& rView, SdrPageView& rPV,
848 const SfxItemSet& rAttr,
849 SdrObject& rOldObj,
850 XFormTextStdForm eForm)
852 SfxItemSet aAttr(*rAttr.GetPool(), XATTR_FORMTXTSTYLE,
853 XATTR_FORMTXTHIDEFORM);
854 SdrObject* pNewObj = NULL;
855 Rectangle aRect;
856 XFormTextAdjust eAdjust = XFT_AUTOSIZE;
858 aAttr.Put(rOldObj.GetMergedItemSet());
860 const XFormTextStdFormItem& rOldForm = (const XFormTextStdFormItem&)
861 aAttr.Get(XATTR_FORMTXTSTDFORM);
863 aRect = rOldObj.GetSnapRect();
865 if ( !rOldObj.ISA(SdrPathObj) )
867 Point aPos = aRect.TopLeft();
868 aRect = rOldObj.GetLogicRect();
869 aRect.SetPos(aPos);
872 aAttr.Put(rAttr);
874 if ( rOldForm.GetValue() == XFTFORM_NONE )
876 long nW = aRect.GetWidth();
877 aRect.SetSize(Size(nW, nW));
878 aAttr.Put(XFormTextStyleItem(XFT_ROTATE));
881 Point aCenter = aRect.Center();
883 switch ( eForm )
885 case XFTFORM_TOPCIRC:
886 case XFTFORM_BOTCIRC:
887 case XFTFORM_LFTCIRC:
888 case XFTFORM_RGTCIRC:
889 case XFTFORM_TOPARC:
890 case XFTFORM_BOTARC:
891 case XFTFORM_LFTARC:
892 case XFTFORM_RGTARC:
894 long nBeg, nEnd;
896 switch ( eForm )
898 default: ; //prevent warning
899 case XFTFORM_TOPCIRC:
900 nBeg = 0;
901 nEnd = 18000;
902 break;
903 case XFTFORM_BOTCIRC:
904 nBeg = 18000;
905 nEnd = 36000;
906 break;
907 case XFTFORM_LFTCIRC:
908 nBeg = 9000;
909 nEnd = 27000;
910 break;
911 case XFTFORM_RGTCIRC:
912 nBeg = 27000;
913 nEnd = 9000;
914 break;
915 case XFTFORM_TOPARC:
916 nBeg = 4500;
917 nEnd = 13500;
918 break;
919 case XFTFORM_BOTARC:
920 nBeg = 22500;
921 nEnd = 31500;
922 break;
923 case XFTFORM_LFTARC:
924 nBeg = 13500;
925 nEnd = 22500;
926 break;
927 case XFTFORM_RGTARC:
928 nBeg = 31500;
929 nEnd = 4500;
930 break;
932 pNewObj = new SdrCircObj(OBJ_CARC, aRect, nBeg, nEnd);
933 break;
935 case XFTFORM_BUTTON1:
937 basegfx::B2DPolyPolygon aPolyPolygon;
938 basegfx::B2DPolygon aLine;
939 long nR = aRect.GetWidth() / 2;
940 basegfx::B2DPolygon aTopArc(XPolygon(aCenter, -nR, nR, 50, 1750, sal_False).getB2DPolygon());
941 basegfx::B2DPolygon aBottomArc(XPolygon(aCenter, -nR, nR, 1850, 3550, sal_False).getB2DPolygon());
943 // Close Polygon
944 aTopArc.setClosed(true);
945 aBottomArc.setClosed(true);
946 aPolyPolygon.append(aTopArc);
948 aLine.append(aBottomArc.getB2DPoint(aBottomArc.count() - 1L));
949 aLine.append(aBottomArc.getB2DPoint(0L));
950 aLine.setClosed(true);
952 aPolyPolygon.append(aLine);
953 aPolyPolygon.append(aBottomArc);
955 pNewObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
956 eAdjust = XFT_CENTER;
957 break;
959 case XFTFORM_BUTTON2:
960 case XFTFORM_BUTTON3:
961 case XFTFORM_BUTTON4:
963 basegfx::B2DPolyPolygon aPolyPolygon;
964 basegfx::B2DPolygon aLine;
965 long nR = aRect.GetWidth() / 2;
966 long nWDiff = nR / 5;
967 long nHDiff;
969 if ( eForm == XFTFORM_BUTTON4 )
971 basegfx::B2DPolygon aNewArc(XPolygon(aCenter, -nR, nR, 950, 2650, sal_False).getB2DPolygon());
972 aNewArc.setClosed(true);
973 aPolyPolygon.append(aNewArc);
974 eAdjust = XFT_CENTER;
976 else
978 basegfx::B2DPolygon aNewArc(XPolygon(aCenter, -nR, nR, 2700, 2700).getB2DPolygon());
979 aPolyPolygon.append(aNewArc);
982 if ( eForm == XFTFORM_BUTTON3 )
983 nHDiff = -aRect.GetHeight() / 10;
984 else
985 nHDiff = aRect.GetHeight() / 20;
987 aLine.append(basegfx::B2DPoint(aRect.Left() + nWDiff, aRect.Center().Y() + nHDiff));
988 aLine.append(basegfx::B2DPoint(aRect.Right() - nWDiff, aRect.Center().Y() + nHDiff));
989 aLine.setClosed(true);
990 aPolyPolygon.append(aLine);
992 if ( eForm == XFTFORM_BUTTON4 )
994 basegfx::B2DPolygon aNewArc(XPolygon(aCenter, -nR, nR, 2750, 850, sal_False).getB2DPolygon());
995 aNewArc.setClosed(true);
996 aPolyPolygon.append(aNewArc);
999 if ( eForm == XFTFORM_BUTTON3 )
1001 nHDiff += nHDiff;
1002 aLine.setB2DPoint(0L, basegfx::B2DPoint(aLine.getB2DPoint(0L).getX(), aLine.getB2DPoint(0L).getY() - nHDiff));
1003 aLine.setB2DPoint(1L, basegfx::B2DPoint(aLine.getB2DPoint(1L).getX(), aLine.getB2DPoint(1L).getY() - nHDiff));
1004 aPolyPolygon.append(aLine);
1007 pNewObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
1008 break;
1010 default: ; //prevent warning
1012 if ( pNewObj )
1014 // due to DLs changes in Outliner the object needs
1015 // a model to get an outliner for later calls to
1016 // pNewObj->SetOutlinerParaObject(pPara) (see below).
1017 pNewObj->SetModel(rOldObj.GetModel());
1019 Size aSize;
1020 Rectangle aSnap = pNewObj->GetSnapRect();
1022 aSize.Width() = aRect.Left() - aSnap.Left();
1023 aSize.Height() = aRect.Top() - aSnap.Top();
1024 pNewObj->NbcMove(aSize);
1026 rView.BegUndo( SVX_RESSTR( RID_SVXSTR_FONTWORK_UNDOCREATE ) );
1027 OutlinerParaObject* pPara = rOldObj.GetOutlinerParaObject();
1028 sal_Bool bHide = sal_True;
1030 if ( pPara != NULL )
1032 pPara = new OutlinerParaObject(*pPara);
1033 pNewObj->SetOutlinerParaObject(pPara);
1035 else
1036 bHide = sal_False;
1038 rView.ReplaceObjectAtView(&rOldObj, rPV, pNewObj, sal_True);
1039 pNewObj->SetLayer(rOldObj.GetLayer());
1040 aAttr.Put(XFormTextHideFormItem(bHide));
1041 aAttr.Put(XFormTextAdjustItem(eAdjust));
1043 XFormTextShadow eShadow = XFTSHADOW_NONE;
1045 if ( nLastShadowTbxId == TBI_SHADOW_NORMAL )
1047 eShadow = XFTSHADOW_NORMAL;
1048 aAttr.Put(XFormTextShadowXValItem(nSaveShadowX));
1049 aAttr.Put(XFormTextShadowYValItem(nSaveShadowY));
1051 else if ( nLastShadowTbxId == TBI_SHADOW_SLANT )
1053 eShadow = XFTSHADOW_SLANT;
1054 aAttr.Put(XFormTextShadowXValItem(nSaveShadowAngle));
1055 aAttr.Put(XFormTextShadowYValItem(nSaveShadowSize));
1058 aAttr.Put(XFormTextShadowItem(eShadow));
1060 rView.SetAttributes(aAttr);
1061 rView.EndUndo();
1065 void SvxFontWorkDialog::DataChanged( const DataChangedEvent& rDCEvt )
1067 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1068 ApplyImageList();
1070 SfxDockingWindow::DataChanged( rDCEvt );
1073 void SvxFontWorkDialog::ApplyImageList()
1075 ResMgr* _pMgr = &DIALOG_MGR();
1077 sal_uInt16 nBitmapResId = RID_SVXBMP_FONTWORK_FORM1;
1078 sal_uInt16 nTextResId = RID_SVXSTR_FONTWORK_FORM1;
1080 bool bInit = aFormSet.GetItemCount() == 0;
1082 sal_uInt16 i;
1083 for( i = 1; i < 13; i++, nTextResId++, nBitmapResId++ )
1085 if( bInit )
1087 aFormSet.InsertItem( i, Bitmap(ResId(nBitmapResId,*_pMgr)),
1088 String(ResId(nTextResId,*_pMgr)));
1090 else
1092 aFormSet.SetItemImage( i, Bitmap(ResId(nBitmapResId,*_pMgr)) );
1096 ImageList& rImgLst = maImageList;
1098 aTbxStyle.SetImageList( rImgLst );
1099 aTbxAdjust.SetImageList( rImgLst );
1100 aTbxShadow.SetImageList( rImgLst );
1102 switch( nLastShadowTbxId )
1104 case TBI_SHADOW_SLANT:
1105 aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_ANGLE ) );
1106 aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_SIZE ) );
1107 break;
1108 default:
1109 aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_XDIST ) );
1110 aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_YDIST ) );
1111 break;
1114 aFbDistance.SetImage( rImgLst.GetImage( TBI_DISTANCE ) );
1115 aFbTextStart.SetImage( rImgLst.GetImage( TBI_TEXTSTART ) );
1119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */