Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <hintids.hxx>
30 : : #include <tools/shl.hxx>
31 : : #include <vcl/menu.hxx>
32 : : #include <vcl/msgbox.hxx>
33 : : #include <sfx2/tabdlg.hxx>
34 : : #include <editeng/brshitem.hxx>
35 : : #include <unotools/configmgr.hxx>
36 : : #include <SwStyleNameMapper.hxx>
37 : : #include <num.hxx>
38 : : #include <view.hxx>
39 : : #include <docsh.hxx>
40 : : #include <uitool.hxx>
41 : : #include <wrtsh.hxx>
42 : : #include <swmodule.hxx>
43 : : #include <fmtcol.hxx>
44 : : #include <outline.hxx>
45 : : #include <uinums.hxx>
46 : : #include <poolfmt.hxx>
47 : : #include <shellres.hxx>
48 : : #include <svl/style.hxx>
49 : : #include <charfmt.hxx>
50 : : #include <docstyle.hxx>
51 : : #include <viewopt.hxx>
52 : : #include <svtools/ctrlbox.hxx>
53 : : #include <helpid.h>
54 : : #include <globals.hrc> // for template name 'none'
55 : : #include <misc.hrc>
56 : : #include <outline.hrc>
57 : : #include <paratr.hxx>
58 : :
59 : : #include <unomid.h>
60 : :
61 : : #include <IDocumentOutlineNodes.hxx>
62 : : #include <app.hrc>
63 : :
64 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
65 : :
66 : : using namespace ::com::sun::star;
67 : :
68 : : DBG_NAME(outlinehdl)
69 : :
70 : : class SwNumNamesDlg: public ModalDialog
71 : : {
72 : : FixedLine aFormFL;
73 : : Edit aFormEdit;
74 : : ListBox aFormBox;
75 : : OKButton aOKBtn;
76 : : CancelButton aCancelBtn;
77 : : HelpButton aHelpBtn;
78 : :
79 : : DECL_LINK( ModifyHdl, Edit * );
80 : : DECL_LINK( SelectHdl, ListBox * );
81 : : DECL_LINK(DoubleClickHdl, void *);
82 : :
83 : : public:
84 : : SwNumNamesDlg(Window *pParent);
85 : : ~SwNumNamesDlg();
86 : : void SetUserNames(const String *pList[]);
87 : 0 : String GetName() const { return aFormEdit.GetText(); }
88 : 0 : sal_uInt16 GetCurEntryPos() const { return aFormBox.GetSelectEntryPos(); }
89 : : };
90 : :
91 : : /*------------------------------------------------------------------------
92 : : Description: remember selected entry
93 : : ------------------------------------------------------------------------*/
94 : 0 : IMPL_LINK_INLINE_START( SwNumNamesDlg, SelectHdl, ListBox *, pBox )
95 : : {
96 : 0 : aFormEdit.SetText(pBox->GetSelectEntry());
97 : 0 : aFormEdit.SetSelection(Selection(0, SELECTION_MAX));
98 : 0 : return 0;
99 : : }
100 : 0 : IMPL_LINK_INLINE_END( SwNumNamesDlg, SelectHdl, ListBox *, pBox )
101 : :
102 : : /*------------------------------------------------------------------------
103 : : Description: set user defined names
104 : : Parameter: list of user defined names;
105 : : unknown positions for the user are 0.
106 : : ------------------------------------------------------------------------*/
107 : 0 : void SwNumNamesDlg::SetUserNames(const String *pList[])
108 : : {
109 : 0 : sal_uInt16 nSelect = 0;
110 : 0 : for(sal_uInt16 i = 0; i < SwBaseNumRules::nMaxRules; ++i)
111 : : {
112 : 0 : if(pList[i])
113 : : {
114 : 0 : aFormBox.RemoveEntry(i);
115 : 0 : aFormBox.InsertEntry(*pList[i], i);
116 : 0 : if(i == nSelect && nSelect < SwBaseNumRules::nMaxRules)
117 : 0 : nSelect++;
118 : : }
119 : : }
120 : 0 : aFormBox.SelectEntryPos(nSelect);
121 : 0 : SelectHdl(&aFormBox);
122 : 0 : }
123 : :
124 : : /*------------------------------------------------------------------------
125 : : Description: unlock OK-Button when text is in Edit
126 : : ------------------------------------------------------------------------*/
127 : 0 : IMPL_LINK_INLINE_START( SwNumNamesDlg, ModifyHdl, Edit *, pBox )
128 : : {
129 : 0 : aOKBtn.Enable(0 != pBox->GetText().Len());
130 : 0 : return 0;
131 : : }
132 : 0 : IMPL_LINK_INLINE_END( SwNumNamesDlg, ModifyHdl, Edit *, pBox )
133 : :
134 : : /*------------------------------------------------------------------------
135 : : Description: DoubleClickHdl
136 : : ------------------------------------------------------------------------*/
137 : 0 : IMPL_LINK_NOARG_INLINE_START(SwNumNamesDlg, DoubleClickHdl)
138 : : {
139 : 0 : EndDialog(RET_OK);
140 : 0 : return 0;
141 : : }
142 : 0 : IMPL_LINK_NOARG_INLINE_END(SwNumNamesDlg, DoubleClickHdl)
143 : :
144 : 0 : SwNumNamesDlg::SwNumNamesDlg(Window *pParent)
145 : : : ModalDialog(pParent, SW_RES(DLG_NUM_NAMES)),
146 : : aFormFL(this, SW_RES(FL_FORM)),
147 : : aFormEdit(this, SW_RES(ED_FORM)),
148 : : aFormBox(this, SW_RES(LB_FORM)),
149 : : aOKBtn(this, SW_RES(BT_OK)),
150 : : aCancelBtn(this, SW_RES(BT_CANCEL)),
151 : 0 : aHelpBtn(this, SW_RES(BT_HELP))
152 : : {
153 : 0 : FreeResource();
154 : 0 : aFormEdit.SetModifyHdl(LINK(this, SwNumNamesDlg, ModifyHdl));
155 : 0 : aFormBox.SetSelectHdl(LINK(this, SwNumNamesDlg, SelectHdl));
156 : 0 : aFormBox.SetDoubleClickHdl(LINK(this, SwNumNamesDlg, DoubleClickHdl));
157 : 0 : SelectHdl(&aFormBox);
158 : 0 : }
159 : :
160 : 0 : SwNumNamesDlg::~SwNumNamesDlg() {}
161 : :
162 : 0 : sal_uInt16 lcl_BitToLevel(sal_uInt16 nActLevel)
163 : : {
164 : 0 : sal_uInt16 nTmp = nActLevel;
165 : 0 : sal_uInt16 nTmpLevel = 0;
166 : 0 : while( 0 != (nTmp >>= 1) )
167 : 0 : nTmpLevel++;
168 : 0 : return nTmpLevel;
169 : : }
170 : :
171 : : sal_uInt16 SwOutlineTabDialog::nNumLevel = 1;
172 : 0 : SwOutlineTabDialog::SwOutlineTabDialog(Window* pParent,
173 : : const SfxItemSet* pSwItemSet,
174 : : SwWrtShell &rSh) :
175 : : // the UserString is set correctly afterwards
176 : : SfxTabDialog(pParent, SW_RES(DLG_TAB_OUTLINE), pSwItemSet, sal_False, &aEmptyStr),
177 : : aNullStr(rtl::OUString("____")),
178 : : aFormMenu(SW_RES(MN_FORM)),
179 : : rWrtSh(rSh),
180 : 0 : pChapterNumRules(SW_MOD()->GetChapterNumRules()),
181 : 0 : bModified(rWrtSh.IsModified())
182 : : {
183 : : // --> OD 2008-04-14 #outlinelevel#
184 : 0 : SetText( SW_RES( STR_OUTLINE_NUMBERING ) );
185 : 0 : PushButton* pUserButton = GetUserButton();
186 : 0 : pUserButton->SetText(SW_RES(ST_FORM));
187 : 0 : pUserButton->SetHelpId(HID_OUTLINE_FORM);
188 : 0 : pUserButton->SetClickHdl(LINK(this, SwOutlineTabDialog, FormHdl));
189 : 0 : pUserButton->SetAccessibleRole( com::sun::star::accessibility::AccessibleRole::BUTTON_MENU );
190 : :
191 : 0 : FreeResource();
192 : 0 : pNumRule = new SwNumRule( *rSh.GetOutlineNumRule() );
193 : 0 : GetCancelButton().SetClickHdl(LINK(this, SwOutlineTabDialog, CancelHdl));
194 : :
195 : 0 : AddTabPage(TP_NUM_POSITION , &SwNumPositionTabPage::Create, 0);
196 : 0 : AddTabPage(TP_OUTLINE_NUM , &SwOutlineSettingsTabPage::Create, 0);
197 : :
198 : 0 : String sHeadline;
199 : : sal_uInt16 i;
200 : :
201 : 0 : for( i = 0; i < MAXLEVEL; ++i )
202 : : {
203 : : // if the style wasn't created yet, it's still at this position
204 : 0 : if( !rWrtSh.GetParaStyle( sHeadline =
205 : : SwStyleNameMapper::GetUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i),
206 : 0 : sHeadline )) )
207 : 0 : aCollNames[i] = sHeadline;
208 : : }
209 : :
210 : : // query the text templates' outlining levels
211 : 0 : const sal_uInt16 nCount = rWrtSh.GetTxtFmtCollCount();
212 : 0 : for(i = 0; i < nCount; ++i )
213 : : {
214 : 0 : SwTxtFmtColl &rTxtColl = rWrtSh.GetTxtFmtColl(i);
215 : 0 : if(!rTxtColl.IsDefault())
216 : : {
217 : : //->added by zhaojianwei
218 : 0 : if(rTxtColl.IsAssignedToListLevelOfOutlineStyle())
219 : : {
220 : 0 : int nOutLevel = rTxtColl.GetAssignedOutlineStyleLevel();
221 : 0 : aCollNames[ nOutLevel ] = rTxtColl.GetName();
222 : : }
223 : : //<-end
224 : : }
225 : 0 : }
226 : 0 : }
227 : :
228 : 0 : SwOutlineTabDialog::~SwOutlineTabDialog()
229 : : {
230 : 0 : delete pNumRule;
231 : 0 : }
232 : :
233 : 0 : void SwOutlineTabDialog::PageCreated(sal_uInt16 nPageId, SfxTabPage& rPage)
234 : : {
235 : 0 : switch ( nPageId )
236 : : {
237 : : case TP_NUM_POSITION:
238 : 0 : ((SwNumPositionTabPage&)rPage).SetWrtShell(&rWrtSh);
239 : 0 : ((SwNumPositionTabPage&)rPage).SetOutlineTabDialog(this);
240 : 0 : break;
241 : : case TP_OUTLINE_NUM:
242 : 0 : ((SwOutlineSettingsTabPage&)rPage).SetWrtShell(&rWrtSh);
243 : 0 : break;
244 : : }
245 : 0 : }
246 : :
247 : 0 : IMPL_LINK_NOARG(SwOutlineTabDialog, CancelHdl)
248 : : {
249 : 0 : if (!bModified)
250 : 0 : rWrtSh.ResetModified();
251 : 0 : EndDialog(RET_CANCEL);
252 : 0 : return 0;
253 : : }
254 : :
255 : 0 : IMPL_LINK( SwOutlineTabDialog, FormHdl, Button *, pBtn )
256 : : {
257 : : // fill PopupMenu
258 : 0 : for( sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i )
259 : : {
260 : 0 : const SwNumRulesWithName *pRules = pChapterNumRules->GetRules(i);
261 : 0 : if( pRules )
262 : 0 : aFormMenu.SetItemText(i + MN_FORMBASE, pRules->GetName());
263 : : }
264 : 0 : aFormMenu.SetSelectHdl(LINK(this, SwOutlineTabDialog, MenuSelectHdl));
265 : 0 : aFormMenu.Execute(pBtn, Rectangle(Point(0,0), pBtn->GetSizePixel()), POPUPMENU_EXECUTE_DOWN);
266 : 0 : return 0;
267 : : }
268 : :
269 : 0 : IMPL_LINK( SwOutlineTabDialog, MenuSelectHdl, Menu *, pMenu )
270 : : {
271 : 0 : sal_uInt8 nLevelNo = 0;
272 : 0 : switch(pMenu->GetCurItemId())
273 : : {
274 : 0 : case MN_FORM1: nLevelNo = 1; break;
275 : 0 : case MN_FORM2: nLevelNo = 2; break;
276 : 0 : case MN_FORM3: nLevelNo = 3; break;
277 : 0 : case MN_FORM4: nLevelNo = 4; break;
278 : 0 : case MN_FORM5: nLevelNo = 5; break;
279 : 0 : case MN_FORM6: nLevelNo = 6; break;
280 : 0 : case MN_FORM7: nLevelNo = 7; break;
281 : 0 : case MN_FORM8: nLevelNo = 8; break;
282 : 0 : case MN_FORM9: nLevelNo = 9; break;
283 : :
284 : : case MN_SAVE:
285 : : {
286 : 0 : SwNumNamesDlg *pDlg = new SwNumNamesDlg(this);
287 : : const String *aStrArr[SwChapterNumRules::nMaxRules];
288 : 0 : for(sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i)
289 : : {
290 : 0 : const SwNumRulesWithName *pRules = pChapterNumRules->GetRules(i);
291 : 0 : if(pRules)
292 : 0 : aStrArr[i] = &pRules->GetName();
293 : : else
294 : 0 : aStrArr[i] = 0;
295 : : }
296 : 0 : pDlg->SetUserNames(aStrArr);
297 : 0 : if(RET_OK == pDlg->Execute())
298 : : {
299 : 0 : const String aName(pDlg->GetName());
300 : : pChapterNumRules->ApplyNumRules( SwNumRulesWithName(
301 : 0 : *pNumRule, aName ), pDlg->GetCurEntryPos() );
302 : : pMenu->SetItemText(
303 : 0 : pDlg->GetCurEntryPos() + MN_FORMBASE, aName);
304 : : }
305 : 0 : delete pDlg;
306 : 0 : return 0;
307 : :
308 : : }
309 : :
310 : : }
311 : 0 : if( nLevelNo-- )
312 : : {
313 : 0 : const SwNumRulesWithName *pRules = pChapterNumRules->GetRules( nLevelNo );
314 : 0 : if( pRules )
315 : : {
316 : 0 : pRules->MakeNumRule( rWrtSh, *pNumRule );
317 : 0 : pNumRule->SetRuleType( OUTLINE_RULE );
318 : : }
319 : : else
320 : 0 : *pNumRule = *rWrtSh.GetOutlineNumRule();
321 : : }
322 : :
323 : 0 : sal_uInt16 nPageId = GetCurPageId();
324 : 0 : SfxTabPage* pPage = GetTabPage( nPageId );
325 : 0 : pPage->Reset(*GetOutputItemSet());
326 : :
327 : 0 : return 0;
328 : : }
329 : :
330 : 0 : sal_uInt16 SwOutlineTabDialog::GetLevel(const String &rFmtName) const
331 : : {
332 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; ++i)
333 : : {
334 : 0 : if(aCollNames[i] == rFmtName)
335 : 0 : return i;
336 : : }
337 : 0 : return MAXLEVEL;//NO_NUMBERING; //#outline level,zhaojianwei
338 : :
339 : : }
340 : :
341 : 0 : short SwOutlineTabDialog::Ok()
342 : : {
343 : 0 : SfxTabDialog::Ok();
344 : : // set levels for all created templates; has to be done in order to
345 : : // delete possibly cancelled assignments again.
346 : :
347 : : // #130443#
348 : : // encapsulate changes into a action to avoid effects on the current cursor
349 : : // position during the changes.
350 : 0 : rWrtSh.StartAction();
351 : :
352 : 0 : const SwNumRule * pOutlineRule = rWrtSh.GetOutlineNumRule();
353 : :
354 : 0 : sal_uInt16 i, nCount = rWrtSh.GetTxtFmtCollCount();
355 : 0 : for( i = 0; i < nCount; ++i )
356 : : {
357 : 0 : SwTxtFmtColl &rTxtColl = rWrtSh.GetTxtFmtColl(i);
358 : 0 : if( !rTxtColl.IsDefault() )
359 : : {
360 : :
361 : : const SfxPoolItem & rItem =
362 : 0 : rTxtColl.GetFmtAttr(RES_PARATR_NUMRULE, sal_False);
363 : :
364 : 0 : if ((sal_uInt8)GetLevel(rTxtColl.GetName()) == MAXLEVEL) //add by zhaojianwei
365 : : {
366 : 0 : if(rTxtColl.IsAssignedToListLevelOfOutlineStyle())
367 : : {
368 : 0 : rTxtColl.DeleteAssignmentToListLevelOfOutlineStyle();
369 : : }
370 : 0 : if (static_cast<const SwNumRuleItem &>(rItem).GetValue() ==
371 : 0 : pOutlineRule->GetName())
372 : : {
373 : 0 : rTxtColl.ResetFmtAttr(RES_PARATR_NUMRULE);
374 : : }
375 : : }
376 : : else
377 : : {
378 : 0 : rTxtColl.AssignToListLevelOfOutlineStyle(GetLevel(rTxtColl.GetName()));
379 : :
380 : 0 : if (static_cast<const SwNumRuleItem &>(rItem).GetValue() !=
381 : 0 : pOutlineRule->GetName())
382 : : {
383 : 0 : SwNumRuleItem aItem(pOutlineRule->GetName());
384 : 0 : rTxtColl.SetFmtAttr(aItem);
385 : : }
386 : : } //<-end,zhaojianwei
387 : : }
388 : : }
389 : :
390 : 0 : for(i = 0; i < MAXLEVEL; ++i )
391 : : {
392 : 0 : String sHeadline;
393 : : ::SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i),
394 : 0 : sHeadline );
395 : 0 : SwTxtFmtColl* pColl = rWrtSh.FindTxtFmtCollByName( sHeadline );
396 : 0 : if( !pColl )
397 : : {
398 : 0 : if(aCollNames[i] != sHeadline)
399 : : {
400 : : SwTxtFmtColl* pTxtColl = rWrtSh.GetTxtCollFromPool(
401 : 0 : static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i) );
402 : 0 : pTxtColl->DeleteAssignmentToListLevelOfOutlineStyle();
403 : 0 : pTxtColl->ResetFmtAttr(RES_PARATR_NUMRULE);
404 : :
405 : 0 : if( aCollNames[i].Len() )
406 : : {
407 : : pTxtColl = rWrtSh.GetParaStyle(
408 : 0 : aCollNames[i], SwWrtShell::GETSTYLE_CREATESOME);
409 : 0 : if(pTxtColl)
410 : : {
411 : 0 : pTxtColl->AssignToListLevelOfOutlineStyle(i);
412 : 0 : SwNumRuleItem aItem(pOutlineRule->GetName());
413 : 0 : pTxtColl->SetFmtAttr(aItem);
414 : : }
415 : : }
416 : : }
417 : : }
418 : 0 : }
419 : :
420 : 0 : rWrtSh.SetOutlineNumRule( *pNumRule);
421 : :
422 : : // #i30443#
423 : 0 : rWrtSh.EndAction();
424 : :
425 : 0 : return RET_OK;
426 : : }
427 : :
428 : 0 : SwOutlineSettingsTabPage::SwOutlineSettingsTabPage(Window* pParent, const SfxItemSet& rSet) :
429 : : SfxTabPage(pParent, SW_RES(TP_OUTLINE_NUM), rSet),
430 : : aLevelFL( this, SW_RES(FL_LEVEL )),
431 : : aLevelLB( this, SW_RES(LB_LEVEL )),
432 : : aNumberFL(this, SW_RES(FL_NUMBER)),
433 : : aCollLbl(this, SW_RES(FT_COLL)),
434 : : aCollBox(this, SW_RES(LB_COLL)),
435 : : aNumberLbl(this, SW_RES(FT_NUMBER)),
436 : : aNumberBox(this, SW_RES(LB_NUMBER), INSERT_NUM_TYPE_NO_NUMBERING|INSERT_NUM_EXTENDED_TYPES),
437 : : aCharFmtFT(this, SW_RES(FT_CHARFMT)),
438 : : aCharFmtLB(this, SW_RES(LB_CHARFMT)),
439 : : aAllLevelFT( this, SW_RES(FT_ALL_LEVEL)),
440 : : aAllLevelNF( this, SW_RES(NF_ALL_LEVEL)),
441 : : aDelim(this, SW_RES(FT_DELIM)),
442 : : aPrefixFT(this, SW_RES(FT_PREFIX)),
443 : : aPrefixED(this, SW_RES(ED_PREFIX)),
444 : : aSuffixFT(this, SW_RES(FT_SUFFIX)),
445 : : aSuffixED(this, SW_RES(ED_SUFFIX)),
446 : : aStartLbl(this, SW_RES(FT_START)),
447 : : aStartEdit(this, SW_RES(ED_START)),
448 : : aPreviewWIN( this, SW_RES(WIN_PREVIEW )),
449 : :
450 : : aNoFmtName(SW_RES(ST_NO_COLL)),
451 : : pSh(0),
452 : : pCollNames(0),
453 : 0 : nActLevel(1)
454 : : {
455 : 0 : FreeResource();
456 : 0 : SetExchangeSupport();
457 : :
458 : 0 : aCollBox.InsertEntry(aNoFmtName);
459 : 0 : aLevelLB.SetSelectHdl(LINK(this, SwOutlineSettingsTabPage, LevelHdl));
460 : 0 : aAllLevelNF.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, ToggleComplete));
461 : 0 : aCollBox.SetSelectHdl(LINK(this, SwOutlineSettingsTabPage, CollSelect));
462 : 0 : aCollBox.SetGetFocusHdl(LINK(this, SwOutlineSettingsTabPage, CollSelectGetFocus));
463 : 0 : aNumberBox.SetSelectHdl(LINK(this, SwOutlineSettingsTabPage, NumberSelect));
464 : 0 : aPrefixED.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, DelimModify));
465 : 0 : aSuffixED.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, DelimModify));
466 : 0 : aStartEdit.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, StartModified));
467 : 0 : aCharFmtLB.SetSelectHdl(LINK(this, SwOutlineSettingsTabPage, CharFmtHdl));
468 : :
469 : 0 : }
470 : :
471 : 0 : void SwOutlineSettingsTabPage::Update()
472 : : {
473 : : // if a template was already selected for this level, select it in the ListBox
474 : 0 : aCollBox.Enable(USHRT_MAX != nActLevel);
475 : 0 : if(USHRT_MAX == nActLevel)
476 : : {
477 : 0 : sal_Bool bSamePrefix = sal_True;
478 : 0 : sal_Bool bSameSuffix = sal_True;
479 : 0 : sal_Bool bSameType = sal_True;
480 : 0 : sal_Bool bSameComplete = sal_True;
481 : 0 : sal_Bool bSameStart = sal_True;
482 : 0 : sal_Bool bSameCharFmt = sal_True;
483 : :
484 : : const SwNumFmt* aNumFmtArr[MAXLEVEL];
485 : 0 : const SwCharFmt* pFirstFmt = 0;
486 : :
487 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
488 : : {
489 : :
490 : 0 : aNumFmtArr[ i ] = &pNumRule->Get(i);
491 : 0 : if(i == 0)
492 : 0 : pFirstFmt = aNumFmtArr[i]->GetCharFmt();
493 : : else
494 : : {
495 : 0 : bSameType &= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[0]->GetNumberingType();
496 : 0 : bSameStart &= aNumFmtArr[i]->GetStart() == aNumFmtArr[0]->GetStart();
497 : 0 : bSamePrefix &= aNumFmtArr[i]->GetPrefix() == aNumFmtArr[0]->GetPrefix();
498 : 0 : bSameSuffix &= aNumFmtArr[i]->GetSuffix() == aNumFmtArr[0]->GetSuffix();
499 : 0 : bSameComplete &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[0]->GetIncludeUpperLevels();
500 : 0 : const SwCharFmt* pFmt = aNumFmtArr[i]->GetCharFmt();
501 : : bSameCharFmt &= (!pFirstFmt && !pFmt)
502 : 0 : || (pFirstFmt && pFmt && pFmt->GetName() == pFirstFmt->GetName());
503 : : }
504 : : }
505 : 0 : CheckForStartValue_Impl(aNumFmtArr[0]->GetNumberingType());
506 : 0 : if(bSameType)
507 : 0 : aNumberBox.SelectNumberingType( aNumFmtArr[0]->GetNumberingType() );
508 : : else
509 : 0 : aNumberBox.SetNoSelection();
510 : 0 : if(bSameStart)
511 : 0 : aStartEdit.SetValue(aNumFmtArr[0]->GetStart());
512 : : else
513 : 0 : aStartEdit.SetText(aEmptyStr);
514 : 0 : if(bSamePrefix)
515 : 0 : aPrefixED.SetText(aNumFmtArr[0]->GetPrefix());
516 : : else
517 : 0 : aPrefixED.SetText(aEmptyStr);
518 : 0 : if(bSameSuffix)
519 : 0 : aSuffixED.SetText(aNumFmtArr[0]->GetSuffix());
520 : : else
521 : 0 : aSuffixED.SetText(aEmptyStr);
522 : :
523 : 0 : if(bSameCharFmt)
524 : : {
525 : 0 : if(pFirstFmt)
526 : 0 : aCharFmtLB.SelectEntry(pFirstFmt->GetName());
527 : : else
528 : 0 : aCharFmtLB.SelectEntry( ViewShell::GetShellRes()->aStrNone );
529 : : }
530 : : else
531 : 0 : aCharFmtLB.SetNoSelection();
532 : :
533 : 0 : aAllLevelFT.Enable(sal_True);
534 : 0 : aAllLevelNF.Enable(sal_True);
535 : 0 : aAllLevelNF.SetMax(MAXLEVEL);
536 : 0 : if(bSameComplete)
537 : : {
538 : 0 : aAllLevelNF.SetValue(aNumFmtArr[0]->GetIncludeUpperLevels());
539 : : }
540 : : else
541 : : {
542 : 0 : aAllLevelNF.SetText(aEmptyStr);
543 : : }
544 : : }
545 : : else
546 : : {
547 : 0 : sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
548 : 0 : String aColl(pCollNames[nTmpLevel]);
549 : 0 : if(aColl.Len())
550 : 0 : aCollBox.SelectEntry(aColl);
551 : : else
552 : 0 : aCollBox.SelectEntry(aNoFmtName);
553 : 0 : const SwNumFmt &rFmt = pNumRule->Get(nTmpLevel);
554 : :
555 : 0 : aNumberBox.SelectNumberingType( rFmt.GetNumberingType() );
556 : 0 : aPrefixED.SetText(rFmt.GetPrefix());
557 : 0 : aSuffixED.SetText(rFmt.GetSuffix());
558 : 0 : const SwCharFmt* pFmt = rFmt.GetCharFmt();
559 : 0 : if(pFmt)
560 : 0 : aCharFmtLB.SelectEntry(pFmt->GetName());
561 : : else
562 : 0 : aCharFmtLB.SelectEntry( ViewShell::GetShellRes()->aStrNone );
563 : :
564 : 0 : if(nTmpLevel)
565 : : {
566 : 0 : aAllLevelFT.Enable(sal_True);
567 : 0 : aAllLevelNF.Enable(sal_True);
568 : 0 : aAllLevelNF.SetMax(nTmpLevel + 1);
569 : 0 : aAllLevelNF.SetValue(rFmt.GetIncludeUpperLevels());
570 : : }
571 : : else
572 : : {
573 : 0 : aAllLevelNF.SetText(aEmptyStr);
574 : 0 : aAllLevelNF.Enable(sal_False);
575 : 0 : aAllLevelFT.Enable(sal_False);
576 : : }
577 : 0 : CheckForStartValue_Impl(rFmt.GetNumberingType());
578 : 0 : aStartEdit.SetValue( rFmt.GetStart() );
579 : : }
580 : 0 : SetModified();
581 : 0 : }
582 : :
583 : 0 : IMPL_LINK( SwOutlineSettingsTabPage, LevelHdl, ListBox *, pBox )
584 : : {
585 : 0 : nActLevel = 0;
586 : 0 : if(pBox->IsEntryPosSelected( MAXLEVEL ))
587 : : {
588 : 0 : nActLevel = 0xFFFF;
589 : : }
590 : : else
591 : : {
592 : 0 : sal_uInt16 nMask = 1;
593 : 0 : for( sal_uInt16 i = 0; i < MAXLEVEL; i++ )
594 : : {
595 : 0 : if(pBox->IsEntryPosSelected( i ))
596 : 0 : nActLevel |= nMask;
597 : 0 : nMask <<= 1;
598 : : }
599 : : }
600 : 0 : Update();
601 : 0 : return 0;
602 : : }
603 : :
604 : 0 : IMPL_LINK( SwOutlineSettingsTabPage, ToggleComplete, NumericField *, pFld )
605 : : {
606 : 0 : sal_uInt16 nMask = 1;
607 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
608 : : {
609 : 0 : if(nActLevel & nMask)
610 : : {
611 : 0 : SwNumFmt aNumFmt(pNumRule->Get(i));
612 : 0 : aNumFmt.SetIncludeUpperLevels( Min( (sal_uInt8)pFld->GetValue(),
613 : 0 : (sal_uInt8)(i + 1)) );
614 : 0 : pNumRule->Set(i, aNumFmt);
615 : : }
616 : 0 : nMask <<= 1;
617 : : }
618 : 0 : SetModified();
619 : 0 : return 0;
620 : : }
621 : :
622 : 0 : IMPL_LINK( SwOutlineSettingsTabPage, CollSelect, ListBox *, pBox )
623 : : {
624 : : sal_uInt8 i;
625 : :
626 : 0 : const String aCollName(pBox->GetSelectEntry());
627 : : //0xFFFF not allowed here (disable)
628 : 0 : sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
629 : 0 : String sOldName( pCollNames[nTmpLevel] );
630 : :
631 : 0 : for( i = 0; i < MAXLEVEL; ++i)
632 : 0 : pCollNames[i] = aSaveCollNames[i];
633 : :
634 : 0 : if(aCollName == aNoFmtName)
635 : 0 : pCollNames[nTmpLevel] = aEmptyStr;
636 : : else
637 : : {
638 : 0 : pCollNames[nTmpLevel] = aCollName;
639 : : // template already in use?
640 : 0 : for( i = 0; i < MAXLEVEL; ++i)
641 : 0 : if(i != nTmpLevel && pCollNames[i] == aCollName )
642 : 0 : pCollNames[i] = aEmptyStr;
643 : : }
644 : :
645 : : // search the oldname and put it into the current entries
646 : 0 : if( sOldName.Len() )
647 : 0 : for( i = 0; i < MAXLEVEL; ++i)
648 : 0 : if( aSaveCollNames[ i ] == sOldName && i != nTmpLevel &&
649 : 0 : !pCollNames[ i ].Len() )
650 : : {
651 : : sal_uInt8 n;
652 : 0 : for( n = 0; n < MAXLEVEL; ++n )
653 : 0 : if( pCollNames[ n ] == sOldName )
654 : 0 : break;
655 : :
656 : 0 : if( MAXLEVEL == n )
657 : : // it was a outline leveld name and the current entries is zero.
658 : 0 : pCollNames[ i ] = sOldName;
659 : : }
660 : :
661 : 0 : SetModified();
662 : 0 : return 0;
663 : : }
664 : :
665 : 0 : IMPL_LINK_NOARG(SwOutlineSettingsTabPage, CollSelectGetFocus)
666 : : {
667 : 0 : for( sal_uInt8 i = 0; i < MAXLEVEL; ++i)
668 : 0 : aSaveCollNames[i] = pCollNames[i];
669 : 0 : return 0;
670 : : }
671 : :
672 : 0 : IMPL_LINK( SwOutlineSettingsTabPage, NumberSelect, SwNumberingTypeListBox *, pBox )
673 : : {
674 : 0 : sal_uInt16 nMask = 1;
675 : 0 : sal_Int16 nNumberType = pBox->GetSelectedNumberingType();
676 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
677 : : {
678 : 0 : if(nActLevel & nMask)
679 : : {
680 : 0 : SwNumFmt aNumFmt(pNumRule->Get(i));
681 : 0 : aNumFmt.SetNumberingType(nNumberType);
682 : 0 : pNumRule->Set(i, aNumFmt);
683 : 0 : CheckForStartValue_Impl(nNumberType);
684 : : }
685 : 0 : nMask <<= 1;
686 : : }
687 : 0 : SetModified();
688 : 0 : return 0;
689 : : }
690 : :
691 : 0 : IMPL_LINK_NOARG(SwOutlineSettingsTabPage, DelimModify)
692 : : {
693 : 0 : sal_uInt16 nMask = 1;
694 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
695 : : {
696 : 0 : if(nActLevel & nMask)
697 : : {
698 : 0 : SwNumFmt aNumFmt(pNumRule->Get(i));
699 : 0 : aNumFmt.SetPrefix( aPrefixED.GetText() );
700 : 0 : aNumFmt.SetSuffix( aSuffixED.GetText() );
701 : 0 : pNumRule->Set(i, aNumFmt);
702 : : }
703 : 0 : nMask <<= 1;
704 : : }
705 : 0 : SetModified();
706 : 0 : return 0;
707 : : }
708 : :
709 : 0 : IMPL_LINK( SwOutlineSettingsTabPage, StartModified, NumericField *, pFld )
710 : : {
711 : 0 : sal_uInt16 nMask = 1;
712 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
713 : : {
714 : 0 : if(nActLevel & nMask)
715 : : {
716 : 0 : SwNumFmt aNumFmt(pNumRule->Get(i));
717 : 0 : aNumFmt.SetStart( (sal_uInt16)pFld->GetValue() );
718 : 0 : pNumRule->Set(i, aNumFmt);
719 : : }
720 : 0 : nMask <<= 1;
721 : : }
722 : 0 : SetModified();
723 : 0 : return 0;
724 : : }
725 : :
726 : 0 : IMPL_LINK_NOARG(SwOutlineSettingsTabPage, CharFmtHdl)
727 : : {
728 : 0 : String sEntry = aCharFmtLB.GetSelectEntry();
729 : 0 : sal_uInt16 nMask = 1;
730 : 0 : sal_Bool bFormatNone = sEntry == ViewShell::GetShellRes()->aStrNone;
731 : 0 : SwCharFmt* pFmt = 0;
732 : 0 : if(!bFormatNone)
733 : : {
734 : 0 : sal_uInt16 nChCount = pSh->GetCharFmtCount();
735 : 0 : for(sal_uInt16 i = 0; i < nChCount; i++)
736 : : {
737 : 0 : SwCharFmt& rChFmt = pSh->GetCharFmt(i);
738 : 0 : if(rChFmt.GetName() == sEntry)
739 : : {
740 : 0 : pFmt = &rChFmt;
741 : 0 : break;
742 : : }
743 : : }
744 : 0 : if(!pFmt)
745 : : {
746 : 0 : SfxStyleSheetBasePool* pPool = pSh->GetView().GetDocShell()->GetStyleSheetPool();
747 : : SfxStyleSheetBase* pBase;
748 : 0 : pBase = pPool->Find(sEntry, SFX_STYLE_FAMILY_CHAR);
749 : 0 : if(!pBase)
750 : 0 : pBase = &pPool->Make(sEntry, SFX_STYLE_FAMILY_PAGE);
751 : 0 : pFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
752 : :
753 : : }
754 : : }
755 : :
756 : 0 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
757 : : {
758 : 0 : if(nActLevel & nMask)
759 : : {
760 : 0 : SwNumFmt aNumFmt(pNumRule->Get(i));
761 : 0 : if(bFormatNone)
762 : 0 : aNumFmt.SetCharFmt(0);
763 : : else
764 : 0 : aNumFmt.SetCharFmt(pFmt);
765 : 0 : pNumRule->Set(i, aNumFmt);
766 : : }
767 : 0 : nMask <<= 1;
768 : : }
769 : 0 : return RET_OK;
770 : : }
771 : :
772 : 0 : SwOutlineSettingsTabPage::~SwOutlineSettingsTabPage()
773 : : {
774 : 0 : }
775 : :
776 : 0 : void SwOutlineSettingsTabPage::SetWrtShell(SwWrtShell* pShell)
777 : : {
778 : 0 : pSh = pShell;
779 : : // query this document's NumRules
780 : 0 : pNumRule = ((SwOutlineTabDialog*)GetTabDialog())->GetNumRule();
781 : 0 : pCollNames = ((SwOutlineTabDialog*)GetTabDialog())->GetCollNames();
782 : :
783 : 0 : aPreviewWIN.SetNumRule(pNumRule);
784 : 0 : aPreviewWIN.SetOutlineNames(pCollNames);
785 : : // set start value - nActLevel must be 1 here
786 : 0 : sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
787 : 0 : const SwNumFmt& rNumFmt = pNumRule->Get( nTmpLevel );
788 : 0 : aStartEdit.SetValue( rNumFmt.GetStart() );
789 : :
790 : : // create pool formats for headlines
791 : 0 : String sStr;
792 : : sal_uInt16 i;
793 : 0 : for( i = 0; i < MAXLEVEL; ++i )
794 : : {
795 : : aCollBox.InsertEntry( SwStyleNameMapper::GetUIName(
796 : 0 : static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i), aEmptyStr ));
797 : 0 : aLevelLB.InsertEntry( String::CreateFromInt32(i + 1) );
798 : : }
799 : 0 : sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "1 - " ));
800 : 0 : sStr += String::CreateFromInt32(MAXLEVEL);
801 : 0 : aLevelLB.InsertEntry( sStr );
802 : :
803 : : // query the texttemplates' outlining levels
804 : 0 : const sal_uInt16 nCount = pSh->GetTxtFmtCollCount();
805 : 0 : for( i = 0; i < nCount; ++i )
806 : : {
807 : 0 : SwTxtFmtColl &rTxtColl = pSh->GetTxtFmtColl(i);
808 : 0 : if(!rTxtColl.IsDefault())
809 : : {
810 : 0 : sStr = rTxtColl.GetName();
811 : 0 : if(LISTBOX_ENTRY_NOTFOUND == aCollBox.GetEntryPos( sStr ))
812 : 0 : aCollBox.InsertEntry( sStr );
813 : : }
814 : : }
815 : :
816 : 0 : aNumberBox.SelectNumberingType(rNumFmt.GetNumberingType());
817 : 0 : sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
818 : 0 : sal_uInt16 nTmp = 0;
819 : 0 : if(nOutlinePos != USHRT_MAX)
820 : : {
821 : 0 : nTmp = static_cast<sal_uInt16>(pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos));
822 : : }
823 : 0 : aLevelLB.SelectEntryPos(nTmp-1);//nTmp);//#outline level,zhaojianwei
824 : :
825 : : // collect char styles
826 : 0 : aCharFmtLB.Clear();
827 : 0 : aCharFmtLB.InsertEntry( ViewShell::GetShellRes()->aStrNone );
828 : :
829 : : // char styles
830 : : ::FillCharStyleListBox(aCharFmtLB,
831 : 0 : pSh->GetView().GetDocShell());
832 : 0 : Update();
833 : 0 : }
834 : :
835 : 0 : void SwOutlineSettingsTabPage::ActivatePage(const SfxItemSet& )
836 : : {
837 : 0 : nActLevel = SwOutlineTabDialog::GetActNumLevel();
838 : 0 : if(nActLevel != USHRT_MAX)
839 : 0 : aLevelLB.SelectEntryPos(lcl_BitToLevel(nActLevel));
840 : : else
841 : 0 : aLevelLB.SelectEntryPos(MAXLEVEL);
842 : 0 : LevelHdl(&aLevelLB);
843 : 0 : }
844 : :
845 : 0 : int SwOutlineSettingsTabPage::DeactivatePage(SfxItemSet*)
846 : : {
847 : 0 : SwOutlineTabDialog::SetActNumLevel(nActLevel);
848 : 0 : return LEAVE_PAGE;
849 : : }
850 : :
851 : 0 : sal_Bool SwOutlineSettingsTabPage::FillItemSet( SfxItemSet& )
852 : : {
853 : 0 : return sal_True;
854 : : }
855 : :
856 : 0 : void SwOutlineSettingsTabPage::Reset( const SfxItemSet& rSet )
857 : : {
858 : 0 : ActivatePage(rSet);
859 : 0 : }
860 : :
861 : 0 : SfxTabPage* SwOutlineSettingsTabPage::Create( Window* pParent,
862 : : const SfxItemSet& rAttrSet)
863 : : {
864 : 0 : return new SwOutlineSettingsTabPage(pParent, rAttrSet);
865 : : }
866 : :
867 : 0 : void SwOutlineSettingsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
868 : : {
869 : 0 : sal_Bool bIsNull = aStartEdit.GetValue() == 0;
870 : : sal_Bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
871 : : SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
872 : 0 : SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
873 : 0 : aStartEdit.SetMin(bNoZeroAllowed ? 1 : 0);
874 : 0 : if(bIsNull && bNoZeroAllowed)
875 : 0 : aStartEdit.GetModifyHdl().Call(&aStartEdit);
876 : 0 : }
877 : :
878 : 0 : sal_uInt16 lcl_DrawBullet(VirtualDevice* pVDev,
879 : : const SwNumFmt& rFmt, sal_uInt16 nXStart,
880 : : sal_uInt16 nYStart, const Size& rSize)
881 : : {
882 : 0 : Font aTmpFont(pVDev->GetFont());
883 : :
884 : 0 : Font aFont(*rFmt.GetBulletFont());
885 : 0 : aFont.SetSize(rSize);
886 : 0 : aFont.SetTransparent(sal_True);
887 : 0 : pVDev->SetFont( aFont );
888 : 0 : rtl::OUString aText(rFmt.GetBulletChar());
889 : 0 : pVDev->DrawText( Point(nXStart, nYStart), aText );
890 : 0 : sal_uInt16 nRet = (sal_uInt16)pVDev->GetTextWidth(aText);
891 : :
892 : 0 : pVDev->SetFont(aTmpFont);
893 : 0 : return nRet;
894 : : }
895 : :
896 : 0 : sal_uInt16 lcl_DrawGraphic(VirtualDevice* pVDev, const SwNumFmt &rFmt, sal_uInt16 nXStart,
897 : : sal_uInt16 nYStart, sal_uInt16 nDivision)
898 : : {
899 : 0 : const SvxBrushItem* pBrushItem = rFmt.GetBrush();
900 : 0 : sal_uInt16 nRet = 0;
901 : 0 : if(pBrushItem)
902 : : {
903 : 0 : const Graphic* pGrf = pBrushItem->GetGraphic();
904 : 0 : if(pGrf)
905 : : {
906 : 0 : Size aGSize( rFmt.GetGraphicSize());
907 : 0 : aGSize.Width() /= nDivision;
908 : 0 : nRet = (sal_uInt16)aGSize.Width();
909 : 0 : aGSize.Height() /= nDivision;
910 : : pGrf->Draw( pVDev, Point(nXStart,nYStart),
911 : 0 : pVDev->PixelToLogic( aGSize ) );
912 : : }
913 : : }
914 : 0 : return nRet;
915 : :
916 : : }
917 : :
918 : : /*--------------------------------------------------
919 : : paint numbering's preview
920 : : --------------------------------------------------*/
921 : 0 : void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
922 : : {
923 : 0 : Size aSize(PixelToLogic(GetOutputSizePixel()));
924 : 0 : Rectangle aRect(Point(0,0), aSize);
925 : :
926 : 0 : VirtualDevice* pVDev = new VirtualDevice(*this);
927 : 0 : pVDev->SetMapMode(GetMapMode());
928 : 0 : pVDev->SetOutputSize( aSize );
929 : :
930 : : // #101524# OJ
931 : 0 : pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
932 : 0 : pVDev->SetLineColor( GetSettings().GetStyleSettings().GetButtonTextColor() );
933 : 0 : pVDev->DrawRect(aRect);
934 : :
935 : 0 : if(pActNum)
936 : : {
937 : : sal_uInt16 nWidthRelation;
938 : 0 : if(nPageWidth)
939 : : {
940 : 0 : nWidthRelation = sal_uInt16 (nPageWidth / aSize.Width());
941 : 0 : if(bPosition)
942 : 0 : nWidthRelation = nWidthRelation * 2 / 3;
943 : : else
944 : 0 : nWidthRelation = nWidthRelation / 4;
945 : : }
946 : : else
947 : 0 : nWidthRelation = 30; // chapter dialog
948 : :
949 : : // height per level
950 : 0 : sal_uInt16 nXStep = sal_uInt16(aSize.Width() / (3 * MAXLEVEL));
951 : : if(MAXLEVEL < 10)
952 : : nXStep /= 2;
953 : 0 : sal_uInt16 nYStart = 4;
954 : 0 : sal_uInt16 nYStep = sal_uInt16((aSize.Height() - 6)/ MAXLEVEL);
955 : : aStdFont = OutputDevice::GetDefaultFont(
956 : 0 : DEFAULTFONT_UI_SANS, (LanguageType)GetAppLanguage(),
957 : 0 : DEFAULTFONT_FLAGS_ONLYONE, this );
958 : : // #101524# OJ
959 : 0 : aStdFont.SetColor( SwViewOption::GetFontColor() );
960 : :
961 : 0 : sal_uInt16 nFontHeight = nYStep * 6 / 10;
962 : 0 : if(bPosition)
963 : 0 : nFontHeight = nYStep * 15 / 10;
964 : 0 : aStdFont.SetSize(Size( 0, nFontHeight ));
965 : :
966 : 0 : sal_uInt16 nPreNum = pActNum->Get(0).GetStart();
967 : :
968 : 0 : if(bPosition)
969 : : {
970 : 0 : sal_uInt16 nLineHeight = nFontHeight * 8 / 7;
971 : 0 : sal_uInt8 nStart = 0;
972 : 0 : while( !(nActLevel & (1<<nStart)) )
973 : : {
974 : 0 : nStart++;
975 : : }
976 : 0 : if(nStart) // so that possible predecessors and successors are showed
977 : 0 : nStart--;
978 : :
979 : 0 : SwNumberTree::tNumberVector aNumVector;
980 : 0 : sal_uInt8 nEnd = Min( (sal_uInt8)(nStart + 3), MAXLEVEL );
981 : 0 : for( sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel )
982 : : {
983 : 0 : const SwNumFmt &rFmt = pActNum->Get(nLevel);
984 : 0 : aNumVector.push_back(rFmt.GetStart());
985 : :
986 : 0 : sal_uInt16 nXStart( 0 );
987 : 0 : short nTextOffset( 0 );
988 : 0 : sal_uInt16 nNumberXPos( 0 );
989 : 0 : if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
990 : : {
991 : 0 : nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
992 : 0 : nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
993 : 0 : nNumberXPos = nXStart;
994 : 0 : sal_uInt16 nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
995 : :
996 : 0 : if(nFirstLineOffset <= nNumberXPos)
997 : 0 : nNumberXPos = nNumberXPos - nFirstLineOffset;
998 : : else
999 : 0 : nNumberXPos = 0;
1000 : : }
1001 : 0 : else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1002 : : {
1003 : 0 : const long nTmpNumberXPos( ( rFmt.GetIndentAt() +
1004 : 0 : rFmt.GetFirstLineIndent() ) /
1005 : 0 : nWidthRelation );
1006 : 0 : if ( nTmpNumberXPos < 0 )
1007 : : {
1008 : 0 : nNumberXPos = 0;
1009 : : }
1010 : : else
1011 : : {
1012 : 0 : nNumberXPos = static_cast<sal_uInt16>(nTmpNumberXPos);
1013 : : }
1014 : : }
1015 : :
1016 : 0 : sal_uInt16 nBulletWidth = 0;
1017 : 0 : if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
1018 : : {
1019 : : nBulletWidth = lcl_DrawGraphic(pVDev, rFmt,
1020 : : nNumberXPos,
1021 : 0 : nYStart, nWidthRelation);
1022 : : }
1023 : 0 : else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
1024 : : {
1025 : 0 : nBulletWidth = lcl_DrawBullet(pVDev, rFmt, nNumberXPos, nYStart, aStdFont.GetSize());
1026 : : }
1027 : : else
1028 : : {
1029 : 0 : pVDev->SetFont(aStdFont);
1030 : 0 : if(pActNum->IsContinusNum())
1031 : 0 : aNumVector[nLevel] = nPreNum;
1032 : : // #128041#
1033 : 0 : String aText(pActNum->MakeNumString( aNumVector ));
1034 : 0 : pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
1035 : 0 : nBulletWidth = (sal_uInt16)pVDev->GetTextWidth(aText);
1036 : 0 : nPreNum++;
1037 : : }
1038 : 0 : if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
1039 : 0 : rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
1040 : : {
1041 : 0 : pVDev->SetFont(aStdFont);
1042 : 0 : rtl::OUString aText(' ');
1043 : 0 : pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
1044 : 0 : nBulletWidth = nBulletWidth + (sal_uInt16)pVDev->GetTextWidth(aText);
1045 : : }
1046 : :
1047 : 0 : sal_uInt16 nTextXPos( 0 );
1048 : 0 : if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1049 : : {
1050 : 0 : nTextXPos = nXStart;
1051 : 0 : if(nTextOffset < 0)
1052 : 0 : nTextXPos = nTextXPos + nTextOffset;
1053 : 0 : if(nNumberXPos + nBulletWidth + nTextOffset > nTextXPos )
1054 : 0 : nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
1055 : : }
1056 : 0 : else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1057 : : {
1058 : 0 : switch ( rFmt.GetLabelFollowedBy() )
1059 : : {
1060 : : case SvxNumberFormat::LISTTAB:
1061 : : {
1062 : : nTextXPos = static_cast<sal_uInt16>(
1063 : 0 : rFmt.GetListtabPos() / nWidthRelation );
1064 : 0 : if ( nTextXPos < nNumberXPos + nBulletWidth )
1065 : : {
1066 : 0 : nTextXPos = nNumberXPos + nBulletWidth;
1067 : : }
1068 : : }
1069 : 0 : break;
1070 : : case SvxNumberFormat::SPACE:
1071 : : case SvxNumberFormat::NOTHING:
1072 : : {
1073 : 0 : nTextXPos = nNumberXPos + nBulletWidth;
1074 : : }
1075 : 0 : break;
1076 : : }
1077 : :
1078 : 0 : nXStart = static_cast<sal_uInt16>( rFmt.GetIndentAt() / nWidthRelation );
1079 : : }
1080 : :
1081 : :
1082 : 0 : Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
1083 : 0 : pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() ); // Color( COL_BLACK ) );
1084 : 0 : pVDev->DrawRect( aRect1 );
1085 : :
1086 : 0 : Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
1087 : 0 : pVDev->DrawRect( aRect2 );
1088 : 0 : nYStart += 2 * nLineHeight;
1089 : 0 : }
1090 : : }
1091 : : else
1092 : : {
1093 : 0 : SwNumberTree::tNumberVector aNumVector;
1094 : 0 : sal_uInt16 nLineHeight = nFontHeight * 3 / 2;
1095 : 0 : for( sal_uInt8 nLevel = 0; nLevel < MAXLEVEL;
1096 : : ++nLevel, nYStart = nYStart + nYStep )
1097 : : {
1098 : 0 : const SwNumFmt &rFmt = pActNum->Get(nLevel);
1099 : 0 : aNumVector.push_back(rFmt.GetStart());
1100 : 0 : sal_uInt16 nXStart( 0 );
1101 : 0 : if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1102 : : {
1103 : 0 : nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
1104 : : }
1105 : 0 : else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1106 : : {
1107 : 0 : const long nTmpXStart( ( rFmt.GetIndentAt() +
1108 : 0 : rFmt.GetFirstLineIndent() ) /
1109 : 0 : nWidthRelation );
1110 : 0 : if ( nTmpXStart < 0 )
1111 : : {
1112 : 0 : nXStart = 0;
1113 : : }
1114 : : else
1115 : : {
1116 : 0 : nXStart = static_cast<sal_uInt16>(nTmpXStart);
1117 : : }
1118 : : }
1119 : 0 : nXStart /= 2;
1120 : 0 : nXStart += 2;
1121 : 0 : sal_uInt16 nTextOffset = 2 * nXStep;
1122 : 0 : if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
1123 : : {
1124 : 0 : lcl_DrawGraphic(pVDev, rFmt, nXStart, nYStart, nWidthRelation);
1125 : 0 : nTextOffset = nLineHeight + nXStep;
1126 : : }
1127 : 0 : else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
1128 : : {
1129 : 0 : nTextOffset = lcl_DrawBullet(pVDev, rFmt, nXStart, nYStart, aStdFont.GetSize());
1130 : 0 : nTextOffset = nTextOffset + nXStep;
1131 : : }
1132 : : else
1133 : : {
1134 : 0 : pVDev->SetFont(aStdFont);
1135 : 0 : if(pActNum->IsContinusNum())
1136 : 0 : aNumVector[nLevel] = nPreNum;
1137 : : // #128041#
1138 : 0 : String aText(pActNum->MakeNumString( aNumVector ));
1139 : 0 : pVDev->DrawText( Point(nXStart, nYStart), aText );
1140 : 0 : nTextOffset = (sal_uInt16)pVDev->GetTextWidth(aText);
1141 : 0 : nTextOffset = nTextOffset + nXStep;
1142 : 0 : nPreNum++;
1143 : : }
1144 : 0 : pVDev->SetFont(aStdFont);
1145 : : pVDev->DrawText(
1146 : : Point(nXStart + nTextOffset, nYStart),
1147 : : (pOutlineNames == 0
1148 : : ? utl::ConfigManager::getProductName()
1149 : 0 : : rtl::OUString(pOutlineNames[nLevel])));
1150 : 0 : }
1151 : : }
1152 : : }
1153 : : DrawOutDev( Point(0,0), aSize,
1154 : : Point(0,0), aSize,
1155 : 0 : *pVDev );
1156 : 0 : delete pVDev;
1157 : :
1158 : 0 : }
1159 : :
1160 : 0 : NumberingPreview::~NumberingPreview()
1161 : : {
1162 : 0 : }
1163 : :
1164 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|