xref: /trunk/main/sw/source/filter/html/htmlnum.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _HTMLNUM_HXX
24 #define _HTMLNUM_HXX
25 
26 #include <swtypes.hxx>
27 #include <string.h>
28 
29 #define HTML_NUMBUL_MARGINLEFT 	(MM50*2 + MM50/2)
30 #define HTML_NUMBUL_INDENT 		(-MM50)
31 
32 class SwTxtNode;
33 class SwNumRule;
34 
35 class SwHTMLNumRuleInfo
36 {
37 	sal_uInt16		aNumStarts[MAXLEVEL];
38 	SwNumRule 	*	pNumRule;		// Aktuelle Numerierung
39 	sal_uInt16		nDeep;			// aktuelle Num-Tiefe (1, 2, 3, ...)
40 	sal_Bool 		bRestart : 1;	// Export: Numerierung neu starten
41 	sal_Bool 		bNumbered : 1;	// Export: Absatz ist numeriert
42 
43 public:
44 
45 	inline void Set( const SwHTMLNumRuleInfo& rInf );
46 	void Set( const SwTxtNode& rTxtNd );
47 
SwHTMLNumRuleInfo()48 	SwHTMLNumRuleInfo() :
49 		pNumRule( 0 ), nDeep( 0 ),
50         bRestart( sal_False ), bNumbered( sal_False )
51 	{
52 		memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
53 	}
54 
SwHTMLNumRuleInfo(const SwHTMLNumRuleInfo & rInf)55 	SwHTMLNumRuleInfo( const SwHTMLNumRuleInfo& rInf ) :
56 		pNumRule( rInf.pNumRule ), nDeep( rInf.nDeep ),
57         bRestart( rInf.bRestart ), bNumbered( rInf.bNumbered )
58 	{
59 		memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
60 	}
61 
SwHTMLNumRuleInfo(const SwTxtNode & rTxtNd)62 	SwHTMLNumRuleInfo( const SwTxtNode& rTxtNd ) { Set( rTxtNd ); }
63 	inline SwHTMLNumRuleInfo& operator=( const SwHTMLNumRuleInfo& rInf );
64 
65 	inline void Clear();
66 
SetNumRule(const SwNumRule * pRule)67 	void SetNumRule( const SwNumRule *pRule ) { pNumRule = (SwNumRule *)pRule; }
GetNumRule()68 	SwNumRule *GetNumRule() { return pNumRule; }
GetNumRule() const69 	const SwNumRule *GetNumRule() const { return pNumRule; }
70 
SetDepth(sal_uInt16 nDepth)71 	void SetDepth( sal_uInt16 nDepth ) { nDeep = nDepth; }
GetDepth() const72 	sal_uInt16 GetDepth() const { return nDeep; }
IncDepth()73 	sal_uInt16 IncDepth() { return ++nDeep; }
DecDepth()74 	sal_uInt16 DecDepth() { return nDeep==0 ? 0 : --nDeep; }
75 	inline sal_uInt8 GetLevel() const;
76 
SetRestart(sal_Bool bSet)77     void SetRestart( sal_Bool bSet ) { bRestart = bSet; }
IsRestart() const78 	sal_Bool IsRestart() const { return bRestart; }
79 
SetNumbered(sal_Bool bSet)80 	void SetNumbered( sal_Bool bSet ) { bNumbered = bSet; }
IsNumbered() const81 	sal_Bool IsNumbered() const { return bNumbered; }
82 
83 	inline void SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal=USHRT_MAX );
GetNodeStartValue(sal_uInt8 nLvl) const84 	sal_uInt16 GetNodeStartValue( sal_uInt8 nLvl ) const { return aNumStarts[nLvl]; }
85 };
86 
operator =(const SwHTMLNumRuleInfo & rInf)87 inline SwHTMLNumRuleInfo& SwHTMLNumRuleInfo::operator=(
88 	const SwHTMLNumRuleInfo& rInf )
89 {
90 	Set( rInf );
91 	return *this;
92 }
93 
Set(const SwHTMLNumRuleInfo & rInf)94 inline void SwHTMLNumRuleInfo::Set( const SwHTMLNumRuleInfo& rInf )
95 {
96 	pNumRule = rInf.pNumRule;
97 	nDeep = rInf.nDeep;
98     bRestart = rInf.bRestart;
99 	bNumbered = rInf.bNumbered;
100 	memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
101 }
102 
Clear()103 inline void SwHTMLNumRuleInfo::Clear()
104 {
105 	pNumRule = 0;
106 	nDeep = 0;
107     bRestart = bNumbered = sal_False;
108 	memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
109 }
110 
GetLevel() const111 inline sal_uInt8 SwHTMLNumRuleInfo::GetLevel() const
112 {
113 	return
114 		(sal_uInt8)( pNumRule!=0 && nDeep != 0
115 			? ( nDeep<=MAXLEVEL ? nDeep-1 : MAXLEVEL - 1 )
116 			: 0 );
117 }
118 
SetNodeStartValue(sal_uInt8 nLvl,sal_uInt16 nVal)119 inline void SwHTMLNumRuleInfo::SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal )
120 {
121 	aNumStarts[nLvl] = nVal;
122 }
123 
124 
125 #endif
126 
127 
128