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 $
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
39 #define USE_NUMTABPAGES
41 #include <hintids.hxx>
43 #ifndef _MSGBOX_HXX //autogen
44 #include <vcl/msgbox.hxx>
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>
55 #include <swmodule.hxx>
67 #include <uiitems.hxx>
68 #include <docstyle.hxx>
69 #include <charfmt.hxx>
71 #include <poolfmt.hxx>
72 #include <shellres.hxx>
73 #include <outline.hxx>
75 #include <viewopt.hxx>
88 #include <globals.hrc>
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
) ),
133 aStandardPB( this, SW_RES(PB_STANDARD
)),
135 aPreviewWIN( this, SW_RES(WIN_PREVIEW
)),
142 bInInintControl(FALSE
),
143 // --> OD 2008-02-01 #newlistlevelattrs#
144 bLabelAlignmentPosAndSpaceModeActive( false )
148 SetExchangeSupport();
149 aPreviewWIN
.SetBackground(Wallpaper(Color(COL_TRANSPARENT
)));
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() );
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
);
194 aLevelLB
.SetSelectHdl(LINK(this, SwNumPositionTabPage
, LevelHdl
));
195 aRelativeCB
.SetClickHdl(LINK(this, SwNumPositionTabPage
, RelativeHdl
));
196 aStandardPB
.SetClickHdl(LINK(this, SwNumPositionTabPage
, StandardHdl
));
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()
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 ) );
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
;
247 const SwNumFmt
* aNumFmtArr
[MAXLEVEL
];
248 const SwFmtVertOrient
* pFirstOrient
= 0;
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
)
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();
275 // --> OD 2008-02-01 #newlistlevelattrs#
276 bSameAdjust
&= aNumFmtArr
[i
]->GetNumAdjust() == aNumFmtArr
[nLvl
]->GetNumAdjust();
277 if ( !bLabelAlignmentPosAndSpaceModeActive
)
281 if(nFirstBorderTextRelative
== -1)
282 nFirstBorderTextRelative
=
283 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
284 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
286 bSameDistBorderNum
&= nFirstBorderTextRelative
==
287 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
288 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
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();
303 bSameLabelFollowedBy
&=
304 aNumFmtArr
[i
]->GetLabelFollowedBy() == aNumFmtArr
[nLvl
]->GetLabelFollowedBy();
306 aNumFmtArr
[i
]->GetListtabPos() == aNumFmtArr
[nLvl
]->GetListtabPos();
308 ( ( aNumFmtArr
[i
]->GetIndentAt() + aNumFmtArr
[i
]->GetFirstLineIndent() )
309 == ( aNumFmtArr
[nLvl
]->GetIndentAt() + aNumFmtArr
[nLvl
]->GetFirstLineIndent() ) );
311 aNumFmtArr
[i
]->GetIndentAt() == aNumFmtArr
[nLvl
]->GetIndentAt();
320 if(bSameDistBorderNum
)
325 nDistBorderNum
= (long)aNumFmtArr
[nLvl
]->GetAbsLSpace()+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
327 nDistBorderNum
-= (long)aNumFmtArr
[nLvl
- 1]->GetAbsLSpace()+ aNumFmtArr
[nLvl
- 1]->GetFirstLineOffset();
331 nDistBorderNum
= (long)aNumFmtArr
[nLvl
]->GetAbsLSpace()+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
333 aDistBorderMF
.SetValue(aDistBorderMF
.Normalize(nDistBorderNum
),FUNIT_TWIP
);
336 bSetDistEmpty
= TRUE
;
339 aDistNumMF
.SetValue(aDistNumMF
.Normalize(aNumFmtArr
[nLvl
]->GetCharTextDistance()), FUNIT_TWIP
);
341 aDistNumMF
.SetText(aEmptyStr
);
343 aIndentMF
.SetValue(aIndentMF
.Normalize(-aNumFmtArr
[nLvl
]->GetFirstLineOffset()), FUNIT_TWIP
);
345 aIndentMF
.SetText(aEmptyStr
);
349 USHORT nPos
= 1; // zentriert
350 if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_LEFT
)
352 else if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_RIGHT
)
354 aAlignLB
.SelectEntryPos(nPos
);
355 // --> OD 2008-02-01 #newlistlevelattrs#
356 aAlign2LB
.SelectEntryPos( nPos
);
361 aAlignLB
.SetNoSelection();
362 // --> OD 2008-02-01 #newlistlevelattrs#
363 aAlign2LB
.SetNoSelection();
367 // --> OD 2008-02-01 #newlistlevelattrs#
368 if ( bSameLabelFollowedBy
)
370 USHORT nPos
= 0; // LISTTAB
371 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
375 else if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING
)
379 aLabelFollowedByLB
.SelectEntryPos( nPos
);
383 aLabelFollowedByLB
.SetNoSelection();
386 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB
)
388 aListtabFT
.Enable( true );
389 aListtabMF
.Enable( true );
392 aListtabMF
.SetValue(aListtabMF
.Normalize(aNumFmtArr
[nLvl
]->GetListtabPos()),FUNIT_TWIP
);
396 aListtabMF
.SetText(aEmptyStr
);
401 aListtabFT
.Enable( false );
402 aListtabMF
.Enable( false );
403 aListtabMF
.SetText(aEmptyStr
);
408 aAlignedAtMF
.SetValue(
409 aAlignedAtMF
.Normalize( aNumFmtArr
[nLvl
]->GetIndentAt() +
410 aNumFmtArr
[nLvl
]->GetFirstLineIndent()),
415 aAlignedAtMF
.SetText(aEmptyStr
);
420 aIndentAtMF
.SetValue(
421 aIndentAtMF
.Normalize( aNumFmtArr
[nLvl
]->GetIndentAt()), FUNIT_TWIP
);
425 aIndentAtMF
.SetText(aEmptyStr
);
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
;
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
;
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
);
466 aLevelLB
.SetUpdateMode(TRUE
);
468 // --> OD 2008-02-01 #newlistlevelattrs#
469 InitPosAndSpaceMode();
470 ShowControlsDependingOnPosAndSpaceMode();
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
);
491 /*-----------------03.12.97 10:02-------------------
493 --------------------------------------------------*/
494 BOOL
SwNumPositionTabPage::FillItemSet( SfxItemSet
& rSet
)
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
));
507 /*-----------------03.12.97 10:02-------------------
509 --------------------------------------------------*/
510 void SwNumPositionTabPage::Reset( const SfxItemSet
& rSet
)
512 const SfxPoolItem
* pItem
;
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();
523 aLevelLB
.SetUpdateMode(FALSE
);
524 aLevelLB
.SetNoSelection();
525 if(nActNumLvl
== USHRT_MAX
)
527 aLevelLB
.SelectEntryPos( MAXLEVEL
, TRUE
);
530 for(USHORT i
= 0; i
< MAXLEVEL
; i
++)
532 if(nActNumLvl
& nMask
)
533 aLevelLB
.SelectEntryPos( i
, TRUE
);
536 aLevelLB
.SetUpdateMode(TRUE
);
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();
551 // --> OD 2008-01-11 #newlistlevelattrs#
552 void SwNumPositionTabPage::InitPosAndSpaceMode()
557 "<SwNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
561 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode
=
562 SvxNumberFormat::LABEL_ALIGNMENT
;
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
)
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
);
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
)
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
);
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
);
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);
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
);
669 /*-----------------03.12.97 11:06-------------------
671 --------------------------------------------------*/
672 IMPL_LINK( SwNumPositionTabPage
, EditModifyHdl
, Edit
*, EMPTYARG
)
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();
686 SvxAdjust eAdjust
= SVX_ADJUST_CENTER
;
688 eAdjust
= SVX_ADJUST_LEFT
;
690 eAdjust
= SVX_ADJUST_RIGHT
;
691 aNumFmt
.SetNumAdjust( eAdjust
);
692 pActNum
->Set(i
, aNumFmt
);
699 /*-----------------03.12.97 11:11-------------------
701 --------------------------------------------------*/
702 IMPL_LINK( SwNumPositionTabPage
, LevelHdl
, ListBox
*, pBox
)
704 USHORT nSaveNumLvl
= nActNumLvl
;
706 if(pBox
->IsEntryPosSelected( MAXLEVEL
) &&
707 (pBox
->GetSelectEntryCount() == 1 || nSaveNumLvl
!= 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())
718 for( USHORT i
= 0; i
< MAXLEVEL
; i
++ )
720 if(pBox
->IsEntryPosSelected( i
))
724 pBox
->SelectEntryPos( MAXLEVEL
, FALSE
);
728 nActNumLvl
= nSaveNumLvl
;
730 for( USHORT i
= 0; i
< MAXLEVEL
; i
++ )
732 if(nActNumLvl
& nMask
)
734 pBox
->SelectEntryPos(i
);
740 aRelativeCB
.Enable(1 != nActNumLvl
);
742 // --> OD 2008-02-01 #newlistlevelattrs#
743 InitPosAndSpaceMode();
744 ShowControlsDependingOnPosAndSpaceMode();
749 /*-----------------03.12.97 12:24-------------------
751 --------------------------------------------------*/
752 IMPL_LINK( SwNumPositionTabPage
, DistanceHdl
, MetricField
*, pFld
)
756 long nValue
= static_cast< long >(pFld
->Denormalize(pFld
->GetValue(FUNIT_TWIP
)));
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())
770 long nTmp
= aNumFmt
.GetFirstLineOffset();
771 aNumFmt
.SetAbsLSpace( USHORT(nValue
- nTmp
));
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
));
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
);
806 if(!aDistBorderMF
.IsEnabled())
807 aDistBorderMF
.SetText(aEmptyStr
);
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
;
821 if(bOn
|| bSingleSelection
)
826 for(USHORT i
= 0; i
< MAXLEVEL
; i
++)
828 if(nActNumLvl
& nMask
)
830 const SwNumFmt
&rNumFmt
= pActNum
->Get(i
);
833 nValue
= rNumFmt
.GetAbsLSpace();
835 nValue
-= pActNum
->Get(i
- 1).GetAbsLSpace();
838 bSetValue
= nValue
== rNumFmt
.GetAbsLSpace() - pActNum
->Get(i
- 1).GetAbsLSpace();
846 aDistBorderMF
.SetValue(aDistBorderMF
.Normalize(nValue
), FUNIT_TWIP
);
848 aDistBorderMF
.SetText(aEmptyStr
);
849 aDistBorderMF
.Enable(bOn
|| bSingleSelection
||0 != pOutlineDlg
);
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();
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
;
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
)
890 bSameListtabPos
&= aNumFmt
.GetListtabPos() ==
891 pActNum
->Get( nFirstLvl
).GetListtabPos();
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
)
904 aListtabMF
.Normalize( pActNum
->Get( nFirstLvl
).GetListtabPos() ),
909 aListtabMF
.SetText( String() );
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
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
);
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
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
);
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
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
);
998 /*-----------------05.12.97 15:33-------------------
1000 --------------------------------------------------*/
1001 IMPL_LINK( SwNumPositionTabPage
, StandardHdl
, PushButton
*, EMPTYARG
)
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
);
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() );
1033 pActNum
->Set( i
, aNumFmt
);
1043 #if OSL_DEBUG_LEVEL > 1
1044 void SwNumPositionTabPage::SetModified(BOOL bRepaint
)
1049 aPreviewWIN
.SetLevel(nActNumLvl
);
1050 aPreviewWIN
.Invalidate();
1056 /**************************************************************************/
1059 /**************************************************************************/
1062 SwSvxNumBulletTabDialog::SwSvxNumBulletTabDialog(Window
* pParent
,
1063 const SfxItemSet
* pSwItemSet
, SwWrtShell
& rSh
) :
1064 SfxTabDialog(pParent
, SW_RES(DLG_SVXTEST_NUM_BULLET
), pSwItemSet
, FALSE
, &aEmptyStr
),
1066 sRemoveText(SW_RES(ST_RESET
)),
1067 nRetOptionsDialog(USHRT_MAX
)
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
);
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
);
1112 case RID_SVXPAGE_PICK_BULLET
:
1114 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
1115 aSet
.Put (SfxStringItem(SID_BULLET_CHAR_FMT
,sBulletCharFmt
));
1116 rPage
.PageCreated(aSet
);
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);
1128 rCharFmtLB
.InsertEntry( ViewShell::GetShellRes()->aStrNone
);
1129 SwDocShell
* pDocShell
= rWrtSh
.GetView().GetDocShell();
1130 ::FillCharStyleListBox(rCharFmtLB
, pDocShell
);
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
);
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);
1159 /*-----------------17.02.97 16.52-------------------
1161 --------------------------------------------------*/
1162 short SwSvxNumBulletTabDialog::Ok()
1164 short nRet
= SfxTabDialog::Ok();
1165 pExampleSet
->ClearItem(SID_PARAM_NUM_PRESET
);
1168 /* -----------------02.12.98 08:35-------------------
1170 * --------------------------------------------------*/
1171 IMPL_LINK(SwSvxNumBulletTabDialog
, RemoveNumberingHdl
, PushButton
*, EMPTYARG
)
1173 EndDialog(RET_USER
);