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_svx.hxx"
23 #include <svx/sidebar/ColorControl.hxx>
24 
25 #include "ParaPropertyPanel.hxx"
26 #include "ParaPropertyPanel.hrc"
27 
28 #include "ParaLineSpacingPopup.hxx"
29 #include "ParaLineSpacingControl.hxx"
30 #include "ParaBulletsPopup.hxx"
31 #include "ParaBulletsControl.hxx"
32 #include "ParaNumberingPopup.hxx"
33 #include "ParaNumberingControl.hxx"
34 #include <sfx2/sidebar/Theme.hxx>
35 #include <sfx2/sidebar/ResourceDefinitions.hrc>
36 #include <sfx2/sidebar/ControlFactory.hxx>
37 #include <sfx2/sidebar/Tools.hxx>
38 #include <svx/sidebar/PopupContainer.hxx>
39 #include <sfx2/dispatch.hxx>
40 //#include <sfx2/imagemgr.hxx>
41 #include <editeng/colritem.hxx>
42 #include <editeng/brshitem.hxx>
43 #include <editeng/lrspitem.hxx>
44 #include <editeng/ulspitem.hxx>
45 #include <vcl/toolbox.hxx>
46 #include <vcl/fixed.hxx>
47 #include <vcl/svapp.hxx>
48 #include <svx/svxids.hrc>
49 #include <svl/intitem.hxx>
50 #include "svx/dialmgr.hxx"
51 #include <sfx2/objsh.hxx>
52 #include <svtools/unitconv.hxx>
53 #include <boost/bind.hpp>
54 using namespace css;
55 using namespace cssu;
56 using ::sfx2::sidebar::Theme;
57 using ::sfx2::sidebar::ControlFactory;
58 
59 namespace svx {namespace sidebar {
60 #define DEFAULT_VALUE          0
61 #define TOOLBOX_ITEM1          1
62 #define TOOLBOX_ITEM2          2
63 #define TOOLBOX_ITEM3          3
64 #define TOOLBOX_ITEM4          4
65 
66 #define MAX_DURCH             5670
67 
68 #define INDENT_INCREMENT       1
69 #define INDENT_DECREMENT       2
70 #define INDENT_STEP            706
71 #define UL_STEP                58
72 
73 #define NEGATIVE_MAX_VALUE              -9999
74 #define BEGIN_VALUE            28
75 #define MAX_SW                  1709400
76 #define MAX_SC_SD				116220200
77 #define NEGA_MAXVALUE          -10000000
78 
79 #define POS_FT_PARA_SPACE								Point(LogicToPixel(Point(FT_PARA_SPACE_X,FT_PARA_SPACE_Y), MAP_APPFONT))
80 #define POS_FT_PARA_SPACE2								Point(LogicToPixel(Point(FT_PARA_SPACE_X,FT_PARA_SPACE_Y2), MAP_APPFONT))
81 #define POS_TBX_PARA_SPACE_INC_DEC						Point(LogicToPixel(Point(TBX_PARA_SPACE_INC_DEC_X,TBX_PARA_SPACE_INC_DEC_Y), MAP_APPFONT))
82 #define POS_TBX_PARA_SPACE_INC_DEC2						Point(LogicToPixel(Point(TBX_PARA_SPACE_INC_DEC_X,TBX_PARA_SPACE_INC_DEC_Y2), MAP_APPFONT))
83 #define POS_FT_PARA_INDENT								Point(LogicToPixel(Point(FT_PARA_INDENT_X,FT_PARA_INDENT_Y), MAP_APPFONT))
84 #define POS_FT_PARA_INDENT2								Point(LogicToPixel(Point(FT_PARA_INDENT_X,FT_PARA_INDENT_Y2), MAP_APPFONT))
85 #define POS_TBX_PARA_INDENT_INC_DEC						Point(LogicToPixel(Point(TBX_PARA_INDENT_INC_DEC_X,TBX_PARA_INDENT_INC_DEC_Y), MAP_APPFONT))
86 #define POS_TBX_PARA_INDENT_INC_DEC2					Point(LogicToPixel(Point(TBX_PARA_INDENT_INC_DEC_X,TBX_PARA_INDENT_INC_DEC_Y2), MAP_APPFONT))
87 #define POS_MBX_TOP_DIST								Point(LogicToPixel(Point(MBX_TOP_DIST_X,MBX_TOP_DIST_Y), MAP_APPFONT))
88 #define POS_MBX_TOP_DIST2								Point(LogicToPixel(Point(MBX_TOP_DIST_X,MBX_TOP_DIST_Y2), MAP_APPFONT))
89 #define POS_MBX_BOT_DIST								Point(LogicToPixel(Point(MBX_BOT_DIST_X,MBX_BOT_DIST_Y), MAP_APPFONT))
90 #define POS_MBX_BOT_DIST2								Point(LogicToPixel(Point(MBX_BOT_DIST_X,MBX_BOT_DIST_Y2), MAP_APPFONT))
91 #define POS_MBX_LEFT_DIST								Point(LogicToPixel(Point(MBX_LEFT_DIST_X,MBX_LEFT_DIST_Y), MAP_APPFONT))
92 #define POS_MBX_LEFT_DIST2								Point(LogicToPixel(Point(MBX_LEFT_DIST_X,MBX_LEFT_DIST_Y2), MAP_APPFONT))
93 #define POS_MBX_RIGHT_DIST								Point(LogicToPixel(Point(MBX_RIGHT_DIST_X,MBX_RIGHT_DIST_Y), MAP_APPFONT))
94 #define POS_MBX_RIGHT_DIST2								Point(LogicToPixel(Point(MBX_RIGHT_DIST_X,MBX_RIGHT_DIST_Y2), MAP_APPFONT))
95 #define POS_MBX_FLINE_DIST								Point(LogicToPixel(Point(MBX_FLINE_DIST_X,MBX_FLINE_DIST_Y), MAP_APPFONT))
96 #define POS_MBX_FLINE_DIST2								Point(LogicToPixel(Point(MBX_FLINE_DIST_X,MBX_FLINE_DIST_Y2), MAP_APPFONT))
97 #define POS_IMG_SPACE1									Point(LogicToPixel(Point(IMG_SPACE_X,IMG_SPACE1_Y), MAP_APPFONT))
98 #define POS_IMG_SPACE12									Point(LogicToPixel(Point(IMG_SPACE_X,IMG_SPACE1_Y2), MAP_APPFONT))
99 #define POS_IMG_SPACE2									Point(LogicToPixel(Point(IMG_SPACE_X,IMG_SPACE2_Y), MAP_APPFONT))
100 #define POS_IMG_SPACE22									Point(LogicToPixel(Point(IMG_SPACE_X,IMG_SPACE2_Y2), MAP_APPFONT))
101 #define POS_IMG_INDENT1									Point(LogicToPixel(Point(IMG_INDENT_X,IMG_INDENT1_Y), MAP_APPFONT))
102 #define POS_IMG_INDENT12								Point(LogicToPixel(Point(IMG_INDENT_X,IMG_INDENT1_Y2), MAP_APPFONT))
103 #define POS_IMG_INDENT2									Point(LogicToPixel(Point(IMG_INDENT_X,IMG_INDENT2_Y), MAP_APPFONT))
104 #define POS_IMG_INDENT22								Point(LogicToPixel(Point(IMG_INDENT_X,IMG_INDENT2_Y2), MAP_APPFONT))
105 #define POS_IMG_INDENT3									Point(LogicToPixel(Point(IMG_INDENT_X,IMG_INDENT3_Y), MAP_APPFONT))
106 #define POS_IMG_INDENT32								Point(LogicToPixel(Point(IMG_INDENT_X,IMG_INDENT3_Y2), MAP_APPFONT))
107 #define TBX_LINE_SPACE									Point(LogicToPixel(Point(TBX_LINE_SPACE_X,TBX_LINE_SPACE_Y), MAP_APPFONT))
108 #define TBX_LINE_SPACE2									Point(LogicToPixel(Point(TBX_LINE_SPACE_X,TBX_LINE_SPACE_Y2), MAP_APPFONT))
109 
110 #define LINE_POINT1_WHITE								Point(LogicToPixel(Point(LINE_X_WHITE,LINE_TOP_Y), MAP_APPFONT))
111 #define LINE_POINT2_WHITE								Point(LogicToPixel(Point(LINE_X_WHITE,LINE_BOT_Y), MAP_APPFONT))
112 #define LINE_POINT3_WHITE								Point(LogicToPixel(Point(LINE_X_WHITE,LINE_TOP_Y2), MAP_APPFONT))
113 #define LINE_POINT4_WHITE								Point(LogicToPixel(Point(LINE_X_WHITE,LINE_BOT_Y2), MAP_APPFONT))
114 
115 ParaPropertyPanel* ParaPropertyPanel::Create (
116     Window* pParent,
117     const cssu::Reference<css::frame::XFrame>& rxFrame,
118     SfxBindings* pBindings,
119     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
120 {
121     if (pParent == NULL)
122         throw lang::IllegalArgumentException(A2S("no parent Window given to ParaPropertyPanel::Create"), NULL, 0);
123     if ( ! rxFrame.is())
124         throw lang::IllegalArgumentException(A2S("no XFrame given to ParaPropertyPanel::Create"), NULL, 1);
125     if (pBindings == NULL)
126         throw lang::IllegalArgumentException(A2S("no SfxBindings given to ParaPropertyPanel::Create"), NULL, 2);
127 
128     return new ParaPropertyPanel(
129         pParent,
130         rxFrame,
131         pBindings,
132         rxSidebar);
133 }
134 
135 void ParaPropertyPanel::HandleContextChange (
136     const ::sfx2::sidebar::EnumContext aContext)
137 {
138     if (maContext == aContext)
139     {
140         // Nothing to do.
141         return;
142     }
143 
144     maContext = aContext;
145     switch (maContext.GetCombinedContext_DI())
146     {
147         case CombinedEnumContext(Application_Calc, Context_DrawText):
148             maTBxVertAlign->Show();
149             maTBxVertAlignBackground->Show();
150             maTBxBackColor->Hide();
151             maTBxBackColorBackground->Hide();
152             maTBxNumBullet->Hide();
153             maTBxNumBulletBackground->Hide();
154             ReSize(false);
155             maTbxIndent_IncDec->Show();
156             maTbxIndent_IncDecBackground->Show();
157             maTbxProDemote->Hide();
158             maTbxProDemoteBackground->Hide();
159             break;
160 
161         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
162         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
163         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
164             maTBxVertAlign->Hide();
165 		    maTBxVertAlignBackground->Hide();
166             maTBxBackColor->Hide();
167             maTBxBackColorBackground->Hide();
168             maTBxNumBullet->Show();
169             maTBxNumBulletBackground->Show();
170             ReSize(true);
171             maTbxIndent_IncDec->Hide();
172             maTbxIndent_IncDecBackground->Hide();
173             maTbxProDemote->Show();
174             maTbxProDemoteBackground->Show();
175             break;
176 
177         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
178             maTBxVertAlign->Show();
179             maTBxVertAlignBackground->Show();
180             maTBxBackColor->Hide();
181             maTBxBackColorBackground->Hide();
182             maTBxNumBullet->Show();
183             maTBxNumBulletBackground->Show();
184             ReSize(true);
185             maTbxIndent_IncDec->Hide();
186             maTbxIndent_IncDecBackground->Hide();
187             maTbxProDemote->Show();
188             maTbxProDemoteBackground->Show();
189             break;
190 
191         case CombinedEnumContext(Application_DrawImpress, Context_Table):
192             maTBxVertAlign->Show();
193             maTBxVertAlignBackground->Show();
194             maTBxBackColor->Hide();
195             maTBxBackColorBackground->Hide();
196             maTBxNumBullet->Show();
197             maTBxNumBulletBackground->Show();
198             ReSize(true);
199             maTbxIndent_IncDec->Hide();
200             maTbxIndent_IncDecBackground->Hide();
201             maTbxProDemote->Show();
202             maTbxProDemoteBackground->Show();
203             break;
204 
205         case CombinedEnumContext(Application_WriterVariants, Context_Default):
206         case CombinedEnumContext(Application_WriterVariants, Context_Text):
207             maTBxVertAlign->Hide();
208             maTBxVertAlignBackground->Hide();
209             maTBxBackColor->Show();
210             maTBxBackColorBackground->Show();
211             maTBxNumBullet->Show();
212 
213             maTBxNumBulletBackground->Show();
214             ReSize(true);
215             maTbxIndent_IncDec->Show();
216             maTbxIndent_IncDecBackground->Show();
217             maTbxProDemote->Hide();
218             maTbxProDemoteBackground->Hide();
219             break;
220 
221         case CombinedEnumContext(Application_WriterVariants, Context_Table):
222             maTBxVertAlign->Show();
223             maTBxVertAlignBackground->Show();
224             maTBxBackColor->Show();
225             maTBxBackColorBackground->Show();
226             maTBxNumBullet->Show();
227             maTBxNumBulletBackground->Show();
228             ReSize(true);
229             maTbxIndent_IncDec->Show();
230             maTbxIndent_IncDecBackground->Show();
231             maTbxProDemote->Hide();
232             maTbxProDemoteBackground->Hide();
233             break;
234 
235         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
236             maTBxVertAlign->Show();
237             maTBxVertAlignBackground->Show();
238             maTBxBackColor->Hide();
239             maTBxBackColorBackground->Hide();
240             maTBxNumBullet->Hide();
241             maTBxNumBulletBackground->Hide();
242             ReSize(false);
243             maTbxIndent_IncDec->Show();
244             maTbxIndent_IncDecBackground->Show();
245             maTbxProDemote->Hide();
246             maTbxProDemoteBackground->Hide();
247             break;
248 
249         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
250             maTBxVertAlign->Hide();
251             maTBxVertAlignBackground->Hide();
252             maTBxBackColor->Hide();
253             maTBxBackColorBackground->Hide();
254             maTBxNumBullet->Hide();
255             maTBxNumBulletBackground->Hide();
256             ReSize(false);
257             maTbxIndent_IncDec->Show();
258             maTbxIndent_IncDecBackground->Show();
259             maTbxProDemote->Hide();
260             maTbxProDemoteBackground->Hide();
261             break;
262 
263         case CombinedEnumContext(Application_Calc, Context_EditCell):
264         case CombinedEnumContext(Application_Calc, Context_Cell):
265         case CombinedEnumContext(Application_Calc, Context_Pivot):
266         case CombinedEnumContext(Application_DrawImpress, Context_Text):
267         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
268         /*{
269             mpToolBoxScriptSw->Hide();
270             mpToolBoxScript->Show();
271             mpToolBoxSpacing->Show();
272             mpToolBoxHighlight->Hide();
273 
274             Size aSize(PROPERTYPAGE_WIDTH,TEXT_SECTIONPAGE_HEIGHT);
275             aSize = LogicToPixel( aSize,MapMode(MAP_APPFONT) );
276             aSize.setWidth(GetOutputSizePixel().Width());
277             SetSizePixel(aSize);
278         }*/
279             break;
280 
281         default:
282             break;
283     }
284 }
285 
286 SfxBindings* ParaPropertyPanel::GetBindings()
287 {
288     return mpBindings;
289 }
290 
291 
292 
293 
294 void ParaPropertyPanel::DataChanged (const DataChangedEvent& rEvent)
295 {
296     (void)rEvent;
297 }
298 
299 ParaPropertyPanel::~ParaPropertyPanel()
300 {
301 	delete mpLnSPItem;
302 }
303 
304 void ParaPropertyPanel::ReSize(bool bSize)
305 {
306 	if(bSize)
307 	{
308 		//Paragraph spacing
309 		maFTUL->SetPosPixel(POS_FT_PARA_SPACE);
310 		maTbxUL_IncDec->SetPosPixel(POS_TBX_PARA_SPACE_INC_DEC);
311 		maTopDist->SetPosPixel(POS_MBX_TOP_DIST);
312 		maBottomDist->SetPosPixel(POS_MBX_BOT_DIST);
313 		//Indent
314 		maFTIndent->SetPosPixel(POS_FT_PARA_INDENT);
315 		maTbxIndent_IncDec->SetPosPixel(POS_TBX_PARA_INDENT_INC_DEC);
316 		maTbxProDemote->SetPosPixel(POS_TBX_PARA_INDENT_INC_DEC);
317 		maLeftIndent->SetPosPixel(POS_MBX_LEFT_DIST);
318 		maRightIndent->SetPosPixel(POS_MBX_RIGHT_DIST);
319 		maFLineIndent->SetPosPixel(POS_MBX_FLINE_DIST);
320 		//Line spacing
321 		maLineSPTbx->SetPosPixel(TBX_LINE_SPACE);
322 		//image
323 		maFISpace1.SetPosPixel(POS_IMG_SPACE1);
324 		maFISpace2.SetPosPixel(POS_IMG_SPACE2);
325 		maFIndent1.SetPosPixel(POS_IMG_INDENT1);
326 		maFIndent2.SetPosPixel(POS_IMG_INDENT2);
327 		maFIndent3.SetPosPixel(POS_IMG_INDENT3);
328 		Size aSize(GetOutputSizePixel().Width(),PARA_SECTIONPAGE_HEIGHT);
329 		aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
330 		aSize.setWidth(GetOutputSizePixel().Width());
331 		SetSizePixel(aSize);
332 	}
333 	else
334 	{
335 		//Paragraph spacing
336 		maFTUL->SetPosPixel(POS_FT_PARA_SPACE2);
337 		maTbxUL_IncDec->SetPosPixel(POS_TBX_PARA_SPACE_INC_DEC2);
338 		maTopDist->SetPosPixel(POS_MBX_TOP_DIST2);
339 		maBottomDist->SetPosPixel(POS_MBX_BOT_DIST2);
340 		//Indent
341 		maFTIndent->SetPosPixel(POS_FT_PARA_INDENT2);
342 		maTbxIndent_IncDec->SetPosPixel(POS_TBX_PARA_INDENT_INC_DEC2);
343 		maTbxProDemote->SetPosPixel(POS_TBX_PARA_INDENT_INC_DEC2);
344 		maLeftIndent->SetPosPixel(POS_MBX_LEFT_DIST2);
345 		maRightIndent->SetPosPixel(POS_MBX_RIGHT_DIST2);
346 		maFLineIndent->SetPosPixel(POS_MBX_FLINE_DIST2);
347 		//Line spacing
348 		maLineSPTbx->SetPosPixel(TBX_LINE_SPACE2);
349 		//image
350 		maFISpace1.SetPosPixel(POS_IMG_SPACE12);
351 		maFISpace2.SetPosPixel(POS_IMG_SPACE22);
352 		maFIndent1.SetPosPixel(POS_IMG_INDENT12);
353 		maFIndent2.SetPosPixel(POS_IMG_INDENT22);
354 		maFIndent3.SetPosPixel(POS_IMG_INDENT32);
355 		Size aSize(GetOutputSizePixel().Width(),PARA_SECTIONPAGE_HEIGHT_2);
356 		aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
357 		aSize.setWidth(GetOutputSizePixel().Width());
358 		SetSizePixel(aSize);
359 	}
360 
361     if (mxSidebar.is())
362         mxSidebar->requestLayout();
363 }
364 
365 void ParaPropertyPanel::EndSpacingPopupMode (void)
366 {
367     maLineSpacePopup.Hide();
368 }
369 
370 void ParaPropertyPanel::EndBulletsPopupMode (void)
371 {
372 	//i122054, Missed following line, for collapse the bullets popup
373 	maBulletsPopup.Hide();
374 }
375 
376 void ParaPropertyPanel::EndNumberingPopupMode (void)
377 {
378 	//i122054, Missed following line, for collapse the numbering popup
379 	maNumberingPopup.Hide();
380 }
381 
382 
383 void ParaPropertyPanel::InitToolBoxAlign()
384 {
385     const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
386 	maAlignToolBox->SetItemImage(TOOLBOX_ITEM1, maLeftAlignControl.GetIcon(bIsHighContrastModeActive));
387 	maAlignToolBox->SetItemImage(TOOLBOX_ITEM2, maCenterAlignControl.GetIcon(bIsHighContrastModeActive));
388 	maAlignToolBox->SetItemImage(TOOLBOX_ITEM3, maRightAlignControl.GetIcon(bIsHighContrastModeActive));
389 	maAlignToolBox->SetItemImage(TOOLBOX_ITEM4, maJustifyAlignControl.GetIcon(bIsHighContrastModeActive));
390 
391 	Link aLink = LINK( this, ParaPropertyPanel, AlignStyleModifyHdl_Impl );
392 	maAlignToolBox->SetSelectHdl( aLink );
393 	Size aTbxSize (maAlignToolBox->CalcWindowSizePixel());
394 	maAlignToolBox->SetOutputSizePixel( aTbxSize );
395 }
396 
397 void ParaPropertyPanel::InitToolBoxVertAlign()
398 {
399     const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
400     maTBxVertAlign->SetItemImage(IID_VERT_TOP, maVertTop.GetIcon(bIsHighContrastModeActive));
401     maTBxVertAlign->SetItemImage(IID_VERT_CENTER, maVertCenter.GetIcon(bIsHighContrastModeActive));
402     maTBxVertAlign->SetItemImage(IID_VERT_BOTTOM, maVertBottom.GetIcon(bIsHighContrastModeActive));
403 	maTBxVertAlign->SetSelectHdl(LINK(this,ParaPropertyPanel,VertTbxSelectHandler));
404 	Size aTbxSize (maTBxVertAlign->CalcWindowSizePixel());
405 	maTBxVertAlign->SetOutputSizePixel( aTbxSize );
406 }
407 
408 
409 void ParaPropertyPanel::InitToolBoxIndent()
410 {
411 	Link aLink = LINK( this, ParaPropertyPanel, ModifyIndentHdl_Impl );
412 	maLeftIndent->SetModifyHdl( aLink );
413 	maRightIndent->SetModifyHdl( aLink );
414 	maFLineIndent->SetModifyHdl( aLink );
415 
416     maLeftIndent->SetAccessibleName(maLeftIndent->GetQuickHelpText());
417 	maRightIndent->SetAccessibleName(maRightIndent->GetQuickHelpText());
418 	maFLineIndent->SetAccessibleName(maFLineIndent->GetQuickHelpText());
419 
420     const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
421 
422 	if( Application::GetSettings().GetLayoutRTL())
423 	{
424 		maTbxIndent_IncDec->SetItemImage(TOOLBOX_ITEM1, maIncIndentControl.GetIcon(bIsHighContrastModeActive));
425 		maTbxIndent_IncDec->SetItemImage(TOOLBOX_ITEM2, maDecIndentControl.GetIcon(bIsHighContrastModeActive));
426 	}
427 	else
428 	{
429 		maTbxIndent_IncDec->SetItemImage(TOOLBOX_ITEM1, maIncIndentControl.GetIcon(bIsHighContrastModeActive));
430 		maTbxIndent_IncDec->SetItemImage(TOOLBOX_ITEM2, maDecIndentControl.GetIcon(bIsHighContrastModeActive));
431 	}
432 	maTbxIndent_IncDec->SetItemImage(TOOLBOX_ITEM3,maIndHang);
433 	aLink = LINK( this, ParaPropertyPanel, ClickIndent_IncDec_Hdl_Impl );
434 	maTbxIndent_IncDec->SetSelectHdl(aLink);
435 	m_eLRSpaceUnit = maLRSpaceControl.GetCoreMetric();
436 	Size aTbxSize = maTbxIndent_IncDec->CalcWindowSizePixel();
437 	maTbxIndent_IncDec->SetOutputSizePixel( aTbxSize );
438 
439 	if( Application::GetSettings().GetLayoutRTL())
440 	{
441 		maTbxProDemote->SetItemImage(TOOLBOX_ITEM1, maOutLineLeftControl.GetIcon(bIsHighContrastModeActive));
442 		maTbxProDemote->SetItemImage(TOOLBOX_ITEM2, maOutLineRightControl.GetIcon(bIsHighContrastModeActive));
443 	}
444 	else
445 	{
446 		maTbxProDemote->SetItemImage(TOOLBOX_ITEM1, maOutLineLeftControl.GetIcon(bIsHighContrastModeActive));
447 		maTbxProDemote->SetItemImage(TOOLBOX_ITEM2, maOutLineRightControl.GetIcon(bIsHighContrastModeActive));
448 	}
449 	maTbxProDemote->SetItemImage(TOOLBOX_ITEM3,maIndHang);
450 	aLink = LINK( this, ParaPropertyPanel, ClickProDemote_Hdl_Impl );
451 	maTbxProDemote->SetSelectHdl(aLink);
452 	m_eLRSpaceUnit = maLRSpaceControl.GetCoreMetric();
453 	aTbxSize = maTbxProDemote->CalcWindowSizePixel();
454 	maTbxProDemote->SetOutputSizePixel( aTbxSize );
455 }
456 
457 void ParaPropertyPanel::InitToolBoxBGColor()
458 {
459 	mpColorUpdater.reset(new ::svx::ToolboxButtonColorUpdater(SID_BACKGROUND_COLOR, TBI_BACK_COLOR, maTBxBackColor.get(), TBX_UPDATER_MODE_CHAR_COLOR_NEW ));
460 
461 	maTBxBackColor->SetItemImage(TBI_BACK_COLOR, GetDisplayBackground().GetColor().IsDark()? maImgBackColorHigh : maImgBackColor);
462 	maTBxBackColor->SetItemBits( TBI_BACK_COLOR, maTBxBackColor->GetItemBits( TBI_BACK_COLOR ) | TIB_DROPDOWNONLY );
463 
464 	Link aLink = LINK(this, ParaPropertyPanel, ToolBoxBackColorDDHandler);
465 	maTBxBackColor->SetDropdownClickHdl ( aLink );
466 	maTBxBackColor->SetSelectHdl ( aLink );
467 	Size aTbxSize (maTBxBackColor->CalcWindowSizePixel());
468 	maTBxBackColor->SetOutputSizePixel( aTbxSize );
469 }
470 
471 void ParaPropertyPanel::InitToolBoxBulletsNumbering()
472 {
473     const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
474     maTBxNumBullet->SetItemImage(IID_BULLET, maBulletOnOff.GetIcon(bIsHighContrastModeActive));
475     maTBxNumBullet->SetItemImage(IID_NUMBER, maNumberOnOff.GetIcon(bIsHighContrastModeActive));
476 
477 	maTBxNumBullet->SetDropdownClickHdl(LINK(this,ParaPropertyPanel,NumBTbxDDHandler));
478 	maTBxNumBullet->SetSelectHdl(LINK(this,ParaPropertyPanel,NumBTbxSelectHandler));
479 	Size aTbxSize (maTBxNumBullet->CalcWindowSizePixel());
480 	maTBxNumBullet->SetOutputSizePixel( aTbxSize );
481 }
482 void ParaPropertyPanel::InitToolBoxSpacing()
483 {
484 	Link aLink = LINK( this, ParaPropertyPanel, ULSpaceHdl_Impl );
485 	maTopDist->SetModifyHdl(aLink);
486 	maBottomDist->SetModifyHdl( aLink );
487 
488     maTopDist->SetAccessibleName(maTopDist->GetQuickHelpText());
489     maBottomDist->SetAccessibleName(maBottomDist->GetQuickHelpText());
490 
491     // Use a form of image loading that can handle both .uno:<command>
492     // and private:graphirepository... syntax.  This is necessary to
493     // handle the workaround for accessing the images of commands
494     // ParaspaceIncrease and ParaspaceDecrease.
495     // See issue 122446 for more details.
496     maTbxUL_IncDec->SetItemImage(
497         BT_TBX_UL_INC,
498         sfx2::sidebar::Tools::GetImage(maTbxUL_IncDec->GetItemCommand(BT_TBX_UL_INC), mxFrame));
499     maTbxUL_IncDec->SetItemImage(
500         BT_TBX_UL_DEC,
501         sfx2::sidebar::Tools::GetImage(maTbxUL_IncDec->GetItemCommand(BT_TBX_UL_DEC), mxFrame));
502 
503 	aLink = LINK( this, ParaPropertyPanel, ClickUL_IncDec_Hdl_Impl );
504 	maTbxUL_IncDec->SetSelectHdl(aLink);
505 	m_eULSpaceUnit = maULSpaceControl.GetCoreMetric();
506 	Size aTbxSize = maTbxUL_IncDec->CalcWindowSizePixel();
507 	maTbxUL_IncDec->SetOutputSizePixel( aTbxSize );
508 }
509 void ParaPropertyPanel::InitToolBoxLineSpacing()
510 {
511 	Link aLink = LINK( this, ParaPropertyPanel, ClickLineSPDropDownHdl_Impl );
512 	maLineSPTbx->SetDropdownClickHdl( aLink );
513 	maLineSPTbx->SetSelectHdl( aLink );		//support keyinput "ENTER"
514 	maLineSPTbx->SetItemBits( TOOLBOX_ITEM1, maLineSPTbx->GetItemBits( TOOLBOX_ITEM1 ) | TIB_DROPDOWNONLY );
515 	maLineSPTbx->SetItemImage(TOOLBOX_ITEM1,maSpace3);
516 	Size aTbxSize = maLineSPTbx->CalcWindowSizePixel();
517 	maLineSPTbx->SetOutputSizePixel( aTbxSize );
518 }
519 
520 void ParaPropertyPanel::initial()
521 {
522     maFTUL->SetBackground(Wallpaper());
523     maFTIndent->SetBackground(Wallpaper());
524     maFISpace1.SetBackground(Wallpaper());
525     maFISpace2.SetBackground(Wallpaper());
526     maFIndent1.SetBackground(Wallpaper());
527     maFIndent2.SetBackground(Wallpaper());
528     maFIndent3.SetBackground(Wallpaper());
529 
530     maFISpace1.SetImage(maSpace1);
531 	maFISpace2.SetImage(maSpace2);
532 	maFIndent1.SetImage(maIndent3);
533 	maFIndent2.SetImage(maIndent2);
534 	maFIndent3.SetImage(maIndent1);
535 
536 	GetBindings()->Invalidate(SID_ATTR_PARA_ADJUST_LEFT,sal_True,sal_False);
537 	GetBindings()->Invalidate(SID_ATTR_PARA_ADJUST_CENTER,sal_True,sal_False);
538 	GetBindings()->Invalidate(SID_ATTR_PARA_ADJUST_RIGHT,sal_True,sal_False);
539 	GetBindings()->Invalidate(SID_ATTR_PARA_ADJUST_BLOCK,sal_True,sal_False);
540 
541 	//toolbox
542 	InitToolBoxAlign();
543 	InitToolBoxVertAlign();
544 	InitToolBoxIndent();
545 	InitToolBoxBGColor();
546 	InitToolBoxBulletsNumbering();
547 	InitToolBoxSpacing();
548 	InitToolBoxLineSpacing();
549 
550 #ifdef HAS_IA2
551 	maAlignToolBox->SetAccRelationLabeledBy(&maAlignToolBox);
552 	maTBxVertAlign->SetMpSubEditAccLableBy(&maTBxVertAlign);
553 	maTBxNumBullet->SetAccRelationLabeledBy(&maTBxNumBullet);
554 	maTBxBackColor->SetMpSubEditAccLableBy(&maTBxBackColor);
555 	maFTUL->SetAccRelationLabeledBy(&maFTUL);
556 	maTbxUL_IncDec->SetAccRelationLabeledBy(&maTbxUL_IncDec);
557 	maTopDist->SetAccRelationLabeledBy(&maTopDist);
558 	maBottomDist->SetAccRelationLabeledBy(&maBottomDist);
559 	maLineSPTbx->SetAccRelationLabeledBy(&maLineSPTbx);
560 	maFTIndent->SetAccRelationLabeledBy(&maFTIndent);
561 	maTbxIndent_IncDec->SetAccRelationLabeledBy(&maTbxIndent_IncDec);
562 	maTbxProDemote->SetAccRelationLabeledBy(&maTbxProDemote);
563 	maLeftIndent->SetAccRelationLabeledBy(&maLeftIndent);
564 	maRightIndent->SetAccRelationLabeledBy(&maRightIndent);
565 	maFLineIndent->SetAccRelationLabeledBy(&maFLineIndent);
566 	mpColorUpdater->SetAccRelationLabeledBy(&mpColorUpdater);
567 #endif
568 }
569 
570 void ParaPropertyPanel::InitImageList(::boost::scoped_ptr<ToolBox>& rTbx, ImageList& rImglst, ImageList& rImgHlst)
571 {
572 	sal_Bool bHighContrast = GetDisplayBackground().GetColor().IsDark();
573 
574     ImageList& rImgLst = bHighContrast ? rImgHlst : rImglst;
575 
576 	sal_uInt16 nCount = rTbx->GetItemCount();
577     for (sal_uInt16 i = 0; i < nCount; i++)
578     {
579     	sal_uInt16 nId = rTbx->GetItemId(i);
580 		rTbx->SetItemImage( nId, rImgLst.GetImage( nId ) );
581     }
582 }
583 
584 //===========================for Numbering & Bullet================================================
585 
586 
587 
588 IMPL_LINK(ParaPropertyPanel, NumBTbxDDHandler, ToolBox*, pToolBox)
589 {
590 	sal_uInt16 nId = pToolBox->GetCurItemId();
591 
592 	EndTracking();
593 	pToolBox->SetItemDown( nId, sal_True );
594 
595 	if (nId == 1)
596     {
597 		maBulletsPopup.UpdateValueSet();
598 		maBulletsPopup.Show(*pToolBox);
599 	}
600 	else if (nId == 2)
601 	{
602 		maNumberingPopup.UpdateValueSet();
603 		maNumberingPopup.Show(*pToolBox);
604 	}
605 	pToolBox->SetItemDown( nId, sal_False );
606 	return 0;
607 }
608 
609 IMPL_LINK(ParaPropertyPanel, NumBTbxSelectHandler, ToolBox*, pToolBox)
610 {
611 	sal_uInt16 nId = pToolBox->GetCurItemId();
612 	sal_uInt16 nSID = SID_TABLE_VERT_NONE;
613 
614 	EndTracking();
615 	if (nId == 1)
616     {
617 		nSID = FN_NUM_BULLET_ON;
618 	}
619 	else if ( nId == 2)
620 	{
621 		nSID = FN_NUM_NUMBERING_ON;
622 	}
623 	SfxBoolItem aBoolItem(nSID, sal_True);
624 	GetBindings()->GetDispatcher()->Execute(nSID, SFX_CALLMODE_RECORD, &aBoolItem, 0L);
625 
626 	return 0;
627 }
628 
629 
630 //================================for Vertical Alignment========================================
631 
632 
633 
634 IMPL_LINK(ParaPropertyPanel, VertTbxSelectHandler, ToolBox*, pToolBox)
635 {
636 	sal_uInt16 nId = pToolBox->GetCurItemId();
637 	sal_uInt16 nSID = SID_TABLE_VERT_NONE;
638 	EndTracking();
639 	if (nId == 1)
640     {
641         nSID = SID_TABLE_VERT_NONE;
642 		maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_CHECK);
643 		maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_NOCHECK);
644 		maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_NOCHECK);
645 	}
646 	else if (nId == 2)
647 	{
648 		nSID = SID_TABLE_VERT_CENTER;
649 		maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_NOCHECK);
650 		maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_CHECK);
651 		maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_NOCHECK);
652 	}
653 	else if (nId == 3)
654 	{
655 		nSID = SID_TABLE_VERT_BOTTOM;
656 		maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_NOCHECK);
657 		maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_NOCHECK);
658 		maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_CHECK);
659 	}
660 	SfxBoolItem aBoolItem(nSID, sal_True);
661 	GetBindings()->GetDispatcher()->Execute(nSID, SFX_CALLMODE_RECORD, &aBoolItem, 0L);
662 
663 	return 0;
664 }
665 
666 void ParaPropertyPanel::VertStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
667 {
668 	if (eState < SFX_ITEM_DONTCARE)
669 	{
670 		maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_NOCHECK);
671 		maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_NOCHECK);
672 		maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_NOCHECK);
673 		maTBxVertAlign->EnableItem(IID_VERT_TOP, sal_False);
674 		maTBxVertAlign->EnableItem(IID_VERT_CENTER, sal_False);
675 		maTBxVertAlign->EnableItem(IID_VERT_BOTTOM, sal_False);
676 	}
677 	else
678 	{
679 		maTBxVertAlign->EnableItem(IID_VERT_TOP, sal_True);
680 		maTBxVertAlign->EnableItem(IID_VERT_CENTER, sal_True);
681 		maTBxVertAlign->EnableItem(IID_VERT_BOTTOM, sal_True);
682 		if ( (eState >= SFX_ITEM_DEFAULT) && (pState->ISA(SfxBoolItem)))
683 		{
684 			const SfxBoolItem* pItem= (const SfxBoolItem*)pState;
685 			sal_Bool aBool = (sal_Bool)pItem->GetValue();
686 
687 			if (aBool)
688 			{
689 				if (nSID == SID_TABLE_VERT_NONE)
690 				{
691 					maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_CHECK);
692 					maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_NOCHECK);
693 					maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_NOCHECK);
694 				}
695 				else if (nSID == SID_TABLE_VERT_CENTER)
696 				{
697 					maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_NOCHECK);
698 					maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_CHECK);
699 					maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_NOCHECK);
700 				}
701 				else if (nSID == SID_TABLE_VERT_BOTTOM)
702 				{
703 					maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_NOCHECK);
704 					maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_NOCHECK);
705 					maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_CHECK);
706 				}
707 			}
708 			else
709 			{
710 				if (nSID == SID_TABLE_VERT_NONE)
711 				{
712 					maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_NOCHECK);
713 				}
714 				else if (nSID == SID_TABLE_VERT_CENTER)
715 				{
716 					maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_NOCHECK);
717 				}
718 				else if (nSID == SID_TABLE_VERT_BOTTOM)
719 				{
720 					maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_NOCHECK);
721 				}
722 			}
723 		}
724 		else
725 		{
726 			maTBxVertAlign->SetItemState(IID_VERT_TOP, STATE_NOCHECK);
727 			maTBxVertAlign->SetItemState(IID_VERT_CENTER, STATE_NOCHECK);
728 			maTBxVertAlign->SetItemState(IID_VERT_BOTTOM, STATE_NOCHECK);
729 		}
730 	}
731 }
732 //==================================for Background color=====================
733 
734 IMPL_LINK(ParaPropertyPanel, ToolBoxBackColorDDHandler,ToolBox*, pToolBox)
735 {
736 	sal_uInt16 nId = pToolBox->GetCurItemId();
737 	OSL_ASSERT(nId == TBI_BACK_COLOR);
738 	if(nId == TBI_BACK_COLOR)
739 	{
740 		pToolBox->SetItemDown( nId, true );
741 		maBGColorPopup.Show(*pToolBox);
742 		maBGColorPopup.SetCurrentColor(maColor, mbColorAvailable);
743 	}
744 	return 0;
745 }
746 
747 IMPL_LINK( ParaPropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG )
748 {
749 	return 0;
750 }
751 
752 void ParaPropertyPanel::ShowMenu (void)
753 {
754     if (mpBindings != NULL)
755     {
756         SfxDispatcher* pDispatcher = mpBindings->GetDispatcher();
757         if (pDispatcher != NULL)
758             pDispatcher->Execute(SID_PARA_DLG, SFX_CALLMODE_ASYNCHRON);
759     }
760 }
761 
762 void ParaPropertyPanel::ParaBKGStateChanged(sal_uInt16 /* nSID */, SfxItemState eState, const SfxPoolItem* pState)
763 {
764 	if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxColorItem))
765 	{
766 		const SvxColorItem* pItem =  (const SvxColorItem*)pState;
767 		maColor = pItem->GetValue();
768 		mbColorAvailable = sal_True;
769 		mpColorUpdater->Update(maColor);
770 	}
771 	else
772 	{
773 		mbColorAvailable = sal_False;
774 		maColor.SetColor(COL_AUTO);
775 		mpColorUpdater->Update(maColor);
776 	}
777 }
778 
779 void ParaPropertyPanel::SetBGColor (
780     const String& /* rsColorName */,
781     const Color aColor)
782 {
783 	SvxColorItem aColorItem(aColor, SID_BACKGROUND_COLOR);
784 	mpBindings->GetDispatcher()->Execute(SID_BACKGROUND_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
785 	maColor = aColor;
786 }
787 
788 //==================================for Paragraph Alignment=====================
789 IMPL_LINK( ParaPropertyPanel, AlignStyleModifyHdl_Impl, ToolBox*, pBox )
790 {
791 	switch (pBox->GetCurItemId())
792 	{
793 	case BT_SUBSTLEFT:
794 		{
795 			pBox->SetItemState(BT_SUBSTLEFT,STATE_CHECK);
796 			pBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
797 			pBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
798 			pBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
799 			SfxBoolItem aBoolItem( SID_ATTR_PARA_ADJUST_LEFT,  sal_True );
800 			GetBindings()->GetDispatcher()->Execute(SID_ATTR_PARA_ADJUST_LEFT, SFX_CALLMODE_RECORD, &aBoolItem, 0L);
801 		}
802 		break;
803 	case BT_SUBSTCENTER:
804 		{
805 			pBox->SetItemState(BT_SUBSTCENTER,STATE_CHECK);
806 			pBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
807 			pBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
808 			pBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
809 			SfxBoolItem aBoolItem( SID_ATTR_PARA_ADJUST_CENTER, sal_True );
810 			GetBindings()->GetDispatcher()->Execute(SID_ATTR_PARA_ADJUST_CENTER, SFX_CALLMODE_RECORD, &aBoolItem, 0L);
811 		}
812 		break;
813 	case BT_SUBSTRIGHT:
814 		{
815 			pBox->SetItemState(BT_SUBSTRIGHT,STATE_CHECK);
816 			pBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
817 			pBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
818 			pBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
819 			SfxBoolItem aBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, sal_True );
820 			GetBindings()->GetDispatcher()->Execute(SID_ATTR_PARA_ADJUST_RIGHT, SFX_CALLMODE_RECORD, &aBoolItem, 0L);
821 		}
822 		break;
823 	case BT_SUBSTJUSTIFY:
824 		{
825 			pBox->SetItemState(BT_SUBSTJUSTIFY,STATE_CHECK);
826 			pBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
827 			pBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
828 			pBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
829 			SfxBoolItem aBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, sal_True );
830 			GetBindings()->GetDispatcher()->Execute(SID_ATTR_PARA_ADJUST_BLOCK, SFX_CALLMODE_RECORD, &aBoolItem, 0L);
831 		}
832 		break;
833 	}
834 
835 	return 0;
836 }
837 //==================================for Paragraph Indent=====================
838 IMPL_LINK( ParaPropertyPanel, ModifyIndentHdl_Impl, SvxRelativeField*, /* pBox */ )
839 {
840 	SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
841 	aMargin.SetTxtLeft( (const long)GetCoreValue( *maLeftIndent.get(), m_eLRSpaceUnit ) );
842 	aMargin.SetRight( (const long)GetCoreValue( *maRightIndent.get(), m_eLRSpaceUnit ) );
843 	aMargin.SetTxtFirstLineOfst( (const short)GetCoreValue( *maFLineIndent.get(), m_eLRSpaceUnit ) );
844 
845 	GetBindings()->GetDispatcher()->Execute(
846 		SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
847 	return 0;
848 }
849 
850 IMPL_LINK(ParaPropertyPanel, ClickIndent_IncDec_Hdl_Impl, ToolBox *, pControl)
851 {
852     switch (pControl->GetCurItemId())
853     {
854     case INDENT_INCREMENT:
855         {
856             switch (maContext.GetCombinedContext_DI())
857             {
858             case CombinedEnumContext(Application_WriterVariants, Context_Default):
859             case CombinedEnumContext(Application_WriterVariants, Context_Text):
860             case CombinedEnumContext(Application_WriterVariants, Context_Table):
861                 {
862                     SfxBoolItem aMargin( SID_INC_INDENT, sal_True );
863                     GetBindings()->GetDispatcher()->Execute(
864                         SID_INC_INDENT, SFX_CALLMODE_RECORD, &aMargin, 0L);
865                 }
866                 break;
867             default:
868                 {
869                     SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
870 
871                     maTxtLeft += INDENT_STEP;
872                     sal_Int64 nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
873                     nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
874                     aMargin.SetTxtLeft( (const long)nVal );
875                     aMargin.SetRight( (const long)GetCoreValue( *maRightIndent.get(), m_eLRSpaceUnit ) );
876                     aMargin.SetTxtFirstLineOfst( (const short)GetCoreValue( *maFLineIndent.get(), m_eLRSpaceUnit ) );
877 
878                     GetBindings()->GetDispatcher()->Execute(
879                         SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
880                 }
881             }
882         }
883         break;
884     case INDENT_DECREMENT:
885         {
886             switch (maContext.GetCombinedContext_DI())
887             {
888             case CombinedEnumContext(Application_WriterVariants, Context_Default):
889             case CombinedEnumContext(Application_WriterVariants, Context_Text):
890             case CombinedEnumContext(Application_WriterVariants, Context_Table):
891                 {
892                     SfxBoolItem aMargin( SID_DEC_INDENT, sal_True );
893                     GetBindings()->GetDispatcher()->Execute(
894                         SID_DEC_INDENT, SFX_CALLMODE_RECORD, &aMargin, 0L);
895                 }
896                 break;
897             default:
898                 {
899                     if((maTxtLeft - INDENT_STEP) < 0)
900                         maTxtLeft = DEFAULT_VALUE;
901                     else
902                         maTxtLeft -= INDENT_STEP;
903 
904                     SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
905 
906                     sal_Int64 nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
907                     nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
908 
909                     aMargin.SetTxtLeft( (const long)nVal );
910                     aMargin.SetRight( (const long)GetCoreValue( *maRightIndent.get(), m_eLRSpaceUnit ) );
911                     aMargin.SetTxtFirstLineOfst( (const short)GetCoreValue( *maFLineIndent.get(), m_eLRSpaceUnit ) );
912 
913                     GetBindings()->GetDispatcher()->Execute(
914                         SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
915                 }
916             }
917         }
918         break;
919     case ID_HANGING_INDENT:
920         {
921             SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
922             aMargin.SetTxtLeft( (const long)GetCoreValue( *maLeftIndent.get(), m_eLRSpaceUnit ) + (const short)GetCoreValue( *maFLineIndent.get(), m_eLRSpaceUnit ) );
923             aMargin.SetRight( (const long)GetCoreValue( *maRightIndent.get(), m_eLRSpaceUnit ) );
924             aMargin.SetTxtFirstLineOfst( ((const short)GetCoreValue( *maFLineIndent.get(), m_eLRSpaceUnit ))*(-1) );
925 
926             GetBindings()->GetDispatcher()->Execute(
927                 SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
928         }
929         break;
930     }
931     return( 0L );
932 }
933 
934 IMPL_LINK(ParaPropertyPanel, ClickProDemote_Hdl_Impl, ToolBox *, pControl)
935 {
936     switch (pControl->GetCurItemId())
937     {
938         case BT_TBX_INDENT_PROMOTE:
939         {
940             GetBindings()->GetDispatcher()->Execute( SID_OUTLINE_RIGHT, SFX_CALLMODE_RECORD );
941         }
942         break;
943         case BT_TBX_INDENT_DEMOTE:
944         {
945             GetBindings()->GetDispatcher()->Execute( SID_OUTLINE_LEFT, SFX_CALLMODE_RECORD );
946         }
947         break;
948         case SD_HANGING_INDENT:
949         {
950             SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
951             aMargin.SetTxtLeft( (const long)GetCoreValue( *maLeftIndent.get(), m_eLRSpaceUnit ) + (const short)GetCoreValue( *maFLineIndent.get(), m_eLRSpaceUnit ) );
952             aMargin.SetRight( (const long)GetCoreValue( *maRightIndent.get(), m_eLRSpaceUnit ) );
953             aMargin.SetTxtFirstLineOfst( ((const short)GetCoreValue( *maFLineIndent.get(), m_eLRSpaceUnit ))*(-1) );
954 
955             GetBindings()->GetDispatcher()->Execute( SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
956         }
957         break;
958     }
959     return( 0L );
960 }
961 //==================================for Paragraph Line Spacing=====================
962 
963 IMPL_LINK( ParaPropertyPanel, ClickLineSPDropDownHdl_Impl, ToolBox*, pBox )
964 {
965 
966 	const sal_uInt16 nId = pBox->GetCurItemId();
967 	OSL_ASSERT(nId == TOOLBOX_ITEM1);
968 	if(nId == TOOLBOX_ITEM1)
969 	{
970 		pBox->SetItemDown( nId, true );
971 		maLineSpacePopup.Rearrange(meLnSpState,m_eMetricUnit,mpLnSPItem,maContext);
972 		maLineSpacePopup.Show(*pBox);
973 
974 	}
975 	return (0L);
976 }
977 
978 //==================================for Paragraph Spacing=====================
979 IMPL_LINK( ParaPropertyPanel, ULSpaceHdl_Impl, SvxRelativeField*, /* pBox */)
980 {
981 	SvxULSpaceItem aMargin( SID_ATTR_PARA_ULSPACE );
982 	aMargin.SetUpper( (sal_uInt16)GetCoreValue( *maTopDist.get(), m_eULSpaceUnit ) );
983 	aMargin.SetLower( (sal_uInt16)GetCoreValue( *maBottomDist.get(), m_eULSpaceUnit ) );
984 
985 	GetBindings()->GetDispatcher()->Execute(
986 		SID_ATTR_PARA_ULSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
987 	return 0L;
988 }
989 
990 IMPL_LINK(ParaPropertyPanel, ClickUL_IncDec_Hdl_Impl, ToolBox *, pControl)
991 {
992 	switch (pControl->GetCurItemId())
993 		{
994             case BT_TBX_UL_INC:
995 		     {
996 				 SvxULSpaceItem aMargin( SID_ATTR_PARA_ULSPACE );
997 
998 				 maUpper += UL_STEP;
999 				 sal_Int64 nVal = OutputDevice::LogicToLogic( maUpper, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1000 				 nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
1001 				 aMargin.SetUpper( (const sal_uInt16)nVal );
1002 
1003 				 maLower += UL_STEP;
1004 				 nVal = OutputDevice::LogicToLogic( maLower, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1005 				 nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
1006 	             aMargin.SetLower( (const sal_uInt16)nVal );
1007 
1008 				 GetBindings()->GetDispatcher()->Execute(
1009 					 SID_ATTR_PARA_ULSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
1010 			 }
1011 			 break;
1012 		case BT_TBX_UL_DEC:
1013 			{
1014 				 SvxULSpaceItem aMargin( SID_ATTR_PARA_ULSPACE );
1015 
1016 				 if( maUpper >= UL_STEP )
1017 				 {
1018 					maUpper -= UL_STEP;
1019 					sal_Int64	nVal = OutputDevice::LogicToLogic( maUpper, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1020 					nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
1021 					aMargin.SetUpper( (const sal_uInt16)nVal );
1022 				 }
1023 				 else
1024 					aMargin.SetUpper( DEFAULT_VALUE );
1025 				 if( maLower >= UL_STEP )
1026 				 {
1027 					maLower -= UL_STEP;
1028 					sal_Int64	nVal = OutputDevice::LogicToLogic( maLower, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1029 					nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
1030 					aMargin.SetLower( (const sal_uInt16)nVal );
1031 				 }
1032 				 else
1033 					aMargin.SetLower( DEFAULT_VALUE );
1034 
1035 				 GetBindings()->GetDispatcher()->Execute(
1036 					 SID_ATTR_PARA_ULSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
1037 			}
1038 			break;
1039 		}
1040 	return( 0L );
1041 }
1042 
1043 //==================================for Paragraph State change=====================
1044 void ParaPropertyPanel::NotifyItemUpdate(
1045     sal_uInt16 nSID,
1046     SfxItemState eState,
1047     const SfxPoolItem* pState,
1048     const bool bIsEnabled)
1049 {
1050     (void)bIsEnabled;
1051 
1052     switch (nSID)
1053     {
1054     case SID_ATTR_METRIC:
1055         {
1056             m_eMetricUnit = GetCurrentUnit(eState,pState);
1057             if( m_eMetricUnit!=m_last_eMetricUnit )
1058             {
1059                 SetFieldUnit( *maLeftIndent.get(), m_eMetricUnit );
1060                 SetFieldUnit( *maRightIndent.get(), m_eMetricUnit );
1061                 SetFieldUnit( *maFLineIndent.get(), m_eMetricUnit );
1062                 SetFieldUnit( *maTopDist.get(), m_eMetricUnit );
1063                 SetFieldUnit( *maBottomDist.get(), m_eMetricUnit );
1064             }
1065             m_last_eMetricUnit = m_eMetricUnit;
1066         }
1067         break;
1068 
1069     case SID_ATTR_PARA_LRSPACE:
1070         StateChangedIndentImpl( nSID, eState, pState );
1071         break;
1072 
1073     case SID_ATTR_PARA_LINESPACE:
1074         StateChangedLnSPImpl( nSID, eState, pState );
1075         break;
1076 
1077     case SID_ATTR_PARA_ULSPACE:
1078         StateChangedULImpl( nSID, eState, pState );
1079         break;
1080 
1081     case SID_ATTR_PARA_ADJUST_LEFT:
1082     case SID_ATTR_PARA_ADJUST_CENTER:
1083     case SID_ATTR_PARA_ADJUST_RIGHT:
1084     case SID_ATTR_PARA_ADJUST_BLOCK:
1085         StateChangedAlignmentImpl( nSID, eState, pState );
1086         break;
1087 
1088     case SID_OUTLINE_LEFT:
1089     case SID_OUTLINE_RIGHT:
1090         StateChangeOutLineImpl( nSID, eState, pState );
1091         break;
1092 
1093     case SID_INC_INDENT:
1094     case SID_DEC_INDENT:
1095         StateChangeIncDecImpl( nSID, eState, pState );
1096         break;
1097 
1098     case FN_NUM_NUMBERING_ON:
1099     case FN_NUM_BULLET_ON:
1100         StateChangeBulletNumImpl( nSID, eState, pState );
1101         break;
1102 
1103     case FN_BUL_NUM_RULE_INDEX:
1104     case FN_NUM_NUM_RULE_INDEX:
1105         StateChangeBulletNumRuleImpl( nSID, eState, pState );
1106         break;
1107 
1108     case SID_TABLE_VERT_NONE:
1109     case SID_TABLE_VERT_CENTER:
1110     case SID_TABLE_VERT_BOTTOM:
1111         VertStateChanged( nSID, eState, pState);
1112         break;
1113 
1114     case SID_BACKGROUND_COLOR:
1115         ParaBKGStateChanged(nSID, eState, pState);
1116         break;
1117     }
1118 }
1119 
1120 
1121 
1122 
1123 void ParaPropertyPanel::StateChangedAlignmentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1124 {
1125 	if( eState >= SFX_ITEM_AVAILABLE )
1126 	{
1127 		const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
1128 		bool IsChecked = (bool)pItem->GetValue();
1129 		switch (nSID)
1130 		{
1131 		case SID_ATTR_PARA_ADJUST_LEFT:
1132 			{
1133 				if(IsChecked)
1134 				{
1135 					maAlignToolBox->SetItemState(BT_SUBSTLEFT,STATE_CHECK);
1136 					maAlignToolBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
1137 					maAlignToolBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
1138 					maAlignToolBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
1139 				}
1140 				else
1141 					maAlignToolBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
1142 			}
1143 			break;
1144 		case SID_ATTR_PARA_ADJUST_CENTER:
1145 			{
1146 				if(IsChecked)
1147 				{
1148 					maAlignToolBox->SetItemState(BT_SUBSTCENTER,STATE_CHECK);
1149 					maAlignToolBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
1150 					maAlignToolBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
1151 					maAlignToolBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
1152 				}
1153 				else
1154 					maAlignToolBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
1155 			}
1156 			break;
1157 		case SID_ATTR_PARA_ADJUST_RIGHT:
1158 			{
1159 				if(IsChecked)
1160 				{
1161 					maAlignToolBox->SetItemState(BT_SUBSTRIGHT,STATE_CHECK);
1162 					maAlignToolBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
1163 					maAlignToolBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
1164 					maAlignToolBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
1165 				}
1166 				else
1167 					maAlignToolBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
1168 			}
1169 			break;
1170 		case SID_ATTR_PARA_ADJUST_BLOCK:
1171 			{
1172 				if(IsChecked)
1173 				{
1174 					maAlignToolBox->SetItemState(BT_SUBSTJUSTIFY,STATE_CHECK);
1175 					maAlignToolBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
1176 					maAlignToolBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
1177 					maAlignToolBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
1178 				}
1179 				else
1180 					maAlignToolBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
1181 			}
1182 			break;
1183 		}
1184 	}
1185 	else if( eState == SFX_ITEM_DISABLED )
1186 	{
1187 	}
1188 	else if ( eState == SFX_ITEM_DONTCARE )
1189 	{
1190 		switch (nSID)
1191 		{
1192 		case SID_ATTR_PARA_ADJUST_LEFT:
1193 			maAlignToolBox->SetItemState(BT_SUBSTLEFT,STATE_NOCHECK);
1194 			break;
1195 		case SID_ATTR_PARA_ADJUST_CENTER:
1196 			maAlignToolBox->SetItemState(BT_SUBSTCENTER,STATE_NOCHECK);
1197 			break;
1198 		case SID_ATTR_PARA_ADJUST_RIGHT:
1199 			maAlignToolBox->SetItemState(BT_SUBSTRIGHT,STATE_NOCHECK);
1200 			break;
1201 		case SID_ATTR_PARA_ADJUST_BLOCK:
1202 			maAlignToolBox->SetItemState(BT_SUBSTJUSTIFY,STATE_NOCHECK);
1203 			break;
1204 		}
1205 	}
1206 }
1207 
1208 void ParaPropertyPanel::StateChangedIndentImpl( sal_uInt16 /* nSID */, SfxItemState eState, const SfxPoolItem* pState )
1209 {
1210     switch (maContext.GetCombinedContext_DI())
1211     {
1212 
1213     case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
1214     case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
1215     case CombinedEnumContext(Application_Calc, Context_DrawText):
1216         {
1217             maLeftIndent->SetMin( DEFAULT_VALUE );
1218             maRightIndent->SetMin( DEFAULT_VALUE );
1219             maFLineIndent->SetMin( DEFAULT_VALUE );
1220             maTbxIndent_IncDec->Show();
1221             maTbxProDemote->Hide();
1222         }
1223         break;
1224     case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
1225     case CombinedEnumContext(Application_DrawImpress, Context_Draw):
1226     case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
1227     case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
1228     case CombinedEnumContext(Application_DrawImpress, Context_Table):
1229         {
1230             maLeftIndent->SetMin( DEFAULT_VALUE );
1231             maRightIndent->SetMin( DEFAULT_VALUE );
1232             maFLineIndent->SetMin( DEFAULT_VALUE );
1233             maTbxIndent_IncDec->Hide();
1234             maTbxProDemote->Show();
1235         }
1236         break;
1237     case CombinedEnumContext(Application_WriterVariants, Context_Default):
1238     case CombinedEnumContext(Application_WriterVariants, Context_Text):
1239     case CombinedEnumContext(Application_WriterVariants, Context_Table):
1240         {
1241             maLeftIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
1242             maRightIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
1243             maFLineIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
1244             maTbxIndent_IncDec->Show();
1245             maTbxProDemote->Hide();
1246         }
1247         break;
1248     }
1249 
1250     if( pState && eState >= SFX_ITEM_AVAILABLE )
1251     {
1252         SvxLRSpaceItem* pSpace = ( SvxLRSpaceItem*)pState;
1253         maTxtLeft = pSpace->GetTxtLeft();
1254         maTxtLeft = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
1255         maTxtLeft = OutputDevice::LogicToLogic( maTxtLeft, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
1256 
1257         long aTxtRight = pSpace->GetRight();
1258         aTxtRight = OutputDevice::LogicToLogic( aTxtRight, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
1259         aTxtRight = OutputDevice::LogicToLogic( aTxtRight, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
1260 
1261         long aTxtFirstLineOfst = pSpace->GetTxtFirstLineOfst();
1262         aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
1263         aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
1264 
1265         long nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1266         nVal = (long)maLeftIndent->Normalize( (long)nVal );
1267         maLeftIndent->SetValue( nVal, FUNIT_100TH_MM );
1268 
1269         if ( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)
1270              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default)
1271              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table))
1272         {
1273             maFLineIndent->SetMin( nVal*(-1), FUNIT_100TH_MM );
1274         }
1275 
1276         long nrVal = OutputDevice::LogicToLogic( aTxtRight, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1277         nrVal = (long)maRightIndent->Normalize( (long)nrVal );
1278         maRightIndent->SetValue( nrVal, FUNIT_100TH_MM );
1279 
1280         long nfVal = OutputDevice::LogicToLogic( aTxtFirstLineOfst, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1281         nfVal = (long)maFLineIndent->Normalize( (long)nfVal );
1282         maFLineIndent->SetValue( nfVal, FUNIT_100TH_MM );
1283 
1284         switch (maContext.GetCombinedContext_DI())
1285         {
1286         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
1287         case CombinedEnumContext(Application_WriterVariants, Context_Text):
1288         case CombinedEnumContext(Application_WriterVariants, Context_Default):
1289         case CombinedEnumContext(Application_WriterVariants, Context_Table):
1290         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
1291             {
1292                 maLeftIndent->SetMax( MAX_SW - nrVal, FUNIT_100TH_MM );
1293                 maRightIndent->SetMax( MAX_SW - nVal, FUNIT_100TH_MM );
1294                 maFLineIndent->SetMax( MAX_SW - nVal - nrVal, FUNIT_100TH_MM );
1295             }
1296             break;
1297         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
1298         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
1299         case CombinedEnumContext(Application_DrawImpress, Context_Table):
1300         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
1301         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
1302             {
1303                 maLeftIndent->SetMax( MAX_SC_SD - nrVal, FUNIT_100TH_MM );
1304                 maRightIndent->SetMax( MAX_SC_SD - nVal, FUNIT_100TH_MM );
1305                 maFLineIndent->SetMax( MAX_SC_SD - nVal - nrVal, FUNIT_100TH_MM );
1306             }
1307         }
1308 
1309         maTbxIndent_IncDec->Enable();
1310         maTbxIndent_IncDec->EnableItem(ID_HANGING_INDENT, sal_True);
1311         if ( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)
1312              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default)
1313              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table) )
1314         {
1315             maTbxIndent_IncDec->EnableItem(BT_TBX_INDENT_INC, sal_True);
1316             maTbxIndent_IncDec->EnableItem(BT_TBX_INDENT_DEC, sal_True);
1317         }
1318 
1319         maTbxProDemote->EnableItem(SD_HANGING_INDENT, sal_True);
1320     }
1321     else if( eState == SFX_ITEM_DISABLED )
1322     {
1323         maLeftIndent-> Disable();
1324         maRightIndent->Disable();
1325         maFLineIndent->Disable();
1326         maTbxIndent_IncDec->Disable();
1327         if( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)  &&
1328             maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default) &&
1329             maContext.GetCombinedContext_DI() !=  CombinedEnumContext(Application_WriterVariants, Context_Table) )
1330             maTbxIndent_IncDec->Disable();
1331         else
1332             maTbxIndent_IncDec->EnableItem(ID_HANGING_INDENT, sal_False);
1333 
1334         //		maTbxProDemote->Disable();
1335         maTbxProDemote->EnableItem(SD_HANGING_INDENT, sal_False);
1336     }
1337     else
1338     {
1339         maLeftIndent->SetEmptyFieldValue();
1340         maRightIndent->SetEmptyFieldValue();
1341         maFLineIndent->SetEmptyFieldValue();
1342         if( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)  &&
1343             maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default) &&
1344             maContext.GetCombinedContext_DI() !=  CombinedEnumContext(Application_WriterVariants, Context_Table) )
1345             maTbxIndent_IncDec->Disable();
1346         else
1347             maTbxIndent_IncDec->EnableItem(ID_HANGING_INDENT, sal_False);
1348         maTbxProDemote->EnableItem(SD_HANGING_INDENT, sal_False);
1349     }
1350 }
1351 
1352 void ParaPropertyPanel::StateChangedLnSPImpl( sal_uInt16 /* nSID */, SfxItemState eState, const SfxPoolItem* pState )
1353 {
1354 	meLnSpState = eState;
1355 
1356 	if( pState && eState >= SFX_ITEM_AVAILABLE )
1357 	{
1358 		if(mpLnSPItem)
1359 			delete mpLnSPItem;
1360 		mpLnSPItem = ( SvxLineSpacingItem *)pState->Clone();
1361 	}
1362 }
1363 
1364 void ParaPropertyPanel::StateChangedULImpl( sal_uInt16 /* nSID */, SfxItemState eState, const SfxPoolItem* pState )
1365 {
1366 	maTopDist->SetMax( maTopDist->Normalize( MAX_DURCH ), MapToFieldUnit(m_eULSpaceUnit) );
1367 	maBottomDist->SetMax( maBottomDist->Normalize( MAX_DURCH ), MapToFieldUnit(m_eULSpaceUnit) );
1368 
1369 	if( pState && eState >= SFX_ITEM_AVAILABLE )
1370 	{
1371 		SvxULSpaceItem* pOldItem = (SvxULSpaceItem*)pState;
1372 
1373 		maUpper = pOldItem->GetUpper();
1374 		maUpper = OutputDevice::LogicToLogic( maUpper, (MapUnit)m_eULSpaceUnit, MAP_100TH_MM );
1375 		maUpper = OutputDevice::LogicToLogic( maUpper, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
1376 
1377 		maLower = pOldItem->GetLower();
1378 		maLower = OutputDevice::LogicToLogic( maLower, (MapUnit)m_eULSpaceUnit, MAP_100TH_MM );
1379 		maLower = OutputDevice::LogicToLogic( maLower, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
1380 
1381 		sal_Int64 nVal = OutputDevice::LogicToLogic( maUpper, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1382 		nVal = maTopDist->Normalize( nVal );
1383 		maTopDist->SetValue( nVal, FUNIT_100TH_MM );
1384 
1385 		nVal = OutputDevice::LogicToLogic( maLower, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
1386 		nVal = maBottomDist->Normalize( nVal );
1387 		maBottomDist->SetValue( nVal, FUNIT_100TH_MM );
1388 		maTbxUL_IncDec->Enable();
1389 	}
1390 	else if(eState == SFX_ITEM_DISABLED )
1391 	{
1392 		maTopDist->Disable();
1393 		maBottomDist->Disable();
1394 		maTbxUL_IncDec->Disable();
1395 	}
1396 	else
1397 	{
1398 		maTopDist->SetEmptyFieldValue();
1399 		maBottomDist->SetEmptyFieldValue();
1400 		maTbxUL_IncDec->Disable();
1401 	}
1402 }
1403 
1404 void ParaPropertyPanel::StateChangeOutLineImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1405 {
1406     if (nSID==SID_OUTLINE_LEFT)
1407 	{
1408 		if( pState && eState == SFX_ITEM_UNKNOWN )
1409 			mbOutLineLeft = 1;
1410 		else
1411 			mbOutLineLeft = 0;
1412 	}
1413 	if (nSID==SID_OUTLINE_RIGHT)
1414 	{
1415 		if( pState && eState == SFX_ITEM_UNKNOWN )
1416 			mbOutLineRight = 1;
1417 		else
1418 			mbOutLineRight = 0;
1419 	}
1420 	if(mbOutLineLeft)
1421 		maTbxProDemote->EnableItem(BT_TBX_INDENT_DEMOTE, sal_True);
1422 	else
1423 		maTbxProDemote->EnableItem(BT_TBX_INDENT_DEMOTE, sal_False);
1424 
1425 	if(mbOutLineRight)
1426 		maTbxProDemote->EnableItem(BT_TBX_INDENT_PROMOTE, sal_True);
1427 	else
1428 		maTbxProDemote->EnableItem(BT_TBX_INDENT_PROMOTE, sal_False);
1429 
1430 }
1431 
1432 void ParaPropertyPanel::StateChangeIncDecImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1433 {
1434     if ( ( maContext.GetCombinedContext_DI() == CombinedEnumContext(Application_WriterVariants, Context_Text)
1435            || maContext.GetCombinedContext_DI() == CombinedEnumContext(Application_WriterVariants, Context_Default)
1436            || maContext.GetCombinedContext_DI() ==  CombinedEnumContext(Application_WriterVariants, Context_Table) )
1437          && ( nSID == SID_INC_INDENT || nSID == SID_DEC_INDENT ) )
1438     {
1439         // Writer's text shell is the only one which provides reasonable states for Slots SID_INC_INDENT and SID_DEC_INDENT
1440         // - namely SFX_ITEM_UNKNOWN and SFX_ITEM_DISABLED
1441         maTbxIndent_IncDec->EnableItem(
1442             nSID == SID_INC_INDENT ? BT_TBX_INDENT_INC : BT_TBX_INDENT_DEC,
1443             ( pState && eState == SFX_ITEM_UNKNOWN ) ? sal_True : sal_False );
1444     }
1445 }
1446 
1447 
1448 // Add toggle state for numbering and bullet icons
1449 void ParaPropertyPanel::StateChangeBulletNumImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1450 {
1451     if ( (eState >= SFX_ITEM_DEFAULT) && (pState->ISA(SfxBoolItem)) )
1452     {
1453         const SfxBoolItem* pItem= (const SfxBoolItem*)pState;
1454         const sal_Bool aBool = (sal_Bool)pItem->GetValue();
1455         if (nSID==FN_NUM_NUMBERING_ON)
1456         {
1457             maTBxNumBullet->SetItemState(
1458                 IID_NUMBER,
1459                 aBool ? STATE_CHECK : STATE_NOCHECK );
1460         }
1461         else if (nSID==FN_NUM_BULLET_ON)
1462         {
1463             maTBxNumBullet->SetItemState(
1464                 IID_BULLET,
1465                 aBool ? STATE_CHECK : STATE_NOCHECK );
1466         }
1467     }
1468 }
1469 
1470 
1471 void ParaPropertyPanel::StateChangeBulletNumRuleImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1472 {
1473     if ( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxUInt16Item) )
1474     {
1475         sal_uInt16 nValue = (sal_uInt16)0xFFFF;
1476         {
1477             const SfxUInt16Item* pIt = (const SfxUInt16Item*)pState;
1478             if ( pIt )
1479                 nValue = pIt->GetValue();
1480         }
1481 
1482         if ( nSID == FN_BUL_NUM_RULE_INDEX )
1483         {
1484             mnBulletTypeIndex = nValue;
1485         }
1486         else if ( nSID == FN_NUM_NUM_RULE_INDEX )
1487         {
1488             mnNumTypeIndex = nValue;
1489         }
1490     }
1491 }
1492 
1493 
1494 FieldUnit ParaPropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
1495 {
1496 	FieldUnit eUnit = FUNIT_NONE;
1497 
1498 	if ( pState && eState >= SFX_ITEM_DEFAULT )
1499 		eUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
1500 	else
1501 	{
1502 		SfxViewFrame* pFrame = SfxViewFrame::Current();
1503 		SfxObjectShell* pSh = NULL;
1504 		if ( pFrame )
1505 			pSh = pFrame->GetObjectShell();
1506 		if ( pSh )  //the object shell is not always available during reload
1507 		{
1508 			SfxModule* pModule = pSh->GetModule();
1509 			if ( pModule )
1510 			{
1511 				const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
1512 				if ( pItem )
1513 					eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
1514 			}
1515 			else
1516 			{
1517 				DBG_ERRORFILE( "GetModuleFieldUnit(): no module found" );
1518 			}
1519 		}
1520 	}
1521 
1522 	return eUnit;
1523 }
1524 
1525 
1526 PopupControl* ParaPropertyPanel::CreateLineSpacingControl (PopupContainer* pParent)
1527 {
1528 	return new ParaLineSpacingControl(pParent, *this);
1529 }
1530 
1531 PopupControl* ParaPropertyPanel::CreateBulletsPopupControl (PopupContainer* pParent)
1532 {
1533 	return new ParaBulletsControl(pParent, *this);
1534 }
1535 
1536 PopupControl* ParaPropertyPanel::CreateNumberingPopupControl (PopupContainer* pParent)
1537 {
1538 	return new ParaNumberingControl(pParent, *this);
1539 }
1540 
1541 namespace
1542 {
1543     Color GetNoBackgroundColor(void)
1544     {
1545         return COL_TRANSPARENT;
1546     }
1547 } // end of anonymous namespace
1548 
1549 PopupControl* ParaPropertyPanel::CreateBGColorPopupControl (PopupContainer* pParent)
1550 {
1551     const ResId aResId(SVX_RES(STR_NOFILL));
1552 
1553     return new ColorControl(
1554         pParent,
1555         mpBindings,
1556         SVX_RES(RID_POPUPPANEL_PARAPAGE_BACK_COLOR),
1557         SVX_RES(VS_FONT_COLOR),
1558         ::boost::bind(GetNoBackgroundColor),
1559         ::boost::bind(&ParaPropertyPanel::SetBGColor, this, _1,_2),
1560         pParent,
1561         &aResId);
1562 }
1563 
1564 
1565 ParaPropertyPanel::ParaPropertyPanel(Window* pParent,
1566     const cssu::Reference<css::frame::XFrame>& rxFrame,
1567     SfxBindings* pBindings,
1568     const cssu::Reference<css::ui::XSidebar>& rxSidebar)
1569     : Control(pParent, SVX_RES(RID_SIDEBAR_PARA_PANEL)),
1570       maAlignToolBoxBackground(ControlFactory::CreateToolBoxBackground(this)),
1571       maAlignToolBox (ControlFactory::CreateToolBox(maAlignToolBoxBackground.get(),SVX_RES(TBX_HORIZONTALALIGNMENT))),
1572       maTBxVertAlignBackground(ControlFactory::CreateToolBoxBackground(this)),
1573       maTBxVertAlign (ControlFactory::CreateToolBox(maTBxVertAlignBackground.get(),SVX_RES(TBX_VERT_ALIGN))),
1574       maTBxNumBulletBackground(ControlFactory::CreateToolBoxBackground(this)),
1575       maTBxNumBullet (ControlFactory::CreateToolBox(maTBxNumBulletBackground.get(),SVX_RES(TBX_NUM_BULLET))),
1576       maTBxBackColorBackground(ControlFactory::CreateToolBoxBackground(this)),
1577       maTBxBackColor (ControlFactory::CreateToolBox(maTBxBackColorBackground.get(),SVX_RES(TBX_BACK_COLOR))),
1578       maFTUL (new FixedText(this, SVX_RES(FT_SPACING))),
1579       maTbxUL_IncDecBackground(ControlFactory::CreateToolBoxBackground(this)),
1580       maTbxUL_IncDec (ControlFactory::CreateToolBox(maTbxUL_IncDecBackground.get(),SVX_RES(TBX_UL_INC_DEC))),
1581       maFTIndent (new FixedText(this, SVX_RES(FT_INDENT))),
1582       maTbxIndent_IncDecBackground(ControlFactory::CreateToolBoxBackground(this)),
1583       maTbxIndent_IncDec (ControlFactory::CreateToolBox(maTbxIndent_IncDecBackground.get(),SVX_RES(TBX_INDENT_INC_DEC))),
1584 
1585       maTopDist (new SvxRelativeField(this, SVX_RES(MF_ABOVE_PARASPACING))),
1586       maLeftIndent (new SvxRelativeField(this, SVX_RES(MF_BEFORE_INDENT))),
1587 
1588       maBottomDist (new SvxRelativeField(this, SVX_RES(MF_BELOW_PARASPACING))),
1589       maRightIndent (new SvxRelativeField(this, SVX_RES(MF_AFTER_INDENT))),
1590 
1591       maLineSPTbxBackground(ControlFactory::CreateToolBoxBackground(this)),
1592       maLineSPTbx (ControlFactory::CreateToolBox(maLineSPTbxBackground.get(),SVX_RES(TBX_LINESP))),
1593       maFLineIndent (new SvxRelativeField(this, SVX_RES(MF_FL_INDENT))),
1594 
1595       maTbxProDemoteBackground(ControlFactory::CreateToolBoxBackground(this)),
1596       maTbxProDemote (ControlFactory::CreateToolBox(maTbxProDemoteBackground.get(),SVX_RES(TBX_INDENT_PRO_DEMOTE))),
1597       mpColorUpdater (),
1598       maFISpace1 ( this, SVX_RES( FI_SPACE1)),
1599       maFISpace2 ( this, SVX_RES( FI_SPACE2)),
1600       maFIndent1 ( this, SVX_RES( FI_INDENT1)),
1601       maFIndent2 ( this, SVX_RES( FI_INDENT2)),
1602       maFIndent3 ( this, SVX_RES( FI_INDENT3)),
1603       maSpace1 (SVX_RES(IMG_SPACE1)),
1604       maSpace2 (SVX_RES(IMG_SPACE2)),
1605       maSpace3 (SVX_RES(IMG_SPACE3)),
1606       maIndent1 (SVX_RES(IMG_INDENT1)),
1607       maIndent2 (SVX_RES(IMG_INDENT2)),
1608       maIndent3 (SVX_RES(IMG_INDENT3)),
1609       maIndHang (SVX_RES(IMG_INDENT_HANG)),
1610       maNumBImageList (SVX_RES(IL_NUM_BULLET)),
1611       maNumBImageListH (SVX_RES(ILH_NUM_BULLET)),
1612       maNumBImageListRTL (SVX_RES(IL_NUM_BULLET_RTL)),
1613       maImgBackColorHigh (SVX_RES(IMG_BACK_COLOR_H)),
1614       maImgBackColor (SVX_RES(IMG_BACK_COLOR)),
1615       maTxtLeft (0),
1616       mpLnSPItem (NULL),
1617       meLnSpState (SFX_ITEM_DONTCARE),
1618       mbOutLineLeft (false),
1619       mbOutLineRight (false),
1620       maUpper (0),
1621       maLower (0),
1622       mnBulletTypeIndex ((sal_uInt16)0xFFFF),
1623       mnNumTypeIndex ((sal_uInt16)0xFFFF),
1624       maColor (COL_AUTO),
1625       mbColorAvailable (true),
1626       m_eLRSpaceUnit(),
1627       m_eULSpaceUnit(),
1628       maLeftAlignControl(SID_ATTR_PARA_ADJUST_LEFT, *pBindings, *this, A2S("LeftPara"), rxFrame),
1629       maCenterAlignControl(SID_ATTR_PARA_ADJUST_CENTER, *pBindings, *this, A2S("CenterPara"), rxFrame),
1630       maRightAlignControl(SID_ATTR_PARA_ADJUST_RIGHT, *pBindings, *this, A2S("RightPara"), rxFrame),
1631       maJustifyAlignControl(SID_ATTR_PARA_ADJUST_BLOCK, *pBindings, *this, A2S("JustifyPara"), rxFrame),
1632       maLRSpaceControl (SID_ATTR_PARA_LRSPACE,*pBindings,*this),
1633       maLNSpaceControl (SID_ATTR_PARA_LINESPACE, *pBindings,*this),
1634       maULSpaceControl (SID_ATTR_PARA_ULSPACE, *pBindings,*this),
1635       maOutLineLeftControl(SID_OUTLINE_LEFT, *pBindings, *this, A2S("OutlineRight"), rxFrame),
1636       maOutLineRightControl(SID_OUTLINE_RIGHT, *pBindings, *this, A2S("OutlineLeft"), rxFrame),
1637       maDecIndentControl(SID_DEC_INDENT, *pBindings,*this, A2S("DecrementIndent"), rxFrame),
1638       maIncIndentControl(SID_INC_INDENT, *pBindings,*this, A2S("IncrementIndent"), rxFrame),
1639       maVertTop (SID_TABLE_VERT_NONE, *pBindings, *this, A2S("CellVertTop"), rxFrame),
1640       maVertCenter (SID_TABLE_VERT_CENTER, *pBindings,*this, A2S("CellVertCenter"), rxFrame),
1641       maVertBottom (SID_TABLE_VERT_BOTTOM,*pBindings,*this, A2S("CellVertBottom"), rxFrame),
1642       maBulletOnOff(FN_NUM_BULLET_ON, *pBindings, *this, A2S("DefaultBullet"), rxFrame),
1643       maNumberOnOff(FN_NUM_NUMBERING_ON, *pBindings, *this, A2S("DefaultNumbering"), rxFrame),
1644       maBackColorControl (SID_BACKGROUND_COLOR,	*pBindings,*this),
1645       m_aMetricCtl (SID_ATTR_METRIC, *pBindings,*this),
1646       maBulletNumRuleIndex (FN_BUL_NUM_RULE_INDEX, *pBindings,*this),
1647       maNumNumRuleIndex (FN_NUM_NUM_RULE_INDEX, *pBindings,*this),
1648       mxFrame(rxFrame),
1649       maContext(),
1650       mpBindings(pBindings),
1651       maLineSpacePopup(this, ::boost::bind(&ParaPropertyPanel::CreateLineSpacingControl, this, _1)),
1652       maBulletsPopup(this, ::boost::bind(&ParaPropertyPanel::CreateBulletsPopupControl, this, _1)),
1653       maNumberingPopup(this, ::boost::bind(&ParaPropertyPanel::CreateNumberingPopupControl, this, _1)),
1654       maBGColorPopup(this, ::boost::bind(&ParaPropertyPanel::CreateBGColorPopupControl, this, _1)),
1655       mxSidebar(rxSidebar)
1656 {
1657 	initial();
1658 	FreeResource();
1659 }
1660 
1661 } } // end of namespace svx::sidebar
1662