LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/misc - outline.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 619 0.0 %
Date: 2013-07-09 Functions: 0 60 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10