1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26
27 #include <vector>
28
29 #include <boost/scoped_array.hpp>
30 #include <boost/tuple/tuple.hpp>
31
32 #include <tools/solar.h>
33 #include <tools/debug.hxx>
34 #ifndef _SVSTDARR_STRINGSDTOR_DECL
35 #define _SVSTDARR_STRINGSDTOR
36 #include <svl/svstdarr.hxx>
37 #endif
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/beans/PropertyValue.hpp>
40 #include <com/sun/star/container/XEnumerationAccess.hpp>
41 #include <com/sun/star/container/XNameContainer.hpp>
42 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
43 #include <com/sun/star/text/XTextCursor.hpp>
44 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
45 #include <com/sun/star/text/XTextFramesSupplier.hpp>
46 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
47 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
48 #include <com/sun/star/text/TextContentAnchorType.hpp>
49 #include <com/sun/star/text/XTextFrame.hpp>
50 #include <com/sun/star/text/XFormField.hpp>
51 #include <com/sun/star/drawing/XShapes.hpp>
52 #include <com/sun/star/util/DateTime.hpp>
53 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
54 #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
55 #include <com/sun/star/container/XNamed.hpp>
56 #include <xmloff/xmltoken.hxx>
57 #include "xmloff/xmlnmspe.hxx"
58 #include <xmloff/txtstyli.hxx>
59 #include <xmloff/families.hxx>
60 #include <xmloff/xmlnumfi.hxx>
61 #include <xmloff/xmlnumi.hxx>
62 #include <xmloff/xmlictxt.hxx>
63 #include <xmloff/xmlimppr.hxx>
64
65 #include "txtparai.hxx"
66 #include <xmloff/txtimp.hxx>
67 #include <xmloff/txtprmap.hxx>
68 #include "xmloff/txtimppr.hxx"
69 #include <xmloff/xmlimp.hxx>
70 #include "txtvfldi.hxx"
71 #include "xmloff/i18nmap.hxx"
72 #include "XMLTextListItemContext.hxx"
73 #include "XMLTextListBlockContext.hxx"
74 #include "XMLTextFrameContext.hxx"
75 #include "XMLPropertyBackpatcher.hxx"
76 #include "XMLTextFrameHyperlinkContext.hxx"
77 #include "XMLSectionImportContext.hxx"
78 #include "XMLIndexTOCContext.hxx"
79 #include <xmloff/XMLFontStylesContext.hxx>
80 #include <xmloff/ProgressBarHelper.hxx>
81 #include <xmloff/nmspmap.hxx>
82 #include <xmloff/XMLEventsImportContext.hxx>
83 #include "XMLTrackedChangesImportContext.hxx"
84 #include "XMLChangeImportContext.hxx"
85 #include "XMLAutoMarkFileContext.hxx"
86
87 #include "XMLCalculationSettingsContext.hxx"
88 #include <xmloff/formsimp.hxx>
89 #include "XMLNumberStylesImport.hxx"
90 #include <com/sun/star/beans/XPropertyState.hpp>
91
92 #include <txtlists.hxx>
93 #include <xmloff/odffields.hxx>
94 #include <comphelper/stlunosequence.hxx>
95
96 using ::rtl::OUString;
97 using ::rtl::OUStringBuffer;
98 using ::com::sun::star::ucb::XAnyCompare;
99
100 using namespace ::std;
101 using namespace ::com::sun::star;
102 using namespace ::com::sun::star::uno;
103 using namespace ::com::sun::star::beans;
104 using namespace ::com::sun::star::text;
105 using namespace ::com::sun::star::frame;
106 using namespace ::com::sun::star::style;
107 using namespace ::com::sun::star::container;
108 using namespace ::com::sun::star::drawing;
109 using namespace ::com::sun::star::xml::sax;
110 using namespace ::com::sun::star::lang;
111 using namespace ::xmloff::token;
112 using ::com::sun::star::util::DateTime;
113 using namespace ::com::sun::star::ucb;
114 using namespace ::com::sun::star;
115 using ::comphelper::UStringLess;
116
117
118
119 static __FAR_DATA SvXMLTokenMapEntry aTextElemTokenMap[] =
120 {
121 { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TEXT_P },
122 { XML_NAMESPACE_TEXT, XML_H, XML_TOK_TEXT_H },
123 { XML_NAMESPACE_TEXT, XML_LIST, XML_TOK_TEXT_LIST },
124 { XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_TEXT_FRAME_PAGE },
125 { XML_NAMESPACE_DRAW, XML_A, XML_TOK_DRAW_A_PAGE },
126 { XML_NAMESPACE_TABLE,XML_TABLE, XML_TOK_TABLE_TABLE },
127 // { XML_NAMESPACE_TABLE,XML_SUB_TABLE, XML_TOK_TABLE_SUBTABLE },
128 { XML_NAMESPACE_TEXT, XML_VARIABLE_DECLS, XML_TOK_TEXT_VARFIELD_DECLS },
129 { XML_NAMESPACE_TEXT, XML_USER_FIELD_DECLS, XML_TOK_TEXT_USERFIELD_DECLS },
130 { XML_NAMESPACE_TEXT, XML_SEQUENCE_DECLS, XML_TOK_TEXT_SEQUENCE_DECLS },
131 { XML_NAMESPACE_TEXT, XML_DDE_CONNECTION_DECLS, XML_TOK_TEXT_DDE_DECLS },
132 { XML_NAMESPACE_TEXT, XML_SECTION, XML_TOK_TEXT_SECTION },
133 { XML_NAMESPACE_TEXT, XML_TABLE_OF_CONTENT, XML_TOK_TEXT_TOC },
134 { XML_NAMESPACE_TEXT, XML_OBJECT_INDEX, XML_TOK_TEXT_OBJECT_INDEX },
135 { XML_NAMESPACE_TEXT, XML_TABLE_INDEX, XML_TOK_TEXT_TABLE_INDEX },
136 { XML_NAMESPACE_TEXT, XML_ILLUSTRATION_INDEX, XML_TOK_TEXT_ILLUSTRATION_INDEX },
137 { XML_NAMESPACE_TEXT, XML_USER_INDEX, XML_TOK_TEXT_USER_INDEX },
138 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX, XML_TOK_TEXT_ALPHABETICAL_INDEX },
139 { XML_NAMESPACE_TEXT, XML_BIBLIOGRAPHY, XML_TOK_TEXT_BIBLIOGRAPHY_INDEX },
140 { XML_NAMESPACE_TEXT, XML_INDEX_TITLE, XML_TOK_TEXT_INDEX_TITLE },
141 { XML_NAMESPACE_TEXT, XML_TRACKED_CHANGES, XML_TOK_TEXT_TRACKED_CHANGES },
142 { XML_NAMESPACE_TEXT, XML_CHANGE_START, XML_TOK_TEXT_CHANGE_START },
143 { XML_NAMESPACE_TEXT, XML_CHANGE_END, XML_TOK_TEXT_CHANGE_END },
144 { XML_NAMESPACE_TEXT, XML_CHANGE, XML_TOK_TEXT_CHANGE },
145 { XML_NAMESPACE_OFFICE, XML_FORMS, XML_TOK_TEXT_FORMS },
146 { XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, XML_TOK_TEXT_CALCULATION_SETTINGS },
147 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE, XML_TOK_TEXT_AUTOMARK },
148 // --> FLR #i52127#
149 { XML_NAMESPACE_TEXT, XML_NUMBERED_PARAGRAPH, XML_TOK_TEXT_NUMBERED_PARAGRAPH },
150 // <--
151
152 XML_TOKEN_MAP_END
153 };
154
155 static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] =
156 {
157 { XML_NAMESPACE_TEXT, XML_SPAN, XML_TOK_TEXT_SPAN },
158 { XML_NAMESPACE_TEXT, XML_TAB, XML_TOK_TEXT_TAB_STOP },
159 { XML_NAMESPACE_TEXT, XML_LINE_BREAK, XML_TOK_TEXT_LINE_BREAK },
160 { XML_NAMESPACE_TEXT, XML_SOFT_PAGE_BREAK, XML_TOK_TEXT_SOFT_PAGE_BREAK },
161 { XML_NAMESPACE_TEXT, XML_S, XML_TOK_TEXT_S },
162 { XML_NAMESPACE_TEXT, XML_A, XML_TOK_TEXT_HYPERLINK },
163 { XML_NAMESPACE_TEXT, XML_RUBY, XML_TOK_TEXT_RUBY },
164
165 { XML_NAMESPACE_TEXT, XML_NOTE, XML_TOK_TEXT_NOTE },
166 { XML_NAMESPACE_TEXT, XML_BOOKMARK, XML_TOK_TEXT_BOOKMARK },
167 { XML_NAMESPACE_TEXT, XML_BOOKMARK_START, XML_TOK_TEXT_BOOKMARK_START },
168 { XML_NAMESPACE_TEXT, XML_BOOKMARK_END, XML_TOK_TEXT_BOOKMARK_END },
169 { XML_NAMESPACE_TEXT, XML_REFERENCE_MARK, XML_TOK_TEXT_REFERENCE },
170 { XML_NAMESPACE_TEXT, XML_REFERENCE_MARK_START,
171 XML_TOK_TEXT_REFERENCE_START },
172 { XML_NAMESPACE_TEXT, XML_REFERENCE_MARK_END,
173 XML_TOK_TEXT_REFERENCE_END },
174
175 { XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_TEXT_FRAME },
176 { XML_NAMESPACE_DRAW, XML_A, XML_TOK_DRAW_A },
177
178 // index marks
179 { XML_NAMESPACE_TEXT, XML_TOC_MARK, XML_TOK_TEXT_TOC_MARK },
180 { XML_NAMESPACE_TEXT, XML_TOC_MARK_START, XML_TOK_TEXT_TOC_MARK_START },
181 { XML_NAMESPACE_TEXT, XML_TOC_MARK_END, XML_TOK_TEXT_TOC_MARK_END },
182 { XML_NAMESPACE_TEXT, XML_USER_INDEX_MARK, XML_TOK_TEXT_USER_INDEX_MARK },
183 { XML_NAMESPACE_TEXT, XML_USER_INDEX_MARK_START,
184 XML_TOK_TEXT_USER_INDEX_MARK_START },
185 { XML_NAMESPACE_TEXT, XML_USER_INDEX_MARK_END,
186 XML_TOK_TEXT_USER_INDEX_MARK_END },
187 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_MARK,
188 XML_TOK_TEXT_ALPHA_INDEX_MARK },
189 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_MARK_START,
190 XML_TOK_TEXT_ALPHA_INDEX_MARK_START },
191 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_MARK_END,
192 XML_TOK_TEXT_ALPHA_INDEX_MARK_END },
193
194 // sender fields
195 { XML_NAMESPACE_TEXT, XML_SENDER_FIRSTNAME,XML_TOK_TEXT_SENDER_FIRSTNAME},
196 { XML_NAMESPACE_TEXT, XML_SENDER_LASTNAME, XML_TOK_TEXT_SENDER_LASTNAME },
197 { XML_NAMESPACE_TEXT, XML_SENDER_INITIALS, XML_TOK_TEXT_SENDER_INITIALS },
198 { XML_NAMESPACE_TEXT, XML_SENDER_TITLE, XML_TOK_TEXT_SENDER_TITLE },
199 { XML_NAMESPACE_TEXT, XML_SENDER_POSITION, XML_TOK_TEXT_SENDER_POSITION },
200 { XML_NAMESPACE_TEXT, XML_SENDER_EMAIL, XML_TOK_TEXT_SENDER_EMAIL },
201 { XML_NAMESPACE_TEXT, XML_SENDER_PHONE_PRIVATE, XML_TOK_TEXT_SENDER_PHONE_PRIVATE },
202 { XML_NAMESPACE_TEXT, XML_SENDER_FAX, XML_TOK_TEXT_SENDER_FAX },
203 { XML_NAMESPACE_TEXT, XML_SENDER_COMPANY, XML_TOK_TEXT_SENDER_COMPANY },
204 { XML_NAMESPACE_TEXT, XML_SENDER_PHONE_WORK, XML_TOK_TEXT_SENDER_PHONE_WORK },
205 { XML_NAMESPACE_TEXT, XML_SENDER_STREET, XML_TOK_TEXT_SENDER_STREET },
206 { XML_NAMESPACE_TEXT, XML_SENDER_CITY, XML_TOK_TEXT_SENDER_CITY },
207 { XML_NAMESPACE_TEXT, XML_SENDER_POSTAL_CODE, XML_TOK_TEXT_SENDER_POSTAL_CODE },
208 { XML_NAMESPACE_TEXT, XML_SENDER_COUNTRY, XML_TOK_TEXT_SENDER_COUNTRY },
209 { XML_NAMESPACE_TEXT, XML_SENDER_STATE_OR_PROVINCE,
210 XML_TOK_TEXT_SENDER_STATE_OR_PROVINCE },
211
212 // misc. document fields
213 { XML_NAMESPACE_TEXT, XML_AUTHOR_NAME, XML_TOK_TEXT_AUTHOR_NAME },
214 { XML_NAMESPACE_TEXT, XML_AUTHOR_INITIALS, XML_TOK_TEXT_AUTHOR_INITIALS },
215 { XML_NAMESPACE_TEXT, XML_DATE, XML_TOK_TEXT_DATE },
216 { XML_NAMESPACE_TEXT, XML_TIME, XML_TOK_TEXT_TIME },
217 { XML_NAMESPACE_TEXT, XML_PAGE_NUMBER, XML_TOK_TEXT_PAGE_NUMBER },
218 { XML_NAMESPACE_TEXT, XML_PAGE_CONTINUATION_STRING,
219 XML_TOK_TEXT_PAGE_CONTINUATION_STRING },
220
221 // variable fields
222 { XML_NAMESPACE_TEXT, XML_VARIABLE_SET, XML_TOK_TEXT_VARIABLE_SET },
223 { XML_NAMESPACE_TEXT, XML_VARIABLE_GET, XML_TOK_TEXT_VARIABLE_GET },
224 { XML_NAMESPACE_TEXT, XML_VARIABLE_INPUT, XML_TOK_TEXT_VARIABLE_INPUT },
225 { XML_NAMESPACE_TEXT, XML_USER_FIELD_GET, XML_TOK_TEXT_USER_FIELD_GET },
226 { XML_NAMESPACE_TEXT, XML_USER_FIELD_INPUT,XML_TOK_TEXT_USER_FIELD_INPUT},
227 { XML_NAMESPACE_TEXT, XML_SEQUENCE, XML_TOK_TEXT_SEQUENCE },
228 { XML_NAMESPACE_TEXT, XML_EXPRESSION, XML_TOK_TEXT_EXPRESSION },
229 { XML_NAMESPACE_TEXT, XML_TEXT_INPUT, XML_TOK_TEXT_TEXT_INPUT },
230
231 // database fields
232 { XML_NAMESPACE_TEXT, XML_DATABASE_DISPLAY,
233 XML_TOK_TEXT_DATABASE_DISPLAY },
234 { XML_NAMESPACE_TEXT, XML_DATABASE_NEXT,
235 XML_TOK_TEXT_DATABASE_NEXT },
236 { XML_NAMESPACE_TEXT, XML_DATABASE_ROW_SELECT,
237 XML_TOK_TEXT_DATABASE_SELECT },
238 { XML_NAMESPACE_TEXT, XML_DATABASE_ROW_NUMBER,
239 XML_TOK_TEXT_DATABASE_ROW_NUMBER },
240 { XML_NAMESPACE_TEXT, XML_DATABASE_NAME, XML_TOK_TEXT_DATABASE_NAME },
241
242 // docinfo fields
243 { XML_NAMESPACE_TEXT, XML_INITIAL_CREATOR,
244 XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR },
245 { XML_NAMESPACE_TEXT, XML_DESCRIPTION, XML_TOK_TEXT_DOCUMENT_DESCRIPTION},
246 { XML_NAMESPACE_TEXT, XML_PRINTED_BY, XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR},
247 { XML_NAMESPACE_TEXT, XML_TITLE, XML_TOK_TEXT_DOCUMENT_TITLE },
248 { XML_NAMESPACE_TEXT, XML_SUBJECT, XML_TOK_TEXT_DOCUMENT_SUBJECT },
249 { XML_NAMESPACE_TEXT, XML_KEYWORDS, XML_TOK_TEXT_DOCUMENT_KEYWORDS },
250 { XML_NAMESPACE_TEXT, XML_CREATOR, XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR },
251 { XML_NAMESPACE_TEXT, XML_EDITING_CYCLES,
252 XML_TOK_TEXT_DOCUMENT_REVISION },
253 { XML_NAMESPACE_TEXT, XML_CREATION_DATE,
254 XML_TOK_TEXT_DOCUMENT_CREATION_DATE },
255 { XML_NAMESPACE_TEXT, XML_CREATION_TIME,
256 XML_TOK_TEXT_DOCUMENT_CREATION_TIME },
257 { XML_NAMESPACE_TEXT, XML_PRINT_DATE, XML_TOK_TEXT_DOCUMENT_PRINT_DATE },
258 { XML_NAMESPACE_TEXT, XML_PRINT_TIME, XML_TOK_TEXT_DOCUMENT_PRINT_TIME },
259 { XML_NAMESPACE_TEXT, XML_MODIFICATION_DATE,
260 XML_TOK_TEXT_DOCUMENT_SAVE_DATE },
261 { XML_NAMESPACE_TEXT, XML_MODIFICATION_TIME,
262 XML_TOK_TEXT_DOCUMENT_SAVE_TIME },
263 { XML_NAMESPACE_TEXT, XML_EDITING_DURATION,
264 XML_TOK_TEXT_DOCUMENT_EDIT_DURATION },
265 { XML_NAMESPACE_TEXT, XML_USER_DEFINED,
266 XML_TOK_TEXT_DOCUMENT_USER_DEFINED },
267
268 // misc fields
269 { XML_NAMESPACE_TEXT, XML_PLACEHOLDER, XML_TOK_TEXT_PLACEHOLDER },
270 { XML_NAMESPACE_TEXT, XML_HIDDEN_TEXT, XML_TOK_TEXT_HIDDEN_TEXT },
271 { XML_NAMESPACE_TEXT, XML_HIDDEN_PARAGRAPH, XML_TOK_TEXT_HIDDEN_PARAGRAPH },
272 { XML_NAMESPACE_TEXT, XML_CONDITIONAL_TEXT, XML_TOK_TEXT_CONDITIONAL_TEXT },
273 { XML_NAMESPACE_TEXT, XML_FILE_NAME, XML_TOK_TEXT_FILENAME },
274 { XML_NAMESPACE_TEXT, XML_CHAPTER, XML_TOK_TEXT_CHAPTER },
275 { XML_NAMESPACE_TEXT, XML_TEMPLATE_NAME, XML_TOK_TEXT_TEMPLATENAME },
276 { XML_NAMESPACE_TEXT, XML_PARAGRAPH_COUNT, XML_TOK_TEXT_PARAGRAPH_COUNT },
277 { XML_NAMESPACE_TEXT, XML_WORD_COUNT, XML_TOK_TEXT_WORD_COUNT },
278 { XML_NAMESPACE_TEXT, XML_TABLE_COUNT, XML_TOK_TEXT_TABLE_COUNT },
279 { XML_NAMESPACE_TEXT, XML_CHARACTER_COUNT, XML_TOK_TEXT_CHARACTER_COUNT },
280 { XML_NAMESPACE_TEXT, XML_IMAGE_COUNT, XML_TOK_TEXT_IMAGE_COUNT },
281 { XML_NAMESPACE_TEXT, XML_OBJECT_COUNT, XML_TOK_TEXT_OBJECT_COUNT },
282 { XML_NAMESPACE_TEXT, XML_PAGE_COUNT, XML_TOK_TEXT_PAGE_COUNT },
283 { XML_NAMESPACE_TEXT, XML_PAGE_VARIABLE_GET, XML_TOK_TEXT_GET_PAGE_VAR },
284 { XML_NAMESPACE_TEXT, XML_PAGE_VARIABLE_SET, XML_TOK_TEXT_SET_PAGE_VAR },
285 { XML_NAMESPACE_TEXT, XML_EXECUTE_MACRO, XML_TOK_TEXT_MACRO },
286 { XML_NAMESPACE_TEXT, XML_DDE_CONNECTION, XML_TOK_TEXT_DDE },
287 { XML_NAMESPACE_TEXT, XML_REFERENCE_REF, XML_TOK_TEXT_REFERENCE_REF },
288 { XML_NAMESPACE_TEXT, XML_BOOKMARK_REF, XML_TOK_TEXT_BOOKMARK_REF },
289 { XML_NAMESPACE_TEXT, XML_SEQUENCE_REF, XML_TOK_TEXT_SEQUENCE_REF },
290 { XML_NAMESPACE_TEXT, XML_NOTE_REF, XML_TOK_TEXT_NOTE_REF },
291 { XML_NAMESPACE_TEXT, XML_BIBLIOGRAPHY_MARK, XML_TOK_TEXT_BIBLIOGRAPHY_MARK },
292 { XML_NAMESPACE_OFFICE, XML_ANNOTATION, XML_TOK_TEXT_ANNOTATION },
293 { XML_NAMESPACE_OFFICE, XML_ANNOTATION_END, XML_TOK_TEXT_ANNOTATION_END },
294 { XML_NAMESPACE_TEXT, XML_SCRIPT, XML_TOK_TEXT_SCRIPT },
295 { XML_NAMESPACE_TEXT, XML_TABLE_FORMULA, XML_TOK_TEXT_TABLE_FORMULA },
296 { XML_NAMESPACE_TEXT, XML_DROPDOWN, XML_TOK_TEXT_DROPDOWN },
297
298 // Calc fields
299 { XML_NAMESPACE_TEXT, XML_SHEET_NAME, XML_TOK_TEXT_SHEET_NAME },
300
301 // draw fields
302 { XML_NAMESPACE_TEXT, XML_MEASURE, XML_TOK_TEXT_MEASURE },
303
304 // RDF metadata
305 { XML_NAMESPACE_TEXT, XML_META, XML_TOK_TEXT_META },
306 { XML_NAMESPACE_TEXT, XML_META_FIELD, XML_TOK_TEXT_META_FIELD },
307
308 // redlining (aka change tracking)
309 { XML_NAMESPACE_TEXT, XML_CHANGE_START, XML_TOK_TEXTP_CHANGE_START },
310 { XML_NAMESPACE_TEXT, XML_CHANGE_END , XML_TOK_TEXTP_CHANGE_END },
311 { XML_NAMESPACE_TEXT, XML_CHANGE, XML_TOK_TEXTP_CHANGE },
312
313 { XML_NAMESPACE_PRESENTATION, XML_HEADER, XML_TOK_DRAW_HEADER },
314 { XML_NAMESPACE_PRESENTATION, XML_FOOTER, XML_TOK_DRAW_FOOTER },
315 { XML_NAMESPACE_PRESENTATION, XML_DATE_TIME, XML_TOK_DRAW_DATE_TIME },
316 { XML_NAMESPACE_TEXT, XML_PAGE_CONTINUATION, XML_TOK_TEXT_PAGE_CONTINUATION },
317
318 { XML_NAMESPACE_FIELD, XML_FIELDMARK, XML_TOK_TEXT_FIELDMARK },
319 { XML_NAMESPACE_FIELD, XML_FIELDMARK_START, XML_TOK_TEXT_FIELDMARK_START },
320 { XML_NAMESPACE_FIELD, XML_FIELDMARK_END, XML_TOK_TEXT_FIELDMARK_END },
321
322
323 XML_TOKEN_MAP_END
324 };
325
326 static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] =
327 {
328 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_P_XMLID },
329 { XML_NAMESPACE_XHTML, XML_ABOUT, XML_TOK_TEXT_P_ABOUT },
330 { XML_NAMESPACE_XHTML, XML_PROPERTY, XML_TOK_TEXT_P_PROPERTY },
331 { XML_NAMESPACE_XHTML, XML_CONTENT, XML_TOK_TEXT_P_CONTENT },
332 { XML_NAMESPACE_XHTML, XML_DATATYPE, XML_TOK_TEXT_P_DATATYPE },
333 { XML_NAMESPACE_TEXT, XML_ID, XML_TOK_TEXT_P_TEXTID },
334 { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_P_STYLE_NAME },
335 { XML_NAMESPACE_TEXT, XML_COND_STYLE_NAME,
336 XML_TOK_TEXT_P_COND_STYLE_NAME },
337 { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,XML_TOK_TEXT_P_LEVEL },
338 { XML_NAMESPACE_TEXT, XML_IS_LIST_HEADER,XML_TOK_TEXT_P_IS_LIST_HEADER },
339 { XML_NAMESPACE_TEXT, XML_RESTART_NUMBERING,XML_TOK_TEXT_P_RESTART_NUMBERING },
340 { XML_NAMESPACE_TEXT, XML_START_VALUE,XML_TOK_TEXT_P_START_VALUE },
341 XML_TOKEN_MAP_END
342 };
343
344 static __FAR_DATA SvXMLTokenMapEntry aTextNumberedParagraphAttrTokenMap[] =
345 {
346 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID },
347 { XML_NAMESPACE_TEXT, XML_LIST_ID,
348 XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID },
349 { XML_NAMESPACE_TEXT, XML_LEVEL, XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL },
350 { XML_NAMESPACE_TEXT, XML_STYLE_NAME,
351 XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME },
352 { XML_NAMESPACE_TEXT, XML_CONTINUE_NUMBERING,
353 XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING },
354 { XML_NAMESPACE_TEXT, XML_START_VALUE,
355 XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE },
356 XML_TOKEN_MAP_END
357 };
358
359 static __FAR_DATA SvXMLTokenMapEntry aTextListBlockAttrTokenMap[] =
360 {
361 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_LIST_BLOCK_XMLID },
362 { XML_NAMESPACE_TEXT, XML_STYLE_NAME,
363 XML_TOK_TEXT_LIST_BLOCK_STYLE_NAME },
364 { XML_NAMESPACE_TEXT, XML_CONTINUE_NUMBERING,
365 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_NUMBERING },
366 // --> OD 2008-04-22 #refactorlists#
367 { XML_NAMESPACE_TEXT, XML_CONTINUE_LIST,
368 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_LIST },
369 XML_TOKEN_MAP_END
370 };
371
372 static __FAR_DATA SvXMLTokenMapEntry aTextListBlockElemTokenMap[] =
373 {
374 { XML_NAMESPACE_TEXT, XML_LIST_HEADER, XML_TOK_TEXT_LIST_HEADER },
375 { XML_NAMESPACE_TEXT, XML_LIST_ITEM, XML_TOK_TEXT_LIST_ITEM },
376 XML_TOKEN_MAP_END
377 };
378
379 static __FAR_DATA SvXMLTokenMapEntry aTextFrameAttrTokenMap[] =
380 {
381 { XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_TEXT_FRAME_STYLE_NAME },
382 { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_TEXT_FRAME_NAME },
383 { XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, XML_TOK_TEXT_FRAME_ANCHOR_TYPE },
384 { XML_NAMESPACE_TEXT, XML_ANCHOR_PAGE_NUMBER, XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER },
385 { XML_NAMESPACE_SVG, XML_X, XML_TOK_TEXT_FRAME_X },
386 { XML_NAMESPACE_SVG, XML_Y, XML_TOK_TEXT_FRAME_Y },
387 { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_TEXT_FRAME_WIDTH },
388 { XML_NAMESPACE_FO, XML_MIN_WIDTH, XML_TOK_TEXT_FRAME_MIN_WIDTH },
389 { XML_NAMESPACE_STYLE, XML_REL_WIDTH, XML_TOK_TEXT_FRAME_REL_WIDTH },
390 { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_TEXT_FRAME_HEIGHT },
391 { XML_NAMESPACE_FO, XML_MIN_HEIGHT, XML_TOK_TEXT_FRAME_MIN_HEIGHT },
392 { XML_NAMESPACE_STYLE, XML_REL_HEIGHT, XML_TOK_TEXT_FRAME_REL_HEIGHT },
393 { XML_NAMESPACE_DRAW, XML_CHAIN_NEXT_NAME, XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME },
394 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_FRAME_HREF },
395 { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_TEXT_FRAME_FILTER_NAME },
396 { XML_NAMESPACE_DRAW, XML_ZINDEX, XML_TOK_TEXT_FRAME_Z_INDEX },
397 { XML_NAMESPACE_SVG, XML_TRANSFORM, XML_TOK_TEXT_FRAME_TRANSFORM },
398 { XML_NAMESPACE_DRAW, XML_CLASS_ID, XML_TOK_TEXT_FRAME_CLASS_ID },
399 { XML_NAMESPACE_DRAW, XML_CODE, XML_TOK_TEXT_FRAME_CODE },
400 { XML_NAMESPACE_DRAW, XML_OBJECT, XML_TOK_TEXT_FRAME_OBJECT },
401 { XML_NAMESPACE_DRAW, XML_ARCHIVE, XML_TOK_TEXT_FRAME_ARCHIVE },
402 { XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, XML_TOK_TEXT_FRAME_MAY_SCRIPT },
403 { XML_NAMESPACE_DRAW, XML_MIME_TYPE, XML_TOK_TEXT_FRAME_MIME_TYPE },
404 { XML_NAMESPACE_DRAW, XML_APPLET_NAME, XML_TOK_TEXT_FRAME_APPLET_NAME },
405 { XML_NAMESPACE_DRAW, XML_FRAME_NAME, XML_TOK_TEXT_FRAME_FRAME_NAME },
406 { XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE },
407 { XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_TABLE, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE },
408 XML_TOKEN_MAP_END
409 };
410
411 static __FAR_DATA SvXMLTokenMapEntry aTextContourAttrTokenMap[] =
412 {
413 { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_TEXT_CONTOUR_WIDTH },
414 { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_TEXT_CONTOUR_HEIGHT },
415 { XML_NAMESPACE_SVG, XML_VIEWBOX, XML_TOK_TEXT_CONTOUR_VIEWBOX },
416 { XML_NAMESPACE_SVG, XML_D, XML_TOK_TEXT_CONTOUR_D },
417 { XML_NAMESPACE_DRAW,XML_POINTS, XML_TOK_TEXT_CONTOUR_POINTS },
418 { XML_NAMESPACE_DRAW,XML_RECREATE_ON_EDIT, XML_TOK_TEXT_CONTOUR_AUTO },
419 XML_TOKEN_MAP_END
420 };
421
422 static __FAR_DATA SvXMLTokenMapEntry aTextHyperlinkAttrTokenMap[] =
423 {
424 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_HYPERLINK_HREF },
425 { XML_NAMESPACE_OFFICE, XML_NAME, XML_TOK_TEXT_HYPERLINK_NAME },
426 { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_TEXT_HYPERLINK_SHOW },
427 { XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, XML_TOK_TEXT_HYPERLINK_TARGET_FRAME },
428 { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_HYPERLINK_STYLE_NAME },
429 { XML_NAMESPACE_TEXT, XML_VISITED_STYLE_NAME, XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME },
430 { XML_NAMESPACE_OFFICE, XML_SERVER_MAP, XML_TOK_TEXT_HYPERLINK_SERVER_MAP },
431 XML_TOKEN_MAP_END
432 };
433
434 static __FAR_DATA SvXMLTokenMapEntry aTextMasterPageElemTokenMap[] =
435 {
436 { XML_NAMESPACE_STYLE, XML_HEADER, XML_TOK_TEXT_MP_HEADER },
437 { XML_NAMESPACE_STYLE, XML_FOOTER, XML_TOK_TEXT_MP_FOOTER },
438 { XML_NAMESPACE_STYLE, XML_HEADER_LEFT, XML_TOK_TEXT_MP_HEADER_LEFT },
439 { XML_NAMESPACE_STYLE, XML_FOOTER_LEFT, XML_TOK_TEXT_MP_FOOTER_LEFT },
440
441 XML_TOKEN_MAP_END
442 };
443
444 static __FAR_DATA SvXMLTokenMapEntry aTextFieldAttrTokenMap[] =
445 {
446 { XML_NAMESPACE_TEXT, XML_FIXED, XML_TOK_TEXTFIELD_FIXED },
447 { XML_NAMESPACE_TEXT, XML_DESCRIPTION, XML_TOK_TEXTFIELD_DESCRIPTION },
448 { XML_NAMESPACE_TEXT, XML_HELP, XML_TOK_TEXTFIELD_HELP },
449 { XML_NAMESPACE_TEXT, XML_HINT, XML_TOK_TEXTFIELD_HINT },
450 { XML_NAMESPACE_TEXT, XML_PLACEHOLDER_TYPE,
451 XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE },
452 { XML_NAMESPACE_TEXT, XML_NAME, XML_TOK_TEXTFIELD_NAME },
453 { XML_NAMESPACE_TEXT, XML_FORMULA, XML_TOK_TEXTFIELD_FORMULA },
454 { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_TEXTFIELD_NUM_FORMAT },
455 { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC,
456 XML_TOK_TEXTFIELD_NUM_LETTER_SYNC },
457 { XML_NAMESPACE_TEXT, XML_DISPLAY_FORMULA,
458 XML_TOK_TEXTFIELD_DISPLAY_FORMULA },
459 { XML_NAMESPACE_TEXT, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE }, // #i32362#: src680m48++ saves text:value-type
460 { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE },
461 { XML_NAMESPACE_TEXT, XML_VALUE, XML_TOK_TEXTFIELD_VALUE },
462 { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TEXTFIELD_VALUE },
463 { XML_NAMESPACE_TEXT, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE },
464 { XML_NAMESPACE_OFFICE, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE },
465 { XML_NAMESPACE_TEXT, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE },
466 { XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE },
467 { XML_NAMESPACE_TEXT, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE },
468 { XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE },
469 { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TOK_TEXTFIELD_BOOL_VALUE},
470 { XML_NAMESPACE_OFFICE, XML_CURRENCY, XML_TOK_TEXTFIELD_CURRENCY},
471 { XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME,
472 XML_TOK_TEXTFIELD_DATA_STYLE_NAME },
473 { XML_NAMESPACE_TEXT, XML_DISPLAY_OUTLINE_LEVEL,
474 XML_TOK_TEXTFIELD_NUMBERING_LEVEL },
475 { XML_NAMESPACE_TEXT, XML_SEPARATION_CHARACTER,
476 XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR },
477 { XML_NAMESPACE_TEXT, XML_DISPLAY, XML_TOK_TEXTFIELD_DISPLAY },
478 { XML_NAMESPACE_TEXT, XML_TIME_ADJUST, XML_TOK_TEXTFIELD_TIME_ADJUST },
479 { XML_NAMESPACE_TEXT, XML_DATE_ADJUST, XML_TOK_TEXTFIELD_DATE_ADJUST },
480 { XML_NAMESPACE_TEXT, XML_PAGE_ADJUST, XML_TOK_TEXTFIELD_PAGE_ADJUST },
481 { XML_NAMESPACE_TEXT, XML_SELECT_PAGE, XML_TOK_TEXTFIELD_SELECT_PAGE },
482 { XML_NAMESPACE_TEXT, XML_DATABASE_NAME, XML_TOK_TEXTFIELD_DATABASE_NAME},
483 { XML_NAMESPACE_TEXT, XML_TABLE_NAME, XML_TOK_TEXTFIELD_TABLE_NAME },
484 { XML_NAMESPACE_TEXT, XML_COLUMN_NAME, XML_TOK_TEXTFIELD_COLUMN_NAME },
485 { XML_NAMESPACE_TEXT, XML_ROW_NUMBER, XML_TOK_TEXTFIELD_ROW_NUMBER },
486 { XML_NAMESPACE_TEXT, XML_CONDITION, XML_TOK_TEXTFIELD_CONDITION },
487 { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_TRUE,
488 XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE },
489 { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_FALSE,
490 XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE },
491 { XML_NAMESPACE_TEXT, XML_EDITING_CYCLES, XML_TOK_TEXTFIELD_REVISION },
492 { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, XML_TOK_TEXTFIELD_OUTLINE_LEVEL},
493 { XML_NAMESPACE_TEXT, XML_ACTIVE, XML_TOK_TEXTFIELD_ACTIVE },
494 { XML_NAMESPACE_TEXT, XML_NOTE_CLASS, XML_TOK_TEXTFIELD_NOTE_CLASS },
495 { XML_NAMESPACE_TEXT, XML_REFERENCE_FORMAT,
496 XML_TOK_TEXTFIELD_REFERENCE_FORMAT },
497 { XML_NAMESPACE_TEXT, XML_REF_NAME, XML_TOK_TEXTFIELD_REF_NAME },
498 { XML_NAMESPACE_TEXT, XML_CONNECTION_NAME,
499 XML_TOK_TEXTFIELD_CONNECTION_NAME },
500 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXTFIELD_HREF },
501 { XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME,
502 XML_TOK_TEXTFIELD_TARGET_FRAME },
503 { XML_NAMESPACE_TEXT, XML_ANNOTATION, XML_TOK_TEXTFIELD_ANNOTATION },
504 { XML_NAMESPACE_SCRIPT, XML_LANGUAGE, XML_TOK_TEXTFIELD_LANGUAGE },
505 { XML_NAMESPACE_TEXT, XML_KIND, XML_TOK_TEXTFIELD_MEASURE_KIND },
506 { XML_NAMESPACE_TEXT, XML_IS_HIDDEN, XML_TOK_TEXTFIELD_IS_HIDDEN },
507 { XML_NAMESPACE_TEXT, XML_CURRENT_VALUE,
508 XML_TOK_TEXTFIELD_CURRENT_VALUE },
509 { XML_NAMESPACE_TEXT, XML_TABLE_TYPE, XML_TOK_TEXTFIELD_TABLE_TYPE },
510 { XML_NAMESPACE_OFFICE, XML_NAME, XML_TOK_TEXT_NAME },
511
512 XML_TOKEN_MAP_END
513 };
514
515
516 // maximum allowed length of combined characters field
517 #define MAX_COMBINED_CHARACTERS 6
518
519 struct SAL_DLLPRIVATE XMLTextImportHelper::Impl
520 : private ::boost::noncopyable
521 {
522 ::std::auto_ptr<SvXMLTokenMap> m_pTextElemTokenMap;
523 ::std::auto_ptr<SvXMLTokenMap> m_pTextPElemTokenMap;
524 ::std::auto_ptr<SvXMLTokenMap> m_pTextPAttrTokenMap;
525 ::std::auto_ptr<SvXMLTokenMap> m_pTextFieldAttrTokenMap;
526 ::std::auto_ptr<SvXMLTokenMap> m_pTextNumberedParagraphAttrTokenMap;
527 ::std::auto_ptr<SvXMLTokenMap> m_pTextListBlockAttrTokenMap;
528 ::std::auto_ptr<SvXMLTokenMap> m_pTextListBlockElemTokenMap;
529 ::std::auto_ptr<SvXMLTokenMap> m_pTextFrameAttrTokenMap;
530 ::std::auto_ptr<SvXMLTokenMap> m_pTextContourAttrTokenMap;
531 ::std::auto_ptr<SvXMLTokenMap> m_pTextHyperlinkAttrTokenMap;
532 ::std::auto_ptr<SvXMLTokenMap> m_pTextMasterPageElemTokenMap;
533 ::std::auto_ptr<SvStringsDtor> m_pPrevFrmNames;
534 ::std::auto_ptr<SvStringsDtor> m_pNextFrmNames;
535
536 // --> OD 2008-04-25 #refactorlists#
537 ::std::auto_ptr<XMLTextListsHelper> m_pTextListsHelper;
538 // <--
539
540 SvXMLImportContextRef m_xAutoStyles;
541 SvXMLImportContextRef m_xFontDecls;
542
543 XMLSectionList_Impl m_SectionList;
544
545 UniReference< SvXMLImportPropertyMapper > m_xParaImpPrMap;
546 UniReference< SvXMLImportPropertyMapper > m_xTextImpPrMap;
547 UniReference< SvXMLImportPropertyMapper > m_xFrameImpPrMap;
548 UniReference< SvXMLImportPropertyMapper > m_xSectionImpPrMap;
549 UniReference< SvXMLImportPropertyMapper > m_xRubyImpPrMap;
550
551 ::std::auto_ptr<SvI18NMap> m_pRenameMap;
552 // --> OD 2006-10-12 #i69629# - change and extend data structure:
553 // - data structure contains candidates of paragraph styles, which
554 // will be assigned to the outline style
555 // - data structure contains more than one candidate for each list level
556 // of the outline style
557 ::boost::scoped_array< ::std::vector< ::rtl::OUString > >
558 m_pOutlineStylesCandidates;
559 // <--
560
561 // start range, xml:id, RDFa stuff
562 typedef ::boost::tuple<
563 uno::Reference<text::XTextRange>, ::rtl::OUString,
564 ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > >
565 BookmarkMapEntry_t;
566 /// start ranges for open bookmarks
567 ::std::map< ::rtl::OUString, BookmarkMapEntry_t,
568 ::comphelper::UStringLess> m_BookmarkStartRanges;
569
570 typedef ::std::vector< ::rtl::OUString > BookmarkVector_t;
571 BookmarkVector_t m_BookmarkVector;
572
573 /// name of the last 'open' redline that started between paragraphs
574 ::rtl::OUString m_sOpenRedlineIdentifier;
575
576 uno::Reference<text::XText> m_xText;
577 uno::Reference<text::XTextCursor> m_xCursor;
578 uno::Reference<text::XTextRange> m_xCursorAsRange;
579 uno::Reference<container::XNameContainer> m_xParaStyles;
580 uno::Reference<container::XNameContainer> m_xTextStyles;
581 uno::Reference<container::XNameContainer> m_xNumStyles;
582 uno::Reference<container::XNameContainer> m_xFrameStyles;
583 uno::Reference<container::XNameContainer> m_xPageStyles;
584 uno::Reference<container::XIndexReplace> m_xChapterNumbering;
585 uno::Reference<container::XNameAccess> m_xTextFrames;
586 uno::Reference<container::XNameAccess> m_xGraphics;
587 uno::Reference<container::XNameAccess> m_xObjects;
588 uno::Reference<lang::XMultiServiceFactory> m_xServiceFactory;
589
590 SvXMLImport & m_rSvXMLImport;
591
592 bool m_bInsertMode : 1;
593 bool m_bStylesOnlyMode : 1;
594 bool m_bBlockMode : 1;
595 bool m_bProgress : 1;
596 bool m_bOrganizerMode : 1;
597 bool m_bBodyContentStarted : 1;
598
599 // #107848#
600 // One more flag to remember if we are inside a deleted redline section
601 bool m_bInsideDeleteContext : 1;
602
603 typedef ::std::pair< ::rtl::OUString, ::rtl::OUString> field_name_type_t;
604 typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > field_param_t;
605 typedef ::std::vector< field_param_t > field_params_t;
606 typedef ::std::pair< field_name_type_t, field_params_t > field_stack_item_t;
607 typedef ::std::stack< field_stack_item_t > field_stack_t;
608
609 field_stack_t m_FieldStack;
610
611 ::rtl::OUString m_sCellParaStyleDefault;
612
ImplXMLTextImportHelper::Impl613 Impl( uno::Reference<frame::XModel> const& rModel,
614 SvXMLImport & rImport,
615 bool const bInsertMode, bool const bStylesOnlyMode,
616 bool const bProgress, bool const bBlockMode,
617 bool const bOrganizerMode)
618 : m_pTextElemTokenMap( 0 )
619 , m_pTextPElemTokenMap( 0 )
620 , m_pTextPAttrTokenMap( 0 )
621 , m_pTextFieldAttrTokenMap( 0 )
622 , m_pTextNumberedParagraphAttrTokenMap( 0 )
623 , m_pTextListBlockAttrTokenMap( 0 )
624 , m_pTextListBlockElemTokenMap( 0 )
625 , m_pTextFrameAttrTokenMap( 0 )
626 , m_pTextContourAttrTokenMap( 0 )
627 , m_pTextHyperlinkAttrTokenMap( 0 )
628 , m_pTextMasterPageElemTokenMap( 0 )
629 , m_pPrevFrmNames( 0 )
630 , m_pNextFrmNames( 0 )
631 // --> OD 2008-04-25 #refactorlists#
632 , m_pTextListsHelper( new XMLTextListsHelper() )
633 // <--
634 , m_pRenameMap( 0 )
635 // --> OD 2006-10-12 #i69629#
636 , m_pOutlineStylesCandidates( 0 )
637 // <--
638 , m_xServiceFactory( rModel, UNO_QUERY )
639 , m_rSvXMLImport( rImport )
640 , m_bInsertMode( bInsertMode )
641 , m_bStylesOnlyMode( bStylesOnlyMode )
642 , m_bBlockMode( bBlockMode )
643 , m_bProgress( bProgress )
644 , m_bOrganizerMode( bOrganizerMode )
645 , m_bBodyContentStarted( true )
646 // #107848# Initialize inside_deleted_section flag correctly
647 , m_bInsideDeleteContext( false )
648 {
649 }
650
InitOutlineStylesCandidatesXMLTextImportHelper::Impl651 void InitOutlineStylesCandidates()
652 {
653 if (!m_pOutlineStylesCandidates)
654 {
655 size_t const size(m_xChapterNumbering->getCount());
656 m_pOutlineStylesCandidates.reset(
657 new ::std::vector< ::rtl::OUString >[size] );
658 }
659 }
660
661 };
662
663
GetText()664 uno::Reference< text::XText > & XMLTextImportHelper::GetText()
665 {
666 return m_pImpl->m_xText;
667 }
668
GetCursor()669 uno::Reference< text::XTextCursor > & XMLTextImportHelper::GetCursor()
670 {
671 return m_pImpl->m_xCursor;
672 }
673
GetCursorAsRange()674 uno::Reference< text::XTextRange > & XMLTextImportHelper::GetCursorAsRange()
675 {
676 return m_pImpl->m_xCursorAsRange;
677 }
678
IsInsertMode() const679 bool XMLTextImportHelper::IsInsertMode() const
680 {
681 return m_pImpl->m_bInsertMode;
682 }
683
IsStylesOnlyMode() const684 bool XMLTextImportHelper::IsStylesOnlyMode() const
685 {
686 return m_pImpl->m_bStylesOnlyMode;
687 }
688
IsBlockMode() const689 bool XMLTextImportHelper::IsBlockMode() const
690 {
691 return m_pImpl->m_bBlockMode;
692 }
693
IsOrganizerMode() const694 bool XMLTextImportHelper::IsOrganizerMode() const
695 {
696 return m_pImpl->m_bOrganizerMode;
697 }
698
IsProgress() const699 bool XMLTextImportHelper::IsProgress() const
700 {
701 return m_pImpl->m_bProgress;
702 }
703
GetSectionList()704 XMLSectionList_Impl & XMLTextImportHelper::GetSectionList()
705 {
706 return m_pImpl->m_SectionList;
707 }
708
709 uno::Reference<container::XNameContainer> const&
GetParaStyles() const710 XMLTextImportHelper::GetParaStyles() const
711 {
712 return m_pImpl->m_xParaStyles;
713 }
714
715 uno::Reference<container::XNameContainer> const&
GetTextStyles() const716 XMLTextImportHelper::GetTextStyles() const
717 {
718 return m_pImpl->m_xTextStyles;
719 }
720
721 uno::Reference<container::XNameContainer> const&
GetNumberingStyles() const722 XMLTextImportHelper::GetNumberingStyles() const
723 {
724 return m_pImpl->m_xNumStyles;
725 }
726
727 uno::Reference<container::XNameContainer> const&
GetFrameStyles() const728 XMLTextImportHelper::GetFrameStyles() const
729 {
730 return m_pImpl->m_xFrameStyles;
731 }
732
733 uno::Reference<container::XNameContainer> const&
GetPageStyles() const734 XMLTextImportHelper::GetPageStyles() const
735 {
736 return m_pImpl->m_xPageStyles;
737 }
738
739 uno::Reference<container::XIndexReplace> const&
GetChapterNumbering() const740 XMLTextImportHelper::GetChapterNumbering() const
741 {
742 return m_pImpl->m_xChapterNumbering;
743 }
744
745 UniReference< SvXMLImportPropertyMapper > const&
GetParaImportPropertySetMapper() const746 XMLTextImportHelper::GetParaImportPropertySetMapper() const
747 {
748 return m_pImpl->m_xParaImpPrMap;
749 }
750
751 UniReference< SvXMLImportPropertyMapper > const&
GetTextImportPropertySetMapper() const752 XMLTextImportHelper::GetTextImportPropertySetMapper() const
753 {
754 return m_pImpl->m_xTextImpPrMap;
755 }
756
757 UniReference< SvXMLImportPropertyMapper > const&
GetFrameImportPropertySetMapper() const758 XMLTextImportHelper::GetFrameImportPropertySetMapper() const
759 {
760 return m_pImpl->m_xFrameImpPrMap;
761 }
762
763 UniReference< SvXMLImportPropertyMapper > const&
GetSectionImportPropertySetMapper() const764 XMLTextImportHelper::GetSectionImportPropertySetMapper() const
765 {
766 return m_pImpl->m_xSectionImpPrMap;
767 }
768
769 UniReference< SvXMLImportPropertyMapper > const&
GetRubyImportPropertySetMapper() const770 XMLTextImportHelper::GetRubyImportPropertySetMapper() const
771 {
772 return m_pImpl->m_xRubyImpPrMap;
773 }
774
SetInsideDeleteContext(bool const bNew)775 void XMLTextImportHelper::SetInsideDeleteContext(bool const bNew)
776 {
777 m_pImpl->m_bInsideDeleteContext = bNew;
778 }
779
IsInsideDeleteContext() const780 bool XMLTextImportHelper::IsInsideDeleteContext() const
781 {
782 return m_pImpl->m_bInsideDeleteContext;
783 }
784
GetXMLImport()785 SvXMLImport & XMLTextImportHelper::GetXMLImport()
786 {
787 return m_pImpl->m_rSvXMLImport;
788 }
789
GetTextListHelper()790 XMLTextListsHelper & XMLTextImportHelper::GetTextListHelper()
791 {
792 return *m_pImpl->m_pTextListsHelper;
793 }
794
GetTextElemTokenMap()795 const SvXMLTokenMap& XMLTextImportHelper::GetTextElemTokenMap()
796 {
797 if (!m_pImpl->m_pTextElemTokenMap.get())
798 {
799 m_pImpl->m_pTextElemTokenMap.reset(
800 new SvXMLTokenMap( aTextElemTokenMap ));
801 }
802 return *m_pImpl->m_pTextElemTokenMap;
803 }
804
GetTextPElemTokenMap()805 const SvXMLTokenMap& XMLTextImportHelper::GetTextPElemTokenMap()
806 {
807 if (!m_pImpl->m_pTextPElemTokenMap.get())
808 {
809 m_pImpl->m_pTextPElemTokenMap.reset(
810 new SvXMLTokenMap( aTextPElemTokenMap ));
811 }
812 return *m_pImpl->m_pTextPElemTokenMap;
813 }
814
GetTextPAttrTokenMap()815 const SvXMLTokenMap& XMLTextImportHelper::GetTextPAttrTokenMap()
816 {
817 if (!m_pImpl->m_pTextPAttrTokenMap.get())
818 {
819 m_pImpl->m_pTextPAttrTokenMap.reset(
820 new SvXMLTokenMap( aTextPAttrTokenMap ));
821 }
822 return *m_pImpl->m_pTextPAttrTokenMap;
823 }
824
GetTextFrameAttrTokenMap()825 const SvXMLTokenMap& XMLTextImportHelper::GetTextFrameAttrTokenMap()
826 {
827 if (!m_pImpl->m_pTextFrameAttrTokenMap.get())
828 {
829 m_pImpl->m_pTextFrameAttrTokenMap.reset(
830 new SvXMLTokenMap( aTextFrameAttrTokenMap ));
831 }
832 return *m_pImpl->m_pTextFrameAttrTokenMap;
833 }
834
GetTextContourAttrTokenMap()835 const SvXMLTokenMap& XMLTextImportHelper::GetTextContourAttrTokenMap()
836 {
837 if (!m_pImpl->m_pTextContourAttrTokenMap.get())
838 {
839 m_pImpl->m_pTextContourAttrTokenMap.reset(
840 new SvXMLTokenMap( aTextContourAttrTokenMap ));
841 }
842 return *m_pImpl->m_pTextContourAttrTokenMap;
843 }
844
GetTextHyperlinkAttrTokenMap()845 const SvXMLTokenMap& XMLTextImportHelper::GetTextHyperlinkAttrTokenMap()
846 {
847 if (!m_pImpl->m_pTextHyperlinkAttrTokenMap.get())
848 {
849 m_pImpl->m_pTextHyperlinkAttrTokenMap.reset(
850 new SvXMLTokenMap( aTextHyperlinkAttrTokenMap ));
851 }
852 return *m_pImpl->m_pTextHyperlinkAttrTokenMap;
853 }
854
GetTextMasterPageElemTokenMap()855 const SvXMLTokenMap& XMLTextImportHelper::GetTextMasterPageElemTokenMap()
856 {
857 if (!m_pImpl->m_pTextMasterPageElemTokenMap.get())
858 {
859 m_pImpl->m_pTextMasterPageElemTokenMap.reset(
860 new SvXMLTokenMap( aTextMasterPageElemTokenMap ));
861 }
862 return *m_pImpl->m_pTextMasterPageElemTokenMap;
863 }
864
GetTextFieldAttrTokenMap()865 const SvXMLTokenMap& XMLTextImportHelper::GetTextFieldAttrTokenMap()
866 {
867 if (!m_pImpl->m_pTextFieldAttrTokenMap.get())
868 {
869 m_pImpl->m_pTextFieldAttrTokenMap.reset(
870 new SvXMLTokenMap( aTextFieldAttrTokenMap ));
871 }
872 return *m_pImpl->m_pTextFieldAttrTokenMap;
873 }
874
875
876 namespace
877 {
878 class FieldParamImporter
879 {
880 public:
881 typedef pair<OUString,OUString> field_param_t;
882 typedef vector<field_param_t> field_params_t;
FieldParamImporter(const field_params_t * const pInParams,Reference<XNameContainer> xOutParams)883 FieldParamImporter(const field_params_t* const pInParams, Reference<XNameContainer> xOutParams)
884 : m_pInParams(pInParams)
885 , m_xOutParams(xOutParams)
886 { };
887 void Import();
888
889 private:
890 const field_params_t* const m_pInParams;
891 Reference<XNameContainer> m_xOutParams;
892 };
893
Import()894 void FieldParamImporter::Import()
895 {
896 ::std::vector<OUString> vListEntries;
897 ::std::map<OUString, Any> vOutParams;
898 for(field_params_t::const_iterator pCurrent = m_pInParams->begin();
899 pCurrent != m_pInParams->end();
900 ++pCurrent)
901 {
902 if(pCurrent->first.equalsAscii(ODF_FORMDROPDOWN_RESULT))
903 {
904 // sal_Int32
905 vOutParams[pCurrent->first] = makeAny(pCurrent->second.toInt32());
906 }
907 else if(pCurrent->first.equalsAscii(ODF_FORMCHECKBOX_RESULT))
908 {
909 // bool
910 vOutParams[pCurrent->first] = makeAny(pCurrent->second.toBoolean());
911 }
912 else if(pCurrent->first.equalsAscii(ODF_FORMDROPDOWN_LISTENTRY))
913 {
914 // sequence
915 vListEntries.push_back(pCurrent->second);
916 }
917 else
918 vOutParams[pCurrent->first] = makeAny(pCurrent->second);
919 }
920 if(!vListEntries.empty())
921 {
922 Sequence<OUString> vListEntriesSeq(vListEntries.size());
923 copy(vListEntries.begin(), vListEntries.end(), ::comphelper::stl_begin(vListEntriesSeq));
924 vOutParams[OUString::createFromAscii(ODF_FORMDROPDOWN_LISTENTRY)] = makeAny(vListEntriesSeq);
925 }
926 for(::std::map<OUString, Any>::const_iterator pCurrent = vOutParams.begin();
927 pCurrent != vOutParams.end();
928 ++pCurrent)
929 {
930 try
931 {
932 m_xOutParams->insertByName(pCurrent->first, pCurrent->second);
933 }
934 catch(ElementExistException)
935 { }
936 }
937 }
938 }
939
XMLTextImportHelper(uno::Reference<frame::XModel> const & rModel,SvXMLImport & rImport,bool const bInsertMode,bool const bStylesOnlyMode,bool const bProgress,bool const bBlockMode,bool const bOrganizerMode)940 XMLTextImportHelper::XMLTextImportHelper(
941 uno::Reference<frame::XModel> const& rModel,
942 SvXMLImport& rImport,
943 bool const bInsertMode, bool const bStylesOnlyMode,
944 bool const bProgress, bool const bBlockMode,
945 bool const bOrganizerMode)
946 : m_pImpl( new Impl(rModel, rImport, bInsertMode, bStylesOnlyMode,
947 bProgress, bBlockMode, bOrganizerMode) )
948 , m_pBackpatcherImpl( MakeBackpatcherImpl() )
949 {
950 static ::rtl::OUString s_PropNameDefaultListId(
951 RTL_CONSTASCII_USTRINGPARAM("DefaultListId"));
952
953 Reference< XChapterNumberingSupplier > xCNSupplier( rModel, UNO_QUERY );
954
955 if( xCNSupplier.is() )
956 {
957 m_pImpl->m_xChapterNumbering = xCNSupplier->getChapterNumberingRules();
958 // --> OD 2008-05-15 #refactorlists#
959 if (m_pImpl->m_xChapterNumbering.is())
960 {
961 Reference< XPropertySet > const xNumRuleProps(
962 m_pImpl->m_xChapterNumbering, UNO_QUERY);
963 if ( xNumRuleProps.is() )
964 {
965 Reference< XPropertySetInfo > xNumRulePropSetInfo(
966 xNumRuleProps->getPropertySetInfo());
967 if (xNumRulePropSetInfo.is() &&
968 xNumRulePropSetInfo->hasPropertyByName(
969 s_PropNameDefaultListId))
970 {
971 ::rtl::OUString sListId;
972 xNumRuleProps->getPropertyValue(s_PropNameDefaultListId)
973 >>= sListId;
974 DBG_ASSERT( sListId.getLength() != 0,
975 "no default list id found at chapter numbering rules instance. Serious defect -> please inform OD." );
976 if ( sListId.getLength() )
977 {
978 Reference< XNamed > const xChapterNumNamed(
979 m_pImpl->m_xChapterNumbering, UNO_QUERY);
980 if ( xChapterNumNamed.is() )
981 {
982 m_pImpl->m_pTextListsHelper->KeepListAsProcessed(
983 sListId,
984 xChapterNumNamed->getName(),
985 ::rtl::OUString() );
986 }
987 }
988 }
989 }
990 }
991 // <--
992 }
993
994 Reference< XStyleFamiliesSupplier > xFamiliesSupp( rModel, UNO_QUERY );
995 // DBG_ASSERT( xFamiliesSupp.is(), "no chapter numbering supplier" ); for clipboard there may be documents without styles
996
997 if( xFamiliesSupp.is() )
998 {
999 Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
1000
1001 const OUString aParaStyles(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles"));
1002 if( xFamilies->hasByName( aParaStyles ) )
1003 {
1004 m_pImpl->m_xParaStyles.set(xFamilies->getByName(aParaStyles),
1005 UNO_QUERY);
1006 }
1007
1008 const OUString aCharStyles(RTL_CONSTASCII_USTRINGPARAM("CharacterStyles"));
1009 if( xFamilies->hasByName( aCharStyles ) )
1010 {
1011 m_pImpl->m_xTextStyles.set(xFamilies->getByName(aCharStyles),
1012 UNO_QUERY);
1013 }
1014
1015 const OUString aNumStyles(RTL_CONSTASCII_USTRINGPARAM("NumberingStyles"));
1016 if( xFamilies->hasByName( aNumStyles ) )
1017 {
1018 m_pImpl->m_xNumStyles.set(xFamilies->getByName(aNumStyles),
1019 UNO_QUERY);
1020 }
1021
1022 const OUString aFrameStyles(RTL_CONSTASCII_USTRINGPARAM("FrameStyles"));
1023 if( xFamilies->hasByName( aFrameStyles ) )
1024 {
1025 m_pImpl->m_xFrameStyles.set(xFamilies->getByName(aFrameStyles),
1026 UNO_QUERY);
1027 }
1028
1029 const OUString aPageStyles(RTL_CONSTASCII_USTRINGPARAM("PageStyles"));
1030 if( xFamilies->hasByName( aPageStyles ) )
1031 {
1032 m_pImpl->m_xPageStyles.set(xFamilies->getByName(aPageStyles),
1033 UNO_QUERY);
1034 }
1035 }
1036
1037 Reference < XTextFramesSupplier > xTFS( rModel, UNO_QUERY );
1038 if( xTFS.is() )
1039 {
1040 m_pImpl->m_xTextFrames.set(xTFS->getTextFrames());
1041 }
1042
1043 Reference < XTextGraphicObjectsSupplier > xTGOS( rModel, UNO_QUERY );
1044 if( xTGOS.is() )
1045 {
1046 m_pImpl->m_xGraphics.set(xTGOS->getGraphicObjects());
1047 }
1048
1049 Reference < XTextEmbeddedObjectsSupplier > xTEOS( rModel, UNO_QUERY );
1050 if( xTEOS.is() )
1051 {
1052 m_pImpl->m_xObjects.set(xTEOS->getEmbeddedObjects());
1053 }
1054
1055 XMLPropertySetMapper *pPropMapper =
1056 new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA );
1057 m_pImpl->m_xParaImpPrMap =
1058 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1059
1060 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
1061 m_pImpl->m_xTextImpPrMap =
1062 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1063
1064 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
1065 m_pImpl->m_xFrameImpPrMap =
1066 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1067
1068 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION );
1069 m_pImpl->m_xSectionImpPrMap =
1070 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1071
1072 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY );
1073 m_pImpl->m_xRubyImpPrMap =
1074 new SvXMLImportPropertyMapper( pPropMapper, rImport );
1075 }
1076
~XMLTextImportHelper()1077 XMLTextImportHelper::~XMLTextImportHelper()
1078 {
1079 }
1080
CreateShapeExtPropMapper(SvXMLImport & rImport)1081 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateShapeExtPropMapper(SvXMLImport& rImport)
1082 {
1083 XMLPropertySetMapper *pPropMapper =
1084 new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
1085 return new XMLTextImportPropertyMapper( pPropMapper, rImport,
1086 const_cast<XMLFontStylesContext*>(rImport.GetFontDecls()) );
1087 }
1088
CreateCharExtPropMapper(SvXMLImport & rImport,XMLFontStylesContext * pFontDecls)1089 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateCharExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext *pFontDecls)
1090 {
1091 XMLPropertySetMapper *pPropMapper =
1092 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
1093 if (!pFontDecls)
1094 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
1095 return new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
1096 }
1097
CreateParaExtPropMapper(SvXMLImport & rImport,XMLFontStylesContext * pFontDecls)1098 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext *pFontDecls)
1099 {
1100 XMLPropertySetMapper *pPropMapper =
1101 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
1102 if (!pFontDecls)
1103 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
1104 return new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
1105 }
1106
CreateParaDefaultExtPropMapper(SvXMLImport & rImport,XMLFontStylesContext * pFontDecls)1107 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaDefaultExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext* pFontDecls)
1108 {
1109 if (!pFontDecls)
1110 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
1111
1112 XMLPropertySetMapper* pPropMapper =
1113 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
1114 SvXMLImportPropertyMapper* pImportMapper = new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
1115
1116 pPropMapper =
1117 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS );
1118 pImportMapper->ChainImportMapper( new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls ) );
1119
1120 return pImportMapper;
1121 }
1122
1123 SvXMLImportPropertyMapper*
CreateTableDefaultExtPropMapper(SvXMLImport & rImport,XMLFontStylesContext *)1124 XMLTextImportHelper::CreateTableDefaultExtPropMapper(
1125 SvXMLImport& rImport,
1126 XMLFontStylesContext* )
1127 {
1128 XMLPropertySetMapper *pPropMapper =
1129 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_DEFAULTS );
1130 return new SvXMLImportPropertyMapper( pPropMapper, rImport );
1131 }
1132
1133 SvXMLImportPropertyMapper*
CreateTableRowDefaultExtPropMapper(SvXMLImport & rImport,XMLFontStylesContext *)1134 XMLTextImportHelper::CreateTableRowDefaultExtPropMapper(
1135 SvXMLImport& rImport,
1136 XMLFontStylesContext* )
1137 {
1138 XMLPropertySetMapper *pPropMapper =
1139 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_ROW_DEFAULTS );
1140 return new SvXMLImportPropertyMapper( pPropMapper, rImport );
1141 }
1142
SetCursor(const Reference<XTextCursor> & rCursor)1143 void XMLTextImportHelper::SetCursor( const Reference < XTextCursor > & rCursor )
1144 {
1145 m_pImpl->m_xCursor.set(rCursor);
1146 m_pImpl->m_xText.set(rCursor->getText());
1147 m_pImpl->m_xCursorAsRange.set( rCursor, UNO_QUERY );
1148 }
1149
ResetCursor()1150 void XMLTextImportHelper::ResetCursor()
1151 {
1152 m_pImpl->m_xCursor.set(0);
1153 m_pImpl->m_xText.set(0);
1154 m_pImpl->m_xCursorAsRange.set(0);
1155 }
1156
1157
HasFrameByName(const OUString & rName) const1158 sal_Bool XMLTextImportHelper::HasFrameByName( const OUString& rName ) const
1159 {
1160 return (m_pImpl->m_xTextFrames.is() &&
1161 m_pImpl->m_xTextFrames->hasByName(rName))
1162 || (m_pImpl->m_xGraphics.is() &&
1163 m_pImpl->m_xGraphics->hasByName(rName))
1164 || (m_pImpl->m_xObjects.is() &&
1165 m_pImpl->m_xObjects->hasByName(rName));
1166 }
1167
InsertString(const OUString & rChars)1168 void XMLTextImportHelper::InsertString( const OUString& rChars )
1169 {
1170 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1171 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1172 if (m_pImpl->m_xText.is())
1173 {
1174 m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange,
1175 rChars, sal_False);
1176 }
1177 }
1178
InsertString(const OUString & rChars,sal_Bool & rIgnoreLeadingSpace)1179 void XMLTextImportHelper::InsertString( const OUString& rChars,
1180 sal_Bool& rIgnoreLeadingSpace )
1181 {
1182 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1183 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1184 if (m_pImpl->m_xText.is())
1185 {
1186 sal_Int32 nLen = rChars.getLength();
1187 OUStringBuffer sChars( nLen );
1188
1189 for( sal_Int32 i=0; i < nLen; i++ )
1190 {
1191 sal_Unicode c = rChars[i];
1192 switch( c )
1193 {
1194 case 0x20:
1195 case 0x09:
1196 case 0x0a:
1197 case 0x0d:
1198 if( !rIgnoreLeadingSpace )
1199 sChars.append( (sal_Unicode)0x20 );
1200 rIgnoreLeadingSpace = sal_True;
1201 break;
1202 default:
1203 rIgnoreLeadingSpace = sal_False;
1204 sChars.append( c );
1205 break;
1206 }
1207 }
1208 m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange,
1209 sChars.makeStringAndClear(), sal_False);
1210 }
1211 }
1212
InsertControlCharacter(sal_Int16 nControl)1213 void XMLTextImportHelper::InsertControlCharacter( sal_Int16 nControl )
1214 {
1215 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1216 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1217 if (m_pImpl->m_xText.is())
1218 {
1219 m_pImpl->m_xText->insertControlCharacter(
1220 m_pImpl->m_xCursorAsRange, nControl, sal_False);
1221 }
1222 }
1223
InsertTextContent(Reference<XTextContent> & xContent)1224 void XMLTextImportHelper::InsertTextContent(
1225 Reference < XTextContent > & xContent )
1226 {
1227 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1228 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1229 if (m_pImpl->m_xText.is())
1230 {
1231 m_pImpl->m_xText->insertTextContent(
1232 m_pImpl->m_xCursorAsRange, xContent, sal_False);
1233 }
1234 }
1235
DeleteParagraph()1236 void XMLTextImportHelper::DeleteParagraph()
1237 {
1238 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1239 DBG_ASSERT(m_pImpl->m_xCursor.is(), "no cursor");
1240 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1241
1242 sal_Bool bDelete = sal_True;
1243 Reference < XEnumerationAccess > const xEnumAccess(
1244 m_pImpl->m_xCursor, UNO_QUERY);
1245 if( xEnumAccess.is() )
1246 {
1247 Reference < XEnumeration > xEnum(xEnumAccess->createEnumeration());
1248 DBG_ASSERT( xEnum->hasMoreElements(), "empty text enumeration" );
1249 if( xEnum->hasMoreElements() )
1250 {
1251 Reference < XComponent > xComp( xEnum->nextElement(), UNO_QUERY );
1252 DBG_ASSERT( xComp.is(), "got no component" );
1253 if( xComp.is() )
1254 {
1255 xComp->dispose();
1256 bDelete = sal_False;
1257 }
1258 }
1259 }
1260 if( bDelete )
1261 {
1262 if (m_pImpl->m_xCursor->goLeft( 1, sal_True ))
1263 {
1264 OUString sEmpty;
1265 m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange,
1266 sEmpty, sal_True);
1267 }
1268 }
1269 }
1270
ConvertStarFonts(const OUString & rChars,const OUString & rStyleName,sal_uInt8 & rFlags,sal_Bool bPara,SvXMLImport & rImport) const1271 OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars,
1272 const OUString& rStyleName,
1273 sal_uInt8& rFlags,
1274 sal_Bool bPara,
1275 SvXMLImport& rImport ) const
1276 {
1277 OUStringBuffer sChars( rChars );
1278 sal_Bool bConverted = sal_False;
1279 for( sal_Int32 j=0; j<rChars.getLength(); j++ )
1280 {
1281 sal_Unicode c = rChars[j];
1282 if( c >= 0xf000 && c <= 0xf0ff )
1283 {
1284 if( (rFlags & CONV_STAR_FONT_FLAGS_VALID) == 0 )
1285 {
1286 XMLTextStyleContext *pStyle = 0;
1287 sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH
1288 : XML_STYLE_FAMILY_TEXT_TEXT;
1289 if (rStyleName.getLength() && m_pImpl->m_xAutoStyles.Is())
1290 {
1291 const SvXMLStyleContext* pTempStyle =
1292 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
1293 FindStyleChildContext( nFamily, rStyleName,
1294 sal_True );
1295 pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle);
1296 }
1297
1298 if( pStyle )
1299 {
1300 sal_Int32 nCount = pStyle->_GetProperties().size();
1301 if( nCount )
1302 {
1303 UniReference < SvXMLImportPropertyMapper > xImpPrMap =
1304 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)
1305 ->GetImportPropertyMapper(nFamily);
1306 if( xImpPrMap.is() )
1307 {
1308 UniReference<XMLPropertySetMapper> rPropMapper =
1309 xImpPrMap->getPropertySetMapper();
1310 for( sal_Int32 i=0; i < nCount; i++ )
1311 {
1312 const XMLPropertyState& rProp = pStyle->_GetProperties()[i];
1313 sal_Int32 nIdx = rProp.mnIndex;
1314 sal_uInt32 nContextId = rPropMapper->GetEntryContextId(nIdx);
1315 if( CTF_FONTFAMILYNAME == nContextId )
1316 {
1317 rFlags &= ~(CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH);
1318 OUString sFontName;
1319 rProp.maValue >>= sFontName;
1320 OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM("StarBats" ) );
1321 OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM("StarMath" ) );
1322 if( sFontName.equalsIgnoreAsciiCase( sStarBats ) )
1323 rFlags |= CONV_FROM_STAR_BATS;
1324 else if( sFontName.equalsIgnoreAsciiCase( sStarMath ) )
1325 rFlags |= CONV_FROM_STAR_MATH;
1326 break;
1327 }
1328 }
1329 }
1330 }
1331
1332 }
1333
1334 rFlags |= CONV_STAR_FONT_FLAGS_VALID;
1335 }
1336 if( (rFlags & CONV_FROM_STAR_BATS ) != 0 )
1337 {
1338 sChars.setCharAt( j, rImport.ConvStarBatsCharToStarSymbol( c ) );
1339 bConverted = sal_True;
1340 }
1341 else if( (rFlags & CONV_FROM_STAR_MATH ) != 0 )
1342 {
1343 sChars.setCharAt( j, rImport.ConvStarMathCharToStarSymbol( c ) );
1344 bConverted = sal_True;
1345 }
1346 }
1347 }
1348
1349 return bConverted ? sChars.makeStringAndClear() : rChars;
1350 }
1351
1352 // --> OD 2006-10-12 #i69629#
1353 // helper method to determine, if a paragraph style has a list style (inclusive
1354 // an empty one) inherits a list style (inclusive an empty one) from one of its parents
1355 // --> OD 2007-01-29 #i73973#
1356 // apply special case, that found list style equals the chapter numbering, also
1357 // to the found list styles of the parent styles.
lcl_HasListStyle(OUString sStyleName,const Reference<XNameContainer> & xParaStyles,SvXMLImport & rImport,const OUString & sNumberingStyleName,const OUString & sOutlineStyleName)1358 sal_Bool lcl_HasListStyle( OUString sStyleName,
1359 const Reference < XNameContainer >& xParaStyles,
1360 SvXMLImport& rImport,
1361 const OUString& sNumberingStyleName,
1362 const OUString& sOutlineStyleName )
1363 {
1364 sal_Bool bRet( sal_False );
1365
1366 if ( !xParaStyles->hasByName( sStyleName ) )
1367 {
1368 // error case
1369 return sal_True;
1370 }
1371
1372 Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ),
1373 UNO_QUERY );
1374 if ( !xPropState.is() )
1375 {
1376 // error case
1377 return sal_False;
1378 }
1379
1380 if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
1381 {
1382 // list style found
1383 bRet = sal_True;
1384 // special case: the set list style equals the chapter numbering
1385 Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
1386 if ( xPropSet.is() )
1387 {
1388 OUString sListStyle;
1389 xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
1390 if ( sListStyle.getLength() != 0 &&
1391 sListStyle == sOutlineStyleName )
1392 {
1393 bRet = sal_False;
1394 }
1395 }
1396 }
1397 else
1398 {
1399 // --> OD 2007-12-07 #i77708#
1400 sal_Int32 nUPD( 0 );
1401 sal_Int32 nBuild( 0 );
1402 // --> OD 2008-03-19 #i86058#
1403 // rImport.getBuildIds( nUPD, nBuild );
1404 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1405 // <--
1406 // <--
1407 // search list style at parent
1408 Reference<XStyle> xStyle( xPropState, UNO_QUERY );
1409 while ( xStyle.is() )
1410 {
1411 OUString aParentStyle( xStyle->getParentStyle() );
1412 if ( aParentStyle.getLength() > 0 )
1413 {
1414 aParentStyle =
1415 rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
1416 aParentStyle );
1417 }
1418 if ( aParentStyle.getLength() == 0 ||
1419 !xParaStyles->hasByName( aParentStyle ) )
1420 {
1421 // no list style found
1422 break;
1423 }
1424 else
1425 {
1426 xPropState = Reference< XPropertyState >(
1427 xParaStyles->getByName( aParentStyle ),
1428 UNO_QUERY );
1429 if ( !xPropState.is() )
1430 {
1431 // error case
1432 return sal_True;
1433 }
1434 if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
1435 {
1436 // list style found
1437 bRet = sal_True;
1438 // --> OD 2007-01-29 #i73973#
1439 // special case: the found list style equals the chapter numbering
1440 Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
1441 if ( xPropSet.is() )
1442 {
1443 OUString sListStyle;
1444 xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
1445 if ( sListStyle.getLength() != 0 &&
1446 sListStyle == sOutlineStyleName )
1447 {
1448 bRet = sal_False;
1449 }
1450 // --> OD 2007-12-07 #i77708#
1451 // special handling for text documents from OOo version prior OOo 2.4
1452 // --> OD 2008-03-19 #i86058#
1453 // check explicitly on certain versions and on import of
1454 // text documents in OpenOffice.org file format
1455 else if ( sListStyle.getLength() == 0 &&
1456 ( rImport.IsTextDocInOOoFileFormat() ||
1457 ( bBuildIdFound &&
1458 ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1459 ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1
1460 {
1461 bRet = sal_False;
1462 }
1463 // <--
1464 }
1465 // <--
1466 break;
1467 }
1468 else
1469 {
1470 // search list style at parent
1471 xStyle = Reference<XStyle>( xPropState, UNO_QUERY );
1472 }
1473 }
1474 }
1475 }
1476
1477 return bRet;
1478 }
1479 // <--
SetStyleAndAttrs(SvXMLImport & rImport,const Reference<XTextCursor> & rCursor,const OUString & rStyleName,sal_Bool bPara,sal_Bool bOutlineLevelAttrFound,sal_Int8 nOutlineLevel,sal_Bool bSetListAttrs)1480 OUString XMLTextImportHelper::SetStyleAndAttrs(
1481 SvXMLImport& rImport,
1482 const Reference < XTextCursor >& rCursor,
1483 const OUString& rStyleName,
1484 sal_Bool bPara,
1485 sal_Bool bOutlineLevelAttrFound,
1486 sal_Int8 nOutlineLevel,
1487 // --> OD 2007-08-17 #i80724#
1488 sal_Bool bSetListAttrs )
1489 // <--
1490 {
1491 static ::rtl::OUString s_ParaStyleName(
1492 RTL_CONSTASCII_USTRINGPARAM("ParaStyleName"));
1493 static ::rtl::OUString s_CharStyleName(
1494 RTL_CONSTASCII_USTRINGPARAM("CharStyleName"));
1495 static ::rtl::OUString s_NumberingRules(
1496 RTL_CONSTASCII_USTRINGPARAM("NumberingRules"));
1497 static ::rtl::OUString s_NumberingIsNumber(
1498 RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber"));
1499 static ::rtl::OUString s_NumberingLevel(
1500 RTL_CONSTASCII_USTRINGPARAM("NumberingLevel"));
1501 static ::rtl::OUString s_ParaIsNumberingRestart(
1502 RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart"));
1503 static ::rtl::OUString s_NumberingStartValue(
1504 RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue"));
1505 static ::rtl::OUString s_PropNameListId(
1506 RTL_CONSTASCII_USTRINGPARAM("ListId"));
1507 static ::rtl::OUString s_PageDescName(
1508 RTL_CONSTASCII_USTRINGPARAM("PageDescName"));
1509 static ::rtl::OUString s_ServiceCombinedCharacters(
1510 RTL_CONSTASCII_USTRINGPARAM(
1511 "com.sun.star.text.TextField.CombinedCharacters"));
1512 static ::rtl::OUString s_Content(RTL_CONSTASCII_USTRINGPARAM("Content"));
1513 static ::rtl::OUString s_OutlineLevel(
1514 RTL_CONSTASCII_USTRINGPARAM("OutlineLevel"));
1515 static ::rtl::OUString s_NumberingStyleName(
1516 RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName"));
1517
1518 const sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH
1519 : XML_STYLE_FAMILY_TEXT_TEXT;
1520 XMLTextStyleContext *pStyle = 0;
1521 OUString sStyleName( rStyleName );
1522 if (sStyleName.getLength() && m_pImpl->m_xAutoStyles.Is())
1523 {
1524 const SvXMLStyleContext* pTempStyle =
1525 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
1526 FindStyleChildContext( nFamily, sStyleName, sal_True );
1527 pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle);
1528 }
1529 if( pStyle )
1530 sStyleName = pStyle->GetParentName();
1531
1532 Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
1533 Reference< XPropertySetInfo > xPropSetInfo(
1534 xPropSet->getPropertySetInfo());
1535
1536 // style
1537 if( sStyleName.getLength() )
1538 {
1539 sStyleName = rImport.GetStyleDisplayName( nFamily, sStyleName );
1540 const String& rPropName = (bPara) ? s_ParaStyleName : s_CharStyleName;
1541 const Reference < XNameContainer > & rStyles = (bPara)
1542 ? m_pImpl->m_xParaStyles
1543 : m_pImpl->m_xTextStyles;
1544 if( rStyles.is() &&
1545 xPropSetInfo->hasPropertyByName( rPropName ) &&
1546 rStyles->hasByName( sStyleName ) )
1547 {
1548 xPropSet->setPropertyValue( rPropName, makeAny(sStyleName) );
1549 }
1550 else
1551 sStyleName = OUString();
1552 }
1553
1554 // --> OD 2008-09-10 #i70748#
1555 // The outline level needs to be only applied as list level, if the heading
1556 // is not inside a list and if it by default applies the outline style.
1557 bool bApplyOutlineLevelAsListLevel( false );
1558 // --> OD 2007-08-17 #i80724#
1559 if (bSetListAttrs && bPara
1560 && xPropSetInfo->hasPropertyByName( s_NumberingRules))
1561 // <--
1562 {
1563 // Set numbering rules
1564 Reference< XIndexReplace > const xNumRules(
1565 xPropSet->getPropertyValue(s_NumberingRules), UNO_QUERY);
1566
1567 XMLTextListBlockContext * pListBlock(0);
1568 XMLTextListItemContext * pListItem(0);
1569 XMLNumberedParaContext * pNumberedParagraph(0);
1570 GetTextListHelper().ListContextTop(
1571 pListBlock, pListItem, pNumberedParagraph);
1572
1573 OSL_ENSURE(!(pListBlock && pNumberedParagraph), "XMLTextImportHelper::"
1574 "SetStyleAndAttrs: both list and numbered-paragraph???");
1575
1576 Reference < XIndexReplace > xNewNumRules;
1577 sal_Int8 nLevel(-1);
1578 ::rtl::OUString sListId;
1579 sal_Int16 nStartValue(-1);
1580 bool bNumberingIsNumber(true);
1581
1582 if (pListBlock) {
1583
1584 if (!pListItem) {
1585 bNumberingIsNumber = false; // list-header
1586 }
1587 // --> OD 2008-05-08 #refactorlists#
1588 // consider text:style-override property of <text:list-item>
1589 xNewNumRules.set(
1590 (pListItem != 0 && pListItem->HasNumRulesOverride())
1591 ? pListItem->GetNumRulesOverride()
1592 : pListBlock->GetNumRules() );
1593 // <--
1594 nLevel = static_cast<sal_Int8>(pListBlock->GetLevel());
1595
1596 if ( pListItem && pListItem->HasStartValue() ) {
1597 nStartValue = pListItem->GetStartValue();
1598 }
1599
1600 // --> OD 2008-08-15 #i92811#
1601 sListId = m_pImpl->m_pTextListsHelper->GetListIdForListBlock(
1602 *pListBlock);
1603 // <--
1604 }
1605 else if (pNumberedParagraph)
1606 {
1607 xNewNumRules.set(pNumberedParagraph->GetNumRules());
1608 nLevel = static_cast<sal_Int8>(pNumberedParagraph->GetLevel());
1609 sListId = pNumberedParagraph->GetListId();
1610 nStartValue = pNumberedParagraph->GetStartValue();
1611 }
1612
1613
1614 if (pListBlock || pNumberedParagraph)
1615 {
1616 // --> OD 2009-08-24 #i101349#
1617 // Assure that list style of automatic paragraph style is applied at paragraph.
1618 sal_Bool bApplyNumRules = pStyle && pStyle->IsListStyleSet();
1619 if ( !bApplyNumRules )
1620 {
1621 sal_Bool bSameNumRules = xNewNumRules == xNumRules;
1622 if( !bSameNumRules && xNewNumRules.is() && xNumRules.is() )
1623 {
1624 // If the interface pointers are different then this does
1625 // not mean that the num rules are different. Further tests
1626 // are required then. However, if only one num rule is
1627 // set, no tests are required of course.
1628 Reference< XNamed > xNewNamed( xNewNumRules, UNO_QUERY );
1629 Reference< XNamed > xNamed( xNumRules, UNO_QUERY );
1630 if( xNewNamed.is() && xNamed.is() )
1631 {
1632 bSameNumRules = xNewNamed->getName() == xNamed->getName();
1633 }
1634 else
1635 {
1636 Reference< XAnyCompare > xNumRuleCompare( xNumRules, UNO_QUERY );
1637 if( xNumRuleCompare.is() )
1638 {
1639 bSameNumRules = (xNumRuleCompare->compare( Any(xNumRules), Any(xNewNumRules) ) == 0);
1640 }
1641 }
1642 }
1643 bApplyNumRules = !bSameNumRules;
1644 }
1645
1646 if ( bApplyNumRules )
1647 // <--
1648 {
1649 // #102607# This may except when xNewNumRules contains
1650 // a Writer-NumRule-Implementation bug gets applied to
1651 // a shape. Since this may occur inside a document
1652 // (e.g. when edited), this must be handled
1653 // gracefully.
1654 try
1655 {
1656 xPropSet->setPropertyValue(
1657 s_NumberingRules, makeAny(xNewNumRules) );
1658 }
1659 catch( Exception e )
1660 {
1661 ; // I would really like to use a warning here,
1662 // but I can't access the XMLErrorHandler from
1663 // here.
1664 }
1665 }
1666
1667 if (!bNumberingIsNumber &&
1668 xPropSetInfo->hasPropertyByName(s_NumberingIsNumber))
1669 {
1670 xPropSet->setPropertyValue(s_NumberingIsNumber, Any(sal_False));
1671 }
1672
1673 xPropSet->setPropertyValue( s_NumberingLevel, Any(nLevel) );
1674
1675 if( pListBlock && pListBlock->IsRestartNumbering() )
1676 {
1677 // TODO: property missing
1678 if (xPropSetInfo->hasPropertyByName(s_ParaIsNumberingRestart))
1679 {
1680 sal_Bool bTmp = sal_True;
1681 xPropSet->setPropertyValue(s_ParaIsNumberingRestart,
1682 makeAny(bTmp) );
1683 }
1684 pListBlock->ResetRestartNumbering();
1685 }
1686
1687 if ( 0 <= nStartValue &&
1688 xPropSetInfo->hasPropertyByName(s_NumberingStartValue))
1689 {
1690 xPropSet->setPropertyValue(s_NumberingStartValue,
1691 makeAny(nStartValue));
1692 }
1693
1694 // --> OD 2008-04-23 #refactorlists#
1695 if (xPropSetInfo->hasPropertyByName(s_PropNameListId))
1696 {
1697 if (sListId.getLength()) {
1698 xPropSet->setPropertyValue(s_PropNameListId,
1699 makeAny(sListId) );
1700 }
1701 }
1702 // <--
1703
1704 GetTextListHelper().SetListItem( (XMLTextListItemContext *)0 );
1705 }
1706 else
1707 {
1708 // If the paragraph is not in a list but its style, remove it from
1709 // the list.
1710 // --> OD 2005-10-25 #126347# - do not remove it, if the list
1711 // of the style is the chapter numbering rule.
1712 if( xNumRules.is() )
1713 {
1714 bool bRemove( true );
1715 // --> OD 2008-12-17 #i70748# - special handling for document from OOo 2.x
1716 sal_Int32 nUPD( 0 );
1717 sal_Int32 nBuild( 0 );
1718 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1719 DBG_ASSERT( ( bBuildIdFound && nUPD == 680 ) ||
1720 !pStyle ||
1721 !pStyle->IsListStyleSet() ||
1722 pStyle->GetListStyle().getLength() == 0,
1723 "automatic paragraph style with list style name, but paragraph not in list???" );
1724 if ( ( bBuildIdFound && nUPD == 680 ) ||
1725 !pStyle || !pStyle->IsListStyleSet() )
1726 {
1727 if (m_pImpl->m_xChapterNumbering.is())
1728 {
1729 Reference< XNamed > xNumNamed( xNumRules, UNO_QUERY );
1730 Reference< XNamed > const xChapterNumNamed (
1731 m_pImpl->m_xChapterNumbering, UNO_QUERY);
1732 if ( xNumNamed.is() && xChapterNumNamed.is() &&
1733 xNumNamed->getName() == xChapterNumNamed->getName() )
1734 {
1735 bRemove = false;
1736 // --> OD 2008-09-10 #i70748#
1737 bApplyOutlineLevelAsListLevel = true;
1738 // <--
1739 }
1740 }
1741 }
1742 // <--
1743 if ( bRemove )
1744 {
1745 xPropSet->setPropertyValue( s_NumberingRules, Any() );
1746 }
1747 }
1748 // <--
1749 }
1750 }
1751
1752 // hard paragraph properties
1753 if( pStyle )
1754 {
1755 pStyle->FillPropertySet( xPropSet );
1756 if( bPara && pStyle->HasMasterPageName() &&
1757 xPropSetInfo->hasPropertyByName(s_PageDescName))
1758 {
1759 OUString sDisplayName(
1760 rImport.GetStyleDisplayName(
1761 XML_STYLE_FAMILY_MASTER_PAGE,
1762 pStyle->GetMasterPageName()) );
1763 if( !sDisplayName.getLength() ||
1764 (m_pImpl->m_xPageStyles.is() &&
1765 m_pImpl->m_xPageStyles->hasByName( sDisplayName)))
1766 {
1767 xPropSet->setPropertyValue(s_PageDescName,
1768 makeAny(sDisplayName));
1769 }
1770 }
1771 if( bPara && pStyle->GetDropCapStyleName().getLength() &&
1772 m_pImpl->m_xTextStyles.is())
1773 {
1774 OUString sDisplayName(
1775 rImport.GetStyleDisplayName(
1776 XML_STYLE_FAMILY_TEXT_TEXT,
1777 pStyle->GetDropCapStyleName()) );
1778 if (m_pImpl->m_xTextStyles->hasByName(sDisplayName) &&
1779 xPropSetInfo->hasPropertyByName( sDisplayName ) )
1780 {
1781 xPropSet->setPropertyValue( pStyle->sDropCapCharStyleName, makeAny(sDisplayName) );
1782 }
1783 }
1784
1785 // combined characters special treatment
1786 if (!bPara && pStyle->HasCombinedCharactersLetter())
1787 {
1788 // insert combined characters text field
1789 if (m_pImpl->m_xServiceFactory.is())
1790 {
1791 uno::Reference<beans::XPropertySet> const xTmp(
1792 m_pImpl->m_xServiceFactory->createInstance(
1793 s_ServiceCombinedCharacters), UNO_QUERY);
1794 if( xTmp.is() )
1795 {
1796 // fix cursor if larger than possible for
1797 // combined characters field
1798 if (rCursor->getString().getLength() >
1799 MAX_COMBINED_CHARACTERS)
1800 {
1801 rCursor->gotoRange(rCursor->getStart(), sal_False);
1802 rCursor->goRight(MAX_COMBINED_CHARACTERS, sal_True);
1803 }
1804
1805 // set field value (the combined character string)
1806 xTmp->setPropertyValue(s_Content,
1807 makeAny(rCursor->getString()));
1808
1809 // insert the field over it's original text
1810 Reference<XTextRange> xRange(rCursor, UNO_QUERY);
1811 Reference<XTextContent> xTextContent(xTmp, UNO_QUERY);
1812 if (m_pImpl->m_xText.is() && xRange.is())
1813 {
1814 // #i107225# the combined characters need to be inserted first
1815 // the selected text has to be removed afterwards
1816 m_pImpl->m_xText->insertTextContent( xRange->getStart(), xTextContent, sal_True );
1817
1818 if( xRange->getString().getLength() )
1819 {
1820 try
1821 {
1822 uno::Reference< text::XTextCursor > xCrsr = xRange->getText()->createTextCursorByRange( xRange->getStart() );
1823 xCrsr->goLeft( 1, true );
1824 uno::Reference< beans::XPropertySet> xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW );
1825 //the hard properties of the removed text need to be applied to the combined characters field
1826 pStyle->FillPropertySet( xCrsrProperties );
1827 xCrsr->collapseToEnd();
1828 xCrsr->gotoRange( xRange->getEnd(), true );
1829 xCrsr->setString( ::rtl::OUString() );
1830 }
1831 catch( const uno::Exception& rEx )
1832 {
1833 (void)rEx;
1834 }
1835 }
1836 }
1837 }
1838 }
1839 }
1840 }
1841
1842 // outline level; set after list style has been set
1843 // --> OD 2005-08-25 #i53198#
1844 // Complete re-worked and corrected:
1845 // - set outline level at paragraph
1846 // - set numbering level at paragraph, if none is already set
1847 // - assure that style is marked as an outline style for the corresponding
1848 // outline level.
1849 // - DO NOT set type of numbering rule to outline.
1850 // - DO NOT set numbering rule directly at the paragraph.
1851
1852 // --> OD 2008-12-09 #i70748#
1853 // Some minor rework and adjust access to paragraph styles
1854 if ( bPara )
1855 {
1856 // --> OD 2009-08-18 #i103817#
1857 sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
1858 const bool bHasOutlineLevelProp(
1859 xPropSetInfo->hasPropertyByName(s_OutlineLevel));
1860 if ( bHasOutlineLevelProp )
1861 {
1862 xPropSet->getPropertyValue(s_OutlineLevel)
1863 >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
1864 }
1865 // <--
1866 //if ( bPara && nOutlineLevel != -1 ) //#outline level,removed by zhaojianwei
1867 if ( nOutlineLevel > 0 ) //add by zhaojianwei
1868 {
1869 //#outline level,removed by zhaojianwei
1870 if ( bHasOutlineLevelProp )
1871 {
1872 // In case that the value equals the value of its paragraph style
1873 // attribute outline level, the paragraph attribute value is left unset
1874 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel )
1875 {
1876 xPropSet->setPropertyValue( s_OutlineLevel,
1877 makeAny( static_cast<sal_Int16>(nOutlineLevel) ) );
1878 }
1879 }//<-end,zhaojianwei
1880
1881 // --> OD 2008-09-10 #i70748#
1882 if ( bApplyOutlineLevelAsListLevel )
1883 {
1884 sal_Int16 nNumLevel = -1;
1885 xPropSet->getPropertyValue( s_NumberingLevel ) >>= nNumLevel;
1886 if ( nNumLevel == -1 ||
1887 nNumLevel != (nOutlineLevel - 1) )
1888 {
1889 xPropSet->setPropertyValue( s_NumberingLevel,
1890 makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) );
1891 }
1892 }
1893 // <--
1894 // --> OD 2006-10-13 #i69629# - correction:
1895 // - for text document from version OOo 2.0.4/SO 8 PU4 and earlier
1896 // the paragraph style of a heading should be assigned to the
1897 // corresponding list level of the outline style.
1898 // - for other text documents the paragraph style of a heading is only
1899 // a candidate for an assignment to the list level of the outline
1900 // style, if it has no direct list style property and (if exists) the
1901 // automatic paragraph style has also no direct list style set.
1902 if (m_pImpl->m_xParaStyles->hasByName(sStyleName))
1903 {
1904 bool bOutlineStyleCandidate( false );
1905
1906 sal_Int32 nUPD( 0 );
1907 sal_Int32 nBuild( 0 );
1908 // --> OD 2007-12-19 #152540#
1909 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1910 // --> OD 2007-07-25 #i73509#
1911 // --> OD 2008-03-19 #i86058# - check explicitly on certain versions
1912 if ( rImport.IsTextDocInOOoFileFormat() ||
1913 ( bBuildIdFound &&
1914 ( nUPD == 645 || nUPD == 641 ) ) )
1915 {
1916 bOutlineStyleCandidate = true;
1917 }
1918 else if ( nUPD == 680 && nBuild <= 9073 ) /* BuildId of OOo 2.0.4/SO8 PU4 */
1919 {
1920 bOutlineStyleCandidate = bOutlineLevelAttrFound;
1921 }
1922 // <--
1923 // else
1924 // {
1925 // Reference< XPropertyState > xStylePropState(
1926 // xParaStyles->getByName( sStyleName ), UNO_QUERY );
1927 // if ( xStylePropState.is() &&
1928 // xStylePropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
1929 // {
1930 // bOutlineStyleCandidate = false;
1931 // }
1932 // // --> OD 2007-01-11 #i73361#
1933 // // The automatic paragraph style doesn't have to be considered.
1934 // // else if ( pStyle && /* automatic paragraph style */
1935 // // pStyle->IsListStyleSet() )
1936 // // {
1937 // // bOutlineStyleCandidate = false;
1938 // // }
1939 // // <--
1940 // else
1941 // {
1942 // bOutlineStyleCandidate = true;
1943 // }
1944 // }
1945
1946 if ( bOutlineStyleCandidate )
1947 {
1948 AddOutlineStyleCandidate( nOutlineLevel, sStyleName );
1949 }
1950 // --> OD 2009-08-18 #i103817#
1951 // Assure that heading applies the outline style
1952 if ( ( !pStyle || !pStyle->IsListStyleSet() ) &&
1953 !bOutlineStyleCandidate &&
1954 m_pImpl->m_xChapterNumbering.is())
1955 {
1956 OUString sEmptyStr;
1957 if ( !lcl_HasListStyle( sStyleName,
1958 m_pImpl->m_xParaStyles, GetXMLImport(),
1959 s_NumberingStyleName,
1960 sEmptyStr ) )
1961 {
1962 // heading not in a list --> apply outline style
1963 xPropSet->setPropertyValue( s_NumberingRules,
1964 makeAny(m_pImpl->m_xChapterNumbering) );
1965 xPropSet->setPropertyValue( s_NumberingLevel,
1966 makeAny(static_cast<sal_Int8>(nOutlineLevel - 1)));
1967 }
1968 }
1969 // <--
1970 }
1971 // <--
1972 }
1973 //-> #outlinelevel added by zhaojianwei
1974 //handle for text:p,if the paragraphstyle outlinelevel is set to[1~10]
1975 else if( bHasOutlineLevelProp )
1976 {
1977 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 )
1978 {
1979 sal_Int16 nZero = 0;
1980 xPropSet->setPropertyValue(s_OutlineLevel,
1981 makeAny( static_cast<sal_Int16>(nZero) ));
1982 }
1983 }//<-end,zhaojianwei
1984 }
1985 // <--
1986
1987 return sStyleName;
1988 }
1989
FindOutlineStyleName(::rtl::OUString & rStyleName,sal_Int8 nOutlineLevel)1990 void XMLTextImportHelper::FindOutlineStyleName( ::rtl::OUString& rStyleName,
1991 sal_Int8 nOutlineLevel )
1992 {
1993 static ::rtl::OUString s_HeadingStyleName(
1994 RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName"));
1995
1996 // style name empty?
1997 if( rStyleName.getLength() == 0 )
1998 {
1999 // Empty? Then we need o do stuff. Let's do error checking first.
2000 if (m_pImpl->m_xChapterNumbering.is() &&
2001 ( nOutlineLevel > 0 ) &&
2002 (nOutlineLevel <= m_pImpl->m_xChapterNumbering->getCount()))
2003 {
2004 nOutlineLevel--; // for the remainder, the level's are 0-based
2005
2006 // empty style name: look-up previously used name
2007
2008 // if we don't have a previously used name, we'll use the default
2009 m_pImpl->InitOutlineStylesCandidates();
2010 if (m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel].empty())
2011 {
2012 // no other name used previously? Then use default
2013
2014 // iterate over property value sequence to find the style name
2015 Sequence<PropertyValue> aProperties;
2016 m_pImpl->m_xChapterNumbering->getByIndex( nOutlineLevel )
2017 >>= aProperties;
2018 for( sal_Int32 i = 0; i < aProperties.getLength(); i++ )
2019 {
2020 if (aProperties[i].Name == s_HeadingStyleName)
2021 {
2022 rtl::OUString aOutlineStyle;
2023 aProperties[i].Value >>= aOutlineStyle;
2024 m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel]
2025 .push_back( aOutlineStyle );
2026 break; // early out, if we found it!.
2027 }
2028 }
2029 }
2030
2031 // finally, we'll use the previously used style name for this
2032 // format (or the default we've just put into that style)
2033 // --> OD 2006-11-06 #i71249# - take last added one
2034 rStyleName =
2035 m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel].back();
2036 // <--
2037 }
2038 // else: nothing we can do, so we'll leave it empty
2039 }
2040 // else: we already had a style name, so we let it pass.
2041 }
2042
AddOutlineStyleCandidate(const sal_Int8 nOutlineLevel,const OUString & rStyleName)2043 void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel,
2044 const OUString& rStyleName )
2045 {
2046 if (rStyleName.getLength()
2047 && m_pImpl->m_xChapterNumbering.is()
2048 && (nOutlineLevel > 0)
2049 && (nOutlineLevel <= m_pImpl->m_xChapterNumbering->getCount()))
2050 {
2051 m_pImpl->InitOutlineStylesCandidates();
2052 m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel-1].push_back(
2053 rStyleName);
2054 }
2055 }
2056
SetOutlineStyles(sal_Bool bSetEmptyLevels)2057 void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels )
2058 {
2059 static ::rtl::OUString s_NumberingStyleName(
2060 RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName"));
2061 static ::rtl::OUString s_HeadingStyleName(
2062 RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName"));
2063
2064 if (( bool(m_pImpl->m_pOutlineStylesCandidates) || bSetEmptyLevels) &&
2065 m_pImpl->m_xChapterNumbering.is() &&
2066 !IsInsertMode())
2067 {
2068 bool bChooseLastOne( false );
2069 {
2070 if ( GetXMLImport().IsTextDocInOOoFileFormat() )
2071 {
2072 bChooseLastOne = true;
2073 }
2074 else
2075 {
2076 sal_Int32 nUPD( 0 );
2077 sal_Int32 nBuild( 0 );
2078 if ( GetXMLImport().getBuildIds( nUPD, nBuild ) )
2079 {
2080 // check explicitly on certain versions
2081 bChooseLastOne = ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
2082 ( nUPD == 680 && nBuild <= 9073 ); // OOo 2.0 - OOo 2.0.4
2083 }
2084 }
2085 }
2086
2087 OUString sOutlineStyleName;
2088 {
2089 Reference<XPropertySet> xChapterNumRule(
2090 m_pImpl->m_xChapterNumbering, UNO_QUERY);
2091 const OUString sName(RTL_CONSTASCII_USTRINGPARAM("Name"));
2092 xChapterNumRule->getPropertyValue(sName) >>= sOutlineStyleName;
2093 }
2094
2095 const sal_Int32 nCount = m_pImpl->m_xChapterNumbering->getCount();
2096 // --> OD 2009-11-13 #i106218#
2097 // First collect all paragraph styles chosen for assignment to each
2098 // list level of the outline style, then perform the intrinsic assignment.
2099 // Reason: The assignment of a certain paragraph style to a list level
2100 // of the outline style causes side effects on the children
2101 // paragraph styles in Writer.
2102 ::std::vector<OUString> sChosenStyles(nCount);
2103 // <--
2104 for( sal_Int32 i=0; i < nCount; ++i )
2105 {
2106 if ( bSetEmptyLevels ||
2107 (m_pImpl->m_pOutlineStylesCandidates &&
2108 !m_pImpl->m_pOutlineStylesCandidates[i].empty()))
2109 {
2110 // determine, which candidate is one to be assigned to the list
2111 // level of the outline style
2112 if (m_pImpl->m_pOutlineStylesCandidates &&
2113 !m_pImpl->m_pOutlineStylesCandidates[i].empty())
2114 {
2115 if ( bChooseLastOne )
2116 {
2117 sChosenStyles[i] =
2118 m_pImpl->m_pOutlineStylesCandidates[i].back();
2119 }
2120 else
2121 {
2122 for (sal_uInt32 j = 0;
2123 j < m_pImpl->m_pOutlineStylesCandidates[i].size();
2124 ++j)
2125 {
2126 if (!lcl_HasListStyle(
2127 m_pImpl->m_pOutlineStylesCandidates[i][j],
2128 m_pImpl->m_xParaStyles,
2129 GetXMLImport(),
2130 s_NumberingStyleName,
2131 sOutlineStyleName))
2132 {
2133 sChosenStyles[i] =
2134 m_pImpl->m_pOutlineStylesCandidates[i][j];
2135 break;
2136 }
2137 }
2138 }
2139 }
2140 }
2141 }
2142 // --> OD 2009-11-13 #i106218#
2143 Sequence < PropertyValue > aProps( 1 );
2144 PropertyValue *pProps = aProps.getArray();
2145 pProps->Name = s_HeadingStyleName;
2146 for ( sal_Int32 i = 0; i < nCount; ++i )
2147 {
2148 // --> OD 2009-12-11 #i107610#
2149 if ( bSetEmptyLevels ||
2150 sChosenStyles[i].getLength() > 0 )
2151 // <--
2152 {
2153 pProps->Value <<= sChosenStyles[i];
2154 m_pImpl->m_xChapterNumbering->replaceByIndex(i,
2155 makeAny( aProps ));
2156 }
2157 }
2158 // <--
2159 }
2160 }
2161
SetHyperlink(SvXMLImport & rImport,const Reference<XTextCursor> & rCursor,const OUString & rHRef,const OUString & rName,const OUString & rTargetFrameName,const OUString & rStyleName,const OUString & rVisitedStyleName,XMLEventsImportContext * pEvents)2162 void XMLTextImportHelper::SetHyperlink(
2163 SvXMLImport& rImport,
2164 const Reference < XTextCursor >& rCursor,
2165 const OUString& rHRef,
2166 const OUString& rName,
2167 const OUString& rTargetFrameName,
2168 const OUString& rStyleName,
2169 const OUString& rVisitedStyleName,
2170 XMLEventsImportContext* pEvents)
2171 {
2172 static ::rtl::OUString s_HyperLinkURL(
2173 RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"));
2174 static ::rtl::OUString s_HyperLinkName(
2175 RTL_CONSTASCII_USTRINGPARAM("HyperLinkName"));
2176 static ::rtl::OUString s_HyperLinkTarget(
2177 RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget"));
2178 static ::rtl::OUString s_UnvisitedCharStyleName(
2179 RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName"));
2180 static ::rtl::OUString s_VisitedCharStyleName(
2181 RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName"));
2182 static ::rtl::OUString s_HyperLinkEvents(
2183 RTL_CONSTASCII_USTRINGPARAM("HyperLinkEvents"));
2184
2185 Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
2186 Reference < XPropertySetInfo > xPropSetInfo(
2187 xPropSet->getPropertySetInfo());
2188 if (!xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
2189 return;
2190
2191 xPropSet->setPropertyValue(s_HyperLinkURL, makeAny(rHRef));
2192
2193 if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
2194 {
2195 xPropSet->setPropertyValue(s_HyperLinkName, makeAny(rName));
2196 }
2197
2198 if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
2199 {
2200 xPropSet->setPropertyValue(s_HyperLinkTarget,
2201 makeAny(rTargetFrameName));
2202 }
2203
2204 if ( (pEvents != NULL) &&
2205 xPropSetInfo->hasPropertyByName(s_HyperLinkEvents))
2206 {
2207 // The API treats events at hyperlinks differently from most
2208 // other properties: You have to set a name replace with the
2209 // events in it. The easiest way to to this is to 1) get
2210 // events, 2) set new ones, and 3) then put events back.
2211 uno::Reference<XNameReplace> const xReplace(
2212 xPropSet->getPropertyValue(s_HyperLinkEvents), UNO_QUERY);
2213 if (xReplace.is())
2214 {
2215 // set events
2216 pEvents->SetEvents(xReplace);
2217
2218 // put events
2219 xPropSet->setPropertyValue(s_HyperLinkEvents, makeAny(xReplace));
2220 }
2221 }
2222
2223 if (m_pImpl->m_xTextStyles.is())
2224 {
2225 OUString sDisplayName(
2226 rImport.GetStyleDisplayName(
2227 XML_STYLE_FAMILY_TEXT_TEXT, rStyleName ) );
2228 if( sDisplayName.getLength() &&
2229 xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) &&
2230 m_pImpl->m_xTextStyles->hasByName(sDisplayName))
2231 {
2232 xPropSet->setPropertyValue(s_UnvisitedCharStyleName,
2233 makeAny(sDisplayName));
2234 }
2235
2236 sDisplayName =
2237 rImport.GetStyleDisplayName(
2238 XML_STYLE_FAMILY_TEXT_TEXT, rVisitedStyleName );
2239 if( sDisplayName.getLength() &&
2240 xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) &&
2241 m_pImpl->m_xTextStyles->hasByName(sDisplayName))
2242 {
2243 xPropSet->setPropertyValue(s_VisitedCharStyleName,
2244 makeAny(sDisplayName));
2245 }
2246 }
2247 }
2248
SetRuby(SvXMLImport & rImport,const Reference<XTextCursor> & rCursor,const OUString & rStyleName,const OUString & rTextStyleName,const OUString & rText)2249 void XMLTextImportHelper::SetRuby(
2250 SvXMLImport& rImport,
2251 const Reference < XTextCursor >& rCursor,
2252 const OUString& rStyleName,
2253 const OUString& rTextStyleName,
2254 const OUString& rText )
2255 {
2256 Reference<XPropertySet> xPropSet(rCursor, UNO_QUERY);
2257
2258 OUString sRubyText(RTL_CONSTASCII_USTRINGPARAM("RubyText"));
2259 OUString sRubyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("RubyCharStyleName"));
2260
2261 // if we have one Ruby property, we assume all of them are present
2262 if (xPropSet.is() &&
2263 xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText ))
2264 {
2265 // the ruby text
2266 xPropSet->setPropertyValue(sRubyText, makeAny(rText));
2267
2268 // the ruby style (ruby-adjust)
2269 XMLPropStyleContext *pStyle = 0;
2270 if (rStyleName.getLength() && m_pImpl->m_xAutoStyles.Is())
2271 {
2272 const SvXMLStyleContext* pTempStyle =
2273 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2274 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_RUBY,
2275 rStyleName, sal_True );
2276 pStyle = PTR_CAST(XMLPropStyleContext,pTempStyle);
2277
2278 if (NULL != pStyle)
2279 pStyle->FillPropertySet( xPropSet );
2280 }
2281
2282 // the ruby text character style
2283 if (m_pImpl->m_xTextStyles.is())
2284 {
2285 OUString sDisplayName(
2286 rImport.GetStyleDisplayName(
2287 XML_STYLE_FAMILY_TEXT_TEXT, rTextStyleName ) );
2288 if( (sDisplayName.getLength() > 0) &&
2289 // xPropSetInfo->hasPropertyByName( sRubyCharStyleName ) &&
2290 m_pImpl->m_xTextStyles->hasByName( sDisplayName ))
2291 {
2292 xPropSet->setPropertyValue(sRubyCharStyleName, makeAny(sDisplayName));
2293 }
2294 }
2295 }
2296 }
2297
SetAutoStyles(SvXMLStylesContext * pStyles)2298 void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles )
2299 {
2300 m_pImpl->m_xAutoStyles = pStyles;
2301 }
2302
SetFontDecls(XMLFontStylesContext * pFontDecls)2303 void XMLTextImportHelper::SetFontDecls( XMLFontStylesContext *pFontDecls )
2304 {
2305 m_pImpl->m_xFontDecls = pFontDecls;
2306 ((XMLTextImportPropertyMapper *)m_pImpl->m_xParaImpPrMap.get())
2307 ->SetFontDecls( pFontDecls );
2308 ((XMLTextImportPropertyMapper *)m_pImpl->m_xTextImpPrMap.get())
2309 ->SetFontDecls( pFontDecls );
2310 }
2311
GetFontDecls() const2312 const XMLFontStylesContext *XMLTextImportHelper::GetFontDecls() const
2313 {
2314 return (XMLFontStylesContext *)&m_pImpl->m_xFontDecls;
2315 }
2316
HasDrawNameAttribute(const Reference<XAttributeList> & xAttrList,SvXMLNamespaceMap & rNamespaceMap)2317 sal_Bool XMLTextImportHelper::HasDrawNameAttribute(
2318 const Reference< XAttributeList > & xAttrList,
2319 SvXMLNamespaceMap& rNamespaceMap )
2320 {
2321 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
2322 for( sal_Int16 i=0; i < nAttrCount; i++ )
2323 {
2324 const OUString& rAttrName = xAttrList->getNameByIndex( i );
2325
2326 OUString aLocalName;
2327 sal_uInt16 nPrefix =
2328 rNamespaceMap.GetKeyByAttrName( rAttrName, &aLocalName );
2329 if( XML_NAMESPACE_DRAW == nPrefix &&
2330 IsXMLToken( aLocalName, XML_NAME ) )
2331 {
2332 return xAttrList->getValueByIndex(i).getLength() != 0;
2333 }
2334 }
2335
2336 return sal_False;
2337 }
2338
CreateTextChildContext(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList,XMLTextType eType)2339 SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
2340 SvXMLImport& rImport,
2341 sal_uInt16 nPrefix, const OUString& rLocalName,
2342 const Reference< XAttributeList > & xAttrList,
2343 XMLTextType eType )
2344 {
2345 SvXMLImportContext *pContext = 0;
2346
2347 const SvXMLTokenMap& rTokenMap = GetTextElemTokenMap();
2348 sal_Bool bHeading = sal_False;
2349 sal_Bool bContent = sal_True;
2350 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
2351 switch( nToken )
2352 {
2353 case XML_TOK_TEXT_H:
2354 bHeading = sal_True;
2355 case XML_TOK_TEXT_P:
2356 pContext = new XMLParaContext( rImport,
2357 nPrefix, rLocalName,
2358 xAttrList, bHeading );
2359 if (m_pImpl->m_bProgress && XML_TEXT_TYPE_SHAPE != eType)
2360 {
2361 rImport.GetProgressBarHelper()->Increment();
2362 }
2363 break;
2364 case XML_TOK_TEXT_NUMBERED_PARAGRAPH:
2365 pContext = new XMLNumberedParaContext(
2366 rImport, nPrefix, rLocalName, xAttrList );
2367 break;
2368 case XML_TOK_TEXT_LIST:
2369 pContext = new XMLTextListBlockContext( rImport, *this,
2370 nPrefix, rLocalName,
2371 xAttrList );
2372 break;
2373 case XML_TOK_TABLE_TABLE:
2374 if( XML_TEXT_TYPE_BODY == eType ||
2375 XML_TEXT_TYPE_TEXTBOX == eType ||
2376 XML_TEXT_TYPE_SECTION == eType ||
2377 XML_TEXT_TYPE_HEADER_FOOTER == eType ||
2378 XML_TEXT_TYPE_CHANGED_REGION == eType ||
2379 XML_TEXT_TYPE_CELL == eType )
2380 pContext = CreateTableChildContext( rImport, nPrefix, rLocalName,
2381 xAttrList );
2382 break;
2383 case XML_TOK_TEXT_SEQUENCE_DECLS:
2384 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2385 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2386 {
2387 pContext = new XMLVariableDeclsImportContext(
2388 rImport, *this, nPrefix, rLocalName, VarTypeSequence);
2389 bContent = sal_False;
2390 }
2391 break;
2392
2393 case XML_TOK_TEXT_VARFIELD_DECLS:
2394 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2395 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2396 {
2397 pContext = new XMLVariableDeclsImportContext(
2398 rImport, *this, nPrefix, rLocalName, VarTypeSimple);
2399 bContent = sal_False;
2400 }
2401 break;
2402
2403 case XML_TOK_TEXT_USERFIELD_DECLS:
2404 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted)||
2405 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2406 {
2407 pContext = new XMLVariableDeclsImportContext(
2408 rImport, *this, nPrefix, rLocalName, VarTypeUserField);
2409 bContent = sal_False;
2410 }
2411 break;
2412
2413 case XML_TOK_TEXT_DDE_DECLS:
2414 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2415 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2416 {
2417 pContext = new XMLDdeFieldDeclsImportContext(
2418 rImport, nPrefix, rLocalName);
2419 bContent = sal_False;
2420 }
2421 break;
2422
2423 case XML_TOK_TEXT_FRAME_PAGE:
2424 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2425 XML_TEXT_TYPE_TEXTBOX == eType ||
2426 XML_TEXT_TYPE_CHANGED_REGION == eType )
2427 {
2428 TextContentAnchorType eAnchorType =
2429 XML_TEXT_TYPE_TEXTBOX == eType ? TextContentAnchorType_AT_FRAME
2430 : TextContentAnchorType_AT_PAGE;
2431 pContext = new XMLTextFrameContext( rImport, nPrefix,
2432 rLocalName, xAttrList,
2433 eAnchorType );
2434 bContent = sal_False;
2435 }
2436 break;
2437
2438 case XML_TOK_DRAW_A_PAGE:
2439 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2440 XML_TEXT_TYPE_TEXTBOX == eType ||
2441 XML_TEXT_TYPE_CHANGED_REGION == eType)
2442 {
2443 TextContentAnchorType eAnchorType =
2444 XML_TEXT_TYPE_TEXTBOX == eType ? TextContentAnchorType_AT_FRAME
2445 : TextContentAnchorType_AT_PAGE;
2446 pContext = new XMLTextFrameHyperlinkContext( rImport, nPrefix,
2447 rLocalName, xAttrList,
2448 eAnchorType );
2449 bContent = sal_False;
2450 }
2451 break;
2452
2453 case XML_TOK_TEXT_INDEX_TITLE:
2454 case XML_TOK_TEXT_SECTION:
2455 #ifndef SVX_LIGHT
2456 pContext = new XMLSectionImportContext( rImport, nPrefix, rLocalName );
2457 #else
2458 // create default context to skip content
2459 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2460 #endif // #ifndef SVX_LIGHT
2461 break;
2462
2463 case XML_TOK_TEXT_TOC:
2464 case XML_TOK_TEXT_OBJECT_INDEX:
2465 case XML_TOK_TEXT_TABLE_INDEX:
2466 case XML_TOK_TEXT_ILLUSTRATION_INDEX:
2467 case XML_TOK_TEXT_USER_INDEX:
2468 case XML_TOK_TEXT_ALPHABETICAL_INDEX:
2469 case XML_TOK_TEXT_BIBLIOGRAPHY_INDEX:
2470 #ifndef SVX_LIGHT
2471 if( XML_TEXT_TYPE_SHAPE != eType )
2472 pContext = new XMLIndexTOCContext( rImport, nPrefix, rLocalName );
2473 #else
2474 // create default context to skip content
2475 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2476 #endif // #ifndef SVX_LIGHT
2477 break;
2478
2479 case XML_TOK_TEXT_TRACKED_CHANGES:
2480 #ifndef SVX_LIGHT
2481 pContext = new XMLTrackedChangesImportContext( rImport, nPrefix,
2482 rLocalName);
2483 #else
2484 // create default context to skip content
2485 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2486 #endif // #ifndef SVX_LIGHT
2487 bContent = sal_False;
2488 break;
2489
2490 case XML_TOK_TEXT_CHANGE:
2491 case XML_TOK_TEXT_CHANGE_START:
2492 case XML_TOK_TEXT_CHANGE_END:
2493 pContext = new XMLChangeImportContext(
2494 rImport, nPrefix, rLocalName,
2495 (XML_TOK_TEXT_CHANGE_END != nToken),
2496 (XML_TOK_TEXT_CHANGE_START != nToken),
2497 sal_True);
2498 break;
2499
2500 case XML_TOK_TEXT_FORMS:
2501 #ifndef SVX_LIGHT
2502 pContext = rImport.GetFormImport()->createOfficeFormsContext(rImport, nPrefix, rLocalName);
2503 #else
2504 // create default context to skip content
2505 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2506 #endif // #ifndef SVX_LIGHT
2507 bContent = sal_False;
2508 break;
2509
2510 case XML_TOK_TEXT_AUTOMARK:
2511 if( XML_TEXT_TYPE_BODY == eType )
2512 {
2513 pContext = new XMLAutoMarkFileContext(rImport, nPrefix,rLocalName);
2514 }
2515 bContent = sal_False;
2516 break;
2517
2518 case XML_TOK_TEXT_CALCULATION_SETTINGS:
2519 #ifndef SVX_LIGHT
2520 pContext = new XMLCalculationSettingsContext ( rImport, nPrefix, rLocalName, xAttrList);
2521 #else
2522 // create default context to skip content
2523 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2524 #endif // #ifndef SVX_LIGHT
2525 bContent = sal_False;
2526 break;
2527
2528 default:
2529 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2530 XML_TEXT_TYPE_TEXTBOX == eType ||
2531 XML_TEXT_TYPE_CHANGED_REGION == eType )
2532 {
2533 Reference < XShapes > xShapes;
2534 pContext = rImport.GetShapeImport()->CreateGroupChildContext(
2535 rImport, nPrefix, rLocalName, xAttrList, xShapes );
2536 bContent = sal_False;
2537 }
2538 }
2539
2540 // if( !pContext )
2541 // pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
2542
2543 // handle open redlines
2544 if ( (XML_TOK_TEXT_CHANGE != nToken) &&
2545 (XML_TOK_TEXT_CHANGE_END != nToken) &&
2546 (XML_TOK_TEXT_CHANGE_START != nToken) )
2547 {
2548 // ResetOpenRedlineId();
2549 }
2550
2551 if( XML_TEXT_TYPE_BODY == eType && bContent )
2552 {
2553 m_pImpl->m_bBodyContentStarted = sal_False;
2554 }
2555
2556 return pContext;
2557 }
2558
CreateTableChildContext(SvXMLImport &,sal_uInt16,const OUString &,const Reference<XAttributeList> &)2559 SvXMLImportContext *XMLTextImportHelper::CreateTableChildContext(
2560 SvXMLImport&,
2561 sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/,
2562 const Reference< XAttributeList > & )
2563 {
2564 return 0;
2565 }
2566
2567 /// get data style key for use with NumberFormat property
GetDataStyleKey(const OUString & sStyleName,sal_Bool * pIsSystemLanguage)2568 sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName,
2569 sal_Bool* pIsSystemLanguage )
2570 {
2571 const SvXMLStyleContext* pStyle =
2572 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2573 FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE,
2574 sStyleName, sal_True );
2575
2576 // get appropriate context
2577
2578
2579 // first check if its a impress and draw only number format
2580 // this is needed since its also a SvXMLNumFormatContext,
2581 // that was needed to support them for controls in impress/draw also
2582 SdXMLNumberFormatImportContext* pSdNumStyle = PTR_CAST( SdXMLNumberFormatImportContext, pStyle );
2583 if( pSdNumStyle )
2584 {
2585 return pSdNumStyle->GetDrawKey();
2586 }
2587 else
2588 {
2589 SvXMLNumFormatContext* pNumStyle = PTR_CAST( SvXMLNumFormatContext, pStyle );
2590 if( pNumStyle )
2591 {
2592 if( pIsSystemLanguage != NULL )
2593 *pIsSystemLanguage = pNumStyle->IsSystemLanguage();
2594
2595 // return key
2596 return pNumStyle->GetKey();
2597 }
2598 }
2599 return -1;
2600 }
2601
FindAutoListStyle(const OUString & rName) const2602 const SvxXMLListStyleContext *XMLTextImportHelper::FindAutoListStyle( const OUString& rName ) const
2603 {
2604 const SvxXMLListStyleContext *pStyle = 0;
2605 if (m_pImpl->m_xAutoStyles.Is())
2606 {
2607 const SvXMLStyleContext* pTempStyle =
2608 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2609 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_LIST, rName,
2610 sal_True );
2611 pStyle = PTR_CAST( SvxXMLListStyleContext ,pTempStyle);
2612 }
2613
2614 return pStyle;
2615 }
2616
FindAutoFrameStyle(const OUString & rName) const2617 XMLPropStyleContext *XMLTextImportHelper::FindAutoFrameStyle( const OUString& rName ) const
2618 {
2619 XMLPropStyleContext *pStyle = 0;
2620 if (m_pImpl->m_xAutoStyles.Is())
2621 {
2622 const SvXMLStyleContext* pTempStyle =
2623 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2624 FindStyleChildContext( XML_STYLE_FAMILY_SD_GRAPHICS_ID, rName,
2625 sal_True );
2626 pStyle = PTR_CAST( XMLPropStyleContext ,pTempStyle);
2627 }
2628
2629 return pStyle;
2630 }
2631
FindSectionStyle(const OUString & rName) const2632 XMLPropStyleContext* XMLTextImportHelper::FindSectionStyle(
2633 const OUString& rName ) const
2634 {
2635 XMLPropStyleContext* pStyle = NULL;
2636 if (m_pImpl->m_xAutoStyles.Is())
2637 {
2638 const SvXMLStyleContext* pTempStyle =
2639 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2640 FindStyleChildContext(
2641 XML_STYLE_FAMILY_TEXT_SECTION,
2642 rName, sal_True );
2643 pStyle = PTR_CAST( XMLPropStyleContext,pTempStyle);
2644 }
2645
2646 return pStyle;
2647 }
2648
FindPageMaster(const OUString & rName) const2649 XMLPropStyleContext* XMLTextImportHelper::FindPageMaster(
2650 const OUString& rName ) const
2651 {
2652 XMLPropStyleContext* pStyle = NULL;
2653 if (m_pImpl->m_xAutoStyles.Is())
2654 {
2655 const SvXMLStyleContext* pTempStyle =
2656 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2657 FindStyleChildContext(
2658 XML_STYLE_FAMILY_PAGE_MASTER,
2659 rName, sal_True );
2660 pStyle = PTR_CAST( XMLPropStyleContext,pTempStyle);
2661 }
2662
2663 return pStyle;
2664 }
2665
2666
PushListContext(XMLTextListBlockContext * i_pListBlock)2667 void XMLTextImportHelper::PushListContext(XMLTextListBlockContext *i_pListBlock)
2668 {
2669 GetTextListHelper().PushListContext(i_pListBlock);
2670 }
2671
PopListContext()2672 void XMLTextImportHelper::PopListContext()
2673 {
2674 GetTextListHelper().PopListContext();
2675 }
2676
2677
GetTextNumberedParagraphAttrTokenMap()2678 const SvXMLTokenMap& XMLTextImportHelper::GetTextNumberedParagraphAttrTokenMap()
2679 {
2680 if (!m_pImpl->m_pTextNumberedParagraphAttrTokenMap.get())
2681 {
2682 m_pImpl->m_pTextNumberedParagraphAttrTokenMap.reset(
2683 new SvXMLTokenMap( aTextNumberedParagraphAttrTokenMap ) );
2684 }
2685 return *m_pImpl->m_pTextNumberedParagraphAttrTokenMap;
2686 }
2687
GetTextListBlockAttrTokenMap()2688 const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockAttrTokenMap()
2689 {
2690 if (!m_pImpl->m_pTextListBlockAttrTokenMap.get())
2691 {
2692 m_pImpl->m_pTextListBlockAttrTokenMap.reset(
2693 new SvXMLTokenMap( aTextListBlockAttrTokenMap ) );
2694 }
2695 return *m_pImpl->m_pTextListBlockAttrTokenMap;
2696 }
2697
GetTextListBlockElemTokenMap()2698 const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockElemTokenMap()
2699 {
2700 if (!m_pImpl->m_pTextListBlockElemTokenMap.get())
2701 {
2702 m_pImpl->m_pTextListBlockElemTokenMap.reset(
2703 new SvXMLTokenMap( aTextListBlockElemTokenMap ) );
2704 }
2705 return *m_pImpl->m_pTextListBlockElemTokenMap;
2706 }
2707
GetRenameMap()2708 SvI18NMap& XMLTextImportHelper::GetRenameMap()
2709 {
2710 if (!m_pImpl->m_pRenameMap.get())
2711 {
2712 m_pImpl->m_pRenameMap.reset( new SvI18NMap() );
2713 }
2714 return *m_pImpl->m_pRenameMap;
2715 }
2716
InsertBookmarkStartRange(const OUString sName,const Reference<XTextRange> & rRange,OUString const & i_rXmlId,::boost::shared_ptr<::xmloff::ParsedRDFaAttributes> & i_rpRDFaAttributes)2717 void XMLTextImportHelper::InsertBookmarkStartRange(
2718 const OUString sName,
2719 const Reference<XTextRange> & rRange,
2720 OUString const& i_rXmlId,
2721 ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & i_rpRDFaAttributes)
2722 {
2723 m_pImpl->m_BookmarkStartRanges[sName] =
2724 ::boost::make_tuple(rRange, i_rXmlId, i_rpRDFaAttributes);
2725 m_pImpl->m_BookmarkVector.push_back(sName);
2726 }
2727
FindAndRemoveBookmarkStartRange(const OUString sName,Reference<XTextRange> & o_rRange,OUString & o_rXmlId,::boost::shared_ptr<::xmloff::ParsedRDFaAttributes> & o_rpRDFaAttributes)2728 sal_Bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange(
2729 const OUString sName,
2730 Reference<XTextRange> & o_rRange,
2731 OUString & o_rXmlId,
2732 ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes)
2733 {
2734 if (m_pImpl->m_BookmarkStartRanges.count(sName))
2735 {
2736 Impl::BookmarkMapEntry_t & rEntry =
2737 (*m_pImpl->m_BookmarkStartRanges.find(sName)).second;
2738 o_rRange.set(rEntry.get<0>());
2739 o_rXmlId = rEntry.get<1>();
2740 o_rpRDFaAttributes = rEntry.get<2>();
2741 m_pImpl->m_BookmarkStartRanges.erase(sName);
2742 Impl::BookmarkVector_t::iterator it(m_pImpl->m_BookmarkVector.begin());
2743 while (it != m_pImpl->m_BookmarkVector.end() && it->compareTo(sName)!=0)
2744 {
2745 it++;
2746 }
2747 if (it!=m_pImpl->m_BookmarkVector.end()) {
2748 m_pImpl->m_BookmarkVector.erase(it);
2749 }
2750 return sal_True;
2751 }
2752 else
2753 {
2754 return sal_False;
2755 }
2756 }
2757
FindActiveBookmarkName()2758 ::rtl::OUString XMLTextImportHelper::FindActiveBookmarkName()
2759 {
2760 if (!m_pImpl->m_BookmarkVector.empty()) {
2761 return m_pImpl->m_BookmarkVector.back();
2762 } else return ::rtl::OUString(); // return the empty string on error...
2763 }
2764
GetRangeFor(::rtl::OUString & sName)2765 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > XMLTextImportHelper::GetRangeFor(::rtl::OUString &sName)
2766 {
2767 return m_pImpl->m_BookmarkStartRanges[sName].get<0>();
2768 }
2769
2770
pushFieldCtx(::rtl::OUString name,::rtl::OUString type)2771 void XMLTextImportHelper::pushFieldCtx( ::rtl::OUString name, ::rtl::OUString type )
2772 {
2773 m_pImpl->m_FieldStack.push(Impl::field_stack_item_t(
2774 Impl::field_name_type_t(name, type), Impl::field_params_t()));
2775 }
2776
popFieldCtx()2777 void XMLTextImportHelper::popFieldCtx()
2778 {
2779 m_pImpl->m_FieldStack.pop();
2780 }
2781
addFieldParam(::rtl::OUString name,::rtl::OUString value)2782 void XMLTextImportHelper::addFieldParam( ::rtl::OUString name, ::rtl::OUString value )
2783 {
2784 DBG_ASSERT(!m_pImpl->m_FieldStack.empty(),
2785 "stack is empty: not good! Do a pushFieldCtx before...");
2786 if (!m_pImpl->m_FieldStack.empty()) {
2787 Impl::field_stack_item_t & FieldStackItem(m_pImpl->m_FieldStack.top());
2788 FieldStackItem.second.push_back(Impl::field_param_t( name, value ));
2789 }
2790 }
getCurrentFieldName()2791 ::rtl::OUString XMLTextImportHelper::getCurrentFieldName()
2792 {
2793 DBG_ASSERT(!m_pImpl->m_FieldStack.empty(),
2794 "stack is empty: not good! Do a pushFieldCtx before...");
2795 if (!m_pImpl->m_FieldStack.empty()) {
2796 return m_pImpl->m_FieldStack.top().first.first;
2797 } else return ::rtl::OUString();
2798 }
2799
getCurrentFieldType()2800 ::rtl::OUString XMLTextImportHelper::getCurrentFieldType()
2801 {
2802 DBG_ASSERT(!m_pImpl->m_FieldStack.empty(),
2803 "stack is empty: not good! Do a pushFieldCtx before...");
2804 if (!m_pImpl->m_FieldStack.empty()) {
2805 return m_pImpl->m_FieldStack.top().first.second;
2806 } else return ::rtl::OUString();
2807 }
2808
hasCurrentFieldCtx()2809 bool XMLTextImportHelper::hasCurrentFieldCtx()
2810 {
2811 return !m_pImpl->m_FieldStack.empty();
2812 }
2813
setCurrentFieldParamsTo(::com::sun::star::uno::Reference<::com::sun::star::text::XFormField> & xFormField)2814 void XMLTextImportHelper::setCurrentFieldParamsTo(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField> &xFormField)
2815 {
2816 DBG_ASSERT(!m_pImpl->m_FieldStack.empty(),
2817 "stack is empty: not good! Do a pushFieldCtx before...");
2818 if (!m_pImpl->m_FieldStack.empty() && xFormField.is())
2819 {
2820 FieldParamImporter(&m_pImpl->m_FieldStack.top().second,
2821 xFormField->getParameters()).Import();
2822 }
2823 }
2824
2825
ConnectFrameChains(const OUString & rFrmName,const OUString & rNextFrmName,const Reference<XPropertySet> & rFrmPropSet)2826 void XMLTextImportHelper::ConnectFrameChains(
2827 const OUString& rFrmName,
2828 const OUString& rNextFrmName,
2829 const Reference < XPropertySet >& rFrmPropSet )
2830 {
2831 static ::rtl::OUString s_ChainNextName(
2832 RTL_CONSTASCII_USTRINGPARAM("ChainNextName"));
2833 static ::rtl::OUString s_ChainPrevName(
2834 RTL_CONSTASCII_USTRINGPARAM("ChainPrevName"));
2835
2836 if( !rFrmName.getLength() )
2837 return;
2838
2839 if( rNextFrmName.getLength() )
2840 {
2841 OUString sNextFrmName(GetRenameMap().Get( XML_TEXT_RENAME_TYPE_FRAME,
2842 rNextFrmName ));
2843 if (m_pImpl->m_xTextFrames.is()
2844 && m_pImpl->m_xTextFrames->hasByName(sNextFrmName))
2845 {
2846 rFrmPropSet->setPropertyValue(s_ChainNextName,
2847 makeAny(sNextFrmName));
2848 }
2849 else
2850 {
2851 if (!m_pImpl->m_pPrevFrmNames.get())
2852 {
2853 m_pImpl->m_pPrevFrmNames.reset( new SvStringsDtor );
2854 m_pImpl->m_pNextFrmNames.reset( new SvStringsDtor );
2855 }
2856 m_pImpl->m_pPrevFrmNames->Insert( new String( rFrmName ),
2857 m_pImpl->m_pPrevFrmNames->Count() );
2858 m_pImpl->m_pNextFrmNames->Insert( new String( sNextFrmName ),
2859 m_pImpl->m_pNextFrmNames->Count() );
2860 }
2861 }
2862 if (m_pImpl->m_pPrevFrmNames.get() && m_pImpl->m_pPrevFrmNames->Count())
2863 {
2864 sal_uInt16 nCount = m_pImpl->m_pPrevFrmNames->Count();
2865 for( sal_uInt16 i=0; i<nCount; i++ )
2866 {
2867 String *pNext = (*m_pImpl->m_pNextFrmNames)[i];
2868 if( OUString(*pNext) == rFrmName )
2869 {
2870 // The previuous frame must exist, because it existing than
2871 // inserting the entry
2872 String *pPrev = (*m_pImpl->m_pPrevFrmNames)[i];
2873
2874 rFrmPropSet->setPropertyValue(s_ChainPrevName,
2875 makeAny(OUString( *pPrev )));
2876
2877 m_pImpl->m_pPrevFrmNames->Remove( i, 1 );
2878 m_pImpl->m_pNextFrmNames->Remove( i, 1 );
2879 delete pPrev;
2880 delete pNext;
2881
2882 // There cannot be more than one previous frames
2883 break;
2884 }
2885 }
2886 }
2887 }
2888
IsInFrame() const2889 sal_Bool XMLTextImportHelper::IsInFrame() const
2890 {
2891 static ::rtl::OUString s_TextFrame(
2892 RTL_CONSTASCII_USTRINGPARAM("TextFrame"));
2893
2894 sal_Bool bIsInFrame = sal_False;
2895
2896 // are we currently in a text frame? yes, if the cursor has a
2897 // TextFrame property and it's non-NULL
2898 Reference<XPropertySet> xPropSet(((XMLTextImportHelper *)this)->GetCursor(), UNO_QUERY);
2899 if (xPropSet.is())
2900 {
2901 if (xPropSet->getPropertySetInfo()->hasPropertyByName(s_TextFrame))
2902 {
2903 uno::Reference<XTextFrame> const xFrame(
2904 xPropSet->getPropertyValue(s_TextFrame), UNO_QUERY);
2905
2906 if (xFrame.is())
2907 {
2908 bIsInFrame = sal_True;
2909 }
2910 }
2911 }
2912
2913 return bIsInFrame;
2914 }
2915
IsInHeaderFooter() const2916 sal_Bool XMLTextImportHelper::IsInHeaderFooter() const
2917 {
2918 return sal_False;
2919 }
2920
createAndInsertOLEObject(SvXMLImport &,const OUString &,const OUString &,const OUString &,sal_Int32,sal_Int32)2921 Reference< XPropertySet> XMLTextImportHelper::createAndInsertOLEObject(
2922 SvXMLImport&,
2923 const OUString& /*rHRef*/,
2924 const OUString& /*rStyleName*/,
2925 const OUString& /*rTblName*/,
2926 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2927 {
2928 Reference< XPropertySet> xPropSet;
2929 return xPropSet;
2930 }
2931
createAndInsertOOoLink(SvXMLImport &,const OUString &,const OUString &,const OUString &,sal_Int32,sal_Int32)2932 Reference< XPropertySet> XMLTextImportHelper::createAndInsertOOoLink(
2933 SvXMLImport&,
2934 const OUString& /*rHRef*/,
2935 const OUString& /*rStyleName*/,
2936 const OUString& /*rTblName*/,
2937 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2938 {
2939 Reference< XPropertySet> xPropSet;
2940 return xPropSet;
2941 }
2942
createAndInsertApplet(const OUString &,const OUString &,sal_Bool,const OUString &,sal_Int32,sal_Int32)2943 Reference< XPropertySet> XMLTextImportHelper::createAndInsertApplet(
2944 const OUString& /*rCode*/,
2945 const OUString& /*rName*/,
2946 sal_Bool /*bMayScript*/,
2947 const OUString& /*rHRef*/,
2948 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2949 {
2950 Reference< XPropertySet> xPropSet;
2951 return xPropSet;
2952 }
createAndInsertPlugin(const OUString &,const OUString &,sal_Int32,sal_Int32)2953 Reference< XPropertySet> XMLTextImportHelper::createAndInsertPlugin(
2954 const OUString& /*rMimeType*/,
2955 const OUString& /*rHRef*/,
2956 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2957 {
2958 Reference< XPropertySet> xPropSet;
2959 return xPropSet;
2960 }
createAndInsertFloatingFrame(const OUString &,const OUString &,const OUString &,sal_Int32,sal_Int32)2961 Reference< XPropertySet> XMLTextImportHelper::createAndInsertFloatingFrame(
2962 const OUString& /*rName*/,
2963 const OUString& /*rHRef*/,
2964 const OUString& /*rStyleName*/,
2965 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2966 {
2967 Reference< XPropertySet> xPropSet;
2968 return xPropSet;
2969 }
2970
endAppletOrPlugin(const Reference<XPropertySet> &,std::map<const rtl::OUString,rtl::OUString,UStringLess> &)2971 void XMLTextImportHelper::endAppletOrPlugin(
2972 const Reference < XPropertySet> &,
2973 std::map < const rtl::OUString, rtl::OUString, UStringLess > &)
2974 {
2975 }
2976 // redline helper: dummy implementation to be overridden in sw/filter/xml
RedlineAdd(const OUString &,const OUString &,const OUString &,const OUString &,const DateTime &,sal_Bool)2977 void XMLTextImportHelper::RedlineAdd(
2978 const OUString& /*rType*/,
2979 const OUString& /*rId*/,
2980 const OUString& /*rAuthor*/,
2981 const OUString& /*rComment*/,
2982 const DateTime& /*rDateTime*/,
2983 sal_Bool /*bMergeLastPara*/)
2984 {
2985 // dummy implementation: do nothing
2986 }
2987
RedlineCreateText(Reference<XTextCursor> &,const OUString &)2988 Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText(
2989 Reference<XTextCursor> & /*rOldCursor*/,
2990 const OUString& /*rId*/)
2991 {
2992 // dummy implementation: do nothing
2993 Reference<XTextCursor> xRet;
2994 return xRet;
2995 }
2996
RedlineSetCursor(const OUString &,sal_Bool,sal_Bool)2997 void XMLTextImportHelper::RedlineSetCursor(
2998 const OUString& /*rId*/,
2999 sal_Bool /*bStart*/,
3000 sal_Bool /*bIsOutsideOfParagraph*/)
3001 {
3002 // dummy implementation: do nothing
3003 }
3004
RedlineAdjustStartNodeCursor(sal_Bool)3005 void XMLTextImportHelper::RedlineAdjustStartNodeCursor(sal_Bool)
3006 {
3007 // dummy implementation: do nothing
3008 }
3009
SetShowChanges(sal_Bool)3010 void XMLTextImportHelper::SetShowChanges( sal_Bool )
3011 {
3012 // dummy implementation: do nothing
3013 }
3014
SetRecordChanges(sal_Bool)3015 void XMLTextImportHelper::SetRecordChanges( sal_Bool )
3016 {
3017 // dummy implementation: do nothing
3018 }
SetChangesProtectionKey(const Sequence<sal_Int8> &)3019 void XMLTextImportHelper::SetChangesProtectionKey(const Sequence<sal_Int8> &)
3020 {
3021 // dummy implementation: do nothing
3022 }
3023
3024
GetOpenRedlineId()3025 OUString XMLTextImportHelper::GetOpenRedlineId()
3026 {
3027 return m_pImpl->m_sOpenRedlineIdentifier;
3028 }
3029
SetOpenRedlineId(::rtl::OUString & rId)3030 void XMLTextImportHelper::SetOpenRedlineId( ::rtl::OUString& rId)
3031 {
3032 m_pImpl->m_sOpenRedlineIdentifier = rId;
3033 }
3034
ResetOpenRedlineId()3035 void XMLTextImportHelper::ResetOpenRedlineId()
3036 {
3037 OUString sEmpty;
3038 SetOpenRedlineId(sEmpty);
3039 }
3040
3041 void
SetCellParaStyleDefault(::rtl::OUString const & rNewValue)3042 XMLTextImportHelper::SetCellParaStyleDefault(::rtl::OUString const& rNewValue)
3043 {
3044 m_pImpl->m_sCellParaStyleDefault = rNewValue;
3045 }
3046
GetCellParaStyleDefault()3047 ::rtl::OUString const& XMLTextImportHelper::GetCellParaStyleDefault()
3048 {
3049 return m_pImpl->m_sCellParaStyleDefault;
3050 }
3051
3052