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