Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * This file incorporates work covered by the following license notice:
9 : *
10 : * Licensed to the Apache Software Foundation (ASF) under one or more
11 : * contributor license agreements. See the NOTICE file distributed
12 : * with this work for additional information regarding copyright
13 : * ownership. The ASF licenses this file to you under the Apache
14 : * License, Version 2.0 (the "License"); you may not use this file
15 : * except in compliance with the License. You may obtain a copy of
16 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 : */
18 : #include <svx/sidebar/ColorControl.hxx>
19 :
20 : #include "ParaPropertyPanel.hxx"
21 : #include "ParaPropertyPanel.hrc"
22 :
23 : #include "ParaLineSpacingPopup.hxx"
24 : #include "ParaLineSpacingControl.hxx"
25 : #include "ParaBulletsPopup.hxx"
26 : #include "ParaBulletsControl.hxx"
27 : #include "ParaNumberingPopup.hxx"
28 : #include "ParaNumberingControl.hxx"
29 : #include <sfx2/sidebar/ResourceDefinitions.hrc>
30 : #include <sfx2/sidebar/Tools.hxx>
31 : #include <svx/sidebar/PopupContainer.hxx>
32 : #include <sfx2/dispatch.hxx>
33 : #include <editeng/colritem.hxx>
34 : #include <editeng/brushitem.hxx>
35 : #include <editeng/lrspitem.hxx>
36 : #include <editeng/ulspitem.hxx>
37 : #include <vcl/toolbox.hxx>
38 : #include <vcl/fixed.hxx>
39 : #include <vcl/svapp.hxx>
40 : #include <vcl/settings.hxx>
41 : #include <svx/svxids.hrc>
42 : #include <svl/intitem.hxx>
43 : #include "svx/dialmgr.hxx"
44 : #include <sfx2/objsh.hxx>
45 : #include <svtools/unitconv.hxx>
46 : #include <boost/bind.hpp>
47 : using namespace css;
48 : using namespace cssu;
49 :
50 : const char UNO_DEFAULTBULLET[] = ".uno:DefaultBullet";
51 : const char UNO_DEFAULTNUMBERING[] = ".uno:DefaultNumbering";
52 :
53 : const char UNO_PARABACKCOLOR[] = ".uno:BackgroundColor";
54 :
55 : const char UNO_INCREMENTINDENT[] = ".uno:IncrementIndent";
56 : const char UNO_DECREMENTINDENT[] = ".uno:DecrementIndent";
57 : const char UNO_HANGINGINDENT[] = ".uno:HangingIndent";
58 :
59 : const char UNO_PROMOTE[] = ".uno:Promote";
60 : const char UNO_DEMOTE[] = ".uno:Demote";
61 : const char UNO_HANGINGINDENT2[] = ".uno:HangingIndent2";
62 :
63 : const char UNO_LINESPACING[] = ".uno:LineSpacing";
64 :
65 : const char UNO_PARASPACEINC[] = ".uno:ParaspaceIncrease";
66 : const char UNO_PARASPACEDEC[] = ".uno:ParaspaceDecrease";
67 :
68 : namespace svx {namespace sidebar {
69 : #define DEFAULT_VALUE 0
70 :
71 : #define MAX_DURCH 5670
72 :
73 : #define INDENT_STEP 706
74 : #define UL_STEP 58
75 :
76 : #define MAX_SW 1709400
77 : #define MAX_SC_SD 116220200
78 : #define NEGA_MAXVALUE -10000000
79 :
80 0 : ParaPropertyPanel* ParaPropertyPanel::Create (
81 : Window* pParent,
82 : const cssu::Reference<css::frame::XFrame>& rxFrame,
83 : SfxBindings* pBindings,
84 : const cssu::Reference<css::ui::XSidebar>& rxSidebar)
85 : {
86 0 : if (pParent == NULL)
87 0 : throw lang::IllegalArgumentException("no parent Window given to ParaPropertyPanel::Create", NULL, 0);
88 0 : if ( ! rxFrame.is())
89 0 : throw lang::IllegalArgumentException("no XFrame given to ParaPropertyPanel::Create", NULL, 1);
90 0 : if (pBindings == NULL)
91 0 : throw lang::IllegalArgumentException("no SfxBindings given to ParaPropertyPanel::Create", NULL, 2);
92 :
93 : return new ParaPropertyPanel(
94 : pParent,
95 : rxFrame,
96 : pBindings,
97 0 : rxSidebar);
98 : }
99 :
100 0 : void ParaPropertyPanel::HandleContextChange (
101 : const ::sfx2::sidebar::EnumContext aContext)
102 : {
103 0 : if (maContext == aContext)
104 : {
105 : // Nothing to do.
106 0 : return;
107 : }
108 :
109 0 : maContext = aContext;
110 0 : switch (maContext.GetCombinedContext_DI())
111 : {
112 : case CombinedEnumContext(Application_Calc, Context_DrawText):
113 0 : mpTBxVertAlign->Show();
114 0 : mpTBxBackColor->Hide();
115 0 : mpTBxNumBullet->Hide();
116 0 : ReSize(false);
117 0 : mpTbxIndent_IncDec->Show();
118 0 : mpTbxProDemote->Hide();
119 0 : break;
120 :
121 : case CombinedEnumContext(Application_DrawImpress, Context_Draw):
122 : case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
123 : case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
124 0 : mpTBxVertAlign->Hide();
125 0 : mpTBxBackColor->Hide();
126 0 : mpTBxNumBullet->Show();
127 0 : ReSize(true);
128 0 : mpTbxIndent_IncDec->Hide();
129 0 : mpTbxProDemote->Show();
130 0 : break;
131 :
132 : case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
133 0 : mpTBxVertAlign->Show();
134 0 : mpTBxBackColor->Hide();
135 0 : mpTBxNumBullet->Show();
136 0 : ReSize(true);
137 0 : mpTbxIndent_IncDec->Hide();
138 0 : mpTbxProDemote->Show();
139 0 : break;
140 :
141 : case CombinedEnumContext(Application_DrawImpress, Context_Table):
142 0 : mpTBxVertAlign->Show();
143 0 : mpTBxBackColor->Hide();
144 0 : mpTBxNumBullet->Show();
145 0 : ReSize(true);
146 0 : mpTbxIndent_IncDec->Hide();
147 0 : mpTbxProDemote->Show();
148 0 : break;
149 :
150 : case CombinedEnumContext(Application_WriterVariants, Context_Default):
151 : case CombinedEnumContext(Application_WriterVariants, Context_Text):
152 0 : mpTBxVertAlign->Hide();
153 0 : mpTBxBackColor->Show();
154 0 : mpTBxNumBullet->Show();
155 :
156 0 : ReSize(true);
157 0 : mpTbxIndent_IncDec->Show();
158 0 : mpTbxProDemote->Hide();
159 0 : break;
160 :
161 : case CombinedEnumContext(Application_WriterVariants, Context_Table):
162 0 : mpTBxVertAlign->Show();
163 0 : mpTBxBackColor->Show();
164 0 : mpTBxNumBullet->Show();
165 0 : ReSize(true);
166 0 : mpTbxIndent_IncDec->Show();
167 0 : mpTbxProDemote->Hide();
168 0 : break;
169 :
170 : case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
171 0 : mpTBxVertAlign->Show();
172 0 : mpTBxBackColor->Hide();
173 0 : mpTBxNumBullet->Hide();
174 0 : ReSize(false);
175 0 : mpTbxIndent_IncDec->Show();
176 0 : mpTbxProDemote->Hide();
177 0 : break;
178 :
179 : case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
180 0 : mpTBxVertAlign->Hide();
181 0 : mpTBxBackColor->Hide();
182 0 : mpTBxNumBullet->Hide();
183 0 : ReSize(false);
184 0 : mpTbxIndent_IncDec->Show();
185 0 : mpTbxProDemote->Hide();
186 0 : break;
187 :
188 : case CombinedEnumContext(Application_Calc, Context_EditCell):
189 : case CombinedEnumContext(Application_Calc, Context_Cell):
190 : case CombinedEnumContext(Application_Calc, Context_Pivot):
191 : case CombinedEnumContext(Application_DrawImpress, Context_Text):
192 : case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
193 : /*{
194 : mpToolBoxScriptSw->Hide();
195 : mpToolBoxScript->Show();
196 : mpToolBoxSpacing->Show();
197 : mpToolBoxHighlight->Hide();
198 :
199 : Size aSize(PROPERTYPAGE_WIDTH,TEXT_SECTIONPAGE_HEIGHT);
200 : aSize = LogicToPixel( aSize,MapMode(MAP_APPFONT) );
201 : aSize.setWidth(GetOutputSizePixel().Width());
202 : SetSizePixel(aSize);
203 : }*/
204 0 : break;
205 :
206 : default:
207 0 : break;
208 : }
209 : }
210 :
211 0 : SfxBindings* ParaPropertyPanel::GetBindings()
212 : {
213 0 : return mpBindings;
214 : }
215 :
216 :
217 :
218 :
219 0 : void ParaPropertyPanel::DataChanged (const DataChangedEvent& rEvent)
220 : {
221 : (void)rEvent;
222 0 : }
223 :
224 0 : ParaPropertyPanel::~ParaPropertyPanel()
225 : {
226 0 : delete mpLnSPItem;
227 0 : }
228 :
229 0 : void ParaPropertyPanel::ReSize(bool /* bSize */)
230 : {
231 0 : if (mxSidebar.is())
232 0 : mxSidebar->requestLayout();
233 0 : }
234 :
235 0 : void ParaPropertyPanel::EndSpacingPopupMode (void)
236 : {
237 0 : maLineSpacePopup.Hide();
238 0 : }
239 :
240 0 : void ParaPropertyPanel::EndBulletsPopupMode (void)
241 : {
242 : //i122054, Missed following line, for collapse the bullets popup
243 0 : maBulletsPopup.Hide();
244 0 : }
245 :
246 0 : void ParaPropertyPanel::EndNumberingPopupMode (void)
247 : {
248 : //i122054, Missed following line, for collapse the numbering popup
249 0 : maNumberingPopup.Hide();
250 0 : }
251 :
252 :
253 0 : void ParaPropertyPanel::InitToolBoxIndent()
254 : {
255 0 : Link aLink = LINK( this, ParaPropertyPanel, ModifyIndentHdl_Impl );
256 0 : mpLeftIndent->SetModifyHdl( aLink );
257 0 : mpRightIndent->SetModifyHdl( aLink );
258 0 : mpFLineIndent->SetModifyHdl( aLink );
259 :
260 0 : mpLeftIndent->SetAccessibleName(mpLeftIndent->GetQuickHelpText());
261 0 : mpRightIndent->SetAccessibleName(mpRightIndent->GetQuickHelpText());
262 0 : mpFLineIndent->SetAccessibleName(mpFLineIndent->GetQuickHelpText());
263 :
264 0 : const sal_uInt16 nIdIncrement = mpTbxIndent_IncDec->GetItemId(UNO_INCREMENTINDENT);
265 0 : const sal_uInt16 nIdDecrement = mpTbxIndent_IncDec->GetItemId(UNO_DECREMENTINDENT);
266 0 : const sal_uInt16 nIdHanging = mpTbxIndent_IncDec->GetItemId(UNO_HANGINGINDENT);
267 :
268 0 : if( Application::GetSettings().GetLayoutRTL())
269 : {
270 0 : mpTbxIndent_IncDec->SetItemImage(nIdIncrement, maIncIndentControl.GetIcon());
271 0 : mpTbxIndent_IncDec->SetItemImage(nIdDecrement, maDecIndentControl.GetIcon());
272 : }
273 : else
274 : {
275 0 : mpTbxIndent_IncDec->SetItemImage(nIdIncrement, maIncIndentControl.GetIcon());
276 0 : mpTbxIndent_IncDec->SetItemImage(nIdDecrement, maDecIndentControl.GetIcon());
277 : }
278 0 : mpTbxIndent_IncDec->SetItemImage(nIdHanging, maIndHang);
279 :
280 0 : aLink = LINK( this, ParaPropertyPanel, ClickIndent_IncDec_Hdl_Impl );
281 0 : mpTbxIndent_IncDec->SetSelectHdl(aLink);
282 0 : m_eLRSpaceUnit = maLRSpaceControl.GetCoreMetric();
283 :
284 0 : const sal_uInt16 nIdPromote = mpTbxProDemote->GetItemId(UNO_PROMOTE);
285 0 : const sal_uInt16 nIdDemote = mpTbxProDemote->GetItemId(UNO_DEMOTE);
286 0 : const sal_uInt16 nIdHanging2 = mpTbxProDemote->GetItemId(UNO_HANGINGINDENT2);
287 0 : if( Application::GetSettings().GetLayoutRTL())
288 : {
289 0 : mpTbxProDemote->SetItemImage(nIdPromote, maOutLineLeftControl.GetIcon());
290 0 : mpTbxProDemote->SetItemImage(nIdDemote, maOutLineRightControl.GetIcon());
291 : }
292 : else
293 : {
294 0 : mpTbxProDemote->SetItemImage(nIdPromote, maOutLineLeftControl.GetIcon());
295 0 : mpTbxProDemote->SetItemImage(nIdDemote, maOutLineRightControl.GetIcon());
296 : }
297 0 : mpTbxProDemote->SetItemImage(nIdHanging2, maIndHang);
298 0 : aLink = LINK( this, ParaPropertyPanel, ClickProDemote_Hdl_Impl );
299 0 : mpTbxProDemote->SetSelectHdl(aLink);
300 0 : m_eLRSpaceUnit = maLRSpaceControl.GetCoreMetric();
301 0 : }
302 :
303 0 : void ParaPropertyPanel::InitToolBoxBGColor()
304 : {
305 0 : const sal_uInt16 nIdBackColor = mpTBxBackColor->GetItemId(UNO_PARABACKCOLOR);
306 :
307 0 : mpColorUpdater.reset(new ::svx::ToolboxButtonColorUpdater(0 /* not defined, default is transparent */, nIdBackColor, mpTBxBackColor));
308 0 : mpTBxBackColor->SetItemBits( nIdBackColor, mpTBxBackColor->GetItemBits( nIdBackColor ) | TIB_DROPDOWNONLY );
309 :
310 0 : Link aLink = LINK(this, ParaPropertyPanel, ToolBoxBackColorDDHandler);
311 0 : mpTBxBackColor->SetDropdownClickHdl ( aLink );
312 0 : mpTBxBackColor->SetSelectHdl ( aLink );
313 0 : }
314 :
315 0 : void ParaPropertyPanel::InitToolBoxBulletsNumbering()
316 : {
317 0 : const sal_uInt16 nIdBullet = mpTBxNumBullet->GetItemId(UNO_DEFAULTBULLET);
318 0 : const sal_uInt16 nIdNumber = mpTBxNumBullet->GetItemId(UNO_DEFAULTNUMBERING);
319 :
320 0 : mpTBxNumBullet->SetItemImage(nIdBullet, maBulletOnOff.GetIcon());
321 0 : mpTBxNumBullet->SetItemImage(nIdNumber, maNumberOnOff.GetIcon());
322 :
323 0 : mpTBxNumBullet->SetDropdownClickHdl(LINK(this,ParaPropertyPanel,NumBTbxDDHandler));
324 0 : mpTBxNumBullet->SetSelectHdl(LINK(this,ParaPropertyPanel,NumBTbxSelectHandler));
325 0 : }
326 0 : void ParaPropertyPanel::InitToolBoxSpacing()
327 : {
328 0 : Link aLink = LINK( this, ParaPropertyPanel, ULSpaceHdl_Impl );
329 0 : mpTopDist->SetModifyHdl(aLink);
330 0 : mpBottomDist->SetModifyHdl( aLink );
331 :
332 0 : mpTopDist->SetAccessibleName(mpTopDist->GetQuickHelpText());
333 0 : mpBottomDist->SetAccessibleName(mpBottomDist->GetQuickHelpText());
334 :
335 : // Use a form of image loading that can handle both .uno:<command>
336 : // and private:graphirepository... syntax. This is necessary to
337 : // handle the workaround for accessing the images of commands
338 : // ParaspaceIncrease and ParaspaceDecrease.
339 : // See issue 122446 for more details.
340 :
341 0 : const sal_uInt16 nIdParaSpaceInc = mpTbxUL_IncDec->GetItemId(UNO_PARASPACEINC);
342 0 : const sal_uInt16 nIdParaSpaceDec = mpTbxUL_IncDec->GetItemId(UNO_PARASPACEDEC);
343 : mpTbxUL_IncDec->SetItemImage(
344 : nIdParaSpaceInc,
345 0 : sfx2::sidebar::Tools::GetImage("private:graphicrepository/cmd/sc_paraspaceincrease.png" /* i#122446 */, mxFrame));
346 : mpTbxUL_IncDec->SetItemImage(
347 : nIdParaSpaceDec,
348 0 : sfx2::sidebar::Tools::GetImage("private:graphicrepository/cmd/sc_paraspacedecrease.png" /* i#122446 */, mxFrame));
349 :
350 0 : aLink = LINK( this, ParaPropertyPanel, ClickUL_IncDec_Hdl_Impl );
351 0 : mpTbxUL_IncDec->SetSelectHdl(aLink);
352 0 : m_eULSpaceUnit = maULSpaceControl.GetCoreMetric();
353 0 : }
354 :
355 0 : void ParaPropertyPanel::InitToolBoxLineSpacing()
356 : {
357 0 : Link aLink = LINK( this, ParaPropertyPanel, ClickLineSPDropDownHdl_Impl );
358 0 : mpLineSPTbx->SetDropdownClickHdl( aLink );
359 0 : mpLineSPTbx->SetSelectHdl( aLink ); //support keyinput "ENTER"
360 :
361 0 : const sal_uInt16 nIdSpacing = mpLineSPTbx->GetItemId(UNO_LINESPACING);
362 0 : mpLineSPTbx->SetItemBits( nIdSpacing, mpLineSPTbx->GetItemBits( nIdSpacing ) | TIB_DROPDOWNONLY );
363 0 : mpLineSPTbx->SetItemImage(nIdSpacing, maSpace3);
364 0 : }
365 :
366 0 : void ParaPropertyPanel::initial()
367 : {
368 : //toolbox
369 0 : InitToolBoxIndent();
370 0 : InitToolBoxBGColor();
371 0 : InitToolBoxBulletsNumbering();
372 0 : InitToolBoxSpacing();
373 0 : InitToolBoxLineSpacing();
374 :
375 : #ifdef HAS_IA2
376 : mpAlignToolBox->SetAccRelationLabeledBy(&mpAlignToolBox);
377 : mpTBxVertAlign->SetMpSubEditAccLableBy(&mpTBxVertAlign);
378 : mpTBxNumBullet->SetAccRelationLabeledBy(&mpTBxNumBullet);
379 : mpTBxBackColor->SetMpSubEditAccLableBy(&mpTBxBackColor);
380 : mpTbxUL_IncDec->SetAccRelationLabeledBy(&mpTbxUL_IncDec);
381 : mpTopDist->SetAccRelationLabeledBy(&mpTopDist);
382 : mpBottomDist->SetAccRelationLabeledBy(&mpBottomDist);
383 : mpLineSPTbx->SetAccRelationLabeledBy(&mpLineSPTbx);
384 : mpTbxIndent_IncDec->SetAccRelationLabeledBy(&mpTbxIndent_IncDec);
385 : mpTbxProDemote->SetAccRelationLabeledBy(&mpTbxProDemote);
386 : mpLeftIndent->SetAccRelationLabeledBy(&mpLeftIndent);
387 : mpRightIndent->SetAccRelationLabeledBy(&mpRightIndent);
388 : mpFLineIndent->SetAccRelationLabeledBy(&mpFLineIndent);
389 : mpColorUpdater->SetAccRelationLabeledBy(&mpColorUpdater);
390 : #endif
391 0 : }
392 :
393 : //===========================for Numbering & Bullet================================================
394 :
395 :
396 :
397 0 : IMPL_LINK(ParaPropertyPanel, NumBTbxDDHandler, ToolBox*, pToolBox)
398 : {
399 0 : const sal_uInt16 nId = pToolBox->GetCurItemId();
400 0 : const OUString aCommand(pToolBox->GetItemCommand(nId));
401 :
402 0 : EndTracking();
403 0 : pToolBox->SetItemDown( nId, true );
404 :
405 0 : if (aCommand == UNO_DEFAULTBULLET)
406 : {
407 0 : maBulletsPopup.UpdateValueSet();
408 0 : maBulletsPopup.Show(*pToolBox);
409 : }
410 0 : else if (aCommand == UNO_DEFAULTNUMBERING)
411 : {
412 0 : maNumberingPopup.UpdateValueSet();
413 0 : maNumberingPopup.Show(*pToolBox);
414 : }
415 0 : pToolBox->SetItemDown( nId, false );
416 0 : return 0;
417 : }
418 :
419 0 : IMPL_LINK(ParaPropertyPanel, NumBTbxSelectHandler, ToolBox*, pToolBox)
420 : {
421 0 : const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
422 0 : sal_uInt16 nSID = SID_TABLE_VERT_NONE;
423 :
424 0 : EndTracking();
425 0 : if (aCommand == UNO_DEFAULTBULLET)
426 : {
427 0 : nSID = FN_NUM_BULLET_ON;
428 : }
429 0 : else if (aCommand == UNO_DEFAULTNUMBERING)
430 : {
431 0 : nSID = FN_NUM_NUMBERING_ON;
432 : }
433 0 : SfxBoolItem aBoolItem(nSID, true);
434 0 : GetBindings()->GetDispatcher()->Execute(nSID, SFX_CALLMODE_RECORD, &aBoolItem, 0L);
435 :
436 0 : return 0;
437 : }
438 :
439 :
440 : //==================================for Background color=====================
441 :
442 0 : IMPL_LINK(ParaPropertyPanel, ToolBoxBackColorDDHandler,ToolBox*, pToolBox)
443 : {
444 0 : const sal_uInt16 nId = pToolBox->GetCurItemId();
445 0 : const OUString aCommand(pToolBox->GetItemCommand(nId));
446 :
447 0 : if(aCommand == UNO_PARABACKCOLOR)
448 : {
449 0 : pToolBox->SetItemDown( nId, true );
450 0 : maBGColorPopup.Show(*pToolBox);
451 0 : maBGColorPopup.SetCurrentColor(maColor, mbColorAvailable);
452 : }
453 0 : return 0;
454 : }
455 :
456 0 : void ParaPropertyPanel::ParaBKGStateChanged(sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState)
457 : {
458 0 : if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxColorItem))
459 : {
460 0 : const SvxColorItem* pItem = (const SvxColorItem*)pState;
461 0 : maColor = pItem->GetValue();
462 0 : mbColorAvailable = true;
463 0 : mpColorUpdater->Update(maColor);
464 : }
465 : else
466 : {
467 0 : mbColorAvailable = false;
468 0 : maColor.SetColor(COL_AUTO);
469 0 : mpColorUpdater->Update(maColor);
470 : }
471 0 : }
472 :
473 0 : void ParaPropertyPanel::SetBGColor (
474 : const OUString& /*rsColorName*/,
475 : const Color aColor)
476 : {
477 0 : SvxColorItem aColorItem(aColor, SID_BACKGROUND_COLOR);
478 0 : mpBindings->GetDispatcher()->Execute(SID_BACKGROUND_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
479 0 : maColor = aColor;
480 0 : }
481 :
482 : //==================================for Paragraph Indent=====================
483 0 : IMPL_LINK_NOARG( ParaPropertyPanel, ModifyIndentHdl_Impl)
484 : {
485 0 : SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
486 0 : aMargin.SetTxtLeft( (const long)GetCoreValue( *mpLeftIndent, m_eLRSpaceUnit ) );
487 0 : aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
488 0 : aMargin.SetTxtFirstLineOfst( (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
489 :
490 : GetBindings()->GetDispatcher()->Execute(
491 0 : SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
492 0 : return 0;
493 : }
494 :
495 0 : IMPL_LINK(ParaPropertyPanel, ClickIndent_IncDec_Hdl_Impl, ToolBox *, pControl)
496 : {
497 0 : const OUString aCommand(pControl->GetItemCommand(pControl->GetCurItemId()));
498 :
499 0 : if (aCommand == UNO_INCREMENTINDENT)
500 : {
501 0 : switch (maContext.GetCombinedContext_DI())
502 : {
503 : case CombinedEnumContext(Application_WriterVariants, Context_Default):
504 : case CombinedEnumContext(Application_WriterVariants, Context_Text):
505 : case CombinedEnumContext(Application_WriterVariants, Context_Table):
506 : {
507 0 : SfxBoolItem aMargin( SID_INC_INDENT, true );
508 : GetBindings()->GetDispatcher()->Execute(
509 0 : SID_INC_INDENT, SFX_CALLMODE_RECORD, &aMargin, 0L);
510 : }
511 0 : break;
512 : default:
513 : {
514 0 : SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
515 :
516 0 : maTxtLeft += INDENT_STEP;
517 0 : sal_Int64 nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
518 0 : nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
519 0 : aMargin.SetTxtLeft( (const long)nVal );
520 0 : aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
521 0 : aMargin.SetTxtFirstLineOfst( (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
522 :
523 : GetBindings()->GetDispatcher()->Execute(
524 0 : SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
525 : }
526 : }
527 : }
528 0 : else if (aCommand == UNO_DECREMENTINDENT)
529 : {
530 0 : switch (maContext.GetCombinedContext_DI())
531 : {
532 : case CombinedEnumContext(Application_WriterVariants, Context_Default):
533 : case CombinedEnumContext(Application_WriterVariants, Context_Text):
534 : case CombinedEnumContext(Application_WriterVariants, Context_Table):
535 : {
536 0 : SfxBoolItem aMargin( SID_DEC_INDENT, true );
537 : GetBindings()->GetDispatcher()->Execute(
538 0 : SID_DEC_INDENT, SFX_CALLMODE_RECORD, &aMargin, 0L);
539 : }
540 0 : break;
541 : default:
542 : {
543 0 : if((maTxtLeft - INDENT_STEP) < 0)
544 0 : maTxtLeft = DEFAULT_VALUE;
545 : else
546 0 : maTxtLeft -= INDENT_STEP;
547 :
548 0 : SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
549 :
550 0 : sal_Int64 nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
551 0 : nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
552 :
553 0 : aMargin.SetTxtLeft( (const long)nVal );
554 0 : aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
555 0 : aMargin.SetTxtFirstLineOfst( (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
556 :
557 : GetBindings()->GetDispatcher()->Execute(
558 0 : SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
559 : }
560 : }
561 : }
562 0 : else if (aCommand == UNO_HANGINGINDENT)
563 : {
564 0 : SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
565 0 : aMargin.SetTxtLeft( (const long)GetCoreValue( *mpLeftIndent, m_eLRSpaceUnit ) + (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
566 0 : aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
567 0 : aMargin.SetTxtFirstLineOfst( ((const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ))*(-1) );
568 :
569 : GetBindings()->GetDispatcher()->Execute(
570 0 : SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
571 : }
572 :
573 0 : return( 0L );
574 : }
575 :
576 0 : IMPL_LINK(ParaPropertyPanel, ClickProDemote_Hdl_Impl, ToolBox *, pControl)
577 : {
578 0 : const OUString aCommand(pControl->GetItemCommand(pControl->GetCurItemId()));
579 :
580 0 : if (aCommand == UNO_PROMOTE)
581 : {
582 0 : GetBindings()->GetDispatcher()->Execute( SID_OUTLINE_RIGHT, SFX_CALLMODE_RECORD );
583 : }
584 0 : else if (aCommand == UNO_DEMOTE)
585 : {
586 0 : GetBindings()->GetDispatcher()->Execute( SID_OUTLINE_LEFT, SFX_CALLMODE_RECORD );
587 : }
588 0 : else if (aCommand == UNO_HANGINGINDENT2)
589 : {
590 0 : SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
591 0 : aMargin.SetTxtLeft( (const long)GetCoreValue( *mpLeftIndent, m_eLRSpaceUnit ) + (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
592 0 : aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
593 0 : aMargin.SetTxtFirstLineOfst( ((const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ))*(-1) );
594 :
595 0 : GetBindings()->GetDispatcher()->Execute( SID_ATTR_PARA_LRSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
596 : }
597 :
598 0 : return( 0L );
599 : }
600 : //==================================for Paragraph Line Spacing=====================
601 :
602 0 : IMPL_LINK( ParaPropertyPanel, ClickLineSPDropDownHdl_Impl, ToolBox*, pBox )
603 : {
604 0 : const sal_uInt16 nId = pBox->GetCurItemId();
605 0 : const OUString aCommand(pBox->GetItemCommand(nId));
606 :
607 0 : if (aCommand == UNO_LINESPACING)
608 : {
609 0 : pBox->SetItemDown( nId, true );
610 0 : maLineSpacePopup.Rearrange(meLnSpState,m_eMetricUnit,mpLnSPItem,maContext);
611 0 : maLineSpacePopup.Show(*pBox);
612 : }
613 0 : return (0L);
614 : }
615 :
616 : //==================================for Paragraph Spacing=====================
617 0 : IMPL_LINK_NOARG( ParaPropertyPanel, ULSpaceHdl_Impl)
618 : {
619 0 : SvxULSpaceItem aMargin( SID_ATTR_PARA_ULSPACE );
620 0 : aMargin.SetUpper( (sal_uInt16)GetCoreValue( *mpTopDist, m_eULSpaceUnit ) );
621 0 : aMargin.SetLower( (sal_uInt16)GetCoreValue( *mpBottomDist, m_eULSpaceUnit ) );
622 :
623 : GetBindings()->GetDispatcher()->Execute(
624 0 : SID_ATTR_PARA_ULSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
625 0 : return 0L;
626 : }
627 :
628 0 : IMPL_LINK(ParaPropertyPanel, ClickUL_IncDec_Hdl_Impl, ToolBox *, pControl)
629 : {
630 0 : const OUString aCommand(pControl->GetItemCommand(pControl->GetCurItemId()));
631 :
632 0 : if( aCommand == UNO_PARASPACEINC)
633 : {
634 0 : SvxULSpaceItem aMargin( SID_ATTR_PARA_ULSPACE );
635 :
636 0 : maUpper += UL_STEP;
637 0 : sal_Int64 nVal = OutputDevice::LogicToLogic( maUpper, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
638 0 : nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
639 0 : aMargin.SetUpper( (const sal_uInt16)nVal );
640 :
641 0 : maLower += UL_STEP;
642 0 : nVal = OutputDevice::LogicToLogic( maLower, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
643 0 : nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
644 0 : aMargin.SetLower( (const sal_uInt16)nVal );
645 :
646 : GetBindings()->GetDispatcher()->Execute(
647 0 : SID_ATTR_PARA_ULSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
648 : }
649 0 : else if( aCommand == UNO_PARASPACEDEC)
650 : {
651 0 : SvxULSpaceItem aMargin( SID_ATTR_PARA_ULSPACE );
652 0 : if( maUpper >= UL_STEP )
653 : {
654 0 : maUpper -= UL_STEP;
655 0 : sal_Int64 nVal = OutputDevice::LogicToLogic( maUpper, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
656 0 : nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
657 0 : aMargin.SetUpper( (const sal_uInt16)nVal );
658 : }
659 : else
660 0 : aMargin.SetUpper( DEFAULT_VALUE );
661 :
662 0 : if( maLower >= UL_STEP )
663 : {
664 0 : maLower -= UL_STEP;
665 0 : sal_Int64 nVal = OutputDevice::LogicToLogic( maLower, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
666 0 : nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
667 0 : aMargin.SetLower( (const sal_uInt16)nVal );
668 : }
669 : else
670 0 : aMargin.SetLower( DEFAULT_VALUE );
671 :
672 : GetBindings()->GetDispatcher()->Execute(
673 0 : SID_ATTR_PARA_ULSPACE, SFX_CALLMODE_RECORD, &aMargin, 0L);
674 : }
675 :
676 0 : return( 0L );
677 : }
678 :
679 : //==================================for Paragraph State change=====================
680 0 : void ParaPropertyPanel::NotifyItemUpdate(
681 : sal_uInt16 nSID,
682 : SfxItemState eState,
683 : const SfxPoolItem* pState,
684 : const bool bIsEnabled)
685 : {
686 : (void)bIsEnabled;
687 :
688 0 : switch (nSID)
689 : {
690 : case SID_ATTR_METRIC:
691 : {
692 0 : m_eMetricUnit = GetCurrentUnit(eState,pState);
693 0 : if( m_eMetricUnit!=m_last_eMetricUnit )
694 : {
695 0 : SetFieldUnit( *mpLeftIndent, m_eMetricUnit );
696 0 : SetFieldUnit( *mpRightIndent, m_eMetricUnit );
697 0 : SetFieldUnit( *mpFLineIndent, m_eMetricUnit );
698 0 : SetFieldUnit( *mpTopDist, m_eMetricUnit );
699 0 : SetFieldUnit( *mpBottomDist, m_eMetricUnit );
700 : }
701 0 : m_last_eMetricUnit = m_eMetricUnit;
702 : }
703 0 : break;
704 :
705 : case SID_ATTR_PARA_LRSPACE:
706 0 : StateChangedIndentImpl( nSID, eState, pState );
707 0 : break;
708 :
709 : case SID_ATTR_PARA_LINESPACE:
710 0 : StateChangedLnSPImpl( nSID, eState, pState );
711 0 : break;
712 :
713 : case SID_ATTR_PARA_ULSPACE:
714 0 : StateChangedULImpl( nSID, eState, pState );
715 0 : break;
716 :
717 : case SID_OUTLINE_LEFT:
718 : case SID_OUTLINE_RIGHT:
719 0 : StateChangeOutLineImpl( nSID, eState, pState );
720 0 : break;
721 :
722 : case SID_INC_INDENT:
723 : case SID_DEC_INDENT:
724 0 : StateChangeIncDecImpl( nSID, eState, pState );
725 0 : break;
726 :
727 : case FN_NUM_NUMBERING_ON:
728 : case FN_NUM_BULLET_ON:
729 0 : StateChangeBulletNumImpl( nSID, eState, pState );
730 0 : break;
731 :
732 : case FN_BUL_NUM_RULE_INDEX:
733 : case FN_NUM_NUM_RULE_INDEX:
734 0 : StateChangeBulletNumRuleImpl( nSID, eState, pState );
735 0 : break;
736 :
737 : case SID_BACKGROUND_COLOR:
738 0 : ParaBKGStateChanged(nSID, eState, pState);
739 0 : break;
740 : }
741 0 : }
742 :
743 :
744 :
745 :
746 0 : void ParaPropertyPanel::StateChangedIndentImpl( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
747 : {
748 0 : switch (maContext.GetCombinedContext_DI())
749 : {
750 :
751 : case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
752 : case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
753 : case CombinedEnumContext(Application_Calc, Context_DrawText):
754 : {
755 0 : mpLeftIndent->SetMin( DEFAULT_VALUE );
756 0 : mpRightIndent->SetMin( DEFAULT_VALUE );
757 0 : mpFLineIndent->SetMin( DEFAULT_VALUE );
758 0 : mpTbxIndent_IncDec->Show();
759 0 : mpTbxProDemote->Hide();
760 : }
761 0 : break;
762 : case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
763 : case CombinedEnumContext(Application_DrawImpress, Context_Draw):
764 : case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
765 : case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
766 : case CombinedEnumContext(Application_DrawImpress, Context_Table):
767 : {
768 0 : mpLeftIndent->SetMin( DEFAULT_VALUE );
769 0 : mpRightIndent->SetMin( DEFAULT_VALUE );
770 0 : mpFLineIndent->SetMin( DEFAULT_VALUE );
771 0 : mpTbxIndent_IncDec->Hide();
772 0 : mpTbxProDemote->Show();
773 : }
774 0 : break;
775 : case CombinedEnumContext(Application_WriterVariants, Context_Default):
776 : case CombinedEnumContext(Application_WriterVariants, Context_Text):
777 : case CombinedEnumContext(Application_WriterVariants, Context_Table):
778 : {
779 0 : mpLeftIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
780 0 : mpRightIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
781 0 : mpFLineIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
782 0 : mpTbxIndent_IncDec->Show();
783 0 : mpTbxProDemote->Hide();
784 : }
785 0 : break;
786 : }
787 :
788 0 : const sal_uInt16 nIdHangingIndent = mpTbxIndent_IncDec->GetItemId(UNO_HANGINGINDENT);
789 0 : const sal_uInt16 nIdHangingIndent2 = mpTbxIndent_IncDec->GetItemId(UNO_HANGINGINDENT2);
790 0 : if( pState && eState >= SFX_ITEM_AVAILABLE )
791 : {
792 0 : SvxLRSpaceItem* pSpace = ( SvxLRSpaceItem*)pState;
793 0 : maTxtLeft = pSpace->GetTxtLeft();
794 0 : maTxtLeft = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
795 0 : maTxtLeft = OutputDevice::LogicToLogic( maTxtLeft, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
796 :
797 0 : long aTxtRight = pSpace->GetRight();
798 0 : aTxtRight = OutputDevice::LogicToLogic( aTxtRight, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
799 0 : aTxtRight = OutputDevice::LogicToLogic( aTxtRight, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
800 :
801 0 : long aTxtFirstLineOfst = pSpace->GetTxtFirstLineOfst();
802 0 : aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
803 0 : aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
804 :
805 0 : long nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
806 0 : nVal = (long)mpLeftIndent->Normalize( (long)nVal );
807 0 : mpLeftIndent->SetValue( nVal, FUNIT_100TH_MM );
808 :
809 0 : if ( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)
810 0 : && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default)
811 0 : && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table))
812 : {
813 0 : mpFLineIndent->SetMin( nVal*(-1), FUNIT_100TH_MM );
814 : }
815 :
816 0 : long nrVal = OutputDevice::LogicToLogic( aTxtRight, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
817 0 : nrVal = (long)mpRightIndent->Normalize( (long)nrVal );
818 0 : mpRightIndent->SetValue( nrVal, FUNIT_100TH_MM );
819 :
820 0 : long nfVal = OutputDevice::LogicToLogic( aTxtFirstLineOfst, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
821 0 : nfVal = (long)mpFLineIndent->Normalize( (long)nfVal );
822 0 : mpFLineIndent->SetValue( nfVal, FUNIT_100TH_MM );
823 :
824 0 : switch (maContext.GetCombinedContext_DI())
825 : {
826 : case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
827 : case CombinedEnumContext(Application_WriterVariants, Context_Text):
828 : case CombinedEnumContext(Application_WriterVariants, Context_Default):
829 : case CombinedEnumContext(Application_WriterVariants, Context_Table):
830 : case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
831 : {
832 0 : mpLeftIndent->SetMax( MAX_SW - nrVal, FUNIT_100TH_MM );
833 0 : mpRightIndent->SetMax( MAX_SW - nVal, FUNIT_100TH_MM );
834 0 : mpFLineIndent->SetMax( MAX_SW - nVal - nrVal, FUNIT_100TH_MM );
835 : }
836 0 : break;
837 : case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
838 : case CombinedEnumContext(Application_DrawImpress, Context_Draw):
839 : case CombinedEnumContext(Application_DrawImpress, Context_Table):
840 : case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
841 : case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
842 : {
843 0 : mpLeftIndent->SetMax( MAX_SC_SD - nrVal, FUNIT_100TH_MM );
844 0 : mpRightIndent->SetMax( MAX_SC_SD - nVal, FUNIT_100TH_MM );
845 0 : mpFLineIndent->SetMax( MAX_SC_SD - nVal - nrVal, FUNIT_100TH_MM );
846 : }
847 : }
848 :
849 0 : mpTbxIndent_IncDec->Enable();
850 :
851 0 : const sal_uInt16 nIdIncrIndent = mpTbxIndent_IncDec->GetItemId(UNO_INCREMENTINDENT);
852 0 : const sal_uInt16 nIdDecrIndent = mpTbxIndent_IncDec->GetItemId(UNO_DECREMENTINDENT);
853 :
854 0 : mpTbxIndent_IncDec->EnableItem(nIdHangingIndent, true);
855 0 : if ( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)
856 0 : && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default)
857 0 : && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table) )
858 : {
859 0 : mpTbxIndent_IncDec->EnableItem(nIdIncrIndent, true);
860 0 : mpTbxIndent_IncDec->EnableItem(nIdDecrIndent, true);
861 : }
862 :
863 0 : mpTbxProDemote->EnableItem(nIdHangingIndent2, true);
864 : }
865 0 : else if( eState == SFX_ITEM_DISABLED )
866 : {
867 0 : mpLeftIndent-> Disable();
868 0 : mpRightIndent->Disable();
869 0 : mpFLineIndent->Disable();
870 0 : mpTbxIndent_IncDec->Disable();
871 0 : if( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text) &&
872 0 : maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default) &&
873 0 : maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table) )
874 0 : mpTbxIndent_IncDec->Disable();
875 : else
876 0 : mpTbxIndent_IncDec->EnableItem(nIdHangingIndent, false);
877 :
878 : // maTbxProDemote->Disable();
879 0 : mpTbxProDemote->EnableItem(nIdHangingIndent2, false);
880 : }
881 : else
882 : {
883 0 : mpLeftIndent->SetEmptyFieldValue();
884 0 : mpRightIndent->SetEmptyFieldValue();
885 0 : mpFLineIndent->SetEmptyFieldValue();
886 0 : if( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text) &&
887 0 : maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default) &&
888 0 : maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table) )
889 0 : mpTbxIndent_IncDec->Disable();
890 : else
891 0 : mpTbxIndent_IncDec->EnableItem(nIdHangingIndent, false);
892 0 : mpTbxProDemote->EnableItem(nIdHangingIndent2, false);
893 : }
894 0 : }
895 :
896 0 : void ParaPropertyPanel::StateChangedLnSPImpl( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
897 : {
898 0 : meLnSpState = eState;
899 :
900 0 : if( pState && eState >= SFX_ITEM_AVAILABLE )
901 : {
902 0 : if(mpLnSPItem)
903 0 : delete mpLnSPItem;
904 0 : mpLnSPItem = ( SvxLineSpacingItem *)pState->Clone();
905 : }
906 0 : }
907 :
908 0 : void ParaPropertyPanel::StateChangedULImpl( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
909 : {
910 0 : mpTopDist->SetMax( mpTopDist->Normalize( MAX_DURCH ), MapToFieldUnit(m_eULSpaceUnit) );
911 0 : mpBottomDist->SetMax( mpBottomDist->Normalize( MAX_DURCH ), MapToFieldUnit(m_eULSpaceUnit) );
912 :
913 0 : if( pState && eState >= SFX_ITEM_AVAILABLE )
914 : {
915 0 : SvxULSpaceItem* pOldItem = (SvxULSpaceItem*)pState;
916 :
917 0 : maUpper = pOldItem->GetUpper();
918 0 : maUpper = OutputDevice::LogicToLogic( maUpper, (MapUnit)m_eULSpaceUnit, MAP_100TH_MM );
919 0 : maUpper = OutputDevice::LogicToLogic( maUpper, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
920 :
921 0 : maLower = pOldItem->GetLower();
922 0 : maLower = OutputDevice::LogicToLogic( maLower, (MapUnit)m_eULSpaceUnit, MAP_100TH_MM );
923 0 : maLower = OutputDevice::LogicToLogic( maLower, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
924 :
925 0 : sal_Int64 nVal = OutputDevice::LogicToLogic( maUpper, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
926 0 : nVal = mpTopDist->Normalize( nVal );
927 0 : mpTopDist->SetValue( nVal, FUNIT_100TH_MM );
928 :
929 0 : nVal = OutputDevice::LogicToLogic( maLower, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
930 0 : nVal = mpBottomDist->Normalize( nVal );
931 0 : mpBottomDist->SetValue( nVal, FUNIT_100TH_MM );
932 0 : mpTbxUL_IncDec->Enable();
933 : }
934 0 : else if(eState == SFX_ITEM_DISABLED )
935 : {
936 0 : mpTopDist->Disable();
937 0 : mpBottomDist->Disable();
938 0 : mpTbxUL_IncDec->Disable();
939 : }
940 : else
941 : {
942 0 : mpTopDist->SetEmptyFieldValue();
943 0 : mpBottomDist->SetEmptyFieldValue();
944 0 : mpTbxUL_IncDec->Disable();
945 : }
946 0 : }
947 :
948 0 : void ParaPropertyPanel::StateChangeOutLineImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
949 : {
950 0 : if (nSID==SID_OUTLINE_LEFT)
951 : {
952 0 : if( pState && eState == SFX_ITEM_UNKNOWN )
953 0 : mbOutLineLeft = true;
954 : else
955 0 : mbOutLineLeft = false;
956 : }
957 0 : if (nSID==SID_OUTLINE_RIGHT)
958 : {
959 0 : if( pState && eState == SFX_ITEM_UNKNOWN )
960 0 : mbOutLineRight = true;
961 : else
962 0 : mbOutLineRight = false;
963 : }
964 :
965 0 : const sal_uInt16 nIdDemote = mpTbxProDemote->GetItemId(UNO_DEMOTE);
966 0 : if(mbOutLineLeft)
967 0 : mpTbxProDemote->EnableItem(nIdDemote, true);
968 : else
969 0 : mpTbxProDemote->EnableItem(nIdDemote, false);
970 :
971 0 : const sal_uInt16 nIdPromote = mpTbxProDemote->GetItemId(UNO_PROMOTE);
972 0 : if(mbOutLineRight)
973 0 : mpTbxProDemote->EnableItem(nIdPromote, true);
974 : else
975 0 : mpTbxProDemote->EnableItem(nIdPromote, false);
976 :
977 0 : }
978 :
979 0 : void ParaPropertyPanel::StateChangeIncDecImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
980 : {
981 0 : if ( ( maContext.GetCombinedContext_DI() == CombinedEnumContext(Application_WriterVariants, Context_Text)
982 0 : || maContext.GetCombinedContext_DI() == CombinedEnumContext(Application_WriterVariants, Context_Default)
983 0 : || maContext.GetCombinedContext_DI() == CombinedEnumContext(Application_WriterVariants, Context_Table) )
984 0 : && ( nSID == SID_INC_INDENT || nSID == SID_DEC_INDENT ) )
985 : {
986 : // Writer's text shell is the only one which provides reasonable states for Slots SID_INC_INDENT and SID_DEC_INDENT
987 : // - namely SFX_ITEM_UNKNOWN and SFX_ITEM_DISABLED
988 0 : const sal_uInt16 nIdIncrIndent = mpTbxIndent_IncDec->GetItemId(UNO_INCREMENTINDENT);
989 0 : const sal_uInt16 nIdDecrIndent = mpTbxIndent_IncDec->GetItemId(UNO_DECREMENTINDENT);
990 :
991 : mpTbxIndent_IncDec->EnableItem(
992 : nSID == SID_INC_INDENT ? nIdIncrIndent : nIdDecrIndent,
993 0 : ( pState && eState == SFX_ITEM_UNKNOWN ) ? sal_True : sal_False );
994 : }
995 0 : }
996 :
997 :
998 : // Add toggle state for numbering and bullet icons
999 0 : void ParaPropertyPanel::StateChangeBulletNumImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1000 : {
1001 0 : if ( (eState >= SFX_ITEM_DEFAULT) && (pState->ISA(SfxBoolItem)) )
1002 : {
1003 0 : const SfxBoolItem* pItem= (const SfxBoolItem*)pState;
1004 0 : const sal_Bool aBool = (sal_Bool)pItem->GetValue();
1005 :
1006 0 : const sal_uInt16 nIdNumber = mpTBxNumBullet->GetItemId(UNO_DEFAULTNUMBERING);
1007 0 : const sal_uInt16 nIdBullet = mpTBxNumBullet->GetItemId(UNO_DEFAULTBULLET);
1008 :
1009 0 : if (nSID==FN_NUM_NUMBERING_ON)
1010 : {
1011 : mpTBxNumBullet->SetItemState(
1012 : nIdNumber,
1013 0 : aBool ? TRISTATE_TRUE : TRISTATE_FALSE );
1014 : }
1015 0 : else if (nSID==FN_NUM_BULLET_ON)
1016 : {
1017 : mpTBxNumBullet->SetItemState(
1018 : nIdBullet,
1019 0 : aBool ? TRISTATE_TRUE : TRISTATE_FALSE );
1020 : }
1021 : }
1022 0 : }
1023 :
1024 :
1025 0 : void ParaPropertyPanel::StateChangeBulletNumRuleImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1026 : {
1027 0 : if ( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxUInt16Item) )
1028 : {
1029 0 : sal_uInt16 nValue = (sal_uInt16)0xFFFF;
1030 : {
1031 0 : const SfxUInt16Item* pIt = (const SfxUInt16Item*)pState;
1032 0 : if ( pIt )
1033 0 : nValue = pIt->GetValue();
1034 : }
1035 :
1036 0 : if ( nSID == FN_BUL_NUM_RULE_INDEX )
1037 : {
1038 0 : mnBulletTypeIndex = nValue;
1039 : }
1040 0 : else if ( nSID == FN_NUM_NUM_RULE_INDEX )
1041 : {
1042 0 : mnNumTypeIndex = nValue;
1043 : }
1044 : }
1045 0 : }
1046 :
1047 :
1048 0 : FieldUnit ParaPropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
1049 : {
1050 0 : FieldUnit eUnit = FUNIT_NONE;
1051 :
1052 0 : if ( pState && eState >= SFX_ITEM_DEFAULT )
1053 0 : eUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
1054 : else
1055 : {
1056 0 : SfxViewFrame* pFrame = SfxViewFrame::Current();
1057 0 : SfxObjectShell* pSh = NULL;
1058 0 : if ( pFrame )
1059 0 : pSh = pFrame->GetObjectShell();
1060 0 : if ( pSh ) //the object shell is not always available during reload
1061 : {
1062 0 : SfxModule* pModule = pSh->GetModule();
1063 0 : if ( pModule )
1064 : {
1065 0 : const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
1066 0 : if ( pItem )
1067 0 : eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
1068 : }
1069 : else
1070 : {
1071 : DBG_ERRORFILE( "GetModuleFieldUnit(): no module found" );
1072 : }
1073 : }
1074 : }
1075 :
1076 0 : return eUnit;
1077 : }
1078 :
1079 :
1080 0 : PopupControl* ParaPropertyPanel::CreateLineSpacingControl (PopupContainer* pParent)
1081 : {
1082 0 : return new ParaLineSpacingControl(pParent, *this);
1083 : }
1084 :
1085 0 : PopupControl* ParaPropertyPanel::CreateBulletsPopupControl (PopupContainer* pParent)
1086 : {
1087 0 : return new ParaBulletsControl(pParent, *this);
1088 : }
1089 :
1090 0 : PopupControl* ParaPropertyPanel::CreateNumberingPopupControl (PopupContainer* pParent)
1091 : {
1092 0 : return new ParaNumberingControl(pParent, *this);
1093 : }
1094 :
1095 : namespace
1096 : {
1097 0 : Color GetNoBackgroundColor(void)
1098 : {
1099 0 : return COL_TRANSPARENT;
1100 : }
1101 : } // end of anonymous namespace
1102 :
1103 0 : PopupControl* ParaPropertyPanel::CreateBGColorPopupControl (PopupContainer* pParent)
1104 : {
1105 0 : const ResId aResId(SVX_RES(STR_NOFILL));
1106 :
1107 : return new ColorControl(
1108 : pParent,
1109 : mpBindings,
1110 0 : SVX_RES(RID_POPUPPANEL_PARAPAGE_BACK_COLOR),
1111 0 : SVX_RES(VS_FONT_COLOR),
1112 : ::boost::bind(GetNoBackgroundColor),
1113 : ::boost::bind(&ParaPropertyPanel::SetBGColor, this, _1,_2),
1114 : pParent,
1115 0 : &aResId);
1116 : }
1117 :
1118 :
1119 0 : ParaPropertyPanel::ParaPropertyPanel(Window* pParent,
1120 : const cssu::Reference<css::frame::XFrame>& rxFrame,
1121 : SfxBindings* pBindings,
1122 : const cssu::Reference<css::ui::XSidebar>& rxSidebar)
1123 : : PanelLayout(pParent, "ParaPropertyPanel", "svx/ui/sidebarparagraph.ui", rxFrame),
1124 :
1125 : mpColorUpdater (),
1126 0 : maSpace3 (SVX_RES(IMG_SPACE3)),
1127 0 : maIndHang (SVX_RES(IMG_INDENT_HANG)),
1128 0 : maNumBImageList (SVX_RES(IL_NUM_BULLET)),
1129 0 : maNumBImageListRTL (SVX_RES(IL_NUM_BULLET_RTL)),
1130 : maTxtLeft (0),
1131 : mpLnSPItem (NULL),
1132 : meLnSpState (SFX_ITEM_DONTCARE),
1133 : mbOutLineLeft (false),
1134 : mbOutLineRight (false),
1135 : maUpper (0),
1136 : maLower (0),
1137 : mnBulletTypeIndex ((sal_uInt16)0xFFFF),
1138 : mnNumTypeIndex ((sal_uInt16)0xFFFF),
1139 : maColor (COL_AUTO),
1140 : mbColorAvailable (true),
1141 : m_eMetricUnit(FUNIT_NONE),
1142 : m_last_eMetricUnit(FUNIT_NONE),
1143 : m_eLRSpaceUnit(),
1144 : m_eULSpaceUnit(),
1145 : maLRSpaceControl (SID_ATTR_PARA_LRSPACE,*pBindings,*this),
1146 : maLNSpaceControl (SID_ATTR_PARA_LINESPACE, *pBindings,*this),
1147 : maULSpaceControl (SID_ATTR_PARA_ULSPACE, *pBindings,*this),
1148 : maOutLineLeftControl(SID_OUTLINE_LEFT, *pBindings, *this, OUString("OutlineRight"), rxFrame),
1149 : maOutLineRightControl(SID_OUTLINE_RIGHT, *pBindings, *this, OUString("OutlineLeft"), rxFrame),
1150 : maDecIndentControl(SID_DEC_INDENT, *pBindings,*this, OUString("DecrementIndent"), rxFrame),
1151 : maIncIndentControl(SID_INC_INDENT, *pBindings,*this, OUString("IncrementIndent"), rxFrame),
1152 : maBulletOnOff(FN_NUM_BULLET_ON, *pBindings, *this, OUString("DefaultBullet"), rxFrame),
1153 : maNumberOnOff(FN_NUM_NUMBERING_ON, *pBindings, *this, OUString("DefaultNumbering"), rxFrame),
1154 : maBackColorControl (SID_BACKGROUND_COLOR, *pBindings,*this),
1155 : m_aMetricCtl (SID_ATTR_METRIC, *pBindings,*this),
1156 : maBulletNumRuleIndex (FN_BUL_NUM_RULE_INDEX, *pBindings,*this),
1157 : maNumNumRuleIndex (FN_NUM_NUM_RULE_INDEX, *pBindings,*this),
1158 : mxFrame(rxFrame),
1159 : maContext(),
1160 : mpBindings(pBindings),
1161 : maLineSpacePopup(this, ::boost::bind(&ParaPropertyPanel::CreateLineSpacingControl, this, _1)),
1162 : maBulletsPopup(this, ::boost::bind(&ParaPropertyPanel::CreateBulletsPopupControl, this, _1)),
1163 : maNumberingPopup(this, ::boost::bind(&ParaPropertyPanel::CreateNumberingPopupControl, this, _1)),
1164 : maBGColorPopup(this, ::boost::bind(&ParaPropertyPanel::CreateBGColorPopupControl, this, _1)),
1165 0 : mxSidebar(rxSidebar)
1166 : {
1167 : //Alignment
1168 0 : get(mpTBxVertAlign, "verticalalignment");
1169 : //NumBullet&Backcolor
1170 0 : get(mpTBxNumBullet, "numberbullet");
1171 0 : get(mpTBxBackColor, "backgroundcolor");
1172 : //Paragraph spacing
1173 0 : get(mpTopDist, "aboveparaspacing");
1174 0 : mpTopDist->set_width_request(mpTopDist->get_preferred_size().Width());
1175 0 : get(mpBottomDist, "belowparaspacing");
1176 0 : mpBottomDist->set_width_request(mpBottomDist->get_preferred_size().Width());
1177 0 : get(mpLeftIndent, "beforetextindent");
1178 0 : mpLeftIndent->set_width_request(mpLeftIndent->get_preferred_size().Width());
1179 0 : get(mpRightIndent, "aftertextindent");
1180 0 : mpRightIndent->set_width_request(mpRightIndent->get_preferred_size().Width());
1181 0 : get(mpFLineIndent, "firstlineindent");
1182 0 : mpFLineIndent->set_width_request(mpFLineIndent->get_preferred_size().Width());
1183 :
1184 0 : get(mpTbxIndent_IncDec, "indent");
1185 0 : get(mpTbxProDemote, "promotedemote");
1186 0 : get(mpLineSPTbx, "linespacing");
1187 0 : get(mpTbxUL_IncDec, "paraspacing");
1188 :
1189 0 : initial();
1190 0 : }
1191 :
1192 0 : } } // end of namespace svx::sidebar
|