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 INCLUDED_SW_SOURCE_FILTER_HTML_HTMLNUM_HXX
20 : #define INCLUDED_SW_SOURCE_FILTER_HTML_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 SwTextNode;
29 : class SwNumRule;
30 :
31 : // TODO: Unicode: Are these characters the correct ones?
32 : #define HTML_BULLETCHAR_DISC (0xe008)
33 : #define HTML_BULLETCHAR_CIRCLE (0xe009)
34 : #define HTML_BULLETCHAR_SQUARE (0xe00b)
35 :
36 : class SwHTMLNumRuleInfo
37 : {
38 : sal_uInt16 aNumStarts[MAXLEVEL];
39 : SwNumRule * pNumRule; // Aktuelle Numerierung
40 : sal_uInt16 nDeep; // aktuelle Num-Tiefe (1, 2, 3, ...)
41 : bool bRestart : 1; // Export: Numerierung neu starten
42 : bool bNumbered : 1; // Export: Absatz ist numeriert
43 :
44 : public:
45 :
46 : inline void Set( const SwHTMLNumRuleInfo& rInf );
47 : void Set( const SwTextNode& rTextNd );
48 :
49 329 : SwHTMLNumRuleInfo() :
50 : pNumRule( 0 ), nDeep( 0 ),
51 329 : bRestart( false ), bNumbered( false )
52 : {
53 329 : memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
54 329 : }
55 :
56 262 : SwHTMLNumRuleInfo( const SwHTMLNumRuleInfo& rInf ) :
57 : pNumRule( rInf.pNumRule ), nDeep( rInf.nDeep ),
58 262 : bRestart( rInf.bRestart ), bNumbered( rInf.bNumbered )
59 : {
60 262 : memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
61 262 : }
62 :
63 0 : explicit SwHTMLNumRuleInfo( const SwTextNode& rTextNd ) { Set( rTextNd ); }
64 : inline SwHTMLNumRuleInfo& operator=( const SwHTMLNumRuleInfo& rInf );
65 :
66 : inline void Clear();
67 :
68 0 : void SetNumRule( const SwNumRule *pRule ) { pNumRule = const_cast<SwNumRule *>(pRule); }
69 592 : SwNumRule *GetNumRule() { return pNumRule; }
70 0 : const SwNumRule *GetNumRule() const { return pNumRule; }
71 :
72 0 : void SetDepth( sal_uInt16 nDepth ) { nDeep = nDepth; }
73 300 : sal_uInt16 GetDepth() const { return nDeep; }
74 0 : sal_uInt16 IncDepth() { return ++nDeep; }
75 0 : sal_uInt16 DecDepth() { return nDeep==0 ? 0 : --nDeep; }
76 : inline sal_uInt8 GetLevel() const;
77 :
78 : void SetRestart( bool bSet ) { bRestart = bSet; }
79 0 : bool IsRestart() const { return bRestart; }
80 :
81 : void SetNumbered( bool bSet ) { bNumbered = bSet; }
82 0 : bool IsNumbered() const { return bNumbered; }
83 :
84 : inline void SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal=USHRT_MAX );
85 0 : sal_uInt16 GetNodeStartValue( sal_uInt8 nLvl ) const { return aNumStarts[nLvl]; }
86 : };
87 :
88 291 : inline SwHTMLNumRuleInfo& SwHTMLNumRuleInfo::operator=(
89 : const SwHTMLNumRuleInfo& rInf )
90 : {
91 291 : Set( rInf );
92 291 : return *this;
93 : }
94 :
95 567 : inline void SwHTMLNumRuleInfo::Set( const SwHTMLNumRuleInfo& rInf )
96 : {
97 567 : pNumRule = rInf.pNumRule;
98 567 : nDeep = rInf.nDeep;
99 567 : bRestart = rInf.bRestart;
100 567 : bNumbered = rInf.bNumbered;
101 567 : memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
102 567 : }
103 :
104 570 : inline void SwHTMLNumRuleInfo::Clear()
105 : {
106 570 : pNumRule = 0;
107 570 : nDeep = 0;
108 570 : bRestart = bNumbered = false;
109 570 : memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
110 570 : }
111 :
112 0 : inline sal_uInt8 SwHTMLNumRuleInfo::GetLevel() const
113 : {
114 : return
115 0 : (sal_uInt8)( pNumRule!=0 && nDeep != 0
116 0 : ? ( nDeep<=MAXLEVEL ? nDeep-1 : MAXLEVEL - 1 )
117 0 : : 0 );
118 : }
119 :
120 0 : inline void SwHTMLNumRuleInfo::SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal )
121 : {
122 0 : aNumStarts[nLvl] = nVal;
123 0 : }
124 :
125 : #endif
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|