LCOV - code coverage report
Current view: top level - cui/source/tabpages - numpages.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 2041 0.0 %
Date: 2014-04-11 Functions: 0 138 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 <com/sun/star/text/HoriOrientation.hpp>
      21             : #include <com/sun/star/text/VertOrientation.hpp>
      22             : #include <com/sun/star/text/RelOrientation.hpp>
      23             : 
      24             : #include <numpages.hxx>
      25             : #include <numpages.hrc>
      26             : #include <dialmgr.hxx>
      27             : #include <tools/shl.hxx>
      28             : #include <i18nlangtag/mslangid.hxx>
      29             : #include <helpid.hrc>
      30             : #include <editeng/numitem.hxx>
      31             : #include <svl/eitem.hxx>
      32             : #include <vcl/layout.hxx>
      33             : #include <vcl/svapp.hxx>
      34             : #include <svx/gallery.hxx>
      35             : #include <svl/urihelper.hxx>
      36             : #include <editeng/brushitem.hxx>
      37             : #include <svl/intitem.hxx>
      38             : #include <sfx2/objsh.hxx>
      39             : #include <vcl/graph.hxx>
      40             : #include <vcl/msgbox.hxx>
      41             : #include <vcl/settings.hxx>
      42             : #include "cuicharmap.hxx"
      43             : #include <editeng/flstitem.hxx>
      44             : #include <svx/dlgutil.hxx>
      45             : #include <svx/xtable.hxx>
      46             : #include <svx/drawitem.hxx>
      47             : #include <svx/numvset.hxx>
      48             : #include <sfx2/htmlmode.hxx>
      49             : #include <unotools/pathoptions.hxx>
      50             : #include <svtools/ctrltool.hxx>
      51             : #include <editeng/unolingu.hxx>
      52             : #include <com/sun/star/style/NumberingType.hpp>
      53             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      54             : #include <com/sun/star/container/XIndexAccess.hpp>
      55             : #include <com/sun/star/text/DefaultNumberingProvider.hpp>
      56             : #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
      57             : #include <com/sun/star/text/XNumberingFormatter.hpp>
      58             : #include <com/sun/star/beans/PropertyValue.hpp>
      59             : #include <comphelper/processfactory.hxx>
      60             : #include <com/sun/star/text/XNumberingTypeInfo.hpp>
      61             : #include <svx/dialmgr.hxx>
      62             : #include <svx/dialogs.hrc>
      63             : 
      64             : #include <algorithm>
      65             : #include <vector>
      66             : #include "sfx2/opengrf.hxx"
      67             : 
      68             : #include <cuires.hrc>
      69             : #include <sfx2/request.hxx>
      70             : #include <svl/aeitem.hxx>
      71             : #include <svl/stritem.hxx>
      72             : #include <svl/slstitm.hxx>
      73             : 
      74             : using namespace com::sun::star;
      75             : using namespace com::sun::star::uno;
      76             : using namespace com::sun::star::beans;
      77             : using namespace com::sun::star::lang;
      78             : using namespace com::sun::star::i18n;
      79             : using namespace com::sun::star::text;
      80             : using namespace com::sun::star::container;
      81             : using namespace com::sun::star::style;
      82             : 
      83             : #define NUM_PAGETYPE_BULLET         0
      84             : #define NUM_PAGETYPE_SINGLENUM      1
      85             : #define NUM_PAGETYPE_NUM            2
      86             : 
      87             : #define SHOW_NUMBERING              0
      88             : #define SHOW_BULLET                 1
      89             : #define SHOW_BITMAP                 2
      90             : 
      91             : #define MAX_BMP_WIDTH               16
      92             : #define MAX_BMP_HEIGHT              16
      93             : 
      94             : static sal_Bool bLastRelative =         sal_False;
      95             : static const sal_Char cNumberingType[] = "NumberingType";
      96             : static const sal_Char cParentNumbering[] = "ParentNumbering";
      97             : static const sal_Char cPrefix[] = "Prefix";
      98             : static const sal_Char cSuffix[] = "Suffix";
      99             : static const sal_Char cBulletChar[] = "BulletChar";
     100             : static const sal_Char cBulletFontName[] = "BulletFontName";
     101             : 
     102           0 : static Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider()
     103             : {
     104           0 :     Reference<XComponentContext>         xContext( ::comphelper::getProcessComponentContext() );
     105           0 :     Reference<XDefaultNumberingProvider> xRet = text::DefaultNumberingProvider::create(xContext);
     106           0 :     return xRet;
     107             : }
     108             : 
     109           0 : static SvxNumSettings_Impl* lcl_CreateNumSettingsPtr(const Sequence<PropertyValue>& rLevelProps)
     110             : {
     111           0 :     const PropertyValue* pValues = rLevelProps.getConstArray();
     112           0 :     SvxNumSettings_Impl* pNew = new SvxNumSettings_Impl;
     113           0 :     for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++)
     114             :     {
     115           0 :         if ( pValues[j].Name == cNumberingType )
     116           0 :             pValues[j].Value >>= pNew->nNumberType;
     117           0 :         else if ( pValues[j].Name == cPrefix )
     118           0 :             pValues[j].Value >>= pNew->sPrefix;
     119           0 :         else if ( pValues[j].Name == cSuffix )
     120           0 :             pValues[j].Value >>= pNew->sSuffix;
     121           0 :         else if ( pValues[j].Name == cParentNumbering )
     122           0 :             pValues[j].Value >>= pNew->nParentNumbering;
     123           0 :         else if ( pValues[j].Name == cBulletChar )
     124           0 :             pValues[j].Value >>= pNew->sBulletChar;
     125           0 :         else if ( pValues[j].Name == cBulletFontName )
     126           0 :             pValues[j].Value >>= pNew->sBulletFont;
     127             :     }
     128           0 :     return pNew;
     129             : }
     130             : 
     131             : // the selection of bullets from the StarSymbol
     132             : static const sal_Unicode aBulletTypes[] =
     133             : {
     134             :     0x2022,
     135             :     0x25cf,
     136             :     0xe00c,
     137             :     0xe00a,
     138             :     0x2794,
     139             :     0x27a2,
     140             :     0x2717,
     141             :     0x2714
     142             : };
     143             : 
     144             : // Is one of the masked formats set?
     145           0 : static bool lcl_IsNumFmtSet(SvxNumRule* pNum, sal_uInt16 nLevelMask)
     146             : {
     147           0 :     bool bRet = false;
     148           0 :     sal_uInt16 nMask = 1;
     149           0 :     for( sal_uInt16 i = 0; i < SVX_MAX_NUM && !bRet; i++ )
     150             :     {
     151           0 :         if(nLevelMask & nMask)
     152           0 :             bRet |= 0 != pNum->Get( i );
     153           0 :         nMask <<= 1 ;
     154             :     }
     155           0 :     return bRet;
     156             : }
     157             : 
     158           0 : static Font& lcl_GetDefaultBulletFont()
     159             : {
     160             :     static sal_Bool bInit = 0;
     161             :     static Font aDefBulletFont( OUString("StarSymbol"),
     162           0 :                                 OUString(), Size( 0, 14 ) );
     163           0 :     if(!bInit)
     164             :     {
     165           0 :         aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
     166           0 :         aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
     167           0 :         aDefBulletFont.SetPitch( PITCH_DONTKNOW );
     168           0 :         aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
     169           0 :         aDefBulletFont.SetTransparent( true );
     170           0 :         bInit = sal_True;
     171             :     }
     172           0 :     return aDefBulletFont;
     173             : }
     174             : 
     175           0 : SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(Window* pParent,
     176             :                                const SfxItemSet& rSet)
     177             :     : SfxTabPage(pParent, "PickNumberingPage", "cui/ui/picknumberingpage.ui", rSet)
     178             :     , pActNum(0)
     179             :     , pSaveNum(0)
     180             :     , nActNumLvl(SAL_MAX_UINT16)
     181             :     , bModified(false)
     182             :     , bPreset(false)
     183           0 :     , nNumItemId(SID_ATTR_NUMBERING_RULE)
     184             : {
     185           0 :     SetExchangeSupport();
     186           0 :     get(m_pExamplesVS, "valueset");
     187           0 :     m_pExamplesVS->init(NUM_PAGETYPE_SINGLENUM);
     188           0 :     m_pExamplesVS->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage, NumSelectHdl_Impl));
     189           0 :     m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl));
     190             : 
     191           0 :     Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
     192           0 :     if(xDefNum.is())
     193             :     {
     194           0 :         Sequence< Sequence< PropertyValue > > aNumberings;
     195           0 :         const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
     196             :         try
     197             :         {
     198           0 :             aNumberings =
     199           0 :                 xDefNum->getDefaultContinuousNumberingLevels( rLocale );
     200             : 
     201             : 
     202           0 :             sal_Int32 nLength = aNumberings.getLength() > NUM_VALUSET_COUNT ? NUM_VALUSET_COUNT :aNumberings.getLength();
     203             : 
     204           0 :             const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
     205           0 :             for(sal_Int32 i = 0; i < nLength; i++)
     206             :             {
     207           0 :                 SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]);
     208           0 :                 aNumSettingsArr.push_back(pNew);
     209             :             }
     210             :         }
     211           0 :         catch(const Exception&)
     212             :         {
     213             :         }
     214           0 :         Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
     215           0 :         m_pExamplesVS->SetNumberingSettings(aNumberings, xFormat, rLocale);
     216           0 :     }
     217           0 : }
     218             : 
     219           0 : SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
     220             : {
     221           0 :     delete pActNum;
     222           0 :     delete pSaveNum;
     223           0 : }
     224             : 
     225           0 : SfxTabPage*  SvxSingleNumPickTabPage::Create( Window* pParent,
     226             :                                 const SfxItemSet& rAttrSet)
     227             : {
     228           0 :     return new SvxSingleNumPickTabPage(pParent, rAttrSet);
     229             : }
     230             : 
     231           0 : bool  SvxSingleNumPickTabPage::FillItemSet( SfxItemSet& rSet )
     232             : {
     233           0 :     if( (bPreset || bModified) && pSaveNum)
     234             :     {
     235           0 :         *pSaveNum = *pActNum;
     236           0 :         rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
     237           0 :         rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     238             :     }
     239             : 
     240           0 :     return bModified;
     241             : }
     242             : 
     243           0 : void  SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
     244             : {
     245             :     const SfxPoolItem* pItem;
     246           0 :     bPreset = sal_False;
     247           0 :     sal_Bool bIsPreset = sal_False;
     248           0 :     const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
     249           0 :     if(pExampleSet)
     250             :     {
     251           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
     252           0 :             bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
     253           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
     254           0 :             nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
     255             :     }
     256           0 :     if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, false, &pItem))
     257             :     {
     258           0 :         delete pSaveNum;
     259           0 :         pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     260             :     }
     261           0 :     if(pActNum && *pSaveNum != *pActNum)
     262             :     {
     263           0 :         *pActNum = *pSaveNum;
     264           0 :         m_pExamplesVS->SetNoSelection();
     265             :     }
     266             : 
     267           0 :     if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
     268             :     {
     269           0 :         m_pExamplesVS->SelectItem(1);
     270           0 :         NumSelectHdl_Impl(m_pExamplesVS);
     271           0 :         bPreset = sal_True;
     272             :     }
     273           0 :     bPreset |= bIsPreset;
     274             : 
     275           0 :     bModified = sal_False;
     276           0 : }
     277             : 
     278           0 : int  SvxSingleNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
     279             : {
     280           0 :     if(_pSet)
     281           0 :         FillItemSet(*_pSet);
     282           0 :     return sal_True;
     283             : }
     284             : 
     285           0 : void  SvxSingleNumPickTabPage::Reset( const SfxItemSet& rSet )
     286             : {
     287             :     const SfxPoolItem* pItem;
     288             : 
     289             :     // in Draw the item exists as WhichId, in Writer only as SlotId
     290           0 :     SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
     291           0 :     if(eState != SFX_ITEM_SET)
     292             :     {
     293           0 :         nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
     294           0 :         eState = rSet.GetItemState(nNumItemId, false, &pItem);
     295             : 
     296           0 :         if( eState != SFX_ITEM_SET )
     297             :         {
     298           0 :             pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, true ) );
     299           0 :             eState = SFX_ITEM_SET;
     300             :         }
     301             :     }
     302             :     DBG_ASSERT(eState == SFX_ITEM_SET, "no item found!");
     303           0 :     delete pSaveNum;
     304           0 :     pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     305             : 
     306           0 :     if(!pActNum)
     307           0 :         pActNum = new  SvxNumRule(*pSaveNum);
     308           0 :     else if(*pSaveNum != *pActNum)
     309           0 :         *pActNum = *pSaveNum;
     310           0 : }
     311             : 
     312           0 : IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl)
     313             : {
     314           0 :     if(pActNum)
     315             :     {
     316           0 :         bPreset = sal_False;
     317           0 :         bModified = sal_True;
     318           0 :         sal_uInt16 nIdx = m_pExamplesVS->GetSelectItemId() - 1;
     319             :         DBG_ASSERT(aNumSettingsArr.size() > nIdx, "wrong index");
     320           0 :         if(aNumSettingsArr.size() <= nIdx)
     321           0 :             return 0;
     322           0 :         SvxNumSettings_Impl* _pSet = &aNumSettingsArr[nIdx];
     323           0 :         sal_Int16 eNewType = _pSet->nNumberType;
     324           0 :         const sal_Unicode cLocalPrefix = !_pSet->sPrefix.isEmpty() ? _pSet->sPrefix[0] : 0;
     325           0 :         const sal_Unicode cLocalSuffix = !_pSet->sSuffix.isEmpty() ? _pSet->sSuffix[0] : 0;
     326             : 
     327           0 :         sal_uInt16 nMask = 1;
     328           0 :         for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
     329             :         {
     330           0 :             if(nActNumLvl & nMask)
     331             :             {
     332           0 :                 SvxNumberFormat aFmt(pActNum->GetLevel(i));
     333           0 :                 aFmt.SetNumberingType(eNewType);
     334           0 :                 OUString aEmptyStr;
     335           0 :                 if(cLocalPrefix == ' ')
     336           0 :                     aFmt.SetPrefix( aEmptyStr );
     337             :                 else
     338           0 :                     aFmt.SetPrefix(_pSet->sPrefix);
     339           0 :                 if(cLocalSuffix == ' ')
     340           0 :                     aFmt.SetSuffix( aEmptyStr );
     341             :                 else
     342           0 :                     aFmt.SetSuffix(_pSet->sSuffix);
     343           0 :                 aFmt.SetCharFmtName(sNumCharFmtName);
     344             :                 // #62069# // #92724#
     345           0 :                 aFmt.SetBulletRelSize(100);
     346           0 :                 pActNum->SetLevel(i, aFmt);
     347             :             }
     348           0 :             nMask <<= 1 ;
     349             :         }
     350             :     }
     351           0 :     return 0;
     352             : }
     353             : 
     354           0 : IMPL_LINK_NOARG(SvxSingleNumPickTabPage, DoubleClickHdl_Impl)
     355             : {
     356           0 :     NumSelectHdl_Impl(m_pExamplesVS);
     357           0 :     PushButton& rOk = GetTabDialog()->GetOKButton();
     358           0 :     rOk.GetClickHdl().Call(&rOk);
     359           0 :     return 0;
     360             : }
     361             : 
     362             : 
     363           0 : SvxBulletPickTabPage::SvxBulletPickTabPage(Window* pParent,
     364             :                                const SfxItemSet& rSet)
     365             :     : SfxTabPage(pParent, "PickBulletPage", "cui/ui/pickbulletpage.ui", rSet)
     366             :     , pActNum(0)
     367             :     , pSaveNum(0)
     368             :     , nActNumLvl(SAL_MAX_UINT16)
     369             :     , bModified(false)
     370             :     , bPreset(false)
     371           0 :     , nNumItemId(SID_ATTR_NUMBERING_RULE)
     372             : {
     373           0 :     SetExchangeSupport();
     374           0 :     get(m_pExamplesVS, "valueset");
     375           0 :     m_pExamplesVS->init(NUM_PAGETYPE_BULLET),
     376           0 :     m_pExamplesVS->SetSelectHdl(LINK(this, SvxBulletPickTabPage, NumSelectHdl_Impl));
     377           0 :     m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxBulletPickTabPage, DoubleClickHdl_Impl));
     378           0 : }
     379             : 
     380           0 : SvxBulletPickTabPage::~SvxBulletPickTabPage()
     381             : {
     382           0 :     delete pActNum;
     383           0 :     delete pSaveNum;
     384           0 : }
     385             : 
     386           0 : SfxTabPage*  SvxBulletPickTabPage::Create( Window* pParent,
     387             :                                 const SfxItemSet& rAttrSet)
     388             : {
     389           0 :     return new SvxBulletPickTabPage(pParent, rAttrSet);
     390             : }
     391             : 
     392           0 : bool  SvxBulletPickTabPage::FillItemSet( SfxItemSet& rSet )
     393             : {
     394           0 :     if( (bPreset || bModified) && pActNum)
     395             :     {
     396           0 :         *pSaveNum = *pActNum;
     397           0 :         rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
     398           0 :         rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     399             :     }
     400           0 :     return bModified;
     401             : }
     402             : 
     403           0 : void  SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet)
     404             : {
     405             :     const SfxPoolItem* pItem;
     406           0 :     bPreset = sal_False;
     407           0 :     sal_Bool bIsPreset = sal_False;
     408           0 :     const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
     409           0 :     if(pExampleSet)
     410             :     {
     411           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
     412           0 :             bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
     413           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
     414           0 :             nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
     415             :     }
     416           0 :     if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, false, &pItem))
     417             :     {
     418           0 :         delete pSaveNum;
     419           0 :         pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     420             :     }
     421           0 :     if(pActNum && *pSaveNum != *pActNum)
     422             :     {
     423           0 :         *pActNum = *pSaveNum;
     424           0 :         m_pExamplesVS->SetNoSelection();
     425             :     }
     426             : 
     427           0 :     if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
     428             :     {
     429           0 :         m_pExamplesVS->SelectItem(1);
     430           0 :         NumSelectHdl_Impl(m_pExamplesVS);
     431           0 :         bPreset = sal_True;
     432             :     }
     433           0 :     bPreset |= bIsPreset;
     434           0 :     bModified = sal_False;
     435           0 : }
     436             : 
     437           0 : int  SvxBulletPickTabPage::DeactivatePage(SfxItemSet *_pSet)
     438             : {
     439           0 :     if(_pSet)
     440           0 :         FillItemSet(*_pSet);
     441           0 :     return sal_True;
     442             : }
     443             : 
     444           0 : void  SvxBulletPickTabPage::Reset( const SfxItemSet& rSet )
     445             : {
     446             :     const SfxPoolItem* pItem;
     447             :     // in Draw the item exists as WhichId, in Writer only as SlotId
     448           0 :     SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
     449           0 :     if(eState != SFX_ITEM_SET)
     450             :     {
     451           0 :         nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
     452           0 :         eState = rSet.GetItemState(nNumItemId, false, &pItem);
     453             : 
     454           0 :         if( eState != SFX_ITEM_SET )
     455             :         {
     456           0 :             pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, true ) );
     457           0 :             eState = SFX_ITEM_SET;
     458             :         }
     459             : 
     460             :     }
     461             :     DBG_ASSERT(eState == SFX_ITEM_SET, "no item found!");
     462           0 :     delete pSaveNum;
     463           0 :     pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     464             : 
     465           0 :     if(!pActNum)
     466           0 :         pActNum = new  SvxNumRule(*pSaveNum);
     467           0 :     else if(*pSaveNum != *pActNum)
     468           0 :         *pActNum = *pSaveNum;
     469           0 : }
     470             : 
     471           0 : IMPL_LINK_NOARG(SvxBulletPickTabPage, NumSelectHdl_Impl)
     472             : {
     473           0 :     if(pActNum)
     474             :     {
     475           0 :         bPreset = sal_False;
     476           0 :         bModified = sal_True;
     477           0 :         sal_Unicode cChar = aBulletTypes[m_pExamplesVS->GetSelectItemId() - 1];
     478           0 :         Font& rActBulletFont = lcl_GetDefaultBulletFont();
     479             : 
     480           0 :         sal_uInt16 nMask = 1;
     481           0 :         for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
     482             :         {
     483           0 :             if(nActNumLvl & nMask)
     484             :             {
     485           0 :                 SvxNumberFormat aFmt(pActNum->GetLevel(i));
     486           0 :                 aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
     487             :                 // #i93908# clear suffix for bullet lists
     488           0 :                 aFmt.SetPrefix( OUString() );
     489           0 :                 aFmt.SetSuffix( OUString() );
     490           0 :                 aFmt.SetBulletFont(&rActBulletFont);
     491           0 :                 aFmt.SetBulletChar(cChar );
     492           0 :                 aFmt.SetCharFmtName(sBulletCharFmtName);
     493             :                 // #62069# // #92724#
     494           0 :                 aFmt.SetBulletRelSize(45);
     495           0 :                 pActNum->SetLevel(i, aFmt);
     496             :             }
     497           0 :             nMask <<= 1;
     498             :         }
     499             :     }
     500             : 
     501           0 :     return 0;
     502             : }
     503             : 
     504             : 
     505           0 : IMPL_LINK_NOARG(SvxBulletPickTabPage, DoubleClickHdl_Impl)
     506             : {
     507           0 :     NumSelectHdl_Impl(m_pExamplesVS);
     508           0 :     PushButton& rOk = GetTabDialog()->GetOKButton();
     509           0 :     rOk.GetClickHdl().Call(&rOk);
     510           0 :     return 0;
     511             : }
     512             : 
     513             : 
     514           0 : void SvxBulletPickTabPage::PageCreated(SfxAllItemSet aSet)
     515             : {
     516             : 
     517           0 :     SFX_ITEMSET_ARG (&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,false);
     518             : 
     519           0 :     if (pBulletCharFmt)
     520           0 :         SetCharFmtName( pBulletCharFmt->GetValue());
     521             : 
     522             : 
     523           0 : }
     524             : 
     525             : 
     526           0 : SvxNumPickTabPage::SvxNumPickTabPage(Window* pParent,
     527             :                                const SfxItemSet& rSet)
     528             :     : SfxTabPage(pParent, "PickOutlinePage", "cui/ui/pickoutlinepage.ui", rSet)
     529             :     , pActNum(0)
     530             :     , pSaveNum(0)
     531             :     , nActNumLvl(SAL_MAX_UINT16)
     532             :     , nNumItemId(SID_ATTR_NUMBERING_RULE)
     533             :     , bModified(false)
     534           0 :     , bPreset(false)
     535             : {
     536           0 :     SetExchangeSupport();
     537             : 
     538           0 :     get(m_pExamplesVS, "valueset");
     539           0 :     m_pExamplesVS->init(NUM_PAGETYPE_NUM);
     540           0 :     m_pExamplesVS->SetSelectHdl(LINK(this, SvxNumPickTabPage, NumSelectHdl_Impl));
     541           0 :     m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage, DoubleClickHdl_Impl));
     542             : 
     543           0 :     Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
     544           0 :     if(xDefNum.is())
     545             :     {
     546           0 :         Sequence<Reference<XIndexAccess> > aOutlineAccess;
     547           0 :         const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
     548             :         try
     549             :         {
     550           0 :             aOutlineAccess = xDefNum->getDefaultOutlineNumberings( rLocale );
     551             : 
     552           0 :             for(sal_Int32 nItem = 0;
     553           0 :                 nItem < aOutlineAccess.getLength() && nItem < NUM_VALUSET_COUNT;
     554             :                 nItem++ )
     555             :             {
     556           0 :                 SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ];
     557             : 
     558           0 :                 Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem];
     559           0 :                 for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
     560             :                 {
     561           0 :                     Any aValueAny = xLevel->getByIndex(nLevel);
     562           0 :                     Sequence<PropertyValue> aLevelProps;
     563           0 :                     aValueAny >>= aLevelProps;
     564           0 :                     SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aLevelProps);
     565           0 :                     rItemArr.push_back( pNew );
     566           0 :                 }
     567           0 :             }
     568             :         }
     569           0 :         catch(const Exception&)
     570             :         {
     571             :         }
     572           0 :         Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
     573           0 :         m_pExamplesVS->SetOutlineNumberingSettings(aOutlineAccess, xFormat, rLocale);
     574           0 :     }
     575           0 : }
     576             : 
     577           0 : SvxNumPickTabPage::~SvxNumPickTabPage()
     578             : {
     579           0 :     delete pActNum;
     580           0 :     delete pSaveNum;
     581           0 : }
     582             : 
     583           0 : SfxTabPage*  SvxNumPickTabPage::Create( Window* pParent,
     584             :                                 const SfxItemSet& rAttrSet)
     585             : {
     586           0 :     return new SvxNumPickTabPage(pParent, rAttrSet);
     587             : }
     588             : 
     589           0 : bool  SvxNumPickTabPage::FillItemSet( SfxItemSet& rSet )
     590             : {
     591           0 :     if( (bPreset || bModified) && pActNum)
     592             :     {
     593           0 :         *pSaveNum = *pActNum;
     594           0 :         rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
     595           0 :         rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     596             :     }
     597           0 :     return bModified;
     598             : }
     599             : 
     600           0 : void  SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
     601             : {
     602             :     const SfxPoolItem* pItem;
     603           0 :     bPreset = sal_False;
     604           0 :     sal_Bool bIsPreset = sal_False;
     605           0 :     const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
     606           0 :     if(pExampleSet)
     607             :     {
     608           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
     609           0 :             bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
     610           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
     611           0 :             nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
     612             :     }
     613           0 :     if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, false, &pItem))
     614             :     {
     615           0 :         delete pSaveNum;
     616           0 :         pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     617             :     }
     618           0 :     if(pActNum && *pSaveNum != *pActNum)
     619             :     {
     620           0 :         *pActNum = *pSaveNum;
     621           0 :         m_pExamplesVS->SetNoSelection();
     622             :     }
     623             : 
     624           0 :     if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
     625             :     {
     626           0 :         m_pExamplesVS->SelectItem(1);
     627           0 :         NumSelectHdl_Impl(m_pExamplesVS);
     628           0 :         bPreset = sal_True;
     629             :     }
     630           0 :     bPreset |= bIsPreset;
     631           0 :     bModified = sal_False;
     632           0 : }
     633             : 
     634           0 : int  SvxNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
     635             : {
     636           0 :     if(_pSet)
     637           0 :         FillItemSet(*_pSet);
     638           0 :     return sal_True;
     639             : }
     640             : 
     641           0 : void  SvxNumPickTabPage::Reset( const SfxItemSet& rSet )
     642             : {
     643             :     const SfxPoolItem* pItem;
     644             :     // in Draw the item exists as WhichId, in Writer only as SlotId
     645           0 :     SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
     646           0 :     if(eState != SFX_ITEM_SET)
     647             :     {
     648           0 :         nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
     649           0 :         eState = rSet.GetItemState(nNumItemId, false, &pItem);
     650             : 
     651           0 :         if( eState != SFX_ITEM_SET )
     652             :         {
     653           0 :             pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, true ) );
     654           0 :             eState = SFX_ITEM_SET;
     655             :         }
     656             : 
     657             :     }
     658             :     DBG_ASSERT(eState == SFX_ITEM_SET, "no item found!");
     659           0 :     delete pSaveNum;
     660           0 :     pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     661             : 
     662           0 :     if(!pActNum)
     663           0 :         pActNum = new  SvxNumRule(*pSaveNum);
     664           0 :     else if(*pSaveNum != *pActNum)
     665           0 :         *pActNum = *pSaveNum;
     666             : 
     667           0 : }
     668             : 
     669             : // all levels are changed here
     670           0 : IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl)
     671             : {
     672           0 :     if(pActNum)
     673             :     {
     674           0 :         bPreset = sal_False;
     675           0 :         bModified = sal_True;
     676             : 
     677           0 :         const FontList*  pList = 0;
     678             : 
     679           0 :         SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[m_pExamplesVS->GetSelectItemId() - 1];
     680             : 
     681           0 :         Font& rActBulletFont = lcl_GetDefaultBulletFont();
     682           0 :         SvxNumSettings_Impl* pLevelSettings = 0;
     683           0 :         for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
     684             :         {
     685           0 :             if(rItemArr.size() > i)
     686           0 :                 pLevelSettings = &rItemArr[i];
     687           0 :             if(!pLevelSettings)
     688           0 :                 break;
     689           0 :             SvxNumberFormat aFmt(pActNum->GetLevel(i));
     690           0 :             aFmt.SetNumberingType( pLevelSettings->nNumberType );
     691           0 :             sal_uInt16 nUpperLevelOrChar = (sal_uInt16)pLevelSettings->nParentNumbering;
     692           0 :             if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
     693             :             {
     694             :                 // #i93908# clear suffix for bullet lists
     695           0 :                 aFmt.SetPrefix(OUString());
     696           0 :                 aFmt.SetSuffix(OUString());
     697           0 :                 if( !pLevelSettings->sBulletFont.isEmpty() &&
     698             :                     pLevelSettings->sBulletFont.compareTo(
     699           0 :                             rActBulletFont.GetName()))
     700             :                 {
     701             :                     //search for the font
     702           0 :                     if(!pList)
     703             :                     {
     704           0 :                         SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
     705             :                         const SvxFontListItem* pFontListItem =
     706             :                                 (const SvxFontListItem* )pCurDocShell
     707           0 :                                                     ->GetItem( SID_ATTR_CHAR_FONTLIST );
     708           0 :                         pList = pFontListItem ? pFontListItem->GetFontList() : 0;
     709             :                     }
     710           0 :                     if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
     711             :                     {
     712             :                         FontInfo aInfo = pList->Get(
     713           0 :                             pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE);
     714           0 :                         Font aFont(aInfo);
     715           0 :                         aFmt.SetBulletFont(&aFont);
     716             :                     }
     717             :                     else
     718             :                     {
     719             :                         //if it cannot be found then create a new one
     720             :                         Font aCreateFont( pLevelSettings->sBulletFont,
     721           0 :                                                 OUString(), Size( 0, 14 ) );
     722           0 :                         aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
     723           0 :                         aCreateFont.SetFamily( FAMILY_DONTKNOW );
     724           0 :                         aCreateFont.SetPitch( PITCH_DONTKNOW );
     725           0 :                         aCreateFont.SetWeight( WEIGHT_DONTKNOW );
     726           0 :                         aCreateFont.SetTransparent( true );
     727           0 :                         aFmt.SetBulletFont( &aCreateFont );
     728             :                     }
     729             :                 }
     730             :                 else
     731           0 :                     aFmt.SetBulletFont( &rActBulletFont );
     732             : 
     733           0 :                 aFmt.SetBulletChar( !pLevelSettings->sBulletChar.isEmpty()
     734           0 :                                         ? pLevelSettings->sBulletChar[0]
     735           0 :                                         : 0 );
     736           0 :                 aFmt.SetCharFmtName( sBulletCharFmtName );
     737             :                 // #62069# // #92724#
     738           0 :                 aFmt.SetBulletRelSize(45);
     739             :             }
     740             :             else
     741             :             {
     742           0 :                 aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 0));
     743           0 :                 aFmt.SetCharFmtName(sNumCharFmtName);
     744             :                 // #62069# // #92724#
     745           0 :                 aFmt.SetBulletRelSize(100);
     746             :                 // #i93908#
     747           0 :                 aFmt.SetPrefix(pLevelSettings->sPrefix);
     748           0 :                 aFmt.SetSuffix(pLevelSettings->sSuffix);
     749             :             }
     750           0 :             pActNum->SetLevel(i, aFmt);
     751           0 :         }
     752             :     }
     753           0 :     return 0;
     754             : }
     755             : 
     756           0 : IMPL_LINK_NOARG(SvxNumPickTabPage, DoubleClickHdl_Impl)
     757             : {
     758           0 :     NumSelectHdl_Impl(m_pExamplesVS);
     759           0 :     PushButton& rOk = GetTabDialog()->GetOKButton();
     760           0 :     rOk.GetClickHdl().Call(&rOk);
     761           0 :     return 0;
     762             : }
     763             : 
     764           0 : void SvxNumPickTabPage::PageCreated(SfxAllItemSet aSet)
     765             : {
     766           0 :     SFX_ITEMSET_ARG (&aSet,pNumCharFmt,SfxStringItem,SID_NUM_CHAR_FMT,false);
     767           0 :     SFX_ITEMSET_ARG (&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,false);
     768             : 
     769             : 
     770           0 :     if (pNumCharFmt &&pBulletCharFmt)
     771           0 :         SetCharFmtNames( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
     772           0 : }
     773             : 
     774           0 : SvxBitmapPickTabPage::SvxBitmapPickTabPage(Window* pParent,
     775             :                                const SfxItemSet& rSet)
     776             :     : SfxTabPage(pParent, "PickGraphicPage", "cui/ui/pickgraphicpage.ui", rSet)
     777             :     , pActNum(0)
     778             :     , pSaveNum(0)
     779             :     , nActNumLvl(SAL_MAX_UINT16)
     780             :     , nNumItemId(SID_ATTR_NUMBERING_RULE)
     781             :     , bModified(false)
     782           0 :     , bPreset(false)
     783             : {
     784           0 :     SetExchangeSupport();
     785           0 :     get(m_pErrorText, "errorft");
     786           0 :     get(m_pExamplesVS, "valueset");
     787           0 :     m_pExamplesVS->SetSelectHdl(LINK(this, SvxBitmapPickTabPage, NumSelectHdl_Impl));
     788           0 :     m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage, DoubleClickHdl_Impl));
     789             : 
     790           0 :     eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
     791             : 
     792             :     // determine graphic name
     793           0 :     GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
     794             : 
     795           0 :     size_t i = 0;
     796           0 :     for(std::vector<OUString>::iterator it = aGrfNames.begin(); it != aGrfNames.end(); ++it, ++i)
     797             :     {
     798           0 :         m_pExamplesVS->InsertItem( i + 1, i);
     799             : 
     800           0 :         INetURLObject aObj(*it);
     801           0 :         if(aObj.GetProtocol() == INET_PROT_FILE)
     802           0 :             *it = aObj.PathToFileName();
     803             : 
     804           0 :         m_pExamplesVS->SetItemText( i + 1, *it );
     805           0 :     }
     806             : 
     807           0 :     if(aGrfNames.empty())
     808             :     {
     809           0 :         m_pErrorText->Show();
     810             :     }
     811             :     else
     812             :     {
     813           0 :         m_pExamplesVS->Show();
     814           0 :         m_pExamplesVS->Format();
     815             :     }
     816           0 : }
     817             : 
     818           0 : SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
     819             : {
     820           0 :     delete pActNum;
     821           0 :     delete pSaveNum;
     822           0 : }
     823             : 
     824           0 : SfxTabPage*  SvxBitmapPickTabPage::Create( Window* pParent,
     825             :                                 const SfxItemSet& rAttrSet)
     826             : {
     827           0 :     return new SvxBitmapPickTabPage(pParent, rAttrSet);
     828             : }
     829             : 
     830           0 : void  SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet)
     831             : {
     832             :     const SfxPoolItem* pItem;
     833           0 :     bPreset = sal_False;
     834           0 :     sal_Bool bIsPreset = sal_False;
     835           0 :     const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
     836           0 :     if(pExampleSet)
     837             :     {
     838           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
     839           0 :             bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
     840           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
     841           0 :             nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
     842             :     }
     843           0 :     if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, false, &pItem))
     844             :     {
     845           0 :         delete pSaveNum;
     846           0 :         pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     847             :     }
     848           0 :     if(pActNum && *pSaveNum != *pActNum)
     849             :     {
     850           0 :         *pActNum = *pSaveNum;
     851           0 :         m_pExamplesVS->SetNoSelection();
     852             :     }
     853             : 
     854           0 :     if(!aGrfNames.empty() &&
     855           0 :         (pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset)))
     856             :     {
     857           0 :         m_pExamplesVS->SelectItem(1);
     858           0 :         NumSelectHdl_Impl(m_pExamplesVS);
     859           0 :         bPreset = sal_True;
     860             :     }
     861           0 :     bPreset |= bIsPreset;
     862           0 :     bModified = sal_False;
     863           0 : }
     864             : 
     865           0 : int  SvxBitmapPickTabPage::DeactivatePage(SfxItemSet *_pSet)
     866             : {
     867           0 :     if(_pSet)
     868           0 :         FillItemSet(*_pSet);
     869           0 :     return sal_True;
     870             : }
     871             : 
     872           0 : bool  SvxBitmapPickTabPage::FillItemSet( SfxItemSet& rSet )
     873             : {
     874           0 :     if ( aGrfNames.empty() )
     875             :     {
     876           0 :         return false;
     877             :     }
     878           0 :     if( (bPreset || bModified) && pActNum)
     879             :     {
     880           0 :         *pSaveNum = *pActNum;
     881           0 :         rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
     882           0 :         rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     883             :     }
     884             : 
     885           0 :     return bModified;
     886             : }
     887             : 
     888           0 : void  SvxBitmapPickTabPage::Reset( const SfxItemSet& rSet )
     889             : {
     890             :     const SfxPoolItem* pItem;
     891             :     // in Draw the item exists as WhichId, in Writer only as SlotId
     892           0 :     SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
     893           0 :     if(eState != SFX_ITEM_SET)
     894             :     {
     895           0 :         nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
     896           0 :         eState = rSet.GetItemState(nNumItemId, false, &pItem);
     897             : 
     898           0 :         if( eState != SFX_ITEM_SET )
     899             :         {
     900           0 :             pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, true ) );
     901           0 :             eState = SFX_ITEM_SET;
     902             :         }
     903             : 
     904             :     }
     905             :     DBG_ASSERT(eState == SFX_ITEM_SET, "no item found!");
     906           0 :     delete pSaveNum;
     907           0 :     pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
     908             : 
     909           0 :     if(!pActNum)
     910           0 :         pActNum = new  SvxNumRule(*pSaveNum);
     911           0 :     else if(*pSaveNum != *pActNum)
     912           0 :         *pActNum = *pSaveNum;
     913           0 : }
     914             : 
     915           0 : IMPL_LINK_NOARG(SvxBitmapPickTabPage, NumSelectHdl_Impl)
     916             : {
     917           0 :     if(pActNum)
     918             :     {
     919           0 :         bPreset = sal_False;
     920           0 :         bModified = sal_True;
     921           0 :         sal_uInt16 nIdx = m_pExamplesVS->GetSelectItemId() - 1;
     922             : 
     923           0 :         sal_uInt16 nMask = 1;
     924           0 :         OUString aEmptyStr;
     925           0 :         sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
     926           0 :         for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
     927             :         {
     928           0 :             if(nActNumLvl & nMask)
     929             :             {
     930           0 :                 SvxNumberFormat aFmt(pActNum->GetLevel(i));
     931           0 :                 aFmt.SetNumberingType(nSetNumberingType);
     932           0 :                 aFmt.SetPrefix( aEmptyStr );
     933           0 :                 aFmt.SetSuffix( aEmptyStr );
     934           0 :                 aFmt.SetCharFmtName( sNumCharFmtName );
     935             : 
     936           0 :                 Graphic aGraphic;
     937           0 :                 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nIdx, &aGraphic))
     938             :                 {
     939           0 :                     Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
     940           0 :                     sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
     941           0 :                     aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)eCoreUnit);
     942           0 :                     SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
     943           0 :                     aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
     944             :                 }
     945           0 :                 else if(aGrfNames.size() > nIdx)
     946           0 :                     aFmt.SetGraphic( aGrfNames[nIdx] );
     947           0 :                 pActNum->SetLevel(i, aFmt);
     948             :             }
     949           0 :             nMask <<= 1 ;
     950           0 :         }
     951             :     }
     952             : 
     953           0 :     return 0;
     954             : }
     955             : 
     956           0 : IMPL_LINK_NOARG(SvxBitmapPickTabPage, DoubleClickHdl_Impl)
     957             : {
     958           0 :     NumSelectHdl_Impl(m_pExamplesVS);
     959           0 :     PushButton& rOk = GetTabDialog()->GetOKButton();
     960           0 :     rOk.GetClickHdl().Call(&rOk);
     961           0 :     return 0;
     962             : }
     963             : 
     964             : // static
     965           0 : void SvxNumOptionsTabPage::GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove )
     966             : {
     967             : 
     968           0 :     Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
     969           0 :     Reference<XNumberingTypeInfo> xInfo(xDefNum, UNO_QUERY);
     970             : 
     971             :     // Extended numbering schemes present in the resource but not offered by
     972             :     // the i18n framework per configuration must be removed from the listbox.
     973             :     // Do not remove a special entry matching nDoNotRemove.
     974           0 :     const sal_uInt16 nDontRemove = SAL_MAX_UINT16;
     975           0 :     ::std::vector< sal_uInt16> aRemove( rFmtLB.GetEntryCount(), nDontRemove);
     976           0 :     for (size_t i=0; i<aRemove.size(); ++i)
     977             :     {
     978             :         sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)rFmtLB.GetEntryData(
     979           0 :                 sal::static_int_cast< sal_Int32 >(i));
     980           0 :         if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N && nEntryData != nDoNotRemove)
     981           0 :             aRemove[i] = nEntryData;
     982             :     }
     983           0 :     if(xInfo.is())
     984             :     {
     985           0 :         Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes(  );
     986           0 :         const sal_Int16* pTypes = aTypes.getConstArray();
     987           0 :         for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
     988             :         {
     989           0 :             sal_Int16 nCurrent = pTypes[nType];
     990           0 :             if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
     991             :             {
     992           0 :                 sal_Bool bInsert = sal_True;
     993           0 :                 for(sal_Int32 nEntry = 0; nEntry < rFmtLB.GetEntryCount(); nEntry++)
     994             :                 {
     995           0 :                     sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)rFmtLB.GetEntryData(nEntry);
     996           0 :                     if(nEntryData == (sal_uInt16) nCurrent)
     997             :                     {
     998           0 :                         bInsert = sal_False;
     999           0 :                         aRemove[nEntry] = nDontRemove;
    1000           0 :                         break;
    1001             :                     }
    1002             :                 }
    1003           0 :                 if(bInsert)
    1004             :                 {
    1005           0 :                     OUString aIdent = xInfo->getNumberingIdentifier( nCurrent );
    1006           0 :                     sal_Int32 nPos = rFmtLB.InsertEntry(aIdent);
    1007           0 :                     rFmtLB.SetEntryData(nPos,(void*)(sal_uLong)nCurrent);
    1008             :                 }
    1009             :             }
    1010           0 :         }
    1011             :     }
    1012           0 :     for (size_t i=0; i<aRemove.size(); ++i)
    1013             :     {
    1014           0 :         if (aRemove[i] != nDontRemove)
    1015             :         {
    1016           0 :             sal_Int32 nPos = rFmtLB.GetEntryPos( (void*)(sal_uLong)aRemove[i]);
    1017           0 :             rFmtLB.RemoveEntry( nPos);
    1018             :         }
    1019           0 :     }
    1020           0 : }
    1021             : 
    1022             : // tabpage numbering options
    1023           0 : SvxNumOptionsTabPage::SvxNumOptionsTabPage(Window* pParent,
    1024             :                                const SfxItemSet& rSet)
    1025             :     : SfxTabPage(pParent, "NumberingOptionsPage", "cui/ui/numberingoptionspage.ui", rSet)
    1026             :     , pActNum(0)
    1027             :     , pSaveNum(0)
    1028             :     , bLastWidthModified(sal_False)
    1029             :     , bModified(sal_False)
    1030             :     , bPreset(sal_False)
    1031             :     , bAutomaticCharStyles(sal_True)
    1032             :     , bHTMLMode(sal_False)
    1033             :     , bMenuButtonInitialized(sal_False)
    1034             :     , nBullet(0xff)
    1035             :     , nActNumLvl(SAL_MAX_UINT16)
    1036           0 :     , nNumItemId(SID_ATTR_NUMBERING_RULE)
    1037             : {
    1038           0 :     get(m_pLevelLB, "levellb");
    1039           0 :     get(m_pFmtLB, "numfmtlb");
    1040             : 
    1041           0 :     get(m_pSeparatorFT, "separator");
    1042           0 :     get(m_pPrefixFT, "prefixft");
    1043           0 :     get(m_pPrefixED, "prefix");
    1044           0 :     get(m_pSuffixFT, "suffixft");
    1045           0 :     get(m_pSuffixED, "suffix");
    1046             : 
    1047           0 :     get(m_pCharFmtFT, "charstyleft");
    1048           0 :     get(m_pCharFmtLB, "charstyle");
    1049             : 
    1050           0 :     get(m_pBulColorFT, "colorft");
    1051           0 :     get(m_pBulColLB, "color");
    1052             : 
    1053           0 :     get(m_pBulRelSizeFT, "relsizeft");
    1054           0 :     get(m_pBulRelSizeMF, "relsize");
    1055             : 
    1056           0 :     get(m_pAllLevelFT, "sublevelsft");
    1057           0 :     get(m_pAllLevelNF, "sublevels");
    1058             : 
    1059           0 :     get(m_pStartFT, "startatft");
    1060           0 :     get(m_pStartED, "startat");
    1061             : 
    1062           0 :     get(m_pBulletFT, "bulletft");
    1063           0 :     get(m_pBulletPB, "bullet");
    1064             : 
    1065           0 :     get(m_pAlignFT, "numalignft");
    1066           0 :     get(m_pAlignLB, "numalign");
    1067             : 
    1068           0 :     get(m_pBitmapFT, "bitmapft");
    1069           0 :     get(m_pBitmapMB, "bitmap");
    1070             : 
    1071           0 :     get(m_pWidthFT, "widthft");
    1072           0 :     get(m_pWidthMF, "widthmf");
    1073           0 :     get(m_pHeightFT, "heightft");
    1074           0 :     get(m_pHeightMF, "heightmf");
    1075             : 
    1076           0 :     get(m_pRatioCB, "keepratio");
    1077             : 
    1078           0 :     get(m_pOrientFT, "orientft");
    1079           0 :     get(m_pOrientLB, "orientlb");
    1080             : 
    1081           0 :     get(m_pAllLevelsFrame, "levelsframe");
    1082           0 :     get(m_pSameLevelCB, "allsame");
    1083             : 
    1084           0 :     get(m_pPreviewWIN, "preview");
    1085             : 
    1086           0 :     m_pPreviewWIN->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
    1087           0 :     SetExchangeSupport();
    1088           0 :     aActBulletFont = lcl_GetDefaultBulletFont();
    1089             : 
    1090           0 :     m_pBulletPB->SetClickHdl(LINK(this, SvxNumOptionsTabPage, BulletHdl_Impl));
    1091           0 :     m_pFmtLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl));
    1092           0 :     m_pBitmapMB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, GraphicHdl_Impl));
    1093           0 :     m_pLevelLB->EnableMultiSelection(true);
    1094           0 :     m_pLevelLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, LevelHdl_Impl));
    1095           0 :     m_pCharFmtLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, CharFmtHdl_Impl));
    1096           0 :     m_pWidthMF->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
    1097           0 :     m_pHeightMF->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
    1098           0 :     m_pRatioCB->SetClickHdl(LINK(this, SvxNumOptionsTabPage, RatioHdl_Impl));
    1099           0 :     m_pStartED->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
    1100           0 :     m_pPrefixED->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
    1101           0 :     m_pSuffixED->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
    1102           0 :     m_pAllLevelNF->SetModifyHdl(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl));
    1103           0 :     m_pOrientLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl));
    1104           0 :     m_pSameLevelCB->SetClickHdl(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl));
    1105           0 :     m_pBulRelSizeMF->SetModifyHdl(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl));
    1106           0 :     m_pBulColLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, BulColorHdl_Impl));
    1107           0 :     aInvalidateTimer.SetTimeoutHdl(LINK(this, SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl));
    1108           0 :     aInvalidateTimer.SetTimeout(50);
    1109             : 
    1110           0 :     Menu *pBitmapMenu = m_pBitmapMB->GetPopupMenu();
    1111             : 
    1112           0 :     pBitmapMenu->SetHighlightHdl(LINK(this, SvxNumOptionsTabPage, PopupActivateHdl_Impl));
    1113           0 :     m_nGalleryId = pBitmapMenu->GetItemId("gallery");
    1114             :     assert(m_nGalleryId != MENU_ITEM_NOTFOUND);
    1115           0 :     PopupMenu* pPopup = new PopupMenu;
    1116           0 :     pBitmapMenu->SetPopupMenu(m_nGalleryId, pPopup);
    1117             : 
    1118           0 :     eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
    1119             : 
    1120             :     // Get advanced numbering types from the component.
    1121             :     // Watch out for the ugly 0x88/*SVX_NUM_BITMAP|0x80*/ to not remove that.
    1122           0 :     GetI18nNumbering( *m_pFmtLB, (SVX_NUM_BITMAP | 0x80));
    1123           0 : }
    1124             : 
    1125           0 : SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
    1126             : {
    1127           0 :     delete m_pBitmapMB->GetPopupMenu()->GetPopupMenu(m_nGalleryId);
    1128           0 :     delete pActNum;
    1129           0 :     delete pSaveNum;
    1130           0 : }
    1131             : 
    1132           0 : void SvxNumOptionsTabPage::SetMetric(FieldUnit eMetric)
    1133             : {
    1134           0 :     if(eMetric == FUNIT_MM)
    1135             :     {
    1136           0 :         m_pWidthMF->SetDecimalDigits(1);
    1137           0 :         m_pHeightMF->SetDecimalDigits(1);
    1138             :     }
    1139           0 :     m_pWidthMF->SetUnit( eMetric );
    1140           0 :     m_pHeightMF->SetUnit( eMetric );
    1141           0 : }
    1142             : 
    1143           0 : SfxTabPage* SvxNumOptionsTabPage::Create( Window* pParent,
    1144             :                                 const SfxItemSet& rAttrSet)
    1145             : {
    1146           0 :     return new SvxNumOptionsTabPage(pParent, rAttrSet);
    1147             : };
    1148             : 
    1149           0 : void    SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet)
    1150             : {
    1151             :     const SfxPoolItem* pItem;
    1152           0 :     const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
    1153           0 :     sal_uInt16 nTmpNumLvl = SAL_MAX_UINT16;
    1154           0 :     if(pExampleSet)
    1155             :     {
    1156           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
    1157           0 :             bPreset = ((const SfxBoolItem*)pItem)->GetValue();
    1158           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
    1159           0 :             nTmpNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
    1160             :     }
    1161           0 :     if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, false, &pItem))
    1162             :     {
    1163           0 :         delete pSaveNum;
    1164           0 :         pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
    1165             :     }
    1166             : 
    1167           0 :     bModified = (!pActNum->Get( 0 ) || bPreset);
    1168           0 :     if(*pActNum != *pSaveNum ||
    1169           0 :         nActNumLvl != nTmpNumLvl)
    1170             :     {
    1171           0 :         nActNumLvl = nTmpNumLvl;
    1172           0 :         sal_uInt16 nMask = 1;
    1173           0 :         m_pLevelLB->SetUpdateMode(false);
    1174           0 :         m_pLevelLB->SetNoSelection();
    1175           0 :         m_pLevelLB->SelectEntryPos( pActNum->GetLevelCount(), nActNumLvl == SAL_MAX_UINT16);
    1176           0 :         if(nActNumLvl != SAL_MAX_UINT16)
    1177           0 :             for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1178             :             {
    1179           0 :                 if(nActNumLvl & nMask)
    1180           0 :                     m_pLevelLB->SelectEntryPos( i, true);
    1181           0 :                 nMask <<= 1 ;
    1182             :             }
    1183           0 :         m_pLevelLB->SetUpdateMode(true);
    1184           0 :         *pActNum = *pSaveNum;
    1185           0 :         InitControls();
    1186             :     }
    1187             : 
    1188           0 : }
    1189             : 
    1190           0 : int     SvxNumOptionsTabPage::DeactivatePage(SfxItemSet * _pSet)
    1191             : {
    1192           0 :     if(_pSet)
    1193           0 :         FillItemSet(*_pSet);
    1194           0 :     return sal_True;
    1195             : }
    1196             : 
    1197           0 : bool    SvxNumOptionsTabPage::FillItemSet( SfxItemSet& rSet )
    1198             : {
    1199           0 :     rSet.Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
    1200           0 :     if(bModified && pActNum)
    1201             :     {
    1202           0 :         *pSaveNum = *pActNum;
    1203           0 :         rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
    1204           0 :         rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
    1205             :     }
    1206           0 :     return bModified;
    1207             : };
    1208             : 
    1209           0 : void    SvxNumOptionsTabPage::Reset( const SfxItemSet& rSet )
    1210             : {
    1211             :     const SfxPoolItem* pItem;
    1212             :     // in Draw the item exists as WhichId, in Writer only as SlotId
    1213           0 :     SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
    1214           0 :     if(eState != SFX_ITEM_SET)
    1215             :     {
    1216           0 :         nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
    1217           0 :         eState = rSet.GetItemState(nNumItemId, false, &pItem);
    1218             : 
    1219           0 :         if( eState != SFX_ITEM_SET )
    1220             :         {
    1221           0 :             pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, true ) );
    1222           0 :             eState = SFX_ITEM_SET;
    1223             :         }
    1224             : 
    1225             :     }
    1226             :     DBG_ASSERT(eState == SFX_ITEM_SET, "no item found!");
    1227           0 :     delete pSaveNum;
    1228           0 :     pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
    1229             : 
    1230             :     // insert levels
    1231           0 :     if(!m_pLevelLB->GetEntryCount())
    1232             :     {
    1233           0 :         for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
    1234           0 :             m_pLevelLB->InsertEntry( OUString::number(i));
    1235           0 :         if(pSaveNum->GetLevelCount() > 1)
    1236             :         {
    1237           0 :             OUString sEntry( "1 - " );
    1238           0 :             sEntry += OUString::number( pSaveNum->GetLevelCount() );
    1239           0 :             m_pLevelLB->InsertEntry(sEntry);
    1240           0 :             m_pLevelLB->SelectEntry(sEntry);
    1241             :         }
    1242             :         else
    1243           0 :             m_pLevelLB->SelectEntryPos(0);
    1244             :     }
    1245             :     else
    1246           0 :         m_pLevelLB->SelectEntryPos(m_pLevelLB->GetEntryCount() - 1);
    1247             : 
    1248           0 :     sal_uInt16 nMask = 1;
    1249           0 :     m_pLevelLB->SetUpdateMode(false);
    1250           0 :     m_pLevelLB->SetNoSelection();
    1251           0 :     if(nActNumLvl == SAL_MAX_UINT16)
    1252             :     {
    1253           0 :         m_pLevelLB->SelectEntryPos( pSaveNum->GetLevelCount(), true);
    1254             :     }
    1255             :     else
    1256           0 :         for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
    1257             :         {
    1258           0 :             if(nActNumLvl & nMask)
    1259           0 :                 m_pLevelLB->SelectEntryPos( i, true);
    1260           0 :             nMask <<= 1 ;
    1261             :         }
    1262           0 :     m_pLevelLB->SetUpdateMode(true);
    1263             : 
    1264           0 :     if(!pActNum)
    1265           0 :         pActNum = new  SvxNumRule(*pSaveNum);
    1266           0 :     else if(*pSaveNum != *pActNum)
    1267           0 :         *pActNum = *pSaveNum;
    1268           0 :     m_pPreviewWIN->SetNumRule(pActNum);
    1269           0 :     m_pSameLevelCB->Check(pActNum->IsContinuousNumbering());
    1270             : 
    1271             :     // fill ColorListBox as needed
    1272           0 :     if ( pActNum->IsFeatureSupported( NUM_BULLET_COLOR ) )
    1273             :     {
    1274           0 :         SfxObjectShell* pDocSh = SfxObjectShell::Current();
    1275             :         DBG_ASSERT( pDocSh, "DocShell not found!" );
    1276           0 :         XColorListRef pColorTable;
    1277           0 :         if ( pDocSh )
    1278             :         {
    1279           0 :             pItem = pDocSh->GetItem( SID_COLOR_TABLE );
    1280           0 :             if ( pItem )
    1281           0 :                 pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
    1282             :         }
    1283             : 
    1284           0 :         if ( !pColorTable.is() )
    1285           0 :             pColorTable = XColorList::CreateStdColorList();
    1286             : 
    1287           0 :         m_pBulColLB->InsertEntry( Color( COL_AUTO ), SVX_RESSTR( RID_SVXSTR_AUTOMATIC ));
    1288             : 
    1289           0 :         for ( long i = 0; i < pColorTable->Count(); i++ )
    1290             :         {
    1291           0 :             XColorEntry* pEntry = pColorTable->GetColor(i);
    1292           0 :             m_pBulColLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
    1293           0 :         }
    1294             :     }
    1295             : 
    1296             :     SfxObjectShell* pShell;
    1297           0 :     if ( SFX_ITEM_SET == rSet.GetItemState( SID_HTML_MODE, false, &pItem )
    1298           0 :          || ( 0 != ( pShell = SfxObjectShell::Current()) &&
    1299           0 :               0 != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
    1300             :     {
    1301           0 :         sal_uInt16 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
    1302           0 :         bHTMLMode = 0 != (nHtmlMode&HTMLMODE_ON);
    1303             :     }
    1304             : 
    1305           0 :     sal_Bool bCharFmt = pActNum->IsFeatureSupported(NUM_CHAR_STYLE);
    1306           0 :     m_pCharFmtFT->Show(bCharFmt);
    1307           0 :     m_pCharFmtLB->Show(bCharFmt);
    1308             : 
    1309           0 :     sal_Bool bContinuous = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
    1310             : 
    1311           0 :     sal_Bool bAllLevel = bContinuous && !bHTMLMode;
    1312           0 :     m_pAllLevelFT->Show(bAllLevel);
    1313           0 :     m_pAllLevelNF->Show(bAllLevel);
    1314             : 
    1315           0 :     m_pAllLevelsFrame->Show(bContinuous);
    1316             : 
    1317             :     // again misusage: in Draw there is numeration only until the bitmap
    1318             :     // without SVX_NUM_NUMBER_NONE
    1319             :     //remove types that are unsupported by Draw/Impress
    1320           0 :     if(!bContinuous)
    1321             :     {
    1322           0 :         sal_Int32 nFmtCount = m_pFmtLB->GetEntryCount();
    1323           0 :         for(sal_Int32 i = nFmtCount; i; i--)
    1324             :         {
    1325           0 :             sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)m_pFmtLB->GetEntryData(i - 1);
    1326           0 :             if(/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
    1327             :                 ((SVX_NUM_BITMAP|LINK_TOKEN) ==  nEntryData))
    1328           0 :                 m_pFmtLB->RemoveEntry(i - 1);
    1329             :         }
    1330             :     }
    1331             :     //one must be enabled
    1332           0 :     if(!pActNum->IsFeatureSupported(NUM_ENABLE_LINKED_BMP))
    1333             :     {
    1334           0 :         sal_IntPtr nData = SVX_NUM_BITMAP|LINK_TOKEN;
    1335           0 :         sal_Int32 nPos = m_pFmtLB->GetEntryPos((void*)nData);
    1336           0 :         if(LISTBOX_ENTRY_NOTFOUND != nPos)
    1337           0 :             m_pFmtLB->RemoveEntry(nPos);
    1338             :     }
    1339           0 :     else if(!pActNum->IsFeatureSupported(NUM_ENABLE_EMBEDDED_BMP))
    1340             :     {
    1341           0 :         sal_IntPtr nData = SVX_NUM_BITMAP;
    1342           0 :         sal_Int32 nPos = m_pFmtLB->GetEntryPos((void*)nData);
    1343           0 :         if(LISTBOX_ENTRY_NOTFOUND != nPos)
    1344           0 :             m_pFmtLB->RemoveEntry(nPos);
    1345             :     }
    1346           0 :     if(pActNum->IsFeatureSupported(NUM_SYMBOL_ALIGNMENT))
    1347             :     {
    1348           0 :         m_pAlignFT->Show();
    1349           0 :         m_pAlignLB->Show();
    1350           0 :         m_pAlignLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
    1351             :     }
    1352             :     else
    1353             :     {
    1354           0 :         m_pAlignFT->Hide();
    1355           0 :         m_pAlignLB->Hide();
    1356             :     }
    1357             : 
    1358             :     // MegaHack: because of a not-fixable 'design mistake/error' in Impress
    1359             :     // delete all kinds of numeric enumerations
    1360           0 :     if(pActNum->IsFeatureSupported(NUM_NO_NUMBERS))
    1361             :     {
    1362           0 :         sal_Int32 nFmtCount = m_pFmtLB->GetEntryCount();
    1363           0 :         for(sal_Int32 i = nFmtCount; i; i--)
    1364             :         {
    1365           0 :             sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)m_pFmtLB->GetEntryData(i - 1);
    1366           0 :             if( /*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/  nEntryData <= SVX_NUM_NUMBER_NONE)
    1367           0 :                 m_pFmtLB->RemoveEntry(i - 1);
    1368             :         }
    1369             :     }
    1370             : 
    1371           0 :     InitControls();
    1372           0 :     bModified = sal_False;
    1373             : 
    1374           0 : }
    1375             : 
    1376           0 : void SvxNumOptionsTabPage::InitControls()
    1377             : {
    1378           0 :     bool bShowBullet    = true;
    1379           0 :     bool bShowBitmap    = true;
    1380           0 :     bool bSameType      = true;
    1381           0 :     bool bSameStart     = true;
    1382           0 :     bool bSamePrefix    = true;
    1383           0 :     bool bSameSuffix    = true;
    1384           0 :     bool bAllLevel      = true;
    1385           0 :     bool bSameCharFmt   = true;
    1386           0 :     bool bSameVOrient   = true;
    1387           0 :     bool bSameSize      = true;
    1388           0 :     bool bSameBulColor  = true;
    1389           0 :     bool bSameBulRelSize= true;
    1390           0 :     bool bSameAdjust    = true;
    1391             : 
    1392             :     const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
    1393           0 :     OUString sFirstCharFmt;
    1394           0 :     sal_Int16 eFirstOrient = text::VertOrientation::NONE;
    1395           0 :     Size aFirstSize(0,0);
    1396           0 :     sal_uInt16 nMask = 1;
    1397           0 :     sal_uInt16 nLvl = SAL_MAX_UINT16;
    1398           0 :     sal_uInt16 nHighestLevel = 0;
    1399           0 :     OUString aEmptyStr;
    1400             : 
    1401           0 :     sal_Bool bBullColor = pActNum->IsFeatureSupported(NUM_BULLET_COLOR);
    1402           0 :     sal_Bool bBullRelSize = pActNum->IsFeatureSupported(NUM_BULLET_REL_SIZE);
    1403           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1404             :     {
    1405           0 :         if(nActNumLvl & nMask)
    1406             :         {
    1407           0 :             aNumFmtArr[i] = &pActNum->GetLevel(i);
    1408           0 :             bShowBullet &= aNumFmtArr[i]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL;
    1409           0 :             bShowBitmap &= (aNumFmtArr[i]->GetNumberingType()&(~LINK_TOKEN)) == SVX_NUM_BITMAP;
    1410           0 :             if(SAL_MAX_UINT16 == nLvl)
    1411             :             {
    1412           0 :                 nLvl = i;
    1413           0 :                 sFirstCharFmt = aNumFmtArr[i]->GetCharFmtName();
    1414           0 :                 eFirstOrient = aNumFmtArr[i]->GetVertOrient();
    1415           0 :                 if(bShowBitmap)
    1416           0 :                     aFirstSize = aNumFmtArr[i]->GetGraphicSize();
    1417             :             }
    1418           0 :             if( i > nLvl)
    1419             :             {
    1420           0 :                 bSameType &=   aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[nLvl]->GetNumberingType();
    1421           0 :                 bSameStart = aNumFmtArr[i]->GetStart() == aNumFmtArr[nLvl]->GetStart();
    1422             : 
    1423           0 :                 bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix();
    1424           0 :                 bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix();
    1425           0 :                 bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels();
    1426           0 :                 bSameCharFmt    &= sFirstCharFmt == aNumFmtArr[i]->GetCharFmtName();
    1427           0 :                 bSameVOrient    &= eFirstOrient == aNumFmtArr[i]->GetVertOrient();
    1428           0 :                 if(bShowBitmap && bSameSize)
    1429           0 :                     bSameSize &= aNumFmtArr[i]->GetGraphicSize() == aFirstSize;
    1430           0 :                 bSameBulColor &= aNumFmtArr[i]->GetBulletColor() == aNumFmtArr[nLvl]->GetBulletColor();
    1431           0 :                 bSameBulRelSize &= aNumFmtArr[i]->GetBulletRelSize() == aNumFmtArr[nLvl]->GetBulletRelSize();
    1432           0 :                 bSameAdjust     &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
    1433             :             }
    1434           0 :             nHighestLevel = i;
    1435             :         }
    1436             :         else
    1437           0 :             aNumFmtArr[i] = 0;
    1438             : 
    1439           0 :         nMask <<= 1 ;
    1440             :     }
    1441           0 :     SwitchNumberType(bShowBullet ? 1 : bShowBitmap ? 2 : 0);
    1442             : 
    1443             :     sal_uInt16 nNumberingType;
    1444           0 :     if (nLvl != SAL_MAX_UINT16)
    1445           0 :         nNumberingType = aNumFmtArr[nLvl]->GetNumberingType();
    1446             :     else
    1447             :     {
    1448           0 :         nNumberingType = SVX_NUM_NUMBER_NONE;
    1449           0 :         bAllLevel = false;
    1450           0 :         bSameAdjust = false;
    1451           0 :         bSameBulRelSize = false;
    1452           0 :         bSameBulColor = false;
    1453           0 :         bSameStart = false;
    1454           0 :         bSamePrefix = false;
    1455           0 :         bSameSuffix = false;
    1456             :     }
    1457             : 
    1458           0 :     CheckForStartValue_Impl(nNumberingType);
    1459             : 
    1460           0 :     if(bShowBitmap)
    1461             :     {
    1462           0 :         if(!bSameVOrient || eFirstOrient == text::VertOrientation::NONE)
    1463           0 :             m_pOrientLB->SetNoSelection();
    1464             :         else
    1465             :             m_pOrientLB->SelectEntryPos(
    1466           0 :                 sal::static_int_cast< sal_Int32 >(eFirstOrient - 1));
    1467             :                 // no text::VertOrientation::NONE
    1468             : 
    1469           0 :         if(bSameSize)
    1470             :         {
    1471           0 :             SetMetricValue(*m_pHeightMF, aFirstSize.Height(), eCoreUnit);
    1472           0 :             SetMetricValue(*m_pWidthMF, aFirstSize.Width(), eCoreUnit);
    1473             :         }
    1474             :         else
    1475             :         {
    1476           0 :             m_pHeightMF->SetText(aEmptyStr);
    1477           0 :             m_pWidthMF->SetText(aEmptyStr);
    1478             :         }
    1479             :     }
    1480             : 
    1481           0 :     if(bSameType)
    1482             :     {
    1483           0 :         sal_uInt16 nLBData = nNumberingType;
    1484           0 :         m_pFmtLB->SelectEntryPos(m_pFmtLB->GetEntryPos( (void*)sal::static_int_cast<sal_uIntPtr>( nLBData ) ));
    1485             :     }
    1486             :     else
    1487           0 :         m_pFmtLB->SetNoSelection();
    1488             : 
    1489           0 :     m_pAllLevelNF->Enable(nHighestLevel > 0 && !m_pSameLevelCB->IsChecked());
    1490           0 :     m_pAllLevelNF->SetMax(nHighestLevel + 1);
    1491           0 :     if(bAllLevel)
    1492             :     {
    1493           0 :         m_pAllLevelNF->SetValue(aNumFmtArr[nLvl]->GetIncludeUpperLevels());
    1494             :     }
    1495             :     else
    1496             :     {
    1497           0 :         m_pAllLevelNF->SetText(aEmptyStr);
    1498             :     }
    1499           0 :     if(bSameAdjust)
    1500             :     {
    1501           0 :         sal_Int32 nPos = 1; // centered
    1502           0 :         if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
    1503           0 :             nPos = 0;
    1504           0 :         else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
    1505           0 :             nPos = 2;
    1506           0 :         m_pAlignLB->SelectEntryPos(nPos);
    1507             :     }
    1508             :     else
    1509             :     {
    1510           0 :         m_pAlignLB->SetNoSelection();
    1511             :     }
    1512             : 
    1513           0 :     if(bBullRelSize)
    1514             :     {
    1515           0 :         if(bSameBulRelSize)
    1516           0 :             m_pBulRelSizeMF->SetValue(aNumFmtArr[nLvl]->GetBulletRelSize());
    1517             :         else
    1518           0 :             m_pBulRelSizeMF->SetText(aEmptyStr);
    1519             :     }
    1520           0 :     if(bBullColor)
    1521             :     {
    1522           0 :         if(bSameBulColor)
    1523           0 :             m_pBulColLB->SelectEntry(aNumFmtArr[nLvl]->GetBulletColor());
    1524             :         else
    1525           0 :             m_pBulColLB->SetNoSelection();
    1526             :     }
    1527           0 :     switch(nBullet)
    1528             :     {
    1529             :         case SHOW_NUMBERING:
    1530           0 :             if(bSameStart)
    1531             :             {
    1532           0 :                 m_pStartED->SetValue(aNumFmtArr[nLvl]->GetStart());
    1533             :             }
    1534             :             else
    1535           0 :                 m_pStartED->SetText(aEmptyStr);
    1536           0 :         break;
    1537             :         case SHOW_BULLET:
    1538           0 :         break;
    1539             :         case SHOW_BITMAP:
    1540           0 :         break;
    1541             :     }
    1542             : 
    1543           0 :     if(bSamePrefix)
    1544           0 :         m_pPrefixED->SetText(aNumFmtArr[nLvl]->GetPrefix());
    1545             :     else
    1546           0 :         m_pPrefixED->SetText(aEmptyStr);
    1547           0 :     if(bSameSuffix)
    1548           0 :         m_pSuffixED->SetText(aNumFmtArr[nLvl]->GetSuffix());
    1549             :     else
    1550           0 :         m_pSuffixED->SetText(aEmptyStr);
    1551             : 
    1552           0 :     if(bSameCharFmt)
    1553             :     {
    1554           0 :         if(!sFirstCharFmt.isEmpty())
    1555           0 :                 m_pCharFmtLB->SelectEntry(sFirstCharFmt);
    1556             :         else
    1557           0 :             m_pCharFmtLB->SelectEntryPos( 0 );
    1558             :     }
    1559             :     else
    1560           0 :         m_pCharFmtLB->SetNoSelection();
    1561             : 
    1562           0 :     m_pPreviewWIN->SetLevel(nActNumLvl);
    1563           0 :     m_pPreviewWIN->Invalidate();
    1564           0 : }
    1565             : 
    1566             : // 0 - Number; 1 - Bullet; 2 - Bitmap
    1567           0 : void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType, sal_Bool )
    1568             : {
    1569           0 :     if(nBullet == nType)
    1570           0 :         return;
    1571           0 :     nBullet = nType;
    1572           0 :     sal_Bool bBullet = (nType == SHOW_BULLET);
    1573           0 :     sal_Bool bBitmap = (nType == SHOW_BITMAP);
    1574           0 :     sal_Bool bEnableBitmap = (nType == SHOW_BITMAP);
    1575           0 :     sal_Bool bNumeric = !(bBitmap||bBullet);
    1576           0 :     m_pSeparatorFT->Show(bNumeric);
    1577           0 :     m_pPrefixFT->Show(bNumeric);
    1578           0 :     m_pPrefixED->Show(bNumeric);
    1579           0 :     m_pSuffixFT->Show(bNumeric);
    1580           0 :     m_pSuffixED->Show(bNumeric);
    1581             : 
    1582           0 :     sal_Bool bCharFmt = pActNum->IsFeatureSupported(NUM_CHAR_STYLE);
    1583           0 :     m_pCharFmtFT->Show(!bBitmap && bCharFmt);
    1584           0 :     m_pCharFmtLB->Show(!bBitmap && bCharFmt);
    1585             : 
    1586             :     // this is rather misusage, as there is no own flag
    1587             :     // for complete numeration
    1588           0 :     sal_Bool bAllLevelFeature = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
    1589           0 :     sal_Bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode;
    1590           0 :     m_pAllLevelFT->Show(bAllLevel);
    1591           0 :     m_pAllLevelNF->Show(bAllLevel);
    1592             : 
    1593           0 :     m_pStartFT->Show(!(bBullet||bBitmap));
    1594           0 :     m_pStartED->Show(!(bBullet||bBitmap));
    1595             : 
    1596           0 :     m_pBulletFT->Show(bBullet);
    1597           0 :     m_pBulletPB->Show(bBullet);
    1598           0 :     sal_Bool bBullColor = pActNum->IsFeatureSupported(NUM_BULLET_COLOR);
    1599           0 :     m_pBulColorFT->Show(!bBitmap && bBullColor);
    1600           0 :     m_pBulColLB->Show(!bBitmap && bBullColor);
    1601           0 :     sal_Bool bBullResSize = pActNum->IsFeatureSupported(NUM_BULLET_REL_SIZE);
    1602           0 :     m_pBulRelSizeFT->Show(!bBitmap && bBullResSize);
    1603           0 :     m_pBulRelSizeMF->Show(!bBitmap && bBullResSize);
    1604             : 
    1605           0 :     m_pBitmapFT->Show(bBitmap);
    1606           0 :     m_pBitmapMB->Show(bBitmap);
    1607             : 
    1608           0 :     m_pWidthFT->Show(bBitmap);
    1609           0 :     m_pWidthMF->Show(bBitmap);
    1610           0 :     m_pHeightFT->Show(bBitmap);
    1611           0 :     m_pHeightMF->Show(bBitmap);
    1612           0 :     m_pRatioCB->Show(bBitmap);
    1613             : 
    1614           0 :     m_pOrientFT->Show(bBitmap &&  bAllLevelFeature);
    1615           0 :     m_pOrientLB->Show(bBitmap &&  bAllLevelFeature);
    1616             : 
    1617           0 :     m_pWidthFT->Enable(bEnableBitmap);
    1618           0 :     m_pWidthMF->Enable(bEnableBitmap);
    1619           0 :     m_pHeightFT->Enable(bEnableBitmap);
    1620           0 :     m_pHeightMF->Enable(bEnableBitmap);
    1621           0 :     m_pRatioCB->Enable(bEnableBitmap);
    1622           0 :     m_pOrientFT->Enable(bEnableBitmap);
    1623           0 :     m_pOrientLB->Enable(bEnableBitmap);
    1624             : }
    1625             : 
    1626           0 : IMPL_LINK( SvxNumOptionsTabPage, LevelHdl_Impl, ListBox *, pBox )
    1627             : {
    1628           0 :     sal_uInt16 nSaveNumLvl = nActNumLvl;
    1629           0 :     nActNumLvl = 0;
    1630           0 :     if(pBox->IsEntryPosSelected( pActNum->GetLevelCount() ) &&
    1631           0 :         (pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
    1632             :     {
    1633           0 :         nActNumLvl = 0xFFFF;
    1634           0 :         pBox->SetUpdateMode(false);
    1635           0 :         for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
    1636           0 :             pBox->SelectEntryPos( i, false );
    1637           0 :         pBox->SetUpdateMode(true);
    1638             :     }
    1639           0 :     else if(pBox->GetSelectEntryCount())
    1640             :     {
    1641           0 :         sal_uInt16 nMask = 1;
    1642           0 :         for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
    1643             :         {
    1644           0 :             if(pBox->IsEntryPosSelected( i ))
    1645           0 :                 nActNumLvl |= nMask;
    1646           0 :             nMask <<= 1;
    1647             :         }
    1648           0 :         pBox->SelectEntryPos( pActNum->GetLevelCount(), false );
    1649             :     }
    1650             :     else
    1651             :     {
    1652           0 :         nActNumLvl = nSaveNumLvl;
    1653           0 :         sal_uInt16 nMask = 1;
    1654           0 :         for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
    1655             :         {
    1656           0 :             if(nActNumLvl & nMask)
    1657             :             {
    1658           0 :                 pBox->SelectEntryPos(i);
    1659           0 :                 break;
    1660             :             }
    1661           0 :             nMask <<=1;
    1662             :         }
    1663             :     }
    1664           0 :     InitControls();
    1665           0 :     return 0;
    1666             : }
    1667             : 
    1668           0 : IMPL_LINK_NOARG(SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl)
    1669             : {
    1670           0 :     m_pPreviewWIN->Invalidate();
    1671           0 :     return 0;
    1672             : }
    1673             : 
    1674           0 : IMPL_LINK( SvxNumOptionsTabPage, AllLevelHdl_Impl, NumericField*, pBox )
    1675             : {
    1676           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1677             :     {
    1678           0 :         sal_uInt16 nMask = 1;
    1679           0 :         for(sal_uInt16 e = 0; e < pActNum->GetLevelCount(); e++)
    1680             :         {
    1681           0 :             if(nActNumLvl & nMask)
    1682             :             {
    1683           0 :                 SvxNumberFormat aNumFmt(pActNum->GetLevel(e));
    1684           0 :                 aNumFmt.SetIncludeUpperLevels((sal_uInt8) std::min(pBox->GetValue(), sal_Int64(e + 1)) );
    1685           0 :                 pActNum->SetLevel(e, aNumFmt);
    1686             :             }
    1687           0 :             nMask <<= 1;
    1688             :         }
    1689             :     }
    1690           0 :     SetModified();
    1691           0 :     return 0;
    1692             : }
    1693             : 
    1694           0 : IMPL_LINK( SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, ListBox *, pBox )
    1695             : {
    1696           0 :     OUString sSelectStyle;
    1697           0 :     sal_Bool bShowOrient = sal_False;
    1698           0 :     bool bBmp = false;
    1699           0 :     OUString aEmptyStr;
    1700           0 :     sal_uInt16 nMask = 1;
    1701           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1702             :     {
    1703           0 :         if(nActNumLvl & nMask)
    1704             :         {
    1705           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    1706             :             // PAGEDESC does not exist
    1707           0 :             sal_uInt16 nNumType = (sal_uInt16)(sal_uLong)pBox->GetEntryData(pBox->GetSelectEntryPos());
    1708           0 :             aNumFmt.SetNumberingType((sal_Int16)nNumType);
    1709           0 :             sal_uInt16 nNumberingType = aNumFmt.GetNumberingType();
    1710           0 :             if(SVX_NUM_BITMAP == (nNumberingType&(~LINK_TOKEN)))
    1711             :             {
    1712           0 :                 bBmp |= 0 != aNumFmt.GetBrush();
    1713           0 :                 aNumFmt.SetIncludeUpperLevels( sal_False );
    1714           0 :                 aNumFmt.SetSuffix( aEmptyStr );
    1715           0 :                 aNumFmt.SetPrefix( aEmptyStr );
    1716           0 :                 if(!bBmp)
    1717           0 :                     aNumFmt.SetGraphic(aEmptyStr);
    1718           0 :                 pActNum->SetLevel(i, aNumFmt);
    1719           0 :                 SwitchNumberType(SHOW_BITMAP, bBmp );
    1720           0 :                 bShowOrient = sal_True;
    1721             :             }
    1722           0 :             else if( SVX_NUM_CHAR_SPECIAL == nNumberingType )
    1723             :             {
    1724           0 :                 aNumFmt.SetIncludeUpperLevels( sal_False );
    1725           0 :                 aNumFmt.SetSuffix( aEmptyStr );
    1726           0 :                 aNumFmt.SetPrefix( aEmptyStr );
    1727           0 :                 if( !aNumFmt.GetBulletFont() )
    1728           0 :                     aNumFmt.SetBulletFont(&aActBulletFont);
    1729           0 :                 if( !aNumFmt.GetBulletChar() )
    1730           0 :                     aNumFmt.SetBulletChar( SVX_DEF_BULLET );
    1731           0 :                 pActNum->SetLevel(i, aNumFmt);
    1732           0 :                 SwitchNumberType(SHOW_BULLET);
    1733             :                 // allocation of the drawing pattern is automatic
    1734           0 :                 if(bAutomaticCharStyles)
    1735             :                 {
    1736           0 :                     sSelectStyle = m_sBulletCharFmtName;
    1737             :                 }
    1738             :             }
    1739             :             else
    1740             :             {
    1741           0 :                 aNumFmt.SetPrefix( m_pPrefixED->GetText() );
    1742           0 :                 aNumFmt.SetSuffix( m_pSuffixED->GetText() );
    1743           0 :                 SwitchNumberType(SHOW_NUMBERING);
    1744           0 :                 pActNum->SetLevel(i, aNumFmt);
    1745           0 :                 CheckForStartValue_Impl(nNumberingType);
    1746             : 
    1747             :                 // allocation of the drawing pattern is automatic
    1748           0 :                 if(bAutomaticCharStyles)
    1749             :                 {
    1750           0 :                     sSelectStyle = m_sNumCharFmtName;
    1751             :                 }
    1752           0 :             }
    1753             :         }
    1754           0 :         nMask <<= 1;
    1755             :     }
    1756           0 :     sal_Bool bAllLevelFeature = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
    1757           0 :     if(bShowOrient && bAllLevelFeature)
    1758             :     {
    1759           0 :         m_pOrientFT->Show();
    1760           0 :         m_pOrientLB->Show();
    1761             :     }
    1762             :     else
    1763             :     {
    1764           0 :         m_pOrientFT->Hide();
    1765           0 :         m_pOrientLB->Hide();
    1766             :     }
    1767           0 :     SetModified();
    1768           0 :     if(!sSelectStyle.isEmpty())
    1769             :     {
    1770           0 :         m_pCharFmtLB->SelectEntry(sSelectStyle);
    1771           0 :         CharFmtHdl_Impl(m_pCharFmtLB);
    1772           0 :         bAutomaticCharStyles = sal_True;
    1773             :     }
    1774           0 :     return 0;
    1775             : }
    1776             : 
    1777           0 : void SvxNumOptionsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
    1778             : {
    1779           0 :     sal_Bool bIsNull = m_pStartED->GetValue() == 0;
    1780           0 :     sal_Bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
    1781           0 :                         SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
    1782           0 :                         SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
    1783           0 :     m_pStartED->SetMin(bNoZeroAllowed ? 1 : 0);
    1784           0 :     if(bIsNull && bNoZeroAllowed)
    1785           0 :         m_pStartED->GetModifyHdl().Call(m_pStartED);
    1786           0 : }
    1787             : 
    1788           0 : IMPL_LINK( SvxNumOptionsTabPage, OrientHdl_Impl, ListBox *, pBox )
    1789             : {
    1790           0 :     sal_Int32 nPos = pBox->GetSelectEntryPos();
    1791           0 :     nPos ++; // no VERT_NONE
    1792             : 
    1793           0 :     sal_uInt16 nMask = 1;
    1794           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1795             :     {
    1796           0 :         if(nActNumLvl & nMask)
    1797             :         {
    1798           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    1799           0 :             if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
    1800             :             {
    1801           0 :                 const SvxBrushItem* pBrushItem =  aNumFmt.GetBrush();
    1802           0 :                 const Size& rSize = aNumFmt.GetGraphicSize();
    1803           0 :                 sal_Int16 eOrient = (sal_Int16)nPos;
    1804           0 :                 aNumFmt.SetGraphicBrush( pBrushItem, &rSize, &eOrient );
    1805           0 :                 pActNum->SetLevel(i, aNumFmt);
    1806           0 :             }
    1807             :         }
    1808           0 :         nMask <<= 1;
    1809             :     }
    1810           0 :     SetModified(sal_False);
    1811           0 :     return 0;
    1812             : 
    1813             : }
    1814             : 
    1815           0 : IMPL_LINK( SvxNumOptionsTabPage, SameLevelHdl_Impl, CheckBox *, pBox )
    1816             : {
    1817           0 :     sal_Bool bSet = pBox->IsChecked();
    1818           0 :     pActNum->SetContinuousNumbering(bSet);
    1819           0 :     sal_Bool bRepaint = sal_False;
    1820           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1821             :     {
    1822           0 :         SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    1823           0 :         if(aNumFmt.GetNumberingType() != SVX_NUM_NUMBER_NONE)
    1824             :         {
    1825           0 :             bRepaint = sal_True;
    1826           0 :             break;
    1827             :         }
    1828           0 :     }
    1829           0 :     SetModified(bRepaint);
    1830           0 :     InitControls();
    1831           0 :     return 0;
    1832             : }
    1833             : 
    1834           0 : IMPL_LINK( SvxNumOptionsTabPage, BulColorHdl_Impl, ColorListBox*, pBox )
    1835             : {
    1836           0 :     Color nSetColor = pBox->GetSelectEntryColor();
    1837             : 
    1838           0 :     sal_uInt16 nMask = 1;
    1839           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1840             :     {
    1841           0 :         if(nActNumLvl & nMask)
    1842             :         {
    1843           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    1844           0 :             aNumFmt.SetBulletColor(nSetColor);
    1845           0 :             pActNum->SetLevel(i, aNumFmt);
    1846             :         }
    1847           0 :         nMask <<= 1;
    1848             :     }
    1849           0 :     SetModified();
    1850           0 :     return 0;
    1851             : }
    1852             : 
    1853           0 : IMPL_LINK( SvxNumOptionsTabPage, BulRelSizeHdl_Impl, MetricField *, pField)
    1854             : {
    1855           0 :     sal_uInt16 nRelSize = (sal_uInt16)pField->GetValue();
    1856             : 
    1857           0 :     sal_uInt16 nMask = 1;
    1858           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1859             :     {
    1860           0 :         if(nActNumLvl & nMask)
    1861             :         {
    1862           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    1863           0 :             aNumFmt.SetBulletRelSize(nRelSize);
    1864           0 :             pActNum->SetLevel(i, aNumFmt);
    1865             :         }
    1866           0 :         nMask <<= 1;
    1867             :     }
    1868           0 :     SetModified();
    1869           0 :     return 0;
    1870             : }
    1871             : 
    1872           0 : IMPL_LINK( SvxNumOptionsTabPage, GraphicHdl_Impl, MenuButton *, pButton )
    1873             : {
    1874           0 :     sal_uInt16                  nItemId = pButton->GetCurItemId();
    1875           0 :     OUString                aGrfName;
    1876           0 :     Size                    aSize;
    1877           0 :     sal_Bool                bSucc(sal_False);
    1878           0 :     SvxOpenGraphicDialog    aGrfDlg( CUI_RES(RID_SVXSTR_EDIT_GRAPHIC) );
    1879             : 
    1880           0 :     if(MN_GALLERY_ENTRY <= nItemId )
    1881             :     {
    1882           0 :         sal_uInt16 idx = nItemId - MN_GALLERY_ENTRY;
    1883           0 :         if (idx < aGrfNames.size())
    1884             :         {
    1885           0 :             aGrfName = aGrfNames[idx];
    1886           0 :             Graphic aGraphic;
    1887           0 :             if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, idx, &aGraphic))
    1888             :             {
    1889           0 :                 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
    1890           0 :                 bSucc = sal_True;
    1891           0 :             }
    1892             :         }
    1893             :     }
    1894             :     else
    1895             :     {
    1896           0 :         aGrfDlg.EnableLink( false );
    1897           0 :         aGrfDlg.AsLink( false );
    1898           0 :         if ( !aGrfDlg.Execute() )
    1899             :         {
    1900             :             // memorize selected filter
    1901           0 :             aGrfName = aGrfDlg.GetPath();
    1902             : 
    1903           0 :             Graphic aGraphic;
    1904           0 :             if( !aGrfDlg.GetGraphic(aGraphic) )
    1905             :             {
    1906           0 :                 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
    1907           0 :                 bSucc = sal_True;
    1908           0 :             }
    1909             :         }
    1910             :     }
    1911           0 :     if(bSucc)
    1912             :     {
    1913           0 :         aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)eCoreUnit);
    1914             : 
    1915           0 :         sal_uInt16 nMask = 1;
    1916           0 :         for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    1917             :         {
    1918           0 :             if(nActNumLvl & nMask)
    1919             :             {
    1920           0 :                 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    1921           0 :                 aNumFmt.SetCharFmtName(m_sNumCharFmtName);
    1922           0 :                 aNumFmt.SetGraphic(aGrfName);
    1923             : 
    1924             :                 // set size for a later comparison
    1925           0 :                 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
    1926             :                 // initiate asynchronous loading
    1927           0 :                 sal_Int16 eOrient = aNumFmt.GetVertOrient();
    1928           0 :                 aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
    1929           0 :                 aInitSize[i] = aNumFmt.GetGraphicSize();
    1930             : 
    1931           0 :                 pActNum->SetLevel(i, aNumFmt);
    1932             :             }
    1933           0 :             nMask <<= 1;
    1934             :         }
    1935           0 :         m_pRatioCB->Enable();
    1936           0 :         m_pWidthFT->Enable();
    1937           0 :         m_pHeightFT->Enable();
    1938           0 :         m_pWidthMF->Enable();
    1939           0 :         m_pHeightMF->Enable();
    1940           0 :         SetMetricValue(*m_pWidthMF, aSize.Width(), eCoreUnit);
    1941           0 :         SetMetricValue(*m_pHeightMF, aSize.Height(), eCoreUnit);
    1942           0 :         m_pOrientFT->Enable();
    1943           0 :         m_pOrientLB->Enable();
    1944           0 :         SetModified();
    1945             :         //needed due to asynchronous loading of graphics in the SvxBrushItem
    1946           0 :         aInvalidateTimer.Start();
    1947             :     }
    1948           0 :     return 0;
    1949             : }
    1950             : 
    1951           0 : IMPL_LINK_NOARG(SvxNumOptionsTabPage, PopupActivateHdl_Impl)
    1952             : {
    1953           0 :     if(!bMenuButtonInitialized)
    1954             :     {
    1955           0 :         bMenuButtonInitialized = sal_True;
    1956           0 :         EnterWait();
    1957           0 :         PopupMenu* pMenu = m_pBitmapMB->GetPopupMenu();
    1958           0 :         PopupMenu* pPopup = pMenu->GetPopupMenu(m_nGalleryId);
    1959             : 
    1960           0 :         if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames))
    1961             :         {
    1962           0 :             pPopup->Clear();
    1963           0 :             GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
    1964             : 
    1965           0 :             Graphic aGraphic;
    1966           0 :             OUString sGrfName;
    1967           0 :             std::vector<OUString>::const_iterator it = aGrfNames.begin();
    1968           0 :             for(size_t i = 0; it != aGrfNames.end(); ++it, ++i)
    1969             :             {
    1970           0 :                 sGrfName = *it;
    1971           0 :                 INetURLObject aObj(sGrfName);
    1972           0 :                 if(aObj.GetProtocol() == INET_PROT_FILE)
    1973           0 :                     sGrfName = aObj.PathToFileName();
    1974             : 
    1975           0 :                 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, i, &aGraphic))
    1976             :                 {
    1977           0 :                     Bitmap aBitmap(aGraphic.GetBitmap());
    1978           0 :                     Size aSize(aBitmap.GetSizePixel());
    1979           0 :                     if(aSize.Width() > MAX_BMP_WIDTH ||
    1980           0 :                         aSize.Height() > MAX_BMP_HEIGHT)
    1981             :                     {
    1982           0 :                         sal_Bool bWidth = aSize.Width() > aSize.Height();
    1983             :                         double nScale = bWidth ?
    1984           0 :                                             (double)MAX_BMP_WIDTH / (double)aSize.Width():
    1985           0 :                                                 (double)MAX_BMP_HEIGHT / (double)aSize.Height();
    1986           0 :                         aBitmap.Scale(nScale, nScale);
    1987             :                     }
    1988           0 :                     Image aImage(aBitmap);
    1989             : 
    1990           0 :                     pPopup->InsertItem(MN_GALLERY_ENTRY + i, sGrfName, aImage );
    1991             :                 }
    1992             :                 else
    1993             :                 {
    1994           0 :                     Image aImage;
    1995             :                     pPopup->InsertItem(
    1996           0 :                         MN_GALLERY_ENTRY + i, sGrfName, aImage );
    1997             :                 }
    1998           0 :             }
    1999           0 :             GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
    2000             :         }
    2001           0 :         LeaveWait();
    2002             :     }
    2003           0 :     return 0;
    2004             : }
    2005             : 
    2006           0 : IMPL_LINK_NOARG(SvxNumOptionsTabPage, BulletHdl_Impl)
    2007             : {
    2008           0 :     SvxCharacterMap* pMap = new SvxCharacterMap( this, sal_True );
    2009             : 
    2010           0 :     sal_uInt16 nMask = 1;
    2011           0 :     const Font* pFmtFont = 0;
    2012           0 :     sal_Bool bSameBullet = sal_True;
    2013           0 :     sal_Unicode cBullet = 0;
    2014           0 :     sal_Bool bFirst = sal_True;
    2015           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    2016             :     {
    2017           0 :         if(nActNumLvl & nMask)
    2018             :         {
    2019           0 :             const SvxNumberFormat&  rCurFmt = pActNum->GetLevel(i);
    2020           0 :             if(bFirst)
    2021             :             {
    2022           0 :                  cBullet = rCurFmt.GetBulletChar();
    2023             :             }
    2024           0 :             else if(rCurFmt.GetBulletChar() != cBullet )
    2025             :             {
    2026           0 :                 bSameBullet = sal_False;
    2027           0 :                 break;
    2028             :             }
    2029           0 :             if(!pFmtFont)
    2030           0 :                 pFmtFont = rCurFmt.GetBulletFont();
    2031           0 :             bFirst = sal_False;
    2032             :         }
    2033           0 :         nMask <<= 1;
    2034             : 
    2035             :     }
    2036             : 
    2037           0 :     if(pFmtFont)
    2038           0 :         pMap->SetCharFont(*pFmtFont);
    2039             :     else
    2040           0 :         pMap->SetCharFont(aActBulletFont);
    2041           0 :     if(bSameBullet)
    2042           0 :         pMap->SetChar( cBullet );
    2043           0 :     if(pMap->Execute() == RET_OK)
    2044             :     {
    2045             :         // change Font Numrules
    2046           0 :         aActBulletFont = pMap->GetCharFont();
    2047             : 
    2048           0 :         sal_uInt16 _nMask = 1;
    2049           0 :         for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    2050             :         {
    2051           0 :             if(nActNumLvl & _nMask)
    2052             :             {
    2053           0 :                 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    2054           0 :                 aNumFmt.SetBulletFont(&aActBulletFont); ;
    2055           0 :                 aNumFmt.SetBulletChar( (sal_Unicode) pMap->GetChar() );
    2056           0 :                 pActNum->SetLevel(i, aNumFmt);
    2057             :             }
    2058           0 :             _nMask <<= 1;
    2059             :         }
    2060             : 
    2061           0 :         SetModified();
    2062             :     }
    2063           0 :     delete pMap;
    2064           0 :     return 0;
    2065             : }
    2066             : 
    2067           0 : IMPL_LINK( SvxNumOptionsTabPage, SizeHdl_Impl, MetricField *, pField)
    2068             : {
    2069           0 :     sal_Bool bWidth = pField == m_pWidthMF;
    2070           0 :     bLastWidthModified = bWidth;
    2071           0 :     sal_Bool bRatio = m_pRatioCB->IsChecked();
    2072           0 :     long nWidthVal = static_cast<long>(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_100TH_MM)));
    2073           0 :     long nHeightVal = static_cast<long>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_100TH_MM)));
    2074             :     nWidthVal = OutputDevice::LogicToLogic( nWidthVal ,
    2075           0 :                                                 MAP_100TH_MM, (MapUnit)eCoreUnit );
    2076             :     nHeightVal = OutputDevice::LogicToLogic( nHeightVal,
    2077           0 :                                                 MAP_100TH_MM, (MapUnit)eCoreUnit);
    2078             :     double  fSizeRatio;
    2079             : 
    2080           0 :     sal_Bool bRepaint = sal_False;
    2081           0 :     sal_uInt16 nMask = 1;
    2082           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    2083             :     {
    2084           0 :         if(nActNumLvl & nMask)
    2085             :         {
    2086           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    2087           0 :             if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
    2088             :             {
    2089           0 :                 Size aSize(aNumFmt.GetGraphicSize() );
    2090           0 :                 Size aSaveSize(aSize);
    2091             : 
    2092           0 :                 if (aInitSize[i].Height())
    2093           0 :                     fSizeRatio = (double)aInitSize[i].Width() / (double)aInitSize[i].Height();
    2094             :                 else
    2095           0 :                     fSizeRatio = (double)1;
    2096             : 
    2097           0 :                 if(bWidth)
    2098             :                 {
    2099           0 :                     long nDelta = nWidthVal - aInitSize[i].Width();
    2100           0 :                     aSize.Width() = nWidthVal;
    2101           0 :                     if (bRatio)
    2102             :                     {
    2103           0 :                         aSize.Height() = aInitSize[i].Height() + (long)((double)nDelta / fSizeRatio);
    2104             :                         m_pHeightMF->SetUserValue(m_pHeightMF->Normalize(
    2105           0 :                             OutputDevice::LogicToLogic( aSize.Height(), (MapUnit)eCoreUnit, MAP_100TH_MM )),
    2106           0 :                                 FUNIT_100TH_MM);
    2107             :                     }
    2108             :                 }
    2109             :                 else
    2110             :                 {
    2111           0 :                     long nDelta = nHeightVal - aInitSize[i].Height();
    2112           0 :                     aSize.Height() = nHeightVal;
    2113           0 :                     if (bRatio)
    2114             :                     {
    2115           0 :                         aSize.Width() = aInitSize[i].Width() + (long)((double)nDelta * fSizeRatio);
    2116             :                         m_pWidthMF->SetUserValue(m_pWidthMF->Normalize(
    2117           0 :                             OutputDevice::LogicToLogic( aSize.Width(), (MapUnit)eCoreUnit, MAP_100TH_MM )),
    2118           0 :                                 FUNIT_100TH_MM);
    2119             :                     }
    2120             :                 }
    2121           0 :                 const SvxBrushItem* pBrushItem =  aNumFmt.GetBrush();
    2122           0 :                 sal_Int16 eOrient = aNumFmt.GetVertOrient();
    2123           0 :                 if(aSize != aSaveSize)
    2124           0 :                     bRepaint = sal_True;
    2125           0 :                 aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
    2126           0 :                 pActNum->SetLevel(i, aNumFmt);
    2127           0 :             }
    2128             :         }
    2129           0 :         nMask <<= 1;
    2130             :     }
    2131           0 :     SetModified(bRepaint);
    2132           0 :     return 0;
    2133             : }
    2134             : 
    2135           0 : IMPL_LINK( SvxNumOptionsTabPage, RatioHdl_Impl, CheckBox *, pBox )
    2136             : {
    2137           0 :     if (pBox->IsChecked())
    2138             :     {
    2139           0 :         if (bLastWidthModified)
    2140           0 :             SizeHdl_Impl(m_pWidthMF);
    2141             :         else
    2142           0 :             SizeHdl_Impl(m_pHeightMF);
    2143             :     }
    2144           0 :     return 0;
    2145             : }
    2146             : 
    2147           0 : IMPL_LINK_NOARG(SvxNumOptionsTabPage, CharFmtHdl_Impl)
    2148             : {
    2149           0 :     bAutomaticCharStyles = sal_False;
    2150           0 :     sal_Int32 nEntryPos = m_pCharFmtLB->GetSelectEntryPos();
    2151           0 :     OUString sEntry = m_pCharFmtLB->GetSelectEntry();
    2152           0 :     sal_uInt16 nMask = 1;
    2153           0 :     OUString aEmptyStr;
    2154           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    2155             :     {
    2156           0 :         if(nActNumLvl & nMask)
    2157             :         {
    2158           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    2159           0 :             if( 0 == nEntryPos )
    2160           0 :                 aNumFmt.SetCharFmtName(aEmptyStr);
    2161             :             else
    2162             :             {
    2163           0 :                 if(SVX_NUM_BITMAP != (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
    2164           0 :                     aNumFmt.SetCharFmtName(sEntry);
    2165             :             }
    2166           0 :             pActNum->SetLevel(i, aNumFmt);
    2167             :         }
    2168           0 :         nMask <<= 1;
    2169             :     }
    2170           0 :     SetModified(sal_False);
    2171           0 :     return 0;
    2172             : 
    2173             : };
    2174             : 
    2175           0 : IMPL_LINK( SvxNumOptionsTabPage, EditModifyHdl_Impl, Edit *, pEdit )
    2176             : {
    2177           0 :     sal_Bool bPrefix = pEdit == m_pPrefixED;
    2178           0 :     sal_Bool bSuffix = pEdit == m_pSuffixED;
    2179           0 :     sal_Bool bStart = pEdit == m_pStartED;
    2180           0 :     sal_uInt16 nMask = 1;
    2181           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    2182             :     {
    2183           0 :         if(nActNumLvl & nMask)
    2184             :         {
    2185           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    2186           0 :             if(bPrefix)
    2187           0 :                 aNumFmt.SetPrefix( m_pPrefixED->GetText() );
    2188           0 :             else if(bSuffix)
    2189           0 :                 aNumFmt.SetSuffix( m_pSuffixED->GetText() );
    2190           0 :             else if(bStart)
    2191           0 :                 aNumFmt.SetStart( (sal_uInt16)m_pStartED->GetValue() );
    2192             :             else //align
    2193             :             {
    2194           0 :                 sal_Int32 nPos = m_pAlignLB->GetSelectEntryPos();
    2195           0 :                 SvxAdjust eAdjust = SVX_ADJUST_CENTER;
    2196           0 :                 if(nPos == 0)
    2197           0 :                     eAdjust = SVX_ADJUST_LEFT;
    2198           0 :                 else if(nPos == 2)
    2199           0 :                     eAdjust = SVX_ADJUST_RIGHT;
    2200           0 :                 aNumFmt.SetNumAdjust( eAdjust );
    2201             :             }
    2202           0 :             pActNum->SetLevel(i, aNumFmt);
    2203             :         }
    2204           0 :         nMask <<= 1;
    2205             :     }
    2206           0 :     SetModified();
    2207             : 
    2208           0 :     return 0;
    2209             : }
    2210             : 
    2211           0 : static sal_uInt16 lcl_DrawGraphic(VirtualDevice* pVDev, const SvxNumberFormat &rFmt, sal_uInt16 nXStart,
    2212             :                         sal_uInt16 nYStart, sal_uInt16 nDivision)
    2213             : {
    2214           0 :     const SvxBrushItem* pBrushItem = rFmt.GetBrush();
    2215           0 :     sal_uInt16 nRet = 0;
    2216           0 :     if(pBrushItem)
    2217             :     {
    2218           0 :         const Graphic* pGrf = pBrushItem->GetGraphic();
    2219           0 :         if(pGrf)
    2220             :         {
    2221           0 :             Size aGSize( rFmt.GetGraphicSize() );
    2222           0 :             aGSize.Width() /= nDivision;
    2223           0 :             nRet = (sal_uInt16)aGSize.Width();
    2224           0 :             aGSize.Height() /= nDivision;
    2225             :             pGrf->Draw( pVDev, Point(nXStart,nYStart),
    2226           0 :                     pVDev->PixelToLogic( aGSize ) );
    2227             :         }
    2228             :     }
    2229           0 :     return nRet;
    2230             : 
    2231             : }
    2232             : 
    2233           0 : static sal_uInt16 lcl_DrawBullet(VirtualDevice* pVDev,
    2234             :             const SvxNumberFormat& rFmt, sal_uInt16 nXStart,
    2235             :             sal_uInt16 nYStart, const Size& rSize)
    2236             : {
    2237           0 :     Font aTmpFont(pVDev->GetFont());
    2238             : 
    2239             :     // via Uno it's possible that no font has been set!
    2240           0 :     Font aFont(rFmt.GetBulletFont() ? *rFmt.GetBulletFont() : aTmpFont);
    2241           0 :     Size aTmpSize(rSize);
    2242           0 :     aTmpSize.Width() *= rFmt.GetBulletRelSize();
    2243           0 :     aTmpSize.Width() /= 100 ;
    2244           0 :     aTmpSize.Height() *= rFmt.GetBulletRelSize();
    2245           0 :     aTmpSize.Height() /= 100 ;
    2246             :     // in case of a height of zero it is drawed in original height
    2247           0 :     if(!aTmpSize.Height())
    2248           0 :         aTmpSize.Height() = 1;
    2249           0 :     aFont.SetSize(aTmpSize);
    2250           0 :     aFont.SetTransparent(true);
    2251           0 :     Color aBulletColor = rFmt.GetBulletColor();
    2252           0 :     if(aBulletColor.GetColor() == COL_AUTO)
    2253           0 :         aBulletColor = Color(pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK);
    2254           0 :     else if(aBulletColor == pVDev->GetFillColor())
    2255           0 :         aBulletColor.Invert();
    2256           0 :     aFont.SetColor(aBulletColor);
    2257           0 :     pVDev->SetFont( aFont );
    2258           0 :     OUString aText(rFmt.GetBulletChar());
    2259           0 :     long nY = nYStart;
    2260           0 :     nY -= ((aTmpSize.Height() - rSize.Height())/ 2);
    2261           0 :     pVDev->DrawText( Point(nXStart, nY), aText );
    2262           0 :     sal_uInt16 nRet = (sal_uInt16)pVDev->GetTextWidth(aText);
    2263             : 
    2264           0 :     pVDev->SetFont(aTmpFont);
    2265           0 :     return nRet;
    2266             : }
    2267             : 
    2268           0 : SvxNumberingPreview::SvxNumberingPreview(Window* pParent, WinBits nWinBits)
    2269             :     : Window(pParent, nWinBits)
    2270             :     , pActNum(0)
    2271             :     , nPageWidth(0)
    2272             :     , pOutlineNames(0)
    2273             :     , bPosition(false)
    2274           0 :     , nActLevel(SAL_MAX_UINT16)
    2275             : {
    2276           0 :     SetBorderStyle(WINDOW_BORDER_MONO);
    2277           0 : }
    2278             : 
    2279           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxNumberingPreview(Window *pParent, VclBuilder::stringmap &)
    2280             : {
    2281           0 :     return new SvxNumberingPreview(pParent, WB_BORDER);
    2282             : }
    2283             : 
    2284             : // paint preview of numeration
    2285           0 : void    SvxNumberingPreview::Paint( const Rectangle& /*rRect*/ )
    2286             : {
    2287           0 :     Size aSize(PixelToLogic(GetOutputSizePixel()));
    2288           0 :     Rectangle aRect(Point(0,0), aSize);
    2289             : 
    2290           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    2291           0 :     const Color aBackColor = rStyleSettings.GetFieldColor();
    2292           0 :     const Color aTextColor = rStyleSettings.GetFieldTextColor();
    2293             : 
    2294           0 :     VirtualDevice* pVDev = new VirtualDevice(*this);
    2295           0 :     pVDev->EnableRTL( IsRTLEnabled() );
    2296           0 :     pVDev->SetMapMode(GetMapMode());
    2297           0 :     pVDev->SetOutputSize( aSize );
    2298             : 
    2299           0 :     Color aLineColor(COL_LIGHTGRAY);
    2300           0 :     if(aLineColor == aBackColor)
    2301           0 :         aLineColor.Invert();
    2302           0 :     pVDev->SetLineColor(aLineColor);
    2303           0 :     pVDev->SetFillColor( aBackColor );
    2304           0 :     pVDev->DrawRect(aRect);
    2305             : 
    2306           0 :     if(pActNum)
    2307             :     {
    2308             :         sal_uInt16 nWidthRelation;
    2309           0 :         if(nPageWidth)
    2310             :         {
    2311           0 :             nWidthRelation = sal_uInt16 (nPageWidth / aSize.Width());
    2312           0 :             if(bPosition)
    2313           0 :                 nWidthRelation = nWidthRelation * 2 / 3;
    2314             :             else
    2315           0 :                 nWidthRelation = nWidthRelation / 4;
    2316             :         }
    2317             :         else
    2318           0 :             nWidthRelation = 30; // chapter dialog
    2319             : 
    2320             :         // height per level
    2321           0 :         sal_uInt16 nXStep = sal::static_int_cast< sal_uInt16 >(aSize.Width() / (3 * pActNum->GetLevelCount()));
    2322           0 :         if(pActNum->GetLevelCount() < 10)
    2323           0 :             nXStep /= 2;
    2324           0 :         sal_uInt16 nYStart = 4;
    2325             :         // the whole height mustn't be used for a single level
    2326           0 :         sal_uInt16 nYStep = sal::static_int_cast< sal_uInt16 >((aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5));
    2327           0 :         aStdFont = OutputDevice::GetDefaultFont(
    2328           0 :                 DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE);
    2329           0 :         aStdFont.SetColor(aTextColor);
    2330           0 :         aStdFont.SetFillColor(aBackColor);
    2331             : 
    2332           0 :         sal_uInt16 nFontHeight = nYStep * 6 / 10;
    2333           0 :         if(bPosition)
    2334           0 :             nFontHeight = nYStep * 15 / 10;
    2335           0 :         aStdFont.SetSize(Size( 0, nFontHeight ));
    2336             : 
    2337           0 :         SvxNodeNum aNum( (sal_uInt8)0 );
    2338           0 :         sal_uInt16 nPreNum = pActNum->GetLevel(0).GetStart();
    2339             : 
    2340           0 :         if(bPosition)
    2341             :         {
    2342           0 :             sal_uInt16 nLineHeight = nFontHeight * 8 / 7;
    2343           0 :             sal_uInt8 nStart = 0;
    2344           0 :             while( !(nActLevel & (1<<nStart)) )
    2345             :             {
    2346           0 :                 nStart++;
    2347             :             }
    2348           0 :             if(nStart)
    2349           0 :                 nStart--;
    2350           0 :             sal_uInt8 nEnd = std::min( (sal_uInt8)(nStart + 3), (sal_uInt8)pActNum->GetLevelCount() );
    2351           0 :             for( sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel )
    2352             :             {
    2353           0 :                 const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
    2354           0 :                 aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
    2355             : 
    2356           0 :                 sal_uInt16 nXStart( 0 );
    2357           0 :                 short nTextOffset( 0 );
    2358           0 :                 sal_uInt16 nNumberXPos( 0 );
    2359           0 :                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2360             :                 {
    2361           0 :                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
    2362           0 :                     nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
    2363           0 :                     nNumberXPos = nXStart;
    2364           0 :                     sal_uInt16 nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
    2365             : 
    2366           0 :                     if(nFirstLineOffset <= nNumberXPos)
    2367           0 :                         nNumberXPos = nNumberXPos - nFirstLineOffset;
    2368             :                     else
    2369           0 :                         nNumberXPos = 0;
    2370             :                     // in draw this is valid
    2371           0 :                     if(nTextOffset < 0)
    2372           0 :                         nNumberXPos = nNumberXPos + nTextOffset;
    2373             :                 }
    2374           0 :                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    2375             :                 {
    2376           0 :                     const long nTmpNumberXPos( ( rFmt.GetIndentAt() +
    2377           0 :                                                  rFmt.GetFirstLineIndent() ) /
    2378           0 :                                                nWidthRelation );
    2379           0 :                     if ( nTmpNumberXPos < 0 )
    2380             :                     {
    2381           0 :                         nNumberXPos = 0;
    2382             :                     }
    2383             :                     else
    2384             :                     {
    2385           0 :                         nNumberXPos = static_cast<sal_uInt16>( nTmpNumberXPos );
    2386             :                     }
    2387             :                 }
    2388             : 
    2389           0 :                 sal_uInt16 nBulletWidth = 0;
    2390           0 :                 if( SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN)))
    2391             :                 {
    2392           0 :                     nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(pVDev, rFmt,
    2393             :                                         nNumberXPos,
    2394           0 :                                             nYStart, nWidthRelation) : 0;
    2395             :                 }
    2396           0 :                 else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
    2397             :                 {
    2398           0 :                     nBulletWidth =  rFmt.IsShowSymbol() ?
    2399           0 :                      lcl_DrawBullet(pVDev, rFmt, nNumberXPos, nYStart, aStdFont.GetSize()) : 0;
    2400             :                 }
    2401             :                 else
    2402             :                 {
    2403           0 :                     pVDev->SetFont(aStdFont);
    2404           0 :                     aNum.SetLevel( nLevel );
    2405           0 :                     if(pActNum->IsContinuousNumbering())
    2406           0 :                         aNum.GetLevelVal()[nLevel] = nPreNum;
    2407           0 :                     OUString aText(pActNum->MakeNumString( aNum ));
    2408           0 :                     Font aSaveFont = pVDev->GetFont();
    2409           0 :                     Font aColorFont(aSaveFont);
    2410           0 :                     Color aTmpBulletColor = rFmt.GetBulletColor();
    2411           0 :                     if(aTmpBulletColor.GetColor() == COL_AUTO)
    2412           0 :                         aTmpBulletColor = Color(aBackColor.IsDark() ? COL_WHITE : COL_BLACK);
    2413           0 :                     else if(aTmpBulletColor == aBackColor)
    2414           0 :                         aTmpBulletColor.Invert();
    2415           0 :                     aColorFont.SetColor(aTmpBulletColor);
    2416           0 :                     pVDev->SetFont(aColorFont);
    2417           0 :                     pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
    2418           0 :                     pVDev->SetFont(aSaveFont);
    2419           0 :                     nBulletWidth = (sal_uInt16)pVDev->GetTextWidth(aText);
    2420           0 :                     nPreNum++;
    2421             :                 }
    2422           0 :                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
    2423           0 :                      rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
    2424             :                 {
    2425           0 :                     pVDev->SetFont(aStdFont);
    2426           0 :                     OUString aText(' ');
    2427           0 :                     pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
    2428           0 :                     nBulletWidth = nBulletWidth + (sal_uInt16)pVDev->GetTextWidth(aText);
    2429             :                 }
    2430             : 
    2431           0 :                 sal_uInt16 nTextXPos( 0 );
    2432           0 :                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2433             :                 {
    2434           0 :                     nTextXPos = nXStart;
    2435           0 :                     if(nTextOffset < 0)
    2436           0 :                          nTextXPos = nTextXPos + nTextOffset;
    2437           0 :                     if(nNumberXPos + nBulletWidth + nTextOffset > nTextXPos )
    2438           0 :                         nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
    2439             :                 }
    2440           0 :                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    2441             :                 {
    2442           0 :                     switch ( rFmt.GetLabelFollowedBy() )
    2443             :                     {
    2444             :                         case SvxNumberFormat::LISTTAB:
    2445             :                         {
    2446             :                             nTextXPos = static_cast<sal_uInt16>(
    2447           0 :                                             rFmt.GetListtabPos() / nWidthRelation );
    2448           0 :                             if ( nTextXPos < nNumberXPos + nBulletWidth )
    2449             :                             {
    2450           0 :                                 nTextXPos = nNumberXPos + nBulletWidth;
    2451             :                             }
    2452             :                         }
    2453           0 :                         break;
    2454             :                         case SvxNumberFormat::SPACE:
    2455             :                         case SvxNumberFormat::NOTHING:
    2456             :                         {
    2457           0 :                             nTextXPos = nNumberXPos + nBulletWidth;
    2458             :                         }
    2459           0 :                         break;
    2460             :                     }
    2461             : 
    2462           0 :                     nXStart = static_cast<sal_uInt16>( rFmt.GetIndentAt() / nWidthRelation );
    2463             :                 }
    2464             : 
    2465           0 :                 Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
    2466           0 :                 pVDev->SetFillColor( aBackColor );
    2467           0 :                 pVDev->DrawRect( aRect1 );
    2468             : 
    2469           0 :                 Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
    2470           0 :                 pVDev->DrawRect( aRect2 );
    2471           0 :                 nYStart += 2 * nLineHeight;
    2472             :             }
    2473             :         }
    2474             :         else
    2475             :         {
    2476             :             //#i5153# painting gray or black rectangles as 'normal' numbering text
    2477           0 :             OUString sMsg( "Preview" );
    2478           0 :             long nWidth = pVDev->GetTextWidth(sMsg);
    2479           0 :             long nTextHeight = pVDev->GetTextHeight();
    2480           0 :             long nRectHeight = nTextHeight * 2 / 3;
    2481           0 :             long nTopOffset = nTextHeight - nRectHeight;
    2482           0 :             Color aBlackColor(COL_BLACK);
    2483           0 :             if(aBlackColor == aBackColor)
    2484           0 :                 aBlackColor.Invert();
    2485             : 
    2486           0 :             for( sal_uInt8 nLevel = 0; nLevel < pActNum->GetLevelCount();
    2487             :                             ++nLevel, nYStart = nYStart + nYStep )
    2488             :             {
    2489           0 :                 const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
    2490           0 :                 aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
    2491           0 :                 sal_uInt16 nXStart( 0 );
    2492           0 :                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2493             :                 {
    2494           0 :                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
    2495             :                 }
    2496           0 :                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    2497             :                 {
    2498           0 :                     const long nTmpXStart( ( rFmt.GetIndentAt() +
    2499           0 :                                              rFmt.GetFirstLineIndent() ) /
    2500           0 :                                            nWidthRelation );
    2501           0 :                     if ( nTmpXStart < 0 )
    2502             :                     {
    2503           0 :                         nXStart = 0;
    2504             :                     }
    2505             :                     else
    2506             :                     {
    2507           0 :                         nXStart = static_cast<sal_uInt16>(nTmpXStart);
    2508             :                     }
    2509             :                 }
    2510           0 :                 nXStart /= 2;
    2511           0 :                 nXStart += 2;
    2512           0 :                 sal_uInt16 nTextOffset = 2 * nXStep;
    2513           0 :                 if( SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN)) )
    2514             :                 {
    2515           0 :                     if(rFmt.IsShowSymbol())
    2516             :                     {
    2517           0 :                         nTextOffset = lcl_DrawGraphic(pVDev, rFmt, nXStart, nYStart, nWidthRelation);
    2518           0 :                         nTextOffset = nTextOffset + nXStep;
    2519             :                     }
    2520             :                 }
    2521           0 :                 else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
    2522             :                 {
    2523           0 :                     if(rFmt.IsShowSymbol())
    2524             :                     {
    2525           0 :                         nTextOffset =  lcl_DrawBullet(pVDev, rFmt, nXStart, nYStart, aStdFont.GetSize());
    2526           0 :                         nTextOffset = nTextOffset + nXStep;
    2527             :                     }
    2528             :                 }
    2529             :                 else
    2530             :                 {
    2531           0 :                     Font aColorFont(aStdFont);
    2532           0 :                     Color aTmpBulletColor = rFmt.GetBulletColor();
    2533           0 :                     if(aTmpBulletColor.GetColor() == COL_AUTO)
    2534           0 :                         aTmpBulletColor = Color(aBackColor.IsDark() ? COL_WHITE : COL_BLACK);
    2535           0 :                     else if(aTmpBulletColor == aBackColor)
    2536           0 :                         aTmpBulletColor.Invert();
    2537           0 :                     aColorFont.SetColor(aTmpBulletColor);
    2538           0 :                     pVDev->SetFont(aColorFont);
    2539           0 :                     aNum.SetLevel( nLevel );
    2540           0 :                     if(pActNum->IsContinuousNumbering())
    2541           0 :                         aNum.GetLevelVal()[nLevel] = nPreNum;
    2542           0 :                     OUString aText(pActNum->MakeNumString( aNum ));
    2543           0 :                     pVDev->DrawText( Point(nXStart, nYStart), aText );
    2544           0 :                     pVDev->SetFont(aStdFont);
    2545           0 :                     nTextOffset = (sal_uInt16)pVDev->GetTextWidth(aText);
    2546           0 :                     nTextOffset = nTextOffset + nXStep;
    2547           0 :                     nPreNum++;
    2548             :                 }
    2549           0 :                 if(pOutlineNames)
    2550             :                 {
    2551             :                     //#i5153# outline numberings still use the style names as text
    2552           0 :                     pVDev->SetFont(aStdFont);
    2553           0 :                     sMsg = pOutlineNames[nLevel];
    2554           0 :                     pVDev->DrawText( Point(nXStart + nTextOffset, nYStart), sMsg );
    2555             :                 }
    2556             :                 else
    2557             :                 {
    2558             :                     //#i5153# the selected rectangle(s) should be black
    2559           0 :                     if( 0 != (nActLevel & (1<<nLevel)))
    2560             :                     {
    2561           0 :                         pVDev->SetFillColor( aBlackColor );
    2562           0 :                         pVDev->SetLineColor( aBlackColor );
    2563             :                     }
    2564             :                     else
    2565             :                     {
    2566             :                         //#i5153# unselected levels are gray
    2567           0 :                         pVDev->SetFillColor( aLineColor );
    2568           0 :                         pVDev->SetLineColor( aLineColor );
    2569             :                     }
    2570           0 :                     Rectangle aRect1(Point(nXStart + nTextOffset, nYStart + nTopOffset), Size(nWidth, nRectHeight));
    2571           0 :                     pVDev->DrawRect(aRect1);
    2572             :                 }
    2573           0 :             }
    2574             :         }
    2575             :     }
    2576             :     DrawOutDev( Point(0,0), aSize,
    2577             :                 Point(0,0), aSize,
    2578           0 :                         *pVDev );
    2579           0 :     delete pVDev;
    2580             : 
    2581           0 : }
    2582             : 
    2583             : //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate
    2584             : //dialog to this one, except with a different preview window impl.
    2585             : //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
    2586             : //merged
    2587           0 : SvxNumPositionTabPage::SvxNumPositionTabPage(Window* pParent,
    2588             :                                const SfxItemSet& rSet)
    2589             :     : SfxTabPage(pParent, "NumberingPositionPage", "cui/ui/numberingpositionpage.ui", rSet)
    2590             :     , pActNum(0)
    2591             :     , pSaveNum(0)
    2592             :     , nActNumLvl(SAL_MAX_UINT16)
    2593             :     , nNumItemId(SID_ATTR_NUMBERING_RULE)
    2594             :     , bModified(false)
    2595             :     , bPreset(false)
    2596             :     , bInInintControl(false)
    2597           0 :     , bLabelAlignmentPosAndSpaceModeActive(false)
    2598             : {
    2599           0 :     SetExchangeSupport();
    2600             : 
    2601           0 :     get(m_pLevelLB, "levellb");
    2602           0 :     get(m_pDistBorderFT, "indent");
    2603           0 :     get(m_pDistBorderMF, "indentmf");
    2604           0 :     get(m_pRelativeCB, "relative");
    2605           0 :     get(m_pIndentFT, "numberingwidth");
    2606           0 :     get(m_pIndentMF, "numberingwidthmf");
    2607           0 :     get(m_pDistNumFT, "numdist");
    2608           0 :     get(m_pDistNumMF, "numdistmf");
    2609           0 :     get(m_pAlignFT, "numalign");
    2610           0 :     get(m_pAlignLB, "numalignlb");
    2611             : 
    2612           0 :     get(m_pLabelFollowedByFT, "numfollowedby");
    2613           0 :     get(m_pLabelFollowedByLB, "numfollowedbylb");
    2614           0 :     get(m_pListtabFT, "at");
    2615           0 :     get(m_pListtabMF, "atmf");
    2616           0 :     get(m_pAlign2FT, "num2align");
    2617           0 :     get(m_pAlign2LB, "num2alignlb");
    2618           0 :     get(m_pAlignedAtFT, "alignedat");
    2619           0 :     get(m_pAlignedAtMF, "alignedatmf");
    2620           0 :     get(m_pIndentAtFT, "indentat");
    2621           0 :     get(m_pIndentAtMF, "indentatmf");
    2622             : 
    2623           0 :     get(m_pStandardPB, "standard");
    2624           0 :     get(m_pPreviewWIN, "preview");
    2625             : 
    2626           0 :     m_pPreviewWIN->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
    2627             : 
    2628           0 :     m_pRelativeCB->Check();
    2629           0 :     m_pAlignLB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
    2630           0 :     m_pAlign2LB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
    2631           0 :     for ( sal_Int32 i = 0; i < m_pAlignLB->GetEntryCount(); ++i )
    2632             :     {
    2633           0 :         m_pAlign2LB->InsertEntry( m_pAlignLB->GetEntry( i ) );
    2634             :     }
    2635           0 :     m_pAlign2LB->SetDropDownLineCount( m_pAlign2LB->GetEntryCount() );
    2636             : 
    2637           0 :     Link aLk = LINK(this, SvxNumPositionTabPage, DistanceHdl_Impl);
    2638             : 
    2639           0 :     m_pDistBorderMF->SetUpHdl(aLk);
    2640           0 :     m_pDistBorderMF->SetDownHdl(aLk);
    2641           0 :     m_pDistBorderMF->SetLoseFocusHdl(aLk);
    2642             : 
    2643           0 :     m_pDistNumMF->SetUpHdl(aLk);
    2644           0 :     m_pDistNumMF->SetDownHdl(aLk);
    2645           0 :     m_pDistNumMF->SetLoseFocusHdl(aLk);
    2646             : 
    2647           0 :     m_pIndentMF->SetUpHdl(aLk);
    2648           0 :     m_pIndentMF->SetDownHdl(aLk);
    2649           0 :     m_pIndentMF->SetLoseFocusHdl(aLk);
    2650             : 
    2651           0 :     m_pLabelFollowedByLB->SetDropDownLineCount( m_pLabelFollowedByLB->GetEntryCount() );
    2652           0 :     m_pLabelFollowedByLB->SetSelectHdl( LINK(this, SvxNumPositionTabPage, LabelFollowedByHdl_Impl) );
    2653             : 
    2654           0 :     aLk = LINK(this, SvxNumPositionTabPage, ListtabPosHdl_Impl);
    2655           0 :     m_pListtabMF->SetUpHdl(aLk);
    2656           0 :     m_pListtabMF->SetDownHdl(aLk);
    2657           0 :     m_pListtabMF->SetLoseFocusHdl(aLk);
    2658             : 
    2659           0 :     aLk = LINK(this, SvxNumPositionTabPage, AlignAtHdl_Impl);
    2660           0 :     m_pAlignedAtMF->SetUpHdl(aLk);
    2661           0 :     m_pAlignedAtMF->SetDownHdl(aLk);
    2662           0 :     m_pAlignedAtMF->SetLoseFocusHdl(aLk);
    2663             : 
    2664           0 :     aLk = LINK(this, SvxNumPositionTabPage, IndentAtHdl_Impl);
    2665           0 :     m_pIndentAtMF->SetUpHdl(aLk);
    2666           0 :     m_pIndentAtMF->SetDownHdl(aLk);
    2667           0 :     m_pIndentAtMF->SetLoseFocusHdl(aLk);
    2668             : 
    2669           0 :     m_pLevelLB->EnableMultiSelection(true);
    2670           0 :     m_pLevelLB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, LevelHdl_Impl));
    2671           0 :     m_pRelativeCB->SetClickHdl(LINK(this, SvxNumPositionTabPage, RelativeHdl_Impl));
    2672           0 :     m_pStandardPB->SetClickHdl(LINK(this, SvxNumPositionTabPage, StandardHdl_Impl));
    2673             : 
    2674             : 
    2675           0 :     m_pRelativeCB->Check(bLastRelative);
    2676           0 :     m_pPreviewWIN->SetPositionMode();
    2677           0 :     eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
    2678           0 : }
    2679             : 
    2680           0 : SvxNumPositionTabPage::~SvxNumPositionTabPage()
    2681             : {
    2682           0 :     delete pActNum;
    2683           0 :     delete pSaveNum;
    2684           0 : }
    2685             : /*-------------------------------------------------------*/
    2686             : 
    2687             : #if OSL_DEBUG_LEVEL > 1
    2688             : void lcl_PrintDebugOutput(FixedText& rFixed, const SvxNumberFormat& rNumFmt)
    2689             : {
    2690             : #define TWIP_TO_MM100(TWIP)     ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
    2691             : 
    2692             :     OUString const sHash( " # " );
    2693             :     if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2694             :     {
    2695             :         OUString sDebugText( OUString::number( TWIP_TO_MM100(rNumFmt.GetAbsLSpace() ) ) );
    2696             :         sDebugText += sHash;
    2697             :         sDebugText += OUString::number( TWIP_TO_MM100(rNumFmt.GetCharTextDistance() ) );
    2698             :         sDebugText += sHash;
    2699             :         sDebugText += OUString::number( TWIP_TO_MM100(rNumFmt.GetFirstLineOffset() ) );
    2700             :         rFixed.SetText(sDebugText);
    2701             :     }
    2702             :     else if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    2703             :     {
    2704             :         OUString sDebugText( OUString::number( TWIP_TO_MM100(rNumFmt.GetListtabPos() ) ) );
    2705             :         sDebugText += sHash;
    2706             :         sDebugText += OUString::number( TWIP_TO_MM100(rNumFmt.GetFirstLineIndent() ) );
    2707             :         sDebugText += sHash;
    2708             :         sDebugText += OUString::number( TWIP_TO_MM100(rNumFmt.GetIndentAt() ) );
    2709             :         rFixed.SetText(sDebugText);
    2710             :     }
    2711             : 
    2712             : }
    2713             : #endif
    2714             : 
    2715           0 : void SvxNumPositionTabPage::InitControls()
    2716             : {
    2717           0 :     bInInintControl = sal_True;
    2718           0 :     const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
    2719           0 :                      m_pRelativeCB->IsEnabled() && m_pRelativeCB->IsChecked();
    2720           0 :     const bool bSingleSelection = m_pLevelLB->GetSelectEntryCount() == 1 &&
    2721           0 :                             SAL_MAX_UINT16 != nActNumLvl;
    2722             : 
    2723           0 :     m_pDistBorderMF->Enable( !bLabelAlignmentPosAndSpaceModeActive &&
    2724           0 :                           ( bSingleSelection || bRelative ) );
    2725           0 :     m_pDistBorderFT->Enable( !bLabelAlignmentPosAndSpaceModeActive &&
    2726           0 :                           ( bSingleSelection || bRelative ) );
    2727             : 
    2728           0 :     bool bSetDistEmpty = false;
    2729           0 :     bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
    2730           0 :     bool bSameDist      = !bLabelAlignmentPosAndSpaceModeActive;
    2731           0 :     bool bSameIndent    = !bLabelAlignmentPosAndSpaceModeActive;
    2732           0 :     bool bSameAdjust    = true;
    2733             : 
    2734           0 :     bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
    2735           0 :     bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
    2736           0 :     bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
    2737           0 :     bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
    2738             : 
    2739             :     const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
    2740           0 :     sal_uInt16 nMask = 1;
    2741           0 :     sal_uInt16 nLvl = SAL_MAX_UINT16;
    2742           0 :     long nFirstBorderTextRelative = -1;
    2743           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    2744             :     {
    2745           0 :         aNumFmtArr[i] = &pActNum->GetLevel(i);
    2746           0 :         if(nActNumLvl & nMask)
    2747             :         {
    2748           0 :             if(SAL_MAX_UINT16 == nLvl)
    2749           0 :                 nLvl = i;
    2750             : 
    2751           0 :             if( i > nLvl)
    2752             :             {
    2753           0 :                 bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
    2754           0 :                 if ( !bLabelAlignmentPosAndSpaceModeActive )
    2755             :                 {
    2756           0 :                     if(bRelative)
    2757             :                     {
    2758           0 :                         if(nFirstBorderTextRelative == -1)
    2759             :                             nFirstBorderTextRelative =
    2760           0 :                             (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
    2761           0 :                             aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
    2762             :                         else
    2763           0 :                             bSameDistBorderNum &= nFirstBorderTextRelative ==
    2764           0 :                             (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
    2765           0 :                             aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
    2766             :                     }
    2767             :                     else
    2768             :                         bSameDistBorderNum &=
    2769           0 :                         aNumFmtArr[i]->GetAbsLSpace() - aNumFmtArr[i]->GetFirstLineOffset() ==
    2770           0 :                         aNumFmtArr[i - 1]->GetAbsLSpace() - aNumFmtArr[i - 1]->GetFirstLineOffset();
    2771             : 
    2772           0 :                     bSameDist       &= aNumFmtArr[i]->GetCharTextDistance() == aNumFmtArr[nLvl]->GetCharTextDistance();
    2773           0 :                     bSameIndent     &= aNumFmtArr[i]->GetFirstLineOffset() == aNumFmtArr[nLvl]->GetFirstLineOffset();
    2774             :                 }
    2775             :                 else
    2776             :                 {
    2777             :                     bSameLabelFollowedBy &=
    2778           0 :                         aNumFmtArr[i]->GetLabelFollowedBy() == aNumFmtArr[nLvl]->GetLabelFollowedBy();
    2779             :                     bSameListtab &=
    2780           0 :                         aNumFmtArr[i]->GetListtabPos() == aNumFmtArr[nLvl]->GetListtabPos();
    2781             :                     bSameAlignAt &=
    2782           0 :                         ( ( aNumFmtArr[i]->GetIndentAt() + aNumFmtArr[i]->GetFirstLineIndent() )
    2783           0 :                             == ( aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent() ) );
    2784             :                     bSameIndentAt &=
    2785           0 :                         aNumFmtArr[i]->GetIndentAt() == aNumFmtArr[nLvl]->GetIndentAt();
    2786             :                 }
    2787             :             }
    2788             :         }
    2789           0 :         nMask <<= 1;
    2790             : 
    2791             :     }
    2792           0 :     if (SVX_MAX_NUM <= nLvl)
    2793             :     {
    2794             :         OSL_ENSURE(false, "cannot happen.");
    2795           0 :         return;
    2796             :     }
    2797             : 
    2798           0 :     if(bSameDistBorderNum)
    2799             :     {
    2800             :         long nDistBorderNum;
    2801           0 :         if(bRelative)
    2802             :         {
    2803           0 :             nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
    2804           0 :             if(nLvl)
    2805           0 :                 nDistBorderNum -= (long)aNumFmtArr[nLvl - 1]->GetAbsLSpace()+ aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
    2806             :         }
    2807             :         else
    2808             :         {
    2809           0 :             nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
    2810             :         }
    2811           0 :         SetMetricValue(*m_pDistBorderMF, nDistBorderNum, eCoreUnit);
    2812             :     }
    2813             :     else
    2814           0 :         bSetDistEmpty = true;
    2815             : 
    2816           0 :     const OUString aEmptyStr;
    2817           0 :     if(bSameDist)
    2818           0 :         SetMetricValue(*m_pDistNumMF, aNumFmtArr[nLvl]->GetCharTextDistance(), eCoreUnit);
    2819             :     else
    2820           0 :         m_pDistNumMF->SetText(aEmptyStr);
    2821           0 :     if(bSameIndent)
    2822           0 :         SetMetricValue(*m_pIndentMF, - aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit);
    2823             :     else
    2824           0 :         m_pIndentMF->SetText(aEmptyStr);
    2825             : 
    2826           0 :     if(bSameAdjust)
    2827             :     {
    2828           0 :         sal_Int32 nPos = 1; // centered
    2829           0 :         if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
    2830           0 :             nPos = 0;
    2831           0 :         else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
    2832           0 :             nPos = 2;
    2833           0 :         m_pAlignLB->SelectEntryPos(nPos);
    2834           0 :         m_pAlign2LB->SelectEntryPos( nPos );
    2835             :     }
    2836             :     else
    2837             :     {
    2838           0 :         m_pAlignLB->SetNoSelection();
    2839           0 :         m_pAlign2LB->SetNoSelection();
    2840             :     }
    2841             : 
    2842           0 :     if ( bSameLabelFollowedBy )
    2843             :     {
    2844           0 :         sal_Int32 nPos = 0; // LISTTAB
    2845           0 :         if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
    2846             :         {
    2847           0 :             nPos = 1;
    2848             :         }
    2849           0 :         else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
    2850             :         {
    2851           0 :             nPos = 2;
    2852             :         }
    2853           0 :         m_pLabelFollowedByLB->SelectEntryPos( nPos );
    2854             :     }
    2855             :     else
    2856             :     {
    2857           0 :         m_pLabelFollowedByLB->SetNoSelection();
    2858             :     }
    2859             : 
    2860           0 :     if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
    2861             :     {
    2862           0 :         m_pListtabFT->Enable( true );
    2863           0 :         m_pListtabMF->Enable( true );
    2864           0 :         if ( bSameListtab )
    2865             :         {
    2866           0 :             SetMetricValue(*m_pListtabMF, aNumFmtArr[nLvl]->GetListtabPos(), eCoreUnit);
    2867             :         }
    2868             :         else
    2869             :         {
    2870           0 :             m_pListtabMF->SetText(aEmptyStr);
    2871             :         }
    2872             :     }
    2873             :     else
    2874             :     {
    2875           0 :         m_pListtabFT->Enable( false );
    2876           0 :         m_pListtabMF->Enable( false );
    2877           0 :         m_pListtabMF->SetText(aEmptyStr);
    2878             :     }
    2879             : 
    2880           0 :     if ( bSameAlignAt )
    2881             :     {
    2882             :         SetMetricValue(*m_pAlignedAtMF,
    2883           0 :                         aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent(),
    2884           0 :                         eCoreUnit);
    2885             :     }
    2886             :     else
    2887             :     {
    2888           0 :         m_pAlignedAtMF->SetText(aEmptyStr);
    2889             :     }
    2890             : 
    2891           0 :     if ( bSameIndentAt )
    2892             :     {
    2893           0 :         SetMetricValue(*m_pIndentAtMF, aNumFmtArr[nLvl]->GetIndentAt(), eCoreUnit);
    2894             :     }
    2895             :     else
    2896             :     {
    2897           0 :         m_pIndentAtMF->SetText(aEmptyStr);
    2898             :     }
    2899             : 
    2900           0 :     if ( bSetDistEmpty )
    2901           0 :         m_pDistBorderMF->SetText(aEmptyStr);
    2902             : 
    2903           0 :     bInInintControl = sal_False;
    2904             : }
    2905             : 
    2906           0 : void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet)
    2907             : {
    2908             :     const SfxPoolItem* pItem;
    2909           0 :     sal_uInt16 nTmpNumLvl = SAL_MAX_UINT16;
    2910           0 :     const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
    2911           0 :     if(pExampleSet)
    2912             :     {
    2913           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
    2914           0 :             bPreset = ((const SfxBoolItem*)pItem)->GetValue();
    2915           0 :         if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
    2916           0 :             nTmpNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
    2917             :     }
    2918           0 :     if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, false, &pItem))
    2919             :     {
    2920           0 :         delete pSaveNum;
    2921           0 :         pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
    2922             :     }
    2923           0 :     bModified = (!pActNum->Get( 0 ) || bPreset);
    2924           0 :     if(*pSaveNum != *pActNum ||
    2925           0 :         nActNumLvl != nTmpNumLvl )
    2926             :     {
    2927           0 :         *pActNum = *pSaveNum;
    2928           0 :         nActNumLvl = nTmpNumLvl;
    2929           0 :         sal_uInt16 nMask = 1;
    2930           0 :         m_pLevelLB->SetUpdateMode(false);
    2931           0 :         m_pLevelLB->SetNoSelection();
    2932           0 :         m_pLevelLB->SelectEntryPos( pActNum->GetLevelCount(), nActNumLvl == SAL_MAX_UINT16);
    2933           0 :         if(nActNumLvl != SAL_MAX_UINT16)
    2934           0 :             for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    2935             :             {
    2936           0 :                 if(nActNumLvl & nMask)
    2937           0 :                     m_pLevelLB->SelectEntryPos( i, true);
    2938           0 :                 nMask <<= 1 ;
    2939             :             }
    2940           0 :         m_pRelativeCB->Enable(nActNumLvl != 1);
    2941           0 :         m_pLevelLB->SetUpdateMode(true);
    2942             : 
    2943           0 :         InitPosAndSpaceMode();
    2944           0 :         ShowControlsDependingOnPosAndSpaceMode();
    2945             : 
    2946           0 :         InitControls();
    2947             :     }
    2948           0 :     m_pPreviewWIN->SetLevel(nActNumLvl);
    2949           0 :     m_pPreviewWIN->Invalidate();
    2950           0 : }
    2951             : 
    2952           0 : int  SvxNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet)
    2953             : {
    2954           0 :     if(_pSet)
    2955             :     {
    2956           0 :         if(m_pDistBorderMF->IsEnabled())
    2957           0 :             DistanceHdl_Impl(m_pDistBorderMF);
    2958           0 :         DistanceHdl_Impl(m_pIndentMF);
    2959           0 :         FillItemSet(*_pSet);
    2960             :     }
    2961           0 :     return sal_True;
    2962             : }
    2963             : 
    2964           0 : bool SvxNumPositionTabPage::FillItemSet( SfxItemSet& rSet )
    2965             : {
    2966           0 :     rSet.Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
    2967             : 
    2968           0 :     if(bModified && pActNum)
    2969             :     {
    2970           0 :         *pSaveNum = *pActNum;
    2971           0 :         rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
    2972           0 :         rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
    2973             :     }
    2974           0 :     return bModified;
    2975             : }
    2976             : 
    2977           0 : void SvxNumPositionTabPage::Reset( const SfxItemSet& rSet )
    2978             : {
    2979             :     const SfxPoolItem* pItem;
    2980             :     // in Draw the item exists as WhichId, in Writer only as SlotId
    2981           0 :     SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
    2982           0 :     if(eState != SFX_ITEM_SET)
    2983             :     {
    2984           0 :         nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
    2985           0 :         eState = rSet.GetItemState(nNumItemId, false, &pItem);
    2986             : 
    2987           0 :         if( eState != SFX_ITEM_SET )
    2988             :         {
    2989           0 :             pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, true ) );
    2990           0 :             eState = SFX_ITEM_SET;
    2991             :         }
    2992             : 
    2993             :     }
    2994             :     DBG_ASSERT(eState == SFX_ITEM_SET, "no item found!");
    2995           0 :     delete pSaveNum;
    2996           0 :     pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
    2997             : 
    2998             :     // insert levels
    2999           0 :     if(!m_pLevelLB->GetEntryCount())
    3000             :     {
    3001           0 :         for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
    3002           0 :             m_pLevelLB->InsertEntry( OUString::number(i) );
    3003           0 :         if(pSaveNum->GetLevelCount() > 1)
    3004             :         {
    3005           0 :             OUString sEntry( "1 - " );
    3006           0 :             sEntry += OUString::number( pSaveNum->GetLevelCount() );
    3007           0 :             m_pLevelLB->InsertEntry(sEntry);
    3008           0 :             m_pLevelLB->SelectEntry(sEntry);
    3009             :         }
    3010             :         else
    3011           0 :             m_pLevelLB->SelectEntryPos(0);
    3012             :     }
    3013             :     else
    3014           0 :         m_pLevelLB->SelectEntryPos(m_pLevelLB->GetEntryCount() - 1);
    3015           0 :     sal_uInt16 nMask = 1;
    3016           0 :     m_pLevelLB->SetUpdateMode(false);
    3017           0 :     m_pLevelLB->SetNoSelection();
    3018           0 :     if(nActNumLvl == SAL_MAX_UINT16)
    3019             :     {
    3020           0 :         m_pLevelLB->SelectEntryPos( pSaveNum->GetLevelCount(), true);
    3021             :     }
    3022             :     else
    3023             :     {
    3024           0 :         for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
    3025             :         {
    3026           0 :             if(nActNumLvl & nMask)
    3027           0 :                 m_pLevelLB->SelectEntryPos( i, true);
    3028           0 :             nMask <<= 1;
    3029             :         }
    3030             :     }
    3031           0 :     m_pLevelLB->SetUpdateMode(true);
    3032             : 
    3033           0 :     if(!pActNum)
    3034           0 :         pActNum = new  SvxNumRule(*pSaveNum);
    3035           0 :     else if(*pSaveNum != *pActNum)
    3036           0 :         *pActNum = *pSaveNum;
    3037           0 :     m_pPreviewWIN->SetNumRule(pActNum);
    3038             : 
    3039           0 :     InitPosAndSpaceMode();
    3040           0 :     ShowControlsDependingOnPosAndSpaceMode();
    3041             : 
    3042           0 :     InitControls();
    3043           0 :     bModified = sal_False;
    3044           0 : }
    3045             : 
    3046           0 : void SvxNumPositionTabPage::InitPosAndSpaceMode()
    3047             : {
    3048           0 :     if ( pActNum == 0 )
    3049             :     {
    3050             :         DBG_ASSERT( false,
    3051             :                 "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
    3052           0 :         return;
    3053             :     }
    3054             : 
    3055             :     SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode =
    3056           0 :                                             SvxNumberFormat::LABEL_ALIGNMENT;
    3057           0 :     sal_uInt16 nMask = 1;
    3058           0 :     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
    3059             :     {
    3060           0 :         if(nActNumLvl & nMask)
    3061             :         {
    3062           0 :             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
    3063           0 :             ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
    3064           0 :             if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    3065             :             {
    3066           0 :                 break;
    3067           0 :             }
    3068             :         }
    3069           0 :         nMask <<= 1;
    3070             :     }
    3071             : 
    3072             :     bLabelAlignmentPosAndSpaceModeActive =
    3073           0 :                     ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
    3074             : }
    3075             : 
    3076           0 : void SvxNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
    3077             : {
    3078           0 :     m_pDistBorderFT->Show( !bLabelAlignmentPosAndSpaceModeActive );
    3079           0 :     m_pDistBorderMF->Show( !bLabelAlignmentPosAndSpaceModeActive );
    3080           0 :     m_pRelativeCB->Show( !bLabelAlignmentPosAndSpaceModeActive );
    3081           0 :     m_pIndentFT->Show( !bLabelAlignmentPosAndSpaceModeActive );
    3082           0 :     m_pIndentMF->Show( !bLabelAlignmentPosAndSpaceModeActive );
    3083           0 :     m_pDistNumFT->Show( !bLabelAlignmentPosAndSpaceModeActive &&
    3084           0 :                      pActNum->IsFeatureSupported(NUM_CONTINUOUS) );
    3085           0 :     m_pDistNumMF->Show( !bLabelAlignmentPosAndSpaceModeActive &&
    3086           0 :                      pActNum->IsFeatureSupported(NUM_CONTINUOUS));
    3087           0 :     m_pAlignFT->Show( !bLabelAlignmentPosAndSpaceModeActive );
    3088           0 :     m_pAlignLB->Show( !bLabelAlignmentPosAndSpaceModeActive );
    3089             : 
    3090           0 :     m_pLabelFollowedByFT->Show( bLabelAlignmentPosAndSpaceModeActive );
    3091           0 :     m_pLabelFollowedByLB->Show( bLabelAlignmentPosAndSpaceModeActive );
    3092           0 :     m_pListtabFT->Show( bLabelAlignmentPosAndSpaceModeActive );
    3093           0 :     m_pListtabMF->Show( bLabelAlignmentPosAndSpaceModeActive );
    3094           0 :     m_pAlign2FT->Show( bLabelAlignmentPosAndSpaceModeActive );
    3095           0 :     m_pAlign2LB->Show( bLabelAlignmentPosAndSpaceModeActive );
    3096           0 :     m_pAlignedAtFT->Show( bLabelAlignmentPosAndSpaceModeActive );
    3097           0 :     m_pAlignedAtMF->Show( bLabelAlignmentPosAndSpaceModeActive );
    3098           0 :     m_pIndentAtFT->Show( bLabelAlignmentPosAndSpaceModeActive );
    3099           0 :     m_pIndentAtMF->Show( bLabelAlignmentPosAndSpaceModeActive );
    3100           0 : }
    3101             : 
    3102           0 : SfxTabPage* SvxNumPositionTabPage::Create( Window* pParent,
    3103             :                                 const SfxItemSet& rAttrSet)
    3104             : {
    3105           0 :     return new SvxNumPositionTabPage(pParent, rAttrSet);
    3106             : }
    3107             : 
    3108           0 : void    SvxNumPositionTabPage::SetMetric(FieldUnit eMetric)
    3109             : {
    3110           0 :     if(eMetric == FUNIT_MM)
    3111             :     {
    3112           0 :         m_pDistBorderMF->SetDecimalDigits(1);
    3113           0 :         m_pDistNumMF->SetDecimalDigits(1);
    3114           0 :         m_pIndentMF->SetDecimalDigits(1);
    3115           0 :         m_pListtabMF->SetDecimalDigits(1);
    3116           0 :         m_pAlignedAtMF->SetDecimalDigits(1);
    3117           0 :         m_pIndentAtMF->SetDecimalDigits(1);
    3118             :     }
    3119           0 :     m_pDistBorderMF->SetUnit( eMetric );
    3120           0 :     m_pDistNumMF->SetUnit( eMetric );
    3121           0 :     m_pIndentMF->SetUnit( eMetric );
    3122           0 :     m_pListtabMF->SetUnit( eMetric );
    3123           0 :     m_pAlignedAtMF->SetUnit( eMetric );
    3124           0 :     m_pIndentAtMF->SetUnit( eMetric );
    3125           0 : }
    3126             : 
    3127           0 : IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl)
    3128             : {
    3129           0 :     sal_uInt16 nMask = 1;
    3130           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    3131             :     {
    3132           0 :         if(nActNumLvl & nMask)
    3133             :         {
    3134           0 :             SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
    3135             : 
    3136           0 :             const sal_Int32 nPos = m_pAlignLB->IsVisible()
    3137           0 :                                 ? m_pAlignLB->GetSelectEntryPos()
    3138           0 :                                 : m_pAlign2LB->GetSelectEntryPos();
    3139           0 :             SvxAdjust eAdjust = SVX_ADJUST_CENTER;
    3140           0 :             if(nPos == 0)
    3141           0 :                 eAdjust = SVX_ADJUST_LEFT;
    3142           0 :             else if(nPos == 2)
    3143           0 :                 eAdjust = SVX_ADJUST_RIGHT;
    3144           0 :             aNumFmt.SetNumAdjust( eAdjust );
    3145           0 :             pActNum->SetLevel(i, aNumFmt);
    3146             :         }
    3147           0 :         nMask <<= 1;
    3148             :     }
    3149           0 :     SetModified();
    3150           0 :     return 0;
    3151             : }
    3152             : 
    3153           0 : IMPL_LINK( SvxNumPositionTabPage, LevelHdl_Impl, ListBox *, pBox )
    3154             : {
    3155           0 :     sal_uInt16 nSaveNumLvl = nActNumLvl;
    3156           0 :     nActNumLvl = 0;
    3157           0 :     if(pBox->IsEntryPosSelected( pActNum->GetLevelCount() ) &&
    3158           0 :             (pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
    3159             :     {
    3160           0 :         nActNumLvl = 0xFFFF;
    3161           0 :         pBox->SetUpdateMode(false);
    3162           0 :         for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
    3163           0 :             pBox->SelectEntryPos( i, false );
    3164           0 :         pBox->SetUpdateMode(true);
    3165             :     }
    3166           0 :     else if(pBox->GetSelectEntryCount())
    3167             :     {
    3168           0 :         sal_uInt16 nMask = 1;
    3169           0 :         for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
    3170             :         {
    3171           0 :             if(pBox->IsEntryPosSelected( i ))
    3172           0 :                 nActNumLvl |= nMask;
    3173           0 :             nMask <<= 1;
    3174             :         }
    3175           0 :         pBox->SelectEntryPos( pActNum->GetLevelCount(), false );
    3176             :     }
    3177             :     else
    3178             :     {
    3179           0 :         nActNumLvl = nSaveNumLvl;
    3180           0 :         sal_uInt16 nMask = 1;
    3181           0 :         for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
    3182             :         {
    3183           0 :             if(nActNumLvl & nMask)
    3184             :             {
    3185           0 :                 pBox->SelectEntryPos(i);
    3186           0 :                 break;
    3187             :             }
    3188           0 :             nMask <<=1;
    3189             :         }
    3190             :     }
    3191           0 :     m_pRelativeCB->Enable(nActNumLvl != 1);
    3192           0 :     SetModified();
    3193           0 :     InitPosAndSpaceMode();
    3194           0 :     ShowControlsDependingOnPosAndSpaceMode();
    3195           0 :     InitControls();
    3196           0 :     return 0;
    3197             : }
    3198             : 
    3199           0 : IMPL_LINK( SvxNumPositionTabPage, DistanceHdl_Impl, MetricField *, pFld )
    3200             : {
    3201           0 :     if(bInInintControl)
    3202           0 :         return 0;
    3203           0 :     long nValue = GetCoreValue(*pFld, eCoreUnit);
    3204           0 :     sal_uInt16 nMask = 1;
    3205           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    3206             :     {
    3207           0 :         if(nActNumLvl & nMask)
    3208             :         {
    3209           0 :             SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
    3210           0 :             if (pFld == m_pDistBorderMF)
    3211             :             {
    3212             : 
    3213           0 :                 if(m_pRelativeCB->IsChecked())
    3214             :                 {
    3215           0 :                     if(0 == i)
    3216             :                     {
    3217           0 :                         long nTmp = aNumFmt.GetFirstLineOffset();
    3218           0 :                         aNumFmt.SetAbsLSpace( sal_uInt16(nValue - nTmp));
    3219             :                     }
    3220             :                     else
    3221             :                     {
    3222           0 :                         long nTmp = pActNum->GetLevel( i - 1 ).GetAbsLSpace() +
    3223           0 :                                     pActNum->GetLevel( i - 1 ).GetFirstLineOffset() -
    3224           0 :                                     pActNum->GetLevel( i ).GetFirstLineOffset();
    3225             : 
    3226           0 :                         aNumFmt.SetAbsLSpace( sal_uInt16(nValue + nTmp));
    3227             :                     }
    3228             :                 }
    3229             :                 else
    3230             :                 {
    3231           0 :                     aNumFmt.SetAbsLSpace( (short)nValue - aNumFmt.GetFirstLineOffset());
    3232             :                 }
    3233             :             }
    3234           0 :             else if (pFld == m_pDistNumMF)
    3235             :             {
    3236           0 :                 aNumFmt.SetCharTextDistance( (short)nValue );
    3237             :             }
    3238           0 :             else if (pFld == m_pIndentMF)
    3239             :             {
    3240             :                 // together with the FirstLineOffset the AbsLSpace must be changed, too
    3241           0 :                 long nDiff = nValue + aNumFmt.GetFirstLineOffset();
    3242           0 :                 long nAbsLSpace = aNumFmt.GetAbsLSpace();
    3243           0 :                 aNumFmt.SetAbsLSpace(sal_uInt16(nAbsLSpace + nDiff));
    3244           0 :                 aNumFmt.SetFirstLineOffset( -(short)nValue );
    3245             :             }
    3246             : 
    3247           0 :             pActNum->SetLevel( i, aNumFmt );
    3248             :         }
    3249           0 :         nMask <<= 1;
    3250             :     }
    3251             : 
    3252           0 :     SetModified();
    3253           0 :     if(!m_pDistBorderMF->IsEnabled())
    3254             :     {
    3255           0 :         OUString aEmptyStr;
    3256           0 :         m_pDistBorderMF->SetText(aEmptyStr);
    3257             :     }
    3258             : 
    3259           0 :     return 0;
    3260             : }
    3261             : 
    3262           0 : IMPL_LINK( SvxNumPositionTabPage, RelativeHdl_Impl, CheckBox *, pBox )
    3263             : {
    3264           0 :     sal_Bool bOn = pBox->IsChecked();
    3265           0 :     sal_Bool bSingleSelection = m_pLevelLB->GetSelectEntryCount() == 1 && SAL_MAX_UINT16 != nActNumLvl;
    3266           0 :     sal_Bool bSetValue = sal_False;
    3267           0 :     long nValue = 0;
    3268           0 :     if(bOn || bSingleSelection)
    3269             :     {
    3270           0 :         sal_uInt16 nMask = 1;
    3271           0 :         sal_Bool bFirst = sal_True;
    3272           0 :         bSetValue = sal_True;
    3273           0 :         for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    3274             :         {
    3275           0 :             if(nActNumLvl & nMask)
    3276             :             {
    3277           0 :                 const SvxNumberFormat &rNumFmt = pActNum->GetLevel(i);
    3278           0 :                 if(bFirst)
    3279             :                 {
    3280           0 :                     nValue = rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset();
    3281           0 :                     if(bOn && i)
    3282           0 :                         nValue -= (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
    3283             :                 }
    3284             :                 else
    3285           0 :                     bSetValue = nValue ==
    3286           0 :                         (rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset()) -
    3287           0 :                             (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
    3288           0 :                 bFirst = sal_False;
    3289             :             }
    3290           0 :             nMask <<= 1;
    3291             :         }
    3292             : 
    3293             :     }
    3294           0 :     OUString aEmptyStr;
    3295           0 :     if(bSetValue)
    3296           0 :         SetMetricValue(*m_pDistBorderMF, nValue,   eCoreUnit);
    3297             :     else
    3298           0 :         m_pDistBorderMF->SetText(aEmptyStr);
    3299           0 :     m_pDistBorderMF->Enable(bOn || bSingleSelection);
    3300           0 :     m_pDistBorderFT->Enable(bOn || bSingleSelection);
    3301           0 :     bLastRelative = bOn;
    3302           0 :     return 0;
    3303             : }
    3304             : 
    3305           0 : IMPL_LINK_NOARG(SvxNumPositionTabPage, LabelFollowedByHdl_Impl)
    3306             : {
    3307             :     // determine value to be set at the chosen list levels
    3308           0 :     SvxNumberFormat::LabelFollowedBy eLabelFollowedBy = SvxNumberFormat::LISTTAB;
    3309             :     {
    3310           0 :         const sal_Int32 nPos = m_pLabelFollowedByLB->GetSelectEntryPos();
    3311           0 :         if ( nPos == 1 )
    3312             :         {
    3313           0 :             eLabelFollowedBy = SvxNumberFormat::SPACE;
    3314             :         }
    3315           0 :         else if ( nPos == 2 )
    3316             :         {
    3317           0 :             eLabelFollowedBy = SvxNumberFormat::NOTHING;
    3318             :         }
    3319             :     }
    3320             : 
    3321             :     // set value at the chosen list levels
    3322           0 :     bool bSameListtabPos = true;
    3323           0 :     sal_uInt16 nFirstLvl = SAL_MAX_UINT16;
    3324           0 :     sal_uInt16 nMask = 1;
    3325           0 :     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
    3326             :     {
    3327           0 :         if ( nActNumLvl & nMask )
    3328             :         {
    3329           0 :             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
    3330           0 :             aNumFmt.SetLabelFollowedBy( eLabelFollowedBy );
    3331           0 :             pActNum->SetLevel( i, aNumFmt );
    3332             : 
    3333           0 :             if ( nFirstLvl == SAL_MAX_UINT16 )
    3334             :             {
    3335           0 :                 nFirstLvl = i;
    3336             :             }
    3337             :             else
    3338             :             {
    3339           0 :                 bSameListtabPos &= aNumFmt.GetListtabPos() ==
    3340           0 :                         pActNum->GetLevel( nFirstLvl ).GetListtabPos();
    3341           0 :             }
    3342             :         }
    3343           0 :         nMask <<= 1;
    3344             :     }
    3345             : 
    3346             :     // enable/disable metric field for list tab stop position depending on
    3347             :     // selected item following the list label.
    3348           0 :     m_pListtabFT->Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
    3349           0 :     m_pListtabMF->Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
    3350           0 :     if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
    3351             :     {
    3352           0 :         SetMetricValue(*m_pListtabMF, pActNum->GetLevel( nFirstLvl ).GetListtabPos(), eCoreUnit);
    3353             :     }
    3354             :     else
    3355             :     {
    3356           0 :         m_pListtabMF->SetText( OUString() );
    3357             :     }
    3358             : 
    3359           0 :     SetModified();
    3360             : 
    3361           0 :     return 0;
    3362             : }
    3363             : 
    3364           0 : IMPL_LINK( SvxNumPositionTabPage, ListtabPosHdl_Impl, MetricField*, pFld )
    3365             : {
    3366             :     // determine value to be set at the chosen list levels
    3367           0 :     const long nValue = GetCoreValue( *pFld, eCoreUnit );
    3368             : 
    3369             :     // set value at the chosen list levels
    3370           0 :     sal_uInt16 nMask = 1;
    3371           0 :     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
    3372             :     {
    3373           0 :         if ( nActNumLvl & nMask )
    3374             :         {
    3375           0 :             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
    3376           0 :             aNumFmt.SetListtabPos( nValue );
    3377           0 :             pActNum->SetLevel( i, aNumFmt );
    3378             :         }
    3379           0 :         nMask <<= 1;
    3380             :     }
    3381             : 
    3382           0 :     SetModified();
    3383             : 
    3384           0 :     return 0;
    3385             : }
    3386             : 
    3387           0 : IMPL_LINK( SvxNumPositionTabPage, AlignAtHdl_Impl, MetricField*, pFld )
    3388             : {
    3389             :     // determine value to be set at the chosen list levels
    3390           0 :     const long nValue = GetCoreValue( *pFld, eCoreUnit );
    3391             : 
    3392             :     // set value at the chosen list levels
    3393           0 :     sal_uInt16 nMask = 1;
    3394           0 :     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
    3395             :     {
    3396           0 :         if ( nActNumLvl & nMask )
    3397             :         {
    3398           0 :             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
    3399           0 :             const long nFirstLineIndent = nValue - aNumFmt.GetIndentAt();
    3400           0 :             aNumFmt.SetFirstLineIndent( nFirstLineIndent );
    3401           0 :             pActNum->SetLevel( i, aNumFmt );
    3402             :         }
    3403           0 :         nMask <<= 1;
    3404             :     }
    3405             : 
    3406           0 :     SetModified();
    3407             : 
    3408           0 :     return 0;
    3409             : }
    3410             : 
    3411           0 : IMPL_LINK( SvxNumPositionTabPage, IndentAtHdl_Impl, MetricField*, pFld )
    3412             : {
    3413             :     // determine value to be set at the chosen list levels
    3414           0 :     const long nValue = GetCoreValue( *pFld, eCoreUnit );
    3415             : 
    3416             :     // set value at the chosen list levels
    3417           0 :     sal_uInt16 nMask = 1;
    3418           0 :     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
    3419             :     {
    3420           0 :         if ( nActNumLvl & nMask )
    3421             :         {
    3422           0 :             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
    3423           0 :             const long nAlignedAt = aNumFmt.GetIndentAt() +
    3424           0 :                                     aNumFmt.GetFirstLineIndent();
    3425           0 :             aNumFmt.SetIndentAt( nValue );
    3426           0 :             const long nNewFirstLineIndent = nAlignedAt - nValue;
    3427           0 :             aNumFmt.SetFirstLineIndent( nNewFirstLineIndent );
    3428           0 :             pActNum->SetLevel( i, aNumFmt );
    3429             :         }
    3430           0 :         nMask <<= 1;
    3431             :     }
    3432             : 
    3433           0 :     SetModified();
    3434             : 
    3435           0 :     return 0;
    3436             : }
    3437             : 
    3438           0 : IMPL_LINK_NOARG(SvxNumPositionTabPage, StandardHdl_Impl)
    3439             : {
    3440           0 :     sal_uInt16 nMask = 1;
    3441             :     SvxNumRule aTmpNumRule( pActNum->GetFeatureFlags(),
    3442           0 :                             pActNum->GetLevelCount(),
    3443           0 :                             pActNum->IsContinuousNumbering(),
    3444             :                             SVX_RULETYPE_NUMBERING,
    3445           0 :                             pActNum->GetLevel( 0 ).GetPositionAndSpaceMode() );
    3446           0 :     for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    3447             :     {
    3448           0 :         if(nActNumLvl & nMask)
    3449             :         {
    3450           0 :             SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
    3451           0 :             SvxNumberFormat aTempFmt(aTmpNumRule.GetLevel( i ));
    3452           0 :             aNumFmt.SetPositionAndSpaceMode( aTempFmt.GetPositionAndSpaceMode() );
    3453           0 :             if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    3454             :             {
    3455           0 :                 aNumFmt.SetAbsLSpace( aTempFmt.GetAbsLSpace() );
    3456           0 :                 aNumFmt.SetCharTextDistance( aTempFmt.GetCharTextDistance() );
    3457           0 :                 aNumFmt.SetFirstLineOffset( aTempFmt.GetFirstLineOffset() );
    3458             :             }
    3459           0 :             else if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    3460             :             {
    3461           0 :                 aNumFmt.SetNumAdjust( aTempFmt.GetNumAdjust() );
    3462           0 :                 aNumFmt.SetLabelFollowedBy( aTempFmt.GetLabelFollowedBy() );
    3463           0 :                 aNumFmt.SetListtabPos( aTempFmt.GetListtabPos() );
    3464           0 :                 aNumFmt.SetFirstLineIndent( aTempFmt.GetFirstLineIndent() );
    3465           0 :                 aNumFmt.SetIndentAt( aTempFmt.GetIndentAt() );
    3466             :             }
    3467             : 
    3468           0 :             pActNum->SetLevel( i, aNumFmt );
    3469             :         }
    3470           0 :         nMask <<= 1;
    3471             :     }
    3472             : 
    3473           0 :     InitControls();
    3474           0 :     SetModified();
    3475           0 :     return 0;
    3476             : }
    3477             : 
    3478           0 : void SvxNumPositionTabPage::SetModified(sal_Bool bRepaint)
    3479             : {
    3480           0 :     bModified = sal_True;
    3481           0 :     if(bRepaint)
    3482             :     {
    3483           0 :         m_pPreviewWIN->SetLevel(nActNumLvl);
    3484           0 :         m_pPreviewWIN->Invalidate();
    3485             :     }
    3486           0 : }
    3487             : 
    3488           0 : void SvxNumOptionsTabPage::SetModified(sal_Bool bRepaint)
    3489             : {
    3490           0 :     bModified = sal_True;
    3491           0 :     if(bRepaint)
    3492             :     {
    3493           0 :         m_pPreviewWIN->SetLevel(nActNumLvl);
    3494           0 :         m_pPreviewWIN->Invalidate();
    3495             :     }
    3496           0 : }
    3497             : 
    3498           0 : void SvxNumOptionsTabPage::PageCreated(SfxAllItemSet aSet)
    3499             : {
    3500           0 :     SFX_ITEMSET_ARG (&aSet,pListItem,SfxStringListItem,SID_CHAR_FMT_LIST_BOX,false);
    3501           0 :     SFX_ITEMSET_ARG (&aSet,pNumCharFmt,SfxStringItem,SID_NUM_CHAR_FMT,false);
    3502           0 :     SFX_ITEMSET_ARG (&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,false);
    3503           0 :     SFX_ITEMSET_ARG (&aSet,pMetricItem,SfxAllEnumItem,SID_METRIC_ITEM,false);
    3504             : 
    3505           0 :     if (pNumCharFmt &&pBulletCharFmt)
    3506           0 :         SetCharFmts( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
    3507             : 
    3508           0 :     if (pListItem)
    3509             :     {
    3510           0 :         ListBox& myCharFmtLB = GetCharFmtListBox();
    3511           0 :         const std::vector<OUString> &aList = pListItem->GetList();
    3512           0 :         sal_uInt32 nCount = aList.size();;
    3513           0 :         for(sal_uInt32 i = 0; i < nCount; i++)
    3514           0 :             myCharFmtLB.InsertEntry(aList[i]);
    3515             :     }
    3516           0 :     if (pMetricItem)
    3517           0 :         SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
    3518           0 : }
    3519             : 
    3520           0 : void SvxNumPositionTabPage::PageCreated(SfxAllItemSet aSet)
    3521             : {
    3522           0 :     SFX_ITEMSET_ARG (&aSet,pMetricItem,SfxAllEnumItem,SID_METRIC_ITEM,false);
    3523             : 
    3524           0 :     if (pMetricItem)
    3525           0 :         SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
    3526           0 : }
    3527             : 
    3528             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10