Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
12 : * GNU Lesser General Public License Version 2.1
13 : * =============================================
14 : * Copyright 2000 by Sun Microsystems, Inc.
15 : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : *
17 : * This library is free software; you can redistribute it and/or
18 : * modify it under the terms of the GNU Lesser General Public
19 : * License version 2.1, as published by the Free Software Foundation.
20 : *
21 : * This library is distributed in the hope that it will be useful,
22 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : * Lesser General Public License for more details.
25 : *
26 : * You should have received a copy of the GNU Lesser General Public
27 : * License along with this library; if not, write to the Free Software
28 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : * MA 02111-1307 USA
30 : *
31 : *
32 : * Sun Industry Standards Source License Version 1.1
33 : * =================================================
34 : * The contents of this file are subject to the Sun Industry Standards
35 : * Source License Version 1.1 (the "License"); You may not use this file
36 : * except in compliance with the License. You may obtain a copy of the
37 : * License at http://www.openoffice.org/license.html.
38 : *
39 : * Software provided under this License is provided on an "AS IS" basis,
40 : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : * See the License for the specific provisions governing your rights and
44 : * obligations concerning the Software.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /*************************************************************************
57 : * @file
58 : * Represente index source,index body and index index entry.
59 : ************************************************************************/
60 : #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFINDEX_HXX
61 : #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFINDEX_HXX
62 : #include <map>
63 : #include <vector>
64 :
65 : #include "xfcontent.hxx"
66 : #include "xfcontentcontainer.hxx"
67 : #include "xftabstop.hxx"
68 :
69 : class XFIndex;
70 : class XFIndexTemplate;
71 : class XFParagraph;
72 :
73 : /**
74 : * @brief
75 : * Index template.
76 : * When index update, the template is used to decide the index body.
77 : */
78 0 : class XFIndexTemplate : public XFContent
79 : {
80 : public:
81 : XFIndexTemplate();
82 :
83 : public:
84 : /**
85 : * @descr Set template level.
86 : */
87 : void SetLevel(const OUString& level);
88 : /**
89 : * @descr Set style.
90 : */
91 : void SetStyleName(const OUString& style) SAL_OVERRIDE;
92 : /**
93 : * @descr Add a entry in the template.
94 : */
95 : void AddEntry(enumXFIndexTemplate entry, const OUString& styleName = "");
96 :
97 : /**
98 : * @descr Add a tab entry in the template.
99 : */
100 : void AddTabEntry(enumXFTab type, double len, sal_Unicode leader = '*', sal_Unicode delimiter='.', const OUString& styleName = "");
101 :
102 : /**
103 : * @descr Add a entry in the template.
104 : */
105 : void AddTextEntry(const OUString& sSpan, const OUString& styleName = "");
106 :
107 : /**
108 : * @descr clear all index template parts.
109 : */
110 : void Clear();
111 : virtual void ToXml(IXFStream *pStrm) SAL_OVERRIDE;
112 :
113 : private:
114 : /**
115 : * @descr Helper function.
116 : */
117 : void SetTagName(const OUString& tag);
118 :
119 : friend class XFIndex;
120 : private:
121 : OUString m_nLevel;
122 : OUString m_strStyle;
123 : enumXFTab m_eTabType;
124 : double m_fTabLength;
125 : OUString m_strTabDelimiter;
126 : OUString m_strTabLeader;
127 : OUString m_strTagName;
128 : typedef std::pair<enumXFIndexTemplate, OUString> TOCTEMPLATE_ENTRY_TYPE;
129 : std::vector<TOCTEMPLATE_ENTRY_TYPE> m_aEntries; // template entry + text style
130 : std::map<sal_uInt16, OUString> m_aTextEntries;
131 : };
132 :
133 : /**
134 : * @brief
135 : * Index, include index template, index body.
136 : */
137 : class XFIndex : public XFContentContainer
138 : {
139 : public:
140 : XFIndex();
141 :
142 : virtual ~XFIndex();
143 :
144 : public:
145 : /**
146 : * @descr Set index type.
147 : */
148 : void SetIndexType(enumXFIndex type);
149 :
150 : /**
151 : * @descr Add index templaet entry.
152 : */
153 : void AddTemplate(const OUString& level, const OUString& style, XFIndexTemplate* templ);
154 :
155 : /**
156 : * @descr Set if protected index to prevent handly-revise.
157 : */
158 : void SetProtected(bool protect);
159 :
160 : /**
161 : * @descr Set separator.
162 : */
163 : void SetSeparator(bool sep);
164 :
165 : virtual void ToXml(IXFStream *pStrm) SAL_OVERRIDE;
166 :
167 : void AddTocSource(sal_uInt16 nLevel, const OUString& sStyleName);
168 :
169 : private:
170 : enumXFIndex m_eType;
171 : OUString m_strTitle;
172 : bool m_bProtect;
173 : bool m_bSeparator;
174 : XFParagraph* m_pTitle;
175 :
176 : std::vector<XFIndexTemplate *> m_aTemplates; // template entry + style
177 :
178 : #define MAX_TOC_LEVEL 10
179 : std::vector<OUString> m_aTOCSource[MAX_TOC_LEVEL+1];
180 :
181 : sal_uInt32 m_nMaxLevel;
182 : };
183 :
184 0 : inline XFIndexTemplate::XFIndexTemplate()
185 : : m_eTabType(enumXFTabNone)
186 0 : , m_fTabLength(0.0)
187 : {
188 0 : m_nLevel = OUString::number(0);
189 0 : }
190 :
191 0 : inline void XFIndexTemplate::SetLevel(const OUString& level)
192 : {
193 0 : m_nLevel = level;
194 0 : }
195 0 : inline void XFIndexTemplate::SetStyleName(const OUString& style)
196 : {
197 0 : m_strStyle = style;
198 0 : }
199 :
200 0 : inline void XFIndexTemplate::SetTagName(const OUString& tag)
201 : {
202 0 : m_strTagName = tag;
203 0 : }
204 :
205 0 : inline void XFIndexTemplate::AddEntry(enumXFIndexTemplate entry, const OUString& styleName)
206 : {
207 0 : std::pair<enumXFIndexTemplate, OUString> pair(entry, styleName);
208 0 : m_aEntries.push_back(pair);
209 0 : }
210 :
211 0 : inline void XFIndexTemplate::AddTabEntry(enumXFTab type, double len, sal_Unicode leader, sal_Unicode delimiter, const OUString& styleName)
212 : {
213 0 : m_eTabType = type;
214 0 : m_strTabLeader = OUString( leader );
215 0 : m_strTabDelimiter = OUString( delimiter );
216 0 : m_fTabLength = len;
217 :
218 0 : AddEntry(enumXFIndexTemplateTab, styleName);
219 0 : }
220 :
221 0 : inline void XFIndexTemplate::AddTextEntry(const OUString& sText, const OUString& styleName)
222 : {
223 0 : sal_uInt16 nLen = m_aEntries.size();
224 0 : AddEntry(enumXFIndexTemplateSpan, styleName);
225 :
226 0 : m_aTextEntries[nLen] = sText;
227 0 : }
228 :
229 : inline void XFIndexTemplate::Clear()
230 : {
231 : m_aEntries.clear();
232 : }
233 :
234 0 : inline void XFIndex::SetIndexType(enumXFIndex type)
235 : {
236 0 : m_eType = type;
237 0 : }
238 :
239 : #endif
240 :
241 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|