Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /* TextRunStyle: Stores (and writes) paragraph/span-style-based information
3 : : * (e.g.: a paragraph might be bold) that is needed at the head of an OO
4 : : * document.
5 : : *
6 : : * This Source Code Form is subject to the terms of the Mozilla Public
7 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
8 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 : : *
10 : : * For further information visit http://libwpd.sourceforge.net
11 : : */
12 : :
13 : : /* "This product is not manufactured, approved, or supported by
14 : : * Corel Corporation or Corel Corporation Limited."
15 : : */
16 : :
17 : : #ifndef _TEXTRUNSTYLE_H
18 : : #define _TEXTRUNSTYLE_H
19 : :
20 : : #include <map>
21 : :
22 : : #include <libwpd/libwpd.h>
23 : :
24 : : #include "FilterInternal.hxx"
25 : :
26 : : #include "Style.hxx"
27 : :
28 : : class OdfDocumentHandler;
29 : :
30 : : class ParagraphStyle
31 : : {
32 : : public:
33 : : ParagraphStyle(WPXPropertyList const &propList, const WPXPropertyListVector &tabStops, const WPXString &sName);
34 : : virtual ~ParagraphStyle();
35 : : virtual void write(OdfDocumentHandler *pHandler) const;
36 : 0 : WPXString getName() const
37 : : {
38 : 0 : return msName;
39 : : }
40 : : private:
41 : : WPXPropertyList mpPropList;
42 : : WPXPropertyListVector mxTabStops;
43 : : WPXString msName;
44 : : };
45 : :
46 : :
47 [ # # ][ # # ]: 0 : class SpanStyle : public Style
48 : : {
49 : : public:
50 : : SpanStyle(const char *psName, const WPXPropertyList &xPropList);
51 : : virtual void write(OdfDocumentHandler *pHandler) const;
52 : :
53 : : private:
54 : : WPXPropertyList mPropList;
55 : : };
56 : :
57 : : class ParagraphStyleManager : public StyleManager
58 : : {
59 : : public:
60 [ # # ][ # # ]: 0 : ParagraphStyleManager() : mNameHash(), mStyleHash() {}
61 : 0 : virtual ~ParagraphStyleManager()
62 : 0 : {
63 [ # # ]: 0 : clean();
64 [ # # ]: 0 : }
65 : :
66 : : /* create a new style if it does not exists. In all case, returns the name of the style
67 : :
68 : : Note: using S%i as new name*/
69 : : WPXString findOrAdd(const WPXPropertyList &xPropList, const WPXPropertyListVector &tabStops);
70 : :
71 : : /* returns the style corresponding to a given name ( if it exists ) */
72 : : shared_ptr<ParagraphStyle> const get(const WPXString &name) const;
73 : :
74 : : virtual void clean();
75 : : virtual void write(OdfDocumentHandler *) const;
76 : :
77 : :
78 : : protected:
79 : : // return a unique key
80 : : WPXString getKey(const WPXPropertyList &xPropList, const WPXPropertyListVector &tabStops) const;
81 : :
82 : : // hash key -> name
83 : : std::map<WPXString, WPXString, ltstr> mNameHash;
84 : : // style name -> paragraph style
85 : : std::map<WPXString, shared_ptr<ParagraphStyle>, ltstr> mStyleHash;
86 : : };
87 : :
88 : : class SpanStyleManager : public StyleManager
89 : : {
90 : : public:
91 [ # # ][ # # ]: 0 : SpanStyleManager() : mNameHash(), mStyleHash() {}
92 : 0 : virtual ~SpanStyleManager()
93 : 0 : {
94 [ # # ]: 0 : clean();
95 [ # # ]: 0 : }
96 : :
97 : : /* create a new style if it does not exists. In all case, returns the name of the style
98 : :
99 : : Note: using Span%i as new name*/
100 : : WPXString findOrAdd(const WPXPropertyList &xPropList);
101 : :
102 : : /* returns the style corresponding to a given name ( if it exists ) */
103 : : shared_ptr<SpanStyle> const get(const WPXString &name) const;
104 : :
105 : : virtual void clean();
106 : : virtual void write(OdfDocumentHandler *) const;
107 : :
108 : : protected:
109 : : // hash key -> style name
110 : : std::map<WPXString, WPXString, ltstr> mNameHash;
111 : : // style name -> SpanStyle
112 : : std::map<WPXString, shared_ptr<SpanStyle>, ltstr> mStyleHash;
113 : : };
114 : : #endif
115 : :
116 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|