2010-10-14 08:30:41 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 23:08:29 +00:00
/*************************************************************************
*
2008-04-10 12:26:27 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-09-18 23:08:29 +00:00
*
2010-02-12 15:01:35 +01:00
* Copyright 2000 , 2010 Oracle and / or its affiliates .
2000-09-18 23:08:29 +00:00
*
2008-04-10 12:26:27 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-09-18 23:08:29 +00:00
*
2008-04-10 12:26:27 +00:00
* This file is part of OpenOffice . org .
2000-09-18 23:08:29 +00:00
*
2008-04-10 12:26:27 +00:00
* OpenOffice . org is free software : you can redistribute it and / or modify
* it under the terms of the GNU Lesser General Public License version 3
* only , as published by the Free Software Foundation .
2000-09-18 23:08:29 +00:00
*
2008-04-10 12:26:27 +00:00
* OpenOffice . org is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Lesser General Public License version 3 for more details
* ( a copy is included in the LICENSE file that accompanied this code ) .
2000-09-18 23:08:29 +00:00
*
2008-04-10 12:26:27 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2000-09-18 23:08:29 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <hintids.hxx>
# include <string.h>
# include <vcl/font.hxx>
2010-01-08 18:32:51 +01:00
# include <editeng/brshitem.hxx>
# include <editeng/lrspitem.hxx>
# include <editeng/numitem.hxx>
2000-09-18 23:08:29 +00:00
# include <fmtornt.hxx>
# include <doc.hxx>
# include <pam.hxx>
# include <charfmt.hxx>
# include <paratr.hxx>
# include <frmfmt.hxx>
# include <ndtxt.hxx>
# include <docary.hxx>
# include <docsh.hxx>
2001-07-20 09:40:14 +00:00
# include <SwStyleNameMapper.hxx>
2010-10-18 12:57:41 +01:00
2006-07-25 10:47:05 +00:00
// Needed to load default bullet list configuration
# include <unotools/configitem.hxx>
2010-10-18 12:57:41 +01:00
2008-03-05 15:55:04 +00:00
# include <numrule.hxx>
2008-06-13 08:38:13 +00:00
# include <SwNodeNum.hxx>
2000-09-18 23:08:29 +00:00
2011-02-06 00:58:27 +01:00
# include <boost/unordered_map.hpp>
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
# include <list.hxx>
# include <algorithm>
2010-10-18 12:57:41 +01:00
2009-10-06 07:38:24 +02:00
# include <unotools/saveopt.hxx>
2010-10-18 12:57:41 +01:00
2008-07-11 13:32:10 +00:00
# include <IDocumentListsAccess.hxx>
2004-10-22 07:12:03 +00:00
2007-09-27 07:39:02 +00:00
using namespace : : com : : sun : : star ;
2011-01-17 15:06:54 +01:00
sal_uInt16 SwNumRule : : nRefCount = 0 ;
2000-09-18 23:08:29 +00:00
SwNumFmt * SwNumRule : : aBaseFmts [ RULE_END ] [ MAXLEVEL ] = {
2007-09-27 07:39:02 +00:00
{ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } } ;
2010-10-18 12:57:41 +01:00
2008-03-05 15:55:04 +00:00
SwNumFmt * SwNumRule : : aLabelAlignmentBaseFmts [ RULE_END ] [ MAXLEVEL ] = {
{ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } } ;
2007-09-27 07:39:02 +00:00
char sOutline [ ] = " Outline " ;
char * SwNumRule : : pDefOutlineName = sOutline ;
2000-09-18 23:08:29 +00:00
2011-01-17 15:06:54 +01:00
sal_uInt16 SwNumRule : : aDefNumIndents [ MAXLEVEL ] = {
2004-07-05 13:39:02 +00:00
//inch: 0,5 1,0 1,5 2,0 2,5 3,0 3,5 4,0 4,5 5,0
1440 / 4 , 1440 / 2 , 1440 * 3 / 4 , 1440 , 1440 * 5 / 4 , 1440 * 3 / 2 , 1440 * 7 / 4 , 1440 * 2 ,
1440 * 9 / 4 , 1440 * 5 / 2
2000-09-18 23:08:29 +00:00
} ;
2011-01-17 15:06:54 +01:00
const SwNumFmt & SwNumRule : : Get ( sal_uInt16 i ) const
2004-03-08 11:24:46 +00:00
{
2011-02-20 17:58:46 +01:00
OSL_ASSERT ( i < MAXLEVEL & & eRuleType < RULE_END ) ;
2008-03-05 15:55:04 +00:00
return aFmts [ i ]
? * aFmts [ i ]
: ( meDefaultNumberFormatPositionAndSpaceMode = = SvxNumberFormat : : LABEL_WIDTH_AND_POSITION
? * aBaseFmts [ eRuleType ] [ i ]
: * aLabelAlignmentBaseFmts [ eRuleType ] [ i ] ) ;
2004-03-08 11:24:46 +00:00
}
2011-01-17 15:06:54 +01:00
const SwNumFmt * SwNumRule : : GetNumFmt ( sal_uInt16 i ) const
2004-03-08 11:24:46 +00:00
{
2010-09-08 17:52:18 +02:00
const SwNumFmt * pResult = NULL ;
2011-02-20 17:58:46 +01:00
OSL_ASSERT ( i < MAXLEVEL & & eRuleType < RULE_END ) ;
2010-09-08 17:52:18 +02:00
if ( i < MAXLEVEL & & eRuleType < RULE_END )
{
pResult = aFmts [ i ] ;
}
return pResult ;
2004-03-08 11:24:46 +00:00
}
2004-10-22 07:12:03 +00:00
2011-02-02 20:41:40 +09:00
// #i91400#
2008-07-11 13:32:10 +00:00
void SwNumRule : : SetName ( const String & rName ,
IDocumentListsAccess & rDocListAccess )
2004-11-27 10:41:31 +00:00
{
2008-07-11 13:32:10 +00:00
if ( sName ! = rName )
2004-11-27 10:41:31 +00:00
{
2008-07-11 13:32:10 +00:00
if ( pNumRuleMap )
{
pNumRuleMap - > erase ( sName ) ;
( * pNumRuleMap ) [ rName ] = this ;
if ( GetDefaultListId ( ) . Len ( ) > 0 )
{
rDocListAccess . trackChangeOfListStyleName ( sName , rName ) ;
}
}
sName = rName ;
2004-11-27 10:41:31 +00:00
}
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
void SwNumRule : : GetTxtNodeList ( SwNumRule : : tTxtNodeList & rTxtNodeList ) const
{
rTxtNodeList = maTxtNodeList ;
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
SwNumRule : : tTxtNodeList : : size_type SwNumRule : : GetTxtNodeListSize ( ) const
{
return maTxtNodeList . size ( ) ;
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
void SwNumRule : : AddTxtNode ( SwTxtNode & rTxtNode )
2004-10-22 07:12:03 +00:00
{
2008-06-13 08:38:13 +00:00
tTxtNodeList : : iterator aIter =
std : : find ( maTxtNodeList . begin ( ) , maTxtNodeList . end ( ) , & rTxtNode ) ;
2004-10-22 07:12:03 +00:00
2008-06-13 08:38:13 +00:00
if ( aIter = = maTxtNodeList . end ( ) )
{
maTxtNodeList . push_back ( & rTxtNode ) ;
}
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
void SwNumRule : : RemoveTxtNode ( SwTxtNode & rTxtNode )
{
tTxtNodeList : : iterator aIter =
std : : find ( maTxtNodeList . begin ( ) , maTxtNodeList . end ( ) , & rTxtNode ) ;
if ( aIter ! = maTxtNodeList . end ( ) )
{
maTxtNodeList . erase ( aIter ) ;
}
2004-10-22 07:12:03 +00:00
}
2010-10-18 12:57:41 +01:00
2004-10-22 07:12:03 +00:00
2011-02-06 00:58:27 +01:00
void SwNumRule : : SetNumRuleMap ( boost : : unordered_map < String , SwNumRule * , StringHash > *
2004-11-27 10:41:31 +00:00
_pNumRuleMap )
{
pNumRuleMap = _pNumRuleMap ;
}
2011-01-17 15:06:54 +01:00
sal_uInt16 SwNumRule : : GetNumIndent ( sal_uInt8 nLvl )
2004-03-08 11:24:46 +00:00
{
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( MAXLEVEL > nLvl , " NumLevel is out of range " ) ;
2004-03-08 11:24:46 +00:00
return aDefNumIndents [ nLvl ] ;
}
2004-11-27 10:41:31 +00:00
2012-01-27 10:32:23 +01:00
sal_uInt16 SwNumRule : : GetBullIndent ( sal_uInt8 nLvl )
{
OSL_ENSURE ( MAXLEVEL > nLvl , " NumLevel is out of range " ) ;
return aDefNumIndents [ nLvl ] ;
}
2011-01-17 15:06:54 +01:00
static void lcl_SetRuleChgd ( SwTxtNode & rNd , sal_uInt8 nLevel )
2000-09-18 23:08:29 +00:00
{
2008-06-13 08:38:13 +00:00
if ( rNd . GetActualListLevel ( ) = = nLevel )
2001-02-23 11:45:30 +00:00
rNd . NumRuleChgd ( ) ;
2000-09-18 23:08:29 +00:00
}
2001-02-23 11:45:30 +00:00
SwNumFmt : : SwNumFmt ( ) :
SvxNumberFormat ( SVX_NUM_ARABIC ) ,
2007-09-27 07:39:02 +00:00
SwClient ( 0 ) ,
pVertOrient ( new SwFmtVertOrient ( 0 , text : : VertOrientation : : NONE ) )
2000-09-18 23:08:29 +00:00
{
}
2001-02-23 11:45:30 +00:00
SwNumFmt : : SwNumFmt ( const SwNumFmt & rFmt ) :
SvxNumberFormat ( rFmt ) ,
2010-12-17 09:02:23 +01:00
SwClient ( rFmt . GetRegisteredInNonConst ( ) ) ,
2007-09-27 07:39:02 +00:00
pVertOrient ( new SwFmtVertOrient ( 0 , rFmt . GetVertOrient ( ) ) )
2000-09-18 23:08:29 +00:00
{
2007-09-27 07:39:02 +00:00
sal_Int16 eMyVertOrient = rFmt . GetVertOrient ( ) ;
2001-02-23 11:45:30 +00:00
SetGraphicBrush ( rFmt . GetBrush ( ) , & rFmt . GetGraphicSize ( ) ,
2007-09-27 07:39:02 +00:00
& eMyVertOrient ) ;
2000-09-18 23:08:29 +00:00
}
2001-02-23 11:45:30 +00:00
SwNumFmt : : SwNumFmt ( const SvxNumberFormat & rNumFmt , SwDoc * pDoc ) :
SvxNumberFormat ( rNumFmt ) ,
2007-09-27 07:39:02 +00:00
pVertOrient ( new SwFmtVertOrient ( 0 , rNumFmt . GetVertOrient ( ) ) )
2000-09-18 23:08:29 +00:00
{
2007-09-27 07:39:02 +00:00
sal_Int16 eMyVertOrient = rNumFmt . GetVertOrient ( ) ;
2001-06-01 06:00:09 +00:00
SetGraphicBrush ( rNumFmt . GetBrush ( ) , & rNumFmt . GetGraphicSize ( ) ,
2007-09-27 07:39:02 +00:00
& eMyVertOrient ) ;
2001-02-23 11:45:30 +00:00
const String & rCharStyleName = rNumFmt . SvxNumberFormat : : GetCharFmtName ( ) ;
if ( rCharStyleName . Len ( ) )
2000-09-18 23:08:29 +00:00
{
2001-02-23 11:45:30 +00:00
SwCharFmt * pCFmt = pDoc - > FindCharFmtByName ( rCharStyleName ) ;
if ( ! pCFmt )
2000-09-18 23:08:29 +00:00
{
2011-01-17 15:06:54 +01:00
sal_uInt16 nId = SwStyleNameMapper : : GetPoolIdFromUIName ( rCharStyleName ,
2007-09-27 07:39:02 +00:00
nsSwGetPoolIdFromName : : GET_POOLID_CHRFMT ) ;
2001-02-23 11:45:30 +00:00
pCFmt = nId ! = USHRT_MAX
? pDoc - > GetCharFmtFromPool ( nId )
: pDoc - > MakeCharFmt ( rCharStyleName , 0 ) ;
2000-09-18 23:08:29 +00:00
}
2001-02-23 11:45:30 +00:00
pCFmt - > Add ( this ) ;
2000-09-18 23:08:29 +00:00
}
2001-02-23 11:45:30 +00:00
else if ( GetRegisteredIn ( ) )
2010-12-17 09:02:23 +01:00
GetRegisteredInNonConst ( ) - > Remove ( this ) ;
2001-02-23 11:45:30 +00:00
2000-09-18 23:08:29 +00:00
}
2001-02-23 11:45:30 +00:00
SwNumFmt : : ~ SwNumFmt ( )
{
delete pVertOrient ;
}
2001-07-02 13:25:51 +00:00
void SwNumFmt : : NotifyGraphicArrived ( )
{
if ( GetCharFmt ( ) )
UpdateNumNodes ( ( SwDoc * ) GetCharFmt ( ) - > GetDoc ( ) ) ;
}
2004-06-11 14:21:42 +00:00
// #i22362#
2011-01-17 15:06:54 +01:00
sal_Bool SwNumFmt : : IsEnumeration ( ) const
2004-06-11 14:21:42 +00:00
{
2011-04-16 22:42:13 -03:00
// #i30655# native numbering did not work any longer
2004-08-31 12:52:44 +00:00
// using this code. Therefore HBRINKM and I agreed upon defining
// IsEnumeration() as !IsItemize()
return ! IsItemize ( ) ;
2004-06-11 14:21:42 +00:00
}
2010-10-18 12:57:41 +01:00
2011-01-17 15:06:54 +01:00
sal_Bool SwNumFmt : : IsItemize ( ) const
2004-06-11 14:21:42 +00:00
{
2011-01-17 15:06:54 +01:00
sal_Bool bResult ;
2004-06-11 14:21:42 +00:00
switch ( GetNumberingType ( ) )
{
case SVX_NUM_CHAR_SPECIAL :
case SVX_NUM_BITMAP :
2011-01-17 15:06:54 +01:00
bResult = sal_True ;
2004-06-11 14:21:42 +00:00
break ;
default :
2011-01-17 15:06:54 +01:00
bResult = sal_False ;
2004-06-11 14:21:42 +00:00
}
return bResult ;
}
2001-02-23 11:45:30 +00:00
SwNumFmt & SwNumFmt : : operator = ( const SwNumFmt & rNumFmt )
2000-09-18 23:08:29 +00:00
{
2001-02-23 11:45:30 +00:00
SvxNumberFormat : : operator = ( rNumFmt ) ;
2000-09-18 23:08:29 +00:00
if ( rNumFmt . GetRegisteredIn ( ) )
2010-12-17 09:02:23 +01:00
rNumFmt . GetRegisteredInNonConst ( ) - > Add ( this ) ;
2000-09-18 23:08:29 +00:00
else if ( GetRegisteredIn ( ) )
2010-12-17 09:02:23 +01:00
GetRegisteredInNonConst ( ) - > Remove ( this ) ;
2000-09-18 23:08:29 +00:00
return * this ;
}
2011-01-17 15:06:54 +01:00
sal_Bool SwNumFmt : : operator = = ( const SwNumFmt & rNumFmt ) const
2000-09-18 23:08:29 +00:00
{
2011-01-17 15:06:54 +01:00
sal_Bool bRet = SvxNumberFormat : : operator = = ( rNumFmt ) & &
2011-02-09 15:55:27 +01:00
GetRegisteredIn ( ) = = rNumFmt . GetRegisteredIn ( ) ;
2000-09-18 23:08:29 +00:00
return bRet ;
}
2001-02-23 11:45:30 +00:00
void SwNumFmt : : SetCharFmt ( SwCharFmt * pChFmt )
2000-09-18 23:08:29 +00:00
{
if ( pChFmt )
pChFmt - > Add ( this ) ;
else if ( GetRegisteredIn ( ) )
2010-12-17 09:02:23 +01:00
GetRegisteredInNonConst ( ) - > Remove ( this ) ;
2000-09-18 23:08:29 +00:00
}
2010-12-17 09:02:23 +01:00
void SwNumFmt : : Modify ( const SfxPoolItem * pOld , const SfxPoolItem * pNew )
2000-09-18 23:08:29 +00:00
{
2012-01-03 13:56:50 +01:00
// Look for the NumRules object in the Doc where this NumFormat is set.
// The format does not need to exist!
2000-09-18 23:08:29 +00:00
const SwCharFmt * pFmt = 0 ;
2011-02-09 19:07:37 +01:00
sal_uInt16 nWhich = pOld ? pOld - > Which ( ) : pNew ? pNew - > Which ( ) : 0 ;
2010-12-17 09:02:23 +01:00
switch ( nWhich )
2000-09-18 23:08:29 +00:00
{
case RES_ATTRSET_CHG :
case RES_FMT_CHG :
pFmt = GetCharFmt ( ) ;
break ;
}
if ( pFmt & & ! pFmt - > GetDoc ( ) - > IsInDtor ( ) )
UpdateNumNodes ( ( SwDoc * ) pFmt - > GetDoc ( ) ) ;
else
2010-12-17 09:02:23 +01:00
CheckRegistration ( pOld , pNew ) ;
2000-09-18 23:08:29 +00:00
}
2001-02-23 11:45:30 +00:00
void SwNumFmt : : SetCharFmtName ( const String & rSet )
2000-09-18 23:08:29 +00:00
{
2001-02-23 11:45:30 +00:00
SvxNumberFormat : : SetCharFmtName ( rSet ) ;
2000-09-18 23:08:29 +00:00
}
2001-02-23 11:45:30 +00:00
const String & SwNumFmt : : GetCharFmtName ( ) const
{
2010-12-17 09:02:23 +01:00
if ( ( SwCharFmt * ) GetRegisteredIn ( ) )
return ( ( SwCharFmt * ) GetRegisteredIn ( ) ) - > GetName ( ) ;
2001-02-23 11:45:30 +00:00
else
return aEmptyStr ;
}
2000-09-18 23:08:29 +00:00
2010-12-17 09:02:23 +01:00
void SwNumFmt : : ForgetCharFmt ( )
{
if ( GetRegisteredIn ( ) )
GetRegisteredInNonConst ( ) - > Remove ( this ) ;
}
2000-09-18 23:08:29 +00:00
2001-02-23 11:45:30 +00:00
void SwNumFmt : : SetGraphicBrush ( const SvxBrushItem * pBrushItem , const Size * pSize ,
2007-09-27 07:39:02 +00:00
const sal_Int16 * pOrient )
2000-09-18 23:08:29 +00:00
{
2001-02-23 11:45:30 +00:00
if ( pOrient )
2007-09-27 07:39:02 +00:00
pVertOrient - > SetVertOrient ( * pOrient ) ;
2001-02-23 11:45:30 +00:00
SvxNumberFormat : : SetGraphicBrush ( pBrushItem , pSize , pOrient ) ;
}
2000-09-18 23:08:29 +00:00
2007-09-27 07:39:02 +00:00
void SwNumFmt : : SetVertOrient ( sal_Int16 eSet )
2001-02-23 11:45:30 +00:00
{
SvxNumberFormat : : SetVertOrient ( eSet ) ;
2000-09-18 23:08:29 +00:00
}
2007-09-27 07:39:02 +00:00
sal_Int16 SwNumFmt : : GetVertOrient ( ) const
2000-09-18 23:08:29 +00:00
{
2001-06-01 06:00:09 +00:00
return SvxNumberFormat : : GetVertOrient ( ) ;
2000-09-18 23:08:29 +00:00
}
void SwNumFmt : : UpdateNumNodes ( SwDoc * pDoc )
{
2011-01-17 15:06:54 +01:00
sal_Bool bDocIsModified = pDoc - > IsModified ( ) ;
2012-11-04 02:02:46 +09:00
bool bFnd = false ;
2000-09-18 23:08:29 +00:00
const SwNumRule * pRule ;
2012-05-16 15:23:09 +02:00
for ( sal_uInt16 n = pDoc - > GetNumRuleTbl ( ) . size ( ) ; ! bFnd & & n ; )
2000-09-18 23:08:29 +00:00
{
pRule = pDoc - > GetNumRuleTbl ( ) [ - - n ] ;
2011-01-17 15:06:54 +01:00
for ( sal_uInt8 i = 0 ; i < MAXLEVEL ; + + i )
2000-09-18 23:08:29 +00:00
if ( pRule - > GetNumFmt ( i ) = = this )
{
2008-06-13 08:38:13 +00:00
SwNumRule : : tTxtNodeList aTxtNodeList ;
pRule - > GetTxtNodeList ( aTxtNodeList ) ;
for ( SwNumRule : : tTxtNodeList : : iterator aIter = aTxtNodeList . begin ( ) ;
aIter ! = aTxtNodeList . end ( ) ; + + aIter )
{
lcl_SetRuleChgd ( * ( * aIter ) , i ) ;
}
2012-11-04 02:02:46 +09:00
bFnd = true ;
2000-09-18 23:08:29 +00:00
break ;
}
}
if ( bFnd & & ! bDocIsModified )
pDoc - > ResetModified ( ) ;
}
2001-06-01 06:00:09 +00:00
const SwFmtVertOrient * SwNumFmt : : GetGraphicOrientation ( ) const
{
2007-09-27 07:39:02 +00:00
sal_Int16 eOrient = SvxNumberFormat : : GetVertOrient ( ) ;
if ( text : : VertOrientation : : NONE = = eOrient )
2001-06-01 06:00:09 +00:00
return 0 ;
else
{
2007-09-27 07:39:02 +00:00
pVertOrient - > SetVertOrient ( eOrient ) ;
2001-06-01 06:00:09 +00:00
return pVertOrient ;
}
}
2000-09-18 23:08:29 +00:00
2005-07-18 12:34:24 +00:00
2008-03-05 15:55:04 +00:00
// handle new parameter <eDefaultNumberFormatPositionAndSpaceMode>
SwNumRule : : SwNumRule ( const String & rNm ,
const SvxNumberFormat : : SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode ,
SwNumRuleType eType ,
2011-01-17 15:06:54 +01:00
sal_Bool bAutoFlg )
2008-06-13 08:38:13 +00:00
: maTxtNodeList ( ) ,
maParagraphStyleList ( ) ,
2007-09-27 07:39:02 +00:00
pNumRuleMap ( 0 ) ,
2000-09-18 23:08:29 +00:00
sName ( rNm ) ,
2007-09-27 07:39:02 +00:00
eRuleType ( eType ) ,
nPoolFmtId ( USHRT_MAX ) ,
nPoolHelpId ( USHRT_MAX ) ,
nPoolHlpFileId ( UCHAR_MAX ) ,
2000-09-18 23:08:29 +00:00
bAutoRuleFlag ( bAutoFlg ) ,
2011-01-17 15:06:54 +01:00
bInvalidRuleFlag ( sal_True ) ,
bContinusNum ( sal_False ) ,
bAbsSpaces ( sal_False ) ,
2008-03-05 15:55:04 +00:00
mbCountPhantoms ( true ) ,
2008-06-13 08:38:13 +00:00
meDefaultNumberFormatPositionAndSpaceMode ( eDefaultNumberFormatPositionAndSpaceMode ) ,
msDefaultListId ( )
2000-09-18 23:08:29 +00:00
{
2012-01-03 13:56:50 +01:00
if ( ! nRefCount + + ) // for the first time, initialize
2000-09-18 23:08:29 +00:00
{
SwNumFmt * pFmt ;
2011-01-17 15:06:54 +01:00
sal_uInt8 n ;
2003-12-01 15:36:27 +00:00
2008-03-05 15:55:04 +00:00
// numbering:
// position-and-space mode LABEL_WIDTH_AND_POSITION:
2003-12-01 15:36:27 +00:00
for ( n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
{
pFmt = new SwNumFmt ;
2001-02-23 11:45:30 +00:00
pFmt - > SetIncludeUpperLevels ( 1 ) ;
pFmt - > SetStart ( 1 ) ;
2000-09-18 23:08:29 +00:00
pFmt - > SetLSpace ( lNumIndent ) ;
2004-07-05 13:39:02 +00:00
pFmt - > SetAbsLSpace ( lNumIndent + SwNumRule : : GetNumIndent ( n ) ) ;
2000-09-18 23:08:29 +00:00
pFmt - > SetFirstLineOffset ( lNumFirstLineOffset ) ;
2001-02-23 11:45:30 +00:00
pFmt - > SetSuffix ( aDotStr ) ;
2006-07-25 10:47:05 +00:00
pFmt - > SetBulletChar ( numfunc : : GetBulletChar ( n ) ) ;
2000-09-18 23:08:29 +00:00
SwNumRule : : aBaseFmts [ NUM_RULE ] [ n ] = pFmt ;
}
2008-03-05 15:55:04 +00:00
// position-and-space mode LABEL_ALIGNMENT
// first line indent of general numbering in inch: -0,25 inch
const long cFirstLineIndent = - 1440 / 4 ;
// indent values of general numbering in inch:
// 0,5 0,75 1,0 1,25 1,5
// 1,75 2,0 2,25 2,5 2,75
const long cIndentAt [ MAXLEVEL ] = {
1440 / 2 , 1440 * 3 / 4 , 1440 , 1440 * 5 / 4 , 1440 * 3 / 2 ,
1440 * 7 / 4 , 1440 * 2 , 1440 * 9 / 4 , 1440 * 5 / 2 , 1440 * 11 / 4 } ;
for ( n = 0 ; n < MAXLEVEL ; + + n )
{
pFmt = new SwNumFmt ;
pFmt - > SetIncludeUpperLevels ( 1 ) ;
pFmt - > SetStart ( 1 ) ;
pFmt - > SetPositionAndSpaceMode ( SvxNumberFormat : : LABEL_ALIGNMENT ) ;
pFmt - > SetLabelFollowedBy ( SvxNumberFormat : : LISTTAB ) ;
pFmt - > SetListtabPos ( cIndentAt [ n ] ) ;
pFmt - > SetFirstLineIndent ( cFirstLineIndent ) ;
pFmt - > SetIndentAt ( cIndentAt [ n ] ) ;
pFmt - > SetSuffix ( aDotStr ) ;
pFmt - > SetBulletChar ( numfunc : : GetBulletChar ( n ) ) ;
SwNumRule : : aLabelAlignmentBaseFmts [ NUM_RULE ] [ n ] = pFmt ;
}
2000-09-18 23:08:29 +00:00
2008-03-05 15:55:04 +00:00
// outline:
// position-and-space mode LABEL_WIDTH_AND_POSITION:
2000-09-18 23:08:29 +00:00
for ( n = 0 ; n < MAXLEVEL ; + + n )
{
pFmt = new SwNumFmt ;
2001-02-23 11:45:30 +00:00
pFmt - > SetNumberingType ( SVX_NUM_NUMBER_NONE ) ;
2002-10-08 12:51:25 +00:00
pFmt - > SetIncludeUpperLevels ( MAXLEVEL ) ;
2001-02-23 11:45:30 +00:00
pFmt - > SetStart ( 1 ) ;
2005-03-23 10:51:45 +00:00
pFmt - > SetCharTextDistance ( lOutlineMinTextDistance ) ;
2006-07-25 10:47:05 +00:00
pFmt - > SetBulletChar ( numfunc : : GetBulletChar ( n ) ) ;
2000-09-18 23:08:29 +00:00
SwNumRule : : aBaseFmts [ OUTLINE_RULE ] [ n ] = pFmt ;
}
2008-03-05 15:55:04 +00:00
// position-and-space mode LABEL_ALIGNMENT:
// indent values of default outline numbering in inch:
// 0,3 0,4 0,5 0,6 0,7
// 0,8 0,9 1,0 1,1 1,2
const long cOutlineIndentAt [ MAXLEVEL ] = {
1440 * 3 / 10 , 1440 * 2 / 5 , 1440 / 2 , 1440 * 3 / 5 , 1440 * 7 / 10 ,
1440 * 4 / 5 , 1440 * 9 / 10 , 1440 , 1440 * 11 / 10 , 1440 * 6 / 5 } ;
for ( n = 0 ; n < MAXLEVEL ; + + n )
{
pFmt = new SwNumFmt ;
pFmt - > SetNumberingType ( SVX_NUM_NUMBER_NONE ) ;
pFmt - > SetIncludeUpperLevels ( MAXLEVEL ) ;
pFmt - > SetStart ( 1 ) ;
pFmt - > SetPositionAndSpaceMode ( SvxNumberFormat : : LABEL_ALIGNMENT ) ;
pFmt - > SetLabelFollowedBy ( SvxNumberFormat : : LISTTAB ) ;
pFmt - > SetListtabPos ( cOutlineIndentAt [ n ] ) ;
pFmt - > SetFirstLineIndent ( - cOutlineIndentAt [ n ] ) ;
pFmt - > SetIndentAt ( cOutlineIndentAt [ n ] ) ;
pFmt - > SetBulletChar ( numfunc : : GetBulletChar ( n ) ) ;
SwNumRule : : aLabelAlignmentBaseFmts [ OUTLINE_RULE ] [ n ] = pFmt ;
}
2000-09-18 23:08:29 +00:00
}
memset ( aFmts , 0 , sizeof ( aFmts ) ) ;
2012-01-04 13:50:06 +01:00
OSL_ENSURE ( sName . Len ( ) , " NumRule without a name! " ) ;
2000-09-18 23:08:29 +00:00
}
SwNumRule : : SwNumRule ( const SwNumRule & rNumRule )
2008-06-13 08:38:13 +00:00
: maTxtNodeList ( ) ,
maParagraphStyleList ( ) ,
pNumRuleMap ( 0 ) ,
sName ( rNumRule . sName ) ,
eRuleType ( rNumRule . eRuleType ) ,
nPoolFmtId ( rNumRule . GetPoolFmtId ( ) ) ,
nPoolHelpId ( rNumRule . GetPoolHelpId ( ) ) ,
nPoolHlpFileId ( rNumRule . GetPoolHlpFileId ( ) ) ,
bAutoRuleFlag ( rNumRule . bAutoRuleFlag ) ,
2011-01-17 15:06:54 +01:00
bInvalidRuleFlag ( sal_True ) ,
2008-06-13 08:38:13 +00:00
bContinusNum ( rNumRule . bContinusNum ) ,
bAbsSpaces ( rNumRule . bAbsSpaces ) ,
mbCountPhantoms ( true ) ,
meDefaultNumberFormatPositionAndSpaceMode ( rNumRule . meDefaultNumberFormatPositionAndSpaceMode ) ,
msDefaultListId ( rNumRule . msDefaultListId )
2000-09-18 23:08:29 +00:00
{
+ + nRefCount ;
memset ( aFmts , 0 , sizeof ( aFmts ) ) ;
2011-01-17 15:06:54 +01:00
for ( sal_uInt16 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
if ( rNumRule . aFmts [ n ] )
Set ( n , * rNumRule . aFmts [ n ] ) ;
}
SwNumRule : : ~ SwNumRule ( )
{
2011-01-17 15:06:54 +01:00
for ( sal_uInt16 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
delete aFmts [ n ] ;
2004-11-27 10:41:31 +00:00
if ( pNumRuleMap )
{
pNumRuleMap - > erase ( GetName ( ) ) ;
}
2012-01-03 13:56:50 +01:00
if ( ! - - nRefCount ) // the last one closes the door (?)
2000-09-18 23:08:29 +00:00
{
2012-01-03 13:56:50 +01:00
// Numbering:
2000-09-18 23:08:29 +00:00
SwNumFmt * * ppFmts = ( SwNumFmt * * ) SwNumRule : : aBaseFmts ;
2003-12-01 15:36:27 +00:00
int n ;
for ( n = 0 ; n < MAXLEVEL ; + + n , + + ppFmts )
2000-09-18 23:08:29 +00:00
delete * ppFmts , * ppFmts = 0 ;
2012-01-04 13:50:06 +01:00
// Outline:
2000-09-18 23:08:29 +00:00
for ( n = 0 ; n < MAXLEVEL ; + + n , + + ppFmts )
delete * ppFmts , * ppFmts = 0 ;
2008-03-05 15:55:04 +00:00
ppFmts = ( SwNumFmt * * ) SwNumRule : : aLabelAlignmentBaseFmts ;
for ( n = 0 ; n < MAXLEVEL ; + + n , + + ppFmts )
delete * ppFmts , * ppFmts = 0 ;
for ( n = 0 ; n < MAXLEVEL ; + + n , + + ppFmts )
delete * ppFmts , * ppFmts = 0 ;
2000-09-18 23:08:29 +00:00
}
2005-11-08 16:17:38 +00:00
2008-06-13 08:38:13 +00:00
maTxtNodeList . clear ( ) ;
maParagraphStyleList . clear ( ) ;
2000-09-18 23:08:29 +00:00
}
void SwNumRule : : CheckCharFmts ( SwDoc * pDoc )
{
SwCharFmt * pFmt ;
2011-01-17 15:06:54 +01:00
for ( sal_uInt8 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
if ( aFmts [ n ] & & 0 ! = ( pFmt = aFmts [ n ] - > GetCharFmt ( ) ) & &
pFmt - > GetDoc ( ) ! = pDoc )
{
2012-01-03 13:56:50 +01:00
// copy
2000-09-18 23:08:29 +00:00
SwNumFmt * pNew = new SwNumFmt ( * aFmts [ n ] ) ;
pNew - > SetCharFmt ( pDoc - > CopyCharFmt ( * pFmt ) ) ;
delete aFmts [ n ] ;
aFmts [ n ] = pNew ;
}
}
SwNumRule & SwNumRule : : operator = ( const SwNumRule & rNumRule )
{
if ( this ! = & rNumRule )
{
2011-01-17 15:06:54 +01:00
for ( sal_uInt16 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
Set ( n , rNumRule . aFmts [ n ] ) ;
eRuleType = rNumRule . eRuleType ;
sName = rNumRule . sName ;
bAutoRuleFlag = rNumRule . bAutoRuleFlag ;
2011-01-17 15:06:54 +01:00
bInvalidRuleFlag = sal_True ;
2000-09-18 23:08:29 +00:00
bContinusNum = rNumRule . bContinusNum ;
bAbsSpaces = rNumRule . bAbsSpaces ;
nPoolFmtId = rNumRule . GetPoolFmtId ( ) ;
nPoolHelpId = rNumRule . GetPoolHelpId ( ) ;
nPoolHlpFileId = rNumRule . GetPoolHlpFileId ( ) ;
}
return * this ;
}
2011-01-17 15:06:54 +01:00
sal_Bool SwNumRule : : operator = = ( const SwNumRule & rRule ) const
2000-09-18 23:08:29 +00:00
{
2011-01-17 15:06:54 +01:00
sal_Bool bRet = eRuleType = = rRule . eRuleType & &
2000-09-18 23:08:29 +00:00
sName = = rRule . sName & &
bAutoRuleFlag = = rRule . bAutoRuleFlag & &
bContinusNum = = rRule . bContinusNum & &
bAbsSpaces = = rRule . bAbsSpaces & &
nPoolFmtId = = rRule . GetPoolFmtId ( ) & &
nPoolHelpId = = rRule . GetPoolHelpId ( ) & &
nPoolHlpFileId = = rRule . GetPoolHlpFileId ( ) ;
if ( bRet )
{
2011-01-17 15:06:54 +01:00
for ( sal_uInt8 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
if ( ! ( rRule . Get ( n ) = = Get ( n ) ) )
{
2011-01-17 15:06:54 +01:00
bRet = sal_False ;
2000-09-18 23:08:29 +00:00
break ;
}
}
return bRet ;
}
2011-01-17 15:06:54 +01:00
void SwNumRule : : Set ( sal_uInt16 i , const SwNumFmt & rNumFmt )
2000-09-18 23:08:29 +00:00
{
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( i < MAXLEVEL , " Serious defect, please inform OD " ) ;
2008-05-20 13:39:47 +00:00
if ( i < MAXLEVEL )
2000-09-18 23:08:29 +00:00
{
2008-05-20 13:39:47 +00:00
if ( ! aFmts [ i ] | | ! ( rNumFmt = = Get ( i ) ) )
{
delete aFmts [ i ] ;
aFmts [ i ] = new SwNumFmt ( rNumFmt ) ;
2011-01-17 15:06:54 +01:00
bInvalidRuleFlag = sal_True ;
2008-05-20 13:39:47 +00:00
}
2000-09-18 23:08:29 +00:00
}
}
2011-01-17 15:06:54 +01:00
void SwNumRule : : Set ( sal_uInt16 i , const SwNumFmt * pNumFmt )
2000-09-18 23:08:29 +00:00
{
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( i < MAXLEVEL , " Serious defect, please inform OD " ) ;
2008-05-20 13:39:47 +00:00
if ( i > = MAXLEVEL )
return ;
2000-09-18 23:08:29 +00:00
SwNumFmt * pOld = aFmts [ i ] ;
if ( ! pOld )
{
if ( pNumFmt )
{
aFmts [ i ] = new SwNumFmt ( * pNumFmt ) ;
2011-01-17 15:06:54 +01:00
bInvalidRuleFlag = sal_True ;
2000-09-18 23:08:29 +00:00
}
}
else if ( ! pNumFmt )
2011-01-17 15:06:54 +01:00
delete pOld , aFmts [ i ] = 0 , bInvalidRuleFlag = sal_True ;
2000-09-18 23:08:29 +00:00
else if ( * pOld ! = * pNumFmt )
2011-01-17 15:06:54 +01:00
* pOld = * pNumFmt , bInvalidRuleFlag = sal_True ;
2000-09-18 23:08:29 +00:00
}
2011-01-17 15:06:54 +01:00
String SwNumRule : : MakeNumString ( const SwNodeNum & rNum , sal_Bool bInclStrings ,
sal_Bool bOnlyArabic ) const
2000-09-18 23:08:29 +00:00
{
String aStr ;
2005-11-08 16:17:38 +00:00
if ( rNum . IsCounted ( ) )
aStr = MakeNumString ( rNum . GetNumberVector ( ) ,
2008-03-07 10:59:42 +00:00
bInclStrings , bOnlyArabic , MAXLEVEL ) ;
2005-11-08 16:17:38 +00:00
return aStr ;
}
2008-06-13 08:38:13 +00:00
String SwNumRule : : MakeNumString ( const SwNumberTree : : tNumberVector & rNumVector ,
2011-01-17 15:06:54 +01:00
const sal_Bool bInclStrings ,
const sal_Bool bOnlyArabic ,
2011-07-11 23:02:20 +10:00
const unsigned int _nRestrictToThisLevel ,
SwNumRule : : Extremities * pExtremities ) const
2005-11-08 16:17:38 +00:00
{
String aStr ;
unsigned int nLevel = rNumVector . size ( ) - 1 ;
2010-10-18 12:57:41 +01:00
2011-07-11 23:02:20 +10:00
if ( pExtremities )
pExtremities - > nPrefixChars = pExtremities - > nSuffixChars = 0 ;
2005-11-08 16:17:38 +00:00
if ( nLevel > _nRestrictToThisLevel )
{
nLevel = _nRestrictToThisLevel ;
}
2007-09-27 07:39:02 +00:00
if ( nLevel < MAXLEVEL )
2000-09-18 23:08:29 +00:00
{
2011-01-17 15:06:54 +01:00
const SwNumFmt & rMyNFmt = Get ( static_cast < sal_uInt16 > ( nLevel ) ) ;
2010-11-18 08:25:05 +01:00
2000-09-18 23:08:29 +00:00
{
2011-01-17 15:06:54 +01:00
sal_uInt8 i = static_cast < sal_uInt8 > ( nLevel ) ;
2000-09-18 23:08:29 +00:00
if ( ! IsContinusNum ( ) & &
2006-09-26 13:19:38 +00:00
// - do not include upper levels, if level isn't numbered.
rMyNFmt . GetNumberingType ( ) ! = SVX_NUM_NUMBER_NONE & &
2012-01-03 13:56:50 +01:00
rMyNFmt . GetIncludeUpperLevels ( ) ) // Just the own level?
2000-09-18 23:08:29 +00:00
{
2011-01-17 15:06:54 +01:00
sal_uInt8 n = rMyNFmt . GetIncludeUpperLevels ( ) ;
2000-09-18 23:08:29 +00:00
if ( 1 < n )
{
if ( i + 1 > = n )
i - = n - 1 ;
else
i = 0 ;
}
}
2005-11-08 16:17:38 +00:00
for ( ; i < = nLevel ; + + i )
2000-09-18 23:08:29 +00:00
{
const SwNumFmt & rNFmt = Get ( i ) ;
2001-02-23 11:45:30 +00:00
if ( SVX_NUM_NUMBER_NONE = = rNFmt . GetNumberingType ( ) )
2000-09-18 23:08:29 +00:00
{
2012-01-03 13:56:50 +01:00
// Should 1.1.1 --> 2. NoNum --> 1..1 or 1.1 ??
2005-11-08 16:17:38 +00:00
// if( i != rNum.nMyLevel )
// aStr += aDotStr;
2000-09-18 23:08:29 +00:00
continue ;
}
2005-11-08 16:17:38 +00:00
if ( rNumVector [ i ] )
2000-09-18 23:08:29 +00:00
{
if ( bOnlyArabic )
2005-11-08 16:17:38 +00:00
aStr + = String : : CreateFromInt32 ( rNumVector [ i ] ) ;
2000-09-18 23:08:29 +00:00
else
2005-11-08 16:17:38 +00:00
aStr + = rNFmt . GetNumStr ( rNumVector [ i ] ) ;
2000-09-18 23:08:29 +00:00
}
else
2012-01-03 13:56:50 +01:00
aStr + = ' 0 ' ; // all 0 level are a 0
2005-11-08 16:17:38 +00:00
if ( i ! = nLevel & & aStr . Len ( ) )
2000-09-18 23:08:29 +00:00
aStr + = aDotStr ;
}
2012-01-04 13:50:06 +01:00
// The type doesn't have any number, so don't append
// the post-/prefix string
2005-11-08 16:17:38 +00:00
if ( bInclStrings & & ! bOnlyArabic & &
SVX_NUM_CHAR_SPECIAL ! = rMyNFmt . GetNumberingType ( ) & &
SVX_NUM_BITMAP ! = rMyNFmt . GetNumberingType ( ) )
{
2011-07-11 23:02:20 +10:00
String const & rPrefix = rMyNFmt . GetPrefix ( ) ;
String const & rSuffix = rMyNFmt . GetSuffix ( ) ;
aStr . Insert ( rPrefix , 0 ) ;
aStr + = rSuffix ;
if ( pExtremities )
{
pExtremities - > nPrefixChars = rPrefix . Len ( ) ;
pExtremities - > nSuffixChars = rSuffix . Len ( ) ;
}
2005-11-08 16:17:38 +00:00
}
2000-09-18 23:08:29 +00:00
}
}
2005-11-08 16:17:38 +00:00
2000-09-18 23:08:29 +00:00
return aStr ;
}
2010-10-18 12:57:41 +01:00
2008-02-26 09:37:59 +00:00
String SwNumRule : : MakeRefNumString ( const SwNodeNum & rNodeNum ,
const bool bInclSuperiorNumLabels ,
const sal_uInt8 nRestrictInclToThisLevel ) const
{
String aRefNumStr ;
2008-06-13 08:38:13 +00:00
if ( rNodeNum . GetLevelInListTree ( ) > = 0 )
2008-02-26 09:37:59 +00:00
{
2012-11-04 02:02:46 +09:00
bool bOldHadPrefix = true ;
2012-07-06 15:57:32 +02:00
bool bFirstIteration = true ;
: : rtl : : OUString sOldPrefix ;
2011-07-11 23:02:20 +10:00
2008-02-26 09:37:59 +00:00
const SwNodeNum * pWorkingNodeNum ( & rNodeNum ) ;
do
{
bool bMakeNumStringForPhantom ( false ) ;
if ( pWorkingNodeNum - > IsPhantom ( ) )
{
2011-01-17 15:06:54 +01:00
SwNumFmt aFmt ( Get ( static_cast < sal_uInt16 > ( pWorkingNodeNum - > GetLevelInListTree ( ) ) ) ) ;
2008-02-26 09:37:59 +00:00
bMakeNumStringForPhantom = aFmt . IsEnumeration ( ) & &
SVX_NUM_NUMBER_NONE ! = aFmt . GetNumberingType ( ) ;
}
if ( bMakeNumStringForPhantom | |
( ! pWorkingNodeNum - > IsPhantom ( ) & &
pWorkingNodeNum - > GetTxtNode ( ) & &
pWorkingNodeNum - > GetTxtNode ( ) - > HasNumber ( ) ) )
{
2011-07-11 23:02:20 +10:00
Extremities aExtremities ;
String aPrevStr = MakeNumString ( pWorkingNodeNum - > GetNumberVector ( ) ,
sal_True , sal_False , MAXLEVEL ,
& aExtremities ) ;
int nStrip = 0 ;
sal_Unicode c ;
while ( nStrip < aExtremities . nPrefixChars & &
( ' \t ' = = ( c = aPrevStr . GetChar ( nStrip ) ) | |
' ' = = c ) )
{
+ + nStrip ;
}
if ( nStrip )
{
2012-07-06 15:57:32 +02:00
aPrevStr . Erase ( 0 , nStrip ) ;
aExtremities . nPrefixChars - = nStrip ;
2011-07-11 23:02:20 +10:00
}
2012-07-06 15:57:32 +02:00
if ( ( bFirstIteration | | bOldHadPrefix ) & &
2011-07-11 23:02:20 +10:00
aExtremities . nSuffixChars & &
! aExtremities . nPrefixChars
)
{
2012-07-06 15:57:32 +02:00
int nStrip2 = aPrevStr . Len ( ) ;
while ( aPrevStr . Len ( ) - nStrip2 < aExtremities . nSuffixChars )
{
char const cur = aPrevStr . GetChar ( nStrip2 ) ;
if ( ! bFirstIteration & & ' \t ' ! = cur & & ' ' ! = cur )
{
break ;
}
- - nStrip2 ;
}
if ( nStrip2 < aPrevStr . Len ( ) )
{
aPrevStr . Erase ( nStrip2 , aPrevStr . Len ( ) - nStrip2 ) ;
}
2011-07-11 23:02:20 +10:00
}
2012-07-06 15:57:32 +02:00
else if ( sOldPrefix . getLength ( ) )
{
aRefNumStr . Insert ( sOldPrefix , 0 ) ;
}
sOldPrefix = : : rtl : : OUString ( ) ;
2011-07-11 23:02:20 +10:00
bOldHadPrefix = ( aExtremities . nPrefixChars > 0 ) ;
aRefNumStr . Insert ( aPrevStr , 0 ) ;
2008-02-26 09:37:59 +00:00
}
else if ( aRefNumStr . Len ( ) > 0 )
{
2012-07-06 15:57:32 +02:00
sOldPrefix + = " " ;
2011-07-11 23:02:20 +10:00
bOldHadPrefix = true ;
2008-02-26 09:37:59 +00:00
}
2008-06-13 08:38:13 +00:00
if ( bInclSuperiorNumLabels & & pWorkingNodeNum - > GetLevelInListTree ( ) > 0 )
2008-02-26 09:37:59 +00:00
{
2011-01-17 15:06:54 +01:00
sal_uInt8 n = Get ( static_cast < sal_uInt16 > ( pWorkingNodeNum - > GetLevelInListTree ( ) ) ) . GetIncludeUpperLevels ( ) ;
2008-02-26 09:37:59 +00:00
pWorkingNodeNum = dynamic_cast < SwNodeNum * > ( pWorkingNodeNum - > GetParent ( ) ) ;
// skip parents, whose list label is already contained in the actual list label.
while ( pWorkingNodeNum & & n > 1 )
{
pWorkingNodeNum = dynamic_cast < SwNodeNum * > ( pWorkingNodeNum - > GetParent ( ) ) ;
- - n ;
}
}
else
{
break ;
}
2012-07-06 15:57:32 +02:00
bFirstIteration = false ;
2008-02-26 09:37:59 +00:00
} while ( pWorkingNodeNum & &
2008-06-13 08:38:13 +00:00
pWorkingNodeNum - > GetLevelInListTree ( ) > = 0 & &
static_cast < sal_uInt8 > ( pWorkingNodeNum - > GetLevelInListTree ( ) ) > = nRestrictInclToThisLevel ) ;
2008-02-26 09:37:59 +00:00
}
return aRefNumStr ;
}
2012-01-04 13:50:06 +01:00
// ----- Copy method of SwNumRule ------
2000-09-18 23:08:29 +00:00
2012-01-03 13:56:50 +01:00
// A kind of copy constructor, so that the num formats are attached
// to the right CharFormats of a Document.
// Copies the NumFormats and returns itself.
2000-09-18 23:08:29 +00:00
SwNumRule & SwNumRule : : CopyNumRule ( SwDoc * pDoc , const SwNumRule & rNumRule )
{
2011-01-17 15:06:54 +01:00
for ( sal_uInt16 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
{
Set ( n , rNumRule . aFmts [ n ] ) ;
if ( aFmts [ n ] & & aFmts [ n ] - > GetCharFmt ( ) & &
2012-06-20 16:36:51 +02:00
! pDoc - > GetCharFmts ( ) - > Contains ( aFmts [ n ] - > GetCharFmt ( ) ) )
2012-01-03 13:56:50 +01:00
// If we copy across different Documents, then copy the
// corresponding CharFormat into the new Document.
2000-09-18 23:08:29 +00:00
aFmts [ n ] - > SetCharFmt ( pDoc - > CopyCharFmt ( * aFmts [ n ] - >
GetCharFmt ( ) ) ) ;
}
eRuleType = rNumRule . eRuleType ;
sName = rNumRule . sName ;
bAutoRuleFlag = rNumRule . bAutoRuleFlag ;
nPoolFmtId = rNumRule . GetPoolFmtId ( ) ;
nPoolHelpId = rNumRule . GetPoolHelpId ( ) ;
nPoolHlpFileId = rNumRule . GetPoolHlpFileId ( ) ;
2011-01-17 15:06:54 +01:00
bInvalidRuleFlag = sal_True ;
2000-09-18 23:08:29 +00:00
return * this ;
}
2010-10-14 18:42:28 +05:30
2000-09-18 23:08:29 +00:00
void SwNumRule : : SetSvxRule ( const SvxNumRule & rNumRule , SwDoc * pDoc )
{
2011-01-17 15:06:54 +01:00
for ( sal_uInt16 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
{
const SvxNumberFormat * pSvxFmt = rNumRule . Get ( n ) ;
delete aFmts [ n ] ;
aFmts [ n ] = pSvxFmt ? new SwNumFmt ( * pSvxFmt , pDoc ) : 0 ;
}
2011-01-17 15:06:54 +01:00
bInvalidRuleFlag = sal_True ;
2000-09-18 23:08:29 +00:00
bContinusNum = rNumRule . IsContinuousNumbering ( ) ;
}
2010-10-14 18:42:28 +05:30
2000-09-18 23:08:29 +00:00
SvxNumRule SwNumRule : : MakeSvxNumRule ( ) const
{
SvxNumRule aRule ( NUM_CONTINUOUS | NUM_CHAR_TEXT_DISTANCE | NUM_CHAR_STYLE |
NUM_ENABLE_LINKED_BMP | NUM_ENABLE_EMBEDDED_BMP ,
2007-09-27 07:39:02 +00:00
MAXLEVEL , bContinusNum ,
2000-09-18 23:08:29 +00:00
eRuleType = =
NUM_RULE ?
SVX_RULETYPE_NUMBERING :
SVX_RULETYPE_OUTLINE_NUMBERING ) ;
2011-01-17 15:06:54 +01:00
for ( sal_uInt16 n = 0 ; n < MAXLEVEL ; + + n )
2000-09-18 23:08:29 +00:00
{
2001-07-09 12:35:49 +00:00
SwNumFmt aNumFmt = Get ( n ) ;
if ( aNumFmt . GetCharFmt ( ) )
aNumFmt . SetCharFmtName ( aNumFmt . GetCharFmt ( ) - > GetName ( ) ) ;
aRule . SetLevel ( n , aNumFmt , aFmts [ n ] ! = 0 ) ;
2000-09-18 23:08:29 +00:00
}
return aRule ;
}
2011-01-17 15:06:54 +01:00
void SwNumRule : : SetInvalidRule ( sal_Bool bFlag )
2004-10-22 07:12:03 +00:00
{
2005-11-08 16:17:38 +00:00
if ( bFlag )
2004-10-22 07:12:03 +00:00
{
2008-06-13 08:38:13 +00:00
std : : set < SwList * > aLists ;
tTxtNodeList : : iterator aIter ;
for ( aIter = maTxtNodeList . begin ( ) ; aIter ! = maTxtNodeList . end ( ) ; + + aIter )
2005-11-08 16:17:38 +00:00
{
2008-06-13 08:38:13 +00:00
const SwTxtNode * pTxtNode = * aIter ;
2011-02-02 20:41:40 +09:00
// #i111681# - applying patch from cmc
2010-06-04 10:10:57 +02:00
SwList * pList = pTxtNode - > GetDoc ( ) - > getListByName ( pTxtNode - > GetListId ( ) ) ;
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( pList , " <SwNumRule::SetInvalidRule(..)> - list at which the text node is registered at does not exist. This is a serious issue --> please inform OD. " ) ;
2010-06-04 10:10:57 +02:00
if ( pList )
{
aLists . insert ( pList ) ;
}
2005-11-08 16:17:38 +00:00
}
2008-06-13 08:38:13 +00:00
std : : for_each ( aLists . begin ( ) , aLists . end ( ) ,
std : : mem_fun ( & SwList : : InvalidateListTree ) ) ;
2004-10-22 07:12:03 +00:00
}
bInvalidRuleFlag = bFlag ;
}
2000-09-18 23:08:29 +00:00
2008-07-08 07:21:48 +00:00
// change indent of all list levels by given difference
void SwNumRule : : ChangeIndent ( const short nDiff )
2004-04-07 11:43:33 +00:00
{
2011-01-17 15:06:54 +01:00
for ( sal_uInt16 i = 0 ; i < MAXLEVEL ; + + i )
2004-04-07 11:43:33 +00:00
{
2008-07-08 07:21:48 +00:00
SwNumFmt aTmpNumFmt ( Get ( i ) ) ;
2004-04-07 11:43:33 +00:00
2008-07-08 07:21:48 +00:00
const SvxNumberFormat : : SvxNumPositionAndSpaceMode ePosAndSpaceMode (
aTmpNumFmt . GetPositionAndSpaceMode ( ) ) ;
if ( ePosAndSpaceMode = = SvxNumberFormat : : LABEL_WIDTH_AND_POSITION )
{
short nNewIndent = nDiff +
aTmpNumFmt . GetAbsLSpace ( ) ;
if ( nNewIndent < 0 )
2004-04-07 11:43:33 +00:00
{
2008-07-08 07:21:48 +00:00
nNewIndent = 0 ;
2004-04-07 11:43:33 +00:00
}
2008-07-08 07:21:48 +00:00
aTmpNumFmt . SetAbsLSpace ( nNewIndent ) ;
}
else if ( ePosAndSpaceMode = = SvxNumberFormat : : LABEL_ALIGNMENT )
{
2009-02-13 10:05:35 +00:00
// adjust also the list tab position, if a list tab stop is applied
if ( aTmpNumFmt . GetLabelFollowedBy ( ) = = SvxNumberFormat : : LISTTAB )
{
const long nNewListTab = aTmpNumFmt . GetListtabPos ( ) + nDiff ;
aTmpNumFmt . SetListtabPos ( nNewListTab ) ;
}
2010-10-18 12:57:41 +01:00
2009-02-13 10:05:35 +00:00
const long nNewIndent = nDiff +
2008-07-08 07:21:48 +00:00
aTmpNumFmt . GetIndentAt ( ) ;
aTmpNumFmt . SetIndentAt ( nNewIndent ) ;
}
Set ( i , aTmpNumFmt ) ;
2004-04-07 11:43:33 +00:00
}
2011-01-17 15:06:54 +01:00
SetInvalidRule ( sal_True ) ;
2008-07-08 07:21:48 +00:00
}
2004-04-07 11:43:33 +00:00
2008-07-08 07:21:48 +00:00
// set indent of certain list level to given value
void SwNumRule : : SetIndent ( const short nNewIndent ,
2011-01-17 15:06:54 +01:00
const sal_uInt16 nListLevel )
2008-07-08 07:21:48 +00:00
{
SwNumFmt aTmpNumFmt ( Get ( nListLevel ) ) ;
2004-04-07 11:43:33 +00:00
2008-07-08 07:21:48 +00:00
const SvxNumberFormat : : SvxNumPositionAndSpaceMode ePosAndSpaceMode (
aTmpNumFmt . GetPositionAndSpaceMode ( ) ) ;
if ( ePosAndSpaceMode = = SvxNumberFormat : : LABEL_WIDTH_AND_POSITION )
{
aTmpNumFmt . SetAbsLSpace ( nNewIndent ) ;
}
else if ( ePosAndSpaceMode = = SvxNumberFormat : : LABEL_ALIGNMENT )
{
2009-02-13 10:05:35 +00:00
// adjust also the list tab position, if a list tab stop is applied
if ( aTmpNumFmt . GetLabelFollowedBy ( ) = = SvxNumberFormat : : LISTTAB )
{
const long nNewListTab = aTmpNumFmt . GetListtabPos ( ) +
( nNewIndent - aTmpNumFmt . GetIndentAt ( ) ) ;
aTmpNumFmt . SetListtabPos ( nNewListTab ) ;
}
2010-10-18 12:57:41 +01:00
2008-07-08 07:21:48 +00:00
aTmpNumFmt . SetIndentAt ( nNewIndent ) ;
}
2004-04-07 11:43:33 +00:00
2011-01-17 15:06:54 +01:00
SetInvalidRule ( sal_True ) ;
2008-07-08 07:21:48 +00:00
}
2004-04-07 11:43:33 +00:00
2008-07-08 07:21:48 +00:00
// set indent of first list level to given value and change other list level's
// indents accordingly
void SwNumRule : : SetIndentOfFirstListLevelAndChangeOthers ( const short nNewIndent )
{
SwNumFmt aTmpNumFmt ( Get ( 0 ) ) ;
2004-04-07 11:43:33 +00:00
2008-07-08 07:21:48 +00:00
short nDiff ( 0 ) ;
const SvxNumberFormat : : SvxNumPositionAndSpaceMode ePosAndSpaceMode (
aTmpNumFmt . GetPositionAndSpaceMode ( ) ) ;
if ( ePosAndSpaceMode = = SvxNumberFormat : : LABEL_WIDTH_AND_POSITION )
{
nDiff = nNewIndent
- aTmpNumFmt . GetFirstLineOffset ( )
- aTmpNumFmt . GetAbsLSpace ( ) ;
}
else if ( ePosAndSpaceMode = = SvxNumberFormat : : LABEL_ALIGNMENT )
{
nDiff = static_cast < short > ( nNewIndent
- aTmpNumFmt . GetIndentAt ( ) ) ;
}
if ( nDiff ! = 0 )
{
ChangeIndent ( nDiff ) ;
2004-04-07 11:43:33 +00:00
}
}
2010-10-18 12:57:41 +01:00
2005-02-22 09:02:55 +00:00
2008-06-13 08:38:13 +00:00
void SwNumRule : : Validate ( )
2005-11-08 16:17:38 +00:00
{
2008-06-13 08:38:13 +00:00
std : : set < SwList * > aLists ;
tTxtNodeList : : iterator aIter ;
for ( aIter = maTxtNodeList . begin ( ) ; aIter ! = maTxtNodeList . end ( ) ; + + aIter )
{
const SwTxtNode * pTxtNode = * aIter ;
aLists . insert ( pTxtNode - > GetDoc ( ) - > getListByName ( pTxtNode - > GetListId ( ) ) ) ;
}
std : : for_each ( aLists . begin ( ) , aLists . end ( ) ,
std : : mem_fun ( & SwList : : ValidateListTree ) ) ;
2010-10-18 12:57:41 +01:00
2005-11-08 16:17:38 +00:00
2011-01-17 15:06:54 +01:00
SetInvalidRule ( sal_False ) ;
2005-11-08 16:17:38 +00:00
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
bool SwNumRule : : IsCountPhantoms ( ) const
2005-11-08 16:17:38 +00:00
{
2008-06-13 08:38:13 +00:00
return mbCountPhantoms ;
2005-11-08 16:17:38 +00:00
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
void SwNumRule : : SetCountPhantoms ( bool bCountPhantoms )
2005-11-08 16:17:38 +00:00
{
2008-06-13 08:38:13 +00:00
mbCountPhantoms = bCountPhantoms ;
}
2005-11-08 16:17:38 +00:00
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
SwNumRule : : tParagraphStyleList : : size_type SwNumRule : : GetParagraphStyleListSize ( ) const
{
return maParagraphStyleList . size ( ) ;
2005-11-08 16:17:38 +00:00
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
void SwNumRule : : AddParagraphStyle ( SwTxtFmtColl & rTxtFmtColl )
2005-11-08 16:17:38 +00:00
{
2008-06-13 08:38:13 +00:00
tParagraphStyleList : : iterator aIter =
std : : find ( maParagraphStyleList . begin ( ) , maParagraphStyleList . end ( ) , & rTxtFmtColl ) ;
if ( aIter = = maParagraphStyleList . end ( ) )
{
maParagraphStyleList . push_back ( & rTxtFmtColl ) ;
}
2005-11-08 16:17:38 +00:00
}
2010-10-18 12:57:41 +01:00
2008-06-13 08:38:13 +00:00
void SwNumRule : : RemoveParagraphStyle ( SwTxtFmtColl & rTxtFmtColl )
2005-11-08 16:17:38 +00:00
{
2008-06-13 08:38:13 +00:00
tParagraphStyleList : : iterator aIter =
std : : find ( maParagraphStyleList . begin ( ) , maParagraphStyleList . end ( ) , & rTxtFmtColl ) ;
if ( aIter ! = maParagraphStyleList . end ( ) )
{
maParagraphStyleList . erase ( aIter ) ;
}
2005-11-08 16:17:38 +00:00
}
2010-10-18 12:57:41 +01:00
2006-07-25 10:47:05 +00:00
namespace numfunc
{
/** class containing default bullet list configuration data
@ author OD
*/
class SwDefBulletConfig : private utl : : ConfigItem
{
public :
2011-05-16 23:33:23 +01:00
static SwDefBulletConfig & getInstance ( ) ;
2006-07-25 10:47:05 +00:00
inline const String & GetFontname ( ) const
{
return msFontname ;
}
2010-10-18 12:57:41 +01:00
2008-10-10 13:02:43 +00:00
inline bool IsFontnameUserDefined ( ) const
2008-07-08 07:21:48 +00:00
{
return mbUserDefinedFontname ;
}
2010-10-18 12:57:41 +01:00
2006-07-25 10:47:05 +00:00
inline const Font & GetFont ( ) const
{
return * mpFont ;
}
2010-10-18 12:57:41 +01:00
2008-10-10 13:02:43 +00:00
inline short GetFontWeight ( ) const
2006-07-25 10:47:05 +00:00
{
2007-09-27 07:39:02 +00:00
return static_cast < short > ( meFontWeight ) ;
2006-07-25 10:47:05 +00:00
}
2010-10-18 12:57:41 +01:00
2008-10-10 13:02:43 +00:00
inline short GetFontItalic ( ) const
2006-07-25 10:47:05 +00:00
{
2007-09-27 07:39:02 +00:00
return static_cast < short > ( meFontItalic ) ;
2006-07-25 10:47:05 +00:00
}
2011-01-17 15:06:54 +01:00
inline sal_Unicode GetChar ( sal_uInt8 p_nListLevel ) const
2006-07-25 10:47:05 +00:00
{
2012-07-27 17:30:57 +02:00
if ( p_nListLevel > = MAXLEVEL )
2006-07-25 10:47:05 +00:00
{
2012-07-27 17:30:57 +02:00
p_nListLevel = MAXLEVEL - 1 ;
2006-07-25 10:47:05 +00:00
}
return mnLevelChars [ p_nListLevel ] ;
}
SwDefBulletConfig ( ) ;
2011-05-16 23:33:23 +01:00
~ SwDefBulletConfig ( ) ;
private :
2006-07-25 10:47:05 +00:00
/** sets internal default bullet configuration data to default values
@ author OD
*/
void SetToDefault ( ) ;
/** returns sequence of default bullet configuration property names
@ author OD
*/
2007-09-27 07:39:02 +00:00
uno : : Sequence < rtl : : OUString > GetPropNames ( ) const ;
2006-07-25 10:47:05 +00:00
/** loads default bullet configuration properties and applies
values to internal data
@ author OD
*/
void LoadConfig ( ) ;
/** initialize font instance for default bullet list
@ author OD
*/
void InitFont ( ) ;
/** catches notification about changed default bullet configuration data
@ author OD
*/
2007-09-27 07:39:02 +00:00
virtual void Notify ( const uno : : Sequence < rtl : : OUString > & aPropertyNames ) ;
2009-10-16 00:05:16 +02:00
virtual void Commit ( ) ;
2006-07-25 10:47:05 +00:00
// default bullet list configuration data
String msFontname ;
2008-07-08 07:21:48 +00:00
bool mbUserDefinedFontname ;
2006-07-25 10:47:05 +00:00
FontWeight meFontWeight ;
FontItalic meFontItalic ;
sal_Unicode mnLevelChars [ MAXLEVEL ] ;
// default bullet list font instance
Font * mpFont ;
} ;
2011-05-16 23:33:23 +01:00
namespace
{
class theSwDefBulletConfig
: public rtl : : Static < SwDefBulletConfig , theSwDefBulletConfig > { } ;
}
SwDefBulletConfig & SwDefBulletConfig : : getInstance ( )
{
return theSwDefBulletConfig : : get ( ) ;
}
2006-07-25 10:47:05 +00:00
SwDefBulletConfig : : SwDefBulletConfig ( )
2010-10-27 11:38:46 +01:00
: ConfigItem ( rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Office.Writer/Numbering/DefaultBulletList " ) ) ) ,
2008-07-08 07:21:48 +00:00
// default bullet font is now OpenSymbol
2012-07-02 16:02:38 +01:00
msFontname ( rtl : : OUString ( " OpenSymbol " ) ) ,
2008-07-08 07:21:48 +00:00
mbUserDefinedFontname ( false ) ,
2006-07-25 10:47:05 +00:00
meFontWeight ( WEIGHT_DONTKNOW ) ,
meFontItalic ( ITALIC_NONE ) ,
2007-10-15 16:32:53 +00:00
mpFont ( 0 )
2006-07-25 10:47:05 +00:00
{
SetToDefault ( ) ;
LoadConfig ( ) ;
InitFont ( ) ;
// enable notification for changes on default bullet configuration change
EnableNotification ( GetPropNames ( ) ) ;
}
2011-05-16 23:33:23 +01:00
SwDefBulletConfig : : ~ SwDefBulletConfig ( )
{
delete mpFont ;
}
2006-07-25 10:47:05 +00:00
void SwDefBulletConfig : : SetToDefault ( )
{
2012-07-02 16:02:38 +01:00
msFontname = rtl : : OUString ( " OpenSymbol " ) ;
2008-07-08 07:21:48 +00:00
mbUserDefinedFontname = false ;
2006-07-25 10:47:05 +00:00
meFontWeight = WEIGHT_DONTKNOW ;
meFontItalic = ITALIC_NONE ;
2008-07-08 07:21:48 +00:00
mnLevelChars [ 0 ] = 0x2022 ;
mnLevelChars [ 1 ] = 0x25e6 ;
mnLevelChars [ 2 ] = 0x25aa ;
mnLevelChars [ 3 ] = 0x2022 ;
mnLevelChars [ 4 ] = 0x25e6 ;
mnLevelChars [ 5 ] = 0x25aa ;
mnLevelChars [ 6 ] = 0x2022 ;
mnLevelChars [ 7 ] = 0x25e6 ;
mnLevelChars [ 8 ] = 0x25aa ;
mnLevelChars [ 9 ] = 0x2022 ;
2006-07-25 10:47:05 +00:00
}
2007-09-27 07:39:02 +00:00
uno : : Sequence < rtl : : OUString > SwDefBulletConfig : : GetPropNames ( ) const
2006-07-25 10:47:05 +00:00
{
2007-09-27 07:39:02 +00:00
uno : : Sequence < rtl : : OUString > aPropNames ( 13 ) ;
2006-07-25 10:47:05 +00:00
rtl : : OUString * pNames = aPropNames . getArray ( ) ;
2010-10-27 11:38:46 +01:00
pNames [ 0 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletFont/FontFamilyname " ) ) ;
pNames [ 1 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletFont/FontWeight " ) ) ;
pNames [ 2 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletFont/FontItalic " ) ) ;
pNames [ 3 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl1 " ) ) ;
pNames [ 4 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl2 " ) ) ;
pNames [ 5 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl3 " ) ) ;
pNames [ 6 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl4 " ) ) ;
pNames [ 7 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl5 " ) ) ;
pNames [ 8 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl6 " ) ) ;
pNames [ 9 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl7 " ) ) ;
pNames [ 10 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl8 " ) ) ;
pNames [ 11 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl9 " ) ) ;
pNames [ 12 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " BulletCharLvl10 " ) ) ;
2006-07-25 10:47:05 +00:00
return aPropNames ;
}
void SwDefBulletConfig : : LoadConfig ( )
{
2007-09-27 07:39:02 +00:00
uno : : Sequence < rtl : : OUString > aPropNames = GetPropNames ( ) ;
uno : : Sequence < uno : : Any > aValues =
2006-07-25 10:47:05 +00:00
GetProperties ( aPropNames ) ;
2007-09-27 07:39:02 +00:00
const uno : : Any * pValues = aValues . getConstArray ( ) ;
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( aValues . getLength ( ) = = aPropNames . getLength ( ) ,
" <SwDefBulletConfig::SwDefBulletConfig()> - GetProperties failed " ) ;
2006-07-25 10:47:05 +00:00
if ( aValues . getLength ( ) = = aPropNames . getLength ( ) )
{
for ( int nProp = 0 ; nProp < aPropNames . getLength ( ) ; + + nProp )
{
if ( pValues [ nProp ] . hasValue ( ) )
{
switch ( nProp )
{
case 0 :
{
rtl : : OUString aStr ;
pValues [ nProp ] > > = aStr ;
msFontname = aStr ;
2008-07-08 07:21:48 +00:00
mbUserDefinedFontname = true ;
2006-07-25 10:47:05 +00:00
}
break ;
case 1 :
case 2 :
{
2007-11-12 15:22:42 +00:00
sal_uInt8 nTmp = 0 ;
2006-07-25 10:47:05 +00:00
pValues [ nProp ] > > = nTmp ;
if ( nProp = = 1 )
meFontWeight = static_cast < FontWeight > ( nTmp ) ;
else if ( nProp = = 2 )
meFontItalic = static_cast < FontItalic > ( nTmp ) ;
}
break ;
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
case 8 :
case 9 :
case 10 :
case 11 :
case 12 :
{
2007-11-12 15:22:42 +00:00
sal_Unicode cChar = sal_Unicode ( ) ;
2006-07-25 10:47:05 +00:00
pValues [ nProp ] > > = cChar ;
mnLevelChars [ nProp - 3 ] = cChar ;
}
break ;
}
}
}
}
}
void SwDefBulletConfig : : InitFont ( )
{
delete mpFont ;
mpFont = new Font ( msFontname , aEmptyStr , Size ( 0 , 14 ) ) ;
mpFont - > SetWeight ( meFontWeight ) ;
mpFont - > SetItalic ( meFontItalic ) ;
}
2007-09-27 07:39:02 +00:00
void SwDefBulletConfig : : Notify ( const uno : : Sequence < rtl : : OUString > & )
2006-07-25 10:47:05 +00:00
{
SetToDefault ( ) ;
LoadConfig ( ) ;
InitFont ( ) ;
}
2009-10-16 00:05:16 +02:00
void SwDefBulletConfig : : Commit ( )
{
}
2006-07-25 10:47:05 +00:00
const String & GetDefBulletFontname ( )
{
2011-05-16 23:33:23 +01:00
return SwDefBulletConfig : : getInstance ( ) . GetFontname ( ) ;
2006-07-25 10:47:05 +00:00
}
2008-10-10 13:02:43 +00:00
bool IsDefBulletFontUserDefined ( )
2008-07-08 07:21:48 +00:00
{
2011-05-16 23:33:23 +01:00
return SwDefBulletConfig : : getInstance ( ) . IsFontnameUserDefined ( ) ;
2008-07-08 07:21:48 +00:00
}
2006-07-25 10:47:05 +00:00
const Font & GetDefBulletFont ( )
{
2011-05-16 23:33:23 +01:00
return SwDefBulletConfig : : getInstance ( ) . GetFont ( ) ;
2006-07-25 10:47:05 +00:00
}
2011-01-17 15:06:54 +01:00
sal_Unicode GetBulletChar ( sal_uInt8 nLevel )
2006-07-25 10:47:05 +00:00
{
2011-05-16 23:33:23 +01:00
return SwDefBulletConfig : : getInstance ( ) . GetChar ( nLevel ) ;
2006-07-25 10:47:05 +00:00
}
2007-10-15 16:32:53 +00:00
/** class containing configuration data about user interface behavior
regarding lists and list items .
configuration item about behavior of < TAB > / < SHIFT - TAB > - key at first
position of first list item
@ author OD
*/
class SwNumberingUIBehaviorConfig : private utl : : ConfigItem
{
public :
2011-05-16 23:33:23 +01:00
static SwNumberingUIBehaviorConfig & getInstance ( ) ;
2007-10-15 16:32:53 +00:00
2008-10-10 13:02:43 +00:00
inline sal_Bool ChangeIndentOnTabAtFirstPosOfFirstListItem ( ) const
2007-10-15 16:32:53 +00:00
{
return mbChangeIndentOnTabAtFirstPosOfFirstListItem ;
}
SwNumberingUIBehaviorConfig ( ) ;
2011-05-16 23:33:23 +01:00
private :
2007-10-15 16:32:53 +00:00
/** sets internal configuration data to default values
@ author OD
*/
void SetToDefault ( ) ;
/** returns sequence of configuration property names
@ author OD
*/
com : : sun : : star : : uno : : Sequence < rtl : : OUString > GetPropNames ( ) const ;
/** loads configuration properties and applies values to internal data
@ author OD
*/
void LoadConfig ( ) ;
/** catches notification about changed configuration data
@ author OD
*/
virtual void Notify ( const com : : sun : : star : : uno : : Sequence < rtl : : OUString > & aPropertyNames ) ;
2009-10-16 00:05:16 +02:00
virtual void Commit ( ) ;
2007-10-15 16:32:53 +00:00
// configuration data
sal_Bool mbChangeIndentOnTabAtFirstPosOfFirstListItem ;
} ;
2011-05-16 23:33:23 +01:00
namespace
{
class theSwNumberingUIBehaviorConfig : public rtl : : Static < SwNumberingUIBehaviorConfig , theSwNumberingUIBehaviorConfig > { } ;
}
SwNumberingUIBehaviorConfig & SwNumberingUIBehaviorConfig : : getInstance ( )
{
return theSwNumberingUIBehaviorConfig : : get ( ) ;
}
2007-10-15 16:32:53 +00:00
SwNumberingUIBehaviorConfig : : SwNumberingUIBehaviorConfig ( )
2010-10-27 11:38:46 +01:00
: ConfigItem ( rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Office.Writer/Numbering/UserInterfaceBehavior " ) ) ) ,
2007-10-15 16:32:53 +00:00
mbChangeIndentOnTabAtFirstPosOfFirstListItem ( sal_True )
{
SetToDefault ( ) ;
LoadConfig ( ) ;
// enable notification for changes on configuration change
EnableNotification ( GetPropNames ( ) ) ;
}
void SwNumberingUIBehaviorConfig : : SetToDefault ( )
{
mbChangeIndentOnTabAtFirstPosOfFirstListItem = sal_True ;
}
com : : sun : : star : : uno : : Sequence < rtl : : OUString > SwNumberingUIBehaviorConfig : : GetPropNames ( ) const
{
com : : sun : : star : : uno : : Sequence < rtl : : OUString > aPropNames ( 1 ) ;
rtl : : OUString * pNames = aPropNames . getArray ( ) ;
2010-10-27 11:38:46 +01:00
pNames [ 0 ] = rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " ChangeIndentOnTabAtFirstPosOfFirstListItem " ) ) ;
2007-10-15 16:32:53 +00:00
return aPropNames ;
}
2009-10-16 00:05:16 +02:00
void SwNumberingUIBehaviorConfig : : Commit ( ) { }
2007-10-15 16:32:53 +00:00
void SwNumberingUIBehaviorConfig : : LoadConfig ( )
{
com : : sun : : star : : uno : : Sequence < rtl : : OUString > aPropNames = GetPropNames ( ) ;
com : : sun : : star : : uno : : Sequence < com : : sun : : star : : uno : : Any > aValues =
GetProperties ( aPropNames ) ;
const com : : sun : : star : : uno : : Any * pValues = aValues . getConstArray ( ) ;
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( aValues . getLength ( ) = = aPropNames . getLength ( ) ,
" <SwNumberingUIBehaviorConfig::LoadConfig()> - GetProperties failed " ) ;
2007-10-15 16:32:53 +00:00
if ( aValues . getLength ( ) = = aPropNames . getLength ( ) )
{
for ( int nProp = 0 ; nProp < aPropNames . getLength ( ) ; + + nProp )
{
if ( pValues [ nProp ] . hasValue ( ) )
{
switch ( nProp )
{
case 0 :
{
pValues [ nProp ] > > = mbChangeIndentOnTabAtFirstPosOfFirstListItem ;
}
break ;
default :
{
2011-03-12 11:51:35 +01:00
OSL_FAIL ( " <SwNumberingUIBehaviorConfig::LoadConfig()> - unknown configuration property " ) ;
2007-10-15 16:32:53 +00:00
}
}
}
}
}
}
void SwNumberingUIBehaviorConfig : : Notify ( const com : : sun : : star : : uno : : Sequence < rtl : : OUString > & aPropertyNames )
{
2007-10-18 09:47:45 +00:00
( void ) aPropertyNames ;
2007-10-15 16:32:53 +00:00
SetToDefault ( ) ;
LoadConfig ( ) ;
}
2008-10-10 13:02:43 +00:00
sal_Bool ChangeIndentOnTabAtFirstPosOfFirstListItem ( )
2007-10-15 16:32:53 +00:00
{
2011-05-16 23:33:23 +01:00
return SwNumberingUIBehaviorConfig : : getInstance ( ) . ChangeIndentOnTabAtFirstPosOfFirstListItem ( ) ;
2007-10-15 16:32:53 +00:00
}
2008-07-08 07:21:48 +00:00
2008-10-10 13:02:43 +00:00
SvxNumberFormat : : SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode ( )
2008-07-08 07:21:48 +00:00
{
SvxNumberFormat : : SvxNumPositionAndSpaceMode ePosAndSpaceMode ;
SvtSaveOptions aSaveOptions ;
switch ( aSaveOptions . GetODFDefaultVersion ( ) )
{
case SvtSaveOptions : : ODFVER_010 :
case SvtSaveOptions : : ODFVER_011 :
{
ePosAndSpaceMode = SvxNumberFormat : : LABEL_WIDTH_AND_POSITION ;
}
break ;
default : // ODFVER_UNKNOWN or ODFVER_012
{
ePosAndSpaceMode = SvxNumberFormat : : LABEL_ALIGNMENT ;
}
}
return ePosAndSpaceMode ;
}
2006-07-25 10:47:05 +00:00
}
2010-10-14 08:30:41 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */