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 #include "precompiled_sc.hxx"
23 
24 #include <sfx2/sidebar/propertypanel.hrc>
25 #include <sfx2/sidebar/Theme.hxx>
26 #include <sfx2/sidebar/ControlFactory.hxx>
27 #include <AlignmentPropertyPanel.hxx>
28 #include <AlignmentPropertyPanel.hrc>
29 #include <svx/dialmgr.hxx>
30 #include "sc.hrc"
31 #include "scresid.hxx"
32 #include <sfx2/bindings.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <svx/algitem.hxx>
35 #include <svx/dlgutil.hxx>
36 #include <vcl/toolbox.hxx>
37 #include <svx/sidebar/SidebarDialControl.hxx>
38 
39 using namespace css;
40 using namespace cssu;
41 
42 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
43 
44 //////////////////////////////////////////////////////////////////////////////
45 // namespace open
46 
47 namespace sc { namespace sidebar {
48 
49 //////////////////////////////////////////////////////////////////////////////
50 
51 AlignmentPropertyPanel::AlignmentPropertyPanel(
52     Window* pParent,
53     const cssu::Reference<css::frame::XFrame>& rxFrame,
54     SfxBindings* pBindings)
55 :   Control(
56         pParent,
57         ScResId(RID_PROPERTYPANEL_SC_ALIGNMENT)),
58     mpTBHorizontal(new ToolBox(this, ScResId(TBX_HORIZONTAL_ALIGNMENT))),
59     mpTBVertical(new ToolBox(this, ScResId(TBX_VERTICAL_ALIGN))),
60     mpFTLeftIndent(new FixedText(this, ScResId(FT_LEFT_INDENT))),
61     mpMFLeftIndent(new MetricField(this, ScResId(MF_LEFT_INDENT))),
62     mpCBXWrapText(new CheckBox(this, ScResId(CBX_WRAP))),
63     mpCBXMergeCell(new CheckBox(this, ScResId(CBX_MERGE))),
64     mpFtRotate(new FixedText(this, ScResId(FT_ORIENT))),
65     mpCtrlDial(new svx::sidebar::SidebarDialControl(this, ScResId(DIAL_CONTROL))), // , true)),
66     mpMtrAngle(new MetricBox(this, ScResId(CBOX_ANGLE))),
67     mpCbStacked(new CheckBox(this, ScResId(CBX_VERT))),
68     maAlignHorControl(SID_H_ALIGNCELL, *pBindings, *this),
69     maAlignVerControl(SID_V_ALIGNCELL, *pBindings, *this),
70     maLeftIndentControl(SID_ATTR_ALIGN_INDENT, *pBindings, *this),
71     maMergeCellControl(FID_MERGE_TOGGLE, *pBindings, *this),
72     maWrapTextControl(SID_ATTR_ALIGN_LINEBREAK, *pBindings, *this),
73     maAngleControl(SID_ATTR_ALIGN_DEGREES, *pBindings, *this),
74     maStackControl(SID_ATTR_ALIGN_STACKED, *pBindings, *this),
75     maIMGAlignLeft(ScResId(IMG_ALIGN_LEFT)),
76     maIMGAlignCenter(ScResId(IMG_ALIGN_CENTER)),
77     maIMGAlignRight(ScResId(IMG_ALIGN_RIGHT)),
78     maIMGAlignJust(ScResId(IMG_ALIGN_JUST)),
79     maIMGAlignTop(ScResId(IMG_ALIGN_TOP)),
80     maIMGAlignCenterV(ScResId(IMG_ALIGN_CENTER_V)),
81     maIMGAlignBottom(ScResId(IMG_ALIGN_BOTTOM)),
82     meHorAlignState(SVX_HOR_JUSTIFY_STANDARD),
83     meVerAlignState(SVX_VER_JUSTIFY_STANDARD),
84     mbMultiDisable(false),
85     mxFrame(rxFrame),
86     maContext(),
87     mpBindings(pBindings)
88 {
89     Initialize();
90     FreeResource();
91 }
92 
93 //////////////////////////////////////////////////////////////////////////////
94 
95 AlignmentPropertyPanel::~AlignmentPropertyPanel()
96 {
97 }
98 
99 //////////////////////////////////////////////////////////////////////////////
100 
101 void AlignmentPropertyPanel::Initialize()
102 {
103 	mpTBHorizontal->SetItemImage(ID_SUBSTLEFT, maIMGAlignLeft);
104 	mpTBHorizontal->SetItemImage(ID_SUBSTCENTER, maIMGAlignCenter);
105 	mpTBHorizontal->SetItemImage(ID_SUBSTRIGHT, maIMGAlignRight);
106 	mpTBHorizontal->SetItemImage(ID_SUBSTJUSTIFY, maIMGAlignJust);
107 	Size aTbxSize( mpTBHorizontal->CalcWindowSizePixel() );
108 	mpTBHorizontal->SetOutputSizePixel( aTbxSize );
109 	mpTBHorizontal->SetBackground(Wallpaper());
110 	mpTBHorizontal->SetPaintTransparent(true);
111 	Link aLink = LINK(this, AlignmentPropertyPanel, TbxHorAlignSelectHdl);
112 	mpTBHorizontal->SetSelectHdl ( aLink );
113 
114 	mpTBVertical->SetItemImage(IID_VERT_TOP, maIMGAlignTop);
115 	mpTBVertical->SetItemImage(IID_VERT_CENTER, maIMGAlignCenterV);
116 	mpTBVertical->SetItemImage(IID_VERT_BOTTOM, maIMGAlignBottom);
117 	Size aTbxSize2( mpTBVertical->CalcWindowSizePixel() );
118 	mpTBVertical->SetOutputSizePixel( aTbxSize2 );
119 	mpTBVertical->SetBackground(Wallpaper());
120 	mpTBVertical->SetPaintTransparent(true);
121 	aLink = LINK(this, AlignmentPropertyPanel, TbxVerAlignSelectHdl);
122 	mpTBVertical->SetSelectHdl ( aLink );
123 
124 	mpFTLeftIndent->Disable();
125 	mpMFLeftIndent->Disable();
126 	mpMFLeftIndent->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Left Indent")));	//wj acc
127 	aLink = LINK(this, AlignmentPropertyPanel, MFLeftIndentMdyHdl);
128 	mpMFLeftIndent->SetModifyHdl ( aLink );
129 
130 	aLink = LINK(this, AlignmentPropertyPanel, CBOXMergnCellClkHdl);
131 	mpCBXMergeCell->SetClickHdl ( aLink );
132 
133 	aLink = LINK(this, AlignmentPropertyPanel, CBOXWrapTextClkHdl);
134 	mpCBXWrapText->SetClickHdl ( aLink );
135 
136 	//rotation control
137 	mpCtrlDial->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text Orientation")));	//wj acc
138 	mpCtrlDial->SetModifyHdl(LINK( this, AlignmentPropertyPanel, RotationHdl));
139 
140     //rotation
141 	mpMtrAngle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text Orientation")));	//wj acc
142 	mpMtrAngle->SetModifyHdl(LINK( this, AlignmentPropertyPanel, AngleModifiedHdl));
143 	mpMtrAngle->EnableAutocomplete( false );
144 
145     //Vertical stacked
146 	mpCbStacked->SetClickHdl( LINK( this, AlignmentPropertyPanel, ClickStackHdl ) );
147 
148 	mpMtrAngle->InsertValue(0, FUNIT_CUSTOM);
149 	mpMtrAngle->InsertValue(45, FUNIT_CUSTOM);
150 	mpMtrAngle->InsertValue(90, FUNIT_CUSTOM);
151 	mpMtrAngle->InsertValue(135, FUNIT_CUSTOM);
152 	mpMtrAngle->InsertValue(180, FUNIT_CUSTOM);
153 	mpMtrAngle->InsertValue(225, FUNIT_CUSTOM);
154 	mpMtrAngle->InsertValue(270, FUNIT_CUSTOM);
155 	mpMtrAngle->InsertValue(315, FUNIT_CUSTOM);
156     mpMtrAngle->SetDropDownLineCount(mpMtrAngle->GetEntryCount());
157 
158     mpTBHorizontal->SetAccessibleRelationLabeledBy(mpTBHorizontal.get());
159 	mpTBVertical->SetAccessibleRelationLabeledBy(mpTBVertical.get());
160 	mpMFLeftIndent->SetAccessibleRelationLabeledBy(mpFTLeftIndent.get());
161 	mpMtrAngle->SetAccessibleRelationLabeledBy(mpFtRotate.get());
162 #ifdef HAS_IA2
163 	mpMtrAngle->SetMpSubEditAccLableBy(mpFtRotate.get());
164 #endif
165 }
166 
167 //////////////////////////////////////////////////////////////////////////////
168 
169 IMPL_LINK( AlignmentPropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
170 {
171 	String sTmp = mpMtrAngle->GetText();
172 
173 	sal_Unicode nChar = sTmp.GetChar( 0 );
174 	if((sTmp.Len()== 1 &&  nChar == '-') ||
175 		(nChar != '-' && ((nChar < '0') || (nChar > '9') ) ))	////modify
176 		return 0;
177 
178 	double dTmp = sTmp.ToDouble();
179 	FormatDegrees(dTmp);
180 
181 	sal_Int64 nTmp = (sal_Int64)dTmp*100;
182 	SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp);
183 
184 	GetBindings()->GetDispatcher()->Execute(
185 		SID_ATTR_ALIGN_DEGREES, SFX_CALLMODE_RECORD, &aAngleItem, 0L );
186 	return 0;
187 }
188 
189 //////////////////////////////////////////////////////////////////////////////
190 
191 IMPL_LINK( AlignmentPropertyPanel, RotationHdl, void *, EMPTYARG )
192 {
193 	sal_Int32 nTmp = mpCtrlDial->GetRotation();
194 	SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp);
195 
196 	GetBindings()->GetDispatcher()->Execute(
197 		SID_ATTR_ALIGN_DEGREES, SFX_CALLMODE_RECORD, &aAngleItem, 0L );
198 
199 	return 0;
200 }
201 
202 //////////////////////////////////////////////////////////////////////////////
203 
204 IMPL_LINK( AlignmentPropertyPanel, ClickStackHdl, void *, EMPTYARG )
205 {
206 	bool bVertical = mpCbStacked->IsChecked() ? true : false;
207 	SfxBoolItem  aStackItem( SID_ATTR_ALIGN_STACKED, bVertical );
208 	GetBindings()->GetDispatcher()->Execute(
209 		SID_ATTR_ALIGN_STACKED, SFX_CALLMODE_RECORD, &aStackItem, 0L );
210 	return 0;
211 }
212 
213 //////////////////////////////////////////////////////////////////////////////
214 
215 IMPL_LINK(AlignmentPropertyPanel, TbxHorAlignSelectHdl, ToolBox*, pToolBox)
216 {
217 	sal_uInt16 nId = pToolBox->GetCurItemId();
218 
219 	if(nId == ID_SUBSTLEFT)
220 	{
221 		if(meHorAlignState != SVX_HOR_JUSTIFY_LEFT)
222 			meHorAlignState = SVX_HOR_JUSTIFY_LEFT;
223 		else
224 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
225 	}
226 	else if( nId == ID_SUBSTCENTER )
227 	{
228 		if(meHorAlignState != SVX_HOR_JUSTIFY_CENTER)
229 			meHorAlignState = SVX_HOR_JUSTIFY_CENTER;
230 		else
231 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
232 	}
233 	else if( nId == ID_SUBSTRIGHT )
234 	{
235 		if(meHorAlignState != SVX_HOR_JUSTIFY_RIGHT)
236 			meHorAlignState = SVX_HOR_JUSTIFY_RIGHT;
237 		else
238 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
239 	}
240 	else if( nId == ID_SUBSTJUSTIFY )
241 	{
242 		if(meHorAlignState != SVX_HOR_JUSTIFY_BLOCK)
243 			meHorAlignState = SVX_HOR_JUSTIFY_BLOCK;
244 		else
245 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
246 	}
247 	SvxHorJustifyItem aHorItem(meHorAlignState, SID_H_ALIGNCELL);
248 	GetBindings()->GetDispatcher()->Execute(SID_H_ALIGNCELL, SFX_CALLMODE_RECORD, &aHorItem, 0L);
249 	UpdateHorAlign();
250 	return 0;
251 }
252 
253 //////////////////////////////////////////////////////////////////////////////
254 
255 IMPL_LINK(AlignmentPropertyPanel, TbxVerAlignSelectHdl, ToolBox*, pToolBox)
256 {
257 	sal_uInt16 nId = pToolBox->GetCurItemId();
258 
259 	//Bold
260 	if(nId == IID_VERT_TOP)
261 	{
262 		if(meVerAlignState != SVX_VER_JUSTIFY_TOP)
263 			meVerAlignState = SVX_VER_JUSTIFY_TOP;
264 		else
265 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
266 	}
267 	else if( nId == IID_VERT_CENTER )
268 	{
269 		if(meVerAlignState != SVX_VER_JUSTIFY_CENTER)
270 			meVerAlignState = SVX_VER_JUSTIFY_CENTER;
271 		else
272 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
273 	}
274 	else if( nId == IID_VERT_BOTTOM )
275 	{
276 		if(meVerAlignState != SVX_VER_JUSTIFY_BOTTOM)
277 			meVerAlignState = SVX_VER_JUSTIFY_BOTTOM;
278 		else
279 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
280 	}
281 	SvxVerJustifyItem aVerItem(meVerAlignState, SID_V_ALIGNCELL);
282 	GetBindings()->GetDispatcher()->Execute(SID_V_ALIGNCELL, SFX_CALLMODE_RECORD, &aVerItem, 0L);
283 	UpdateVerAlign();
284 	return 0;
285 }
286 
287 //////////////////////////////////////////////////////////////////////////////
288 
289 IMPL_LINK(AlignmentPropertyPanel, MFLeftIndentMdyHdl, void*, EMPTYARG)
290 {
291 	mpCBXWrapText->EnableTriState(false);
292 	sal_uInt16 nVal = (sal_uInt16)mpMFLeftIndent->GetValue();
293 	SfxUInt16Item aItem( SID_ATTR_ALIGN_INDENT,  (sal_uInt16)CalcToUnit( nVal,  SFX_MAPUNIT_TWIP ) );
294 
295 	GetBindings()->GetDispatcher()->Execute(SID_ATTR_ALIGN_INDENT, SFX_CALLMODE_RECORD, &aItem, 0L);
296 	return( 0L );
297 }
298 
299 //////////////////////////////////////////////////////////////////////////////
300 
301 IMPL_LINK(AlignmentPropertyPanel, CBOXMergnCellClkHdl, void*, EMPTYARG)
302 {
303 	bool bState = mpCBXMergeCell->IsChecked();
304 
305 	//Modified
306 	//SfxBoolItem aItem( FID_MERGE_TOGGLE , bState);
307 	//GetBindings()->GetDispatcher()->Execute(FID_MERGE_TOGGLE, SFX_CALLMODE_RECORD, &aItem, false, 0L);
308 	if(bState)
309 		GetBindings()->GetDispatcher()->Execute(FID_MERGE_ON, SFX_CALLMODE_RECORD);
310 	else
311 		GetBindings()->GetDispatcher()->Execute(FID_MERGE_OFF, SFX_CALLMODE_RECORD);
312 	GetBindings()->Invalidate(FID_MERGE_TOGGLE,true,false);
313 	//modified end
314 
315 	return 0;
316 }
317 
318 //////////////////////////////////////////////////////////////////////////////
319 
320 IMPL_LINK(AlignmentPropertyPanel, CBOXWrapTextClkHdl, void*, EMPTYARG)
321 {
322 	bool bState = mpCBXWrapText->IsChecked();
323 	SfxBoolItem aItem( SID_ATTR_ALIGN_LINEBREAK , bState);
324 	GetBindings()->GetDispatcher()->Execute(SID_ATTR_ALIGN_LINEBREAK, SFX_CALLMODE_RECORD, &aItem, 0L);
325 	return 0;
326 }
327 
328 //////////////////////////////////////////////////////////////////////////////
329 
330 AlignmentPropertyPanel* AlignmentPropertyPanel::Create (
331     Window* pParent,
332     const cssu::Reference<css::frame::XFrame>& rxFrame,
333     SfxBindings* pBindings)
334 {
335     if (pParent == NULL)
336         throw lang::IllegalArgumentException(A2S("no parent Window given to AlignmentPropertyPanel::Create"), NULL, 0);
337     if ( ! rxFrame.is())
338         throw lang::IllegalArgumentException(A2S("no XFrame given to AlignmentPropertyPanel::Create"), NULL, 1);
339     if (pBindings == NULL)
340         throw lang::IllegalArgumentException(A2S("no SfxBindings given to AlignmentPropertyPanel::Create"), NULL, 2);
341 
342     return new AlignmentPropertyPanel(
343         pParent,
344         rxFrame,
345         pBindings);
346 }
347 
348 //////////////////////////////////////////////////////////////////////////////
349 
350 void AlignmentPropertyPanel::DataChanged(
351     const DataChangedEvent& rEvent)
352 {
353     (void)rEvent;
354 }
355 
356 //////////////////////////////////////////////////////////////////////////////
357 
358 void AlignmentPropertyPanel::HandleContextChange(
359     const ::sfx2::sidebar::EnumContext aContext)
360 {
361     if(maContext == aContext)
362     {
363         // Nothing to do.
364         return;
365     }
366 
367     maContext = aContext;
368 
369 
370 
371     // todo
372 }
373 
374 //////////////////////////////////////////////////////////////////////////////
375 
376 void AlignmentPropertyPanel::NotifyItemUpdate(
377     sal_uInt16 nSID,
378     SfxItemState eState,
379     const SfxPoolItem* pState)
380 {
381 	switch(nSID)
382 	{
383 	case SID_H_ALIGNCELL:
384 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxHorJustifyItem) )
385 		{
386 				const SvxHorJustifyItem* pItem = (const SvxHorJustifyItem*)pState;
387 				meHorAlignState = (SvxCellHorJustify)pItem->GetValue();
388 		}
389 		else
390 		{
391 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
392 		}
393 		UpdateHorAlign();
394 		break;
395 	case SID_V_ALIGNCELL:
396 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxVerJustifyItem) )
397 		{
398 				const SvxVerJustifyItem* pItem = (const SvxVerJustifyItem*)pState;
399 				meVerAlignState = (SvxCellVerJustify)pItem->GetValue();
400 		}
401 		else
402 		{
403 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
404 		}
405 		UpdateVerAlign();
406 		break;
407 	case SID_ATTR_ALIGN_INDENT:
408 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SfxUInt16Item) )
409 		{
410 				const SfxUInt16Item* pItem = (const SfxUInt16Item*)pState;
411 				sal_uInt16 nVal = pItem->GetValue();
412 				mpMFLeftIndent->SetValue( CalcToPoint(nVal, SFX_MAPUNIT_TWIP, 1) );
413 		}
414 		else
415 		{
416 			mpMFLeftIndent->SetValue(0);
417 			mpMFLeftIndent->SetText(String());
418 		}
419 		break;
420 	case FID_MERGE_TOGGLE:
421 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SfxBoolItem) )
422 		{
423 			mpCBXMergeCell->Enable();
424 			const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
425 			bool bVal = pItem->GetValue();
426 			if(bVal)
427 				mpCBXMergeCell->Check(true);
428 			else
429 				mpCBXMergeCell->Check(false);
430 		}
431 		else
432 		{
433 			mpCBXMergeCell->Check(false);
434 			mpCBXMergeCell->Disable();
435 		}
436 		break;
437 
438 	case SID_ATTR_ALIGN_LINEBREAK:
439 		if(eState == SFX_ITEM_DISABLED)
440 		{
441 			mpCBXWrapText->EnableTriState(false);
442 			mpCBXWrapText->Check(false);
443 			mpCBXWrapText->Disable();
444 		}
445 		else
446 		{
447 			mpCBXWrapText->Enable();
448 			if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SfxBoolItem) )
449 			{
450 				mpCBXWrapText->EnableTriState(false);
451 				const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
452 				bool bVal = pItem->GetValue();
453 				if(bVal)
454 					mpCBXWrapText->Check(true);
455 				else
456 					mpCBXWrapText->Check(false);
457 			}
458 			else if(eState == SFX_ITEM_DONTCARE)
459 			{
460 				mpCBXWrapText->EnableTriState(true);
461 				mpCBXWrapText->SetState(STATE_DONTKNOW);
462 			}
463 		}
464 		break;
465 	case SID_ATTR_ALIGN_DEGREES:
466 		if (eState >= SFX_ITEM_AVAILABLE)
467 		{
468 			long nTmp = ((const SfxInt32Item*)pState)->GetValue();
469 			mpMtrAngle->SetValue( nTmp / 100);	//wj
470 			mpCtrlDial->SetRotation( nTmp );
471 			switch(nTmp)
472 			{
473 				case 0:
474 					mpMtrAngle->SelectEntryPos(0);
475 				break;
476 				case 4500:
477 					mpMtrAngle->SelectEntryPos(1);
478 				break;
479 				case 9000:
480 					mpMtrAngle->SelectEntryPos(2);
481 				break;
482 				case 13500:
483 					mpMtrAngle->SelectEntryPos(3);
484 				break;
485 				case 18000:
486 					mpMtrAngle->SelectEntryPos(4);
487 				break;
488 				case 22500:
489 					mpMtrAngle->SelectEntryPos(5);
490 				break;
491 				case 27000:
492 					mpMtrAngle->SelectEntryPos(6);
493 				break;
494 				case 31500:
495 					mpMtrAngle->SelectEntryPos(7);
496 			}
497 		}
498 		else
499 		{
500 			mpMtrAngle->SetText( String() );
501 			mpCtrlDial->SetRotation( 0 );
502 		}
503 		break;
504 	case SID_ATTR_ALIGN_STACKED:
505 		if (eState >= SFX_ITEM_AVAILABLE)
506 		{
507 			mpCbStacked->EnableTriState(false);
508 			const SfxBoolItem* aStackItem = (const SfxBoolItem*)pState;
509 			bool IsChecked = (bool)aStackItem->GetValue();
510 			if(IsChecked)
511 			{
512 				mpCbStacked->Check(IsChecked);
513 				mpFtRotate->Disable();
514 				mpMtrAngle->Disable();
515 				mpCtrlDial->Disable();
516 				mbMultiDisable = true;
517 			}
518 			else
519 			{
520 				mpCbStacked->Check(IsChecked);
521 				mpFtRotate->Enable();
522 				mpMtrAngle->Enable();
523 				mpCtrlDial->Enable();
524 				mbMultiDisable = false;
525 			}
526 		}
527 		else
528 		{
529 			mbMultiDisable = true;
530 			mpFtRotate->Disable();
531 			mpMtrAngle->Disable();
532 			mpCtrlDial->Disable();
533 			mpCbStacked->EnableTriState(true);
534 			mpCbStacked->SetState(STATE_DONTKNOW);
535 		}
536 	}
537 }
538 
539 //////////////////////////////////////////////////////////////////////////////
540 
541 SfxBindings* AlignmentPropertyPanel::GetBindings()
542 {
543     return mpBindings;
544 }
545 
546 //////////////////////////////////////////////////////////////////////////////
547 
548 void AlignmentPropertyPanel::FormatDegrees(double& dTmp)
549 {
550 	while(dTmp<0)
551 		dTmp += 360;
552 	while (dTmp > 359)	//modify
553 		dTmp = 359;
554 }
555 
556 //////////////////////////////////////////////////////////////////////////////
557 
558 void AlignmentPropertyPanel::UpdateHorAlign()
559 {
560 	mpTBHorizontal->SetItemState(ID_SUBSTLEFT,	STATE_NOCHECK);
561 	mpTBHorizontal->SetItemState(ID_SUBSTCENTER,	STATE_NOCHECK);
562 	mpTBHorizontal->SetItemState(ID_SUBSTRIGHT,	STATE_NOCHECK);
563 	mpTBHorizontal->SetItemState(ID_SUBSTJUSTIFY,STATE_NOCHECK);
564 	mpFTLeftIndent->Disable();
565 	mpMFLeftIndent->Disable();
566 	if(meHorAlignState==SVX_HOR_JUSTIFY_REPEAT)
567 	{
568 		mpFtRotate->Disable();
569 		mpCtrlDial->Disable();
570 		mpMtrAngle->Disable();
571 		mpCbStacked->Disable();
572 	}
573 	else
574 	{
575 		if(!mbMultiDisable)
576 		{
577 			mpFtRotate->Enable();
578 			mpCtrlDial->Enable();
579 			mpMtrAngle->Enable();
580 		}
581 		else
582 		{
583 			mpFtRotate->Disable();
584 			mpCtrlDial->Disable();
585 			mpMtrAngle->Disable();
586 		}
587 		mpCbStacked->Enable();
588 	}
589 	switch(meHorAlignState)
590 	{
591 	case SVX_HOR_JUSTIFY_LEFT:
592 		mpTBHorizontal->SetItemState(ID_SUBSTLEFT,	STATE_CHECK);
593 		mpFTLeftIndent->Enable();
594 		mpMFLeftIndent->Enable();
595 		break;
596 	case SVX_HOR_JUSTIFY_CENTER:mpTBHorizontal->SetItemState(ID_SUBSTCENTER,	STATE_CHECK);break;
597 	case SVX_HOR_JUSTIFY_RIGHT:	mpTBHorizontal->SetItemState(ID_SUBSTRIGHT,	STATE_CHECK);break;
598 	case SVX_HOR_JUSTIFY_BLOCK:	mpTBHorizontal->SetItemState(ID_SUBSTJUSTIFY,STATE_CHECK);break;
599 	default:;
600 	}
601 }
602 
603 //////////////////////////////////////////////////////////////////////////////
604 
605 void AlignmentPropertyPanel::UpdateVerAlign()
606 {
607 	mpTBVertical->SetItemState(IID_VERT_TOP,		STATE_NOCHECK);
608 	mpTBVertical->SetItemState(IID_VERT_CENTER,	STATE_NOCHECK);
609 	mpTBVertical->SetItemState(IID_VERT_BOTTOM,	STATE_NOCHECK);
610 
611 	switch(meVerAlignState)
612 	{
613 	case SVX_VER_JUSTIFY_TOP:	mpTBVertical->SetItemState(IID_VERT_TOP,		STATE_CHECK);break;
614 	case SVX_VER_JUSTIFY_CENTER:mpTBVertical->SetItemState(IID_VERT_CENTER,	STATE_CHECK);break;
615 	case SVX_VER_JUSTIFY_BOTTOM:	mpTBVertical->SetItemState(IID_VERT_BOTTOM,	STATE_CHECK);break;
616 	default:;
617 	}
618 }
619 
620 //////////////////////////////////////////////////////////////////////////////
621 // namespace close
622 
623 }} // end of namespace ::sc::sidebar
624 
625 //////////////////////////////////////////////////////////////////////////////
626 // eof
627