Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / sidebar / paragraph / ParaLineSpacingControl.cxx
blobd7f1a0f5f4a5e6579f8c51d25c37d0e877f4359f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "ParaLineSpacingControl.hxx"
20 #include "ParaPropertyPanel.hrc"
21 #include <sfx2/sidebar/ResourceDefinitions.hrc>
22 #include <svx/dialogs.hrc>
23 #include <svx/dialmgr.hxx>
24 #include <unotools/viewoptions.hxx>
25 #include <editeng/kernitem.hxx>
26 #include <sfx2/bindings.hxx>
27 #include <sfx2/dispatch.hxx>
28 #include <sfx2/sidebar/Theme.hxx>
29 #include <svtools/unitconv.hxx>
30 #include <vcl/settings.hxx>
32 #define _DEFAULT_LINE_SPACING 200
33 #define FIX_DIST_DEF 283
34 #define LINESPACE_1 100
35 #define LINESPACE_15 150
36 #define LINESPACE_2 200
37 #define LINESPACE_115 115
39 #define LLINESPACE_1 0
40 #define LLINESPACE_15 1
41 #define LLINESPACE_2 2
42 #define LLINESPACE_PROP 3
43 #define LLINESPACE_MIN 4
44 #define LLINESPACE_DURCH 5
45 #define LLINESPACE_FIX 6
47 #define DO_NOT_CUSTOM false
48 #define USE_CUSTOM true
50 namespace svx { namespace sidebar {
53 ParaLineSpacingControl::ParaLineSpacingControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel)
54 : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_LINESPACING))
55 , mbUseLineSPCustom (false)
56 , mbLineSPDisable (false)
57 , mrParaPropertyPanel(rPanel)
58 , mpBindings(NULL)
59 , nMinFixDist(BEGIN_VALUE)
60 , pActLineDistFld(&aLineDistAtPercentBox)
61 , maLineSpacing(ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) )
62 , maCustomFT ( this, SVX_RES( FT_CUSTOM ) )
63 , maLSpacingFT ( this, SVX_RES( FT_LINE_SPACING ) )
64 , aLineDist( this, SVX_RES( LB_LINE_SPACING ))
65 , maOfFT ( this, SVX_RES( FT_OF ) )
66 , aLineDistAtPercentBox ( this, SVX_RES( ED_SBINDE_LINEDISTPERCENT ) )
67 , aLineDistAtMetricBox ( this, SVX_RES( ED_SBINDE_LINEDISTPOINT ) )
68 , maSpacing1 (SVX_RES(IMG_SPACING1))
69 , maSpacing115 (SVX_RES(IMG_SPACING115))
70 , maSpacing15 (SVX_RES(IMG_SPACING15))
71 , maSpacing2 (SVX_RES(IMG_SPACING2))
72 , maSelSpacing1 (SVX_RES(IMG_SEL_SPACING1))
73 , maSelSpacing115 (SVX_RES(IMG_SEL_SPACING115))
74 , maSelSpacing15 (SVX_RES(IMG_SEL_SPACING15))
75 , maSelSpacing2 (SVX_RES(IMG_SEL_SPACING2))
76 , maImgCus (SVX_RES(IMG_CUSTOM))
77 , maImgCusGrey (SVX_RES(IMG_CUSTOM_GRAY))
78 , maStrCus (SVX_RESSTR(STR_LCVALUE))
79 , mpImg(NULL)
80 , mpImgSel(NULL)
81 , mpStr(NULL)
82 , mpStrTip(NULL)
83 , maLine(SVX_RESSTR(STR_LSPACING))
84 , maOf(SVX_RESSTR(STR_LS_OF))
85 , maValue( 0 )
86 , maPos( 0 )
88 initial();
89 FreeResource();
90 mpBindings = mrParaPropertyPanel.GetBindings();
91 // m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric();
92 m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM;
94 ParaLineSpacingControl::~ParaLineSpacingControl()
96 delete[] mpImg;
97 delete[] mpImgSel;
98 delete[] mpStr;
99 delete[] mpStrTip;
102 void ParaLineSpacingControl::initial()
104 maLineSpacing.SetStyle( maLineSpacing.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
106 maLineSpacing.SetControlBackground(
107 GetSettings().GetStyleSettings().GetHighContrastMode()
108 ? GetSettings().GetStyleSettings().GetMenuColor()
109 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
110 maLineSpacing.SetColor(
111 GetSettings().GetStyleSettings().GetHighContrastMode()
112 ? GetSettings().GetStyleSettings().GetMenuColor()
113 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
114 maLineSpacing.SetBackground(
115 GetSettings().GetStyleSettings().GetHighContrastMode()
116 ? GetSettings().GetStyleSettings().GetMenuColor()
117 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
119 mpImg = new Image[4];
120 mpImg[0] = maSpacing1;
121 mpImg[1] = maSpacing115;
122 mpImg[2] = maSpacing15;
123 mpImg[3] = maSpacing2;
125 mpImgSel = new Image[4];
126 mpImgSel[0] = maSelSpacing1;
127 mpImgSel[1] = maSelSpacing115;
128 mpImgSel[2] = maSelSpacing15;
129 mpImgSel[3] = maSelSpacing2;
131 mpStr = new OUString[4];
132 mpStr[0] = SVX_RESSTR(STR_SPACING1);
133 mpStr[1] = SVX_RESSTR(STR_SPACING115);
134 mpStr[2] = SVX_RESSTR(STR_SPACING15);
135 mpStr[3] = SVX_RESSTR(STR_SPACING2);
137 mpStrTip = new OUString[4];
138 mpStrTip[0] = SVX_RESSTR(STR_LS_SINGLE);
139 mpStrTip[1] = SVX_RESSTR(STR_LS_115);
140 mpStrTip[2] = SVX_RESSTR(STR_LS_15);
141 mpStrTip[3] = SVX_RESSTR(STR_LS_DOUBLE);
142 for (int i=0;i<4;i++)
143 maLineSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]);
145 maLineSpacing.AddItem( maImgCus, 0, maStrCus, 0 );
147 SetAllNoSel();
148 Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl );
149 maLineSpacing.SetSelectHdl(aLink);
150 maLineSpacing.StartSelection();
151 maLineSpacing.Show();
153 aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl );
154 aLineDist.SetSelectHdl(aLink);
155 aLineDist.SelectEntryPos( LLINESPACE_1 ) ;
156 aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl );
157 aLineDistAtPercentBox.SetModifyHdl( aLink );
158 aLineDistAtMetricBox.SetModifyHdl( aLink );
162 void ParaLineSpacingControl::PopupModeEndCallback()
164 if( mbUseLineSPCustom )
166 //maLinePos = mpLineSPPage->maPos;
167 //maLineValue = mpLineSPPage->maValue;
169 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
170 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
171 aSeq[0].Name = "maLinePos";
172 aSeq[0].Value <<= ::rtl::OUString::number(maPos);
173 aWinOpt.SetUserData( aSeq );
175 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
176 aSeq[0].Name = "maLineValue";
177 aSeq[0].Value <<= ::rtl::OUString::number(maValue);
178 aWinOpt2.SetUserData( aSeq );
182 void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext)
184 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
185 if ( aWinOpt.Exists() )
187 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
188 ::rtl::OUString aTmp;
189 if ( aSeq.getLength())
190 aSeq[0].Value >>= aTmp;
192 OUString aWinData( aTmp );
193 maPos = (sal_uInt16)aWinData.toInt32();
196 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
197 if ( aWinOpt2.Exists() )
199 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
200 ::rtl::OUString aTmp;
201 if ( aSeq.getLength())
202 aSeq[0].Value >>= aTmp;
204 OUString aWinData( aTmp );
205 maValue = (sal_uInt16)aWinData.toInt32();
207 OUString sHelpText;
208 switch(maPos)
210 case LLINESPACE_1:
211 sHelpText += mpStrTip[0];
212 break;
213 case LLINESPACE_15:
214 sHelpText += mpStrTip[2];
215 break;
216 case LLINESPACE_2:
217 sHelpText += mpStrTip[3];
218 break;
219 case LLINESPACE_PROP:
220 sHelpText +=maLine;
221 sHelpText += "Proportion: ";
222 sHelpText += maOf;
223 sHelpText += OUString::number( maValue );
224 break;
225 case LLINESPACE_MIN:
226 sHelpText += maLine;
227 sHelpText += "At Least: ";
228 sHelpText += maOf;
229 sHelpText += OUString::number( maValue );
230 break;
231 case LLINESPACE_DURCH:
232 sHelpText += maLine;
233 sHelpText += "Leading: ";
234 sHelpText += maOf;
235 sHelpText += OUString::number( maValue );
236 break;
237 case LLINESPACE_FIX:
238 sHelpText += maLine;
239 sHelpText += "Fixed: ";
240 sHelpText += maOf;
241 sHelpText += OUString::number( maValue );
242 break;
244 if( !aWinOpt.Exists() && !aWinOpt2.Exists() )
245 mbLineSPDisable = true;
246 else
247 mbLineSPDisable = false;
249 if( mbLineSPDisable )
250 maLineSpacing.ReplaceItemImages(5, maImgCusGrey,0);
251 else
253 maLineSpacing.ReplaceItemImages(5, maImgCus,0);
254 maLineSpacing.SetItemText(5,sHelpText);
257 SfxItemState eState = currSPState;
259 SetFieldUnit( aLineDistAtMetricBox, currMetricUnit );
261 // mpLineSPPage->SetAllNoSel();
262 aLineDist.Enable();
263 pActLineDistFld->Enable();
264 pActLineDistFld->SetText( "" );
265 //bool bValueSetFocus = sal_False; //wj
267 if( eState >= SFX_ITEM_AVAILABLE )
269 // SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric();
270 SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM;
271 m_eLNSpaceUnit = eUnit;
273 switch( currSPItem->GetLineSpaceRule() )
275 case SVX_LINE_SPACE_AUTO:
277 SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule();
279 switch( eInter )
281 case SVX_INTER_LINE_SPACE_OFF:
283 aLineDist.SelectEntryPos( LLINESPACE_1 );
284 pActLineDistFld->Disable();
285 pActLineDistFld->SetText( "" );
286 mbUseLineSPCustom = DO_NOT_CUSTOM;
287 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
289 maLineSpacing.SelectItem(1);
290 //bValueSetFocus = sal_True; //wj
293 break;
295 case SVX_INTER_LINE_SPACE_PROP:
297 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
299 aLineDist.SelectEntryPos( LLINESPACE_1 );
300 pActLineDistFld->Disable();
301 pActLineDistFld->SetText( "" );
302 mbUseLineSPCustom = DO_NOT_CUSTOM;
303 maLineSpacing.SelectItem(1);
304 //bValueSetFocus = sal_True; //wj
305 break;
307 if ( LINESPACE_15 == currSPItem->GetPropLineSpace() )
309 aLineDist.SelectEntryPos( LLINESPACE_15 );
310 pActLineDistFld->Disable();
311 pActLineDistFld->SetText( "" );
313 mbUseLineSPCustom = DO_NOT_CUSTOM;
314 maLineSpacing.SelectItem(3);
315 //bValueSetFocus = sal_True; //wj
316 break;
318 if ( LINESPACE_2 == currSPItem->GetPropLineSpace() )
320 aLineDist.SelectEntryPos( LLINESPACE_2 );
321 pActLineDistFld->Disable();
322 pActLineDistFld->SetText( "" );
324 mbUseLineSPCustom = DO_NOT_CUSTOM;
325 maLineSpacing.SelectItem(4);
326 //bValueSetFocus = sal_True; //wj
327 break;
330 aLineDist.SelectEntryPos( LLINESPACE_PROP );
331 if(pActLineDistFld != &(aLineDistAtPercentBox))
333 pActLineDistFld->Disable();
334 pActLineDistFld->Hide();
335 pActLineDistFld = &(aLineDistAtPercentBox);
337 else
339 pActLineDistFld = &(aLineDistAtMetricBox);
340 pActLineDistFld->Disable();
341 pActLineDistFld->Hide();
342 pActLineDistFld = &(aLineDistAtPercentBox);
344 pActLineDistFld->Enable();
345 pActLineDistFld->Show();
346 aLineDistAtPercentBox.
347 SetValue( aLineDistAtPercentBox.Normalize(
348 currSPItem->GetPropLineSpace() ) );
350 if( currSPItem->GetPropLineSpace() == LINESPACE_115 )
352 mbUseLineSPCustom = DO_NOT_CUSTOM;
353 maLineSpacing.SelectItem(2);
354 //bValueSetFocus = sal_True; //wj
356 else
358 mbUseLineSPCustom = USE_CUSTOM;
359 maLineSpacing.SetNoSelection();
360 maLineSpacing.SelectItem(0);
363 break;
365 case SVX_INTER_LINE_SPACE_FIX:
367 if(pActLineDistFld != &(aLineDistAtMetricBox))
369 pActLineDistFld->Disable();
370 pActLineDistFld->Hide();
371 pActLineDistFld = &(aLineDistAtMetricBox);
373 else
375 pActLineDistFld = &(aLineDistAtPercentBox);
376 pActLineDistFld->Disable();
377 pActLineDistFld->Hide();
378 pActLineDistFld = &(aLineDistAtMetricBox);
380 pActLineDistFld->Enable();
381 pActLineDistFld->Show();
382 maLineSpacing.SetNoSelection();
383 maLineSpacing.SelectItem(0);
385 SetMetricValue( aLineDistAtMetricBox,
386 currSPItem->GetInterLineSpace(), eUnit );
387 aLineDist.SelectEntryPos( LLINESPACE_DURCH );
389 mbUseLineSPCustom = USE_CUSTOM;
391 break;
392 default:
393 break;
396 break;
397 case SVX_LINE_SPACE_FIX:
399 if(pActLineDistFld != &(aLineDistAtMetricBox))
401 pActLineDistFld->Disable();
402 pActLineDistFld->Hide();
403 pActLineDistFld = &(aLineDistAtMetricBox);
405 else
407 pActLineDistFld = &(aLineDistAtPercentBox);
408 pActLineDistFld->Disable();
409 pActLineDistFld->Hide();
410 pActLineDistFld = &(aLineDistAtMetricBox);
412 pActLineDistFld->Enable();
413 pActLineDistFld->Show();
414 maLineSpacing.SetNoSelection();
415 maLineSpacing.SelectItem(0);
417 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
418 aLineDist.SelectEntryPos( LLINESPACE_FIX );
420 mbUseLineSPCustom = USE_CUSTOM;
422 break;
424 case SVX_LINE_SPACE_MIN:
426 if(pActLineDistFld != &(aLineDistAtMetricBox))
428 pActLineDistFld->Disable();
429 pActLineDistFld->Hide();
430 pActLineDistFld = &(aLineDistAtMetricBox);
432 else
434 pActLineDistFld = &(aLineDistAtPercentBox);
435 pActLineDistFld->Disable();
436 pActLineDistFld->Hide();
437 pActLineDistFld = &(aLineDistAtMetricBox);
439 pActLineDistFld->Enable();
440 pActLineDistFld->Show();
441 maLineSpacing.SetNoSelection();
442 maLineSpacing.SelectItem(0);
444 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
445 aLineDist.SelectEntryPos( LLINESPACE_MIN );
446 mbUseLineSPCustom = USE_CUSTOM;
448 break;
449 default:
450 break;
453 else if( eState == SFX_ITEM_DISABLED )
455 aLineDist.Disable();
456 pActLineDistFld->Enable(false);
457 pActLineDistFld->SetText( "" );
458 maLineSpacing.SetNoSelection();
459 maLineSpacing.SelectItem(0);
461 mbUseLineSPCustom = DO_NOT_CUSTOM;
463 else
465 pActLineDistFld->Enable(false);
466 pActLineDistFld->SetText( "" );
467 aLineDist.SetNoSelection();
468 maLineSpacing.SetNoSelection();
469 maLineSpacing.SelectItem(0);
470 mbUseLineSPCustom = DO_NOT_CUSTOM;
473 aLineDist.SaveValue();
475 const sal_uInt16 uCount = aLineDist.GetEntryCount();
476 if( uCount == LLINESPACE_FIX + 1 )
478 switch (currentContext.GetCombinedContext_DI())
480 case CombinedEnumContext(Application_DrawImpress, Context_Table):
481 case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
482 case CombinedEnumContext(Application_DrawImpress, Context_Draw):
483 case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
484 case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
485 case CombinedEnumContext(Application_Calc, Context_DrawText):
486 case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
487 case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
489 aLineDist.RemoveEntry(LLINESPACE_FIX);
493 else if( uCount == LLINESPACE_FIX)
495 switch (currentContext.GetCombinedContext_DI())
497 case CombinedEnumContext(Application_WriterVariants, Context_Default):
498 case CombinedEnumContext(Application_WriterVariants, Context_Text):
499 case CombinedEnumContext(Application_WriterVariants, Context_Table):
501 aLineDist.InsertEntry(OUString("Fixed"), LLINESPACE_FIX);
505 maLineSpacing.Format();
506 maLineSpacing.StartSelection();
509 void ParaLineSpacingControl::SetAllNoSel()
511 maLineSpacing.SelectItem(1);
512 maLineSpacing.SetNoSelection();
515 IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox )
517 maLineSpacing.SetNoSelection();
518 maLineSpacing.SelectItem(0);
519 maLineSpacing.Format();
520 maLineSpacing.StartSelection();
522 switch( pBox->GetSelectEntryPos() )
524 case LLINESPACE_1:
525 case LLINESPACE_15:
526 case LLINESPACE_2:
527 pActLineDistFld->Enable(false);
528 pActLineDistFld->SetText( "" );
529 break;
531 case LLINESPACE_DURCH:
532 aLineDistAtPercentBox.Hide();
533 pActLineDistFld = &aLineDistAtMetricBox;
534 aLineDistAtMetricBox.SetMin(0);
537 if ( aLineDistAtMetricBox.GetText().isEmpty() )
538 aLineDistAtMetricBox.SetValue(
539 aLineDistAtMetricBox.Normalize( 0 ) );
540 aLineDistAtPercentBox.Hide();
541 pActLineDistFld->Show();
542 pActLineDistFld->Enable();
543 break;
545 case LLINESPACE_MIN:
546 aLineDistAtPercentBox.Hide();
547 pActLineDistFld = &aLineDistAtMetricBox;
548 aLineDistAtMetricBox.SetMin(0);
550 if ( aLineDistAtMetricBox.GetText().isEmpty() )
551 aLineDistAtMetricBox.SetValue(
552 aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP );
553 aLineDistAtPercentBox.Hide();
554 pActLineDistFld->Show();
555 pActLineDistFld->Enable();
556 break;
558 case LLINESPACE_PROP:
559 aLineDistAtMetricBox.Hide();
560 pActLineDistFld = &aLineDistAtPercentBox;
562 if ( aLineDistAtPercentBox.GetText().isEmpty() )
563 aLineDistAtPercentBox.SetValue(
564 aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP );
565 aLineDistAtMetricBox.Hide();
566 pActLineDistFld->Show();
567 pActLineDistFld->Enable();
568 break;
569 case LLINESPACE_FIX:
571 aLineDistAtPercentBox.Hide();
572 pActLineDistFld = &aLineDistAtMetricBox;
573 sal_Int64 nTemp = aLineDistAtMetricBox.GetValue();
574 aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP);
576 if ( aLineDistAtMetricBox.GetValue() != nTemp )
577 SetMetricValue( aLineDistAtMetricBox,
578 FIX_DIST_DEF, SFX_MAPUNIT_TWIP );
579 aLineDistAtPercentBox.Hide();
580 pActLineDistFld->Show();
581 pActLineDistFld->Enable();
583 break;
585 ExecuteLineSpace();
586 return 0;
589 IMPL_LINK_NOARG( ParaLineSpacingControl, LineSPDistAtHdl_Impl )
591 ExecuteLineSpace();
592 return (0L);
595 void ParaLineSpacingControl::ExecuteLineSpace()
597 aLineDist.SaveValue();
598 maLineSpacing.SetNoSelection();
600 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
601 sal_uInt16 nPos = aLineDist.GetSelectEntryPos();
603 switch ( nPos )
605 case LLINESPACE_1:
606 case LLINESPACE_15:
607 case LLINESPACE_2:
609 SetLineSpace( aSpacing, nPos );
610 maPos = nPos;
612 break;
614 case LLINESPACE_PROP:
616 SetLineSpace( aSpacing, nPos,
617 aLineDistAtPercentBox.Denormalize(
618 (long)aLineDistAtPercentBox.GetValue() ) );
619 maPos = nPos;
620 maValue =aLineDistAtPercentBox.GetValue();
622 break;
624 case LLINESPACE_MIN:
625 case LLINESPACE_DURCH:
626 case LLINESPACE_FIX:
628 SetLineSpace( aSpacing, nPos,
629 GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) );
630 maPos = nPos;
631 maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit );
633 break;
635 default:
636 OSL_ENSURE(false, "error!!");
637 break;
640 mpBindings->GetDispatcher()->Execute(
641 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
643 mbUseLineSPCustom = USE_CUSTOM;
646 void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace,
647 int eSpace, long lValue )
649 switch ( eSpace )
651 case LLINESPACE_1:
652 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
653 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
654 break;
656 case LLINESPACE_15:
657 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
658 rLineSpace.SetPropLineSpace( LINESPACE_15 );
659 break;
661 case LLINESPACE_2:
662 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
663 rLineSpace.SetPropLineSpace( LINESPACE_2 );
664 break;
666 case LLINESPACE_PROP:
667 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
668 rLineSpace.SetPropLineSpace( (sal_uInt8)lValue );
669 break;
671 case LLINESPACE_MIN:
672 rLineSpace.SetLineHeight( (sal_uInt16)lValue );
673 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
674 break;
676 case LLINESPACE_DURCH:
677 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
678 rLineSpace.SetInterLineSpace( (sal_uInt16)lValue );
679 break;
681 case LLINESPACE_FIX:
682 rLineSpace.SetLineHeight((sal_uInt16)lValue);
683 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
684 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
685 break;
689 IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl)
691 maLineSpacing.SetNoSelection();
692 bool bClosePop = true;
693 if(pControl == &maLineSpacing)
695 sal_uInt16 iPos = maLineSpacing.GetSelectItemId();
696 switch ( iPos )
698 case 1:
699 ExecuteLineSpacing( false, 0 );
700 break;
701 case 2:
702 ExecuteLineSpacing( false, 3 );
703 break;
704 case 3:
705 ExecuteLineSpacing( false, 1 );
706 break;
707 case 4:
708 ExecuteLineSpacing( false, 2 );
709 break;
710 case 5:
712 if(!(mbLineSPDisable))
714 //maPos = mrParaPropertyPanel.maLinePos;
715 aLineDist.SelectEntryPos( maPos ) ;
716 aLineDist.SaveValue();
717 //maValue = mrParaPropertyPanel.maLineValue;
719 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
720 switch(maPos)
722 case LLINESPACE_1:
723 case LLINESPACE_15:
724 case LLINESPACE_2:
725 SetLineSpace( aSpacing, maPos );
726 break;
728 case LLINESPACE_PROP:
729 SetLineSpace( aSpacing, maPos,
730 aLineDistAtPercentBox.Denormalize( (long)maValue ) );
731 break;
733 case LLINESPACE_MIN:
734 case LLINESPACE_DURCH:
735 case LLINESPACE_FIX:
736 SetLineSpace( aSpacing, maPos, (long)maValue );
737 break;
740 mpBindings->GetDispatcher()->Execute(
741 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
743 ExecuteLineSpacing( USE_CUSTOM, 0 );
745 else
746 bClosePop = false;
748 break;
751 if(bClosePop)
752 mrParaPropertyPanel.EndSpacingPopupMode();
753 return 0;
756 void ParaLineSpacingControl::ExecuteLineSpacing( bool aIsCustom, sal_uInt16 aEntry )
758 if( !aIsCustom )
760 aLineDist.SelectEntryPos( aEntry ) ;
761 aLineDist.SaveValue();
762 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
763 sal_uInt16 nPos = aEntry;
764 if( aEntry == LLINESPACE_PROP )
765 SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) );
766 else
767 SetLineSpace( aSpacing, nPos );
769 mpBindings->GetDispatcher()->Execute(
770 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
773 if( !aIsCustom )
775 mbUseLineSPCustom = DO_NOT_CUSTOM;
776 mrParaPropertyPanel.EndSpacingPopupMode();
778 maLineSpacing.SetNoSelection();
781 }} // end of namespace sidebar
783 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */