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