update dev300-m58
[ooovba.git] / xmloff / source / text / txtimp.cxx
blob18f7e55788a0cf8e258614b9cec9b431e2e2bc89
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtimp.cxx,v $
10 * $Revision: 1.143.2.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <tools/solar.h>
34 #include <tools/debug.hxx>
35 #ifndef _SVSTDARR_STRINGSDTOR_DECL
36 #define _SVSTDARR_STRINGSDTOR
37 #include <svtools/svstdarr.hxx>
38 #endif
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/beans/PropertyValue.hpp>
41 #include <com/sun/star/container/XEnumerationAccess.hpp>
42 #include <com/sun/star/container/XNameContainer.hpp>
43 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
44 #include <com/sun/star/text/XTextCursor.hpp>
45 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
46 #include <com/sun/star/text/XTextFramesSupplier.hpp>
47 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
48 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
49 #include <com/sun/star/text/TextContentAnchorType.hpp>
50 #include <com/sun/star/text/XTextFrame.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 "xmlnmspe.hxx"
58 #include <xmloff/txtstyli.hxx>
59 #include <xmloff/families.hxx>
60 #include <xmloff/xmlnumfi.hxx>
61 #include <xmloff/xmlnumi.hxx>
63 #include "txtparai.hxx"
64 #include <xmloff/txtimp.hxx>
65 #include <xmloff/txtprmap.hxx>
66 #include "txtimppr.hxx"
67 #include <xmloff/xmlimp.hxx>
68 #include "txtvfldi.hxx"
69 #include "i18nmap.hxx"
70 #include "XMLTextListItemContext.hxx"
71 #include "XMLTextListBlockContext.hxx"
72 #include "XMLTextFrameContext.hxx"
73 #include "XMLPropertyBackpatcher.hxx"
74 #include "XMLTextFrameHyperlinkContext.hxx"
75 #include "XMLSectionImportContext.hxx"
76 #include "XMLIndexTOCContext.hxx"
77 #include <xmloff/XMLFontStylesContext.hxx>
78 #include <xmloff/ProgressBarHelper.hxx>
79 #include <xmloff/nmspmap.hxx>
80 #include <xmloff/XMLEventsImportContext.hxx>
81 #include "XMLTrackedChangesImportContext.hxx"
82 #include "XMLChangeImportContext.hxx"
83 #include "XMLAutoMarkFileContext.hxx"
85 #include "XMLCalculationSettingsContext.hxx"
86 #include <xmloff/formsimp.hxx>
87 #include "XMLNumberStylesImport.hxx"
88 // --> OD 2006-10-12 #i69629#
89 #include <com/sun/star/beans/XPropertyState.hpp>
90 // <--
92 // --> OD 2008-04-25 #refactorlists#
93 #include <txtlists.hxx>
94 // <--
96 using ::rtl::OUString;
97 using ::rtl::OUStringBuffer;
98 using ::com::sun::star::ucb::XAnyCompare;
100 using namespace ::std;
101 using namespace ::com::sun::star::uno;
102 using namespace ::com::sun::star::beans;
103 using namespace ::com::sun::star::text;
104 using namespace ::com::sun::star::frame;
105 using namespace ::com::sun::star::style;
106 using namespace ::com::sun::star::container;
107 using namespace ::com::sun::star::drawing;
108 using namespace ::com::sun::star::xml::sax;
109 using namespace ::com::sun::star::lang;
110 using namespace ::xmloff::token;
111 using ::com::sun::star::util::DateTime;
112 using namespace ::com::sun::star::ucb;
114 using ::comphelper::UStringLess;
116 static __FAR_DATA SvXMLTokenMapEntry aTextElemTokenMap[] =
118 { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TEXT_P },
119 { XML_NAMESPACE_TEXT, XML_H, XML_TOK_TEXT_H },
120 { XML_NAMESPACE_TEXT, XML_LIST, XML_TOK_TEXT_LIST },
121 { XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_TEXT_FRAME_PAGE },
122 { XML_NAMESPACE_DRAW, XML_A, XML_TOK_DRAW_A_PAGE },
123 { XML_NAMESPACE_TABLE,XML_TABLE, XML_TOK_TABLE_TABLE },
124 // { XML_NAMESPACE_TABLE,XML_SUB_TABLE, XML_TOK_TABLE_SUBTABLE },
125 { XML_NAMESPACE_TEXT, XML_VARIABLE_DECLS, XML_TOK_TEXT_VARFIELD_DECLS },
126 { XML_NAMESPACE_TEXT, XML_USER_FIELD_DECLS, XML_TOK_TEXT_USERFIELD_DECLS },
127 { XML_NAMESPACE_TEXT, XML_SEQUENCE_DECLS, XML_TOK_TEXT_SEQUENCE_DECLS },
128 { XML_NAMESPACE_TEXT, XML_DDE_CONNECTION_DECLS, XML_TOK_TEXT_DDE_DECLS },
129 { XML_NAMESPACE_TEXT, XML_SECTION, XML_TOK_TEXT_SECTION },
130 { XML_NAMESPACE_TEXT, XML_TABLE_OF_CONTENT, XML_TOK_TEXT_TOC },
131 { XML_NAMESPACE_TEXT, XML_OBJECT_INDEX, XML_TOK_TEXT_OBJECT_INDEX },
132 { XML_NAMESPACE_TEXT, XML_TABLE_INDEX, XML_TOK_TEXT_TABLE_INDEX },
133 { XML_NAMESPACE_TEXT, XML_ILLUSTRATION_INDEX, XML_TOK_TEXT_ILLUSTRATION_INDEX },
134 { XML_NAMESPACE_TEXT, XML_USER_INDEX, XML_TOK_TEXT_USER_INDEX },
135 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX, XML_TOK_TEXT_ALPHABETICAL_INDEX },
136 { XML_NAMESPACE_TEXT, XML_BIBLIOGRAPHY, XML_TOK_TEXT_BIBLIOGRAPHY_INDEX },
137 { XML_NAMESPACE_TEXT, XML_INDEX_TITLE, XML_TOK_TEXT_INDEX_TITLE },
138 { XML_NAMESPACE_TEXT, XML_TRACKED_CHANGES, XML_TOK_TEXT_TRACKED_CHANGES },
139 { XML_NAMESPACE_TEXT, XML_CHANGE_START, XML_TOK_TEXT_CHANGE_START },
140 { XML_NAMESPACE_TEXT, XML_CHANGE_END, XML_TOK_TEXT_CHANGE_END },
141 { XML_NAMESPACE_TEXT, XML_CHANGE, XML_TOK_TEXT_CHANGE },
142 { XML_NAMESPACE_OFFICE, XML_FORMS, XML_TOK_TEXT_FORMS },
143 { XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, XML_TOK_TEXT_CALCULATION_SETTINGS },
144 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE, XML_TOK_TEXT_AUTOMARK },
145 // --> FLR #i52127#
146 { XML_NAMESPACE_TEXT, XML_NUMBERED_PARAGRAPH, XML_TOK_TEXT_NUMBERED_PARAGRAPH },
147 // <--
149 XML_TOKEN_MAP_END
152 static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] =
154 { XML_NAMESPACE_TEXT, XML_SPAN, XML_TOK_TEXT_SPAN },
155 { XML_NAMESPACE_TEXT, XML_TAB, XML_TOK_TEXT_TAB_STOP },
156 { XML_NAMESPACE_TEXT, XML_LINE_BREAK, XML_TOK_TEXT_LINE_BREAK },
157 { XML_NAMESPACE_TEXT, XML_SOFT_PAGE_BREAK, XML_TOK_TEXT_SOFT_PAGE_BREAK },
158 { XML_NAMESPACE_TEXT, XML_S, XML_TOK_TEXT_S },
159 { XML_NAMESPACE_TEXT, XML_A, XML_TOK_TEXT_HYPERLINK },
160 { XML_NAMESPACE_TEXT, XML_RUBY, XML_TOK_TEXT_RUBY },
162 { XML_NAMESPACE_TEXT, XML_NOTE, XML_TOK_TEXT_NOTE },
163 { XML_NAMESPACE_TEXT, XML_BOOKMARK, XML_TOK_TEXT_BOOKMARK },
164 { XML_NAMESPACE_TEXT, XML_BOOKMARK_START, XML_TOK_TEXT_BOOKMARK_START },
165 { XML_NAMESPACE_TEXT, XML_BOOKMARK_END, XML_TOK_TEXT_BOOKMARK_END },
166 { XML_NAMESPACE_TEXT, XML_REFERENCE_MARK, XML_TOK_TEXT_REFERENCE },
167 { XML_NAMESPACE_TEXT, XML_REFERENCE_MARK_START,
168 XML_TOK_TEXT_REFERENCE_START },
169 { XML_NAMESPACE_TEXT, XML_REFERENCE_MARK_END,
170 XML_TOK_TEXT_REFERENCE_END },
172 { XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_TEXT_FRAME },
173 { XML_NAMESPACE_DRAW, XML_A, XML_TOK_DRAW_A },
175 // index marks
176 { XML_NAMESPACE_TEXT, XML_TOC_MARK, XML_TOK_TEXT_TOC_MARK },
177 { XML_NAMESPACE_TEXT, XML_TOC_MARK_START, XML_TOK_TEXT_TOC_MARK_START },
178 { XML_NAMESPACE_TEXT, XML_TOC_MARK_END, XML_TOK_TEXT_TOC_MARK_END },
179 { XML_NAMESPACE_TEXT, XML_USER_INDEX_MARK, XML_TOK_TEXT_USER_INDEX_MARK },
180 { XML_NAMESPACE_TEXT, XML_USER_INDEX_MARK_START,
181 XML_TOK_TEXT_USER_INDEX_MARK_START },
182 { XML_NAMESPACE_TEXT, XML_USER_INDEX_MARK_END,
183 XML_TOK_TEXT_USER_INDEX_MARK_END },
184 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_MARK,
185 XML_TOK_TEXT_ALPHA_INDEX_MARK },
186 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_MARK_START,
187 XML_TOK_TEXT_ALPHA_INDEX_MARK_START },
188 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_MARK_END,
189 XML_TOK_TEXT_ALPHA_INDEX_MARK_END },
191 // sender fields
192 { XML_NAMESPACE_TEXT, XML_SENDER_FIRSTNAME,XML_TOK_TEXT_SENDER_FIRSTNAME},
193 { XML_NAMESPACE_TEXT, XML_SENDER_LASTNAME, XML_TOK_TEXT_SENDER_LASTNAME },
194 { XML_NAMESPACE_TEXT, XML_SENDER_INITIALS, XML_TOK_TEXT_SENDER_INITIALS },
195 { XML_NAMESPACE_TEXT, XML_SENDER_TITLE, XML_TOK_TEXT_SENDER_TITLE },
196 { XML_NAMESPACE_TEXT, XML_SENDER_POSITION, XML_TOK_TEXT_SENDER_POSITION },
197 { XML_NAMESPACE_TEXT, XML_SENDER_EMAIL, XML_TOK_TEXT_SENDER_EMAIL },
198 { XML_NAMESPACE_TEXT, XML_SENDER_PHONE_PRIVATE,
199 XML_TOK_TEXT_SENDER_PHONE_PRIVATE },
200 { XML_NAMESPACE_TEXT, XML_SENDER_FAX, XML_TOK_TEXT_SENDER_FAX },
201 { XML_NAMESPACE_TEXT, XML_SENDER_COMPANY, XML_TOK_TEXT_SENDER_COMPANY },
202 { XML_NAMESPACE_TEXT, XML_SENDER_PHONE_WORK,
203 XML_TOK_TEXT_SENDER_PHONE_WORK },
204 { XML_NAMESPACE_TEXT, XML_SENDER_STREET, XML_TOK_TEXT_SENDER_STREET },
205 { XML_NAMESPACE_TEXT, XML_SENDER_CITY, XML_TOK_TEXT_SENDER_CITY },
206 { XML_NAMESPACE_TEXT, XML_SENDER_POSTAL_CODE,
207 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 },
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 },
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 },
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 },
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 },
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,
272 XML_TOK_TEXT_HIDDEN_PARAGRAPH },
273 { XML_NAMESPACE_TEXT, XML_CONDITIONAL_TEXT,
274 XML_TOK_TEXT_CONDITIONAL_TEXT },
275 { XML_NAMESPACE_TEXT, XML_FILE_NAME, XML_TOK_TEXT_FILENAME },
276 { XML_NAMESPACE_TEXT, XML_CHAPTER, XML_TOK_TEXT_CHAPTER },
277 { XML_NAMESPACE_TEXT, XML_TEMPLATE_NAME, XML_TOK_TEXT_TEMPLATENAME },
278 { XML_NAMESPACE_TEXT, XML_PARAGRAPH_COUNT, XML_TOK_TEXT_PARAGRAPH_COUNT },
279 { XML_NAMESPACE_TEXT, XML_WORD_COUNT, XML_TOK_TEXT_WORD_COUNT },
280 { XML_NAMESPACE_TEXT, XML_TABLE_COUNT, XML_TOK_TEXT_TABLE_COUNT },
281 { XML_NAMESPACE_TEXT, XML_CHARACTER_COUNT, XML_TOK_TEXT_CHARACTER_COUNT },
282 { XML_NAMESPACE_TEXT, XML_IMAGE_COUNT, XML_TOK_TEXT_IMAGE_COUNT },
283 { XML_NAMESPACE_TEXT, XML_OBJECT_COUNT, XML_TOK_TEXT_OBJECT_COUNT },
284 { XML_NAMESPACE_TEXT, XML_PAGE_COUNT, XML_TOK_TEXT_PAGE_COUNT },
285 { XML_NAMESPACE_TEXT, XML_PAGE_VARIABLE_GET, XML_TOK_TEXT_GET_PAGE_VAR },
286 { XML_NAMESPACE_TEXT, XML_PAGE_VARIABLE_SET, XML_TOK_TEXT_SET_PAGE_VAR },
287 { XML_NAMESPACE_TEXT, XML_EXECUTE_MACRO, XML_TOK_TEXT_MACRO },
288 { XML_NAMESPACE_TEXT, XML_DDE_CONNECTION, XML_TOK_TEXT_DDE },
289 { XML_NAMESPACE_TEXT, XML_REFERENCE_REF, XML_TOK_TEXT_REFERENCE_REF },
290 { XML_NAMESPACE_TEXT, XML_BOOKMARK_REF, XML_TOK_TEXT_BOOKMARK_REF },
291 { XML_NAMESPACE_TEXT, XML_SEQUENCE_REF, XML_TOK_TEXT_SEQUENCE_REF },
292 { XML_NAMESPACE_TEXT, XML_NOTE_REF, XML_TOK_TEXT_NOTE_REF },
293 { XML_NAMESPACE_TEXT, XML_BIBLIOGRAPHY_MARK,
294 XML_TOK_TEXT_BIBLIOGRAPHY_MARK },
295 { XML_NAMESPACE_OFFICE, XML_ANNOTATION, XML_TOK_TEXT_ANNOTATION },
296 { XML_NAMESPACE_TEXT, XML_SCRIPT, XML_TOK_TEXT_SCRIPT },
297 { XML_NAMESPACE_TEXT, XML_TABLE_FORMULA, XML_TOK_TEXT_TABLE_FORMULA },
298 { XML_NAMESPACE_TEXT, XML_DROPDOWN, XML_TOK_TEXT_DROPDOWN },
300 // Calc fields
301 { XML_NAMESPACE_TEXT, XML_SHEET_NAME, XML_TOK_TEXT_SHEET_NAME },
303 // draw fields
304 { XML_NAMESPACE_TEXT, XML_MEASURE, XML_TOK_TEXT_MEASURE },
306 // RDF metadata
307 { XML_NAMESPACE_TEXT, XML_META, XML_TOK_TEXT_META },
308 { XML_NAMESPACE_TEXT, XML_META_FIELD, XML_TOK_TEXT_META_FIELD },
310 // redlining (aka change tracking)
311 { XML_NAMESPACE_TEXT, XML_CHANGE_START, XML_TOK_TEXTP_CHANGE_START },
312 { XML_NAMESPACE_TEXT, XML_CHANGE_END , XML_TOK_TEXTP_CHANGE_END },
313 { XML_NAMESPACE_TEXT, XML_CHANGE, XML_TOK_TEXTP_CHANGE },
315 { XML_NAMESPACE_PRESENTATION, XML_HEADER, XML_TOK_DRAW_HEADER },
316 { XML_NAMESPACE_PRESENTATION, XML_FOOTER, XML_TOK_DRAW_FOOTER },
317 { XML_NAMESPACE_PRESENTATION, XML_DATE_TIME, XML_TOK_DRAW_DATE_TIME },
318 { XML_NAMESPACE_TEXT, XML_PAGE_CONTINUATION, XML_TOK_TEXT_PAGE_CONTINUATION },
320 { XML_NAMESPACE_FIELD, XML_FIELDMARK, XML_TOK_TEXT_FIELDMARK },
321 { XML_NAMESPACE_FIELD, XML_FIELDMARK_START, XML_TOK_TEXT_FIELDMARK_START },
322 { XML_NAMESPACE_FIELD, XML_FIELDMARK_END, XML_TOK_TEXT_FIELDMARK_END },
325 XML_TOKEN_MAP_END
328 static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] =
330 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_P_XMLID },
331 { XML_NAMESPACE_XHTML, XML_ABOUT, XML_TOK_TEXT_P_ABOUT },
332 { XML_NAMESPACE_XHTML, XML_PROPERTY, XML_TOK_TEXT_P_PROPERTY },
333 { XML_NAMESPACE_XHTML, XML_CONTENT, XML_TOK_TEXT_P_CONTENT },
334 { XML_NAMESPACE_XHTML, XML_DATATYPE, XML_TOK_TEXT_P_DATATYPE },
335 { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_P_STYLE_NAME },
336 { XML_NAMESPACE_TEXT, XML_COND_STYLE_NAME,
337 XML_TOK_TEXT_P_COND_STYLE_NAME },
338 { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,XML_TOK_TEXT_P_LEVEL },
339 { XML_NAMESPACE_TEXT, XML_ID, XML_TOK_TEXT_P_ID },
340 { XML_NAMESPACE_TEXT, XML_IS_LIST_HEADER,XML_TOK_TEXT_P_IS_LIST_HEADER },
341 { XML_NAMESPACE_TEXT, XML_RESTART_NUMBERING,XML_TOK_TEXT_P_RESTART_NUMBERING },
342 { XML_NAMESPACE_TEXT, XML_START_VALUE,XML_TOK_TEXT_P_START_VALUE },
344 { XML_NAMESPACE_TEXT, XML_CLASS_NAMES, XML_TOK_TEXT_P_CLASS_NAMES },
345 XML_TOKEN_MAP_END
348 static __FAR_DATA SvXMLTokenMapEntry aTextNumberedParagraphAttrTokenMap[] =
350 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID },
351 { XML_NAMESPACE_TEXT, XML_LIST_ID,
352 XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID },
353 { XML_NAMESPACE_TEXT, XML_LEVEL, XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL },
354 { XML_NAMESPACE_TEXT, XML_STYLE_NAME,
355 XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME },
356 { XML_NAMESPACE_TEXT, XML_CONTINUE_NUMBERING,
357 XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING },
358 { XML_NAMESPACE_TEXT, XML_START_VALUE,
359 XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE },
360 XML_TOKEN_MAP_END
363 static __FAR_DATA SvXMLTokenMapEntry aTextListBlockAttrTokenMap[] =
365 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_LIST_BLOCK_XMLID },
366 { XML_NAMESPACE_TEXT, XML_STYLE_NAME,
367 XML_TOK_TEXT_LIST_BLOCK_STYLE_NAME },
368 { XML_NAMESPACE_TEXT, XML_CONTINUE_NUMBERING,
369 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_NUMBERING },
370 // --> OD 2008-04-22 #refactorlists#
371 { XML_NAMESPACE_TEXT, XML_CONTINUE_LIST,
372 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_LIST },
373 XML_TOKEN_MAP_END
376 static __FAR_DATA SvXMLTokenMapEntry aTextListBlockElemTokenMap[] =
378 { XML_NAMESPACE_TEXT, XML_LIST_HEADER, XML_TOK_TEXT_LIST_HEADER },
379 { XML_NAMESPACE_TEXT, XML_LIST_ITEM, XML_TOK_TEXT_LIST_ITEM },
380 XML_TOKEN_MAP_END
383 static __FAR_DATA SvXMLTokenMapEntry aTextFrameAttrTokenMap[] =
385 { XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_TEXT_FRAME_STYLE_NAME },
386 { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_TEXT_FRAME_NAME },
387 { XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, XML_TOK_TEXT_FRAME_ANCHOR_TYPE },
388 { XML_NAMESPACE_TEXT, XML_ANCHOR_PAGE_NUMBER, XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER },
389 { XML_NAMESPACE_SVG, XML_X, XML_TOK_TEXT_FRAME_X },
390 { XML_NAMESPACE_SVG, XML_Y, XML_TOK_TEXT_FRAME_Y },
391 { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_TEXT_FRAME_WIDTH },
392 { XML_NAMESPACE_FO, XML_MIN_WIDTH, XML_TOK_TEXT_FRAME_MIN_WIDTH },
393 { XML_NAMESPACE_STYLE, XML_REL_WIDTH, XML_TOK_TEXT_FRAME_REL_WIDTH },
394 { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_TEXT_FRAME_HEIGHT },
395 { XML_NAMESPACE_FO, XML_MIN_HEIGHT, XML_TOK_TEXT_FRAME_MIN_HEIGHT },
396 { XML_NAMESPACE_STYLE, XML_REL_HEIGHT, XML_TOK_TEXT_FRAME_REL_HEIGHT },
397 { XML_NAMESPACE_DRAW, XML_CHAIN_NEXT_NAME, XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME },
398 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_FRAME_HREF },
399 { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_TEXT_FRAME_FILTER_NAME },
400 { XML_NAMESPACE_DRAW, XML_ZINDEX, XML_TOK_TEXT_FRAME_Z_INDEX },
401 { XML_NAMESPACE_SVG, XML_TRANSFORM, XML_TOK_TEXT_FRAME_TRANSFORM },
402 { XML_NAMESPACE_DRAW, XML_CLASS_ID, XML_TOK_TEXT_FRAME_CLASS_ID },
403 { XML_NAMESPACE_DRAW, XML_CODE, XML_TOK_TEXT_FRAME_CODE },
404 { XML_NAMESPACE_DRAW, XML_OBJECT, XML_TOK_TEXT_FRAME_OBJECT },
405 { XML_NAMESPACE_DRAW, XML_ARCHIVE, XML_TOK_TEXT_FRAME_ARCHIVE },
406 { XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, XML_TOK_TEXT_FRAME_MAY_SCRIPT },
407 { XML_NAMESPACE_DRAW, XML_MIME_TYPE, XML_TOK_TEXT_FRAME_MIME_TYPE },
408 { XML_NAMESPACE_DRAW, XML_APPLET_NAME, XML_TOK_TEXT_FRAME_APPLET_NAME },
409 { XML_NAMESPACE_DRAW, XML_FRAME_NAME, XML_TOK_TEXT_FRAME_FRAME_NAME },
410 { XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE },
411 { XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_TABLE, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE },
412 XML_TOKEN_MAP_END
415 static __FAR_DATA SvXMLTokenMapEntry aTextContourAttrTokenMap[] =
417 { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_TEXT_CONTOUR_WIDTH },
418 { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_TEXT_CONTOUR_HEIGHT },
419 { XML_NAMESPACE_SVG, XML_VIEWBOX, XML_TOK_TEXT_CONTOUR_VIEWBOX },
420 { XML_NAMESPACE_SVG, XML_D, XML_TOK_TEXT_CONTOUR_D },
421 { XML_NAMESPACE_DRAW,XML_POINTS, XML_TOK_TEXT_CONTOUR_POINTS },
422 { XML_NAMESPACE_DRAW,XML_RECREATE_ON_EDIT, XML_TOK_TEXT_CONTOUR_AUTO },
423 XML_TOKEN_MAP_END
426 static __FAR_DATA SvXMLTokenMapEntry aTextHyperlinkAttrTokenMap[] =
428 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_HYPERLINK_HREF },
429 { XML_NAMESPACE_OFFICE, XML_NAME, XML_TOK_TEXT_HYPERLINK_NAME },
430 { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_TEXT_HYPERLINK_SHOW },
431 { XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, XML_TOK_TEXT_HYPERLINK_TARGET_FRAME },
432 { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_HYPERLINK_STYLE_NAME },
433 { XML_NAMESPACE_TEXT, XML_VISITED_STYLE_NAME, XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME },
434 { XML_NAMESPACE_OFFICE, XML_SERVER_MAP, XML_TOK_TEXT_HYPERLINK_SERVER_MAP },
435 XML_TOKEN_MAP_END
438 static __FAR_DATA SvXMLTokenMapEntry aTextMasterPageElemTokenMap[] =
440 { XML_NAMESPACE_STYLE, XML_HEADER, XML_TOK_TEXT_MP_HEADER },
441 { XML_NAMESPACE_STYLE, XML_FOOTER, XML_TOK_TEXT_MP_FOOTER },
442 { XML_NAMESPACE_STYLE, XML_HEADER_LEFT, XML_TOK_TEXT_MP_HEADER_LEFT },
443 { XML_NAMESPACE_STYLE, XML_FOOTER_LEFT, XML_TOK_TEXT_MP_FOOTER_LEFT },
445 XML_TOKEN_MAP_END
448 // maximum allowed length of combined characters field
449 #define MAX_COMBINED_CHARACTERS 6
452 XMLTextImportHelper::XMLTextImportHelper(
453 const Reference < XModel >& rModel,
454 SvXMLImport& rImport,
455 sal_Bool bInsertM, sal_Bool bStylesOnlyM,
456 sal_Bool bPrg,
457 sal_Bool bBlockM,
458 sal_Bool bOrganizerM )
459 : pTextElemTokenMap( 0 )
460 , pTextPElemTokenMap( 0 )
461 , pTextPAttrTokenMap( 0 )
462 , pTextFieldAttrTokenMap( 0 )
463 , pTextNumberedParagraphAttrTokenMap( 0 )
464 , pTextListBlockAttrTokenMap( 0 )
465 , pTextListBlockElemTokenMap( 0 )
466 , pTextFrameAttrTokenMap( 0 )
467 , pTextContourAttrTokenMap( 0 )
468 , pTextHyperlinkAttrTokenMap( 0 )
469 , pTextMasterPageElemTokenMap( 0 )
470 , pPrevFrmNames( 0 )
471 , pNextFrmNames( 0 )
473 // --> OD 2008-04-25 #refactorlists#
474 , mpTextListsHelper( new XMLTextListsHelper() )
475 // <--
477 , pRenameMap( 0 )
478 // --> OD 2006-10-12 #i69629#
479 , mpOutlineStylesCandidates( 0 )
480 // <--
482 , pFootnoteBackpatcher( NULL )
483 , pSequenceIdBackpatcher( NULL )
484 , pSequenceNameBackpatcher( NULL )
486 , xServiceFactory( rModel, UNO_QUERY )
488 , rSvXMLImport( rImport )
490 , bInsertMode( bInsertM )
491 , bStylesOnlyMode( bStylesOnlyM )
492 , bBlockMode( bBlockM )
493 , bProgress( bPrg )
494 , bOrganizerMode( bOrganizerM )
495 , bBodyContentStarted( sal_True )
497 // #107848#
498 // Initialize inside_deleted_section flag correctly
499 , bInsideDeleteContext( sal_False )
501 , sParaStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName"))
502 , sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName"))
503 , sHeadingStyleName(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName"))
504 , sNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("NumberingLevel"))
505 , sNumberingStartValue(RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue"))
506 , sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules"))
507 , sParaIsNumberingRestart(RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart"))
508 , sNumberingIsNumber(RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber"))
509 , sCurrentPresentation(RTL_CONSTASCII_USTRINGPARAM("CurrentPresentation"))
510 , sSequenceNumber(RTL_CONSTASCII_USTRINGPARAM("SequenceNumber"))
511 , sSourceName(RTL_CONSTASCII_USTRINGPARAM("SourceName"))
512 , sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
513 , sChainPrevName(RTL_CONSTASCII_USTRINGPARAM("ChainPrevName"))
514 , sHyperLinkURL(RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"))
515 , sHyperLinkName(RTL_CONSTASCII_USTRINGPARAM("HyperLinkName"))
516 , sHyperLinkTarget(RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget"))
517 , sUnvisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName"))
518 , sVisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName"))
519 , sTextFrame(RTL_CONSTASCII_USTRINGPARAM("TextFrame"))
520 , sPageDescName(RTL_CONSTASCII_USTRINGPARAM("PageDescName"))
521 , sServerMap(RTL_CONSTASCII_USTRINGPARAM("ServerMap"))
522 , sHyperLinkEvents(RTL_CONSTASCII_USTRINGPARAM("HyperLinkEvents"))
523 , sContent(RTL_CONSTASCII_USTRINGPARAM("Content"))
524 , sServiceCombinedCharacters(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.CombinedCharacters"))
525 , sNumberingStyleName(RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName"))
526 // --> OD 2008-04-23 #refactorlists#
527 , sPropNameDefaultListId(RTL_CONSTASCII_USTRINGPARAM("DefaultListId"))
528 , sPropNameListId(RTL_CONSTASCII_USTRINGPARAM("ListId"))
529 , sOutlineLevel( RTL_CONSTASCII_USTRINGPARAM("OutlineLevel")) //#outline level,add by zhaojianwei
530 // <--
532 Reference< XChapterNumberingSupplier > xCNSupplier( rModel, UNO_QUERY );
534 if( xCNSupplier.is() )
536 xChapterNumbering = xCNSupplier->getChapterNumberingRules();
537 // --> OD 2008-05-15 #refactorlists#
538 if ( xChapterNumbering.is() )
540 Reference< XPropertySet > xNumRuleProps( xChapterNumbering, UNO_QUERY );
541 if ( xNumRuleProps.is() )
543 Reference< XPropertySetInfo > xNumRulePropSetInfo(
544 xNumRuleProps->getPropertySetInfo());
545 if ( xNumRulePropSetInfo.is() &&
546 xNumRulePropSetInfo->hasPropertyByName( sPropNameDefaultListId) )
548 ::rtl::OUString sListId;
549 xNumRuleProps->getPropertyValue( sPropNameDefaultListId ) >>= sListId;
550 DBG_ASSERT( sListId.getLength() != 0,
551 "no default list id found at chapter numbering rules instance. Serious defect -> please inform OD." );
552 if ( sListId.getLength() )
554 Reference< XNamed > xChapterNumNamed( xChapterNumbering, UNO_QUERY );
555 if ( xChapterNumNamed.is() )
557 mpTextListsHelper->KeepListAsProcessed(
558 sListId,
559 xChapterNumNamed->getName(),
560 ::rtl::OUString() );
566 // <--
569 Reference< XStyleFamiliesSupplier > xFamiliesSupp( rModel, UNO_QUERY );
570 // DBG_ASSERT( xFamiliesSupp.is(), "no chapter numbering supplier" ); for clipboard there may be documents without styles
572 if( xFamiliesSupp.is() )
574 Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
576 const OUString aParaStyles(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles"));
577 if( xFamilies->hasByName( aParaStyles ) )
579 xParaStyles.set(xFamilies->getByName( aParaStyles ), UNO_QUERY);
582 const OUString aCharStyles(RTL_CONSTASCII_USTRINGPARAM("CharacterStyles"));
583 if( xFamilies->hasByName( aCharStyles ) )
585 xTextStyles.set(xFamilies->getByName( aCharStyles ), UNO_QUERY);
588 const OUString aNumStyles(RTL_CONSTASCII_USTRINGPARAM("NumberingStyles"));
589 if( xFamilies->hasByName( aNumStyles ) )
591 xNumStyles.set(xFamilies->getByName( aNumStyles ), UNO_QUERY);
594 const OUString aFrameStyles(RTL_CONSTASCII_USTRINGPARAM("FrameStyles"));
595 if( xFamilies->hasByName( aFrameStyles ) )
597 xFrameStyles.set(xFamilies->getByName( aFrameStyles ), UNO_QUERY);
600 const OUString aPageStyles(RTL_CONSTASCII_USTRINGPARAM("PageStyles"));
601 if( xFamilies->hasByName( aPageStyles ) )
603 xPageStyles.set(xFamilies->getByName( aPageStyles ), UNO_QUERY);
607 Reference < XTextFramesSupplier > xTFS( rModel, UNO_QUERY );
608 if( xTFS.is() )
609 xTextFrames.set(xTFS->getTextFrames());
611 Reference < XTextGraphicObjectsSupplier > xTGOS( rModel, UNO_QUERY );
612 if( xTGOS.is() )
613 xGraphics.set(xTGOS->getGraphicObjects());
615 Reference < XTextEmbeddedObjectsSupplier > xTEOS( rModel, UNO_QUERY );
616 if( xTEOS.is() )
617 xObjects.set(xTEOS->getEmbeddedObjects());
619 XMLPropertySetMapper *pPropMapper =
620 new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA );
621 xParaImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport );
623 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
624 xTextImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport );
626 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
627 xFrameImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport );
629 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION );
630 xSectionImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport );
632 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY );
633 xRubyImpPrMap = new SvXMLImportPropertyMapper( pPropMapper, rImport );
636 XMLTextImportHelper::~XMLTextImportHelper()
638 // --> OD 2006-10-12 #i69629#
639 delete [] mpOutlineStylesCandidates;
640 // <--
642 aBookmarkVector.clear();
644 _FinitBackpatcher();
647 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateShapeExtPropMapper(SvXMLImport& rImport)
649 XMLPropertySetMapper *pPropMapper =
650 new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
651 return new XMLTextImportPropertyMapper( pPropMapper, rImport,
652 const_cast<XMLFontStylesContext*>(rImport.GetFontDecls()) );
655 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateCharExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext *pFontDecls)
657 XMLPropertySetMapper *pPropMapper =
658 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
659 if (!pFontDecls)
660 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
661 return new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
664 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext *pFontDecls)
666 XMLPropertySetMapper *pPropMapper =
667 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
668 if (!pFontDecls)
669 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
670 return new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
673 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaDefaultExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext* pFontDecls)
675 if (!pFontDecls)
676 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
678 XMLPropertySetMapper* pPropMapper =
679 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
680 SvXMLImportPropertyMapper* pImportMapper = new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
682 pPropMapper =
683 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS );
684 pImportMapper->ChainImportMapper( new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls ) );
686 return pImportMapper;
689 SvXMLImportPropertyMapper*
690 XMLTextImportHelper::CreateTableDefaultExtPropMapper(
691 SvXMLImport& rImport,
692 XMLFontStylesContext* )
694 XMLPropertySetMapper *pPropMapper =
695 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_DEFAULTS );
696 return new SvXMLImportPropertyMapper( pPropMapper, rImport );
699 SvXMLImportPropertyMapper*
700 XMLTextImportHelper::CreateTableRowDefaultExtPropMapper(
701 SvXMLImport& rImport,
702 XMLFontStylesContext* )
704 XMLPropertySetMapper *pPropMapper =
705 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_ROW_DEFAULTS );
706 return new SvXMLImportPropertyMapper( pPropMapper, rImport );
709 void XMLTextImportHelper::SetCursor( const Reference < XTextCursor > & rCursor )
711 xCursor.set(rCursor);
712 xText.set(rCursor->getText());
713 xCursorAsRange.set( rCursor, UNO_QUERY );
716 void XMLTextImportHelper::ResetCursor()
718 xCursor.set(0);
719 xText.set(0);
720 xCursorAsRange.set(0);
723 SvXMLTokenMap *XMLTextImportHelper::_GetTextElemTokenMap()
725 return new SvXMLTokenMap( aTextElemTokenMap );
728 SvXMLTokenMap *XMLTextImportHelper::_GetTextPElemTokenMap()
730 return new SvXMLTokenMap( aTextPElemTokenMap );
733 SvXMLTokenMap *XMLTextImportHelper::_GetTextPAttrTokenMap()
735 return new SvXMLTokenMap( aTextPAttrTokenMap );
738 SvXMLTokenMap *XMLTextImportHelper::_GetTextFrameAttrTokenMap()
740 return new SvXMLTokenMap( aTextFrameAttrTokenMap );
743 SvXMLTokenMap *XMLTextImportHelper::_GetTextContourAttrTokenMap()
745 return new SvXMLTokenMap( aTextContourAttrTokenMap );
749 SvXMLTokenMap *XMLTextImportHelper::_GetTextHyperlinkAttrTokenMap()
751 return new SvXMLTokenMap( aTextHyperlinkAttrTokenMap );
754 SvXMLTokenMap *XMLTextImportHelper::_GetTextMasterPageElemTokenMap()
756 return new SvXMLTokenMap( aTextMasterPageElemTokenMap );
759 sal_Bool XMLTextImportHelper::HasFrameByName( const OUString& rName ) const
761 return ( xTextFrames.is() && xTextFrames->hasByName( rName ) ) ||
762 ( xGraphics.is() && xGraphics->hasByName( rName ) ) ||
763 ( xObjects.is() && xObjects->hasByName( rName ) );
766 void XMLTextImportHelper::InsertString( const OUString& rChars )
768 DBG_ASSERT( xText.is(), "no text" );
769 DBG_ASSERT( xCursorAsRange.is(), "no range" );
770 if( xText.is() )
771 xText->insertString( xCursorAsRange, rChars, sal_False );
774 void XMLTextImportHelper::InsertString( const OUString& rChars,
775 sal_Bool& rIgnoreLeadingSpace )
777 DBG_ASSERT( xText.is(), "no text" );
778 DBG_ASSERT( xCursorAsRange.is(), "no range" );
779 if( xText.is() )
781 sal_Int32 nLen = rChars.getLength();
782 OUStringBuffer sChars( nLen );
784 for( sal_Int32 i=0; i < nLen; i++ )
786 sal_Unicode c = rChars[i];
787 switch( c )
789 case 0x20:
790 case 0x09:
791 case 0x0a:
792 case 0x0d:
793 if( !rIgnoreLeadingSpace )
794 sChars.append( (sal_Unicode)0x20 );
795 rIgnoreLeadingSpace = sal_True;
796 break;
797 default:
798 rIgnoreLeadingSpace = sal_False;
799 sChars.append( c );
800 break;
803 xText->insertString( xCursorAsRange, sChars.makeStringAndClear(),
804 sal_False );
807 void XMLTextImportHelper::InsertControlCharacter( sal_Int16 nControl )
809 DBG_ASSERT( xText.is(), "no text" );
810 DBG_ASSERT( xCursorAsRange.is(), "no range" );
811 if( xText.is() )
812 xText->insertControlCharacter( xCursorAsRange, nControl, sal_False );
815 void XMLTextImportHelper::InsertTextContent(
816 Reference < XTextContent > & xContent )
818 DBG_ASSERT( xText.is(), "no text" );
819 DBG_ASSERT( xCursorAsRange.is(), "no range" );
820 if( xText.is() )
821 xText->insertTextContent( xCursorAsRange, xContent, sal_False );
824 void XMLTextImportHelper::DeleteParagraph()
826 DBG_ASSERT( xText.is(), "no text" );
827 DBG_ASSERT( xCursor.is(), "no cursor" );
828 DBG_ASSERT( xCursorAsRange.is(), "no range" );
830 sal_Bool bDelete = sal_True;
831 Reference < XEnumerationAccess > xEnumAccess( xCursor, UNO_QUERY );
832 if( xEnumAccess.is() )
834 Reference < XEnumeration > xEnum(xEnumAccess->createEnumeration());
835 DBG_ASSERT( xEnum->hasMoreElements(), "empty text enumeration" );
836 if( xEnum->hasMoreElements() )
838 Reference < XComponent > xComp( xEnum->nextElement(), UNO_QUERY );
839 DBG_ASSERT( xComp.is(), "got no component" );
840 if( xComp.is() )
842 xComp->dispose();
843 bDelete = sal_False;
847 if( bDelete )
849 if( xCursor->goLeft( 1, sal_True ) )
851 OUString sEmpty;
852 xText->insertString( xCursorAsRange, sEmpty, sal_True );
857 OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars,
858 const OUString& rStyleName,
859 sal_uInt8& rFlags,
860 sal_Bool bPara,
861 SvXMLImport& rImport ) const
863 OUStringBuffer sChars( rChars );
864 sal_Bool bConverted = sal_False;
865 for( sal_Int32 j=0; j<rChars.getLength(); j++ )
867 sal_Unicode c = rChars[j];
868 if( c >= 0xf000 && c <= 0xf0ff )
870 if( (rFlags & CONV_STAR_FONT_FLAGS_VALID) == 0 )
872 XMLTextStyleContext *pStyle = 0;
873 sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH
874 : XML_STYLE_FAMILY_TEXT_TEXT;
875 if( rStyleName.getLength() && xAutoStyles.Is() )
877 const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)->
878 FindStyleChildContext( nFamily, rStyleName,
879 sal_True );
880 pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle);
883 if( pStyle )
885 sal_Int32 nCount = pStyle->_GetProperties().size();
886 if( nCount )
888 UniReference < SvXMLImportPropertyMapper > xImpPrMap =
889 ((SvXMLStylesContext *)&xAutoStyles)->GetImportPropertyMapper(nFamily);
890 if( xImpPrMap.is() )
892 UniReference<XMLPropertySetMapper> rPropMapper =
893 xImpPrMap->getPropertySetMapper();
894 for( sal_Int32 i=0; i < nCount; i++ )
896 const XMLPropertyState& rProp = pStyle->_GetProperties()[i];
897 sal_Int32 nIdx = rProp.mnIndex;
898 sal_uInt32 nContextId = rPropMapper->GetEntryContextId(nIdx);
899 if( CTF_FONTFAMILYNAME == nContextId )
901 rFlags &= ~(CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH);
902 OUString sFontName;
903 rProp.maValue >>= sFontName;
904 OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM("StarBats" ) );
905 OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM("StarMath" ) );
906 if( sFontName.equalsIgnoreAsciiCase( sStarBats ) )
907 rFlags |= CONV_FROM_STAR_BATS;
908 else if( sFontName.equalsIgnoreAsciiCase( sStarMath ) )
909 rFlags |= CONV_FROM_STAR_MATH;
910 break;
918 rFlags |= CONV_STAR_FONT_FLAGS_VALID;
920 if( (rFlags & CONV_FROM_STAR_BATS ) != 0 )
922 sChars.setCharAt( j, rImport.ConvStarBatsCharToStarSymbol( c ) );
923 bConverted = sal_True;
925 else if( (rFlags & CONV_FROM_STAR_MATH ) != 0 )
927 sChars.setCharAt( j, rImport.ConvStarMathCharToStarSymbol( c ) );
928 bConverted = sal_True;
933 return bConverted ? sChars.makeStringAndClear() : rChars;
936 // --> OD 2006-10-12 #i69629#
937 // helper method to determine, if a paragraph style has a list style (inclusive
938 // an empty one) inherits a list style (inclusive an empty one) from one of its parents
939 // --> OD 2007-01-29 #i73973#
940 // apply special case, that found list style equals the chapter numbering, also
941 // to the found list styles of the parent styles.
942 sal_Bool lcl_HasListStyle( OUString sStyleName,
943 const Reference < XNameContainer >& xParaStyles,
944 SvXMLImport& rImport,
945 const OUString& sNumberingStyleName,
946 const OUString& sOutlineStyleName )
948 sal_Bool bRet( sal_False );
950 if ( !xParaStyles->hasByName( sStyleName ) )
952 // error case
953 return sal_True;
956 Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ),
957 UNO_QUERY );
958 if ( !xPropState.is() )
960 // error case
961 return sal_False;
964 if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
966 // list style found
967 bRet = sal_True;
968 // special case: the set list style equals the chapter numbering
969 Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
970 if ( xPropSet.is() )
972 OUString sListStyle;
973 xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
974 if ( sListStyle.getLength() != 0 &&
975 sListStyle == sOutlineStyleName )
977 bRet = sal_False;
981 else
983 // --> OD 2007-12-07 #i77708#
984 sal_Int32 nUPD( 0 );
985 sal_Int32 nBuild( 0 );
986 // --> OD 2008-03-19 #i86058#
987 // rImport.getBuildIds( nUPD, nBuild );
988 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
989 // <--
990 // <--
991 // search list style at parent
992 Reference<XStyle> xStyle( xPropState, UNO_QUERY );
993 while ( xStyle.is() )
995 OUString aParentStyle( xStyle->getParentStyle() );
996 if ( aParentStyle.getLength() > 0 )
998 aParentStyle =
999 rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
1000 aParentStyle );
1002 if ( aParentStyle.getLength() == 0 ||
1003 !xParaStyles->hasByName( aParentStyle ) )
1005 // no list style found
1006 break;
1008 else
1010 xPropState = Reference< XPropertyState >(
1011 xParaStyles->getByName( aParentStyle ),
1012 UNO_QUERY );
1013 if ( !xPropState.is() )
1015 // error case
1016 return sal_True;
1018 if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
1020 // list style found
1021 bRet = sal_True;
1022 // --> OD 2007-01-29 #i73973#
1023 // special case: the found list style equals the chapter numbering
1024 Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
1025 if ( xPropSet.is() )
1027 OUString sListStyle;
1028 xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
1029 if ( sListStyle.getLength() != 0 &&
1030 sListStyle == sOutlineStyleName )
1032 bRet = sal_False;
1034 // --> OD 2007-12-07 #i77708#
1035 // special handling for text documents from OOo version prior OOo 2.4
1036 // --> OD 2008-03-19 #i86058#
1037 // check explicitly on certain versions and on import of
1038 // text documents in OpenOffice.org file format
1039 else if ( sListStyle.getLength() == 0 &&
1040 ( rImport.IsTextDocInOOoFileFormat() ||
1041 ( bBuildIdFound &&
1042 ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1043 ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1
1045 bRet = sal_False;
1047 // <--
1049 // <--
1050 break;
1052 else
1054 // search list style at parent
1055 xStyle = Reference<XStyle>( xPropState, UNO_QUERY );
1061 return bRet;
1063 // <--
1064 OUString XMLTextImportHelper::SetStyleAndAttrs(
1065 SvXMLImport& rImport,
1066 const Reference < XTextCursor >& rCursor,
1067 const OUString& rStyleName,
1068 const OUString& rClassNames,
1069 sal_Bool bPara,
1070 sal_Bool bOutlineLevelAttrFound,
1071 sal_Int8 nOutlineLevel,
1072 // --> OD 2007-08-17 #i80724#
1073 sal_Bool bSetListAttrs )
1074 // <--
1076 const sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH
1077 : XML_STYLE_FAMILY_TEXT_TEXT;
1078 XMLTextStyleContext *pStyle = 0;
1079 OUString sStyleName( rStyleName );
1080 if( sStyleName.getLength() && xAutoStyles.Is() )
1082 const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)->
1083 FindStyleChildContext( nFamily, sStyleName, sal_True );
1084 pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle);
1086 if( pStyle )
1087 sStyleName = pStyle->GetParentName();
1089 Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
1090 Reference< XPropertySetInfo > xPropSetInfo(
1091 xPropSet->getPropertySetInfo());
1093 // style
1094 if( sStyleName.getLength() )
1096 sStyleName = rImport.GetStyleDisplayName( nFamily, sStyleName );
1097 const String& rPropName = bPara ? sParaStyleName : sCharStyleName;
1098 const Reference < XNameContainer > & rStyles = bPara ? xParaStyles
1099 : xTextStyles;
1100 if( rStyles.is() &&
1101 xPropSetInfo->hasPropertyByName( rPropName ) &&
1102 rStyles->hasByName( sStyleName ) )
1104 xPropSet->setPropertyValue( rPropName, makeAny(sStyleName) );
1106 else
1107 sStyleName = OUString();
1110 // --> OD 2008-09-10 #i70748#
1111 // The outline level needs to be only applied as list level, if the heading
1112 // is not inside a list and if it by default applies the outline style.
1113 bool bApplyOutlineLevelAsListLevel( false );
1114 // --> OD 2007-08-17 #i80724#
1115 if ( bSetListAttrs && bPara && xPropSetInfo->hasPropertyByName( sNumberingRules ) )
1116 // <--
1118 // Set numbering rules
1119 Reference < XIndexReplace > xNumRules(xPropSet->getPropertyValue( sNumberingRules ), UNO_QUERY);
1121 XMLTextListBlockContext * pListBlock(0);
1122 XMLTextListItemContext * pListItem(0);
1123 XMLNumberedParaContext * pNumberedParagraph(0);
1124 GetTextListHelper().ListContextTop(
1125 pListBlock, pListItem, pNumberedParagraph);
1127 OSL_ENSURE(!(pListBlock && pNumberedParagraph), "XMLTextImportHelper::"
1128 "SetStyleAndAttrs: both list and numbered-paragraph???");
1130 Reference < XIndexReplace > xNewNumRules;
1131 sal_Int8 nLevel(-1);
1132 ::rtl::OUString sListId;
1133 sal_Int16 nStartValue(-1);
1134 bool bNumberingIsNumber(true);
1136 if (pListBlock) {
1138 if (!pListItem) {
1139 bNumberingIsNumber = false; // list-header
1141 // --> OD 2008-05-08 #refactorlists#
1142 // consider text:style-override property of <text:list-item>
1143 xNewNumRules.set(
1144 (pListItem != 0 && pListItem->HasNumRulesOverride())
1145 ? pListItem->GetNumRulesOverride()
1146 : pListBlock->GetNumRules() );
1147 // <--
1148 nLevel = static_cast<sal_Int8>(pListBlock->GetLevel());
1150 if ( pListItem && pListItem->HasStartValue() ) {
1151 nStartValue = pListItem->GetStartValue();
1154 // --> OD 2008-08-15 #i92811#
1155 sListId = mpTextListsHelper->GetListIdForListBlock( *pListBlock );
1156 // <--
1158 else if (pNumberedParagraph)
1160 xNewNumRules.set(pNumberedParagraph->GetNumRules());
1161 nLevel = static_cast<sal_Int8>(pNumberedParagraph->GetLevel());
1162 sListId = pNumberedParagraph->GetListId();
1163 nStartValue = pNumberedParagraph->GetStartValue();
1167 if (pListBlock || pNumberedParagraph)
1169 // --> OD 2009-08-24 #i101349#
1170 // Assure that list style of automatic paragraph style is applied at paragraph.
1171 sal_Bool bApplyNumRules = pStyle && pStyle->IsListStyleSet();
1172 if ( !bApplyNumRules )
1174 sal_Bool bSameNumRules = xNewNumRules == xNumRules;
1175 if( !bSameNumRules && xNewNumRules.is() && xNumRules.is() )
1177 // If the interface pointers are different then this does
1178 // not mean that the num rules are different. Further tests
1179 // are required then. However, if only one num rule is
1180 // set, no tests are required of course.
1181 Reference< XNamed > xNewNamed( xNewNumRules, UNO_QUERY );
1182 Reference< XNamed > xNamed( xNumRules, UNO_QUERY );
1183 if( xNewNamed.is() && xNamed.is() )
1185 bSameNumRules = xNewNamed->getName() == xNamed->getName();
1187 else
1189 Reference< XAnyCompare > xNumRuleCompare( xNumRules, UNO_QUERY );
1190 if( xNumRuleCompare.is() )
1192 bSameNumRules = (xNumRuleCompare->compare( Any(xNumRules), Any(xNewNumRules) ) == 0);
1196 bApplyNumRules = !bSameNumRules;
1199 if ( bApplyNumRules )
1200 // <--
1202 // #102607# This may except when xNewNumRules contains
1203 // a Writer-NumRule-Implementation bug gets applied to
1204 // a shape. Since this may occur inside a document
1205 // (e.g. when edited), this must be handled
1206 // gracefully.
1209 xPropSet->setPropertyValue( sNumberingRules, makeAny(xNewNumRules) );
1211 catch( Exception e )
1213 ; // I would really like to use a warning here,
1214 // but I can't access the XMLErrorHandler from
1215 // here.
1219 if (!bNumberingIsNumber &&
1220 xPropSetInfo->hasPropertyByName( sNumberingIsNumber ) )
1222 xPropSet->setPropertyValue( sNumberingIsNumber, Any(sal_False) );
1225 xPropSet->setPropertyValue( sNumberingLevel, Any(nLevel) );
1227 if( pListBlock && pListBlock->IsRestartNumbering() )
1229 // TODO: property missing
1230 if( xPropSetInfo->hasPropertyByName( sParaIsNumberingRestart ) )
1232 sal_Bool bTmp = sal_True;
1233 xPropSet->setPropertyValue(sParaIsNumberingRestart,
1234 makeAny(bTmp) );
1236 pListBlock->ResetRestartNumbering();
1239 if ( 0 <= nStartValue &&
1240 xPropSetInfo->hasPropertyByName( sNumberingStartValue ) )
1242 xPropSet->setPropertyValue(sNumberingStartValue,
1243 makeAny(nStartValue));
1246 // --> OD 2008-04-23 #refactorlists#
1247 if ( xPropSetInfo->hasPropertyByName( sPropNameListId ) )
1249 if (sListId.getLength()) {
1250 xPropSet->setPropertyValue( sPropNameListId,
1251 makeAny(sListId) );
1254 // <--
1256 GetTextListHelper().SetListItem( (XMLTextListItemContext *)0 );
1258 else
1260 // If the paragraph is not in a list but its style, remove it from
1261 // the list.
1262 // --> OD 2005-10-25 #126347# - do not remove it, if the list
1263 // of the style is the chapter numbering rule.
1264 if( xNumRules.is() )
1266 bool bRemove( true );
1267 // --> OD 2008-12-17 #i70748# - special handling for document from OOo 2.x
1268 sal_Int32 nUPD( 0 );
1269 sal_Int32 nBuild( 0 );
1270 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1271 DBG_ASSERT( ( bBuildIdFound && nUPD == 680 ) ||
1272 !pStyle ||
1273 !pStyle->IsListStyleSet() ||
1274 pStyle->GetListStyle().getLength() == 0,
1275 "automatic paragraph style with list style name, but paragraph not in list???" );
1276 if ( ( bBuildIdFound && nUPD == 680 ) ||
1277 !pStyle || !pStyle->IsListStyleSet() )
1279 if ( xChapterNumbering.is() )
1281 Reference< XNamed > xNumNamed( xNumRules, UNO_QUERY );
1282 Reference< XNamed > xChapterNumNamed( xChapterNumbering, UNO_QUERY );
1283 if ( xNumNamed.is() && xChapterNumNamed.is() &&
1284 xNumNamed->getName() == xChapterNumNamed->getName() )
1286 bRemove = false;
1287 // --> OD 2008-09-10 #i70748#
1288 bApplyOutlineLevelAsListLevel = true;
1289 // <--
1293 // <--
1294 if ( bRemove )
1296 xPropSet->setPropertyValue( sNumberingRules, Any() );
1299 // <--
1303 // hard paragraph properties
1304 sal_Int32 nTokenIndex = 0;
1305 rtl::OUString aToken;
1306 do {
1307 #if 1
1308 if (pStyle) {
1309 pStyle->FillPropertySet( xPropSet );
1310 if( bPara && pStyle->HasMasterPageName() &&
1311 xPropSetInfo->hasPropertyByName( sPageDescName ) )
1313 OUString sDisplayName(
1314 rImport.GetStyleDisplayName(
1315 XML_STYLE_FAMILY_MASTER_PAGE,
1316 pStyle->GetMasterPageName()) );
1317 if( !sDisplayName.getLength() ||
1318 (xPageStyles.is() &&
1319 xPageStyles->hasByName( sDisplayName )) )
1321 xPropSet->setPropertyValue( sPageDescName, makeAny(sDisplayName) );
1324 if( bPara && pStyle->GetDropCapStyleName().getLength() &&
1325 xTextStyles.is() )
1327 OUString sDisplayName(
1328 rImport.GetStyleDisplayName(
1329 XML_STYLE_FAMILY_TEXT_TEXT,
1330 pStyle->GetDropCapStyleName()) );
1331 if( xTextStyles->hasByName( sDisplayName ) &&
1332 xPropSetInfo->hasPropertyByName( sDisplayName ) )
1334 xPropSet->setPropertyValue( pStyle->sDropCapCharStyleName, makeAny(sDisplayName) );
1338 // combined characters special treatment
1339 if (!bPara && pStyle->HasCombinedCharactersLetter())
1341 // insert combined characters text field
1342 if( xServiceFactory.is() )
1344 Reference<XPropertySet> xTmp( xServiceFactory->createInstance(sServiceCombinedCharacters), UNO_QUERY );
1345 if( xTmp.is() )
1347 // fix cursor if larger than possible for
1348 // combined characters field
1349 if (rCursor->getString().getLength() >
1350 MAX_COMBINED_CHARACTERS)
1352 rCursor->gotoRange(rCursor->getStart(), sal_False);
1353 rCursor->goRight(MAX_COMBINED_CHARACTERS, sal_True);
1356 // set field value (the combined character string)
1357 xTmp->setPropertyValue(sContent, makeAny(rCursor->getString()));
1359 // insert the field over it's original text
1360 Reference<XTextRange> xRange(rCursor, UNO_QUERY);
1361 Reference<XTextContent> xTextContent(xTmp, UNO_QUERY);
1362 if (xText.is() && xRange.is())
1364 xText->insertTextContent( xRange, xTextContent,
1365 sal_True );
1371 aToken = rClassNames.getToken( 0, ' ', nTokenIndex );
1372 if (aToken.getLength() && xAutoStyles.Is() )
1374 pStyle = PTR_CAST( XMLTextStyleContext,
1375 ((SvXMLStylesContext *)&xAutoStyles)->
1376 FindStyleChildContext( nFamily, aToken, sal_True ) );
1377 } else {
1378 pStyle=NULL;
1379 aToken=rtl::OUString();
1381 #endif
1382 } while (pStyle!=NULL || aToken.getLength()>0);
1384 // outline level; set after list style has been set
1385 // --> OD 2005-08-25 #i53198#
1386 // Complete re-worked and corrected:
1387 // - set outline level at paragraph
1388 // - set numbering level at paragraph, if none is already set
1389 // - assure that style is marked as an outline style for the corresponding
1390 // outline level.
1391 // - DO NOT set type of numbering rule to outline.
1392 // - DO NOT set numbering rule directly at the paragraph.
1394 // --> OD 2008-12-09 #i70748#
1395 // Some minor rework and adjust access to paragraph styles
1396 if ( bPara )
1398 // --> OD 2009-08-18 #i103817#
1399 sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
1400 const bool bHasOutlineLevelProp( xPropSetInfo->hasPropertyByName( sOutlineLevel ) );
1401 if ( bHasOutlineLevelProp )
1403 xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
1405 // <--
1406 //if ( bPara && nOutlineLevel != -1 ) //#outline level,removed by zhaojianwei
1407 if ( nOutlineLevel > 0 ) //add by zhaojianwei
1409 //#outline level,removed by zhaojianwei
1410 if ( bHasOutlineLevelProp )
1412 // In case that the value equals the value of its paragraph style
1413 // attribute outline level, the paragraph attribute value is left unset
1414 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel )
1416 xPropSet->setPropertyValue( sOutlineLevel,
1417 makeAny( static_cast<sal_Int16>(nOutlineLevel) ) );
1419 }//<-end,zhaojianwei
1421 // --> OD 2008-09-10 #i70748#
1422 if ( bApplyOutlineLevelAsListLevel )
1424 sal_Int16 nNumLevel = -1;
1425 xPropSet->getPropertyValue( sNumberingLevel ) >>= nNumLevel;
1426 if ( nNumLevel == -1 ||
1427 nNumLevel != (nOutlineLevel - 1) )
1429 xPropSet->setPropertyValue( sNumberingLevel,
1430 makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) );
1433 // <--
1434 // --> OD 2006-10-13 #i69629# - correction:
1435 // - for text document from version OOo 2.0.4/SO 8 PU4 and earlier
1436 // the paragraph style of a heading should be assigned to the
1437 // corresponding list level of the outline style.
1438 // - for other text documents the paragraph style of a heading is only
1439 // a candidate for an assignment to the list level of the outline
1440 // style, if it has no direct list style property and (if exists) the
1441 // automatic paragraph style has also no direct list style set.
1442 if( xParaStyles->hasByName( sStyleName ) )
1444 bool bOutlineStyleCandidate( false );
1446 sal_Int32 nUPD( 0 );
1447 sal_Int32 nBuild( 0 );
1448 // --> OD 2007-12-19 #152540#
1449 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1450 // --> OD 2007-07-25 #i73509#
1451 // --> OD 2008-03-19 #i86058# - check explicitly on certain versions
1452 if ( rImport.IsTextDocInOOoFileFormat() ||
1453 ( bBuildIdFound &&
1454 ( nUPD == 645 || nUPD == 641 ) ) )
1456 bOutlineStyleCandidate = true;
1458 else if ( nUPD == 680 && nBuild <= 9073 ) /* BuildId of OOo 2.0.4/SO8 PU4 */
1460 bOutlineStyleCandidate = bOutlineLevelAttrFound;
1462 // <--
1463 // else
1464 // {
1465 // Reference< XPropertyState > xStylePropState(
1466 // xParaStyles->getByName( sStyleName ), UNO_QUERY );
1467 // if ( xStylePropState.is() &&
1468 // xStylePropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
1469 // {
1470 // bOutlineStyleCandidate = false;
1471 // }
1472 // // --> OD 2007-01-11 #i73361#
1473 // // The automatic paragraph style doesn't have to be considered.
1474 // // else if ( pStyle && /* automatic paragraph style */
1475 // // pStyle->IsListStyleSet() )
1476 // // {
1477 // // bOutlineStyleCandidate = false;
1478 // // }
1479 // // <--
1480 // else
1481 // {
1482 // bOutlineStyleCandidate = true;
1483 // }
1484 // }
1486 if ( bOutlineStyleCandidate )
1488 AddOutlineStyleCandidate( nOutlineLevel, sStyleName );
1490 // --> OD 2009-08-18 #i103817#
1491 // Assure that heading applies the outline style
1492 if ( ( !pStyle || !pStyle->IsListStyleSet() ) &&
1493 !bOutlineStyleCandidate &&
1494 xChapterNumbering.is() )
1496 OUString sEmptyStr;
1497 if ( !lcl_HasListStyle( sStyleName,
1498 xParaStyles, GetXMLImport(),
1499 sNumberingStyleName,
1500 sEmptyStr ) )
1502 // heading not in a list --> apply outline style
1503 xPropSet->setPropertyValue( sNumberingRules,
1504 makeAny(xChapterNumbering) );
1505 xPropSet->setPropertyValue( sNumberingLevel,
1506 makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) );
1509 // <--
1511 // <--
1513 //-> #outlinelevel added by zhaojianwei
1514 //handle for text:p,if the paragraphstyle outlinelevel is set to[1~10]
1515 else if( bHasOutlineLevelProp )
1517 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 )
1519 sal_Int16 nZero = 0;
1520 xPropSet->setPropertyValue( sOutlineLevel, makeAny( static_cast<sal_Int16>(nZero) ) );
1522 }//<-end,zhaojianwei
1524 // <--
1526 return sStyleName;
1529 // --> OD 2006-10-12 #i69629#
1530 // adjustments to reflect change of internal data structure <mpOutlineStylesCandidates>
1531 void XMLTextImportHelper::FindOutlineStyleName( ::rtl::OUString& rStyleName,
1532 sal_Int8 nOutlineLevel )
1534 // style name empty?
1535 if( rStyleName.getLength() == 0 )
1537 // Empty? Then we need o do stuff. Let's do error checking first.
1538 if( xChapterNumbering.is() &&
1539 ( nOutlineLevel > 0 ) &&
1540 ( nOutlineLevel <= xChapterNumbering->getCount() ) )
1542 nOutlineLevel--; // for the remainder, the level's are 0-based
1544 // empty style name: look-up previously used name
1546 // if we don't have a previously used name, we'll use the default
1547 if ( mpOutlineStylesCandidates == NULL )
1549 mpOutlineStylesCandidates = new ::std::vector<OUString>[xChapterNumbering->getCount()];
1552 if ( mpOutlineStylesCandidates[nOutlineLevel].empty() )
1554 // no other name used previously? Then use default
1556 // iterate over property value sequence to find the style name
1557 Sequence<PropertyValue> aProperties;
1558 xChapterNumbering->getByIndex( nOutlineLevel ) >>= aProperties;
1559 for( sal_Int32 i = 0; i < aProperties.getLength(); i++ )
1561 if( aProperties[i].Name == sHeadingStyleName )
1563 rtl::OUString aOutlineStyle;
1564 aProperties[i].Value >>= aOutlineStyle;
1565 mpOutlineStylesCandidates[nOutlineLevel].push_back( aOutlineStyle );
1566 break; // early out, if we found it!.
1571 // finally, we'll use the previously used style name for this
1572 // format (or the default we've just put into that style)
1573 // --> OD 2006-11-06 #i71249# - take last added one
1574 rStyleName = mpOutlineStylesCandidates[nOutlineLevel].back();
1575 // <--
1577 // else: nothing we can do, so we'll leave it empty
1579 // else: we already had a style name, so we let it pass.
1581 // <--
1583 // --> OD 2006-10-12 #i69629#
1584 void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel,
1585 const OUString& rStyleName )
1587 if ( rStyleName.getLength() &&
1588 xChapterNumbering.is() &&
1589 nOutlineLevel > 0 && nOutlineLevel <= xChapterNumbering->getCount() )
1591 if( !mpOutlineStylesCandidates )
1593 #ifdef IRIX
1594 /* GCC 2 bug when member function is called as part of an array
1595 * initialiser
1597 sal_Int8 count = xChapterNumbering->getCount();
1598 mpOutlineStylesCandidates = new ::std::vector<OUString>[count];
1599 #else
1600 mpOutlineStylesCandidates = new ::std::vector<OUString>[xChapterNumbering->getCount()];
1601 #endif
1603 mpOutlineStylesCandidates[nOutlineLevel-1].push_back( rStyleName );
1606 // <--
1608 // --> OD 2006-10-12 #i69629#
1609 void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels )
1611 if ( ( mpOutlineStylesCandidates != NULL || bSetEmptyLevels ) &&
1612 xChapterNumbering.is() &&
1613 !IsInsertMode() )
1615 // --> OD 2007-12-19 #152540#
1616 bool bChooseLastOne( false );
1618 if ( GetXMLImport().IsTextDocInOOoFileFormat() )
1620 bChooseLastOne = true;
1622 else
1624 sal_Int32 nUPD( 0 );
1625 sal_Int32 nBuild( 0 );
1626 if ( GetXMLImport().getBuildIds( nUPD, nBuild ) )
1628 // --> OD 2008-03-19 #i86058#
1629 // check explicitly on certain versions
1630 bChooseLastOne = ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1631 ( nUPD == 680 && nBuild <= 9073 ); // OOo 2.0 - OOo 2.0.4
1632 // <--
1636 // <--
1638 OUString sOutlineStyleName;
1640 Reference<XPropertySet> xChapterNumRule( xChapterNumbering, UNO_QUERY );
1641 const OUString sName(RTL_CONSTASCII_USTRINGPARAM("Name"));
1642 xChapterNumRule->getPropertyValue(sName) >>= sOutlineStyleName;
1645 OUString sEmpty;
1646 sal_Int32 nCount = xChapterNumbering->getCount();
1647 for( sal_Int32 i=0; i < nCount; ++i )
1649 if ( bSetEmptyLevels ||
1650 ( mpOutlineStylesCandidates &&
1651 !mpOutlineStylesCandidates[i].empty() ) )
1653 // determine, which candidate is one to be assigned to the list
1654 // level of the outline style
1655 OUString sChoosenStyle( sEmpty );
1656 if ( mpOutlineStylesCandidates &&
1657 !mpOutlineStylesCandidates[i].empty() )
1659 // --> OD 2007-12-19 #152540#
1660 if ( bChooseLastOne )
1661 // <--
1663 // --> OD 2006-11-06 #i71249# - take last added one
1664 sChoosenStyle = mpOutlineStylesCandidates[i].back();
1665 // <--
1667 else
1669 for ( sal_uInt32 j = 0; j < mpOutlineStylesCandidates[i].size(); ++j )
1671 if ( !lcl_HasListStyle( mpOutlineStylesCandidates[i][j],
1672 xParaStyles, GetXMLImport(),
1673 sNumberingStyleName,
1674 sOutlineStyleName ) )
1676 sChoosenStyle = mpOutlineStylesCandidates[i][j];
1677 break;
1683 Sequence < PropertyValue > aProps( 1 );
1684 PropertyValue *pProps = aProps.getArray();
1685 pProps->Name = sHeadingStyleName;
1686 pProps->Value <<= sChoosenStyle;
1688 xChapterNumbering->replaceByIndex( i, makeAny( aProps ) );
1693 // <--
1695 void XMLTextImportHelper::SetHyperlink(
1696 SvXMLImport& rImport,
1697 const Reference < XTextCursor >& rCursor,
1698 const OUString& rHRef,
1699 const OUString& rName,
1700 const OUString& rTargetFrameName,
1701 const OUString& rStyleName,
1702 const OUString& rVisitedStyleName,
1703 XMLEventsImportContext* pEvents)
1705 Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
1706 Reference < XPropertySetInfo > xPropSetInfo(
1707 xPropSet->getPropertySetInfo());
1708 if( !xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName(sHyperLinkURL) )
1709 return;
1711 xPropSet->setPropertyValue( sHyperLinkURL, makeAny(rHRef) );
1713 if( xPropSetInfo->hasPropertyByName( sHyperLinkName ) )
1715 xPropSet->setPropertyValue( sHyperLinkName, makeAny(rName) );
1718 if( xPropSetInfo->hasPropertyByName( sHyperLinkTarget ) )
1720 xPropSet->setPropertyValue( sHyperLinkTarget, makeAny(rTargetFrameName) );
1723 if ( (pEvents != NULL) &&
1724 xPropSetInfo->hasPropertyByName( sHyperLinkEvents ))
1726 // The API treats events at hyperlinks differently from most
1727 // other properties: You have to set a name replace with the
1728 // events in it. The easiest way to to this is to 1) get
1729 // events, 2) set new ones, and 3) then put events back.
1730 Reference<XNameReplace> xReplace(xPropSet->getPropertyValue( sHyperLinkEvents ), UNO_QUERY);
1731 if (xReplace.is())
1733 // set events
1734 pEvents->SetEvents(xReplace);
1736 // put events
1737 xPropSet->setPropertyValue( sHyperLinkEvents, makeAny(xReplace) );
1741 if( xTextStyles.is() )
1743 OUString sDisplayName(
1744 rImport.GetStyleDisplayName(
1745 XML_STYLE_FAMILY_TEXT_TEXT, rStyleName ) );
1746 if( sDisplayName.getLength() &&
1747 xPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) &&
1748 xTextStyles->hasByName( sDisplayName ) )
1750 xPropSet->setPropertyValue( sUnvisitedCharStyleName, makeAny(sDisplayName) );
1753 sDisplayName =
1754 rImport.GetStyleDisplayName(
1755 XML_STYLE_FAMILY_TEXT_TEXT, rVisitedStyleName );
1756 if( sDisplayName.getLength() &&
1757 xPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) &&
1758 xTextStyles->hasByName( sDisplayName ) )
1760 xPropSet->setPropertyValue( sVisitedCharStyleName, makeAny(sDisplayName) );
1765 void XMLTextImportHelper::SetRuby(
1766 SvXMLImport& rImport,
1767 const Reference < XTextCursor >& rCursor,
1768 const OUString& rStyleName,
1769 const OUString& rTextStyleName,
1770 const OUString& rText )
1772 Reference<XPropertySet> xPropSet(rCursor, UNO_QUERY);
1774 OUString sRubyText(RTL_CONSTASCII_USTRINGPARAM("RubyText"));
1775 OUString sRubyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("RubyCharStyleName"));
1777 // if we have one Ruby property, we assume all of them are present
1778 if (xPropSet.is() &&
1779 xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText ))
1781 // the ruby text
1782 xPropSet->setPropertyValue(sRubyText, makeAny(rText));
1784 // the ruby style (ruby-adjust)
1785 XMLPropStyleContext *pStyle = 0;
1786 if( rStyleName.getLength() && xAutoStyles.Is() )
1788 const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)->
1789 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_RUBY,
1790 rStyleName, sal_True );
1791 pStyle = PTR_CAST(XMLPropStyleContext,pTempStyle);
1793 if (NULL != pStyle)
1794 pStyle->FillPropertySet( xPropSet );
1797 // the ruby text character style
1798 if( xTextStyles.is() )
1800 OUString sDisplayName(
1801 rImport.GetStyleDisplayName(
1802 XML_STYLE_FAMILY_TEXT_TEXT, rTextStyleName ) );
1803 if( (sDisplayName.getLength() > 0) &&
1804 // xPropSetInfo->hasPropertyByName( sRubyCharStyleName ) &&
1805 xTextStyles->hasByName( sDisplayName ) )
1807 xPropSet->setPropertyValue(sRubyCharStyleName, makeAny(sDisplayName));
1813 void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles )
1815 xAutoStyles = pStyles;
1818 void XMLTextImportHelper::SetFontDecls( XMLFontStylesContext *pFontDecls )
1820 xFontDecls = pFontDecls;
1821 ((XMLTextImportPropertyMapper *)xParaImpPrMap.get())
1822 ->SetFontDecls( pFontDecls );
1823 ((XMLTextImportPropertyMapper *)xTextImpPrMap.get())
1824 ->SetFontDecls( pFontDecls );
1827 const XMLFontStylesContext *XMLTextImportHelper::GetFontDecls() const
1829 return (XMLFontStylesContext *)&xFontDecls;
1832 sal_Bool XMLTextImportHelper::HasDrawNameAttribute(
1833 const Reference< XAttributeList > & xAttrList,
1834 SvXMLNamespaceMap& rNamespaceMap )
1836 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1837 for( sal_Int16 i=0; i < nAttrCount; i++ )
1839 const OUString& rAttrName = xAttrList->getNameByIndex( i );
1841 OUString aLocalName;
1842 sal_uInt16 nPrefix =
1843 rNamespaceMap.GetKeyByAttrName( rAttrName, &aLocalName );
1844 if( XML_NAMESPACE_DRAW == nPrefix &&
1845 IsXMLToken( aLocalName, XML_NAME ) )
1847 return xAttrList->getValueByIndex(i).getLength() != 0;
1851 return sal_False;
1854 SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
1855 SvXMLImport& rImport,
1856 sal_uInt16 nPrefix, const OUString& rLocalName,
1857 const Reference< XAttributeList > & xAttrList,
1858 XMLTextType eType )
1860 SvXMLImportContext *pContext = 0;
1862 const SvXMLTokenMap& rTokenMap = GetTextElemTokenMap();
1863 sal_Bool bHeading = sal_False;
1864 sal_Bool bContent = sal_True;
1865 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
1866 switch( nToken )
1868 case XML_TOK_TEXT_H:
1869 bHeading = sal_True;
1870 case XML_TOK_TEXT_P:
1871 pContext = new XMLParaContext( rImport,
1872 nPrefix, rLocalName,
1873 xAttrList, bHeading );
1874 if( bProgress && XML_TEXT_TYPE_SHAPE != eType )
1876 rImport.GetProgressBarHelper()->Increment();
1878 break;
1879 case XML_TOK_TEXT_NUMBERED_PARAGRAPH:
1880 pContext = new XMLNumberedParaContext(
1881 rImport, nPrefix, rLocalName, xAttrList );
1882 break;
1883 case XML_TOK_TEXT_LIST:
1884 pContext = new XMLTextListBlockContext( rImport, *this,
1885 nPrefix, rLocalName,
1886 xAttrList );
1887 break;
1888 case XML_TOK_TABLE_TABLE:
1889 if( XML_TEXT_TYPE_BODY == eType ||
1890 XML_TEXT_TYPE_TEXTBOX == eType ||
1891 XML_TEXT_TYPE_SECTION == eType ||
1892 XML_TEXT_TYPE_HEADER_FOOTER == eType ||
1893 XML_TEXT_TYPE_CHANGED_REGION == eType ||
1894 XML_TEXT_TYPE_CELL == eType )
1895 pContext = CreateTableChildContext( rImport, nPrefix, rLocalName,
1896 xAttrList );
1897 break;
1898 case XML_TOK_TEXT_SEQUENCE_DECLS:
1899 if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) ||
1900 XML_TEXT_TYPE_HEADER_FOOTER == eType )
1902 pContext = new XMLVariableDeclsImportContext(
1903 rImport, *this, nPrefix, rLocalName, VarTypeSequence);
1904 bContent = sal_False;
1906 break;
1908 case XML_TOK_TEXT_VARFIELD_DECLS:
1909 if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) ||
1910 XML_TEXT_TYPE_HEADER_FOOTER == eType )
1912 pContext = new XMLVariableDeclsImportContext(
1913 rImport, *this, nPrefix, rLocalName, VarTypeSimple);
1914 bContent = sal_False;
1916 break;
1918 case XML_TOK_TEXT_USERFIELD_DECLS:
1919 if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted)||
1920 XML_TEXT_TYPE_HEADER_FOOTER == eType )
1922 pContext = new XMLVariableDeclsImportContext(
1923 rImport, *this, nPrefix, rLocalName, VarTypeUserField);
1924 bContent = sal_False;
1926 break;
1928 case XML_TOK_TEXT_DDE_DECLS:
1929 if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) ||
1930 XML_TEXT_TYPE_HEADER_FOOTER == eType )
1932 pContext = new XMLDdeFieldDeclsImportContext(
1933 rImport, nPrefix, rLocalName);
1934 bContent = sal_False;
1936 break;
1938 case XML_TOK_TEXT_FRAME_PAGE:
1939 if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) ||
1940 XML_TEXT_TYPE_TEXTBOX == eType ||
1941 XML_TEXT_TYPE_CHANGED_REGION == eType )
1943 TextContentAnchorType eAnchorType =
1944 XML_TEXT_TYPE_TEXTBOX == eType ? TextContentAnchorType_AT_FRAME
1945 : TextContentAnchorType_AT_PAGE;
1946 pContext = new XMLTextFrameContext( rImport, nPrefix,
1947 rLocalName, xAttrList,
1948 eAnchorType );
1949 bContent = sal_False;
1951 break;
1953 case XML_TOK_DRAW_A_PAGE:
1954 if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) ||
1955 XML_TEXT_TYPE_TEXTBOX == eType ||
1956 XML_TEXT_TYPE_CHANGED_REGION == eType)
1958 TextContentAnchorType eAnchorType =
1959 XML_TEXT_TYPE_TEXTBOX == eType ? TextContentAnchorType_AT_FRAME
1960 : TextContentAnchorType_AT_PAGE;
1961 pContext = new XMLTextFrameHyperlinkContext( rImport, nPrefix,
1962 rLocalName, xAttrList,
1963 eAnchorType );
1964 bContent = sal_False;
1966 break;
1968 case XML_TOK_TEXT_INDEX_TITLE:
1969 case XML_TOK_TEXT_SECTION:
1970 #ifndef SVX_LIGHT
1971 pContext = new XMLSectionImportContext( rImport, nPrefix, rLocalName );
1972 #else
1973 // create default context to skip content
1974 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
1975 #endif // #ifndef SVX_LIGHT
1976 break;
1978 case XML_TOK_TEXT_TOC:
1979 case XML_TOK_TEXT_OBJECT_INDEX:
1980 case XML_TOK_TEXT_TABLE_INDEX:
1981 case XML_TOK_TEXT_ILLUSTRATION_INDEX:
1982 case XML_TOK_TEXT_USER_INDEX:
1983 case XML_TOK_TEXT_ALPHABETICAL_INDEX:
1984 case XML_TOK_TEXT_BIBLIOGRAPHY_INDEX:
1985 #ifndef SVX_LIGHT
1986 if( XML_TEXT_TYPE_SHAPE != eType )
1987 pContext = new XMLIndexTOCContext( rImport, nPrefix, rLocalName );
1988 #else
1989 // create default context to skip content
1990 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
1991 #endif // #ifndef SVX_LIGHT
1992 break;
1994 case XML_TOK_TEXT_TRACKED_CHANGES:
1995 #ifndef SVX_LIGHT
1996 pContext = new XMLTrackedChangesImportContext( rImport, nPrefix,
1997 rLocalName);
1998 #else
1999 // create default context to skip content
2000 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2001 #endif // #ifndef SVX_LIGHT
2002 bContent = sal_False;
2003 break;
2005 case XML_TOK_TEXT_CHANGE:
2006 case XML_TOK_TEXT_CHANGE_START:
2007 case XML_TOK_TEXT_CHANGE_END:
2008 pContext = new XMLChangeImportContext(
2009 rImport, nPrefix, rLocalName,
2010 (XML_TOK_TEXT_CHANGE_END != nToken),
2011 (XML_TOK_TEXT_CHANGE_START != nToken),
2012 sal_True);
2013 break;
2015 case XML_TOK_TEXT_FORMS:
2016 #ifndef SVX_LIGHT
2017 pContext = rImport.GetFormImport()->createOfficeFormsContext(rImport, nPrefix, rLocalName);
2018 #else
2019 // create default context to skip content
2020 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2021 #endif // #ifndef SVX_LIGHT
2022 bContent = sal_False;
2023 break;
2025 case XML_TOK_TEXT_AUTOMARK:
2026 if( XML_TEXT_TYPE_BODY == eType )
2028 pContext = new XMLAutoMarkFileContext(rImport, nPrefix,rLocalName);
2030 bContent = sal_False;
2031 break;
2033 case XML_TOK_TEXT_CALCULATION_SETTINGS:
2034 #ifndef SVX_LIGHT
2035 pContext = new XMLCalculationSettingsContext ( rImport, nPrefix, rLocalName, xAttrList);
2036 #else
2037 // create default context to skip content
2038 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
2039 #endif // #ifndef SVX_LIGHT
2040 bContent = sal_False;
2041 break;
2043 default:
2044 if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) ||
2045 XML_TEXT_TYPE_TEXTBOX == eType ||
2046 XML_TEXT_TYPE_CHANGED_REGION == eType )
2048 Reference < XShapes > xShapes;
2049 pContext = rImport.GetShapeImport()->CreateGroupChildContext(
2050 rImport, nPrefix, rLocalName, xAttrList, xShapes );
2051 bContent = sal_False;
2055 if (pContext==NULL) {
2056 pContext=rImport.createUnknownContext(nPrefix, rLocalName, xAttrList);
2059 // handle open redlines
2060 if ( (XML_TOK_TEXT_CHANGE != nToken) &&
2061 (XML_TOK_TEXT_CHANGE_END != nToken) &&
2062 (XML_TOK_TEXT_CHANGE_START != nToken) )
2064 // ResetOpenRedlineId();
2067 if( XML_TEXT_TYPE_BODY == eType && bContent )
2068 bBodyContentStarted = sal_False;
2070 return pContext;
2073 SvXMLImportContext *XMLTextImportHelper::CreateTableChildContext(
2074 SvXMLImport&,
2075 sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/,
2076 const Reference< XAttributeList > & )
2078 return 0;
2081 /// get data style key for use with NumberFormat property
2082 sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName,
2083 sal_Bool* pIsSystemLanguage )
2085 const SvXMLStyleContext* pStyle = ((SvXMLStylesContext *)&xAutoStyles)->
2086 FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE,
2087 sStyleName, sal_True );
2089 // get appropriate context
2092 // first check if its a impress and draw only number format
2093 // this is needed since its also a SvXMLNumFormatContext,
2094 // that was needed to support them for controls in impress/draw also
2095 SdXMLNumberFormatImportContext* pSdNumStyle = PTR_CAST( SdXMLNumberFormatImportContext, pStyle );
2096 if( pSdNumStyle )
2098 return pSdNumStyle->GetDrawKey();
2100 else
2102 SvXMLNumFormatContext* pNumStyle = PTR_CAST( SvXMLNumFormatContext, pStyle );
2103 if( pNumStyle )
2105 if( pIsSystemLanguage != NULL )
2106 *pIsSystemLanguage = pNumStyle->IsSystemLanguage();
2108 // return key
2109 return pNumStyle->GetKey();
2112 return -1;
2115 const SvxXMLListStyleContext *XMLTextImportHelper::FindAutoListStyle( const OUString& rName ) const
2117 const SvxXMLListStyleContext *pStyle = 0;
2118 if( xAutoStyles.Is() )
2120 const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)->
2121 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_LIST, rName,
2122 sal_True );
2123 pStyle = PTR_CAST( SvxXMLListStyleContext ,pTempStyle);
2126 return pStyle;
2129 XMLPropStyleContext *XMLTextImportHelper::FindAutoFrameStyle( const OUString& rName ) const
2131 XMLPropStyleContext *pStyle = 0;
2132 if( xAutoStyles.Is() )
2134 const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)->
2135 FindStyleChildContext( XML_STYLE_FAMILY_SD_GRAPHICS_ID, rName,
2136 sal_True );
2137 pStyle = PTR_CAST( XMLPropStyleContext ,pTempStyle);
2140 return pStyle;
2143 XMLPropStyleContext* XMLTextImportHelper::FindSectionStyle(
2144 const OUString& rName ) const
2146 XMLPropStyleContext* pStyle = NULL;
2147 if (xAutoStyles.Is() )
2149 const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)->
2150 FindStyleChildContext(
2151 XML_STYLE_FAMILY_TEXT_SECTION,
2152 rName, sal_True );
2153 pStyle = PTR_CAST( XMLPropStyleContext,pTempStyle);
2156 return pStyle;
2159 XMLPropStyleContext* XMLTextImportHelper::FindPageMaster(
2160 const OUString& rName ) const
2162 XMLPropStyleContext* pStyle = NULL;
2163 if (xAutoStyles.Is() )
2165 const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)->
2166 FindStyleChildContext(
2167 XML_STYLE_FAMILY_PAGE_MASTER,
2168 rName, sal_True );
2169 pStyle = PTR_CAST( XMLPropStyleContext,pTempStyle);
2172 return pStyle;
2176 void XMLTextImportHelper::PushListContext(XMLTextListBlockContext *i_pListBlock)
2178 GetTextListHelper().PushListContext(i_pListBlock);
2181 void XMLTextImportHelper::PopListContext()
2183 GetTextListHelper().PopListContext();
2187 const SvXMLTokenMap& XMLTextImportHelper::GetTextNumberedParagraphAttrTokenMap()
2189 if( !pTextNumberedParagraphAttrTokenMap.get() )
2190 pTextNumberedParagraphAttrTokenMap.reset(
2191 new SvXMLTokenMap( aTextNumberedParagraphAttrTokenMap ) );
2193 return *pTextNumberedParagraphAttrTokenMap;
2196 const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockAttrTokenMap()
2198 if( !pTextListBlockAttrTokenMap.get() )
2199 pTextListBlockAttrTokenMap.reset(
2200 new SvXMLTokenMap( aTextListBlockAttrTokenMap ) );
2202 return *pTextListBlockAttrTokenMap;
2205 const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockElemTokenMap()
2207 if( !pTextListBlockElemTokenMap.get() )
2208 pTextListBlockElemTokenMap.reset(
2209 new SvXMLTokenMap( aTextListBlockElemTokenMap ) );
2211 return *pTextListBlockElemTokenMap;
2214 SvI18NMap& XMLTextImportHelper::GetRenameMap()
2216 if( !pRenameMap.get() )
2217 pRenameMap.reset( new SvI18NMap() );
2218 return *pRenameMap;
2221 void XMLTextImportHelper::InsertBookmarkStartRange(
2222 const OUString sName,
2223 const Reference<XTextRange> & rRange,
2224 const OUString& i_rXmlId)
2226 aBookmarkStartRanges[sName] = std::make_pair(rRange, i_rXmlId);
2227 aBookmarkVector.push_back(sName);
2230 sal_Bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange(
2231 const OUString sName,
2232 Reference<XTextRange> & o_rRange,
2233 OUString& o_rXmlId)
2235 if (aBookmarkStartRanges.count(sName))
2237 o_rRange.set(aBookmarkStartRanges[sName].first);
2238 o_rXmlId = aBookmarkStartRanges[sName].second;
2239 aBookmarkStartRanges.erase(sName);
2240 BookmarkVector_t::iterator it=aBookmarkVector.begin();
2241 while(it!=aBookmarkVector.end() && it->compareTo(sName)!=0) {
2242 it++;
2244 if (it!=aBookmarkVector.end()) {
2245 aBookmarkVector.erase(it);
2247 return sal_True;
2249 else
2251 return sal_False;
2255 ::rtl::OUString XMLTextImportHelper::FindActiveBookmarkName()
2257 if ( !aBookmarkVector.empty() ) {
2258 return aBookmarkVector.back();
2259 } else return ::rtl::OUString(); // return the empty string on error...
2262 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > XMLTextImportHelper::GetRangeFor(::rtl::OUString &sName)
2264 return aBookmarkStartRanges[sName].first;
2268 void XMLTextImportHelper::pushFieldCtx( ::rtl::OUString name, ::rtl::OUString type )
2270 aFieldStack.push(field_stack_item_t(field_name_type_t(name, type), field_params_t()));
2273 void XMLTextImportHelper::popFieldCtx()
2275 aFieldStack.pop();
2278 void XMLTextImportHelper::addFieldParam( ::rtl::OUString name, ::rtl::OUString value )
2280 DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before...");
2281 if (!aFieldStack.empty()) {
2282 field_stack_item_t &aFieldStackItem=aFieldStack.top();
2283 aFieldStackItem.second.push_back(field_param_t( name, value ));
2286 ::rtl::OUString XMLTextImportHelper::getCurrentFieldName()
2288 DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before...");
2289 if (!aFieldStack.empty()) {
2290 return aFieldStack.top().first.first;
2291 } else return ::rtl::OUString();
2294 ::rtl::OUString XMLTextImportHelper::getCurrentFieldType()
2296 DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before...");
2297 if (!aFieldStack.empty()) {
2298 return aFieldStack.top().first.second;
2299 } else return ::rtl::OUString();
2302 bool XMLTextImportHelper::hasCurrentFieldCtx()
2304 return !aFieldStack.empty();
2307 void XMLTextImportHelper::setCurrentFieldParamsTo(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField> &xFormField)
2309 DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before...");
2310 if (!aFieldStack.empty() && xFormField.is()) {
2311 field_params_t &params=aFieldStack.top().second;
2312 for (field_params_t::iterator i=params.begin();i!=params.end();i++) {
2313 rtl::OString aOString1 = ::rtl::OUStringToOString (i->first, RTL_TEXTENCODING_UTF8);
2314 rtl::OString aOString2 = ::rtl::OUStringToOString (i->second, RTL_TEXTENCODING_UTF8);
2315 /* printf("param[\"%s\"]=\"%s\"\n", aOString1.getStr(), aOString2.getStr()); */
2316 xFormField->addParam(i->first, i->second, false);
2322 void XMLTextImportHelper::ConnectFrameChains(
2323 const OUString& rFrmName,
2324 const OUString& rNextFrmName,
2325 const Reference < XPropertySet >& rFrmPropSet )
2327 if( !rFrmName.getLength() )
2328 return;
2330 if( rNextFrmName.getLength() )
2332 OUString sNextFrmName(GetRenameMap().Get( XML_TEXT_RENAME_TYPE_FRAME,
2333 rNextFrmName ));
2334 if( xTextFrames.is() && xTextFrames->hasByName( sNextFrmName ) )
2336 rFrmPropSet->setPropertyValue( sChainNextName, makeAny(sNextFrmName) );
2338 else
2340 if( !pPrevFrmNames.get() )
2342 pPrevFrmNames.reset( new SvStringsDtor );
2343 pNextFrmNames.reset( new SvStringsDtor );
2345 pPrevFrmNames->Insert( new String( rFrmName ),
2346 pPrevFrmNames->Count() );
2347 pNextFrmNames->Insert( new String( sNextFrmName ),
2348 pNextFrmNames->Count() );
2351 if( pPrevFrmNames.get() && pPrevFrmNames->Count() )
2353 sal_uInt16 nCount = pPrevFrmNames->Count();
2354 for( sal_uInt16 i=0; i<nCount; i++ )
2356 String *pNext = (*pNextFrmNames)[i];
2357 if( OUString(*pNext) == rFrmName )
2359 // The previuous frame must exist, because it existing than
2360 // inserting the entry
2361 String *pPrev = (*pPrevFrmNames)[i];
2363 rFrmPropSet->setPropertyValue( sChainPrevName, makeAny(OUString( *pPrev )) );
2365 pPrevFrmNames->Remove( i, 1 );
2366 pNextFrmNames->Remove( i, 1 );
2367 delete pPrev;
2368 delete pNext;
2370 // There cannot be more than one previous frames
2371 break;
2377 sal_Bool XMLTextImportHelper::IsInFrame() const
2379 sal_Bool bIsInFrame = sal_False;
2381 // are we currently in a text frame? yes, if the cursor has a
2382 // TextFrame property and it's non-NULL
2383 Reference<XPropertySet> xPropSet(((XMLTextImportHelper *)this)->GetCursor(), UNO_QUERY);
2384 if (xPropSet.is())
2386 if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextFrame))
2388 Reference<XTextFrame> xFrame(xPropSet->getPropertyValue(sTextFrame), UNO_QUERY);
2390 if (xFrame.is())
2392 bIsInFrame = sal_True;
2397 return bIsInFrame;
2400 sal_Bool XMLTextImportHelper::IsInHeaderFooter() const
2402 return sal_False;
2405 Reference< XPropertySet> XMLTextImportHelper::createAndInsertOLEObject(
2406 SvXMLImport&,
2407 const OUString& /*rHRef*/,
2408 const OUString& /*rStyleName*/,
2409 const OUString& /*rTblName*/,
2410 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2412 Reference< XPropertySet> xPropSet;
2413 return xPropSet;
2416 Reference< XPropertySet> XMLTextImportHelper::createAndInsertOOoLink(
2417 SvXMLImport&,
2418 const OUString& /*rHRef*/,
2419 const OUString& /*rStyleName*/,
2420 const OUString& /*rTblName*/,
2421 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2423 Reference< XPropertySet> xPropSet;
2424 return xPropSet;
2427 Reference< XPropertySet> XMLTextImportHelper::createAndInsertApplet(
2428 const OUString& /*rCode*/,
2429 const OUString& /*rName*/,
2430 sal_Bool /*bMayScript*/,
2431 const OUString& /*rHRef*/,
2432 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2434 Reference< XPropertySet> xPropSet;
2435 return xPropSet;
2437 Reference< XPropertySet> XMLTextImportHelper::createAndInsertPlugin(
2438 const OUString& /*rMimeType*/,
2439 const OUString& /*rHRef*/,
2440 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2442 Reference< XPropertySet> xPropSet;
2443 return xPropSet;
2445 Reference< XPropertySet> XMLTextImportHelper::createAndInsertFloatingFrame(
2446 const OUString& /*rName*/,
2447 const OUString& /*rHRef*/,
2448 const OUString& /*rStyleName*/,
2449 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2451 Reference< XPropertySet> xPropSet;
2452 return xPropSet;
2455 void XMLTextImportHelper::endAppletOrPlugin(
2456 const Reference < XPropertySet> &,
2457 std::map < const rtl::OUString, rtl::OUString, UStringLess > &)
2460 // redline helper: dummy implementation to be overridden in sw/filter/xml
2461 void XMLTextImportHelper::RedlineAdd(
2462 const OUString& /*rType*/,
2463 const OUString& /*rId*/,
2464 const OUString& /*rAuthor*/,
2465 const OUString& /*rComment*/,
2466 const DateTime& /*rDateTime*/,
2467 sal_Bool /*bMergeLastPara*/)
2469 // dummy implementation: do nothing
2472 Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText(
2473 Reference<XTextCursor> & /*rOldCursor*/,
2474 const OUString& /*rId*/)
2476 // dummy implementation: do nothing
2477 Reference<XTextCursor> xRet;
2478 return xRet;
2481 void XMLTextImportHelper::RedlineSetCursor(
2482 const OUString& /*rId*/,
2483 sal_Bool /*bStart*/,
2484 sal_Bool /*bIsOutsideOfParagraph*/)
2486 // dummy implementation: do nothing
2489 void XMLTextImportHelper::RedlineAdjustStartNodeCursor(sal_Bool)
2491 // dummy implementation: do nothing
2494 void XMLTextImportHelper::SetShowChanges( sal_Bool )
2496 // dummy implementation: do nothing
2499 void XMLTextImportHelper::SetRecordChanges( sal_Bool )
2501 // dummy implementation: do nothing
2503 void XMLTextImportHelper::SetChangesProtectionKey(const Sequence<sal_Int8> &)
2505 // dummy implementation: do nothing
2509 OUString XMLTextImportHelper::GetOpenRedlineId()
2511 return sOpenRedlineIdentifier;
2514 void XMLTextImportHelper::SetOpenRedlineId( ::rtl::OUString& rId)
2516 sOpenRedlineIdentifier = rId;
2519 void XMLTextImportHelper::ResetOpenRedlineId()
2521 OUString sEmpty;
2522 SetOpenRedlineId(sEmpty);