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