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 "ParaLineSpacingControl.hxx"
19 : #include "ParaPropertyPanel.hrc"
20 : #include <sfx2/sidebar/ResourceDefinitions.hrc>
21 : #include <svx/dialogs.hrc>
22 : #include <svx/dialmgr.hxx>
23 : #include <unotools/viewoptions.hxx>
24 : #include <editeng/kernitem.hxx>
25 : #include <sfx2/bindings.hxx>
26 : #include <sfx2/dispatch.hxx>
27 : #include <sfx2/sidebar/Theme.hxx>
28 : #include <svtools/unitconv.hxx>
29 :
30 : #define _DEFAULT_LINE_SPACING 200
31 : #define FIX_DIST_DEF 283
32 : #define LINESPACE_1 100
33 : #define LINESPACE_15 150
34 : #define LINESPACE_2 200
35 : #define LINESPACE_115 115
36 :
37 : #define LLINESPACE_1 0
38 : #define LLINESPACE_15 1
39 : #define LLINESPACE_2 2
40 : #define LLINESPACE_PROP 3
41 : #define LLINESPACE_MIN 4
42 : #define LLINESPACE_DURCH 5
43 : #define LLINESPACE_FIX 6
44 :
45 : #define DO_NOT_CUSTOM 0
46 : #define USE_CUSTOM 1
47 :
48 : namespace svx { namespace sidebar {
49 :
50 :
51 0 : ParaLineSpacingControl::ParaLineSpacingControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel)
52 0 : : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_LINESPACING))
53 : , mbUseLineSPCustom (0)
54 : , mbLineSPDisable (0)
55 : , mrParaPropertyPanel(rPanel)
56 : , mpBindings(NULL)
57 : , nMinFixDist(BEGIN_VALUE)
58 : , pActLineDistFld(&aLineDistAtPercentBox)
59 0 : , maLineSpacing(ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) )
60 0 : , maCustomFT ( this, SVX_RES( FT_CUSTOM ) )
61 0 : , maLSpacingFT ( this, SVX_RES( FT_LINE_SPACING ) )
62 0 : , aLineDist( this, SVX_RES( LB_LINE_SPACING ))
63 0 : , maOfFT ( this, SVX_RES( FT_OF ) )
64 0 : , aLineDistAtPercentBox ( this, SVX_RES( ED_SBINDE_LINEDISTPERCENT ) )
65 0 : , aLineDistAtMetricBox ( this, SVX_RES( ED_SBINDE_LINEDISTPOINT ) )
66 0 : , maSpacing1 (SVX_RES(IMG_SPACING1))
67 0 : , maSpacing115 (SVX_RES(IMG_SPACING115))
68 0 : , maSpacing15 (SVX_RES(IMG_SPACING15))
69 0 : , maSpacing2 (SVX_RES(IMG_SPACING2))
70 0 : , maSelSpacing1 (SVX_RES(IMG_SEL_SPACING1))
71 0 : , maSelSpacing115 (SVX_RES(IMG_SEL_SPACING115))
72 0 : , maSelSpacing15 (SVX_RES(IMG_SEL_SPACING15))
73 0 : , maSelSpacing2 (SVX_RES(IMG_SEL_SPACING2))
74 0 : , maImgCus (SVX_RES(IMG_CUSTOM))
75 0 : , maImgCusGrey (SVX_RES(IMG_CUSTOM_GRAY))
76 0 : , maStrCus (SVX_RES(STR_LCVALUE))
77 : , mpImg(NULL)
78 : , mpImgSel(NULL)
79 : , mpStr(NULL)
80 : , mpStrTip(NULL)
81 0 : , maLine(SVX_RES(STR_LSPACING))
82 0 : , maOf(SVX_RES(STR_LS_OF))
83 : , maValue( 0 )
84 0 : , maPos( 0 )
85 : {
86 0 : initial();
87 0 : FreeResource();
88 0 : mpBindings = mrParaPropertyPanel.GetBindings();
89 : // m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric();
90 0 : m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM;
91 0 : }
92 0 : ParaLineSpacingControl::~ParaLineSpacingControl()
93 : {
94 0 : delete[] mpImg;
95 0 : delete[] mpImgSel;
96 0 : delete[] mpStr;
97 0 : delete[] mpStrTip;
98 0 : }
99 :
100 0 : void ParaLineSpacingControl::initial()
101 : {
102 0 : maLineSpacing.SetStyle( maLineSpacing.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
103 :
104 : maLineSpacing.SetControlBackground(
105 0 : GetSettings().GetStyleSettings().GetHighContrastMode()
106 0 : ? GetSettings().GetStyleSettings().GetMenuColor()
107 0 : : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
108 : maLineSpacing.SetColor(
109 0 : GetSettings().GetStyleSettings().GetHighContrastMode()
110 0 : ? GetSettings().GetStyleSettings().GetMenuColor()
111 0 : : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
112 : maLineSpacing.SetBackground(
113 0 : GetSettings().GetStyleSettings().GetHighContrastMode()
114 0 : ? GetSettings().GetStyleSettings().GetMenuColor()
115 0 : : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
116 :
117 0 : mpImg = new Image[4];
118 0 : mpImg[0] = maSpacing1;
119 0 : mpImg[1] = maSpacing115;
120 0 : mpImg[2] = maSpacing15;
121 0 : mpImg[3] = maSpacing2;
122 :
123 0 : mpImgSel = new Image[4];
124 0 : mpImgSel[0] = maSelSpacing1;
125 0 : mpImgSel[1] = maSelSpacing115;
126 0 : mpImgSel[2] = maSelSpacing15;
127 0 : mpImgSel[3] = maSelSpacing2;
128 :
129 0 : mpStr = new XubString[4];
130 0 : mpStr[0] = XubString(SVX_RES(STR_SPACING1));
131 0 : mpStr[1] = XubString(SVX_RES(STR_SPACING115));
132 0 : mpStr[2] = XubString(SVX_RES(STR_SPACING15));
133 0 : mpStr[3] = XubString(SVX_RES(STR_SPACING2));
134 :
135 0 : mpStrTip = new XubString[4];
136 0 : mpStrTip[0] = XubString(SVX_RES(STR_LS_SINGLE));
137 0 : mpStrTip[1] = XubString(SVX_RES(STR_LS_115));
138 0 : mpStrTip[2] = XubString(SVX_RES(STR_LS_15));
139 0 : mpStrTip[3] = XubString(SVX_RES(STR_LS_DOUBLE));
140 0 : for (int i=0;i<4;i++)
141 0 : maLineSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]);
142 :
143 0 : maLineSpacing.AddItem( maImgCus, 0, maStrCus, 0 );
144 :
145 0 : SetAllNoSel();
146 0 : Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl );
147 0 : maLineSpacing.SetSelectHdl(aLink);
148 0 : maLineSpacing.StartSelection();
149 0 : maLineSpacing.Show();
150 :
151 0 : aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl );
152 0 : aLineDist.SetSelectHdl(aLink);
153 0 : aLineDist.SelectEntryPos( LLINESPACE_1 ) ;
154 0 : aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl );
155 0 : aLineDistAtPercentBox.SetModifyHdl( aLink );
156 0 : aLineDistAtMetricBox.SetModifyHdl( aLink );
157 0 : }
158 :
159 :
160 0 : void ParaLineSpacingControl::PopupModeEndCallback()
161 : {
162 0 : if( mbUseLineSPCustom )
163 : {
164 : //maLinePos = mpLineSPPage->maPos;
165 : //maLineValue = mpLineSPPage->maValue;
166 :
167 0 : SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
168 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
169 0 : aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLinePos") );
170 0 : aSeq[0].Value <<= ::rtl::OUString::number(maPos);
171 0 : aWinOpt.SetUserData( aSeq );
172 :
173 0 : SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
174 0 : aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLineValue") );
175 0 : aSeq[0].Value <<= ::rtl::OUString::number(maValue);
176 0 : aWinOpt2.SetUserData( aSeq );
177 : }
178 0 : }
179 :
180 0 : void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext)
181 : {
182 0 : SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
183 0 : if ( aWinOpt.Exists() )
184 : {
185 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
186 0 : ::rtl::OUString aTmp;
187 0 : if ( aSeq.getLength())
188 0 : aSeq[0].Value >>= aTmp;
189 :
190 0 : String aWinData( aTmp );
191 0 : maPos = (sal_uInt16)aWinData.ToInt32();
192 : }
193 :
194 0 : SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
195 0 : if ( aWinOpt2.Exists() )
196 : {
197 0 : ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
198 0 : ::rtl::OUString aTmp;
199 0 : if ( aSeq.getLength())
200 0 : aSeq[0].Value >>= aTmp;
201 :
202 0 : String aWinData( aTmp );
203 0 : maValue = (sal_uInt16)aWinData.ToInt32();
204 : }
205 0 : String sHelpText;
206 0 : switch(maPos)
207 : {
208 : case LLINESPACE_1:
209 0 : sHelpText += mpStrTip[0];
210 0 : break;
211 : case LLINESPACE_15:
212 0 : sHelpText += mpStrTip[2];
213 0 : break;
214 : case LLINESPACE_2:
215 0 : sHelpText += mpStrTip[3];
216 0 : break;
217 : case LLINESPACE_PROP:
218 0 : sHelpText +=maLine;
219 0 : sHelpText.Append(String("Proportion: ", 12, RTL_TEXTENCODING_ASCII_US));
220 0 : sHelpText += maOf;
221 0 : sHelpText.Append( OUString::number( maValue ));
222 0 : break;
223 : case LLINESPACE_MIN:
224 0 : sHelpText += maLine;
225 0 : sHelpText.Append(String("At Least: ", 10, RTL_TEXTENCODING_ASCII_US));
226 0 : sHelpText += maOf;
227 0 : sHelpText.Append( OUString::number( maValue ));
228 0 : break;
229 : case LLINESPACE_DURCH:
230 0 : sHelpText += maLine;
231 0 : sHelpText.Append(String("Leading: ", 9, RTL_TEXTENCODING_ASCII_US));
232 0 : sHelpText += maOf;
233 0 : sHelpText.Append( OUString::number( maValue ));
234 0 : break;
235 : case LLINESPACE_FIX:
236 0 : sHelpText += maLine;
237 0 : sHelpText.Append(String("Fixed: ", 7, RTL_TEXTENCODING_ASCII_US));
238 0 : sHelpText += maOf;
239 0 : sHelpText.Append( OUString::number( maValue ));
240 0 : break;
241 : }
242 0 : if( !aWinOpt.Exists() && !aWinOpt2.Exists() )
243 0 : mbLineSPDisable = sal_True;
244 : else
245 0 : mbLineSPDisable = sal_False;
246 :
247 0 : if( mbLineSPDisable )
248 0 : maLineSpacing.ReplaceItemImages(5, maImgCusGrey,0);
249 : else
250 : {
251 0 : maLineSpacing.ReplaceItemImages(5, maImgCus,0);
252 0 : maLineSpacing.SetItemText(5,sHelpText);
253 : }
254 :
255 0 : SfxItemState eState = currSPState;
256 :
257 0 : SetFieldUnit( aLineDistAtMetricBox, currMetricUnit );
258 :
259 : // mpLineSPPage->SetAllNoSel();
260 0 : aLineDist.Enable();
261 0 : pActLineDistFld->Enable();
262 0 : pActLineDistFld->SetText( String() );
263 : //bool bValueSetFocus = sal_False; //wj
264 :
265 0 : if( eState >= SFX_ITEM_AVAILABLE )
266 : {
267 : // SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric();
268 0 : SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM;
269 0 : m_eLNSpaceUnit = eUnit;
270 :
271 0 : switch( currSPItem->GetLineSpaceRule() )
272 : {
273 : case SVX_LINE_SPACE_AUTO:
274 : {
275 0 : SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule();
276 :
277 0 : switch( eInter )
278 : {
279 : case SVX_INTER_LINE_SPACE_OFF:
280 : {
281 0 : aLineDist.SelectEntryPos( LLINESPACE_1 );
282 0 : pActLineDistFld->Disable();
283 0 : pActLineDistFld->SetText( String() );
284 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
285 0 : if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
286 : {
287 0 : maLineSpacing.SelectItem(1);
288 : //bValueSetFocus = sal_True; //wj
289 : }
290 : }
291 0 : break;
292 :
293 : case SVX_INTER_LINE_SPACE_PROP:
294 : {
295 0 : if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
296 : {
297 0 : aLineDist.SelectEntryPos( LLINESPACE_1 );
298 0 : pActLineDistFld->Disable();
299 0 : pActLineDistFld->SetText( String() );
300 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
301 0 : maLineSpacing.SelectItem(1);
302 : //bValueSetFocus = sal_True; //wj
303 0 : break;
304 : }
305 0 : if ( LINESPACE_15 == currSPItem->GetPropLineSpace() )
306 : {
307 0 : aLineDist.SelectEntryPos( LLINESPACE_15 );
308 0 : pActLineDistFld->Disable();
309 0 : pActLineDistFld->SetText( String() );
310 :
311 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
312 0 : maLineSpacing.SelectItem(3);
313 : //bValueSetFocus = sal_True; //wj
314 0 : break;
315 : }
316 0 : if ( LINESPACE_2 == currSPItem->GetPropLineSpace() )
317 : {
318 0 : aLineDist.SelectEntryPos( LLINESPACE_2 );
319 0 : pActLineDistFld->Disable();
320 0 : pActLineDistFld->SetText( String() );
321 :
322 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
323 0 : maLineSpacing.SelectItem(4);
324 : //bValueSetFocus = sal_True; //wj
325 0 : break;
326 : }
327 :
328 0 : aLineDist.SelectEntryPos( LLINESPACE_PROP );
329 0 : if(pActLineDistFld != &(aLineDistAtPercentBox))
330 : {
331 0 : pActLineDistFld->Disable();
332 0 : pActLineDistFld->Hide();
333 0 : pActLineDistFld = &(aLineDistAtPercentBox);
334 : }
335 : else
336 : {
337 0 : pActLineDistFld = &(aLineDistAtMetricBox);
338 0 : pActLineDistFld->Disable();
339 0 : pActLineDistFld->Hide();
340 0 : pActLineDistFld = &(aLineDistAtPercentBox);
341 : }
342 0 : pActLineDistFld->Enable();
343 0 : pActLineDistFld->Show();
344 : aLineDistAtPercentBox.
345 : SetValue( aLineDistAtPercentBox.Normalize(
346 0 : currSPItem->GetPropLineSpace() ) );
347 :
348 0 : if( currSPItem->GetPropLineSpace() == LINESPACE_115 )
349 : {
350 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
351 0 : maLineSpacing.SelectItem(2);
352 : //bValueSetFocus = sal_True; //wj
353 : }
354 : else
355 : {
356 0 : mbUseLineSPCustom = USE_CUSTOM;
357 0 : maLineSpacing.SetNoSelection();
358 0 : maLineSpacing.SelectItem(0);
359 : }
360 : }
361 0 : break;
362 :
363 : case SVX_INTER_LINE_SPACE_FIX:
364 : {
365 0 : if(pActLineDistFld != &(aLineDistAtMetricBox))
366 : {
367 0 : pActLineDistFld->Disable();
368 0 : pActLineDistFld->Hide();
369 0 : pActLineDistFld = &(aLineDistAtMetricBox);
370 : }
371 : else
372 : {
373 0 : pActLineDistFld = &(aLineDistAtPercentBox);
374 0 : pActLineDistFld->Disable();
375 0 : pActLineDistFld->Hide();
376 0 : pActLineDistFld = &(aLineDistAtMetricBox);
377 : }
378 0 : pActLineDistFld->Enable();
379 0 : pActLineDistFld->Show();
380 0 : maLineSpacing.SetNoSelection();
381 0 : maLineSpacing.SelectItem(0);
382 :
383 : SetMetricValue( aLineDistAtMetricBox,
384 0 : currSPItem->GetInterLineSpace(), eUnit );
385 0 : aLineDist.SelectEntryPos( LLINESPACE_DURCH );
386 :
387 0 : mbUseLineSPCustom = USE_CUSTOM;
388 : }
389 0 : break;
390 : default:
391 0 : break;
392 : }
393 : }
394 0 : break;
395 : case SVX_LINE_SPACE_FIX:
396 : {
397 0 : if(pActLineDistFld != &(aLineDistAtMetricBox))
398 : {
399 0 : pActLineDistFld->Disable();
400 0 : pActLineDistFld->Hide();
401 0 : pActLineDistFld = &(aLineDistAtMetricBox);
402 : }
403 : else
404 : {
405 0 : pActLineDistFld = &(aLineDistAtPercentBox);
406 0 : pActLineDistFld->Disable();
407 0 : pActLineDistFld->Hide();
408 0 : pActLineDistFld = &(aLineDistAtMetricBox);
409 : }
410 0 : pActLineDistFld->Enable();
411 0 : pActLineDistFld->Show();
412 0 : maLineSpacing.SetNoSelection();
413 0 : maLineSpacing.SelectItem(0);
414 :
415 0 : SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
416 0 : aLineDist.SelectEntryPos( LLINESPACE_FIX );
417 :
418 0 : mbUseLineSPCustom = USE_CUSTOM;
419 : }
420 0 : break;
421 :
422 : case SVX_LINE_SPACE_MIN:
423 : {
424 0 : if(pActLineDistFld != &(aLineDistAtMetricBox))
425 : {
426 0 : pActLineDistFld->Disable();
427 0 : pActLineDistFld->Hide();
428 0 : pActLineDistFld = &(aLineDistAtMetricBox);
429 : }
430 : else
431 : {
432 0 : pActLineDistFld = &(aLineDistAtPercentBox);
433 0 : pActLineDistFld->Disable();
434 0 : pActLineDistFld->Hide();
435 0 : pActLineDistFld = &(aLineDistAtMetricBox);
436 : }
437 0 : pActLineDistFld->Enable();
438 0 : pActLineDistFld->Show();
439 0 : maLineSpacing.SetNoSelection();
440 0 : maLineSpacing.SelectItem(0);
441 :
442 0 : SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
443 0 : aLineDist.SelectEntryPos( LLINESPACE_MIN );
444 0 : mbUseLineSPCustom = USE_CUSTOM;
445 : }
446 0 : break;
447 : default:
448 0 : break;
449 : }
450 : }
451 0 : else if( eState == SFX_ITEM_DISABLED )
452 : {
453 0 : aLineDist.Disable();
454 0 : pActLineDistFld->Enable(sal_False);
455 0 : pActLineDistFld->SetText( String() );
456 0 : maLineSpacing.SetNoSelection();
457 0 : maLineSpacing.SelectItem(0);
458 :
459 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
460 : }
461 : else
462 : {
463 0 : pActLineDistFld->Enable(sal_False);
464 0 : pActLineDistFld->SetText( String() );
465 0 : aLineDist.SetNoSelection();
466 0 : maLineSpacing.SetNoSelection();
467 0 : maLineSpacing.SelectItem(0);
468 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
469 : }
470 :
471 0 : aLineDist.SaveValue();
472 :
473 0 : const sal_uInt16 uCount = aLineDist.GetEntryCount();
474 0 : if( uCount == LLINESPACE_FIX + 1 )
475 : {
476 0 : switch (currentContext.GetCombinedContext_DI())
477 : {
478 : case CombinedEnumContext(Application_DrawImpress, Context_Table):
479 : case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
480 : case CombinedEnumContext(Application_DrawImpress, Context_Draw):
481 : case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
482 : case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
483 : case CombinedEnumContext(Application_Calc, Context_DrawText):
484 : case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
485 : case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
486 : {
487 0 : aLineDist.RemoveEntry(LLINESPACE_FIX);
488 : }
489 : }
490 : }
491 0 : else if( uCount == LLINESPACE_FIX)
492 : {
493 0 : switch (currentContext.GetCombinedContext_DI())
494 : {
495 : case CombinedEnumContext(Application_WriterVariants, Context_Default):
496 : case CombinedEnumContext(Application_WriterVariants, Context_Text):
497 : case CombinedEnumContext(Application_WriterVariants, Context_Table):
498 : {
499 0 : aLineDist.InsertEntry(OUString("Fixed"), LLINESPACE_FIX);
500 : }
501 : }
502 : }
503 0 : maLineSpacing.Format();
504 0 : maLineSpacing.StartSelection();
505 0 : }
506 :
507 0 : void ParaLineSpacingControl::SetAllNoSel()
508 : {
509 0 : maLineSpacing.SelectItem(1);
510 0 : maLineSpacing.SetNoSelection();
511 0 : }
512 :
513 0 : IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox )
514 : {
515 0 : maLineSpacing.SetNoSelection();
516 0 : maLineSpacing.SelectItem(0);
517 0 : maLineSpacing.Format();
518 0 : maLineSpacing.StartSelection();
519 :
520 0 : switch( pBox->GetSelectEntryPos() )
521 : {
522 : case LLINESPACE_1:
523 : case LLINESPACE_15:
524 : case LLINESPACE_2:
525 0 : pActLineDistFld->Enable(sal_False);
526 0 : pActLineDistFld->SetText( String() );
527 0 : break;
528 :
529 : case LLINESPACE_DURCH:
530 0 : aLineDistAtPercentBox.Hide();
531 0 : pActLineDistFld = &aLineDistAtMetricBox;
532 0 : aLineDistAtMetricBox.SetMin(0);
533 :
534 :
535 0 : if ( aLineDistAtMetricBox.GetText().isEmpty() )
536 : aLineDistAtMetricBox.SetValue(
537 0 : aLineDistAtMetricBox.Normalize( 0 ) );
538 0 : aLineDistAtPercentBox.Hide();
539 0 : pActLineDistFld->Show();
540 0 : pActLineDistFld->Enable();
541 0 : break;
542 :
543 : case LLINESPACE_MIN:
544 0 : aLineDistAtPercentBox.Hide();
545 0 : pActLineDistFld = &aLineDistAtMetricBox;
546 0 : aLineDistAtMetricBox.SetMin(0);
547 :
548 0 : if ( aLineDistAtMetricBox.GetText().isEmpty() )
549 : aLineDistAtMetricBox.SetValue(
550 0 : aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP );
551 0 : aLineDistAtPercentBox.Hide();
552 0 : pActLineDistFld->Show();
553 0 : pActLineDistFld->Enable();
554 0 : break;
555 :
556 : case LLINESPACE_PROP:
557 0 : aLineDistAtMetricBox.Hide();
558 0 : pActLineDistFld = &aLineDistAtPercentBox;
559 :
560 0 : if ( aLineDistAtPercentBox.GetText().isEmpty() )
561 : aLineDistAtPercentBox.SetValue(
562 0 : aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP );
563 0 : aLineDistAtMetricBox.Hide();
564 0 : pActLineDistFld->Show();
565 0 : pActLineDistFld->Enable();
566 0 : break;
567 : case LLINESPACE_FIX:
568 : {
569 0 : aLineDistAtPercentBox.Hide();
570 0 : pActLineDistFld = &aLineDistAtMetricBox;
571 0 : sal_Int64 nTemp = aLineDistAtMetricBox.GetValue();
572 0 : aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP);
573 :
574 0 : if ( aLineDistAtMetricBox.GetValue() != nTemp )
575 : SetMetricValue( aLineDistAtMetricBox,
576 0 : FIX_DIST_DEF, SFX_MAPUNIT_TWIP );
577 0 : aLineDistAtPercentBox.Hide();
578 0 : pActLineDistFld->Show();
579 0 : pActLineDistFld->Enable();
580 : }
581 0 : break;
582 : }
583 0 : ExecuteLineSpace();
584 0 : return 0;
585 : }
586 :
587 0 : IMPL_LINK_NOARG( ParaLineSpacingControl, LineSPDistAtHdl_Impl )
588 : {
589 0 : ExecuteLineSpace();
590 0 : return (0L);
591 : }
592 :
593 0 : void ParaLineSpacingControl::ExecuteLineSpace()
594 : {
595 0 : aLineDist.SaveValue();
596 0 : maLineSpacing.SetNoSelection();
597 :
598 0 : SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
599 0 : sal_uInt16 nPos = aLineDist.GetSelectEntryPos();
600 :
601 0 : switch ( nPos )
602 : {
603 : case LLINESPACE_1:
604 : case LLINESPACE_15:
605 : case LLINESPACE_2:
606 : {
607 0 : SetLineSpace( aSpacing, nPos );
608 0 : maPos = nPos;
609 : }
610 0 : break;
611 :
612 : case LLINESPACE_PROP:
613 : {
614 : SetLineSpace( aSpacing, nPos,
615 : aLineDistAtPercentBox.Denormalize(
616 0 : (long)aLineDistAtPercentBox.GetValue() ) );
617 0 : maPos = nPos;
618 0 : maValue =aLineDistAtPercentBox.GetValue();
619 : }
620 0 : break;
621 :
622 : case LLINESPACE_MIN:
623 : case LLINESPACE_DURCH:
624 : case LLINESPACE_FIX:
625 : {
626 : SetLineSpace( aSpacing, nPos,
627 0 : GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) );
628 0 : maPos = nPos;
629 0 : maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit );
630 : }
631 0 : break;
632 :
633 : default:
634 : OSL_ENSURE(false, "error!!");
635 0 : break;
636 : }
637 :
638 : mpBindings->GetDispatcher()->Execute(
639 0 : SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
640 :
641 0 : mbUseLineSPCustom = USE_CUSTOM;
642 0 : }
643 :
644 0 : void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace,
645 : int eSpace, long lValue )
646 : {
647 0 : switch ( eSpace )
648 : {
649 : case LLINESPACE_1:
650 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
651 0 : rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
652 0 : break;
653 :
654 : case LLINESPACE_15:
655 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
656 0 : rLineSpace.SetPropLineSpace( LINESPACE_15 );
657 0 : break;
658 :
659 : case LLINESPACE_2:
660 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
661 0 : rLineSpace.SetPropLineSpace( LINESPACE_2 );
662 0 : break;
663 :
664 : case LLINESPACE_PROP:
665 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
666 0 : rLineSpace.SetPropLineSpace( (sal_uInt8)lValue );
667 0 : break;
668 :
669 : case LLINESPACE_MIN:
670 0 : rLineSpace.SetLineHeight( (sal_uInt16)lValue );
671 0 : rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
672 0 : break;
673 :
674 : case LLINESPACE_DURCH:
675 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
676 0 : rLineSpace.SetInterLineSpace( (sal_uInt16)lValue );
677 0 : break;
678 :
679 : case LLINESPACE_FIX:
680 0 : rLineSpace.SetLineHeight((sal_uInt16)lValue);
681 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
682 0 : rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
683 0 : break;
684 : }
685 0 : }
686 :
687 0 : IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl)
688 : {
689 0 : maLineSpacing.SetNoSelection();
690 0 : bool bClosePop = true;
691 0 : if(pControl == &maLineSpacing)
692 : {
693 0 : sal_uInt16 iPos = maLineSpacing.GetSelectItemId();
694 0 : switch ( iPos )
695 : {
696 : case 1:
697 0 : ExecuteLineSpacing( 0, 0 );
698 0 : break;
699 : case 2:
700 0 : ExecuteLineSpacing( 0, 3 );
701 0 : break;
702 : case 3:
703 0 : ExecuteLineSpacing( 0, 1 );
704 0 : break;
705 : case 4:
706 0 : ExecuteLineSpacing( 0, 2 );
707 0 : break;
708 : case 5:
709 : {
710 0 : if(!(mbLineSPDisable))
711 : {
712 : //maPos = mrParaPropertyPanel.maLinePos;
713 0 : aLineDist.SelectEntryPos( maPos ) ;
714 0 : aLineDist.SaveValue();
715 : //maValue = mrParaPropertyPanel.maLineValue;
716 :
717 0 : SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
718 0 : switch(maPos)
719 : {
720 : case LLINESPACE_1:
721 : case LLINESPACE_15:
722 : case LLINESPACE_2:
723 0 : SetLineSpace( aSpacing, maPos );
724 0 : break;
725 :
726 : case LLINESPACE_PROP:
727 : SetLineSpace( aSpacing, maPos,
728 0 : aLineDistAtPercentBox.Denormalize( (long)maValue ) );
729 0 : break;
730 :
731 : case LLINESPACE_MIN:
732 : case LLINESPACE_DURCH:
733 : case LLINESPACE_FIX:
734 0 : SetLineSpace( aSpacing, maPos, (long)maValue );
735 0 : break;
736 : }
737 :
738 : mpBindings->GetDispatcher()->Execute(
739 0 : SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
740 :
741 0 : ExecuteLineSpacing( USE_CUSTOM, 0 );
742 : }
743 : else
744 0 : bClosePop = sal_False;
745 : }
746 0 : break;
747 : }
748 : }
749 0 : if(bClosePop)
750 0 : mrParaPropertyPanel.EndSpacingPopupMode();
751 0 : return 0;
752 : }
753 :
754 0 : void ParaLineSpacingControl::ExecuteLineSpacing( sal_uInt16 aIsCustom, sal_uInt16 aEntry )
755 : {
756 0 : if( !aIsCustom )
757 : {
758 0 : aLineDist.SelectEntryPos( aEntry ) ;
759 0 : aLineDist.SaveValue();
760 0 : SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
761 0 : sal_uInt16 nPos = aEntry;
762 0 : if( aEntry == LLINESPACE_PROP )
763 0 : SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) );
764 : else
765 0 : SetLineSpace( aSpacing, nPos );
766 :
767 : mpBindings->GetDispatcher()->Execute(
768 0 : SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
769 : }
770 :
771 0 : if( !aIsCustom )
772 : {
773 0 : mbUseLineSPCustom = DO_NOT_CUSTOM;
774 0 : mrParaPropertyPanel.EndSpacingPopupMode();
775 : }
776 0 : maLineSpacing.SetNoSelection();
777 0 : }
778 :
779 216 : }} // end of namespace sidebar
780 :
|