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 
157     mpTBHorizontal->SetAccessibleRelationLabeledBy(mpTBHorizontal.get());
158 	mpTBVertical->SetAccessibleRelationLabeledBy(mpTBVertical.get());
159 	mpMFLeftIndent->SetAccessibleRelationLabeledBy(mpFTLeftIndent.get());
160 	mpMtrAngle->SetAccessibleRelationLabeledBy(mpFtRotate.get());
161 #ifdef HAS_IA2
162 	mpMtrAngle->SetMpSubEditAccLableBy(mpFtRotate.get());
163 #endif
164 }
165 
166 //////////////////////////////////////////////////////////////////////////////
167 
168 IMPL_LINK( AlignmentPropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
169 {
170 	String sTmp = mpMtrAngle->GetText();
171 
172 	sal_Unicode nChar = sTmp.GetChar( 0 );
173 	if((sTmp.Len()== 1 &&  nChar == '-') ||
174 		(nChar != '-' && ((nChar < '0') || (nChar > '9') ) ))	////modify
175 		return 0;
176 
177 	double dTmp = sTmp.ToDouble();
178 	FormatDegrees(dTmp);
179 
180 	sal_Int64 nTmp = (sal_Int64)dTmp*100;
181 	SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp);
182 
183 	GetBindings()->GetDispatcher()->Execute(
184 		SID_ATTR_ALIGN_DEGREES, SFX_CALLMODE_RECORD, &aAngleItem, 0L );
185 	return 0;
186 }
187 
188 //////////////////////////////////////////////////////////////////////////////
189 
190 IMPL_LINK( AlignmentPropertyPanel, RotationHdl, void *, EMPTYARG )
191 {
192 	sal_Int32 nTmp = mpCtrlDial->GetRotation();
193 	SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp);
194 
195 	GetBindings()->GetDispatcher()->Execute(
196 		SID_ATTR_ALIGN_DEGREES, SFX_CALLMODE_RECORD, &aAngleItem, 0L );
197 
198 	return 0;
199 }
200 
201 //////////////////////////////////////////////////////////////////////////////
202 
203 IMPL_LINK( AlignmentPropertyPanel, ClickStackHdl, void *, EMPTYARG )
204 {
205 	bool bVertical = mpCbStacked->IsChecked() ? true : false;
206 	SfxBoolItem  aStackItem( SID_ATTR_ALIGN_STACKED, bVertical );
207 	GetBindings()->GetDispatcher()->Execute(
208 		SID_ATTR_ALIGN_STACKED, SFX_CALLMODE_RECORD, &aStackItem, 0L );
209 	return 0;
210 }
211 
212 //////////////////////////////////////////////////////////////////////////////
213 
214 IMPL_LINK(AlignmentPropertyPanel, TbxHorAlignSelectHdl, ToolBox*, pToolBox)
215 {
216 	sal_uInt16 nId = pToolBox->GetCurItemId();
217 
218 	if(nId == ID_SUBSTLEFT)
219 	{
220 		if(meHorAlignState != SVX_HOR_JUSTIFY_LEFT)
221 			meHorAlignState = SVX_HOR_JUSTIFY_LEFT;
222 		else
223 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
224 	}
225 	else if( nId == ID_SUBSTCENTER )
226 	{
227 		if(meHorAlignState != SVX_HOR_JUSTIFY_CENTER)
228 			meHorAlignState = SVX_HOR_JUSTIFY_CENTER;
229 		else
230 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
231 	}
232 	else if( nId == ID_SUBSTRIGHT )
233 	{
234 		if(meHorAlignState != SVX_HOR_JUSTIFY_RIGHT)
235 			meHorAlignState = SVX_HOR_JUSTIFY_RIGHT;
236 		else
237 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
238 	}
239 	else if( nId == ID_SUBSTJUSTIFY )
240 	{
241 		if(meHorAlignState != SVX_HOR_JUSTIFY_BLOCK)
242 			meHorAlignState = SVX_HOR_JUSTIFY_BLOCK;
243 		else
244 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
245 	}
246 	SvxHorJustifyItem aHorItem(meHorAlignState, SID_H_ALIGNCELL);
247 	GetBindings()->GetDispatcher()->Execute(SID_H_ALIGNCELL, SFX_CALLMODE_RECORD, &aHorItem, 0L);
248 	UpdateHorAlign();
249 	return 0;
250 }
251 
252 //////////////////////////////////////////////////////////////////////////////
253 
254 IMPL_LINK(AlignmentPropertyPanel, TbxVerAlignSelectHdl, ToolBox*, pToolBox)
255 {
256 	sal_uInt16 nId = pToolBox->GetCurItemId();
257 
258 	//Bold
259 	if(nId == IID_VERT_TOP)
260 	{
261 		if(meVerAlignState != SVX_VER_JUSTIFY_TOP)
262 			meVerAlignState = SVX_VER_JUSTIFY_TOP;
263 		else
264 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
265 	}
266 	else if( nId == IID_VERT_CENTER )
267 	{
268 		if(meVerAlignState != SVX_VER_JUSTIFY_CENTER)
269 			meVerAlignState = SVX_VER_JUSTIFY_CENTER;
270 		else
271 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
272 	}
273 	else if( nId == IID_VERT_BOTTOM )
274 	{
275 		if(meVerAlignState != SVX_VER_JUSTIFY_BOTTOM)
276 			meVerAlignState = SVX_VER_JUSTIFY_BOTTOM;
277 		else
278 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
279 	}
280 	SvxVerJustifyItem aVerItem(meVerAlignState, SID_V_ALIGNCELL);
281 	GetBindings()->GetDispatcher()->Execute(SID_V_ALIGNCELL, SFX_CALLMODE_RECORD, &aVerItem, 0L);
282 	UpdateVerAlign();
283 	return 0;
284 }
285 
286 //////////////////////////////////////////////////////////////////////////////
287 
288 IMPL_LINK(AlignmentPropertyPanel, MFLeftIndentMdyHdl, void*, EMPTYARG)
289 {
290 	mpCBXWrapText->EnableTriState(false);
291 	sal_uInt16 nVal = (sal_uInt16)mpMFLeftIndent->GetValue();
292 	SfxUInt16Item aItem( SID_ATTR_ALIGN_INDENT,  (sal_uInt16)CalcToUnit( nVal,  SFX_MAPUNIT_TWIP ) );
293 
294 	GetBindings()->GetDispatcher()->Execute(SID_ATTR_ALIGN_INDENT, SFX_CALLMODE_RECORD, &aItem, 0L);
295 	return( 0L );
296 }
297 
298 //////////////////////////////////////////////////////////////////////////////
299 
300 IMPL_LINK(AlignmentPropertyPanel, CBOXMergnCellClkHdl, void*, EMPTYARG)
301 {
302 	bool bState = mpCBXMergeCell->IsChecked();
303 
304 	//Modified
305 	//SfxBoolItem aItem( FID_MERGE_TOGGLE , bState);
306 	//GetBindings()->GetDispatcher()->Execute(FID_MERGE_TOGGLE, SFX_CALLMODE_RECORD, &aItem, false, 0L);
307 	if(bState)
308 		GetBindings()->GetDispatcher()->Execute(FID_MERGE_ON, SFX_CALLMODE_RECORD);
309 	else
310 		GetBindings()->GetDispatcher()->Execute(FID_MERGE_OFF, SFX_CALLMODE_RECORD);
311 	GetBindings()->Invalidate(FID_MERGE_TOGGLE,true,false);
312 	//modified end
313 
314 	return 0;
315 }
316 
317 //////////////////////////////////////////////////////////////////////////////
318 
319 IMPL_LINK(AlignmentPropertyPanel, CBOXWrapTextClkHdl, void*, EMPTYARG)
320 {
321 	bool bState = mpCBXWrapText->IsChecked();
322 	SfxBoolItem aItem( SID_ATTR_ALIGN_LINEBREAK , bState);
323 	GetBindings()->GetDispatcher()->Execute(SID_ATTR_ALIGN_LINEBREAK, SFX_CALLMODE_RECORD, &aItem, 0L);
324 	return 0;
325 }
326 
327 //////////////////////////////////////////////////////////////////////////////
328 
329 AlignmentPropertyPanel* AlignmentPropertyPanel::Create (
330     Window* pParent,
331     const cssu::Reference<css::frame::XFrame>& rxFrame,
332     SfxBindings* pBindings)
333 {
334     if (pParent == NULL)
335         throw lang::IllegalArgumentException(A2S("no parent Window given to AlignmentPropertyPanel::Create"), NULL, 0);
336     if ( ! rxFrame.is())
337         throw lang::IllegalArgumentException(A2S("no XFrame given to AlignmentPropertyPanel::Create"), NULL, 1);
338     if (pBindings == NULL)
339         throw lang::IllegalArgumentException(A2S("no SfxBindings given to AlignmentPropertyPanel::Create"), NULL, 2);
340 
341     return new AlignmentPropertyPanel(
342         pParent,
343         rxFrame,
344         pBindings);
345 }
346 
347 //////////////////////////////////////////////////////////////////////////////
348 
349 void AlignmentPropertyPanel::DataChanged(
350     const DataChangedEvent& rEvent)
351 {
352     (void)rEvent;
353 }
354 
355 //////////////////////////////////////////////////////////////////////////////
356 
357 void AlignmentPropertyPanel::HandleContextChange(
358     const ::sfx2::sidebar::EnumContext aContext)
359 {
360     if(maContext == aContext)
361     {
362         // Nothing to do.
363         return;
364     }
365 
366     maContext = aContext;
367 
368 
369 
370     // todo
371 }
372 
373 //////////////////////////////////////////////////////////////////////////////
374 
375 void AlignmentPropertyPanel::NotifyItemUpdate(
376     sal_uInt16 nSID,
377     SfxItemState eState,
378     const SfxPoolItem* pState)
379 {
380 	switch(nSID)
381 	{
382 	case SID_H_ALIGNCELL:
383 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxHorJustifyItem) )
384 		{
385 				const SvxHorJustifyItem* pItem = (const SvxHorJustifyItem*)pState;
386 				meHorAlignState = (SvxCellHorJustify)pItem->GetValue();
387 		}
388 		else
389 		{
390 			meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
391 		}
392 		UpdateHorAlign();
393 		break;
394 	case SID_V_ALIGNCELL:
395 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxVerJustifyItem) )
396 		{
397 				const SvxVerJustifyItem* pItem = (const SvxVerJustifyItem*)pState;
398 				meVerAlignState = (SvxCellVerJustify)pItem->GetValue();
399 		}
400 		else
401 		{
402 			meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
403 		}
404 		UpdateVerAlign();
405 		break;
406 	case SID_ATTR_ALIGN_INDENT:
407 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SfxUInt16Item) )
408 		{
409 				const SfxUInt16Item* pItem = (const SfxUInt16Item*)pState;
410 				sal_uInt16 nVal = pItem->GetValue();
411 				mpMFLeftIndent->SetValue( CalcToPoint(nVal, SFX_MAPUNIT_TWIP, 1) );
412 		}
413 		else
414 		{
415 			mpMFLeftIndent->SetValue(0);
416 			mpMFLeftIndent->SetText(String());
417 		}
418 		break;
419 	case FID_MERGE_TOGGLE:
420 		if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SfxBoolItem) )
421 		{
422 			mpCBXMergeCell->Enable();
423 			const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
424 			bool bVal = pItem->GetValue();
425 			if(bVal)
426 				mpCBXMergeCell->Check(true);
427 			else
428 				mpCBXMergeCell->Check(false);
429 		}
430 		else
431 		{
432 			mpCBXMergeCell->Check(false);
433 			mpCBXMergeCell->Disable();
434 		}
435 		break;
436 
437 	case SID_ATTR_ALIGN_LINEBREAK:
438 		if(eState == SFX_ITEM_DISABLED)
439 		{
440 			mpCBXWrapText->EnableTriState(false);
441 			mpCBXWrapText->Check(false);
442 			mpCBXWrapText->Disable();
443 		}
444 		else
445 		{
446 			mpCBXWrapText->Enable();
447 			if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SfxBoolItem) )
448 			{
449 				mpCBXWrapText->EnableTriState(false);
450 				const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
451 				bool bVal = pItem->GetValue();
452 				if(bVal)
453 					mpCBXWrapText->Check(true);
454 				else
455 					mpCBXWrapText->Check(false);
456 			}
457 			else if(eState == SFX_ITEM_DONTCARE)
458 			{
459 				mpCBXWrapText->EnableTriState(true);
460 				mpCBXWrapText->SetState(STATE_DONTKNOW);
461 			}
462 		}
463 		break;
464 	case SID_ATTR_ALIGN_DEGREES:
465 		if (eState >= SFX_ITEM_AVAILABLE)
466 		{
467 			long nTmp = ((const SfxInt32Item*)pState)->GetValue();
468 			mpMtrAngle->SetValue( nTmp / 100);	//wj
469 			mpCtrlDial->SetRotation( nTmp );
470 			switch(nTmp)
471 			{
472 				case 0:
473 					mpMtrAngle->SelectEntryPos(0);
474 				break;
475 				case 4500:
476 					mpMtrAngle->SelectEntryPos(1);
477 				break;
478 				case 9000:
479 					mpMtrAngle->SelectEntryPos(2);
480 				break;
481 				case 13500:
482 					mpMtrAngle->SelectEntryPos(3);
483 				break;
484 				case 18000:
485 					mpMtrAngle->SelectEntryPos(4);
486 				break;
487 				case 22500:
488 					mpMtrAngle->SelectEntryPos(5);
489 				break;
490 				case 27000:
491 					mpMtrAngle->SelectEntryPos(6);
492 				break;
493 				case 31500:
494 					mpMtrAngle->SelectEntryPos(7);
495 			}
496 		}
497 		else
498 		{
499 			mpMtrAngle->SetText( String() );
500 			mpCtrlDial->SetRotation( 0 );
501 		}
502 		break;
503 	case SID_ATTR_ALIGN_STACKED:
504 		if (eState >= SFX_ITEM_AVAILABLE)
505 		{
506 			mpCbStacked->EnableTriState(false);
507 			const SfxBoolItem* aStackItem = (const SfxBoolItem*)pState;
508 			bool IsChecked = (bool)aStackItem->GetValue();
509 			if(IsChecked)
510 			{
511 				mpCbStacked->Check(IsChecked);
512 				mpFtRotate->Disable();
513 				mpMtrAngle->Disable();
514 				mpCtrlDial->Disable();
515 				mbMultiDisable = true;
516 			}
517 			else
518 			{
519 				mpCbStacked->Check(IsChecked);
520 				mpFtRotate->Enable();
521 				mpMtrAngle->Enable();
522 				mpCtrlDial->Enable();
523 				mbMultiDisable = false;
524 			}
525 		}
526 		else
527 		{
528 			mbMultiDisable = true;
529 			mpFtRotate->Disable();
530 			mpMtrAngle->Disable();
531 			mpCtrlDial->Disable();
532 			mpCbStacked->EnableTriState(true);
533 			mpCbStacked->SetState(STATE_DONTKNOW);
534 		}
535 	}
536 }
537 
538 //////////////////////////////////////////////////////////////////////////////
539 
540 SfxBindings* AlignmentPropertyPanel::GetBindings()
541 {
542     return mpBindings;
543 }
544 
545 //////////////////////////////////////////////////////////////////////////////
546 
547 void AlignmentPropertyPanel::FormatDegrees(double& dTmp)
548 {
549 	while(dTmp<0)
550 		dTmp += 360;
551 	while (dTmp > 359)	//modify
552 		dTmp = 359;
553 }
554 
555 //////////////////////////////////////////////////////////////////////////////
556 
557 void AlignmentPropertyPanel::UpdateHorAlign()
558 {
559 	mpTBHorizontal->SetItemState(ID_SUBSTLEFT,	STATE_NOCHECK);
560 	mpTBHorizontal->SetItemState(ID_SUBSTCENTER,	STATE_NOCHECK);
561 	mpTBHorizontal->SetItemState(ID_SUBSTRIGHT,	STATE_NOCHECK);
562 	mpTBHorizontal->SetItemState(ID_SUBSTJUSTIFY,STATE_NOCHECK);
563 	mpFTLeftIndent->Disable();
564 	mpMFLeftIndent->Disable();
565 	if(meHorAlignState==SVX_HOR_JUSTIFY_REPEAT)
566 	{
567 		mpFtRotate->Disable();
568 		mpCtrlDial->Disable();
569 		mpMtrAngle->Disable();
570 		mpCbStacked->Disable();
571 	}
572 	else
573 	{
574 		if(!mbMultiDisable)
575 		{
576 			mpFtRotate->Enable();
577 			mpCtrlDial->Enable();
578 			mpMtrAngle->Enable();
579 		}
580 		else
581 		{
582 			mpFtRotate->Disable();
583 			mpCtrlDial->Disable();
584 			mpMtrAngle->Disable();
585 		}
586 		mpCbStacked->Enable();
587 	}
588 	switch(meHorAlignState)
589 	{
590 	case SVX_HOR_JUSTIFY_LEFT:
591 		mpTBHorizontal->SetItemState(ID_SUBSTLEFT,	STATE_CHECK);
592 		mpFTLeftIndent->Enable();
593 		mpMFLeftIndent->Enable();
594 		break;
595 	case SVX_HOR_JUSTIFY_CENTER:mpTBHorizontal->SetItemState(ID_SUBSTCENTER,	STATE_CHECK);break;
596 	case SVX_HOR_JUSTIFY_RIGHT:	mpTBHorizontal->SetItemState(ID_SUBSTRIGHT,	STATE_CHECK);break;
597 	case SVX_HOR_JUSTIFY_BLOCK:	mpTBHorizontal->SetItemState(ID_SUBSTJUSTIFY,STATE_CHECK);break;
598 	default:;
599 	}
600 }
601 
602 //////////////////////////////////////////////////////////////////////////////
603 
604 void AlignmentPropertyPanel::UpdateVerAlign()
605 {
606 	mpTBVertical->SetItemState(IID_VERT_TOP,		STATE_NOCHECK);
607 	mpTBVertical->SetItemState(IID_VERT_CENTER,	STATE_NOCHECK);
608 	mpTBVertical->SetItemState(IID_VERT_BOTTOM,	STATE_NOCHECK);
609 
610 	switch(meVerAlignState)
611 	{
612 	case SVX_VER_JUSTIFY_TOP:	mpTBVertical->SetItemState(IID_VERT_TOP,		STATE_CHECK);break;
613 	case SVX_VER_JUSTIFY_CENTER:mpTBVertical->SetItemState(IID_VERT_CENTER,	STATE_CHECK);break;
614 	case SVX_VER_JUSTIFY_BOTTOM:	mpTBVertical->SetItemState(IID_VERT_BOTTOM,	STATE_CHECK);break;
615 	default:;
616 	}
617 }
618 
619 //////////////////////////////////////////////////////////////////////////////
620 // namespace close
621 
622 }} // end of namespace ::sc::sidebar
623 
624 //////////////////////////////////////////////////////////////////////////////
625 // eof
626