1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: numrule.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #ifndef _LINK_HXX //autogen
35 #include <tools/link.hxx>
37 #ifndef _SV_GEN_HXX //autogen wg. Size
38 #include <tools/gen.hxx>
40 #ifndef _STRING_HXX //autogen
41 #include <tools/string.hxx>
43 #ifndef _SVX_SVXENUM_HXX //autogen
44 #include <bf_svx/svxenum.hxx>
48 #include <swtypes.hxx>
54 #include <errhdl.hxx> // Fuer die inline-ASSERTs
57 #include <error.h> // Fuer die inline-ASSERTs
59 #ifndef _SVX_NUMITEM_HXX
60 #include <bf_svx/numitem.hxx>
70 class SwFmtVertOrient
;
74 extern char __FAR_DATA sOutlineStr
[]; // SWG-Filter
76 inline BYTE
GetRealLevel( const BYTE nLvl
)
78 return nLvl
& (NO_NUMLEVEL
- 1);
80 const sal_Unicode cBulletChar
= 0x2022; // Charakter fuer Aufzaehlungen
82 class SwNumFmt
: public SvxNumberFormat
, public SwClient
84 SwFmtVertOrient
* pVertOrient
;
86 void UpdateNumNodes( SwDoc
* pDoc
);
87 virtual void NotifyGraphicArrived();
90 SwNumFmt( const SwNumFmt
& );
91 SwNumFmt( const SvxNumberFormat
&, SwDoc
* pDoc
);
95 SwNumFmt
& operator=( const SwNumFmt
& );
96 BOOL
operator==( const SwNumFmt
& ) const;
97 BOOL
operator!=( const SwNumFmt
& r
) const { return !(*this == r
); }
99 const Graphic
* GetGraphic() const;
101 SwCharFmt
* GetCharFmt() const { return (SwCharFmt
*)pRegisteredIn
; }
102 void SetCharFmt( SwCharFmt
* );
103 virtual void Modify( SfxPoolItem
* pOld
, SfxPoolItem
* pNew
);
105 virtual void SetCharFmtName(const String
& rSet
);
106 virtual const String
& GetCharFmtName()const;
108 virtual void SetGraphicBrush( const SvxBrushItem
* pBrushItem
, const Size
* pSize
= 0, const SvxFrameVertOrient
* pOrient
= 0);
110 virtual void SetVertOrient(SvxFrameVertOrient eSet
);
111 virtual SvxFrameVertOrient
GetVertOrient() const;
112 const SwFmtVertOrient
* GetGraphicOrientation() const;
115 enum SwNumRuleType
{ OUTLINE_RULE
= 0, NUM_RULE
= 1, RULE_END
= 2 };
118 friend void _FinitCore();
120 static SwNumFmt
* aBaseFmts
[ RULE_END
][ MAXLEVEL
];
121 static USHORT aDefNumIndents
[ MAXLEVEL
];
122 static USHORT nRefCount
;
123 static Font
* pDefBulletFont
;
124 static char* pDefOutlineName
;
126 SwNumFmt
* aFmts
[ MAXLEVEL
];
129 SwNumRuleType eRuleType
;
130 USHORT nPoolFmtId
; // Id-fuer "automatich" erzeugte NumRules
131 USHORT nPoolHelpId
; // HelpId fuer diese Pool-Vorlage
132 BYTE nPoolHlpFileId
; // FilePos ans Doc auf die Vorlagen-Hilfen
133 BOOL bAutoRuleFlag
: 1;
134 BOOL bInvalidRuleFlag
: 1;
135 BOOL bContinusNum
: 1; // Fortlaufende Numerierung - ohne Ebenen
136 BOOL bAbsSpaces
: 1; // die Ebenen repraesentieren absol. Einzuege
138 static void _MakeDefBulletFont();
141 SwNumRule( const String
& rNm
, SwNumRuleType
= NUM_RULE
,
142 BOOL bAutoFlg
= TRUE
);
144 SwNumRule( const SwNumRule
& );
147 SwNumRule
& operator=( const SwNumRule
& );
148 BOOL
operator==( const SwNumRule
& ) const;
149 BOOL
operator!=( const SwNumRule
& r
) const { return !(*this == r
); }
151 inline const SwNumFmt
* GetNumFmt( USHORT i
) const;
152 inline const SwNumFmt
& Get( USHORT i
) const;
153 void Set( USHORT i
, const SwNumFmt
* );
154 void Set( USHORT i
, const SwNumFmt
& );
155 String
MakeNumString( const SwNodeNum
&, BOOL bInclStrings
= TRUE
,
156 BOOL bOnlyArabic
= FALSE
) const;
158 inline sal_Unicode
GetBulletChar( const SwNodeNum
& ) const;
159 inline const Font
* GetBulletFont( const SwNodeNum
& ) const;
160 static inline const Font
& GetDefBulletFont();
162 static char* GetOutlineRuleName() { return pDefOutlineName
; }
164 static inline USHORT
GetNumIndent( BYTE nLvl
);
165 static inline USHORT
GetBullIndent( BYTE nLvl
);
167 SwNumRuleType
GetRuleType() const { return eRuleType
; }
168 void SetRuleType( SwNumRuleType eNew
) { eRuleType
= eNew
;
169 bInvalidRuleFlag
= TRUE
; }
171 // eine Art Copy-Constructor, damit die Num-Formate auch an den
172 // richtigen CharFormaten eines Dokumentes haengen !!
173 // (Kopiert die NumFormate und returnt sich selbst)
174 SwNumRule
& CopyNumRule( SwDoc
*, const SwNumRule
& );
176 // testet ob die CharFormate aus dem angegeben Doc sind und kopiert
178 void CheckCharFmts( SwDoc
* pDoc
);
180 // test ob der Einzug von dieser Numerierung kommt.
181 BOOL
IsRuleLSpace( SwTxtNode
& rNd
) const;
183 const String
& GetName() const { return sName
; }
184 void SetName( const String
& rNm
) { sName
= rNm
; }
186 BOOL
IsAutoRule() const { return bAutoRuleFlag
; }
187 void SetAutoRule( BOOL bFlag
) { bAutoRuleFlag
= bFlag
; }
189 BOOL
IsInvalidRule() const { return bInvalidRuleFlag
; }
190 void SetInvalidRule( BOOL bFlag
) { bInvalidRuleFlag
= bFlag
; }
192 BOOL
IsContinusNum() const { return bContinusNum
; }
193 void SetContinusNum( BOOL bFlag
) { bContinusNum
= bFlag
; }
195 BOOL
IsAbsSpaces() const { return bAbsSpaces
; }
196 void SetAbsSpaces( BOOL bFlag
) { bAbsSpaces
= bFlag
; }
198 // erfragen und setzen der Poolvorlagen-Id's
199 USHORT
GetPoolFmtId() const { return nPoolFmtId
; }
200 void SetPoolFmtId( USHORT nId
) { nPoolFmtId
= nId
; }
202 // erfragen und setzen der Hilfe-Id's fuer die Document-Vorlagen
203 USHORT
GetPoolHelpId() const { return nPoolHelpId
; }
204 void SetPoolHelpId( USHORT nId
) { nPoolHelpId
= nId
; }
205 BYTE
GetPoolHlpFileId() const { return nPoolHlpFileId
; }
206 void SetPoolHlpFileId( BYTE nId
) { nPoolHlpFileId
= nId
; }
209 #109308# Sets adjustment in all formats of the numbering rule.
211 @param eNum adjustment to be set
213 void SetNumAdjust(SvxAdjust eNum
);
215 void SetSvxRule(const SvxNumRule
&, SwDoc
* pDoc
);
216 SvxNumRule
MakeSvxNumRule() const;
222 USHORT nLevelVal
[ MAXLEVEL
]; // Nummern aller Levels
223 USHORT nSetValue
; // vorgegeben Nummer
224 BYTE nMyLevel
; // akt. Level
225 BOOL bStartNum
; // Numerierung neu starten
228 inline SwNodeNum( BYTE nLevel
= NO_NUM
, USHORT nSetVal
= USHRT_MAX
);
229 inline SwNodeNum
& operator=( const SwNodeNum
& rCpy
);
231 BOOL
operator==( const SwNodeNum
& ) const;
233 BYTE
GetLevel() const { return nMyLevel
; }
234 void SetLevel( BYTE nVal
) { nMyLevel
= nVal
; }
236 BOOL
IsStart() const { return bStartNum
; }
237 void SetStart( BOOL bFlag
= TRUE
) { bStartNum
= bFlag
; }
239 USHORT
GetSetValue() const { return nSetValue
; }
240 void SetSetValue( USHORT nVal
) { nSetValue
= nVal
; }
242 const USHORT
* GetLevelVal() const { return nLevelVal
; }
243 USHORT
* GetLevelVal() { return nLevelVal
; }
249 // ------------ inline Methoden ----------------------------
251 inline const SwNumFmt
& SwNumRule::Get( USHORT i
) const
253 ASSERT_ID( i
< MAXLEVEL
&& eRuleType
< RULE_END
, ERR_NUMLEVEL
);
254 return aFmts
[ i
] ? *aFmts
[ i
]
255 : *aBaseFmts
[ eRuleType
][ i
];
258 inline const SwNumFmt
* SwNumRule::GetNumFmt( USHORT i
) const
260 ASSERT_ID( i
< MAXLEVEL
&& eRuleType
< RULE_END
, ERR_NUMLEVEL
);
263 inline const Font
& SwNumRule::GetDefBulletFont()
265 if( !pDefBulletFont
)
266 SwNumRule::_MakeDefBulletFont();
267 return *pDefBulletFont
;
270 inline USHORT
SwNumRule::GetNumIndent( BYTE nLvl
)
272 ASSERT( MAXLEVEL
> nLvl
, "NumLevel is out of range" );
273 return aDefNumIndents
[ nLvl
];
275 inline USHORT
SwNumRule::GetBullIndent( BYTE nLvl
)
277 ASSERT( MAXLEVEL
> nLvl
, "NumLevel is out of range" );
278 return aDefNumIndents
[ nLvl
];
281 inline sal_Unicode
SwNumRule::GetBulletChar( const SwNodeNum
& rNum
) const
283 return Get( rNum
.GetLevel() & ~NO_NUMLEVEL
).GetBulletChar();
285 inline const Font
* SwNumRule::GetBulletFont( const SwNodeNum
& rNum
) const
287 return Get( rNum
.GetLevel() & ~NO_NUMLEVEL
).GetBulletFont();
292 SwNodeNum::SwNodeNum( BYTE nLevel
, USHORT nSetVal
)
293 : nSetValue( nSetVal
), nMyLevel( nLevel
), bStartNum( FALSE
)
295 memset( nLevelVal
, 0, sizeof( nLevelVal
) );
298 inline SwNodeNum
& SwNodeNum::operator=( const SwNodeNum
& rCpy
)
300 nSetValue
= rCpy
.nSetValue
;
301 nMyLevel
= rCpy
.nMyLevel
;
302 bStartNum
= rCpy
.bStartNum
;
304 memcpy( nLevelVal
, rCpy
.nLevelVal
, sizeof( nLevelVal
) );
309 } //namespace binfilter
310 #endif // _NUMRULE_HXX