Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
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/brshitem.hxx>
26 : : #include <editeng/lrspitem.hxx>
27 : : #include <editeng/numitem.hxx>
28 : : #include <swvset.hxx>
29 : : #include <swmodule.hxx>
30 : : #include <wrtsh.hxx>
31 : : #include <docsh.hxx>
32 : : #include <wview.hxx>
33 : : #include <uitool.hxx>
34 : : #include <wdocsh.hxx>
35 : : #include <uiitems.hxx>
36 : : #include <docstyle.hxx>
37 : : #include <charfmt.hxx>
38 : : #include <uinums.hxx>
39 : : #include <poolfmt.hxx>
40 : : #include <shellres.hxx>
41 : : #include <outline.hxx>
42 : : #include <num.hxx>
43 : : #include <viewopt.hxx>
44 : : #include <frmmgr.hxx>
45 : :
46 : : #include <misc.hrc>
47 : : #include <frmui.hrc>
48 : : #include <num.hrc>
49 : : #include <globals.hrc>
50 : : #include <helpid.h>
51 : : #include <SwStyleNameMapper.hxx>
52 : : #include <svx/svxids.hrc>
53 : : #include <svx/dialogs.hrc>
54 : : #include <svl/stritem.hxx>
55 : : #include <svl/aeitem.hxx>
56 : : #include <svl/slstitm.hxx>
57 : :
58 : : static sal_Bool bLastRelative = sal_False;
59 : :
60 : 0 : SwNumPositionTabPage::SwNumPositionTabPage(Window* pParent,
61 : : const SfxItemSet& rSet) :
62 : : SfxTabPage( pParent, SW_RES( TP_NUM_POSITION ), rSet ),
63 : : aLevelFL( this, SW_RES(FL_LEVEL )),
64 : : aLevelLB( this, SW_RES(LB_LEVEL )),
65 : : aPositionFL( this, SW_RES(FL_POSITION )),
66 : :
67 : : aDistBorderFT( this, SW_RES(FT_BORDERDIST )),
68 : : aDistBorderMF( this, SW_RES(MF_BORDERDIST )),
69 : : aRelativeCB( this, SW_RES(CB_RELATIVE )),
70 : : aIndentFT( this, SW_RES(FT_INDENT )),
71 : : aIndentMF( this, SW_RES(MF_INDENT )),
72 : : aDistNumFT( this, SW_RES(FT_NUMDIST )),
73 : : aDistNumMF( this, SW_RES(MF_NUMDIST )),
74 : : aAlignFT( this, SW_RES(FT_ALIGN )),
75 : : aAlignLB( this, SW_RES(LB_ALIGN )),
76 : : aLabelFollowedByFT( this, SW_RES(FT_LABEL_FOLLOWED_BY) ),
77 : : aLabelFollowedByLB( this, SW_RES(LB_LABEL_FOLLOWED_BY) ),
78 : : aListtabFT( this, SW_RES(FT_LISTTAB) ),
79 : : aListtabMF( this, SW_RES(MF_LISTTAB) ),
80 : : aAlign2FT( this, SW_RES(FT_ALIGN_2) ),
81 : : aAlign2LB( this, SW_RES(LB_ALIGN_2) ),
82 : : aAlignedAtFT( this, SW_RES(FT_ALIGNED_AT) ),
83 : : aAlignedAtMF( this, SW_RES(MF_ALIGNED_AT) ),
84 : : aIndentAtFT( this, SW_RES(FT_INDENT_AT) ),
85 : : aIndentAtMF( this, SW_RES(MF_INDENT_AT) ),
86 : : aStandardPB( this, SW_RES(PB_STANDARD )),
87 : :
88 : : aPreviewWIN( this, SW_RES(WIN_PREVIEW )),
89 : :
90 : : pActNum(0),
91 : : pSaveNum(0),
92 : : pWrtSh(0),
93 : : pOutlineDlg(0),
94 : : bPreset( sal_False ),
95 : : bInInintControl(sal_False),
96 : 0 : bLabelAlignmentPosAndSpaceModeActive( false )
97 : : {
98 : 0 : FreeResource();
99 : 0 : SetExchangeSupport();
100 : 0 : aPreviewWIN.SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
101 : :
102 : 0 : aStandardPB.SetAccessibleRelationMemberOf(&aPositionFL);
103 : :
104 : :
105 : 0 : aRelativeCB.Check();
106 : 0 : aAlignLB.SetSelectHdl(LINK(this, SwNumPositionTabPage, EditModifyHdl));
107 : 0 : aAlign2LB.SetSelectHdl(LINK(this, SwNumPositionTabPage, EditModifyHdl));
108 : 0 : for ( sal_uInt16 i = 0; i < aAlignLB.GetEntryCount(); ++i )
109 : : {
110 : 0 : aAlign2LB.InsertEntry( aAlignLB.GetEntry( i ) );
111 : : }
112 : 0 : aAlign2LB.SetDropDownLineCount( aAlign2LB.GetEntryCount() );
113 : 0 : aAlign2FT.SetText( aAlignFT.GetText() );
114 : :
115 : 0 : Link aLk = LINK(this, SwNumPositionTabPage, DistanceHdl);
116 : 0 : aDistBorderMF.SetUpHdl(aLk);
117 : 0 : aDistNumMF.SetUpHdl(aLk);
118 : 0 : aIndentMF.SetUpHdl(aLk);
119 : 0 : aDistBorderMF.SetDownHdl(aLk);
120 : 0 : aDistNumMF.SetDownHdl(aLk);
121 : 0 : aIndentMF.SetDownHdl(aLk);
122 : 0 : aDistBorderMF.SetLoseFocusHdl(aLk);
123 : 0 : aDistNumMF.SetLoseFocusHdl(aLk);
124 : 0 : aIndentMF.SetLoseFocusHdl(aLk);
125 : :
126 : 0 : aLabelFollowedByLB.SetDropDownLineCount( aLabelFollowedByLB.GetEntryCount() );
127 : 0 : aLabelFollowedByLB.SetSelectHdl( LINK(this, SwNumPositionTabPage, LabelFollowedByHdl_Impl) );
128 : :
129 : 0 : aLk = LINK(this, SwNumPositionTabPage, ListtabPosHdl_Impl);
130 : 0 : aListtabMF.SetUpHdl(aLk);
131 : 0 : aListtabMF.SetDownHdl(aLk);
132 : 0 : aListtabMF.SetLoseFocusHdl(aLk);
133 : :
134 : 0 : aLk = LINK(this, SwNumPositionTabPage, AlignAtHdl_Impl);
135 : 0 : aAlignedAtMF.SetUpHdl(aLk);
136 : 0 : aAlignedAtMF.SetDownHdl(aLk);
137 : 0 : aAlignedAtMF.SetLoseFocusHdl(aLk);
138 : :
139 : 0 : aLk = LINK(this, SwNumPositionTabPage, IndentAtHdl_Impl);
140 : 0 : aIndentAtMF.SetUpHdl(aLk);
141 : 0 : aIndentAtMF.SetDownHdl(aLk);
142 : 0 : aIndentAtMF.SetLoseFocusHdl(aLk);
143 : :
144 : 0 : aLevelLB.SetSelectHdl(LINK(this, SwNumPositionTabPage, LevelHdl));
145 : 0 : aRelativeCB.SetClickHdl(LINK(this, SwNumPositionTabPage, RelativeHdl));
146 : 0 : aStandardPB.SetClickHdl(LINK(this, SwNumPositionTabPage, StandardHdl));
147 : :
148 : : // insert levels
149 : 0 : for(sal_uInt16 i = 1; i <= MAXLEVEL; i++)
150 : 0 : aLevelLB.InsertEntry(String::CreateFromInt32(i));
151 : 0 : String sEntry(rtl::OUString("1 - "));
152 : 0 : sEntry += String::CreateFromInt32(MAXLEVEL);
153 : 0 : aLevelLB.InsertEntry(sEntry);
154 : 0 : aLevelLB.SelectEntry(sEntry);
155 : :
156 : 0 : aRelativeCB.Check(bLastRelative);
157 : 0 : aPreviewWIN.SetPositionMode();
158 : 0 : }
159 : :
160 : 0 : SwNumPositionTabPage::~SwNumPositionTabPage()
161 : : {
162 : 0 : delete pActNum;
163 : 0 : }
164 : :
165 : 0 : void SwNumPositionTabPage::InitControls()
166 : : {
167 : 0 : bInInintControl = sal_True;
168 : 0 : const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
169 : 0 : aRelativeCB.IsEnabled() && aRelativeCB.IsChecked();
170 : 0 : const bool bSingleSelection = aLevelLB.GetSelectEntryCount() == 1 &&
171 : 0 : USHRT_MAX != nActNumLvl;
172 : :
173 : 0 : aDistBorderMF.Enable( !bLabelAlignmentPosAndSpaceModeActive &&
174 : 0 : ( bSingleSelection || bRelative || pOutlineDlg != 0 ) );
175 : 0 : aDistBorderFT.Enable( !bLabelAlignmentPosAndSpaceModeActive &&
176 : 0 : ( bSingleSelection || bRelative || pOutlineDlg != 0 ) );
177 : :
178 : 0 : bool bSetDistEmpty = false;
179 : 0 : bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
180 : 0 : bool bSameDist = !bLabelAlignmentPosAndSpaceModeActive;
181 : 0 : bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive;
182 : 0 : bool bSameAdjust = true;
183 : :
184 : 0 : bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
185 : 0 : bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
186 : 0 : bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
187 : 0 : bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
188 : :
189 : : const SwNumFmt* aNumFmtArr[MAXLEVEL];
190 : 0 : sal_uInt16 nMask = 1;
191 : 0 : sal_uInt16 nLvl = USHRT_MAX;
192 : 0 : long nFirstBorderTextRelative = -1;
193 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
194 : : {
195 : 0 : aNumFmtArr[i] = &pActNum->Get(i);
196 : 0 : if(nActNumLvl & nMask)
197 : : {
198 : 0 : if(USHRT_MAX == nLvl)
199 : : {
200 : 0 : nLvl = i;
201 : : }
202 : :
203 : 0 : if( i > nLvl)
204 : : {
205 : 0 : bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
206 : 0 : if ( !bLabelAlignmentPosAndSpaceModeActive )
207 : : {
208 : 0 : if(bRelative)
209 : : {
210 : 0 : if(nFirstBorderTextRelative == -1)
211 : : nFirstBorderTextRelative =
212 : 0 : (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
213 : 0 : aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
214 : : else
215 : : bSameDistBorderNum &= nFirstBorderTextRelative ==
216 : 0 : (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
217 : 0 : aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
218 : :
219 : : }
220 : : else
221 : : {
222 : : bSameDistBorderNum &=
223 : 0 : aNumFmtArr[i]->GetAbsLSpace() - aNumFmtArr[i]->GetFirstLineOffset() ==
224 : 0 : aNumFmtArr[i - 1]->GetAbsLSpace() - aNumFmtArr[i - 1]->GetFirstLineOffset();
225 : : }
226 : :
227 : 0 : bSameDist &= aNumFmtArr[i]->GetCharTextDistance() == aNumFmtArr[nLvl]->GetCharTextDistance();
228 : 0 : bSameIndent &= aNumFmtArr[i]->GetFirstLineOffset() == aNumFmtArr[nLvl]->GetFirstLineOffset();
229 : : }
230 : : else
231 : : {
232 : : bSameLabelFollowedBy &=
233 : 0 : aNumFmtArr[i]->GetLabelFollowedBy() == aNumFmtArr[nLvl]->GetLabelFollowedBy();
234 : : bSameListtab &=
235 : 0 : aNumFmtArr[i]->GetListtabPos() == aNumFmtArr[nLvl]->GetListtabPos();
236 : : bSameAlignAt &=
237 : 0 : ( ( aNumFmtArr[i]->GetIndentAt() + aNumFmtArr[i]->GetFirstLineIndent() )
238 : 0 : == ( aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent() ) );
239 : : bSameIndentAt &=
240 : 0 : aNumFmtArr[i]->GetIndentAt() == aNumFmtArr[nLvl]->GetIndentAt();
241 : : }
242 : : }
243 : : }
244 : 0 : nMask <<= 1;
245 : :
246 : : }
247 : 0 : if (MAXLEVEL <= nLvl)
248 : : {
249 : : OSL_ENSURE(false, "cannot happen.");
250 : 0 : return;
251 : : }
252 : 0 : if(bSameDistBorderNum)
253 : : {
254 : : long nDistBorderNum;
255 : 0 : if(bRelative)
256 : : {
257 : 0 : nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
258 : 0 : if(nLvl)
259 : 0 : nDistBorderNum -= (long)aNumFmtArr[nLvl - 1]->GetAbsLSpace()+ aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
260 : : }
261 : : else
262 : : {
263 : 0 : nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
264 : : }
265 : 0 : aDistBorderMF.SetValue(aDistBorderMF.Normalize(nDistBorderNum),FUNIT_TWIP);
266 : : }
267 : : else
268 : 0 : bSetDistEmpty = sal_True;
269 : :
270 : 0 : if(bSameDist)
271 : 0 : aDistNumMF .SetValue(aDistNumMF.Normalize(aNumFmtArr[nLvl]->GetCharTextDistance()), FUNIT_TWIP);
272 : : else
273 : 0 : aDistNumMF.SetText(aEmptyStr);
274 : 0 : if(bSameIndent)
275 : 0 : aIndentMF.SetValue(aIndentMF.Normalize(-aNumFmtArr[nLvl]->GetFirstLineOffset()), FUNIT_TWIP);
276 : : else
277 : 0 : aIndentMF.SetText(aEmptyStr);
278 : :
279 : 0 : if(bSameAdjust)
280 : : {
281 : 0 : sal_uInt16 nPos = 1; // centered
282 : 0 : if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
283 : 0 : nPos = 0;
284 : 0 : else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
285 : 0 : nPos = 2;
286 : 0 : aAlignLB.SelectEntryPos(nPos);
287 : 0 : aAlign2LB.SelectEntryPos( nPos );
288 : : }
289 : : else
290 : : {
291 : 0 : aAlignLB.SetNoSelection();
292 : 0 : aAlign2LB.SetNoSelection();
293 : : }
294 : :
295 : 0 : if ( bSameLabelFollowedBy )
296 : : {
297 : 0 : sal_uInt16 nPos = 0; // LISTTAB
298 : 0 : if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
299 : : {
300 : 0 : nPos = 1;
301 : : }
302 : 0 : else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
303 : : {
304 : 0 : nPos = 2;
305 : : }
306 : 0 : aLabelFollowedByLB.SelectEntryPos( nPos );
307 : : }
308 : : else
309 : : {
310 : 0 : aLabelFollowedByLB.SetNoSelection();
311 : : }
312 : :
313 : 0 : if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
314 : : {
315 : 0 : aListtabFT.Enable( true );
316 : 0 : aListtabMF.Enable( true );
317 : 0 : if ( bSameListtab )
318 : : {
319 : 0 : aListtabMF.SetValue(aListtabMF.Normalize(aNumFmtArr[nLvl]->GetListtabPos()),FUNIT_TWIP);
320 : : }
321 : : else
322 : : {
323 : 0 : aListtabMF.SetText(aEmptyStr);
324 : : }
325 : : }
326 : : else
327 : : {
328 : 0 : aListtabFT.Enable( false );
329 : 0 : aListtabMF.Enable( false );
330 : 0 : aListtabMF.SetText(aEmptyStr);
331 : : }
332 : :
333 : 0 : if ( bSameAlignAt )
334 : : {
335 : : aAlignedAtMF.SetValue(
336 : 0 : aAlignedAtMF.Normalize( aNumFmtArr[nLvl]->GetIndentAt() +
337 : 0 : aNumFmtArr[nLvl]->GetFirstLineIndent()),
338 : 0 : FUNIT_TWIP );
339 : : }
340 : : else
341 : : {
342 : 0 : aAlignedAtMF.SetText(aEmptyStr);
343 : : }
344 : :
345 : 0 : if ( bSameIndentAt )
346 : : {
347 : : aIndentAtMF.SetValue(
348 : 0 : aIndentAtMF.Normalize( aNumFmtArr[nLvl]->GetIndentAt()), FUNIT_TWIP );
349 : : }
350 : : else
351 : : {
352 : 0 : aIndentAtMF.SetText(aEmptyStr);
353 : : }
354 : :
355 : 0 : if(sal_True == bSetDistEmpty)
356 : 0 : aDistBorderMF.SetText(aEmptyStr);
357 : :
358 : 0 : bInInintControl = sal_False;
359 : : }
360 : :
361 : 0 : void SwNumPositionTabPage::ActivatePage(const SfxItemSet& )
362 : : {
363 : : const SfxPoolItem* pItem;
364 : : sal_uInt16 nTmpNumLvl =
365 : 0 : pOutlineDlg ? pOutlineDlg->GetActNumLevel() : 0;
366 : 0 : const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
367 : 0 : if(pExampleSet && pExampleSet->GetItemState(FN_PARAM_NUM_PRESET, sal_False, &pItem))
368 : : {
369 : 0 : bPreset = ((const SfxBoolItem*)pItem)->GetValue();
370 : : }
371 : 0 : bModified = (!pActNum->GetNumFmt( 0 ) || bPreset);
372 : 0 : if(*pActNum != *pSaveNum ||
373 : : nActNumLvl != nTmpNumLvl )
374 : : {
375 : 0 : *pActNum = *pSaveNum;
376 : 0 : nActNumLvl = nTmpNumLvl;
377 : 0 : sal_uInt16 nMask = 1;
378 : 0 : aLevelLB.SetUpdateMode(sal_False);
379 : 0 : aLevelLB.SetNoSelection();
380 : 0 : aLevelLB.SelectEntryPos( MAXLEVEL, nActNumLvl == USHRT_MAX);
381 : 0 : if(nActNumLvl != USHRT_MAX)
382 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
383 : : {
384 : 0 : if(nActNumLvl & nMask)
385 : 0 : aLevelLB.SelectEntryPos( i, sal_True);
386 : 0 : nMask <<= 1 ;
387 : : }
388 : 0 : aLevelLB.SetUpdateMode(sal_True);
389 : :
390 : 0 : InitPosAndSpaceMode();
391 : 0 : ShowControlsDependingOnPosAndSpaceMode();
392 : :
393 : 0 : InitControls();
394 : : }
395 : 0 : aRelativeCB.Enable(1 != nActNumLvl);
396 : 0 : aPreviewWIN.Invalidate();
397 : 0 : }
398 : :
399 : 0 : int SwNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet)
400 : : {
401 : 0 : SwOutlineTabDialog::SetActNumLevel(nActNumLvl);
402 : 0 : if(_pSet)
403 : 0 : FillItemSet(*_pSet);
404 : 0 : return sal_True;
405 : :
406 : : }
407 : :
408 : 0 : sal_Bool SwNumPositionTabPage::FillItemSet( SfxItemSet& rSet )
409 : : {
410 : 0 : if(pOutlineDlg)
411 : 0 : *pOutlineDlg->GetNumRule() = *pActNum;
412 : 0 : else if(bModified && pActNum)
413 : : {
414 : 0 : *pSaveNum = *pActNum;
415 : 0 : rSet.Put(SwUINumRuleItem( *pSaveNum ));
416 : 0 : rSet.Put(SfxBoolItem(FN_PARAM_NUM_PRESET, sal_False));
417 : : }
418 : 0 : return bModified;
419 : : }
420 : :
421 : 0 : void SwNumPositionTabPage::Reset( const SfxItemSet& rSet )
422 : : {
423 : : const SfxPoolItem* pItem;
424 : 0 : if(pOutlineDlg)
425 : : {
426 : 0 : pSaveNum = pOutlineDlg->GetNumRule();
427 : 0 : aLevelLB.EnableMultiSelection(sal_False);
428 : : }
429 : 0 : else if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_ACT_NUMBER, sal_False, &pItem))
430 : 0 : pSaveNum = ((SwUINumRuleItem*)pItem)->GetNumRule();
431 : :
432 : 0 : nActNumLvl = SwOutlineTabDialog::GetActNumLevel();
433 : 0 : sal_uInt16 nMask = 1;
434 : 0 : aLevelLB.SetUpdateMode(sal_False);
435 : 0 : aLevelLB.SetNoSelection();
436 : 0 : if(nActNumLvl == USHRT_MAX)
437 : : {
438 : 0 : aLevelLB.SelectEntryPos( MAXLEVEL, sal_True);
439 : : }
440 : : else
441 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
442 : : {
443 : 0 : if(nActNumLvl & nMask)
444 : 0 : aLevelLB.SelectEntryPos( i, sal_True);
445 : 0 : nMask <<= 1;
446 : : }
447 : 0 : aLevelLB.SetUpdateMode(sal_True);
448 : :
449 : 0 : if(!pActNum)
450 : 0 : pActNum = new SwNumRule(*pSaveNum);
451 : 0 : else if(*pSaveNum != *pActNum)
452 : 0 : *pActNum = *pSaveNum;
453 : 0 : aPreviewWIN.SetNumRule(pActNum);
454 : 0 : InitPosAndSpaceMode();
455 : 0 : ShowControlsDependingOnPosAndSpaceMode();
456 : 0 : InitControls();
457 : 0 : bModified = sal_False;
458 : 0 : }
459 : :
460 : 0 : void SwNumPositionTabPage::InitPosAndSpaceMode()
461 : : {
462 : 0 : if ( pActNum == 0 )
463 : : {
464 : : OSL_FAIL( "<SwNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
465 : 0 : return;
466 : : }
467 : :
468 : : SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode =
469 : 0 : SvxNumberFormat::LABEL_ALIGNMENT;
470 : 0 : sal_uInt16 nMask = 1;
471 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
472 : : {
473 : 0 : if(nActNumLvl & nMask)
474 : : {
475 : 0 : SvxNumberFormat aNumFmt( pActNum->Get(i) );
476 : 0 : ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
477 : 0 : if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
478 : : {
479 : : break;
480 : 0 : }
481 : : }
482 : 0 : nMask <<= 1;
483 : : }
484 : :
485 : : bLabelAlignmentPosAndSpaceModeActive =
486 : 0 : ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
487 : : }
488 : :
489 : 0 : void SwNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
490 : : {
491 : 0 : aDistBorderFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
492 : 0 : aDistBorderMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
493 : 0 : aRelativeCB.Show( !bLabelAlignmentPosAndSpaceModeActive );
494 : 0 : aIndentFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
495 : 0 : aIndentMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
496 : 0 : aDistNumFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
497 : 0 : aDistNumMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
498 : 0 : aAlignFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
499 : 0 : aAlignLB.Show( !bLabelAlignmentPosAndSpaceModeActive );
500 : :
501 : 0 : aLabelFollowedByFT.Show( bLabelAlignmentPosAndSpaceModeActive );
502 : 0 : aLabelFollowedByLB.Show( bLabelAlignmentPosAndSpaceModeActive );
503 : 0 : aListtabFT.Show( bLabelAlignmentPosAndSpaceModeActive );
504 : 0 : aListtabMF.Show( bLabelAlignmentPosAndSpaceModeActive );
505 : 0 : aAlign2FT.Show( bLabelAlignmentPosAndSpaceModeActive );
506 : 0 : aAlign2LB.Show( bLabelAlignmentPosAndSpaceModeActive );
507 : 0 : aAlignedAtFT.Show( bLabelAlignmentPosAndSpaceModeActive );
508 : 0 : aAlignedAtMF.Show( bLabelAlignmentPosAndSpaceModeActive );
509 : 0 : aIndentAtFT.Show( bLabelAlignmentPosAndSpaceModeActive );
510 : 0 : aIndentAtMF.Show( bLabelAlignmentPosAndSpaceModeActive );
511 : 0 : }
512 : :
513 : 0 : SfxTabPage* SwNumPositionTabPage::Create( Window* pParent,
514 : : const SfxItemSet& rAttrSet)
515 : : {
516 : 0 : return new SwNumPositionTabPage(pParent, rAttrSet);
517 : : }
518 : :
519 : 0 : void SwNumPositionTabPage::SetWrtShell(SwWrtShell* pSh)
520 : : {
521 : 0 : pWrtSh = pSh;
522 : :
523 : 0 : const SwTwips nWidth = pWrtSh->GetAnyCurRect(RECT_FRM).Width();
524 : :
525 : 0 : aDistBorderMF.SetMax(aDistBorderMF.Normalize( nWidth ), FUNIT_TWIP );
526 : 0 : aDistNumMF .SetMax(aDistNumMF .Normalize( nWidth ), FUNIT_TWIP );
527 : 0 : aIndentMF .SetMax(aIndentMF .Normalize( nWidth ), FUNIT_TWIP );
528 : 0 : aListtabMF.SetMax(aListtabMF.Normalize( nWidth ), FUNIT_TWIP );
529 : 0 : aAlignedAtMF.SetMax(aAlignedAtMF.Normalize( nWidth ), FUNIT_TWIP );
530 : 0 : aIndentAtMF.SetMax(aIndentAtMF.Normalize( nWidth ), FUNIT_TWIP );
531 : 0 : const SwTwips nLast2 = nWidth /2;
532 : 0 : aDistBorderMF.SetLast( aDistBorderMF.Normalize( nLast2 ), FUNIT_TWIP );
533 : 0 : aDistNumMF .SetLast( aDistNumMF .Normalize( nLast2 ), FUNIT_TWIP );
534 : 0 : aIndentMF .SetLast( aIndentMF .Normalize( nLast2 ), FUNIT_TWIP );
535 : 0 : aListtabMF.SetLast(aListtabMF.Normalize( nLast2 ), FUNIT_TWIP );
536 : 0 : aAlignedAtMF.SetLast(aAlignedAtMF.Normalize( nLast2 ), FUNIT_TWIP );
537 : 0 : aIndentAtMF.SetLast(aIndentAtMF.Normalize( nLast2 ), FUNIT_TWIP );
538 : :
539 : 0 : const SwRect& rPrtRect = pWrtSh->GetAnyCurRect(RECT_PAGE);
540 : 0 : aPreviewWIN.SetPageWidth(rPrtRect.Width());
541 : 0 : FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &pWrtSh->GetView()));
542 : 0 : if(eMetric == FUNIT_MM)
543 : : {
544 : 0 : aDistBorderMF .SetDecimalDigits(1);
545 : 0 : aDistNumMF .SetDecimalDigits(1);
546 : 0 : aIndentMF .SetDecimalDigits(1);
547 : 0 : aListtabMF.SetDecimalDigits(1);
548 : 0 : aAlignedAtMF.SetDecimalDigits(1);
549 : 0 : aIndentAtMF.SetDecimalDigits(1);
550 : : }
551 : 0 : aDistBorderMF .SetUnit( eMetric );
552 : 0 : aDistNumMF .SetUnit( eMetric );
553 : 0 : aIndentMF .SetUnit( eMetric );
554 : 0 : aListtabMF.SetUnit( eMetric );
555 : 0 : aAlignedAtMF.SetUnit( eMetric );
556 : 0 : aIndentAtMF.SetUnit( eMetric );
557 : 0 : }
558 : :
559 : 0 : IMPL_LINK_NOARG(SwNumPositionTabPage, EditModifyHdl)
560 : : {
561 : 0 : sal_uInt16 nMask = 1;
562 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
563 : : {
564 : 0 : if(nActNumLvl & nMask)
565 : : {
566 : 0 : SwNumFmt aNumFmt(pActNum->Get(i));
567 : :
568 : 0 : const sal_uInt16 nPos = aAlignLB.IsVisible()
569 : 0 : ? aAlignLB.GetSelectEntryPos()
570 : 0 : : aAlign2LB.GetSelectEntryPos();
571 : 0 : SvxAdjust eAdjust = SVX_ADJUST_CENTER;
572 : 0 : if(nPos == 0)
573 : 0 : eAdjust = SVX_ADJUST_LEFT;
574 : 0 : else if(nPos == 2)
575 : 0 : eAdjust = SVX_ADJUST_RIGHT;
576 : 0 : aNumFmt.SetNumAdjust( eAdjust );
577 : 0 : pActNum->Set(i, aNumFmt);
578 : : }
579 : 0 : nMask <<= 1;
580 : : }
581 : 0 : SetModified();
582 : 0 : return 0;
583 : : }
584 : :
585 : 0 : IMPL_LINK( SwNumPositionTabPage, LevelHdl, ListBox *, pBox )
586 : : {
587 : 0 : sal_uInt16 nSaveNumLvl = nActNumLvl;
588 : 0 : nActNumLvl = 0;
589 : 0 : if(pBox->IsEntryPosSelected( MAXLEVEL ) &&
590 : 0 : (pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
591 : : {
592 : 0 : nActNumLvl = 0xFFFF;
593 : 0 : pBox->SetUpdateMode(sal_False);
594 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; i++ )
595 : 0 : pBox->SelectEntryPos( i, sal_False );
596 : 0 : pBox->SetUpdateMode(sal_True);
597 : : }
598 : 0 : else if(pBox->GetSelectEntryCount())
599 : : {
600 : 0 : sal_uInt16 nMask = 1;
601 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; i++ )
602 : : {
603 : 0 : if(pBox->IsEntryPosSelected( i ))
604 : 0 : nActNumLvl |= nMask;
605 : 0 : nMask <<= 1;
606 : : }
607 : 0 : pBox->SelectEntryPos( MAXLEVEL, sal_False );
608 : : }
609 : : else
610 : : {
611 : 0 : nActNumLvl = nSaveNumLvl;
612 : 0 : sal_uInt16 nMask = 1;
613 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; i++ )
614 : : {
615 : 0 : if(nActNumLvl & nMask)
616 : : {
617 : 0 : pBox->SelectEntryPos(i);
618 : 0 : break;
619 : : }
620 : 0 : nMask <<=1;
621 : : }
622 : : }
623 : 0 : aRelativeCB.Enable(1 != nActNumLvl);
624 : 0 : SetModified();
625 : 0 : InitPosAndSpaceMode();
626 : 0 : ShowControlsDependingOnPosAndSpaceMode();
627 : 0 : InitControls();
628 : 0 : return 0;
629 : : }
630 : :
631 : 0 : IMPL_LINK( SwNumPositionTabPage, DistanceHdl, MetricField *, pFld )
632 : : {
633 : 0 : if(bInInintControl)
634 : 0 : return 0;
635 : 0 : long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
636 : 0 : sal_uInt16 nMask = 1;
637 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
638 : : {
639 : 0 : if(nActNumLvl & nMask)
640 : : {
641 : 0 : SwNumFmt aNumFmt( pActNum->Get( i ) );
642 : 0 : if(pFld == &aDistBorderMF)
643 : : {
644 : :
645 : 0 : if(aRelativeCB.IsChecked() && aRelativeCB.IsEnabled())
646 : : {
647 : 0 : if(0 == i)
648 : : {
649 : 0 : long nTmp = aNumFmt.GetFirstLineOffset();
650 : 0 : aNumFmt.SetAbsLSpace( sal_uInt16(nValue - nTmp));
651 : : }
652 : : else
653 : : {
654 : 0 : long nTmp = pActNum->Get( i - 1 ).GetAbsLSpace() +
655 : 0 : pActNum->Get( i - 1 ).GetFirstLineOffset() -
656 : 0 : pActNum->Get( i ).GetFirstLineOffset();
657 : :
658 : 0 : aNumFmt.SetAbsLSpace( sal_uInt16(nValue + nTmp));
659 : : }
660 : : }
661 : : else
662 : : {
663 : 0 : aNumFmt.SetAbsLSpace( (short)nValue - aNumFmt.GetFirstLineOffset());
664 : : }
665 : : }
666 : 0 : else if(pFld == &aDistNumMF)
667 : : {
668 : 0 : aNumFmt.SetCharTextDistance( (short)nValue );
669 : : }
670 : 0 : else if(pFld == &aIndentMF)
671 : : {
672 : : // now AbsLSpace also has to be modified by FirstLineOffset
673 : 0 : long nDiff = nValue + aNumFmt.GetFirstLineOffset();
674 : 0 : long nAbsLSpace = aNumFmt.GetAbsLSpace();
675 : 0 : aNumFmt.SetAbsLSpace(sal_uInt16(nAbsLSpace + nDiff));
676 : 0 : aNumFmt.SetFirstLineOffset( -(short)nValue );
677 : : }
678 : :
679 : 0 : pActNum->Set( i, aNumFmt );
680 : : }
681 : 0 : nMask <<= 1;
682 : : }
683 : :
684 : 0 : SetModified();
685 : 0 : if(!aDistBorderMF.IsEnabled())
686 : 0 : aDistBorderMF.SetText(aEmptyStr);
687 : :
688 : 0 : return 0;
689 : : }
690 : :
691 : 0 : IMPL_LINK( SwNumPositionTabPage, RelativeHdl, CheckBox *, pBox )
692 : : {
693 : 0 : sal_Bool bOn = pBox->IsChecked();
694 : 0 : sal_Bool bSingleSelection = aLevelLB.GetSelectEntryCount() == 1 && USHRT_MAX != nActNumLvl;
695 : 0 : sal_Bool bSetValue = sal_False;
696 : 0 : long nValue = 0;
697 : 0 : if(bOn || bSingleSelection)
698 : : {
699 : 0 : sal_uInt16 nMask = 1;
700 : 0 : sal_Bool bFirst = sal_True;
701 : 0 : bSetValue = sal_True;
702 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
703 : : {
704 : 0 : if(nActNumLvl & nMask)
705 : : {
706 : 0 : const SwNumFmt &rNumFmt = pActNum->Get(i);
707 : 0 : if(bFirst)
708 : : {
709 : 0 : nValue = rNumFmt.GetAbsLSpace();
710 : 0 : if(bOn && i)
711 : 0 : nValue -= pActNum->Get(i - 1).GetAbsLSpace();
712 : : }
713 : : else
714 : 0 : bSetValue = nValue == rNumFmt.GetAbsLSpace() - pActNum->Get(i - 1).GetAbsLSpace();
715 : 0 : bFirst = sal_False;
716 : : }
717 : 0 : nMask <<= 1;
718 : : }
719 : :
720 : : }
721 : 0 : if(bSetValue)
722 : 0 : aDistBorderMF.SetValue(aDistBorderMF.Normalize(nValue), FUNIT_TWIP);
723 : : else
724 : 0 : aDistBorderMF.SetText(aEmptyStr);
725 : 0 : aDistBorderMF.Enable(bOn || bSingleSelection||0 != pOutlineDlg);
726 : 0 : bLastRelative = bOn;
727 : 0 : return 0;
728 : : }
729 : :
730 : 0 : IMPL_LINK_NOARG(SwNumPositionTabPage, LabelFollowedByHdl_Impl)
731 : : {
732 : : // determine value to be set at the chosen list levels
733 : 0 : SvxNumberFormat::LabelFollowedBy eLabelFollowedBy = SvxNumberFormat::LISTTAB;
734 : : {
735 : 0 : const sal_uInt16 nPos = aLabelFollowedByLB.GetSelectEntryPos();
736 : 0 : if ( nPos == 1 )
737 : : {
738 : 0 : eLabelFollowedBy = SvxNumberFormat::SPACE;
739 : : }
740 : 0 : else if ( nPos == 2 )
741 : : {
742 : 0 : eLabelFollowedBy = SvxNumberFormat::NOTHING;
743 : : }
744 : : }
745 : :
746 : : // set value at the chosen list levels
747 : 0 : bool bSameListtabPos = true;
748 : 0 : sal_uInt16 nFirstLvl = USHRT_MAX;
749 : 0 : sal_uInt16 nMask = 1;
750 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
751 : : {
752 : 0 : if ( nActNumLvl & nMask )
753 : : {
754 : 0 : SwNumFmt aNumFmt( pActNum->Get(i) );
755 : 0 : aNumFmt.SetLabelFollowedBy( eLabelFollowedBy );
756 : 0 : pActNum->Set( i, aNumFmt );
757 : :
758 : 0 : if ( nFirstLvl == USHRT_MAX )
759 : : {
760 : 0 : nFirstLvl = i;
761 : : }
762 : : else
763 : : {
764 : 0 : bSameListtabPos &= aNumFmt.GetListtabPos() ==
765 : 0 : pActNum->Get( nFirstLvl ).GetListtabPos();
766 : 0 : }
767 : : }
768 : 0 : nMask <<= 1;
769 : : }
770 : :
771 : : // enable/disable metric field for list tab stop position depending on
772 : : // selected item following the list label.
773 : 0 : aListtabFT.Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
774 : 0 : aListtabMF.Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
775 : 0 : if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
776 : : {
777 : : aListtabMF.SetValue(
778 : 0 : aListtabMF.Normalize( pActNum->Get( nFirstLvl ).GetListtabPos() ),
779 : 0 : FUNIT_TWIP );
780 : : }
781 : : else
782 : : {
783 : 0 : aListtabMF.SetText( String() );
784 : : }
785 : :
786 : 0 : SetModified();
787 : :
788 : 0 : return 0;
789 : : }
790 : :
791 : 0 : IMPL_LINK( SwNumPositionTabPage, ListtabPosHdl_Impl, MetricField*, pFld )
792 : : {
793 : : // determine value to be set at the chosen list levels
794 : 0 : const long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
795 : :
796 : : // set value at the chosen list levels
797 : 0 : sal_uInt16 nMask = 1;
798 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
799 : : {
800 : 0 : if ( nActNumLvl & nMask )
801 : : {
802 : 0 : SwNumFmt aNumFmt( pActNum->Get(i) );
803 : 0 : aNumFmt.SetListtabPos( nValue );
804 : 0 : pActNum->Set( i, aNumFmt );
805 : : }
806 : 0 : nMask <<= 1;
807 : : }
808 : :
809 : 0 : SetModified();
810 : :
811 : 0 : return 0;
812 : : }
813 : :
814 : 0 : IMPL_LINK( SwNumPositionTabPage, AlignAtHdl_Impl, MetricField*, pFld )
815 : : {
816 : : // determine value to be set at the chosen list levels
817 : 0 : const long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
818 : :
819 : : // set value at the chosen list levels
820 : 0 : sal_uInt16 nMask = 1;
821 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
822 : : {
823 : 0 : if ( nActNumLvl & nMask )
824 : : {
825 : 0 : SwNumFmt aNumFmt( pActNum->Get(i) );
826 : 0 : const long nFirstLineIndent = nValue - aNumFmt.GetIndentAt();
827 : 0 : aNumFmt.SetFirstLineIndent( nFirstLineIndent );
828 : 0 : pActNum->Set( i, aNumFmt );
829 : : }
830 : 0 : nMask <<= 1;
831 : : }
832 : :
833 : 0 : SetModified();
834 : :
835 : 0 : return 0;
836 : : }
837 : :
838 : 0 : IMPL_LINK( SwNumPositionTabPage, IndentAtHdl_Impl, MetricField*, pFld )
839 : : {
840 : : // determine value to be set at the chosen list levels
841 : 0 : const long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
842 : :
843 : : // set value at the chosen list levels
844 : 0 : sal_uInt16 nMask = 1;
845 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
846 : : {
847 : 0 : if ( nActNumLvl & nMask )
848 : : {
849 : 0 : SwNumFmt aNumFmt( pActNum->Get(i) );
850 : 0 : const long nAlignedAt = aNumFmt.GetIndentAt() +
851 : 0 : aNumFmt.GetFirstLineIndent();
852 : 0 : aNumFmt.SetIndentAt( nValue );
853 : 0 : const long nNewFirstLineIndent = nAlignedAt - nValue;
854 : 0 : aNumFmt.SetFirstLineIndent( nNewFirstLineIndent );
855 : 0 : pActNum->Set( i, aNumFmt );
856 : : }
857 : 0 : nMask <<= 1;
858 : : }
859 : :
860 : 0 : SetModified();
861 : :
862 : 0 : return 0;
863 : : }
864 : :
865 : 0 : IMPL_LINK_NOARG(SwNumPositionTabPage, StandardHdl)
866 : : {
867 : 0 : sal_uInt16 nMask = 1;
868 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
869 : : {
870 : 0 : if(nActNumLvl & nMask)
871 : : {
872 : 0 : SwNumFmt aNumFmt( pActNum->Get( i ) );
873 : : SwNumRule aTmpNumRule( pWrtSh->GetUniqueNumRuleName(),
874 : : aNumFmt.GetPositionAndSpaceMode(),
875 : 0 : pOutlineDlg ? OUTLINE_RULE : NUM_RULE );
876 : 0 : SwNumFmt aTempFmt(aTmpNumRule.Get( i ));
877 : 0 : aNumFmt.SetPositionAndSpaceMode( aTempFmt.GetPositionAndSpaceMode() );
878 : 0 : if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
879 : : {
880 : 0 : aNumFmt.SetAbsLSpace( aTempFmt.GetAbsLSpace());
881 : 0 : aNumFmt.SetCharTextDistance( aTempFmt.GetCharTextDistance() );
882 : 0 : aNumFmt.SetFirstLineOffset( aTempFmt.GetFirstLineOffset() );
883 : : }
884 : 0 : else if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
885 : : {
886 : 0 : aNumFmt.SetNumAdjust( aTempFmt.GetNumAdjust() );
887 : 0 : aNumFmt.SetLabelFollowedBy( aTempFmt.GetLabelFollowedBy() );
888 : 0 : aNumFmt.SetListtabPos( aTempFmt.GetListtabPos() );
889 : 0 : aNumFmt.SetFirstLineIndent( aTempFmt.GetFirstLineIndent() );
890 : 0 : aNumFmt.SetIndentAt( aTempFmt.GetIndentAt() );
891 : : }
892 : 0 : pActNum->Set( i, aNumFmt );
893 : : }
894 : 0 : nMask <<= 1;
895 : : }
896 : :
897 : 0 : InitControls();
898 : 0 : SetModified();
899 : 0 : return 0;
900 : : }
901 : :
902 : : #ifdef DBG_UTIL
903 : : void SwNumPositionTabPage::SetModified(sal_Bool bRepaint)
904 : : {
905 : : bModified = sal_True;
906 : : if(bRepaint)
907 : : {
908 : : aPreviewWIN.SetLevel(nActNumLvl);
909 : : aPreviewWIN.Invalidate();
910 : : }
911 : : }
912 : : #endif
913 : :
914 : 0 : SwSvxNumBulletTabDialog::SwSvxNumBulletTabDialog(Window* pParent,
915 : : const SfxItemSet* pSwItemSet, SwWrtShell & rSh) :
916 : : SfxTabDialog(pParent, SW_RES(DLG_SVXTEST_NUM_BULLET), pSwItemSet, sal_False, &aEmptyStr),
917 : : rWrtSh(rSh),
918 : : sRemoveText(SW_RES(ST_RESET)),
919 : 0 : nRetOptionsDialog(USHRT_MAX)
920 : : {
921 : 0 : FreeResource();
922 : 0 : GetUserButton()->SetText(sRemoveText);
923 : 0 : GetUserButton()->SetHelpId(HID_NUM_RESET);
924 : 0 : GetUserButton()->SetClickHdl(LINK(this, SwSvxNumBulletTabDialog, RemoveNumberingHdl));
925 : 0 : if(!rWrtSh.GetCurNumRule())
926 : 0 : GetUserButton()->Enable(sal_False);
927 : 0 : AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
928 : 0 : AddTabPage( RID_SVXPAGE_PICK_BULLET );
929 : 0 : AddTabPage( RID_SVXPAGE_PICK_NUM );
930 : 0 : AddTabPage( RID_SVXPAGE_PICK_BMP );
931 : 0 : AddTabPage( RID_SVXPAGE_NUM_OPTIONS );
932 : 0 : AddTabPage( RID_SVXPAGE_NUM_POSITION );
933 : :
934 : 0 : }
935 : :
936 : 0 : SwSvxNumBulletTabDialog::~SwSvxNumBulletTabDialog()
937 : : {
938 : 0 : }
939 : :
940 : 0 : void SwSvxNumBulletTabDialog::PageCreated(sal_uInt16 nPageId, SfxTabPage& rPage)
941 : : {
942 : : // set styles' names and metric
943 : 0 : String sNumCharFmt, sBulletCharFmt;
944 : 0 : SwStyleNameMapper::FillUIName( RES_POOLCHR_NUM_LEVEL, sNumCharFmt );
945 : 0 : SwStyleNameMapper::FillUIName( RES_POOLCHR_BUL_LEVEL, sBulletCharFmt );
946 : :
947 : 0 : switch ( nPageId )
948 : : {
949 : : case RID_SVXPAGE_PICK_NUM:
950 : : {
951 : 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
952 : 0 : aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFmt));
953 : 0 : aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
954 : 0 : rPage.PageCreated(aSet);
955 : : }
956 : 0 : break;
957 : : case RID_SVXPAGE_PICK_BULLET :
958 : : {
959 : 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
960 : 0 : aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
961 : 0 : rPage.PageCreated(aSet);
962 : : }
963 : 0 : break;
964 : :
965 : : case RID_SVXPAGE_NUM_OPTIONS:
966 : : {
967 : 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
968 : 0 : aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFmt));
969 : 0 : aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
970 : : // collect char styles
971 : 0 : ListBox rCharFmtLB(this);
972 : 0 : rCharFmtLB.Clear();
973 : 0 : rCharFmtLB.InsertEntry( ViewShell::GetShellRes()->aStrNone );
974 : 0 : SwDocShell* pDocShell = rWrtSh.GetView().GetDocShell();
975 : 0 : ::FillCharStyleListBox(rCharFmtLB, pDocShell);
976 : :
977 : 0 : std::vector<String> aList;
978 : 0 : for(sal_uInt16 j = 0; j < rCharFmtLB.GetEntryCount(); j++)
979 : 0 : aList.push_back( String(rCharFmtLB.GetEntry(j)));
980 : :
981 : 0 : aSet.Put( SfxStringListItem( SID_CHAR_FMT_LIST_BOX,&aList ) ) ;
982 : :
983 : 0 : FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, pDocShell));
984 : 0 : aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< sal_uInt16 >(eMetric) ) );
985 : 0 : rPage.PageCreated(aSet);
986 : : }
987 : 0 : break;
988 : : case RID_SVXPAGE_NUM_POSITION:
989 : : {
990 : 0 : SwDocShell* pDocShell = rWrtSh.GetView().GetDocShell();
991 : 0 : FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, pDocShell));
992 : 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
993 : 0 : aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< sal_uInt16 >(eMetric)) );
994 : 0 : rPage.PageCreated(aSet);
995 : : }
996 : 0 : break;
997 : 0 : }
998 : 0 : }
999 : :
1000 : 0 : short SwSvxNumBulletTabDialog::Ok()
1001 : : {
1002 : 0 : short nRet = SfxTabDialog::Ok();
1003 : 0 : pExampleSet->ClearItem(SID_PARAM_NUM_PRESET);
1004 : 0 : return nRet;
1005 : : }
1006 : :
1007 : 0 : IMPL_LINK_NOARG(SwSvxNumBulletTabDialog, RemoveNumberingHdl)
1008 : : {
1009 : 0 : EndDialog(RET_USER);
1010 : 0 : return 0;
1011 : : }
1012 : :
1013 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|