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