update dev300-m58
[ooovba.git] / sw / source / ui / misc / num.cxx
blobe413da5580f5cb3f980a13eece8b7254aae9ef28
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: num.cxx,v $
10 * $Revision: 1.21 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
35 #endif
39 #define USE_NUMTABPAGES
40 #define _NUM_CXX
41 #include <hintids.hxx>
43 #ifndef _MSGBOX_HXX //autogen
44 #include <vcl/msgbox.hxx>
45 #endif
46 #include <tools/urlobj.hxx>
47 #include <sfx2/app.hxx>
48 #include <sfx2/imgmgr.hxx>
49 #include <svx/gallery.hxx>
50 #include <svx/brshitem.hxx>
51 #include <svx/lrspitem.hxx>
52 #include <svx/impgrf.hxx>
53 #include <svx/numitem.hxx>
54 #include <swvset.hxx>
55 #include <swmodule.hxx>
56 #include <wrtsh.hxx>
57 #ifndef _DOCSH_HXX
58 #include <docsh.hxx>
59 #endif
60 #ifndef _WVIEW_HXX
61 #include <wview.hxx>
62 #endif
63 #include <uitool.hxx>
64 #ifndef _WDOCSH_HXX
65 #include <wdocsh.hxx>
66 #endif
67 #include <uiitems.hxx>
68 #include <docstyle.hxx>
69 #include <charfmt.hxx>
70 #include <uinums.hxx>
71 #include <poolfmt.hxx>
72 #include <shellres.hxx>
73 #include <outline.hxx>
74 #include <num.hxx>
75 #include <viewopt.hxx>
76 #include <frmmgr.hxx>
78 #ifndef _MISC_HRC
79 #include <misc.hrc>
80 #endif
81 #ifndef _FRMUI_HRC
82 #include <frmui.hrc>
83 #endif
84 #ifndef _NUM_HRC
85 #include <num.hrc>
86 #endif
87 #ifndef _GLOBALS_HRC
88 #include <globals.hrc>
89 #endif
90 #ifndef _HELPID_H
91 #include <helpid.h>
92 #endif
93 #include <SwStyleNameMapper.hxx>
94 #include <svx/svxids.hrc>
95 #include <svx/dialogs.hrc>
96 #include <svtools/stritem.hxx>
97 #include <svtools/aeitem.hxx>
98 #include <svtools/slstitm.hxx>
100 static BOOL bLastRelative = FALSE;
102 /*-----------------03.12.97 10:02-------------------
104 --------------------------------------------------*/
105 SwNumPositionTabPage::SwNumPositionTabPage(Window* pParent,
106 const SfxItemSet& rSet) :
107 SfxTabPage( pParent, SW_RES( TP_NUM_POSITION ), rSet ),
108 aPositionFL( this, SW_RES(FL_POSITION )),
109 aLevelFL( this, SW_RES(FL_LEVEL )),
110 aLevelLB( this, SW_RES(LB_LEVEL )),
112 aDistBorderFT( this, SW_RES(FT_BORDERDIST )),
113 aDistBorderMF( this, SW_RES(MF_BORDERDIST )),
114 aRelativeCB( this, SW_RES(CB_RELATIVE )),
115 aIndentFT( this, SW_RES(FT_INDENT )),
116 aIndentMF( this, SW_RES(MF_INDENT )),
117 aDistNumFT( this, SW_RES(FT_NUMDIST )),
118 aDistNumMF( this, SW_RES(MF_NUMDIST )),
119 aAlignFT( this, SW_RES(FT_ALIGN )),
120 aAlignLB( this, SW_RES(LB_ALIGN )),
121 // --> OD 2008-02-01 #newlistlevelattrs#
122 aLabelFollowedByFT( this, SW_RES(FT_LABEL_FOLLOWED_BY) ),
123 aLabelFollowedByLB( this, SW_RES(LB_LABEL_FOLLOWED_BY) ),
124 aListtabFT( this, SW_RES(FT_LISTTAB) ),
125 aListtabMF( this, SW_RES(MF_LISTTAB) ),
126 aAlign2FT( this, SW_RES(FT_ALIGN_2) ),
127 aAlign2LB( this, SW_RES(LB_ALIGN_2) ),
128 aAlignedAtFT( this, SW_RES(FT_ALIGNED_AT) ),
129 aAlignedAtMF( this, SW_RES(MF_ALIGNED_AT) ),
130 aIndentAtFT( this, SW_RES(FT_INDENT_AT) ),
131 aIndentAtMF( this, SW_RES(MF_INDENT_AT) ),
132 // <--
133 aStandardPB( this, SW_RES(PB_STANDARD )),
135 aPreviewWIN( this, SW_RES(WIN_PREVIEW )),
137 pActNum(0),
138 pSaveNum(0),
139 pWrtSh(0),
140 pOutlineDlg(0),
141 bPreset( FALSE ),
142 bInInintControl(FALSE),
143 // --> OD 2008-02-01 #newlistlevelattrs#
144 bLabelAlignmentPosAndSpaceModeActive( false )
145 // <--
147 FreeResource();
148 SetExchangeSupport();
149 aPreviewWIN.SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
151 aRelativeCB.Check();
152 aAlignLB.SetSelectHdl(LINK(this, SwNumPositionTabPage, EditModifyHdl));
153 // --> OD 2008-02-01 #newlistlevelattrs#
154 aAlign2LB.SetSelectHdl(LINK(this, SwNumPositionTabPage, EditModifyHdl));
155 for ( USHORT i = 0; i < aAlignLB.GetEntryCount(); ++i )
157 aAlign2LB.InsertEntry( aAlignLB.GetEntry( i ) );
159 aAlign2LB.SetDropDownLineCount( aAlign2LB.GetEntryCount() );
160 aAlign2FT.SetText( aAlignFT.GetText() );
161 // <--
163 Link aLk = LINK(this, SwNumPositionTabPage, DistanceHdl);
164 aDistBorderMF.SetUpHdl(aLk);
165 aDistNumMF.SetUpHdl(aLk);
166 aIndentMF.SetUpHdl(aLk);
167 aDistBorderMF.SetDownHdl(aLk);
168 aDistNumMF.SetDownHdl(aLk);
169 aIndentMF.SetDownHdl(aLk);
170 aDistBorderMF.SetLoseFocusHdl(aLk);
171 aDistNumMF.SetLoseFocusHdl(aLk);
172 aIndentMF.SetLoseFocusHdl(aLk);
174 // --> OD 2008-02-01 #newlistlevelattrs#
175 aLabelFollowedByLB.SetDropDownLineCount( aLabelFollowedByLB.GetEntryCount() );
176 aLabelFollowedByLB.SetSelectHdl( LINK(this, SwNumPositionTabPage, LabelFollowedByHdl_Impl) );
178 aLk = LINK(this, SwNumPositionTabPage, ListtabPosHdl_Impl);
179 aListtabMF.SetUpHdl(aLk);
180 aListtabMF.SetDownHdl(aLk);
181 aListtabMF.SetLoseFocusHdl(aLk);
183 aLk = LINK(this, SwNumPositionTabPage, AlignAtHdl_Impl);
184 aAlignedAtMF.SetUpHdl(aLk);
185 aAlignedAtMF.SetDownHdl(aLk);
186 aAlignedAtMF.SetLoseFocusHdl(aLk);
188 aLk = LINK(this, SwNumPositionTabPage, IndentAtHdl_Impl);
189 aIndentAtMF.SetUpHdl(aLk);
190 aIndentAtMF.SetDownHdl(aLk);
191 aIndentAtMF.SetLoseFocusHdl(aLk);
192 // <--
194 aLevelLB.SetSelectHdl(LINK(this, SwNumPositionTabPage, LevelHdl));
195 aRelativeCB.SetClickHdl(LINK(this, SwNumPositionTabPage, RelativeHdl));
196 aStandardPB.SetClickHdl(LINK(this, SwNumPositionTabPage, StandardHdl));
198 // Ebenen einfuegen
199 for(USHORT i = 1; i <= MAXLEVEL; i++)
200 aLevelLB.InsertEntry(String::CreateFromInt32(i));
201 String sEntry(String::CreateFromAscii("1 - "));
202 sEntry += String::CreateFromInt32(MAXLEVEL);
203 aLevelLB.InsertEntry(sEntry);
204 aLevelLB.SelectEntry(sEntry);
206 aRelativeCB.Check(bLastRelative);
207 aPreviewWIN.SetPositionMode();
209 /*-----------------03.12.97 10:02-------------------
211 --------------------------------------------------*/
212 SwNumPositionTabPage::~SwNumPositionTabPage()
214 delete pActNum;
216 /*-----------------03.12.97 10:06-------------------
218 --------------------------------------------------*/
219 void SwNumPositionTabPage::InitControls()
221 bInInintControl = TRUE;
222 // --> OD 2008-02-01 #newlistlevelattrs#
223 const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
224 aRelativeCB.IsEnabled() && aRelativeCB.IsChecked();
225 const bool bSingleSelection = aLevelLB.GetSelectEntryCount() == 1 &&
226 USHRT_MAX != nActNumLvl;
228 aDistBorderMF.Enable( !bLabelAlignmentPosAndSpaceModeActive &&
229 ( bSingleSelection || bRelative || pOutlineDlg != 0 ) );
230 aDistBorderFT.Enable( !bLabelAlignmentPosAndSpaceModeActive &&
231 ( bSingleSelection || bRelative || pOutlineDlg != 0 ) );
232 // <--
234 bool bSetDistEmpty = false;
235 bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
236 bool bSameDist = !bLabelAlignmentPosAndSpaceModeActive;
237 bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive;
238 bool bSameAdjust = true;
240 // --> OD 2008-02-01 #newlistlevelattrs#
241 bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
242 bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
243 bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
244 bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
245 // <--
247 const SwNumFmt* aNumFmtArr[MAXLEVEL];
248 const SwFmtVertOrient* pFirstOrient = 0;
249 USHORT nMask = 1;
250 USHORT nLvl = USHRT_MAX;
251 long nFirstBorderText = 0;
252 long nFirstBorderTextRelative = -1;
253 for(USHORT i = 0; i < MAXLEVEL; i++)
255 aNumFmtArr[i] = &pActNum->Get(i);
256 if(nActNumLvl & nMask)
258 if(USHRT_MAX == nLvl)
260 nLvl = i;
261 // --> OD 2008-02-01 #newlistlevelattrs#
262 if ( !bLabelAlignmentPosAndSpaceModeActive )
264 pFirstOrient = aNumFmtArr[nLvl]->GetGraphicOrientation();
265 nFirstBorderText = nLvl > 0 ?
266 aNumFmtArr[nLvl]->GetAbsLSpace() + aNumFmtArr[nLvl]->GetFirstLineOffset() -
267 aNumFmtArr[nLvl - 1]->GetAbsLSpace() + aNumFmtArr[nLvl - 1]->GetFirstLineOffset():
268 aNumFmtArr[nLvl]->GetAbsLSpace() + aNumFmtArr[nLvl]->GetFirstLineOffset();
270 // <--
273 if( i > nLvl)
275 // --> OD 2008-02-01 #newlistlevelattrs#
276 bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
277 if ( !bLabelAlignmentPosAndSpaceModeActive )
279 if(bRelative)
281 if(nFirstBorderTextRelative == -1)
282 nFirstBorderTextRelative =
283 (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
284 aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
285 else
286 bSameDistBorderNum &= nFirstBorderTextRelative ==
287 (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
288 aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
291 else
293 bSameDistBorderNum &=
294 aNumFmtArr[i]->GetAbsLSpace() - aNumFmtArr[i]->GetFirstLineOffset() ==
295 aNumFmtArr[i - 1]->GetAbsLSpace() - aNumFmtArr[i - 1]->GetFirstLineOffset();
298 bSameDist &= aNumFmtArr[i]->GetCharTextDistance() == aNumFmtArr[nLvl]->GetCharTextDistance();
299 bSameIndent &= aNumFmtArr[i]->GetFirstLineOffset() == aNumFmtArr[nLvl]->GetFirstLineOffset();
301 else
303 bSameLabelFollowedBy &=
304 aNumFmtArr[i]->GetLabelFollowedBy() == aNumFmtArr[nLvl]->GetLabelFollowedBy();
305 bSameListtab &=
306 aNumFmtArr[i]->GetListtabPos() == aNumFmtArr[nLvl]->GetListtabPos();
307 bSameAlignAt &=
308 ( ( aNumFmtArr[i]->GetIndentAt() + aNumFmtArr[i]->GetFirstLineIndent() )
309 == ( aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent() ) );
310 bSameIndentAt &=
311 aNumFmtArr[i]->GetIndentAt() == aNumFmtArr[nLvl]->GetIndentAt();
313 // <--
317 nMask <<= 1;
320 if(bSameDistBorderNum)
322 long nDistBorderNum;
323 if(bRelative)
325 nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
326 if(nLvl)
327 nDistBorderNum -= (long)aNumFmtArr[nLvl - 1]->GetAbsLSpace()+ aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
329 else
331 nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
333 aDistBorderMF.SetValue(aDistBorderMF.Normalize(nDistBorderNum),FUNIT_TWIP);
335 else
336 bSetDistEmpty = TRUE;
338 if(bSameDist)
339 aDistNumMF .SetValue(aDistNumMF.Normalize(aNumFmtArr[nLvl]->GetCharTextDistance()), FUNIT_TWIP);
340 else
341 aDistNumMF.SetText(aEmptyStr);
342 if(bSameIndent)
343 aIndentMF.SetValue(aIndentMF.Normalize(-aNumFmtArr[nLvl]->GetFirstLineOffset()), FUNIT_TWIP);
344 else
345 aIndentMF.SetText(aEmptyStr);
347 if(bSameAdjust)
349 USHORT nPos = 1; // zentriert
350 if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
351 nPos = 0;
352 else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
353 nPos = 2;
354 aAlignLB.SelectEntryPos(nPos);
355 // --> OD 2008-02-01 #newlistlevelattrs#
356 aAlign2LB.SelectEntryPos( nPos );
357 // <--
359 else
361 aAlignLB.SetNoSelection();
362 // --> OD 2008-02-01 #newlistlevelattrs#
363 aAlign2LB.SetNoSelection();
364 // <--
367 // --> OD 2008-02-01 #newlistlevelattrs#
368 if ( bSameLabelFollowedBy )
370 USHORT nPos = 0; // LISTTAB
371 if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
373 nPos = 1;
375 else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
377 nPos = 2;
379 aLabelFollowedByLB.SelectEntryPos( nPos );
381 else
383 aLabelFollowedByLB.SetNoSelection();
386 if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
388 aListtabFT.Enable( true );
389 aListtabMF.Enable( true );
390 if ( bSameListtab )
392 aListtabMF.SetValue(aListtabMF.Normalize(aNumFmtArr[nLvl]->GetListtabPos()),FUNIT_TWIP);
394 else
396 aListtabMF.SetText(aEmptyStr);
399 else
401 aListtabFT.Enable( false );
402 aListtabMF.Enable( false );
403 aListtabMF.SetText(aEmptyStr);
406 if ( bSameAlignAt )
408 aAlignedAtMF.SetValue(
409 aAlignedAtMF.Normalize( aNumFmtArr[nLvl]->GetIndentAt() +
410 aNumFmtArr[nLvl]->GetFirstLineIndent()),
411 FUNIT_TWIP );
413 else
415 aAlignedAtMF.SetText(aEmptyStr);
418 if ( bSameIndentAt )
420 aIndentAtMF.SetValue(
421 aIndentAtMF.Normalize( aNumFmtArr[nLvl]->GetIndentAt()), FUNIT_TWIP );
423 else
425 aIndentAtMF.SetText(aEmptyStr);
427 // <--
429 if(TRUE == bSetDistEmpty)
430 aDistBorderMF.SetText(aEmptyStr);
432 bInInintControl = FALSE;
435 /*-----------------03.12.97 10:02-------------------
437 --------------------------------------------------*/
438 void SwNumPositionTabPage::ActivatePage(const SfxItemSet& )
440 const SfxPoolItem* pItem;
441 UINT16 nTmpNumLvl =
442 pOutlineDlg ? pOutlineDlg->GetActNumLevel() : 0;
443 const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
444 if(pExampleSet && pExampleSet->GetItemState(FN_PARAM_NUM_PRESET, FALSE, &pItem))
446 bPreset = ((const SfxBoolItem*)pItem)->GetValue();
449 bModified = (!pActNum->GetNumFmt( 0 ) || bPreset);
450 if(*pActNum != *pSaveNum ||
451 nActNumLvl != nTmpNumLvl )
453 *pActNum = *pSaveNum;
454 nActNumLvl = nTmpNumLvl;
455 USHORT nMask = 1;
456 aLevelLB.SetUpdateMode(FALSE);
457 aLevelLB.SetNoSelection();
458 aLevelLB.SelectEntryPos( MAXLEVEL, nActNumLvl == USHRT_MAX);
459 if(nActNumLvl != USHRT_MAX)
460 for(USHORT i = 0; i < MAXLEVEL; i++)
462 if(nActNumLvl & nMask)
463 aLevelLB.SelectEntryPos( i, TRUE);
464 nMask <<= 1 ;
466 aLevelLB.SetUpdateMode(TRUE);
468 // --> OD 2008-02-01 #newlistlevelattrs#
469 InitPosAndSpaceMode();
470 ShowControlsDependingOnPosAndSpaceMode();
471 // <--
473 InitControls();
475 aRelativeCB.Enable(1 != nActNumLvl);
476 aPreviewWIN.Invalidate();
479 /*-----------------03.12.97 10:02-------------------
481 --------------------------------------------------*/
482 int SwNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet)
484 SwOutlineTabDialog::SetActNumLevel(nActNumLvl);
485 if(_pSet)
486 FillItemSet(*_pSet);
487 return TRUE;
491 /*-----------------03.12.97 10:02-------------------
493 --------------------------------------------------*/
494 BOOL SwNumPositionTabPage::FillItemSet( SfxItemSet& rSet )
496 if(pOutlineDlg)
497 *pOutlineDlg->GetNumRule() = *pActNum;
498 else if(bModified && pActNum)
500 *pSaveNum = *pActNum;
501 rSet.Put(SwUINumRuleItem( *pSaveNum ));
502 rSet.Put(SfxBoolItem(FN_PARAM_NUM_PRESET, FALSE));
504 return bModified;
507 /*-----------------03.12.97 10:02-------------------
509 --------------------------------------------------*/
510 void SwNumPositionTabPage::Reset( const SfxItemSet& rSet )
512 const SfxPoolItem* pItem;
513 if(pOutlineDlg)
515 pSaveNum = pOutlineDlg->GetNumRule();
516 aLevelLB.EnableMultiSelection(FALSE);
518 else if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_ACT_NUMBER, FALSE, &pItem))
519 pSaveNum = ((SwUINumRuleItem*)pItem)->GetNumRule();
521 nActNumLvl = SwOutlineTabDialog::GetActNumLevel();
522 USHORT nMask = 1;
523 aLevelLB.SetUpdateMode(FALSE);
524 aLevelLB.SetNoSelection();
525 if(nActNumLvl == USHRT_MAX)
527 aLevelLB.SelectEntryPos( MAXLEVEL, TRUE);
529 else
530 for(USHORT i = 0; i < MAXLEVEL; i++)
532 if(nActNumLvl & nMask)
533 aLevelLB.SelectEntryPos( i, TRUE);
534 nMask <<= 1;
536 aLevelLB.SetUpdateMode(TRUE);
538 if(!pActNum)
539 pActNum = new SwNumRule(*pSaveNum);
540 else if(*pSaveNum != *pActNum)
541 *pActNum = *pSaveNum;
542 aPreviewWIN.SetNumRule(pActNum);
543 // --> OD 2008-02-01 #newlistlevelattrs#
544 InitPosAndSpaceMode();
545 ShowControlsDependingOnPosAndSpaceMode();
546 // <--
547 InitControls();
548 bModified = FALSE;
551 // --> OD 2008-01-11 #newlistlevelattrs#
552 void SwNumPositionTabPage::InitPosAndSpaceMode()
554 if ( pActNum == 0 )
556 DBG_ASSERT( false,
557 "<SwNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
558 return;
561 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode =
562 SvxNumberFormat::LABEL_ALIGNMENT;
563 USHORT nMask = 1;
564 for( USHORT i = 0; i < MAXLEVEL; ++i )
566 if(nActNumLvl & nMask)
568 SvxNumberFormat aNumFmt( pActNum->Get(i) );
569 ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
570 if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
572 break;
575 nMask <<= 1;
578 bLabelAlignmentPosAndSpaceModeActive =
579 ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
582 void SwNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
584 aDistBorderFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
585 aDistBorderMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
586 aRelativeCB.Show( !bLabelAlignmentPosAndSpaceModeActive );
587 aIndentFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
588 aIndentMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
589 aDistNumFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
590 aDistNumMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
591 aAlignFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
592 aAlignLB.Show( !bLabelAlignmentPosAndSpaceModeActive );
594 aLabelFollowedByFT.Show( bLabelAlignmentPosAndSpaceModeActive );
595 aLabelFollowedByLB.Show( bLabelAlignmentPosAndSpaceModeActive );
596 aListtabFT.Show( bLabelAlignmentPosAndSpaceModeActive );
597 aListtabMF.Show( bLabelAlignmentPosAndSpaceModeActive );
598 aAlign2FT.Show( bLabelAlignmentPosAndSpaceModeActive );
599 aAlign2LB.Show( bLabelAlignmentPosAndSpaceModeActive );
600 aAlignedAtFT.Show( bLabelAlignmentPosAndSpaceModeActive );
601 aAlignedAtMF.Show( bLabelAlignmentPosAndSpaceModeActive );
602 aIndentAtFT.Show( bLabelAlignmentPosAndSpaceModeActive );
603 aIndentAtMF.Show( bLabelAlignmentPosAndSpaceModeActive );
605 // <--
607 /*-----------------03.12.97 10:02-------------------
609 --------------------------------------------------*/
610 SfxTabPage* SwNumPositionTabPage::Create( Window* pParent,
611 const SfxItemSet& rAttrSet)
613 return new SwNumPositionTabPage(pParent, rAttrSet);
616 /*-----------------04.12.97 12:51-------------------
618 --------------------------------------------------*/
619 void SwNumPositionTabPage::SetWrtShell(SwWrtShell* pSh)
621 pWrtSh = pSh;
623 // --> OD 2008-02-01 #newlistlevelattrs#
624 const SwTwips nWidth = pWrtSh->GetAnyCurRect(RECT_FRM).Width();
626 aDistBorderMF.SetMax(aDistBorderMF.Normalize( nWidth ), FUNIT_TWIP );
627 aDistNumMF .SetMax(aDistNumMF .Normalize( nWidth ), FUNIT_TWIP );
628 aIndentMF .SetMax(aIndentMF .Normalize( nWidth ), FUNIT_TWIP );
629 // --> OD 2008-02-18 #newlistlevelattrs#
630 aListtabMF.SetMax(aListtabMF.Normalize( nWidth ), FUNIT_TWIP );
631 aAlignedAtMF.SetMax(aAlignedAtMF.Normalize( nWidth ), FUNIT_TWIP );
632 aIndentAtMF.SetMax(aIndentAtMF.Normalize( nWidth ), FUNIT_TWIP );
633 // <--
634 const SwTwips nLast2 = nWidth /2;
635 aDistBorderMF.SetLast( aDistBorderMF.Normalize( nLast2 ), FUNIT_TWIP );
636 aDistNumMF .SetLast( aDistNumMF .Normalize( nLast2 ), FUNIT_TWIP );
637 aIndentMF .SetLast( aIndentMF .Normalize( nLast2 ), FUNIT_TWIP );
638 // --> OD 2008-02-18 #newlistlevelattrs#
639 aListtabMF.SetLast(aListtabMF.Normalize( nLast2 ), FUNIT_TWIP );
640 aAlignedAtMF.SetLast(aAlignedAtMF.Normalize( nLast2 ), FUNIT_TWIP );
641 aIndentAtMF.SetLast(aIndentAtMF.Normalize( nLast2 ), FUNIT_TWIP );
642 // <--
643 // <--
645 const SwRect& rPrtRect = pWrtSh->GetAnyCurRect(RECT_PAGE);
646 aPreviewWIN.SetPageWidth(rPrtRect.Width());
647 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &pWrtSh->GetView()));
648 if(eMetric == FUNIT_MM)
650 aDistBorderMF .SetDecimalDigits(1);
651 aDistNumMF .SetDecimalDigits(1);
652 aIndentMF .SetDecimalDigits(1);
653 // --> OD 2008-02-18 #newlistlevelattrs#
654 aListtabMF.SetDecimalDigits(1);
655 aAlignedAtMF.SetDecimalDigits(1);
656 aIndentAtMF.SetDecimalDigits(1);
657 // <--
659 aDistBorderMF .SetUnit( eMetric );
660 aDistNumMF .SetUnit( eMetric );
661 aIndentMF .SetUnit( eMetric );
662 // --> OD 2008-02-18 #newlistlevelattrs#
663 aListtabMF.SetUnit( eMetric );
664 aAlignedAtMF.SetUnit( eMetric );
665 aIndentAtMF.SetUnit( eMetric );
666 // <--
669 /*-----------------03.12.97 11:06-------------------
671 --------------------------------------------------*/
672 IMPL_LINK( SwNumPositionTabPage, EditModifyHdl, Edit *, EMPTYARG )
674 USHORT nMask = 1;
675 for(USHORT i = 0; i < MAXLEVEL; i++)
677 if(nActNumLvl & nMask)
679 SwNumFmt aNumFmt(pActNum->Get(i));
681 // --> OD 2008-02-01 #newlistlevelattrs#
682 const USHORT nPos = aAlignLB.IsVisible()
683 ? aAlignLB.GetSelectEntryPos()
684 : aAlign2LB.GetSelectEntryPos();
685 // <--
686 SvxAdjust eAdjust = SVX_ADJUST_CENTER;
687 if(nPos == 0)
688 eAdjust = SVX_ADJUST_LEFT;
689 else if(nPos == 2)
690 eAdjust = SVX_ADJUST_RIGHT;
691 aNumFmt.SetNumAdjust( eAdjust );
692 pActNum->Set(i, aNumFmt);
694 nMask <<= 1;
696 SetModified();
697 return 0;
699 /*-----------------03.12.97 11:11-------------------
701 --------------------------------------------------*/
702 IMPL_LINK( SwNumPositionTabPage, LevelHdl, ListBox *, pBox )
704 USHORT nSaveNumLvl = nActNumLvl;
705 nActNumLvl = 0;
706 if(pBox->IsEntryPosSelected( MAXLEVEL ) &&
707 (pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
709 nActNumLvl = 0xFFFF;
710 pBox->SetUpdateMode(FALSE);
711 for( USHORT i = 0; i < MAXLEVEL; i++ )
712 pBox->SelectEntryPos( i, FALSE );
713 pBox->SetUpdateMode(TRUE);
715 else if(pBox->GetSelectEntryCount())
717 USHORT nMask = 1;
718 for( USHORT i = 0; i < MAXLEVEL; i++ )
720 if(pBox->IsEntryPosSelected( i ))
721 nActNumLvl |= nMask;
722 nMask <<= 1;
724 pBox->SelectEntryPos( MAXLEVEL, FALSE );
726 else
728 nActNumLvl = nSaveNumLvl;
729 USHORT nMask = 1;
730 for( USHORT i = 0; i < MAXLEVEL; i++ )
732 if(nActNumLvl & nMask)
734 pBox->SelectEntryPos(i);
735 break;
737 nMask <<=1;
740 aRelativeCB.Enable(1 != nActNumLvl);
741 SetModified();
742 // --> OD 2008-02-01 #newlistlevelattrs#
743 InitPosAndSpaceMode();
744 ShowControlsDependingOnPosAndSpaceMode();
745 // <--
746 InitControls();
747 return 0;
749 /*-----------------03.12.97 12:24-------------------
751 --------------------------------------------------*/
752 IMPL_LINK( SwNumPositionTabPage, DistanceHdl, MetricField *, pFld )
754 if(bInInintControl)
755 return 0;
756 long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
757 USHORT nMask = 1;
758 for(USHORT i = 0; i < MAXLEVEL; i++)
760 if(nActNumLvl & nMask)
762 SwNumFmt aNumFmt( pActNum->Get( i ) );
763 if(pFld == &aDistBorderMF)
766 if(aRelativeCB.IsChecked() && aRelativeCB.IsEnabled())
768 if(0 == i)
770 long nTmp = aNumFmt.GetFirstLineOffset();
771 aNumFmt.SetAbsLSpace( USHORT(nValue - nTmp));
773 else
775 long nTmp = pActNum->Get( i - 1 ).GetAbsLSpace() +
776 pActNum->Get( i - 1 ).GetFirstLineOffset() -
777 pActNum->Get( i ).GetFirstLineOffset();
779 aNumFmt.SetAbsLSpace( USHORT(nValue + nTmp));
782 else
784 aNumFmt.SetAbsLSpace( (short)nValue - aNumFmt.GetFirstLineOffset());
787 else if(pFld == &aDistNumMF)
789 aNumFmt.SetCharTextDistance( (short)nValue );
791 else if(pFld == &aIndentMF)
793 //jetzt muss mit dem FirstLineOffset auch der AbsLSpace veraendert werden
794 long nDiff = nValue + aNumFmt.GetFirstLineOffset();
795 long nAbsLSpace = aNumFmt.GetAbsLSpace();
796 aNumFmt.SetAbsLSpace(USHORT(nAbsLSpace + nDiff));
797 aNumFmt.SetFirstLineOffset( -(short)nValue );
800 pActNum->Set( i, aNumFmt );
802 nMask <<= 1;
805 SetModified();
806 if(!aDistBorderMF.IsEnabled())
807 aDistBorderMF.SetText(aEmptyStr);
809 return 0;
812 /*-----------------04.12.97 12:35-------------------
814 --------------------------------------------------*/
815 IMPL_LINK( SwNumPositionTabPage, RelativeHdl, CheckBox *, pBox )
817 BOOL bOn = pBox->IsChecked();
818 BOOL bSingleSelection = aLevelLB.GetSelectEntryCount() == 1 && USHRT_MAX != nActNumLvl;
819 BOOL bSetValue = FALSE;
820 long nValue = 0;
821 if(bOn || bSingleSelection)
823 USHORT nMask = 1;
824 BOOL bFirst = TRUE;
825 bSetValue = TRUE;
826 for(USHORT i = 0; i < MAXLEVEL; i++)
828 if(nActNumLvl & nMask)
830 const SwNumFmt &rNumFmt = pActNum->Get(i);
831 if(bFirst)
833 nValue = rNumFmt.GetAbsLSpace();
834 if(bOn && i)
835 nValue -= pActNum->Get(i - 1).GetAbsLSpace();
837 else
838 bSetValue = nValue == rNumFmt.GetAbsLSpace() - pActNum->Get(i - 1).GetAbsLSpace();
839 bFirst = FALSE;
841 nMask <<= 1;
845 if(bSetValue)
846 aDistBorderMF.SetValue(aDistBorderMF.Normalize(nValue), FUNIT_TWIP);
847 else
848 aDistBorderMF.SetText(aEmptyStr);
849 aDistBorderMF.Enable(bOn || bSingleSelection||0 != pOutlineDlg);
850 bLastRelative = bOn;
851 return 0;
854 // --> OD 2008-02-01 #newlistlevelattrs#
855 IMPL_LINK( SwNumPositionTabPage, LabelFollowedByHdl_Impl, ListBox*, EMPTYARG )
857 // determine value to be set at the chosen list levels
858 SvxNumberFormat::SvxNumLabelFollowedBy eLabelFollowedBy =
859 SvxNumberFormat::LISTTAB;
861 const USHORT nPos = aLabelFollowedByLB.GetSelectEntryPos();
862 if ( nPos == 1 )
864 eLabelFollowedBy = SvxNumberFormat::SPACE;
866 else if ( nPos == 2 )
868 eLabelFollowedBy = SvxNumberFormat::NOTHING;
872 // set value at the chosen list levels
873 bool bSameListtabPos = true;
874 USHORT nFirstLvl = USHRT_MAX;
875 USHORT nMask = 1;
876 for( USHORT i = 0; i < MAXLEVEL; ++i )
878 if ( nActNumLvl & nMask )
880 SwNumFmt aNumFmt( pActNum->Get(i) );
881 aNumFmt.SetLabelFollowedBy( eLabelFollowedBy );
882 pActNum->Set( i, aNumFmt );
884 if ( nFirstLvl == USHRT_MAX )
886 nFirstLvl = i;
888 else
890 bSameListtabPos &= aNumFmt.GetListtabPos() ==
891 pActNum->Get( nFirstLvl ).GetListtabPos();
894 nMask <<= 1;
897 // enable/disable metric field for list tab stop position depending on
898 // selected item following the list label.
899 aListtabFT.Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
900 aListtabMF.Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
901 if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
903 aListtabMF.SetValue(
904 aListtabMF.Normalize( pActNum->Get( nFirstLvl ).GetListtabPos() ),
905 FUNIT_TWIP );
907 else
909 aListtabMF.SetText( String() );
912 SetModified();
914 return 0;
916 // <--
918 // --> OD 2008-02-01 #newlistlevelattrs#
919 IMPL_LINK( SwNumPositionTabPage, ListtabPosHdl_Impl, MetricField*, pFld )
921 // determine value to be set at the chosen list levels
922 const long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
924 // set value at the chosen list levels
925 USHORT nMask = 1;
926 for( USHORT i = 0; i < MAXLEVEL; ++i )
928 if ( nActNumLvl & nMask )
930 SwNumFmt aNumFmt( pActNum->Get(i) );
931 aNumFmt.SetListtabPos( nValue );
932 pActNum->Set( i, aNumFmt );
934 nMask <<= 1;
937 SetModified();
939 return 0;
941 // <--
943 // --> OD 2008-02-01 #newlistlevelattrs#
944 IMPL_LINK( SwNumPositionTabPage, AlignAtHdl_Impl, MetricField*, pFld )
946 // determine value to be set at the chosen list levels
947 const long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
949 // set value at the chosen list levels
950 USHORT nMask = 1;
951 for( USHORT i = 0; i < MAXLEVEL; ++i )
953 if ( nActNumLvl & nMask )
955 SwNumFmt aNumFmt( pActNum->Get(i) );
956 const long nFirstLineIndent = nValue - aNumFmt.GetIndentAt();
957 aNumFmt.SetFirstLineIndent( nFirstLineIndent );
958 pActNum->Set( i, aNumFmt );
960 nMask <<= 1;
963 SetModified();
965 return 0;
967 // <--
969 // --> OD 2008-02-01 #newlistlevelattrs#
970 IMPL_LINK( SwNumPositionTabPage, IndentAtHdl_Impl, MetricField*, pFld )
972 // determine value to be set at the chosen list levels
973 const long nValue = static_cast< long >(pFld->Denormalize(pFld->GetValue(FUNIT_TWIP)));
975 // set value at the chosen list levels
976 USHORT nMask = 1;
977 for( USHORT i = 0; i < MAXLEVEL; ++i )
979 if ( nActNumLvl & nMask )
981 SwNumFmt aNumFmt( pActNum->Get(i) );
982 const long nAlignedAt = aNumFmt.GetIndentAt() +
983 aNumFmt.GetFirstLineIndent();
984 aNumFmt.SetIndentAt( nValue );
985 const long nNewFirstLineIndent = nAlignedAt - nValue;
986 aNumFmt.SetFirstLineIndent( nNewFirstLineIndent );
987 pActNum->Set( i, aNumFmt );
989 nMask <<= 1;
992 SetModified();
994 return 0;
996 // <--
998 /*-----------------05.12.97 15:33-------------------
1000 --------------------------------------------------*/
1001 IMPL_LINK( SwNumPositionTabPage, StandardHdl, PushButton *, EMPTYARG )
1003 USHORT nMask = 1;
1004 for(USHORT i = 0; i < MAXLEVEL; i++)
1006 if(nActNumLvl & nMask)
1008 SwNumFmt aNumFmt( pActNum->Get( i ) );
1009 // --> OD 2008-02-11 #newlistlevelattrs#
1010 SwNumRule aTmpNumRule( pWrtSh->GetUniqueNumRuleName(),
1011 aNumFmt.GetPositionAndSpaceMode(),
1012 pOutlineDlg ? OUTLINE_RULE : NUM_RULE );
1013 // <--
1014 SwNumFmt aTempFmt(aTmpNumRule.Get( i ));
1015 // --> OD 2008-02-05 #newlistlevelattrs#
1016 aNumFmt.SetPositionAndSpaceMode( aTempFmt.GetPositionAndSpaceMode() );
1017 if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1019 aNumFmt.SetAbsLSpace( aTempFmt.GetAbsLSpace());
1020 aNumFmt.SetCharTextDistance( aTempFmt.GetCharTextDistance() );
1021 aNumFmt.SetFirstLineOffset( aTempFmt.GetFirstLineOffset() );
1023 else if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1025 aNumFmt.SetNumAdjust( aTempFmt.GetNumAdjust() );
1026 aNumFmt.SetLabelFollowedBy( aTempFmt.GetLabelFollowedBy() );
1027 aNumFmt.SetListtabPos( aTempFmt.GetListtabPos() );
1028 aNumFmt.SetFirstLineIndent( aTempFmt.GetFirstLineIndent() );
1029 aNumFmt.SetIndentAt( aTempFmt.GetIndentAt() );
1031 // <--
1033 pActNum->Set( i, aNumFmt );
1035 nMask <<= 1;
1038 InitControls();
1039 SetModified();
1040 return 0;
1043 #if OSL_DEBUG_LEVEL > 1
1044 void SwNumPositionTabPage::SetModified(BOOL bRepaint)
1046 bModified = TRUE;
1047 if(bRepaint)
1049 aPreviewWIN.SetLevel(nActNumLvl);
1050 aPreviewWIN.Invalidate();
1054 #endif
1056 /**************************************************************************/
1057 /* */
1058 /* */
1059 /**************************************************************************/
1062 SwSvxNumBulletTabDialog::SwSvxNumBulletTabDialog(Window* pParent,
1063 const SfxItemSet* pSwItemSet, SwWrtShell & rSh) :
1064 SfxTabDialog(pParent, SW_RES(DLG_SVXTEST_NUM_BULLET), pSwItemSet, FALSE, &aEmptyStr),
1065 rWrtSh(rSh),
1066 sRemoveText(SW_RES(ST_RESET)),
1067 nRetOptionsDialog(USHRT_MAX)
1069 FreeResource();
1070 GetUserButton()->SetText(sRemoveText);
1071 GetUserButton()->SetHelpId(HID_NUM_RESET);
1072 GetUserButton()->SetClickHdl(LINK(this, SwSvxNumBulletTabDialog, RemoveNumberingHdl));
1073 if(!rWrtSh.GetCurNumRule())
1074 GetUserButton()->Enable(FALSE);
1075 AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
1076 AddTabPage( RID_SVXPAGE_PICK_BULLET );
1077 AddTabPage( RID_SVXPAGE_PICK_NUM );
1078 AddTabPage( RID_SVXPAGE_PICK_BMP );
1079 AddTabPage( RID_SVXPAGE_NUM_OPTIONS );
1080 AddTabPage( RID_SVXPAGE_NUM_POSITION );
1083 /*-----------------07.02.97 12.08-------------------
1085 --------------------------------------------------*/
1087 SwSvxNumBulletTabDialog::~SwSvxNumBulletTabDialog()
1091 /*-----------------07.02.97 14.48-------------------
1093 --------------------------------------------------*/
1095 void SwSvxNumBulletTabDialog::PageCreated(USHORT nPageId, SfxTabPage& rPage)
1097 //Namen der Vorlagen und Metric setzen
1098 String sNumCharFmt, sBulletCharFmt;
1099 SwStyleNameMapper::FillUIName( RES_POOLCHR_NUM_LEVEL, sNumCharFmt );
1100 SwStyleNameMapper::FillUIName( RES_POOLCHR_BUL_LEVEL, sBulletCharFmt );
1102 switch ( nPageId )
1104 case RID_SVXPAGE_PICK_NUM:
1106 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1107 aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFmt));
1108 aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
1109 rPage.PageCreated(aSet);
1111 break;
1112 case RID_SVXPAGE_PICK_BULLET :
1114 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1115 aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
1116 rPage.PageCreated(aSet);
1118 break;
1120 case RID_SVXPAGE_NUM_OPTIONS:
1122 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1123 aSet.Put (SfxStringItem(SID_NUM_CHAR_FMT,sNumCharFmt));
1124 aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFmt));
1125 // Zeichenvorlagen sammeln
1126 ListBox rCharFmtLB(this);
1127 rCharFmtLB.Clear();
1128 rCharFmtLB.InsertEntry( ViewShell::GetShellRes()->aStrNone );
1129 SwDocShell* pDocShell = rWrtSh.GetView().GetDocShell();
1130 ::FillCharStyleListBox(rCharFmtLB, pDocShell);
1131 List aList;
1132 for(USHORT j = 0; j < rCharFmtLB.GetEntryCount(); j++)
1135 aList.Insert( new XubString(rCharFmtLB.GetEntry(j)), LIST_APPEND );
1137 aSet.Put( SfxStringListItem( SID_CHAR_FMT_LIST_BOX,&aList ) ) ;
1139 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, pDocShell));
1140 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< USHORT >(eMetric) ) );
1141 rPage.PageCreated(aSet);
1142 for( USHORT i = (USHORT)aList.Count(); i; --i )
1143 delete (XubString*)aList.Remove(i);
1144 aList.Clear();
1146 break;
1147 case RID_SVXPAGE_NUM_POSITION:
1149 SwDocShell* pDocShell = rWrtSh.GetView().GetDocShell();
1150 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, pDocShell));
1151 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1152 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM, static_cast< USHORT >(eMetric)) );
1153 rPage.PageCreated(aSet);
1154 // ((SvxNumPositionTabPage&)rPage).SetWrtShell(&rWrtSh);
1156 break;
1159 /*-----------------17.02.97 16.52-------------------
1161 --------------------------------------------------*/
1162 short SwSvxNumBulletTabDialog::Ok()
1164 short nRet = SfxTabDialog::Ok();
1165 pExampleSet->ClearItem(SID_PARAM_NUM_PRESET);
1166 return nRet;
1168 /* -----------------02.12.98 08:35-------------------
1170 * --------------------------------------------------*/
1171 IMPL_LINK(SwSvxNumBulletTabDialog, RemoveNumberingHdl, PushButton*, EMPTYARG)
1173 EndDialog(RET_USER);
1174 return 0;