LibreOffice Module sw (master)  1
htmlnum.hxx
Go to the documentation of this file.
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 
37 {
38  sal_uInt16 aNumStarts[MAXLEVEL];
39  SwNumRule * pNumRule; // current numbering
40  sal_uInt16 nDeep; // current numbering depth (1, 2, 3, ...)
41  bool bRestart : 1; // Export: restart numbering
42  bool bNumbered : 1; // Export: paragraph is numbered
43 
44 public:
45 
46  inline void Set( const SwHTMLNumRuleInfo& rInf );
47  void Set( const SwTextNode& rTextNd );
48 
50  pNumRule( nullptr ), nDeep( 0 ),
51  bRestart( false ), bNumbered( false )
52  {
53  memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
54  }
55 
57  pNumRule( rInf.pNumRule ), nDeep( rInf.nDeep ),
58  bRestart( rInf.bRestart ), bNumbered( rInf.bNumbered )
59  {
60  memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
61  }
62 
63  explicit SwHTMLNumRuleInfo( const SwTextNode& rTextNd ) { Set( rTextNd ); }
64  inline SwHTMLNumRuleInfo& operator=( const SwHTMLNumRuleInfo& rInf );
65 
66  inline void Clear();
67 
68  void SetNumRule( const SwNumRule *pRule ) { pNumRule = const_cast<SwNumRule *>(pRule); }
69  SwNumRule *GetNumRule() { return pNumRule; }
70  const SwNumRule *GetNumRule() const { return pNumRule; }
71 
72  void SetDepth( sal_uInt16 nDepth ) { nDeep = nDepth; }
73  sal_uInt16 GetDepth() const { return nDeep; }
74  void IncDepth() { ++nDeep; }
75  void DecDepth() { if (nDeep!=0) --nDeep; }
76  inline sal_uInt8 GetLevel() const;
77 
78  bool IsRestart() const { return bRestart; }
79 
80  bool IsNumbered() const { return bNumbered; }
81 
82  inline void SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal=USHRT_MAX );
83  sal_uInt16 GetNodeStartValue( sal_uInt8 nLvl ) const { return aNumStarts[nLvl]; }
84 };
85 
87  const SwHTMLNumRuleInfo& rInf )
88 {
89  Set( rInf );
90  return *this;
91 }
92 
93 inline void SwHTMLNumRuleInfo::Set( const SwHTMLNumRuleInfo& rInf )
94 {
95  pNumRule = rInf.pNumRule;
96  nDeep = rInf.nDeep;
97  bRestart = rInf.bRestart;
98  bNumbered = rInf.bNumbered;
99  memcpy( &aNumStarts, &rInf.aNumStarts, sizeof( aNumStarts ) );
100 }
101 
103 {
104  pNumRule = nullptr;
105  nDeep = 0;
106  bRestart = bNumbered = false;
107  memset( &aNumStarts, 0xff, sizeof( aNumStarts ) );
108 }
109 
111 {
112  return
113  static_cast<sal_uInt8>( pNumRule!=nullptr && nDeep != 0
114  ? ( nDeep<=MAXLEVEL ? nDeep-1 : MAXLEVEL - 1 )
115  : 0 );
116 }
117 
118 inline void SwHTMLNumRuleInfo::SetNodeStartValue( sal_uInt8 nLvl, sal_uInt16 nVal )
119 {
120  aNumStarts[nLvl] = nVal;
121 }
122 
123 #endif
124 
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetLevel() const
Definition: htmlnum.hxx:110
SwHTMLNumRuleInfo(const SwTextNode &rTextNd)
Definition: htmlnum.hxx:63
SwHTMLNumRuleInfo & operator=(const SwHTMLNumRuleInfo &rInf)
Definition: htmlnum.hxx:86
void Set(const SwHTMLNumRuleInfo &rInf)
Definition: htmlnum.hxx:93
bool IsRestart() const
Definition: htmlnum.hxx:78
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
void SetNodeStartValue(sal_uInt8 nLvl, sal_uInt16 nVal=USHRT_MAX)
Definition: htmlnum.hxx:118
sal_uInt16 GetNodeStartValue(sal_uInt8 nLvl) const
Definition: htmlnum.hxx:83
sal_uInt16 GetDepth() const
Definition: htmlnum.hxx:73
void SetNumRule(const SwNumRule *pRule)
Definition: htmlnum.hxx:68
SwHTMLNumRuleInfo(const SwHTMLNumRuleInfo &rInf)
Definition: htmlnum.hxx:56
bool IsNumbered() const
Definition: htmlnum.hxx:80
SwNumRule * pNumRule
Definition: htmlnum.hxx:39
void SetDepth(sal_uInt16 nDepth)
Definition: htmlnum.hxx:72
sal_uInt16 aNumStarts[MAXLEVEL]
Definition: htmlnum.hxx:38
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
unsigned char sal_uInt8
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
const SwNumRule * GetNumRule() const
Definition: htmlnum.hxx:70
SwNumRule * GetNumRule()
Definition: htmlnum.hxx:69
sal_uInt16 nDeep
Definition: htmlnum.hxx:40