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