1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <hintids.hxx>
21 #include <vcl/msgbox.hxx>
22 #include <sfx2/app.hxx>
23 #include <sfx2/imgmgr.hxx>
24 #include <svx/gallery.hxx>
25 #include <editeng/brushitem.hxx>
26 #include <editeng/lrspitem.hxx>
27 #include <editeng/numitem.hxx>
29 #include <swmodule.hxx>
35 #include <uiitems.hxx>
36 #include <docstyle.hxx>
37 #include <charfmt.hxx>
39 #include <poolfmt.hxx>
40 #include <shellres.hxx>
41 #include <outline.hxx>
43 #include <viewopt.hxx>
48 #include <globals.hrc>
50 #include <SwStyleNameMapper.hxx>
51 #include <svx/svxids.hrc>
52 #include <svx/dialogs.hrc>
53 #include <svl/stritem.hxx>
54 #include <svl/aeitem.hxx>
55 #include <svl/slstitm.hxx>
57 static sal_Bool bLastRelative
= sal_False
;
59 //See cui/uiconfig/ui/numberingpositionpage.ui for effectively a duplicate
60 //dialog to this one, except with a different preview window impl.
61 //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
63 SwNumPositionTabPage::SwNumPositionTabPage(Window
* pParent
,
64 const SfxItemSet
& rSet
)
65 : SfxTabPage(pParent
, "OutlinePositionPage",
66 "modules/swriter/ui/outlinepositionpage.ui", rSet
)
71 , bPreset( sal_False
)
72 , bInInintControl(sal_False
)
73 , bLabelAlignmentPosAndSpaceModeActive( false )
75 get(m_pLevelLB
, "levellb");
76 m_pLevelLB
->EnableMultiSelection(true);
77 get(m_pPositionFrame
, "numberingframe");
78 get(m_pDistBorderFT
, "indent");
79 get(m_pDistBorderMF
, "indentmf");
80 get(m_pRelativeCB
, "relative");
81 get(m_pIndentFT
, "numberingwidth");
82 get(m_pIndentMF
, "numberingwidthmf");
83 get(m_pDistNumFT
, "numdist");
84 get(m_pDistNumMF
, "numdistmf");
85 get(m_pAlignFT
, "numalign");
86 get(m_pAlignLB
, "numalignlb");
88 get(m_pLabelFollowedByFT
, "numfollowedby");
89 get(m_pLabelFollowedByLB
, "numfollowedbylb");
90 get(m_pListtabFT
, "at");
91 get(m_pListtabMF
, "atmf");
92 get(m_pAlign2FT
, "num2align");
93 get(m_pAlign2LB
, "num2alignlb");
94 get(m_pAlignedAtFT
, "alignedat");
95 get(m_pAlignedAtMF
, "alignedatmf");
96 get(m_pIndentAtFT
, "indentat");
97 get(m_pIndentAtMF
, "indentatmf");
98 get(m_pStandardPB
, "standard");
100 get(m_pPreviewWIN
, "preview");
102 SetExchangeSupport();
103 m_pPreviewWIN
->SetBackground(Wallpaper(Color(COL_TRANSPARENT
)));
105 m_pStandardPB
->SetAccessibleRelationMemberOf(m_pPositionFrame
->get_label_widget());
108 m_pRelativeCB
->Check();
109 m_pAlignLB
->SetSelectHdl(LINK(this, SwNumPositionTabPage
, EditModifyHdl
));
110 m_pAlign2LB
->SetSelectHdl(LINK(this, SwNumPositionTabPage
, EditModifyHdl
));
111 for ( sal_uInt16 i
= 0; i
< m_pAlignLB
->GetEntryCount(); ++i
)
113 m_pAlign2LB
->InsertEntry( m_pAlignLB
->GetEntry( i
) );
115 m_pAlign2LB
->SetDropDownLineCount( m_pAlign2LB
->GetEntryCount() );
116 m_pAlign2FT
->SetText( m_pAlignFT
->GetText() );
118 Link aLk
= LINK(this, SwNumPositionTabPage
, DistanceHdl
);
119 m_pDistBorderMF
->SetUpHdl(aLk
);
120 m_pDistNumMF
->SetUpHdl(aLk
);
121 m_pIndentMF
->SetUpHdl(aLk
);
122 m_pDistBorderMF
->SetDownHdl(aLk
);
123 m_pDistNumMF
->SetDownHdl(aLk
);
124 m_pIndentMF
->SetDownHdl(aLk
);
125 m_pDistBorderMF
->SetLoseFocusHdl(aLk
);
126 m_pDistNumMF
->SetLoseFocusHdl(aLk
);
127 m_pIndentMF
->SetLoseFocusHdl(aLk
);
129 m_pLabelFollowedByLB
->SetDropDownLineCount( m_pLabelFollowedByLB
->GetEntryCount() );
130 m_pLabelFollowedByLB
->SetSelectHdl( LINK(this, SwNumPositionTabPage
, LabelFollowedByHdl_Impl
) );
132 aLk
= LINK(this, SwNumPositionTabPage
, ListtabPosHdl_Impl
);
133 m_pListtabMF
->SetUpHdl(aLk
);
134 m_pListtabMF
->SetDownHdl(aLk
);
135 m_pListtabMF
->SetLoseFocusHdl(aLk
);
137 aLk
= LINK(this, SwNumPositionTabPage
, AlignAtHdl_Impl
);
138 m_pAlignedAtMF
->SetUpHdl(aLk
);
139 m_pAlignedAtMF
->SetDownHdl(aLk
);
140 m_pAlignedAtMF
->SetLoseFocusHdl(aLk
);
142 aLk
= LINK(this, SwNumPositionTabPage
, IndentAtHdl_Impl
);
143 m_pIndentAtMF
->SetUpHdl(aLk
);
144 m_pIndentAtMF
->SetDownHdl(aLk
);
145 m_pIndentAtMF
->SetLoseFocusHdl(aLk
);
147 m_pLevelLB
->SetSelectHdl(LINK(this, SwNumPositionTabPage
, LevelHdl
));
148 m_pRelativeCB
->SetClickHdl(LINK(this, SwNumPositionTabPage
, RelativeHdl
));
149 m_pStandardPB
->SetClickHdl(LINK(this, SwNumPositionTabPage
, StandardHdl
));
152 for(sal_uInt16 i
= 1; i
<= MAXLEVEL
; i
++)
153 m_pLevelLB
->InsertEntry(OUString::number(i
));
154 String
sEntry(OUString("1 - "));
155 sEntry
+= OUString::number(MAXLEVEL
);
156 m_pLevelLB
->InsertEntry(sEntry
);
157 m_pLevelLB
->SelectEntry(sEntry
);
159 m_pRelativeCB
->Check(bLastRelative
);
160 m_pPreviewWIN
->SetPositionMode();
163 SwNumPositionTabPage::~SwNumPositionTabPage()
168 void SwNumPositionTabPage::InitControls()
170 bInInintControl
= sal_True
;
171 const bool bRelative
= !bLabelAlignmentPosAndSpaceModeActive
&&
172 m_pRelativeCB
->IsEnabled() && m_pRelativeCB
->IsChecked();
173 const bool bSingleSelection
= m_pLevelLB
->GetSelectEntryCount() == 1 &&
174 USHRT_MAX
!= nActNumLvl
;
176 m_pDistBorderMF
->Enable( !bLabelAlignmentPosAndSpaceModeActive
&&
177 ( bSingleSelection
|| bRelative
|| pOutlineDlg
!= 0 ) );
178 m_pDistBorderFT
->Enable( !bLabelAlignmentPosAndSpaceModeActive
&&
179 ( bSingleSelection
|| bRelative
|| pOutlineDlg
!= 0 ) );
181 bool bSetDistEmpty
= false;
182 bool bSameDistBorderNum
= !bLabelAlignmentPosAndSpaceModeActive
;
183 bool bSameDist
= !bLabelAlignmentPosAndSpaceModeActive
;
184 bool bSameIndent
= !bLabelAlignmentPosAndSpaceModeActive
;
185 bool bSameAdjust
= true;
187 bool bSameLabelFollowedBy
= bLabelAlignmentPosAndSpaceModeActive
;
188 bool bSameListtab
= bLabelAlignmentPosAndSpaceModeActive
;
189 bool bSameAlignAt
= bLabelAlignmentPosAndSpaceModeActive
;
190 bool bSameIndentAt
= bLabelAlignmentPosAndSpaceModeActive
;
192 const SwNumFmt
* aNumFmtArr
[MAXLEVEL
];
193 sal_uInt16 nMask
= 1;
194 sal_uInt16 nLvl
= USHRT_MAX
;
195 long nFirstBorderTextRelative
= -1;
196 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++)
198 aNumFmtArr
[i
] = &pActNum
->Get(i
);
199 if(nActNumLvl
& nMask
)
201 if(USHRT_MAX
== nLvl
)
208 bSameAdjust
&= aNumFmtArr
[i
]->GetNumAdjust() == aNumFmtArr
[nLvl
]->GetNumAdjust();
209 if ( !bLabelAlignmentPosAndSpaceModeActive
)
213 if(nFirstBorderTextRelative
== -1)
214 nFirstBorderTextRelative
=
215 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
216 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
218 bSameDistBorderNum
&= nFirstBorderTextRelative
==
219 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
220 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
225 bSameDistBorderNum
&=
226 aNumFmtArr
[i
]->GetAbsLSpace() - aNumFmtArr
[i
]->GetFirstLineOffset() ==
227 aNumFmtArr
[i
- 1]->GetAbsLSpace() - aNumFmtArr
[i
- 1]->GetFirstLineOffset();
230 bSameDist
&= aNumFmtArr
[i
]->GetCharTextDistance() == aNumFmtArr
[nLvl
]->GetCharTextDistance();
231 bSameIndent
&= aNumFmtArr
[i
]->GetFirstLineOffset() == aNumFmtArr
[nLvl
]->GetFirstLineOffset();
235 bSameLabelFollowedBy
&=
236 aNumFmtArr
[i
]->GetLabelFollowedBy() == aNumFmtArr
[nLvl
]->GetLabelFollowedBy();
238 aNumFmtArr
[i
]->GetListtabPos() == aNumFmtArr
[nLvl
]->GetListtabPos();
240 ( ( aNumFmtArr
[i
]->GetIndentAt() + aNumFmtArr
[i
]->GetFirstLineIndent() )
241 == ( aNumFmtArr
[nLvl
]->GetIndentAt() + aNumFmtArr
[nLvl
]->GetFirstLineIndent() ) );
243 aNumFmtArr
[i
]->GetIndentAt() == aNumFmtArr
[nLvl
]->GetIndentAt();
250 if (MAXLEVEL
<= nLvl
)
252 OSL_ENSURE(false, "cannot happen.");
255 if(bSameDistBorderNum
)
260 nDistBorderNum
= (long)aNumFmtArr
[nLvl
]->GetAbsLSpace()+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
262 nDistBorderNum
-= (long)aNumFmtArr
[nLvl
- 1]->GetAbsLSpace()+ aNumFmtArr
[nLvl
- 1]->GetFirstLineOffset();
266 nDistBorderNum
= (long)aNumFmtArr
[nLvl
]->GetAbsLSpace()+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
268 m_pDistBorderMF
->SetValue(m_pDistBorderMF
->Normalize(nDistBorderNum
),FUNIT_TWIP
);
271 bSetDistEmpty
= sal_True
;
274 m_pDistNumMF
->SetValue(m_pDistNumMF
->Normalize(aNumFmtArr
[nLvl
]->GetCharTextDistance()), FUNIT_TWIP
);
276 m_pDistNumMF
->SetText(aEmptyStr
);
278 m_pIndentMF
->SetValue(m_pIndentMF
->Normalize(-aNumFmtArr
[nLvl
]->GetFirstLineOffset()), FUNIT_TWIP
);
280 m_pIndentMF
->SetText(aEmptyStr
);
284 sal_uInt16 nPos
= 1; // centered
285 if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_LEFT
)
287 else if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_RIGHT
)
289 m_pAlignLB
->SelectEntryPos(nPos
);
290 m_pAlign2LB
->SelectEntryPos( nPos
);
294 m_pAlignLB
->SetNoSelection();
295 m_pAlign2LB
->SetNoSelection();
298 if ( bSameLabelFollowedBy
)
300 sal_uInt16 nPos
= 0; // LISTTAB
301 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
305 else if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING
)
309 m_pLabelFollowedByLB
->SelectEntryPos( nPos
);
313 m_pLabelFollowedByLB
->SetNoSelection();
316 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB
)
318 m_pListtabFT
->Enable( true );
319 m_pListtabMF
->Enable( true );
322 m_pListtabMF
->SetValue(m_pListtabMF
->Normalize(aNumFmtArr
[nLvl
]->GetListtabPos()),FUNIT_TWIP
);
326 m_pListtabMF
->SetText(aEmptyStr
);
331 m_pListtabFT
->Enable( false );
332 m_pListtabMF
->Enable( false );
333 m_pListtabMF
->SetText(aEmptyStr
);
338 m_pAlignedAtMF
->SetValue(
339 m_pAlignedAtMF
->Normalize( aNumFmtArr
[nLvl
]->GetIndentAt() +
340 aNumFmtArr
[nLvl
]->GetFirstLineIndent()),
345 m_pAlignedAtMF
->SetText(aEmptyStr
);
350 m_pIndentAtMF
->SetValue(
351 m_pIndentAtMF
->Normalize( aNumFmtArr
[nLvl
]->GetIndentAt()), FUNIT_TWIP
);
355 m_pIndentAtMF
->SetText(aEmptyStr
);
358 if(sal_True
== bSetDistEmpty
)
359 m_pDistBorderMF
->SetText(aEmptyStr
);
361 bInInintControl
= sal_False
;
364 void SwNumPositionTabPage::ActivatePage(const SfxItemSet
& )
366 const SfxPoolItem
* pItem
;
367 sal_uInt16 nTmpNumLvl
=
368 pOutlineDlg
? pOutlineDlg
->GetActNumLevel() : 0;
369 const SfxItemSet
* pExampleSet
= GetTabDialog()->GetExampleSet();
370 if(pExampleSet
&& pExampleSet
->GetItemState(FN_PARAM_NUM_PRESET
, sal_False
, &pItem
))
372 bPreset
= ((const SfxBoolItem
*)pItem
)->GetValue();
374 bModified
= (!pActNum
->GetNumFmt( 0 ) || bPreset
);
375 if(*pActNum
!= *pSaveNum
||
376 nActNumLvl
!= nTmpNumLvl
)
378 *pActNum
= *pSaveNum
;
379 nActNumLvl
= nTmpNumLvl
;
380 sal_uInt16 nMask
= 1;
381 m_pLevelLB
->SetUpdateMode(sal_False
);
382 m_pLevelLB
->SetNoSelection();
383 m_pLevelLB
->SelectEntryPos( MAXLEVEL
, nActNumLvl
== USHRT_MAX
);
384 if(nActNumLvl
!= USHRT_MAX
)
385 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++)
387 if(nActNumLvl
& nMask
)
388 m_pLevelLB
->SelectEntryPos( i
, sal_True
);
391 m_pLevelLB
->SetUpdateMode(sal_True
);
393 InitPosAndSpaceMode();
394 ShowControlsDependingOnPosAndSpaceMode();
398 m_pRelativeCB
->Enable(1 != nActNumLvl
);
399 m_pPreviewWIN
->Invalidate();
402 int SwNumPositionTabPage::DeactivatePage(SfxItemSet
*_pSet
)
404 SwOutlineTabDialog::SetActNumLevel(nActNumLvl
);
411 sal_Bool
SwNumPositionTabPage::FillItemSet( SfxItemSet
& rSet
)
414 *pOutlineDlg
->GetNumRule() = *pActNum
;
415 else if(bModified
&& pActNum
)
417 *pSaveNum
= *pActNum
;
418 rSet
.Put(SwUINumRuleItem( *pSaveNum
));
419 rSet
.Put(SfxBoolItem(FN_PARAM_NUM_PRESET
, sal_False
));
424 void SwNumPositionTabPage::Reset( const SfxItemSet
& rSet
)
426 const SfxPoolItem
* pItem
;
429 pSaveNum
= pOutlineDlg
->GetNumRule();
430 m_pLevelLB
->EnableMultiSelection(sal_False
);
432 else if(SFX_ITEM_SET
== rSet
.GetItemState(FN_PARAM_ACT_NUMBER
, sal_False
, &pItem
))
433 pSaveNum
= ((SwUINumRuleItem
*)pItem
)->GetNumRule();
435 nActNumLvl
= SwOutlineTabDialog::GetActNumLevel();
436 sal_uInt16 nMask
= 1;
437 m_pLevelLB
->SetUpdateMode(sal_False
);
438 m_pLevelLB
->SetNoSelection();
439 if(nActNumLvl
== USHRT_MAX
)
441 m_pLevelLB
->SelectEntryPos( MAXLEVEL
, sal_True
);
444 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++)
446 if(nActNumLvl
& nMask
)
447 m_pLevelLB
->SelectEntryPos( i
, sal_True
);
450 m_pLevelLB
->SetUpdateMode(sal_True
);
453 pActNum
= new SwNumRule(*pSaveNum
);
454 else if(*pSaveNum
!= *pActNum
)
455 *pActNum
= *pSaveNum
;
456 m_pPreviewWIN
->SetNumRule(pActNum
);
457 InitPosAndSpaceMode();
458 ShowControlsDependingOnPosAndSpaceMode();
460 bModified
= sal_False
;
463 void SwNumPositionTabPage::InitPosAndSpaceMode()
467 OSL_FAIL( "<SwNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
471 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode
=
472 SvxNumberFormat::LABEL_ALIGNMENT
;
473 sal_uInt16 nMask
= 1;
474 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
476 if(nActNumLvl
& nMask
)
478 SvxNumberFormat
aNumFmt( pActNum
->Get(i
) );
479 ePosAndSpaceMode
= aNumFmt
.GetPositionAndSpaceMode();
480 if ( ePosAndSpaceMode
== SvxNumberFormat::LABEL_ALIGNMENT
)
488 bLabelAlignmentPosAndSpaceModeActive
=
489 ePosAndSpaceMode
== SvxNumberFormat::LABEL_ALIGNMENT
;
492 void SwNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
494 m_pDistBorderFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
495 m_pDistBorderMF
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
496 m_pRelativeCB
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
497 m_pIndentFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
498 m_pIndentMF
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
499 m_pDistNumFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
500 m_pDistNumMF
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
501 m_pAlignFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
502 m_pAlignLB
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
504 m_pLabelFollowedByFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
505 m_pLabelFollowedByLB
->Show( bLabelAlignmentPosAndSpaceModeActive
);
506 m_pListtabFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
507 m_pListtabMF
->Show( bLabelAlignmentPosAndSpaceModeActive
);
508 m_pAlign2FT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
509 m_pAlign2LB
->Show( bLabelAlignmentPosAndSpaceModeActive
);
510 m_pAlignedAtFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
511 m_pAlignedAtMF
->Show( bLabelAlignmentPosAndSpaceModeActive
);
512 m_pIndentAtFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
513 m_pIndentAtMF
->Show( bLabelAlignmentPosAndSpaceModeActive
);
516 SfxTabPage
* SwNumPositionTabPage::Create( Window
* pParent
,
517 const SfxItemSet
& rAttrSet
)
519 return new SwNumPositionTabPage(pParent
, rAttrSet
);
522 void SwNumPositionTabPage::SetWrtShell(SwWrtShell
* pSh
)
526 const SwTwips nWidth
= pWrtSh
->GetAnyCurRect(RECT_FRM
).Width();
528 m_pDistBorderMF
->SetMax(m_pDistBorderMF
->Normalize( nWidth
), FUNIT_TWIP
);
529 m_pDistNumMF
->SetMax(m_pDistNumMF
->Normalize( nWidth
), FUNIT_TWIP
);
530 m_pIndentMF
->SetMax(m_pIndentMF
->Normalize( nWidth
), FUNIT_TWIP
);
531 m_pListtabMF
->SetMax(m_pListtabMF
->Normalize( nWidth
), FUNIT_TWIP
);
532 m_pAlignedAtMF
->SetMax(m_pAlignedAtMF
->Normalize( nWidth
), FUNIT_TWIP
);
533 m_pIndentAtMF
->SetMax(m_pIndentAtMF
->Normalize( nWidth
), FUNIT_TWIP
);
534 const SwTwips nLast2
= nWidth
/2;
535 m_pDistBorderMF
->SetLast( m_pDistBorderMF
->Normalize( nLast2
), FUNIT_TWIP
);
536 m_pDistNumMF
->SetLast(m_pDistNumMF
->Normalize( nLast2
), FUNIT_TWIP
);
537 m_pIndentMF
->SetLast(m_pIndentMF
->Normalize( nLast2
), FUNIT_TWIP
);
538 m_pListtabMF
->SetLast(m_pListtabMF
->Normalize( nLast2
), FUNIT_TWIP
);
539 m_pAlignedAtMF
->SetLast(m_pAlignedAtMF
->Normalize( nLast2
), FUNIT_TWIP
);
540 m_pIndentAtMF
->SetLast(m_pIndentAtMF
->Normalize( nLast2
), FUNIT_TWIP
);
542 const SwRect
& rPrtRect
= pWrtSh
->GetAnyCurRect(RECT_PAGE
);
543 m_pPreviewWIN
->SetPageWidth(rPrtRect
.Width());
544 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &pWrtSh
->GetView()));
545 if(eMetric
== FUNIT_MM
)
547 m_pDistBorderMF
->SetDecimalDigits(1);
548 m_pDistNumMF
->SetDecimalDigits(1);
549 m_pIndentMF
->SetDecimalDigits(1);
550 m_pListtabMF
->SetDecimalDigits(1);
551 m_pAlignedAtMF
->SetDecimalDigits(1);
552 m_pIndentAtMF
->SetDecimalDigits(1);
554 m_pDistBorderMF
->SetUnit( eMetric
);
555 m_pDistNumMF
->SetUnit( eMetric
);
556 m_pIndentMF
->SetUnit( eMetric
);
557 m_pListtabMF
->SetUnit( eMetric
);
558 m_pAlignedAtMF
->SetUnit( eMetric
);
559 m_pIndentAtMF
->SetUnit( eMetric
);
562 IMPL_LINK_NOARG(SwNumPositionTabPage
, EditModifyHdl
)
564 sal_uInt16 nMask
= 1;
565 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++)
567 if(nActNumLvl
& nMask
)
569 SwNumFmt
aNumFmt(pActNum
->Get(i
));
571 const sal_uInt16 nPos
= m_pAlignLB
->IsVisible()
572 ? m_pAlignLB
->GetSelectEntryPos()
573 : m_pAlign2LB
->GetSelectEntryPos();
574 SvxAdjust eAdjust
= SVX_ADJUST_CENTER
;
576 eAdjust
= SVX_ADJUST_LEFT
;
578 eAdjust
= SVX_ADJUST_RIGHT
;
579 aNumFmt
.SetNumAdjust( eAdjust
);
580 pActNum
->Set(i
, aNumFmt
);
588 IMPL_LINK( SwNumPositionTabPage
, LevelHdl
, ListBox
*, pBox
)
590 sal_uInt16 nSaveNumLvl
= nActNumLvl
;
592 if(pBox
->IsEntryPosSelected( MAXLEVEL
) &&
593 (pBox
->GetSelectEntryCount() == 1 || nSaveNumLvl
!= 0xffff))
596 pBox
->SetUpdateMode(sal_False
);
597 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++ )
598 pBox
->SelectEntryPos( i
, sal_False
);
599 pBox
->SetUpdateMode(sal_True
);
601 else if(pBox
->GetSelectEntryCount())
603 sal_uInt16 nMask
= 1;
604 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++ )
606 if(pBox
->IsEntryPosSelected( i
))
610 pBox
->SelectEntryPos( MAXLEVEL
, sal_False
);
614 nActNumLvl
= nSaveNumLvl
;
615 sal_uInt16 nMask
= 1;
616 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++ )
618 if(nActNumLvl
& nMask
)
620 pBox
->SelectEntryPos(i
);
626 m_pRelativeCB
->Enable(1 != nActNumLvl
);
628 InitPosAndSpaceMode();
629 ShowControlsDependingOnPosAndSpaceMode();
634 IMPL_LINK( SwNumPositionTabPage
, DistanceHdl
, MetricField
*, pFld
)
638 long nValue
= static_cast< long >(pFld
->Denormalize(pFld
->GetValue(FUNIT_TWIP
)));
639 sal_uInt16 nMask
= 1;
640 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++)
642 if(nActNumLvl
& nMask
)
644 SwNumFmt
aNumFmt( pActNum
->Get( i
) );
645 if(pFld
== m_pDistBorderMF
)
648 if(m_pRelativeCB
->IsChecked() && m_pRelativeCB
->IsEnabled())
652 long nTmp
= aNumFmt
.GetFirstLineOffset();
653 aNumFmt
.SetAbsLSpace( sal_uInt16(nValue
- nTmp
));
657 long nTmp
= pActNum
->Get( i
- 1 ).GetAbsLSpace() +
658 pActNum
->Get( i
- 1 ).GetFirstLineOffset() -
659 pActNum
->Get( i
).GetFirstLineOffset();
661 aNumFmt
.SetAbsLSpace( sal_uInt16(nValue
+ nTmp
));
666 aNumFmt
.SetAbsLSpace( (short)nValue
- aNumFmt
.GetFirstLineOffset());
669 else if (pFld
== m_pDistNumMF
)
671 aNumFmt
.SetCharTextDistance( (short)nValue
);
673 else if (pFld
== m_pIndentMF
)
675 // now AbsLSpace also has to be modified by FirstLineOffset
676 long nDiff
= nValue
+ aNumFmt
.GetFirstLineOffset();
677 long nAbsLSpace
= aNumFmt
.GetAbsLSpace();
678 aNumFmt
.SetAbsLSpace(sal_uInt16(nAbsLSpace
+ nDiff
));
679 aNumFmt
.SetFirstLineOffset( -(short)nValue
);
682 pActNum
->Set( i
, aNumFmt
);
688 if(!m_pDistBorderMF
->IsEnabled())
689 m_pDistBorderMF
->SetText(aEmptyStr
);
694 IMPL_LINK( SwNumPositionTabPage
, RelativeHdl
, CheckBox
*, pBox
)
696 sal_Bool bOn
= pBox
->IsChecked();
697 bool bSingleSelection
= m_pLevelLB
->GetSelectEntryCount() == 1 && USHRT_MAX
!= nActNumLvl
;
698 bool bSetValue
= false;
700 if(bOn
|| bSingleSelection
)
702 sal_uInt16 nMask
= 1;
705 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++)
707 if(nActNumLvl
& nMask
)
709 const SwNumFmt
&rNumFmt
= pActNum
->Get(i
);
712 nValue
= rNumFmt
.GetAbsLSpace();
714 nValue
-= pActNum
->Get(i
- 1).GetAbsLSpace();
717 bSetValue
= nValue
== rNumFmt
.GetAbsLSpace() - pActNum
->Get(i
- 1).GetAbsLSpace();
725 m_pDistBorderMF
->SetValue(m_pDistBorderMF
->Normalize(nValue
), FUNIT_TWIP
);
727 m_pDistBorderMF
->SetText(aEmptyStr
);
728 m_pDistBorderMF
->Enable(bOn
|| bSingleSelection
||0 != pOutlineDlg
);
733 IMPL_LINK_NOARG(SwNumPositionTabPage
, LabelFollowedByHdl_Impl
)
735 // determine value to be set at the chosen list levels
736 SvxNumberFormat::LabelFollowedBy eLabelFollowedBy
= SvxNumberFormat::LISTTAB
;
738 const sal_uInt16 nPos
= m_pLabelFollowedByLB
->GetSelectEntryPos();
741 eLabelFollowedBy
= SvxNumberFormat::SPACE
;
743 else if ( nPos
== 2 )
745 eLabelFollowedBy
= SvxNumberFormat::NOTHING
;
749 // set value at the chosen list levels
750 bool bSameListtabPos
= true;
751 sal_uInt16 nFirstLvl
= USHRT_MAX
;
752 sal_uInt16 nMask
= 1;
753 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
755 if ( nActNumLvl
& nMask
)
757 SwNumFmt
aNumFmt( pActNum
->Get(i
) );
758 aNumFmt
.SetLabelFollowedBy( eLabelFollowedBy
);
759 pActNum
->Set( i
, aNumFmt
);
761 if ( nFirstLvl
== USHRT_MAX
)
767 bSameListtabPos
&= aNumFmt
.GetListtabPos() ==
768 pActNum
->Get( nFirstLvl
).GetListtabPos();
774 // enable/disable metric field for list tab stop position depending on
775 // selected item following the list label.
776 m_pListtabFT
->Enable( eLabelFollowedBy
== SvxNumberFormat::LISTTAB
);
777 m_pListtabMF
->Enable( eLabelFollowedBy
== SvxNumberFormat::LISTTAB
);
778 if ( bSameListtabPos
&& eLabelFollowedBy
== SvxNumberFormat::LISTTAB
)
780 m_pListtabMF
->SetValue(
781 m_pListtabMF
->Normalize( pActNum
->Get( nFirstLvl
).GetListtabPos() ),
786 m_pListtabMF
->SetText( String() );
794 IMPL_LINK( SwNumPositionTabPage
, ListtabPosHdl_Impl
, MetricField
*, pFld
)
796 // determine value to be set at the chosen list levels
797 const long nValue
= static_cast< long >(pFld
->Denormalize(pFld
->GetValue(FUNIT_TWIP
)));
799 // set value at the chosen list levels
800 sal_uInt16 nMask
= 1;
801 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
803 if ( nActNumLvl
& nMask
)
805 SwNumFmt
aNumFmt( pActNum
->Get(i
) );
806 aNumFmt
.SetListtabPos( nValue
);
807 pActNum
->Set( i
, aNumFmt
);
817 IMPL_LINK( SwNumPositionTabPage
, AlignAtHdl_Impl
, MetricField
*, pFld
)
819 // determine value to be set at the chosen list levels
820 const long nValue
= static_cast< long >(pFld
->Denormalize(pFld
->GetValue(FUNIT_TWIP
)));
822 // set value at the chosen list levels
823 sal_uInt16 nMask
= 1;
824 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
826 if ( nActNumLvl
& nMask
)
828 SwNumFmt
aNumFmt( pActNum
->Get(i
) );
829 const long nFirstLineIndent
= nValue
- aNumFmt
.GetIndentAt();
830 aNumFmt
.SetFirstLineIndent( nFirstLineIndent
);
831 pActNum
->Set( i
, aNumFmt
);
841 IMPL_LINK( SwNumPositionTabPage
, IndentAtHdl_Impl
, MetricField
*, pFld
)
843 // determine value to be set at the chosen list levels
844 const long nValue
= static_cast< long >(pFld
->Denormalize(pFld
->GetValue(FUNIT_TWIP
)));
846 // set value at the chosen list levels
847 sal_uInt16 nMask
= 1;
848 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
850 if ( nActNumLvl
& nMask
)
852 SwNumFmt
aNumFmt( pActNum
->Get(i
) );
853 const long nAlignedAt
= aNumFmt
.GetIndentAt() +
854 aNumFmt
.GetFirstLineIndent();
855 aNumFmt
.SetIndentAt( nValue
);
856 const long nNewFirstLineIndent
= nAlignedAt
- nValue
;
857 aNumFmt
.SetFirstLineIndent( nNewFirstLineIndent
);
858 pActNum
->Set( i
, aNumFmt
);
868 IMPL_LINK_NOARG(SwNumPositionTabPage
, StandardHdl
)
870 sal_uInt16 nMask
= 1;
871 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; i
++)
873 if(nActNumLvl
& nMask
)
875 SwNumFmt
aNumFmt( pActNum
->Get( i
) );
876 SwNumRule
aTmpNumRule( pWrtSh
->GetUniqueNumRuleName(),
877 aNumFmt
.GetPositionAndSpaceMode(),
878 pOutlineDlg
? OUTLINE_RULE
: NUM_RULE
);
879 SwNumFmt
aTempFmt(aTmpNumRule
.Get( i
));
880 aNumFmt
.SetPositionAndSpaceMode( aTempFmt
.GetPositionAndSpaceMode() );
881 if ( aTempFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
883 aNumFmt
.SetAbsLSpace( aTempFmt
.GetAbsLSpace());
884 aNumFmt
.SetCharTextDistance( aTempFmt
.GetCharTextDistance() );
885 aNumFmt
.SetFirstLineOffset( aTempFmt
.GetFirstLineOffset() );
887 else if ( aTempFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
889 aNumFmt
.SetNumAdjust( aTempFmt
.GetNumAdjust() );
890 aNumFmt
.SetLabelFollowedBy( aTempFmt
.GetLabelFollowedBy() );
891 aNumFmt
.SetListtabPos( aTempFmt
.GetListtabPos() );
892 aNumFmt
.SetFirstLineIndent( aTempFmt
.GetFirstLineIndent() );
893 aNumFmt
.SetIndentAt( aTempFmt
.GetIndentAt() );
895 pActNum
->Set( i
, aNumFmt
);
906 void SwNumPositionTabPage::SetModified(sal_Bool bRepaint
)
908 bModified
= sal_True
;
911 m_pPreviewWIN
->SetLevel(nActNumLvl
);
912 m_pPreviewWIN
->Invalidate();
917 SwSvxNumBulletTabDialog::SwSvxNumBulletTabDialog(Window
* pParent
,
918 const SfxItemSet
* pSwItemSet
, SwWrtShell
& rSh
)
919 : SfxTabDialog(pParent
, "BulletsAndNumberingDialog",
920 "modules/swriter/ui/bulletsandnumbering.ui",
921 pSwItemSet
, sal_False
)
924 GetUserButton()->SetClickHdl(LINK(this, SwSvxNumBulletTabDialog
, RemoveNumberingHdl
));
925 GetUserButton()->Enable(rWrtSh
.GetCurNumRule() != NULL
);
926 m_nSingleNumPageId
= AddTabPage("singlenum", RID_SVXPAGE_PICK_SINGLE_NUM
);
927 m_nBulletPageId
= AddTabPage("bullets", RID_SVXPAGE_PICK_BULLET
);
928 AddTabPage("outlinenum", RID_SVXPAGE_PICK_NUM
);
929 AddTabPage("graphics", RID_SVXPAGE_PICK_BMP
);
930 m_nOptionsPageId
= AddTabPage("options", RID_SVXPAGE_NUM_OPTIONS
);
931 m_nPositionPageId
= AddTabPage("position", RID_SVXPAGE_NUM_POSITION
);
934 SwSvxNumBulletTabDialog::~SwSvxNumBulletTabDialog()
938 void SwSvxNumBulletTabDialog::PageCreated(sal_uInt16 nPageId
, SfxTabPage
& rPage
)
940 // set styles' names and metric
941 String sNumCharFmt
, sBulletCharFmt
;
942 SwStyleNameMapper::FillUIName( RES_POOLCHR_NUM_LEVEL
, sNumCharFmt
);
943 SwStyleNameMapper::FillUIName( RES_POOLCHR_BUL_LEVEL
, sBulletCharFmt
);
945 if (nPageId
== m_nSingleNumPageId
)
947 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
948 aSet
.Put (SfxStringItem(SID_NUM_CHAR_FMT
,sNumCharFmt
));
949 aSet
.Put (SfxStringItem(SID_BULLET_CHAR_FMT
,sBulletCharFmt
));
950 rPage
.PageCreated(aSet
);
952 else if (nPageId
== m_nBulletPageId
)
954 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
955 aSet
.Put (SfxStringItem(SID_BULLET_CHAR_FMT
,sBulletCharFmt
));
956 rPage
.PageCreated(aSet
);
958 else if (nPageId
== m_nOptionsPageId
)
960 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
961 aSet
.Put (SfxStringItem(SID_NUM_CHAR_FMT
,sNumCharFmt
));
962 aSet
.Put (SfxStringItem(SID_BULLET_CHAR_FMT
,sBulletCharFmt
));
963 // collect char styles
964 ListBox
rCharFmtLB(this);
966 rCharFmtLB
.InsertEntry( ViewShell::GetShellRes()->aStrNone
);
967 SwDocShell
* pDocShell
= rWrtSh
.GetView().GetDocShell();
968 ::FillCharStyleListBox(rCharFmtLB
, pDocShell
);
970 std::vector
<String
> aList
;
971 for(sal_uInt16 j
= 0; j
< rCharFmtLB
.GetEntryCount(); j
++)
972 aList
.push_back( String(rCharFmtLB
.GetEntry(j
)));
974 aSet
.Put( SfxStringListItem( SID_CHAR_FMT_LIST_BOX
,&aList
) ) ;
976 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell
, pDocShell
));
977 aSet
.Put ( SfxAllEnumItem(SID_METRIC_ITEM
, static_cast< sal_uInt16
>(eMetric
) ) );
978 rPage
.PageCreated(aSet
);
980 else if (nPageId
== m_nPositionPageId
)
982 SwDocShell
* pDocShell
= rWrtSh
.GetView().GetDocShell();
983 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell
, pDocShell
));
984 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
985 aSet
.Put ( SfxAllEnumItem(SID_METRIC_ITEM
, static_cast< sal_uInt16
>(eMetric
)) );
986 rPage
.PageCreated(aSet
);
990 short SwSvxNumBulletTabDialog::Ok()
992 short nRet
= SfxTabDialog::Ok();
993 pExampleSet
->ClearItem(SID_PARAM_NUM_PRESET
);
997 IMPL_LINK_NOARG(SwSvxNumBulletTabDialog
, RemoveNumberingHdl
)
1003 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */