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