xref: /aoo42x/main/svx/source/dialog/fontwork.cxx (revision 7ea7a1cc)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 // include ---------------------------------------------------------------
28 #include <sfx2/module.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <tools/shl.hxx>
31 
32 #define _SVX_FONTWORK_CXX
33 #include <svx/svdobj.hxx>
34 #include <svx/svdopath.hxx>
35 #include <svx/svdview.hxx>
36 #include <svx/svdocirc.hxx>
37 #include <svx/xtextit.hxx>
38 
39 #include <svx/dialmgr.hxx>
40 #include "svx/dlgutil.hxx"
41 
42 #include <svx/dialogs.hrc>
43 #include "fontwork.hrc"
44 #include <svx/fontwork.hxx>
45 #include <editeng/outlobj.hxx>
46 #include <basegfx/polygon/b2dpolygon.hxx>
47 #include <basegfx/point/b2dpoint.hxx>
48 
49 SFX_IMPL_DOCKINGWINDOW( SvxFontWorkChildWindow, SID_FONTWORK );
50 
51 /*************************************************************************
52 |*
53 |* ControllerItem fuer Fontwork
54 |*
55 \************************************************************************/
56 
SvxFontWorkControllerItem(sal_uInt16 _nId,SvxFontWorkDialog & rDlg,SfxBindings & rBindings)57 SvxFontWorkControllerItem::SvxFontWorkControllerItem
58 (
59     sal_uInt16 _nId,
60 	SvxFontWorkDialog& rDlg,
61 	SfxBindings& rBindings
62 ) :
63 
64     SfxControllerItem( _nId, rBindings ),
65 
66 	rFontWorkDlg( rDlg )
67 {
68 }
69 
70 /*************************************************************************
71 |*
72 |* StateChanged-Methode fuer FontWork-Items
73 |*
74 \************************************************************************/
75 
StateChanged(sal_uInt16,SfxItemState,const SfxPoolItem * pItem)76 void SvxFontWorkControllerItem::StateChanged( sal_uInt16 /*nSID*/, SfxItemState /*eState*/,
77 											  const SfxPoolItem* pItem )
78 {
79 	switch ( GetId() )
80 	{
81 		case SID_FORMTEXT_STYLE:
82 		{
83 			const XFormTextStyleItem* pStateItem =
84 								PTR_CAST(XFormTextStyleItem, pItem);
85 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStyleItem erwartet");
86 			rFontWorkDlg.SetStyle_Impl(pStateItem);
87 			break;
88 		}
89 		case SID_FORMTEXT_ADJUST:
90 		{
91 			const XFormTextAdjustItem* pStateItem =
92 								PTR_CAST(XFormTextAdjustItem, pItem);
93 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextAdjustItem erwartet");
94 			rFontWorkDlg.SetAdjust_Impl(pStateItem);
95 			break;
96 		}
97 		case SID_FORMTEXT_DISTANCE:
98 		{
99 			const XFormTextDistanceItem* pStateItem =
100 								PTR_CAST(XFormTextDistanceItem, pItem);
101 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextDistanceItem erwartet");
102 			rFontWorkDlg.SetDistance_Impl(pStateItem);
103 			break;
104 		}
105 		case SID_FORMTEXT_START:
106 		{
107 			const XFormTextStartItem* pStateItem =
108 								PTR_CAST(XFormTextStartItem, pItem);
109 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStartItem erwartet");
110 			rFontWorkDlg.SetStart_Impl(pStateItem);
111 			break;
112 		}
113 		case SID_FORMTEXT_MIRROR:
114 		{
115 			const XFormTextMirrorItem* pStateItem =
116 								PTR_CAST(XFormTextMirrorItem, pItem);
117 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextMirrorItem erwartet");
118 			rFontWorkDlg.SetMirror_Impl(pStateItem);
119 			break;
120 		}
121 		case SID_FORMTEXT_HIDEFORM:
122 		{
123 			const XFormTextHideFormItem* pStateItem =
124 								PTR_CAST(XFormTextHideFormItem, pItem);
125 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextHideFormItem erwartet");
126 			rFontWorkDlg.SetShowForm_Impl(pStateItem);
127 			break;
128 		}
129 		case SID_FORMTEXT_OUTLINE:
130 		{
131 			const XFormTextOutlineItem* pStateItem =
132 								PTR_CAST(XFormTextOutlineItem, pItem);
133 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextOutlineItem erwartet");
134 			rFontWorkDlg.SetOutline_Impl(pStateItem);
135 			break;
136 		}
137 		case SID_FORMTEXT_SHADOW:
138 		{
139 			const XFormTextShadowItem* pStateItem =
140 								PTR_CAST(XFormTextShadowItem, pItem);
141 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowItem erwartet");
142 			rFontWorkDlg.SetShadow_Impl(pStateItem);
143 			break;
144 		}
145 		case SID_FORMTEXT_SHDWCOLOR:
146 		{
147 			const XFormTextShadowColorItem* pStateItem =
148 								PTR_CAST(XFormTextShadowColorItem, pItem);
149 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowColorItem erwartet");
150 			rFontWorkDlg.SetShadowColor_Impl(pStateItem);
151 			break;
152 		}
153 		case SID_FORMTEXT_SHDWXVAL:
154 		{
155 			const XFormTextShadowXValItem* pStateItem =
156 								PTR_CAST(XFormTextShadowXValItem, pItem);
157 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowXValItem erwartet");
158 			rFontWorkDlg.SetShadowXVal_Impl(pStateItem);
159 			break;
160 		}
161 		case SID_FORMTEXT_SHDWYVAL:
162 		{
163 			const XFormTextShadowYValItem* pStateItem =
164 								PTR_CAST(XFormTextShadowYValItem, pItem);
165 			DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowYValItem erwartet");
166 			rFontWorkDlg.SetShadowYVal_Impl(pStateItem);
167 			break;
168 		}
169 	}
170 }
171 
172 /*************************************************************************
173 |*
174 |* Ableitung vom SfxChildWindow als "Behaelter" fuer Fontwork-Dialog
175 |*
176 \************************************************************************/
177 
SvxFontWorkChildWindow(Window * _pParent,sal_uInt16 nId,SfxBindings * pBindings,SfxChildWinInfo * pInfo)178 SvxFontWorkChildWindow::SvxFontWorkChildWindow
179 (
180     Window* _pParent,
181 	sal_uInt16 nId,
182 	SfxBindings* pBindings,
183 	SfxChildWinInfo* pInfo
184 ) :
185 
186     SfxChildWindow( _pParent, nId )
187 
188 {
189     pWindow = new SvxFontWorkDialog( pBindings, this, _pParent,
190 									 SVX_RES( RID_SVXDLG_FONTWORK ) );
191 	SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*) pWindow;
192 
193 	eChildAlignment = SFX_ALIGN_NOALIGNMENT;
194 
195 	pDlg->Initialize( pInfo );
196 }
197 
198 /*************************************************************************
199 |*
200 |* Floating Window zur Attributierung von Texteffekten
201 |*
202 \************************************************************************/
203 
SvxFontWorkDialog(SfxBindings * pBindinx,SfxChildWindow * pCW,Window * _pParent,const ResId & rResId)204 SvxFontWorkDialog::SvxFontWorkDialog( SfxBindings *pBindinx,
205 									  SfxChildWindow *pCW,
206                                       Window* _pParent,
207 									  const ResId& rResId ) :
208     SfxDockingWindow( pBindinx, pCW, _pParent, rResId ),
209 
210 	aTbxStyle		(this, ResId(TBX_STYLE,*rResId.GetResMgr())),
211 	aTbxAdjust		(this, ResId(TBX_ADJUST,*rResId.GetResMgr())),
212 
213 	aFbDistance 	(this, ResId(FB_DISTANCE,*rResId.GetResMgr())),
214 	aMtrFldDistance (this, ResId(MTR_FLD_DISTANCE,*rResId.GetResMgr())),
215 	aFbTextStart	(this, ResId(FB_TEXTSTART,*rResId.GetResMgr())),
216 	aMtrFldTextStart(this, ResId(MTR_FLD_TEXTSTART,*rResId.GetResMgr())),
217 
218 	aTbxShadow		(this, ResId(TBX_SHADOW,*rResId.GetResMgr())),
219 
220 	aFbShadowX		(this, ResId(FB_SHADOW_X,*rResId.GetResMgr())),
221 	aMtrFldShadowX	(this, ResId(MTR_FLD_SHADOW_X,*rResId.GetResMgr())),
222 	aFbShadowY		(this, ResId(FB_SHADOW_Y,*rResId.GetResMgr())),
223 	aMtrFldShadowY	(this, ResId(MTR_FLD_SHADOW_Y,*rResId.GetResMgr())),
224 
225 	aShadowColorLB	(this, ResId(CLB_SHADOW_COLOR,*rResId.GetResMgr())),
226     rBindings       (*pBindinx),
227 
228 	nLastStyleTbxId(0),
229 	nLastAdjustTbxId(0),
230 	nLastShadowTbxId(0),
231 	nSaveShadowX	(0),
232 	nSaveShadowY	(0),
233 	nSaveShadowAngle(450),
234 	nSaveShadowSize (100),
235 
236     maImageList     (ResId(IL_FONTWORK,*rResId.GetResMgr())),
237     maImageListH    (ResId(ILH_FONTWORK,*rResId.GetResMgr())),
238 
239     maColorTable()
240 {
241 	FreeResource();
242 
243 	ApplyImageList();
244 
245 	pCtrlItems[0] = new SvxFontWorkControllerItem(SID_FORMTEXT_STYLE, *this, rBindings);
246 	pCtrlItems[1] = new SvxFontWorkControllerItem(SID_FORMTEXT_ADJUST, *this, rBindings);
247 	pCtrlItems[2] = new SvxFontWorkControllerItem(SID_FORMTEXT_DISTANCE, *this, rBindings);
248 	pCtrlItems[3] = new SvxFontWorkControllerItem(SID_FORMTEXT_START, *this, rBindings);
249 	pCtrlItems[4] = new SvxFontWorkControllerItem(SID_FORMTEXT_MIRROR, *this, rBindings);
250 	pCtrlItems[5] = new SvxFontWorkControllerItem(SID_FORMTEXT_HIDEFORM, *this, rBindings);
251 	pCtrlItems[6] = new SvxFontWorkControllerItem(SID_FORMTEXT_OUTLINE, *this, rBindings);
252 	pCtrlItems[7] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHADOW, *this, rBindings);
253 	pCtrlItems[8] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWCOLOR, *this, rBindings);
254 	pCtrlItems[9] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWXVAL, *this, rBindings);
255 	pCtrlItems[10] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWYVAL, *this, rBindings);
256 
257 	Size aSize = aTbxStyle.CalcWindowSizePixel();
258 	aTbxStyle.SetSizePixel(aSize);
259 	aTbxStyle.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectStyleHdl_Impl) );
260 
261 	aTbxAdjust.SetSizePixel(aSize);
262 	aTbxAdjust.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectAdjustHdl_Impl) );
263 
264 	aTbxShadow.SetSizePixel(aSize);
265 	aTbxShadow.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectShadowHdl_Impl) );
266 
267 	Link aLink = LINK(this, SvxFontWorkDialog, ModifyInputHdl_Impl);
268 	aMtrFldDistance.SetModifyHdl( aLink );
269 	aMtrFldTextStart.SetModifyHdl( aLink );
270 	aMtrFldShadowX.SetModifyHdl( aLink );
271 	aMtrFldShadowY.SetModifyHdl( aLink );
272 
273 	// System-Metrik setzen
274 	const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
275 	SetFieldUnit( aMtrFldDistance, eDlgUnit, sal_True );
276 	SetFieldUnit( aMtrFldTextStart, eDlgUnit, sal_True );
277 	SetFieldUnit( aMtrFldShadowX, eDlgUnit, sal_True );
278 	SetFieldUnit( aMtrFldShadowY, eDlgUnit, sal_True );
279 	if( eDlgUnit == FUNIT_MM )
280 	{
281 		aMtrFldDistance.SetSpinSize( 50 );
282 		aMtrFldTextStart.SetSpinSize( 50 );
283 		aMtrFldShadowX.SetSpinSize( 50 );
284 		aMtrFldShadowY.SetSpinSize( 50 );
285 	}
286 	else
287 	{
288 		aMtrFldDistance.SetSpinSize( 10 );
289 		aMtrFldTextStart.SetSpinSize( 10 );
290 		aMtrFldShadowX.SetSpinSize( 10 );
291 		aMtrFldShadowY.SetSpinSize( 10 );
292 	}
293 
294 	aShadowColorLB.SetSelectHdl( LINK(this, SvxFontWorkDialog, ColorSelectHdl_Impl) );
295 
296 	aInputTimer.SetTimeout(500);
297 	aInputTimer.SetTimeoutHdl(LINK(this, SvxFontWorkDialog, InputTimoutHdl_Impl));
298 }
299 
300 /*************************************************************************
301 |*
302 |* Destruktor
303 |*
304 \************************************************************************/
305 
~SvxFontWorkDialog()306 SvxFontWorkDialog::~SvxFontWorkDialog()
307 {
308 	for (sal_uInt16 i = 0; i < CONTROLLER_COUNT; i++)
309 		DELETEZ(pCtrlItems[i]);
310 }
311 
312 /*************************************************************************
313 |*
314 \************************************************************************/
315 
Zoom()316 void SvxFontWorkDialog::Zoom()
317 {
318 	SfxDockingWindow::Roll();
319 }
320 
321 
322 /*************************************************************************
323 |*
324 |*
325 |*
326 \************************************************************************/
327 
CheckAlignment(SfxChildAlignment eActAlign,SfxChildAlignment eAlign)328 SfxChildAlignment SvxFontWorkDialog::CheckAlignment( SfxChildAlignment eActAlign,
329 													 SfxChildAlignment eAlign )
330 {
331 	SfxChildAlignment eAlignment;
332 
333 	switch ( eAlign )
334 	{
335 		case SFX_ALIGN_TOP:
336 		case SFX_ALIGN_HIGHESTTOP:
337 		case SFX_ALIGN_LOWESTTOP:
338 		case SFX_ALIGN_BOTTOM:
339 		case SFX_ALIGN_LOWESTBOTTOM:
340 		case SFX_ALIGN_HIGHESTBOTTOM:
341 		{
342 			eAlignment = eActAlign;
343 		}
344 		break;
345 
346 		case SFX_ALIGN_LEFT:
347 		case SFX_ALIGN_RIGHT:
348 		case SFX_ALIGN_FIRSTLEFT:
349 		case SFX_ALIGN_LASTLEFT:
350 		case SFX_ALIGN_FIRSTRIGHT:
351 		case SFX_ALIGN_LASTRIGHT:
352 		{
353 			eAlignment = eAlign;
354 		}
355 		break;
356 
357 		default:
358 		{
359 			eAlignment = eAlign;
360 		}
361 		break;
362 	}
363 
364 	return eAlignment;
365 }
366 
367 
368 /*************************************************************************
369 |*
370 |* Style-Buttons setzen
371 |*
372 \************************************************************************/
373 
SetStyle_Impl(const XFormTextStyleItem * pItem)374 void SvxFontWorkDialog::SetStyle_Impl(const XFormTextStyleItem* pItem)
375 {
376     if ( pItem )
377 	{
378 		sal_uInt16 nId = TBI_STYLE_OFF;
379 
380 		switch ( pItem->GetValue() )
381 		{
382 			case XFT_ROTATE : nId = TBI_STYLE_ROTATE;	break;
383 			case XFT_UPRIGHT: nId = TBI_STYLE_UPRIGHT;	break;
384 			case XFT_SLANTX : nId = TBI_STYLE_SLANTX;	break;
385 			case XFT_SLANTY : nId = TBI_STYLE_SLANTY;	break;
386             default: ;//prevent warning
387 		}
388 		aTbxStyle.Enable();
389 
390         // Make sure that there is allways exactly one checked toolbox item.
391 		if ( pItem->GetValue() == XFT_NONE )
392 		{
393 			aTbxStyle.CheckItem(TBI_STYLE_ROTATE, sal_False);
394 			aTbxStyle.CheckItem(TBI_STYLE_UPRIGHT, sal_False);
395 			aTbxStyle.CheckItem(TBI_STYLE_SLANTX, sal_False);
396 			aTbxStyle.CheckItem(TBI_STYLE_SLANTY, sal_False);
397 
398 			aTbxStyle.CheckItem(TBI_STYLE_OFF, sal_True);
399 		}
400 		else
401         {
402 			aTbxStyle.CheckItem(TBI_STYLE_OFF, sal_False);
403             aTbxStyle.CheckItem(nId);
404         }
405 
406 		nLastStyleTbxId = nId;
407 	}
408 	else
409 		aTbxStyle.Disable();
410 }
411 
412 /*************************************************************************
413 |*
414 |* Adjust-Buttons setzen
415 |*
416 \************************************************************************/
417 
SetAdjust_Impl(const XFormTextAdjustItem * pItem)418 void SvxFontWorkDialog::SetAdjust_Impl(const XFormTextAdjustItem* pItem)
419 {
420 	if ( pItem )
421 	{
422 		sal_uInt16 nId;
423 
424 		aTbxAdjust.Enable();
425 		aMtrFldDistance.Enable();
426 
427 		if ( pItem->GetValue() == XFT_LEFT || pItem->GetValue() == XFT_RIGHT )
428 		{
429 			if ( pItem->GetValue() == XFT_LEFT )	nId = TBI_ADJUST_LEFT;
430 			else									nId = TBI_ADJUST_RIGHT;
431 			aMtrFldTextStart.Enable();
432 		}
433 		else
434 		{
435 			if ( pItem->GetValue() == XFT_CENTER )	nId = TBI_ADJUST_CENTER;
436 			else									nId = TBI_ADJUST_AUTOSIZE;
437 			aMtrFldTextStart.Disable();
438 		}
439 
440 		if ( !aTbxAdjust.IsItemChecked(nId) )
441 		{
442 			aTbxAdjust.CheckItem(nId);
443 		}
444 		nLastAdjustTbxId = nId;
445 	}
446 	else
447 	{
448 		aTbxAdjust.Disable();
449 		aMtrFldTextStart.Disable();
450 		aMtrFldDistance.Disable();
451 	}
452 }
453 
454 /*************************************************************************
455 |*
456 |* Abstand-Wert in Editfeld eintragen
457 |*
458 \************************************************************************/
459 
SetDistance_Impl(const XFormTextDistanceItem * pItem)460 void SvxFontWorkDialog::SetDistance_Impl(const XFormTextDistanceItem* pItem)
461 {
462 	// #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
463 	if ( pItem && !aMtrFldDistance.HasChildPathFocus() )
464 	{
465 		SetMetricValue( aMtrFldDistance, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
466 	}
467 }
468 
469 /*************************************************************************
470 |*
471 |* Einzug-Wert in Editfeld eintragen
472 |*
473 \************************************************************************/
474 
SetStart_Impl(const XFormTextStartItem * pItem)475 void SvxFontWorkDialog::SetStart_Impl(const XFormTextStartItem* pItem)
476 {
477 	// #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
478 	if ( pItem && !aMtrFldTextStart.HasChildPathFocus() )
479 	{
480 		SetMetricValue( aMtrFldTextStart, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
481 	}
482 }
483 
484 /*************************************************************************
485 |*
486 |* Button fuer Umkehrung der Textrichtung setzen
487 |*
488 \************************************************************************/
489 
SetMirror_Impl(const XFormTextMirrorItem * pItem)490 void SvxFontWorkDialog::SetMirror_Impl(const XFormTextMirrorItem* pItem)
491 {
492 	if ( pItem )
493 		aTbxAdjust.CheckItem(TBI_ADJUST_MIRROR, pItem->GetValue());
494 }
495 
496 /*************************************************************************
497 |*
498 |* Button fuer Konturanzeige setzen
499 |*
500 \************************************************************************/
501 
SetShowForm_Impl(const XFormTextHideFormItem * pItem)502 void SvxFontWorkDialog::SetShowForm_Impl(const XFormTextHideFormItem* pItem)
503 {
504 	if ( pItem )
505 		aTbxShadow.CheckItem(TBI_SHOWFORM, !pItem->GetValue());
506 }
507 
508 /*************************************************************************
509 |*
510 |* Button fuer Zeichenumrandung setzen
511 |*
512 \************************************************************************/
513 
SetOutline_Impl(const XFormTextOutlineItem * pItem)514 void SvxFontWorkDialog::SetOutline_Impl(const XFormTextOutlineItem* pItem)
515 {
516 	if ( pItem )
517 		aTbxShadow.CheckItem(TBI_OUTLINE, pItem->GetValue());
518 }
519 
520 /*************************************************************************
521 |*
522 |* Shadow-Buttons setzen
523 |*
524 \************************************************************************/
525 
SetShadow_Impl(const XFormTextShadowItem * pItem,sal_Bool bRestoreValues)526 void SvxFontWorkDialog::SetShadow_Impl(const XFormTextShadowItem* pItem,
527 										sal_Bool bRestoreValues)
528 {
529 	if ( pItem )
530 	{
531 		sal_uInt16 nId;
532 
533 		aTbxShadow.Enable();
534 
535 		if ( pItem->GetValue() == XFTSHADOW_NONE )
536 		{
537 			nId = TBI_SHADOW_OFF;
538 			aFbShadowX.Hide();
539 			aFbShadowY.Hide();
540 			aMtrFldShadowX.Disable();
541 			aMtrFldShadowY.Disable();
542 			aShadowColorLB.Disable();
543 		}
544 		else
545 		{
546 			aFbShadowX.Show();
547 			aFbShadowY.Show();
548 			aMtrFldShadowX.Enable();
549 			aMtrFldShadowY.Enable();
550 			aShadowColorLB.Enable();
551 
552 			if ( pItem->GetValue() == XFTSHADOW_NORMAL )
553 			{
554 				nId = TBI_SHADOW_NORMAL;
555 				const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
556 
557 //              aFbShadowX.SetBitmap( Bitmap( ResId(RID_SVXBMP_SHADOW_XDIST, _pMgr ) ) );
558 				//aMtrFldShadowX.SetUnit(FUNIT_MM);
559 				aMtrFldShadowX.SetUnit( eDlgUnit );
560 				aMtrFldShadowX.SetDecimalDigits(2);
561                 aMtrFldShadowX.SetMin(LONG_MIN);
562                 aMtrFldShadowX.SetMax(LONG_MAX);
563 				if( eDlgUnit == FUNIT_MM )
564 					aMtrFldShadowX.SetSpinSize( 50 );
565 				else
566 					aMtrFldShadowX.SetSpinSize( 10 );
567 
568 //              aFbShadowY.SetBitmap( Bitmap( ResId( RID_SVXBMP_SHADOW_YDIST, _pMgr ) ) );
569 				//aMtrFldShadowY.SetUnit(FUNIT_MM);
570 				aMtrFldShadowY.SetUnit( eDlgUnit );
571 				aMtrFldShadowY.SetDecimalDigits(2);
572                 aMtrFldShadowY.SetMin(LONG_MIN);
573                 aMtrFldShadowY.SetMax(LONG_MAX);
574 				if( eDlgUnit == FUNIT_MM )
575 					aMtrFldShadowY.SetSpinSize( 50 );
576 				else
577 					aMtrFldShadowY.SetSpinSize( 10 );
578 
579 				if ( bRestoreValues )
580 				{
581 					SetMetricValue( aMtrFldShadowX, nSaveShadowX, SFX_MAPUNIT_100TH_MM );
582 					SetMetricValue( aMtrFldShadowY, nSaveShadowY, SFX_MAPUNIT_100TH_MM );
583 
584 					XFormTextShadowXValItem aXItem( nSaveShadowX );
585 					XFormTextShadowYValItem aYItem( nSaveShadowY );
586 
587 					GetBindings().GetDispatcher()->Execute(
588 						SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
589 				}
590 			}
591 			else
592 			{
593 				nId = TBI_SHADOW_SLANT;
594 
595 //              aFbShadowX.SetBitmap( Bitmap( ResId( RID_SVXBMP_SHADOW_ANGLE, _pMgr ) ) );
596 				aMtrFldShadowX.SetUnit(FUNIT_CUSTOM);
597 				aMtrFldShadowX.SetDecimalDigits(1);
598                 aMtrFldShadowX.SetMin(-1800);
599                 aMtrFldShadowX.SetMax( 1800);
600 				aMtrFldShadowX.SetSpinSize(10);
601 
602 //              aFbShadowY.SetBitmap( Bitmap( ResId( RID_SVXBMP_SHADOW_SIZE, _pMgr ) ) );
603 				aMtrFldShadowY.SetUnit(FUNIT_PERCENT);
604 				aMtrFldShadowY.SetDecimalDigits(0);
605                 aMtrFldShadowY.SetMin(-999);
606                 aMtrFldShadowY.SetMax( 999);
607 				aMtrFldShadowY.SetSpinSize(10);
608 
609 				if ( bRestoreValues )
610 				{
611 					aMtrFldShadowX.SetValue(nSaveShadowAngle);
612 					aMtrFldShadowY.SetValue(nSaveShadowSize);
613 					XFormTextShadowXValItem aXItem(nSaveShadowAngle);
614 					XFormTextShadowYValItem aYItem(nSaveShadowSize);
615 					GetBindings().GetDispatcher()->Execute(
616 						SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
617 				}
618 			}
619 		}
620 
621 		if ( !aTbxShadow.IsItemChecked(nId) )
622 		{
623 			aTbxShadow.CheckItem(nId);
624 		}
625 		nLastShadowTbxId = nId;
626 
627 		ApplyImageList();
628 	}
629 	else
630 	{
631 		aTbxShadow.Disable();
632 		aMtrFldShadowX.Disable();
633 		aMtrFldShadowY.Disable();
634 		aShadowColorLB.Disable();
635 	}
636 }
637 
638 /*************************************************************************
639 |*
640 |* Schattenfarbe in Listbox eintragen
641 |*
642 \************************************************************************/
643 
SetShadowColor_Impl(const XFormTextShadowColorItem * pItem)644 void SvxFontWorkDialog::SetShadowColor_Impl(const XFormTextShadowColorItem* pItem)
645 {
646 	if ( pItem )
647         aShadowColorLB.SelectEntry(pItem->GetColorValue());
648 }
649 
650 /*************************************************************************
651 |*
652 |* X-Wert fuer Schatten in Editfeld eintragen
653 |*
654 \************************************************************************/
655 
SetShadowXVal_Impl(const XFormTextShadowXValItem * pItem)656 void SvxFontWorkDialog::SetShadowXVal_Impl(const XFormTextShadowXValItem* pItem)
657 {
658 	// #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
659 	if ( pItem && !aMtrFldShadowX.HasChildPathFocus() )
660 	{
661 		// #i19251#
662 		// sal_Int32 nValue = pItem->GetValue();
663 
664 		// #i19251#
665 		// The two involved fields/items are used double and contain/give different
666 		// values regarding to the access method. Thus, here we need to separate the access
667 		// methos regarding to the kind of value accessed.
668 		if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
669 		{
670 			// #i19251#
671 			// There is no value correction necessary at all, i think this
672 			// was only tried to be done without understanding that the two
673 			// involved fields/items are used double and contain/give different
674 			// values regarding to the access method.
675 			// nValue = nValue - ( int( float( nValue ) / 360.0 ) * 360 );
676 			aMtrFldShadowX.SetValue(pItem->GetValue());
677 		}
678 		else
679 		{
680 			SetMetricValue( aMtrFldShadowX, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
681 		}
682 	}
683 }
684 
685 /*************************************************************************
686 |*
687 |* Y-Wert fuer Schatten in Editfeld eintragen
688 |*
689 \************************************************************************/
690 
SetShadowYVal_Impl(const XFormTextShadowYValItem * pItem)691 void SvxFontWorkDialog::SetShadowYVal_Impl(const XFormTextShadowYValItem* pItem)
692 {
693 	// #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
694 	if ( pItem && !aMtrFldShadowY.HasChildPathFocus() )
695 	{
696 		// #i19251#
697 		// The two involved fields/items are used double and contain/give different
698 		// values regarding to the access method. Thus, here we need to separate the access
699 		// methos regarding to the kind of value accessed.
700 		if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
701 		{
702 			aMtrFldShadowY.SetValue(pItem->GetValue());
703 		}
704 		else
705 		{
706 			SetMetricValue( aMtrFldShadowY, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
707 		}
708 	}
709 }
710 
711 /*************************************************************************
712 |*
713 \************************************************************************/
714 
IMPL_LINK(SvxFontWorkDialog,SelectStyleHdl_Impl,void *,EMPTYARG)715 IMPL_LINK( SvxFontWorkDialog, SelectStyleHdl_Impl, void *, EMPTYARG )
716 {
717 	sal_uInt16 nId = aTbxStyle.GetCurItemId();
718 
719     // Execute this block when a different toolbox item has been clicked or
720     // when the off item has been clicked.  The later is necessary to
721     // override the toolbox behaviour of unchecking the item after second
722     // click on it: One of the items has to be checked at all times (when
723     // enabled that is.)
724 	if (nId == TBI_STYLE_OFF || nId != nLastStyleTbxId )
725 	{
726 		XFormTextStyle eStyle = XFT_NONE;
727 
728 		switch ( nId )
729 		{
730 			case TBI_STYLE_ROTATE	: eStyle = XFT_ROTATE;	break;
731 			case TBI_STYLE_UPRIGHT	: eStyle = XFT_UPRIGHT; break;
732 			case TBI_STYLE_SLANTX	: eStyle = XFT_SLANTX;	break;
733 			case TBI_STYLE_SLANTY	: eStyle = XFT_SLANTY;	break;
734 		}
735 		XFormTextStyleItem aItem( eStyle );
736 		GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_STYLE, SFX_CALLMODE_RECORD, &aItem, 0L );
737 		SetStyle_Impl( &aItem );
738 		nLastStyleTbxId = nId;
739 	}
740 	return 0;
741 }
742 
743 /*************************************************************************
744 |*
745 \************************************************************************/
746 
IMPL_LINK(SvxFontWorkDialog,SelectAdjustHdl_Impl,void *,EMPTYARG)747 IMPL_LINK( SvxFontWorkDialog, SelectAdjustHdl_Impl, void *, EMPTYARG )
748 {
749 	sal_uInt16 nId = aTbxAdjust.GetCurItemId();
750 
751 	if ( nId == TBI_ADJUST_MIRROR )
752 	{
753 		XFormTextMirrorItem aItem(aTbxAdjust.IsItemChecked(nId));
754 		GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_MIRROR, SFX_CALLMODE_SLOT, &aItem, 0L );
755 	}
756 	else if ( nId != nLastAdjustTbxId )
757 	{
758 		XFormTextAdjust eAdjust = XFT_AUTOSIZE;
759 
760 		switch ( nId )
761 		{
762 			case TBI_ADJUST_LEFT	: eAdjust = XFT_LEFT;	break;
763 			case TBI_ADJUST_CENTER	: eAdjust = XFT_CENTER; break;
764 			case TBI_ADJUST_RIGHT	: eAdjust = XFT_RIGHT;	break;
765 		}
766 		XFormTextAdjustItem aItem(eAdjust);
767 		GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_ADJUST, SFX_CALLMODE_RECORD, &aItem, 0L );
768 		SetAdjust_Impl(&aItem);
769 		nLastAdjustTbxId = nId;
770 	}
771 	return 0;
772 }
773 
774 /*************************************************************************
775 |*
776 \************************************************************************/
777 
IMPL_LINK(SvxFontWorkDialog,SelectShadowHdl_Impl,void *,EMPTYARG)778 IMPL_LINK( SvxFontWorkDialog, SelectShadowHdl_Impl, void *, EMPTYARG )
779 {
780 	sal_uInt16 nId = aTbxShadow.GetCurItemId();
781 
782 	if ( nId == TBI_SHOWFORM )
783 	{
784 		XFormTextHideFormItem aItem(!aTbxShadow.IsItemChecked(nId));
785 		GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_HIDEFORM, SFX_CALLMODE_RECORD, &aItem, 0L );
786 	}
787 	else if ( nId == TBI_OUTLINE )
788 	{
789 		XFormTextOutlineItem aItem(aTbxShadow.IsItemChecked(nId));
790 		GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_OUTLINE, SFX_CALLMODE_RECORD, &aItem, 0L );
791 	}
792 	else if ( nId != nLastShadowTbxId )
793 	{
794 		XFormTextShadow eShadow = XFTSHADOW_NONE;
795 
796 		if ( nLastShadowTbxId == TBI_SHADOW_NORMAL )
797 		{
798 			nSaveShadowX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
799 			nSaveShadowY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
800 		}
801 		else if ( nLastShadowTbxId == TBI_SHADOW_SLANT )
802 		{
803 			nSaveShadowAngle = static_cast<long>(aMtrFldShadowX.GetValue());
804 			nSaveShadowSize  = static_cast<long>(aMtrFldShadowY.GetValue());
805 		}
806 		nLastShadowTbxId = nId;
807 
808 		if ( nId == TBI_SHADOW_NORMAL ) 	eShadow = XFTSHADOW_NORMAL;
809 		else if ( nId == TBI_SHADOW_SLANT ) eShadow = XFTSHADOW_SLANT;
810 
811 		XFormTextShadowItem aItem(eShadow);
812 		GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHADOW, SFX_CALLMODE_RECORD, &aItem, 0L );
813 		SetShadow_Impl(&aItem, sal_True);
814 	}
815 	return 0;
816 }
817 
818 /*************************************************************************
819 |*
820 \************************************************************************/
821 
IMPL_LINK_INLINE_START(SvxFontWorkDialog,ModifyInputHdl_Impl,void *,EMPTYARG)822 IMPL_LINK_INLINE_START( SvxFontWorkDialog, ModifyInputHdl_Impl, void *, EMPTYARG )
823 {
824 	aInputTimer.Start();
825 	return 0;
826 }
IMPL_LINK_INLINE_END(SvxFontWorkDialog,ModifyInputHdl_Impl,void *,EMPTYARG)827 IMPL_LINK_INLINE_END( SvxFontWorkDialog, ModifyInputHdl_Impl, void *, EMPTYARG )
828 
829 /*************************************************************************
830 |*
831 \************************************************************************/
832 
833 IMPL_LINK( SvxFontWorkDialog, InputTimoutHdl_Impl, void *, EMPTYARG )
834 {
835 	// System-Metrik evtl. neu setzen
836 	// Dieses sollte mal als Listener passieren, ist aber aus
837 	// inkompatibilitaetsgruenden z.Z. nicht moeglich
838 	const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
839 	if( eDlgUnit != aMtrFldDistance.GetUnit() )
840 	{
841 		SetFieldUnit( aMtrFldDistance, eDlgUnit, sal_True );
842 		SetFieldUnit( aMtrFldTextStart, eDlgUnit, sal_True );
843 		aMtrFldDistance.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
844 		aMtrFldTextStart.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
845 	}
846 	if( eDlgUnit != aMtrFldShadowX.GetUnit() &&
847 		aTbxShadow.IsItemChecked( TBI_SHADOW_NORMAL ) )
848 	{
849 		SetFieldUnit( aMtrFldShadowX, eDlgUnit, sal_True );
850 		SetFieldUnit( aMtrFldShadowY, eDlgUnit, sal_True );
851 		aMtrFldShadowX.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
852 		aMtrFldShadowY.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
853 	}
854 
855 	long nValue = GetCoreValue( aMtrFldDistance, SFX_MAPUNIT_100TH_MM );
856 	XFormTextDistanceItem aDistItem( nValue );
857 	nValue = GetCoreValue( aMtrFldTextStart, SFX_MAPUNIT_100TH_MM );
858 	XFormTextStartItem aStartItem( nValue );
859 
860 	sal_Int32 nValueX(0L);
861 	sal_Int32 nValueY(0L);
862 
863 	// #i19251#
864 	// The two involved fields/items are used double and contain/give different
865 	// values regarding to the access method. Thus, here we need to separate the access
866 	// methos regarding to the kind of value accessed.
867 	if(nLastShadowTbxId == TBI_SHADOW_NORMAL)
868 	{
869 		nValueX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
870 		nValueY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
871 	}
872 	else if(nLastShadowTbxId == TBI_SHADOW_SLANT)
873 	{
874 		nValueX = static_cast<long>(aMtrFldShadowX.GetValue());
875 		nValueY = static_cast<long>(aMtrFldShadowY.GetValue());
876 	}
877 
878 	XFormTextShadowXValItem aShadowXItem( nValueX );
879 	XFormTextShadowYValItem aShadowYItem( nValueY );
880 
881 	// Slot-ID ist egal, die Exec-Methode wertet das gesamte ItemSet aus
882 	GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_DISTANCE, SFX_CALLMODE_RECORD, &aDistItem,
883 											&aStartItem, &aShadowXItem, &aShadowYItem, 0L );
884 	return 0;
885 }
886 
887 /*************************************************************************
888 |*
889 \************************************************************************/
890 
IMPL_LINK(SvxFontWorkDialog,ColorSelectHdl_Impl,void *,EMPTYARG)891 IMPL_LINK( SvxFontWorkDialog, ColorSelectHdl_Impl, void *, EMPTYARG )
892 {
893 // Changed by obo. Linux-Compiler can't parse commented lines
894 	XFormTextShadowColorItem aItem( (const String &) String(),
895 								    (const Color &) aShadowColorLB.GetSelectEntryColor() );
896 //	XFormTextShadowColorItem aItem( String(),
897 //								    aShadowColorLB.GetSelectEntryColor() );
898 	GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHDWCOLOR, SFX_CALLMODE_RECORD, &aItem, 0L );
899 	return 0;
900 }
901 
902 /*************************************************************************
903 |*
904 \************************************************************************/
905 
SetColorTable(XColorListSharedPtr aTable)906 void SvxFontWorkDialog::SetColorTable(XColorListSharedPtr aTable)
907 {
908 	if ( aTable != maColorTable )
909 	{
910 		maColorTable = aTable;
911 		aShadowColorLB.Clear();
912 		aShadowColorLB.Fill(maColorTable);
913 	}
914 }
915 
916 /*************************************************************************
917 |*
918 \************************************************************************/
919 
SetActive(sal_Bool)920 void SvxFontWorkDialog::SetActive(sal_Bool /*bActivate*/)
921 {
922 }
923 
DataChanged(const DataChangedEvent & rDCEvt)924 void SvxFontWorkDialog::DataChanged( const DataChangedEvent& rDCEvt )
925 {
926 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
927             ApplyImageList();
928 
929     SfxDockingWindow::DataChanged( rDCEvt );
930 }
931 /* -----------------------------08.05.2002 14:28------------------------------
932 
933  ---------------------------------------------------------------------------*/
ApplyImageList()934 void SvxFontWorkDialog::ApplyImageList()
935 {
936 	bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
937 
938     ImageList& rImgLst = bHighContrast ? maImageListH : maImageList;
939 
940 	aTbxStyle.SetImageList( rImgLst );
941 	aTbxAdjust.SetImageList( rImgLst );
942 	aTbxShadow.SetImageList( rImgLst );
943 
944 	switch( nLastShadowTbxId )
945 	{
946 	case TBI_SHADOW_SLANT:
947 		aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_ANGLE ) );
948 		aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_SIZE ) );
949 		break;
950 //	case TBI_SHADOW_NORMAL:
951 	default:
952 		aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_XDIST ) );
953 		aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_YDIST ) );
954 		break;
955 	}
956 
957 	aFbDistance.SetImage( rImgLst.GetImage( TBI_DISTANCE ) );
958 	aFbTextStart.SetImage( rImgLst.GetImage( TBI_TEXTSTART ) );
959 
960 }
961