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 : #ifndef _HTMLNUM_HXX
20 : #define _HTMLNUM_HXX
21 :
22 : #include <swtypes.hxx>
23 : #include <string.h>
24 :
25 : #define HTML_NUMBUL_MARGINLEFT (MM50*2 + MM50/2)
26 : #define HTML_NUMBUL_INDENT (-MM50)
27 :
28 : class SwTxtNode;
29 : class SwNumRule;
30 :
31 : class SwHTMLNumRuleInfo
32 : {
33 : sal_uInt16 aNumStarts[MAXLEVEL];
34 : SwNumRule * pNumRule; // Aktuelle Numerierung
35 : sal_uInt16 nDeep; // aktuelle Num-Tiefe (1, 2, 3, ...)
36 : sal_Bool bRestart : 1; // Export: Numerierung neu starten
37 : sal_Bool bNumbered : 1; // Export: Absatz ist numeriert
38 :
39 : public:
40 :
41 : inline void Set( const SwHTMLNumRuleInfo& rInf );
42 : void Set( const SwTxtNode& rTxtNd );
43 :
44 266 : SwHTMLNumRuleInfo() :
45 : pNumRule( 0 ), nDeep( 0 ),
46 266 : bRestart( sal_False ), bNumbered( sal_False )
47 : {
48 266 : memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
49 266 : }
50 :
51 260 : SwHTMLNumRuleInfo( const SwHTMLNumRuleInfo& rInf ) :
52 : pNumRule( rInf.pNumRule ), nDeep( rInf.nDeep ),
53 260 : bRestart( rInf.bRestart ), bNumbered( rInf.bNumbered )
54 : {
55 260 : memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
56 260 : }
57 :
58 0 : SwHTMLNumRuleInfo( const SwTxtNode& rTxtNd ) { Set( rTxtNd ); }
59 : inline SwHTMLNumRuleInfo& operator=( const SwHTMLNumRuleInfo& rInf );
60 :
61 : inline void Clear();
62 :
63 0 : void SetNumRule( const SwNumRule *pRule ) { pNumRule = (SwNumRule *)pRule; }
64 264 : SwNumRule *GetNumRule() { return pNumRule; }
65 0 : const SwNumRule *GetNumRule() const { return pNumRule; }
66 :
67 0 : void SetDepth( sal_uInt16 nDepth ) { nDeep = nDepth; }
68 1 : sal_uInt16 GetDepth() const { return nDeep; }
69 0 : sal_uInt16 IncDepth() { return ++nDeep; }
70 0 : sal_uInt16 DecDepth() { return nDeep==0 ? 0 : --nDeep; }
71 : inline sal_uInt8 GetLevel() const;
72 :
73 : void SetRestart( sal_Bool bSet ) { bRestart = bSet; }
74 0 : sal_Bool IsRestart() const { return bRestart; }
75 :
76 : void SetNumbered( sal_Bool bSet ) { bNumbered = bSet; }
77 0 : sal_Bool IsNumbered() const { return bNumbered; }
78 :
79 : inline void SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal=USHRT_MAX );
80 0 : sal_uInt16 GetNodeStartValue( sal_uInt8 nLvl ) const { return aNumStarts[nLvl]; }
81 : };
82 :
83 263 : inline SwHTMLNumRuleInfo& SwHTMLNumRuleInfo::operator=(
84 : const SwHTMLNumRuleInfo& rInf )
85 : {
86 263 : Set( rInf );
87 263 : return *this;
88 : }
89 :
90 523 : inline void SwHTMLNumRuleInfo::Set( const SwHTMLNumRuleInfo& rInf )
91 : {
92 523 : pNumRule = rInf.pNumRule;
93 523 : nDeep = rInf.nDeep;
94 523 : bRestart = rInf.bRestart;
95 523 : bNumbered = rInf.bNumbered;
96 523 : memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
97 523 : }
98 :
99 262 : inline void SwHTMLNumRuleInfo::Clear()
100 : {
101 262 : pNumRule = 0;
102 262 : nDeep = 0;
103 262 : bRestart = bNumbered = sal_False;
104 262 : memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
105 262 : }
106 :
107 0 : inline sal_uInt8 SwHTMLNumRuleInfo::GetLevel() const
108 : {
109 : return
110 0 : (sal_uInt8)( pNumRule!=0 && nDeep != 0
111 0 : ? ( nDeep<=MAXLEVEL ? nDeep-1 : MAXLEVEL - 1 )
112 0 : : 0 );
113 : }
114 :
115 0 : inline void SwHTMLNumRuleInfo::SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal )
116 : {
117 0 : aNumStarts[nLvl] = nVal;
118 0 : }
119 :
120 :
121 : #endif
122 :
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|