Bump for 3.6-28
[LibreOffice.git] / xmloff / source / text / txtimp.cxx
blob11395016a4afd6d8eaaa744cfb9f2a8e387dda3b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <vector>
32 #include <boost/scoped_array.hpp>
33 #include <boost/tuple/tuple.hpp>
35 #include <tools/solar.h>
36 #include <tools/debug.hxx>
37 #include <svl/svstdarr.hxx>
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>
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"
87 #include "XMLCalculationSettingsContext.hxx"
88 #include "XMLNumberStylesImport.hxx"
89 // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#)
90 #include <com/sun/star/beans/XPropertyState.hpp>
91 #include <txtlists.hxx>
92 #include <xmloff/odffields.hxx>
93 #include <comphelper/stlunosequence.hxx>
95 using ::rtl::OUString;
96 using ::rtl::OUStringBuffer;
97 using ::com::sun::star::ucb::XAnyCompare;
99 using namespace ::std;
100 using namespace ::com::sun::star;
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;
113 using namespace ::com::sun::star;
114 using ::comphelper::UStringLess;
118 static SvXMLTokenMapEntry aTextElemTokenMap[] =
120 { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TEXT_P },
121 { XML_NAMESPACE_TEXT, XML_H, XML_TOK_TEXT_H },
122 { XML_NAMESPACE_TEXT, XML_LIST, XML_TOK_TEXT_LIST },
123 { XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_TEXT_FRAME_PAGE },
124 { XML_NAMESPACE_DRAW, XML_A, XML_TOK_DRAW_A_PAGE },
125 { XML_NAMESPACE_TABLE,XML_TABLE, XML_TOK_TABLE_TABLE },
126 { XML_NAMESPACE_TEXT, XML_VARIABLE_DECLS, XML_TOK_TEXT_VARFIELD_DECLS },
127 { XML_NAMESPACE_TEXT, XML_USER_FIELD_DECLS, XML_TOK_TEXT_USERFIELD_DECLS },
128 { XML_NAMESPACE_TEXT, XML_SEQUENCE_DECLS, XML_TOK_TEXT_SEQUENCE_DECLS },
129 { XML_NAMESPACE_TEXT, XML_DDE_CONNECTION_DECLS, XML_TOK_TEXT_DDE_DECLS },
130 { XML_NAMESPACE_TEXT, XML_SECTION, XML_TOK_TEXT_SECTION },
131 { XML_NAMESPACE_TEXT, XML_TABLE_OF_CONTENT, XML_TOK_TEXT_TOC },
132 { XML_NAMESPACE_TEXT, XML_OBJECT_INDEX, XML_TOK_TEXT_OBJECT_INDEX },
133 { XML_NAMESPACE_TEXT, XML_TABLE_INDEX, XML_TOK_TEXT_TABLE_INDEX },
134 { XML_NAMESPACE_TEXT, XML_ILLUSTRATION_INDEX, XML_TOK_TEXT_ILLUSTRATION_INDEX },
135 { XML_NAMESPACE_TEXT, XML_USER_INDEX, XML_TOK_TEXT_USER_INDEX },
136 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX, XML_TOK_TEXT_ALPHABETICAL_INDEX },
137 { XML_NAMESPACE_TEXT, XML_BIBLIOGRAPHY, XML_TOK_TEXT_BIBLIOGRAPHY_INDEX },
138 { XML_NAMESPACE_TEXT, XML_INDEX_TITLE, XML_TOK_TEXT_INDEX_TITLE },
139 { XML_NAMESPACE_TEXT, XML_TRACKED_CHANGES, XML_TOK_TEXT_TRACKED_CHANGES },
140 { XML_NAMESPACE_TEXT, XML_CHANGE_START, XML_TOK_TEXT_CHANGE_START },
141 { XML_NAMESPACE_TEXT, XML_CHANGE_END, XML_TOK_TEXT_CHANGE_END },
142 { XML_NAMESPACE_TEXT, XML_CHANGE, XML_TOK_TEXT_CHANGE },
143 { XML_NAMESPACE_OFFICE, XML_FORMS, XML_TOK_TEXT_FORMS },
144 { XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, XML_TOK_TEXT_CALCULATION_SETTINGS },
145 { XML_NAMESPACE_TEXT, XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE, XML_TOK_TEXT_AUTOMARK },
146 // #i52127#
147 { XML_NAMESPACE_TEXT, XML_NUMBERED_PARAGRAPH, XML_TOK_TEXT_NUMBERED_PARAGRAPH },
149 XML_TOKEN_MAP_END
152 static 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 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_ID, XML_TOK_TEXT_P_TEXTID },
336 { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_P_STYLE_NAME },
337 { XML_NAMESPACE_TEXT, XML_COND_STYLE_NAME,
338 XML_TOK_TEXT_P_COND_STYLE_NAME },
339 { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,XML_TOK_TEXT_P_LEVEL },
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 },
343 XML_TOKEN_MAP_END
346 static SvXMLTokenMapEntry aTextNumberedParagraphAttrTokenMap[] =
348 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID },
349 { XML_NAMESPACE_TEXT, XML_LIST_ID,
350 XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID },
351 { XML_NAMESPACE_TEXT, XML_LEVEL, XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL },
352 { XML_NAMESPACE_TEXT, XML_STYLE_NAME,
353 XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME },
354 { XML_NAMESPACE_TEXT, XML_CONTINUE_NUMBERING,
355 XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING },
356 { XML_NAMESPACE_TEXT, XML_START_VALUE,
357 XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE },
358 XML_TOKEN_MAP_END
361 static SvXMLTokenMapEntry aTextListBlockAttrTokenMap[] =
363 { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_LIST_BLOCK_XMLID },
364 { XML_NAMESPACE_TEXT, XML_STYLE_NAME,
365 XML_TOK_TEXT_LIST_BLOCK_STYLE_NAME },
366 { XML_NAMESPACE_TEXT, XML_CONTINUE_NUMBERING,
367 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_NUMBERING },
368 { XML_NAMESPACE_TEXT, XML_CONTINUE_LIST,
369 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_LIST },
370 XML_TOKEN_MAP_END
373 static SvXMLTokenMapEntry aTextListBlockElemTokenMap[] =
375 { XML_NAMESPACE_TEXT, XML_LIST_HEADER, XML_TOK_TEXT_LIST_HEADER },
376 { XML_NAMESPACE_TEXT, XML_LIST_ITEM, XML_TOK_TEXT_LIST_ITEM },
377 XML_TOKEN_MAP_END
380 static SvXMLTokenMapEntry aTextFrameAttrTokenMap[] =
382 { XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_TEXT_FRAME_STYLE_NAME },
383 { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_TEXT_FRAME_NAME },
384 { XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, XML_TOK_TEXT_FRAME_ANCHOR_TYPE },
385 { XML_NAMESPACE_TEXT, XML_ANCHOR_PAGE_NUMBER, XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER },
386 { XML_NAMESPACE_SVG, XML_X, XML_TOK_TEXT_FRAME_X },
387 { XML_NAMESPACE_SVG, XML_Y, XML_TOK_TEXT_FRAME_Y },
388 { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_TEXT_FRAME_WIDTH },
389 { XML_NAMESPACE_FO, XML_MIN_WIDTH, XML_TOK_TEXT_FRAME_MIN_WIDTH },
390 { XML_NAMESPACE_STYLE, XML_REL_WIDTH, XML_TOK_TEXT_FRAME_REL_WIDTH },
391 { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_TEXT_FRAME_HEIGHT },
392 { XML_NAMESPACE_FO, XML_MIN_HEIGHT, XML_TOK_TEXT_FRAME_MIN_HEIGHT },
393 { XML_NAMESPACE_STYLE, XML_REL_HEIGHT, XML_TOK_TEXT_FRAME_REL_HEIGHT },
394 { XML_NAMESPACE_DRAW, XML_CHAIN_NEXT_NAME, XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME },
395 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_FRAME_HREF },
396 { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_TEXT_FRAME_FILTER_NAME },
397 { XML_NAMESPACE_DRAW, XML_ZINDEX, XML_TOK_TEXT_FRAME_Z_INDEX },
398 { XML_NAMESPACE_SVG, XML_TRANSFORM, XML_TOK_TEXT_FRAME_TRANSFORM },
399 { XML_NAMESPACE_DRAW, XML_CLASS_ID, XML_TOK_TEXT_FRAME_CLASS_ID },
400 { XML_NAMESPACE_DRAW, XML_CODE, XML_TOK_TEXT_FRAME_CODE },
401 { XML_NAMESPACE_DRAW, XML_OBJECT, XML_TOK_TEXT_FRAME_OBJECT },
402 { XML_NAMESPACE_DRAW, XML_ARCHIVE, XML_TOK_TEXT_FRAME_ARCHIVE },
403 { XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, XML_TOK_TEXT_FRAME_MAY_SCRIPT },
404 { XML_NAMESPACE_DRAW, XML_MIME_TYPE, XML_TOK_TEXT_FRAME_MIME_TYPE },
405 { XML_NAMESPACE_DRAW, XML_APPLET_NAME, XML_TOK_TEXT_FRAME_APPLET_NAME },
406 { XML_NAMESPACE_DRAW, XML_FRAME_NAME, XML_TOK_TEXT_FRAME_FRAME_NAME },
407 { XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE },
408 { XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_TABLE, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE },
409 XML_TOKEN_MAP_END
412 static SvXMLTokenMapEntry aTextContourAttrTokenMap[] =
414 { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_TEXT_CONTOUR_WIDTH },
415 { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_TEXT_CONTOUR_HEIGHT },
416 { XML_NAMESPACE_SVG, XML_VIEWBOX, XML_TOK_TEXT_CONTOUR_VIEWBOX },
417 { XML_NAMESPACE_SVG, XML_D, XML_TOK_TEXT_CONTOUR_D },
418 { XML_NAMESPACE_DRAW,XML_POINTS, XML_TOK_TEXT_CONTOUR_POINTS },
419 { XML_NAMESPACE_DRAW,XML_RECREATE_ON_EDIT, XML_TOK_TEXT_CONTOUR_AUTO },
420 XML_TOKEN_MAP_END
423 static SvXMLTokenMapEntry aTextHyperlinkAttrTokenMap[] =
425 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXT_HYPERLINK_HREF },
426 { XML_NAMESPACE_OFFICE, XML_NAME, XML_TOK_TEXT_HYPERLINK_NAME },
427 { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_TEXT_HYPERLINK_SHOW },
428 { XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, XML_TOK_TEXT_HYPERLINK_TARGET_FRAME },
429 { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_HYPERLINK_STYLE_NAME },
430 { XML_NAMESPACE_TEXT, XML_VISITED_STYLE_NAME, XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME },
431 { XML_NAMESPACE_OFFICE, XML_SERVER_MAP, XML_TOK_TEXT_HYPERLINK_SERVER_MAP },
432 XML_TOKEN_MAP_END
435 static SvXMLTokenMapEntry aTextMasterPageElemTokenMap[] =
437 { XML_NAMESPACE_STYLE, XML_HEADER, XML_TOK_TEXT_MP_HEADER },
438 { XML_NAMESPACE_STYLE, XML_FOOTER, XML_TOK_TEXT_MP_FOOTER },
439 { XML_NAMESPACE_STYLE, XML_HEADER_LEFT, XML_TOK_TEXT_MP_HEADER_LEFT },
440 { XML_NAMESPACE_STYLE, XML_FOOTER_LEFT, XML_TOK_TEXT_MP_FOOTER_LEFT },
442 XML_TOKEN_MAP_END
445 static SvXMLTokenMapEntry aTextFieldAttrTokenMap[] =
447 { XML_NAMESPACE_TEXT, XML_FIXED, XML_TOK_TEXTFIELD_FIXED },
448 { XML_NAMESPACE_TEXT, XML_DESCRIPTION, XML_TOK_TEXTFIELD_DESCRIPTION },
449 { XML_NAMESPACE_TEXT, XML_HELP, XML_TOK_TEXTFIELD_HELP },
450 { XML_NAMESPACE_TEXT, XML_HINT, XML_TOK_TEXTFIELD_HINT },
451 { XML_NAMESPACE_TEXT, XML_PLACEHOLDER_TYPE,
452 XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE },
453 { XML_NAMESPACE_TEXT, XML_NAME, XML_TOK_TEXTFIELD_NAME },
454 { XML_NAMESPACE_TEXT, XML_FORMULA, XML_TOK_TEXTFIELD_FORMULA },
455 { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_TEXTFIELD_NUM_FORMAT },
456 { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC,
457 XML_TOK_TEXTFIELD_NUM_LETTER_SYNC },
458 { XML_NAMESPACE_TEXT, XML_DISPLAY_FORMULA,
459 XML_TOK_TEXTFIELD_DISPLAY_FORMULA },
460 { XML_NAMESPACE_TEXT, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE }, // #i32362#: src680m48++ saves text:value-type
461 { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE },
462 { XML_NAMESPACE_TEXT, XML_VALUE, XML_TOK_TEXTFIELD_VALUE },
463 { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TEXTFIELD_VALUE },
464 { XML_NAMESPACE_TEXT, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE },
465 { XML_NAMESPACE_OFFICE, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE },
466 { XML_NAMESPACE_TEXT, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE },
467 { XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE },
468 { XML_NAMESPACE_TEXT, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE },
469 { XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE },
470 { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TOK_TEXTFIELD_BOOL_VALUE},
471 { XML_NAMESPACE_OFFICE, XML_CURRENCY, XML_TOK_TEXTFIELD_CURRENCY},
472 { XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME,
473 XML_TOK_TEXTFIELD_DATA_STYLE_NAME },
474 { XML_NAMESPACE_TEXT, XML_DISPLAY_OUTLINE_LEVEL,
475 XML_TOK_TEXTFIELD_NUMBERING_LEVEL },
476 { XML_NAMESPACE_TEXT, XML_SEPARATION_CHARACTER,
477 XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR },
478 { XML_NAMESPACE_TEXT, XML_DISPLAY, XML_TOK_TEXTFIELD_DISPLAY },
479 { XML_NAMESPACE_TEXT, XML_TIME_ADJUST, XML_TOK_TEXTFIELD_TIME_ADJUST },
480 { XML_NAMESPACE_TEXT, XML_DATE_ADJUST, XML_TOK_TEXTFIELD_DATE_ADJUST },
481 { XML_NAMESPACE_TEXT, XML_PAGE_ADJUST, XML_TOK_TEXTFIELD_PAGE_ADJUST },
482 { XML_NAMESPACE_TEXT, XML_SELECT_PAGE, XML_TOK_TEXTFIELD_SELECT_PAGE },
483 { XML_NAMESPACE_TEXT, XML_DATABASE_NAME, XML_TOK_TEXTFIELD_DATABASE_NAME},
484 { XML_NAMESPACE_TEXT, XML_TABLE_NAME, XML_TOK_TEXTFIELD_TABLE_NAME },
485 { XML_NAMESPACE_TEXT, XML_COLUMN_NAME, XML_TOK_TEXTFIELD_COLUMN_NAME },
486 { XML_NAMESPACE_TEXT, XML_ROW_NUMBER, XML_TOK_TEXTFIELD_ROW_NUMBER },
487 { XML_NAMESPACE_TEXT, XML_CONDITION, XML_TOK_TEXTFIELD_CONDITION },
488 { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_TRUE,
489 XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE },
490 { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_FALSE,
491 XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE },
492 { XML_NAMESPACE_TEXT, XML_EDITING_CYCLES, XML_TOK_TEXTFIELD_REVISION },
493 { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, XML_TOK_TEXTFIELD_OUTLINE_LEVEL},
494 { XML_NAMESPACE_TEXT, XML_ACTIVE, XML_TOK_TEXTFIELD_ACTIVE },
495 { XML_NAMESPACE_TEXT, XML_NOTE_CLASS, XML_TOK_TEXTFIELD_NOTE_CLASS },
496 { XML_NAMESPACE_TEXT, XML_REFERENCE_FORMAT,
497 XML_TOK_TEXTFIELD_REFERENCE_FORMAT },
498 { XML_NAMESPACE_TEXT, XML_REF_NAME, XML_TOK_TEXTFIELD_REF_NAME },
499 { XML_NAMESPACE_TEXT, XML_CONNECTION_NAME,
500 XML_TOK_TEXTFIELD_CONNECTION_NAME },
501 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXTFIELD_HREF },
502 { XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME,
503 XML_TOK_TEXTFIELD_TARGET_FRAME },
504 { XML_NAMESPACE_TEXT, XML_ANNOTATION, XML_TOK_TEXTFIELD_ANNOTATION },
505 { XML_NAMESPACE_SCRIPT, XML_LANGUAGE, XML_TOK_TEXTFIELD_LANGUAGE },
506 { XML_NAMESPACE_TEXT, XML_KIND, XML_TOK_TEXTFIELD_MEASURE_KIND },
507 { XML_NAMESPACE_TEXT, XML_IS_HIDDEN, XML_TOK_TEXTFIELD_IS_HIDDEN },
508 { XML_NAMESPACE_TEXT, XML_CURRENT_VALUE,
509 XML_TOK_TEXTFIELD_CURRENT_VALUE },
510 { XML_NAMESPACE_TEXT, XML_TABLE_TYPE, XML_TOK_TEXTFIELD_TABLE_TYPE },
512 XML_TOKEN_MAP_END
516 // maximum allowed length of combined characters field
517 #define MAX_COMBINED_CHARACTERS 6
519 struct SAL_DLLPRIVATE XMLTextImportHelper::Impl
520 : private ::boost::noncopyable
522 SAL_WNODEPRECATED_DECLARATIONS_PUSH
523 ::std::auto_ptr<SvXMLTokenMap> m_pTextElemTokenMap;
524 ::std::auto_ptr<SvXMLTokenMap> m_pTextPElemTokenMap;
525 ::std::auto_ptr<SvXMLTokenMap> m_pTextPAttrTokenMap;
526 ::std::auto_ptr<SvXMLTokenMap> m_pTextFieldAttrTokenMap;
527 ::std::auto_ptr<SvXMLTokenMap> m_pTextNumberedParagraphAttrTokenMap;
528 ::std::auto_ptr<SvXMLTokenMap> m_pTextListBlockAttrTokenMap;
529 ::std::auto_ptr<SvXMLTokenMap> m_pTextListBlockElemTokenMap;
530 ::std::auto_ptr<SvXMLTokenMap> m_pTextFrameAttrTokenMap;
531 ::std::auto_ptr<SvXMLTokenMap> m_pTextContourAttrTokenMap;
532 ::std::auto_ptr<SvXMLTokenMap> m_pTextHyperlinkAttrTokenMap;
533 ::std::auto_ptr<SvXMLTokenMap> m_pTextMasterPageElemTokenMap;
534 ::std::auto_ptr< std::vector<rtl::OUString> > m_pPrevFrmNames;
535 ::std::auto_ptr< std::vector<rtl::OUString> > m_pNextFrmNames;
536 ::std::auto_ptr<XMLTextListsHelper> m_pTextListsHelper;
537 SAL_WNODEPRECATED_DECLARATIONS_POP
539 SvXMLImportContextRef m_xAutoStyles;
540 SvXMLImportContextRef m_xFontDecls;
542 UniReference< SvXMLImportPropertyMapper > m_xParaImpPrMap;
543 UniReference< SvXMLImportPropertyMapper > m_xTextImpPrMap;
544 UniReference< SvXMLImportPropertyMapper > m_xFrameImpPrMap;
545 UniReference< SvXMLImportPropertyMapper > m_xSectionImpPrMap;
546 UniReference< SvXMLImportPropertyMapper > m_xRubyImpPrMap;
548 SAL_WNODEPRECATED_DECLARATIONS_PUSH
549 ::std::auto_ptr<SvI18NMap> m_pRenameMap;
550 SAL_WNODEPRECATED_DECLARATIONS_POP
551 /* Change and extend data structure:
552 - data structure contains candidates of paragraph styles, which
553 will be assigned to the outline style
554 - data structure contains more than one candidate for each list level
555 of the outline style (#i69629#)
557 ::boost::scoped_array< ::std::vector< ::rtl::OUString > >
558 m_pOutlineStylesCandidates;
560 // start range, xml:id, RDFa stuff
561 typedef ::boost::tuple<
562 uno::Reference<text::XTextRange>, ::rtl::OUString,
563 ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > >
564 BookmarkMapEntry_t;
565 /// start ranges for open bookmarks
566 ::std::map< ::rtl::OUString, BookmarkMapEntry_t,
567 ::comphelper::UStringLess> m_BookmarkStartRanges;
569 typedef ::std::vector< ::rtl::OUString > BookmarkVector_t;
570 BookmarkVector_t m_BookmarkVector;
572 /// name of the last 'open' redline that started between paragraphs
573 ::rtl::OUString m_sOpenRedlineIdentifier;
575 uno::Reference<text::XText> m_xText;
576 uno::Reference<text::XTextCursor> m_xCursor;
577 uno::Reference<text::XTextRange> m_xCursorAsRange;
578 uno::Reference<container::XNameContainer> m_xParaStyles;
579 uno::Reference<container::XNameContainer> m_xTextStyles;
580 uno::Reference<container::XNameContainer> m_xNumStyles;
581 uno::Reference<container::XNameContainer> m_xFrameStyles;
582 uno::Reference<container::XNameContainer> m_xPageStyles;
583 uno::Reference<container::XIndexReplace> m_xChapterNumbering;
584 uno::Reference<container::XNameAccess> m_xTextFrames;
585 uno::Reference<container::XNameAccess> m_xGraphics;
586 uno::Reference<container::XNameAccess> m_xObjects;
587 uno::Reference<lang::XMultiServiceFactory> m_xServiceFactory;
589 SvXMLImport & m_rSvXMLImport;
591 bool m_bInsertMode : 1;
592 bool m_bStylesOnlyMode : 1;
593 bool m_bBlockMode : 1;
594 bool m_bProgress : 1;
595 bool m_bOrganizerMode : 1;
596 bool m_bBodyContentStarted : 1;
598 // #107848#
599 // One more flag to remember if we are inside a deleted redline section
600 bool m_bInsideDeleteContext : 1;
602 typedef ::std::pair< ::rtl::OUString, ::rtl::OUString> field_name_type_t;
603 typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > field_param_t;
604 typedef ::std::vector< field_param_t > field_params_t;
605 typedef ::std::pair< field_name_type_t, field_params_t > field_stack_item_t;
606 typedef ::std::stack< field_stack_item_t > field_stack_t;
608 field_stack_t m_FieldStack;
610 ::rtl::OUString m_sCellParaStyleDefault;
612 Impl( uno::Reference<frame::XModel> const& rModel,
613 SvXMLImport & rImport,
614 bool const bInsertMode, bool const bStylesOnlyMode,
615 bool const bProgress, bool const bBlockMode,
616 bool const bOrganizerMode)
617 : m_pTextElemTokenMap( 0 )
618 , m_pTextPElemTokenMap( 0 )
619 , m_pTextPAttrTokenMap( 0 )
620 , m_pTextFieldAttrTokenMap( 0 )
621 , m_pTextNumberedParagraphAttrTokenMap( 0 )
622 , m_pTextListBlockAttrTokenMap( 0 )
623 , m_pTextListBlockElemTokenMap( 0 )
624 , m_pTextFrameAttrTokenMap( 0 )
625 , m_pTextContourAttrTokenMap( 0 )
626 , m_pTextHyperlinkAttrTokenMap( 0 )
627 , m_pTextMasterPageElemTokenMap( 0 )
628 , m_pPrevFrmNames( 0 )
629 , m_pNextFrmNames( 0 )
630 , m_pTextListsHelper( new XMLTextListsHelper() )
631 , m_pRenameMap( 0 )
632 // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#)
633 , m_pOutlineStylesCandidates( 0 )
634 , m_xServiceFactory( rModel, UNO_QUERY )
635 , m_rSvXMLImport( rImport )
636 , m_bInsertMode( bInsertMode )
637 , m_bStylesOnlyMode( bStylesOnlyMode )
638 , m_bBlockMode( bBlockMode )
639 , m_bProgress( bProgress )
640 , m_bOrganizerMode( bOrganizerMode )
641 , m_bBodyContentStarted( true )
642 // #107848# Initialize inside_deleted_section flag correctly
643 , m_bInsideDeleteContext( false )
647 void InitOutlineStylesCandidates()
649 if (!m_pOutlineStylesCandidates)
651 size_t const size(m_xChapterNumbering->getCount());
652 m_pOutlineStylesCandidates.reset(
653 new ::std::vector< ::rtl::OUString >[size] );
660 uno::Reference< text::XText > & XMLTextImportHelper::GetText()
662 return m_pImpl->m_xText;
665 uno::Reference< text::XTextCursor > & XMLTextImportHelper::GetCursor()
667 return m_pImpl->m_xCursor;
670 uno::Reference< text::XTextRange > & XMLTextImportHelper::GetCursorAsRange()
672 return m_pImpl->m_xCursorAsRange;
675 bool XMLTextImportHelper::IsInsertMode() const
677 return m_pImpl->m_bInsertMode;
680 bool XMLTextImportHelper::IsStylesOnlyMode() const
682 return m_pImpl->m_bStylesOnlyMode;
685 bool XMLTextImportHelper::IsBlockMode() const
687 return m_pImpl->m_bBlockMode;
690 bool XMLTextImportHelper::IsOrganizerMode() const
692 return m_pImpl->m_bOrganizerMode;
695 bool XMLTextImportHelper::IsProgress() const
697 return m_pImpl->m_bProgress;
700 uno::Reference<container::XNameContainer> const&
701 XMLTextImportHelper::GetParaStyles() const
703 return m_pImpl->m_xParaStyles;
706 uno::Reference<container::XNameContainer> const&
707 XMLTextImportHelper::GetTextStyles() const
709 return m_pImpl->m_xTextStyles;
712 uno::Reference<container::XNameContainer> const&
713 XMLTextImportHelper::GetNumberingStyles() const
715 return m_pImpl->m_xNumStyles;
718 uno::Reference<container::XNameContainer> const&
719 XMLTextImportHelper::GetFrameStyles() const
721 return m_pImpl->m_xFrameStyles;
724 uno::Reference<container::XNameContainer> const&
725 XMLTextImportHelper::GetPageStyles() const
727 return m_pImpl->m_xPageStyles;
730 uno::Reference<container::XIndexReplace> const&
731 XMLTextImportHelper::GetChapterNumbering() const
733 return m_pImpl->m_xChapterNumbering;
736 UniReference< SvXMLImportPropertyMapper > const&
737 XMLTextImportHelper::GetParaImportPropertySetMapper() const
739 return m_pImpl->m_xParaImpPrMap;
742 UniReference< SvXMLImportPropertyMapper > const&
743 XMLTextImportHelper::GetTextImportPropertySetMapper() const
745 return m_pImpl->m_xTextImpPrMap;
748 UniReference< SvXMLImportPropertyMapper > const&
749 XMLTextImportHelper::GetSectionImportPropertySetMapper() const
751 return m_pImpl->m_xSectionImpPrMap;
754 UniReference< SvXMLImportPropertyMapper > const&
755 XMLTextImportHelper::GetRubyImportPropertySetMapper() const
757 return m_pImpl->m_xRubyImpPrMap;
760 void XMLTextImportHelper::SetInsideDeleteContext(bool const bNew)
762 m_pImpl->m_bInsideDeleteContext = bNew;
765 bool XMLTextImportHelper::IsInsideDeleteContext() const
767 return m_pImpl->m_bInsideDeleteContext;
770 SvXMLImport & XMLTextImportHelper::GetXMLImport()
772 return m_pImpl->m_rSvXMLImport;
775 XMLTextListsHelper & XMLTextImportHelper::GetTextListHelper()
777 return *m_pImpl->m_pTextListsHelper;
780 const SvXMLTokenMap& XMLTextImportHelper::GetTextElemTokenMap()
782 if (!m_pImpl->m_pTextElemTokenMap.get())
784 m_pImpl->m_pTextElemTokenMap.reset(
785 new SvXMLTokenMap( aTextElemTokenMap ));
787 return *m_pImpl->m_pTextElemTokenMap;
790 const SvXMLTokenMap& XMLTextImportHelper::GetTextPElemTokenMap()
792 if (!m_pImpl->m_pTextPElemTokenMap.get())
794 m_pImpl->m_pTextPElemTokenMap.reset(
795 new SvXMLTokenMap( aTextPElemTokenMap ));
797 return *m_pImpl->m_pTextPElemTokenMap;
800 const SvXMLTokenMap& XMLTextImportHelper::GetTextPAttrTokenMap()
802 if (!m_pImpl->m_pTextPAttrTokenMap.get())
804 m_pImpl->m_pTextPAttrTokenMap.reset(
805 new SvXMLTokenMap( aTextPAttrTokenMap ));
807 return *m_pImpl->m_pTextPAttrTokenMap;
810 const SvXMLTokenMap& XMLTextImportHelper::GetTextFrameAttrTokenMap()
812 if (!m_pImpl->m_pTextFrameAttrTokenMap.get())
814 m_pImpl->m_pTextFrameAttrTokenMap.reset(
815 new SvXMLTokenMap( aTextFrameAttrTokenMap ));
817 return *m_pImpl->m_pTextFrameAttrTokenMap;
820 const SvXMLTokenMap& XMLTextImportHelper::GetTextContourAttrTokenMap()
822 if (!m_pImpl->m_pTextContourAttrTokenMap.get())
824 m_pImpl->m_pTextContourAttrTokenMap.reset(
825 new SvXMLTokenMap( aTextContourAttrTokenMap ));
827 return *m_pImpl->m_pTextContourAttrTokenMap;
830 const SvXMLTokenMap& XMLTextImportHelper::GetTextHyperlinkAttrTokenMap()
832 if (!m_pImpl->m_pTextHyperlinkAttrTokenMap.get())
834 m_pImpl->m_pTextHyperlinkAttrTokenMap.reset(
835 new SvXMLTokenMap( aTextHyperlinkAttrTokenMap ));
837 return *m_pImpl->m_pTextHyperlinkAttrTokenMap;
840 const SvXMLTokenMap& XMLTextImportHelper::GetTextMasterPageElemTokenMap()
842 if (!m_pImpl->m_pTextMasterPageElemTokenMap.get())
844 m_pImpl->m_pTextMasterPageElemTokenMap.reset(
845 new SvXMLTokenMap( aTextMasterPageElemTokenMap ));
847 return *m_pImpl->m_pTextMasterPageElemTokenMap;
850 const SvXMLTokenMap& XMLTextImportHelper::GetTextFieldAttrTokenMap()
852 if (!m_pImpl->m_pTextFieldAttrTokenMap.get())
854 m_pImpl->m_pTextFieldAttrTokenMap.reset(
855 new SvXMLTokenMap( aTextFieldAttrTokenMap ));
857 return *m_pImpl->m_pTextFieldAttrTokenMap;
861 namespace
863 class FieldParamImporter
865 public:
866 typedef pair<OUString,OUString> field_param_t;
867 typedef vector<field_param_t> field_params_t;
868 FieldParamImporter(const field_params_t* const pInParams, Reference<XNameContainer> xOutParams)
869 : m_pInParams(pInParams)
870 , m_xOutParams(xOutParams)
871 { };
872 void Import();
874 private:
875 const field_params_t* const m_pInParams;
876 Reference<XNameContainer> m_xOutParams;
879 void FieldParamImporter::Import()
881 ::std::vector<OUString> vListEntries;
882 ::std::map<OUString, Any> vOutParams;
883 for(field_params_t::const_iterator pCurrent = m_pInParams->begin();
884 pCurrent != m_pInParams->end();
885 ++pCurrent)
887 if(pCurrent->first.equalsAscii(ODF_FORMDROPDOWN_RESULT))
889 // sal_Int32
890 vOutParams[pCurrent->first] = makeAny(pCurrent->second.toInt32());
892 else if(pCurrent->first.equalsAscii(ODF_FORMCHECKBOX_RESULT))
894 // bool
895 vOutParams[pCurrent->first] = makeAny(pCurrent->second.toBoolean());
897 else if(pCurrent->first.equalsAscii(ODF_FORMDROPDOWN_LISTENTRY))
899 // sequence
900 vListEntries.push_back(pCurrent->second);
902 else
903 vOutParams[pCurrent->first] = makeAny(pCurrent->second);
905 if(!vListEntries.empty())
907 Sequence<OUString> vListEntriesSeq(vListEntries.size());
908 copy(vListEntries.begin(), vListEntries.end(), ::comphelper::stl_begin(vListEntriesSeq));
909 vOutParams[OUString(ODF_FORMDROPDOWN_LISTENTRY)] = makeAny(vListEntriesSeq);
911 for(::std::map<OUString, Any>::const_iterator pCurrent = vOutParams.begin();
912 pCurrent != vOutParams.end();
913 ++pCurrent)
917 m_xOutParams->insertByName(pCurrent->first, pCurrent->second);
919 catch(const ElementExistException&)
926 XMLTextImportHelper::XMLTextImportHelper(
927 uno::Reference<frame::XModel> const& rModel,
928 SvXMLImport& rImport,
929 bool const bInsertMode, bool const bStylesOnlyMode,
930 bool const bProgress, bool const bBlockMode,
931 bool const bOrganizerMode)
932 : m_pImpl( new Impl(rModel, rImport, bInsertMode, bStylesOnlyMode,
933 bProgress, bBlockMode, bOrganizerMode) )
934 , m_pBackpatcherImpl( MakeBackpatcherImpl() )
936 static ::rtl::OUString s_PropNameDefaultListId(
937 "DefaultListId");
939 Reference< XChapterNumberingSupplier > xCNSupplier( rModel, UNO_QUERY );
941 if( xCNSupplier.is() )
943 m_pImpl->m_xChapterNumbering = xCNSupplier->getChapterNumberingRules();
944 if (m_pImpl->m_xChapterNumbering.is())
946 Reference< XPropertySet > const xNumRuleProps(
947 m_pImpl->m_xChapterNumbering, UNO_QUERY);
948 if ( xNumRuleProps.is() )
950 Reference< XPropertySetInfo > xNumRulePropSetInfo(
951 xNumRuleProps->getPropertySetInfo());
952 if (xNumRulePropSetInfo.is() &&
953 xNumRulePropSetInfo->hasPropertyByName(
954 s_PropNameDefaultListId))
956 ::rtl::OUString sListId;
957 xNumRuleProps->getPropertyValue(s_PropNameDefaultListId)
958 >>= sListId;
959 DBG_ASSERT( !sListId.isEmpty(),
960 "no default list id found at chapter numbering rules instance. Serious defect -> please inform OD." );
961 if ( !sListId.isEmpty() )
963 Reference< XNamed > const xChapterNumNamed(
964 m_pImpl->m_xChapterNumbering, UNO_QUERY);
965 if ( xChapterNumNamed.is() )
967 m_pImpl->m_pTextListsHelper->KeepListAsProcessed(
968 sListId,
969 xChapterNumNamed->getName(),
970 ::rtl::OUString() );
978 Reference< XStyleFamiliesSupplier > xFamiliesSupp( rModel, UNO_QUERY );
979 // DBG_ASSERT( xFamiliesSupp.is(), "no chapter numbering supplier" ); for clipboard there may be documents without styles
981 if( xFamiliesSupp.is() )
983 Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
985 const OUString aParaStyles("ParagraphStyles");
986 if( xFamilies->hasByName( aParaStyles ) )
988 m_pImpl->m_xParaStyles.set(xFamilies->getByName(aParaStyles),
989 UNO_QUERY);
992 const OUString aCharStyles("CharacterStyles");
993 if( xFamilies->hasByName( aCharStyles ) )
995 m_pImpl->m_xTextStyles.set(xFamilies->getByName(aCharStyles),
996 UNO_QUERY);
999 const OUString aNumStyles("NumberingStyles");
1000 if( xFamilies->hasByName( aNumStyles ) )
1002 m_pImpl->m_xNumStyles.set(xFamilies->getByName(aNumStyles),
1003 UNO_QUERY);
1006 const OUString aFrameStyles("FrameStyles");
1007 if( xFamilies->hasByName( aFrameStyles ) )
1009 m_pImpl->m_xFrameStyles.set(xFamilies->getByName(aFrameStyles),
1010 UNO_QUERY);
1013 const OUString aPageStyles("PageStyles");
1014 if( xFamilies->hasByName( aPageStyles ) )
1016 m_pImpl->m_xPageStyles.set(xFamilies->getByName(aPageStyles),
1017 UNO_QUERY);
1021 Reference < XTextFramesSupplier > xTFS( rModel, UNO_QUERY );
1022 if( xTFS.is() )
1024 m_pImpl->m_xTextFrames.set(xTFS->getTextFrames());
1027 Reference < XTextGraphicObjectsSupplier > xTGOS( rModel, UNO_QUERY );
1028 if( xTGOS.is() )
1030 m_pImpl->m_xGraphics.set(xTGOS->getGraphicObjects());
1033 Reference < XTextEmbeddedObjectsSupplier > xTEOS( rModel, UNO_QUERY );
1034 if( xTEOS.is() )
1036 m_pImpl->m_xObjects.set(xTEOS->getEmbeddedObjects());
1039 XMLPropertySetMapper *pPropMapper =
1040 new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA );
1041 m_pImpl->m_xParaImpPrMap =
1042 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1044 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
1045 m_pImpl->m_xTextImpPrMap =
1046 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1048 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
1049 m_pImpl->m_xFrameImpPrMap =
1050 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1052 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION );
1053 m_pImpl->m_xSectionImpPrMap =
1054 new XMLTextImportPropertyMapper( pPropMapper, rImport );
1056 pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY );
1057 m_pImpl->m_xRubyImpPrMap =
1058 new SvXMLImportPropertyMapper( pPropMapper, rImport );
1061 XMLTextImportHelper::~XMLTextImportHelper()
1065 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateShapeExtPropMapper(SvXMLImport& rImport)
1067 XMLPropertySetMapper *pPropMapper =
1068 new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
1069 return new XMLTextImportPropertyMapper( pPropMapper, rImport,
1070 const_cast<XMLFontStylesContext*>(rImport.GetFontDecls()) );
1073 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext *pFontDecls)
1075 XMLPropertySetMapper *pPropMapper =
1076 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
1077 if (!pFontDecls)
1078 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
1079 return new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
1082 SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaDefaultExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext* pFontDecls)
1084 if (!pFontDecls)
1085 pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls());
1087 XMLPropertySetMapper* pPropMapper =
1088 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
1089 SvXMLImportPropertyMapper* pImportMapper = new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls );
1091 pPropMapper =
1092 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS );
1093 pImportMapper->ChainImportMapper( new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls ) );
1095 return pImportMapper;
1098 SvXMLImportPropertyMapper*
1099 XMLTextImportHelper::CreateTableDefaultExtPropMapper(
1100 SvXMLImport& rImport,
1101 XMLFontStylesContext* )
1103 XMLPropertySetMapper *pPropMapper =
1104 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_DEFAULTS );
1105 return new SvXMLImportPropertyMapper( pPropMapper, rImport );
1108 SvXMLImportPropertyMapper*
1109 XMLTextImportHelper::CreateTableRowDefaultExtPropMapper(
1110 SvXMLImport& rImport,
1111 XMLFontStylesContext* )
1113 XMLPropertySetMapper *pPropMapper =
1114 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_ROW_DEFAULTS );
1115 return new SvXMLImportPropertyMapper( pPropMapper, rImport );
1118 void XMLTextImportHelper::SetCursor( const Reference < XTextCursor > & rCursor )
1120 m_pImpl->m_xCursor.set(rCursor);
1121 m_pImpl->m_xText.set(rCursor->getText());
1122 m_pImpl->m_xCursorAsRange.set( rCursor, UNO_QUERY );
1125 void XMLTextImportHelper::ResetCursor()
1127 m_pImpl->m_xCursor.set(0);
1128 m_pImpl->m_xText.set(0);
1129 m_pImpl->m_xCursorAsRange.set(0);
1133 sal_Bool XMLTextImportHelper::HasFrameByName( const OUString& rName ) const
1135 return (m_pImpl->m_xTextFrames.is() &&
1136 m_pImpl->m_xTextFrames->hasByName(rName))
1137 || (m_pImpl->m_xGraphics.is() &&
1138 m_pImpl->m_xGraphics->hasByName(rName))
1139 || (m_pImpl->m_xObjects.is() &&
1140 m_pImpl->m_xObjects->hasByName(rName));
1143 void XMLTextImportHelper::InsertString( const OUString& rChars )
1145 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1146 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1147 if (m_pImpl->m_xText.is())
1149 m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange,
1150 rChars, sal_False);
1154 void XMLTextImportHelper::InsertString( const OUString& rChars,
1155 sal_Bool& rIgnoreLeadingSpace )
1157 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1158 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1159 if (m_pImpl->m_xText.is())
1161 sal_Int32 nLen = rChars.getLength();
1162 OUStringBuffer sChars( nLen );
1164 for( sal_Int32 i=0; i < nLen; i++ )
1166 sal_Unicode c = rChars[i];
1167 switch( c )
1169 case 0x20:
1170 case 0x09:
1171 case 0x0a:
1172 case 0x0d:
1173 if( !rIgnoreLeadingSpace )
1174 sChars.append( (sal_Unicode)0x20 );
1175 rIgnoreLeadingSpace = sal_True;
1176 break;
1177 default:
1178 rIgnoreLeadingSpace = sal_False;
1179 sChars.append( c );
1180 break;
1183 m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange,
1184 sChars.makeStringAndClear(), sal_False);
1188 void XMLTextImportHelper::InsertControlCharacter( sal_Int16 nControl )
1190 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1191 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1192 if (m_pImpl->m_xText.is())
1194 m_pImpl->m_xText->insertControlCharacter(
1195 m_pImpl->m_xCursorAsRange, nControl, sal_False);
1199 void XMLTextImportHelper::InsertTextContent(
1200 Reference < XTextContent > & xContent )
1202 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1203 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1204 if (m_pImpl->m_xText.is())
1206 m_pImpl->m_xText->insertTextContent(
1207 m_pImpl->m_xCursorAsRange, xContent, sal_False);
1211 void XMLTextImportHelper::DeleteParagraph()
1213 DBG_ASSERT(m_pImpl->m_xText.is(), "no text");
1214 DBG_ASSERT(m_pImpl->m_xCursor.is(), "no cursor");
1215 DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range");
1217 sal_Bool bDelete = sal_True;
1218 Reference < XEnumerationAccess > const xEnumAccess(
1219 m_pImpl->m_xCursor, UNO_QUERY);
1220 if( xEnumAccess.is() )
1222 Reference < XEnumeration > xEnum(xEnumAccess->createEnumeration());
1223 DBG_ASSERT( xEnum->hasMoreElements(), "empty text enumeration" );
1224 if( xEnum->hasMoreElements() )
1226 Reference < XComponent > xComp( xEnum->nextElement(), UNO_QUERY );
1227 DBG_ASSERT( xComp.is(), "got no component" );
1228 if( xComp.is() )
1230 xComp->dispose();
1231 bDelete = sal_False;
1235 if( bDelete )
1237 if (m_pImpl->m_xCursor->goLeft( 1, sal_True ))
1239 OUString sEmpty;
1240 m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange,
1241 sEmpty, sal_True);
1246 OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars,
1247 const OUString& rStyleName,
1248 sal_uInt8& rFlags,
1249 sal_Bool bPara,
1250 SvXMLImport& rImport ) const
1252 OUStringBuffer sChars( rChars );
1253 sal_Bool bConverted = sal_False;
1254 for( sal_Int32 j=0; j<rChars.getLength(); j++ )
1256 sal_Unicode c = rChars[j];
1257 if( c >= 0xf000 && c <= 0xf0ff )
1259 if( (rFlags & CONV_STAR_FONT_FLAGS_VALID) == 0 )
1261 XMLTextStyleContext *pStyle = 0;
1262 sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH
1263 : XML_STYLE_FAMILY_TEXT_TEXT;
1264 if (!rStyleName.isEmpty() && m_pImpl->m_xAutoStyles.Is())
1266 const SvXMLStyleContext* pTempStyle =
1267 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
1268 FindStyleChildContext( nFamily, rStyleName,
1269 sal_True );
1270 pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle);
1273 if( pStyle )
1275 sal_Int32 nCount = pStyle->_GetProperties().size();
1276 if( nCount )
1278 UniReference < SvXMLImportPropertyMapper > xImpPrMap =
1279 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)
1280 ->GetImportPropertyMapper(nFamily);
1281 if( xImpPrMap.is() )
1283 UniReference<XMLPropertySetMapper> rPropMapper =
1284 xImpPrMap->getPropertySetMapper();
1285 for( sal_Int32 i=0; i < nCount; i++ )
1287 const XMLPropertyState& rProp = pStyle->_GetProperties()[i];
1288 sal_Int32 nIdx = rProp.mnIndex;
1289 sal_uInt32 nContextId = rPropMapper->GetEntryContextId(nIdx);
1290 if( CTF_FONTFAMILYNAME == nContextId )
1292 rFlags &= ~(CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH);
1293 OUString sFontName;
1294 rProp.maValue >>= sFontName;
1295 OUString sStarBats( "StarBats" );
1296 OUString sStarMath( "StarMath" );
1297 if( sFontName.equalsIgnoreAsciiCase( sStarBats ) )
1298 rFlags |= CONV_FROM_STAR_BATS;
1299 else if( sFontName.equalsIgnoreAsciiCase( sStarMath ) )
1300 rFlags |= CONV_FROM_STAR_MATH;
1301 break;
1309 rFlags |= CONV_STAR_FONT_FLAGS_VALID;
1311 if( (rFlags & CONV_FROM_STAR_BATS ) != 0 )
1313 sChars[j] = rImport.ConvStarBatsCharToStarSymbol( c );
1314 bConverted = sal_True;
1316 else if( (rFlags & CONV_FROM_STAR_MATH ) != 0 )
1318 sChars[j] = rImport.ConvStarMathCharToStarSymbol( c );
1319 bConverted = sal_True;
1324 return bConverted ? sChars.makeStringAndClear() : rChars;
1327 /* Helper method to determine, if a paragraph style has a list style (inclusive
1328 an empty one) inherits a list style (inclusive an empty one) from one of its parents (#i69629#)
1330 /* Apply special case, that found list style equals the chapter numbering, also
1331 to the found list styles of the parent styles. (#i73973#)
1333 sal_Bool lcl_HasListStyle( OUString sStyleName,
1334 const Reference < XNameContainer >& xParaStyles,
1335 SvXMLImport& rImport,
1336 const OUString& sNumberingStyleName,
1337 const OUString& sOutlineStyleName )
1339 sal_Bool bRet( sal_False );
1341 if ( !xParaStyles->hasByName( sStyleName ) )
1343 // error case
1344 return sal_True;
1347 Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ),
1348 UNO_QUERY );
1349 if ( !xPropState.is() )
1351 // error case
1352 return sal_False;
1355 if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
1357 // list style found
1358 bRet = sal_True;
1359 // special case: the set list style equals the chapter numbering
1360 Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
1361 if ( xPropSet.is() )
1363 OUString sListStyle;
1364 xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
1365 if ( !sListStyle.isEmpty() &&
1366 sListStyle == sOutlineStyleName )
1368 bRet = sal_False;
1372 else
1374 // Tools.Outline settings lost on Save (#i77708#)
1375 sal_Int32 nUPD( 0 );
1376 sal_Int32 nBuild( 0 );
1377 // Don't use UPD for versioning: xmloff/source/text/txtstyli.cxx and txtimp.cxx (#i86058#)
1378 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1379 // search list style at parent
1380 Reference<XStyle> xStyle( xPropState, UNO_QUERY );
1381 while ( xStyle.is() )
1383 OUString aParentStyle( xStyle->getParentStyle() );
1384 if ( !aParentStyle.isEmpty() )
1386 aParentStyle =
1387 rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
1388 aParentStyle );
1390 if ( aParentStyle.isEmpty() || !xParaStyles->hasByName( aParentStyle ) )
1392 // no list style found
1393 break;
1395 else
1397 xPropState = Reference< XPropertyState >(
1398 xParaStyles->getByName( aParentStyle ),
1399 UNO_QUERY );
1400 if ( !xPropState.is() )
1402 // error case
1403 return sal_True;
1405 if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
1407 // list style found
1408 bRet = sal_True;
1409 // Special case: the found list style equals the chapter numbering (#i73973#)
1410 Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
1411 if ( xPropSet.is() )
1413 OUString sListStyle;
1414 xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
1415 if ( !sListStyle.isEmpty() &&
1416 sListStyle == sOutlineStyleName )
1418 bRet = sal_False;
1420 // Special handling for text documents from OOo version prior OOo 2.4 (#i77708#)
1421 /* Check explicitly on certain versions and on import of
1422 text documents in OpenOffice.org file format (#i86058#)
1424 else if ( sListStyle.isEmpty() &&
1425 ( rImport.IsTextDocInOOoFileFormat() ||
1426 ( bBuildIdFound &&
1427 ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1428 ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1
1430 bRet = sal_False;
1433 break;
1435 else
1437 // search list style at parent
1438 xStyle = Reference<XStyle>( xPropState, UNO_QUERY );
1444 return bRet;
1446 OUString XMLTextImportHelper::SetStyleAndAttrs(
1447 SvXMLImport& rImport,
1448 const Reference < XTextCursor >& rCursor,
1449 const OUString& rStyleName,
1450 sal_Bool bPara,
1451 sal_Bool bOutlineLevelAttrFound,
1452 sal_Int8 nOutlineLevel,
1453 // Numberings/Bullets in table not visible aftzer save/reload (#i80724#)
1454 sal_Bool bSetListAttrs )
1456 static ::rtl::OUString s_ParaStyleName( "ParaStyleName");
1457 static ::rtl::OUString s_CharStyleName( "CharStyleName");
1458 static ::rtl::OUString s_NumberingRules( "NumberingRules");
1459 static ::rtl::OUString s_NumberingIsNumber( "NumberingIsNumber");
1460 static ::rtl::OUString s_NumberingLevel( "NumberingLevel");
1461 static ::rtl::OUString s_ParaIsNumberingRestart( "ParaIsNumberingRestart");
1462 static ::rtl::OUString s_NumberingStartValue( "NumberingStartValue");
1463 static ::rtl::OUString s_PropNameListId( "ListId");
1464 static ::rtl::OUString s_PageDescName( "PageDescName");
1465 static ::rtl::OUString s_ServiceCombinedCharacters( "com.sun.star.text.TextField.CombinedCharacters");
1466 static ::rtl::OUString s_Content("Content");
1467 static ::rtl::OUString s_OutlineLevel( "OutlineLevel");
1468 static ::rtl::OUString s_NumberingStyleName( "NumberingStyleName");
1470 const sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH
1471 : XML_STYLE_FAMILY_TEXT_TEXT;
1472 XMLTextStyleContext *pStyle = 0;
1473 OUString sStyleName( rStyleName );
1474 if (!sStyleName.isEmpty() && m_pImpl->m_xAutoStyles.Is())
1476 const SvXMLStyleContext* pTempStyle =
1477 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
1478 FindStyleChildContext( nFamily, sStyleName, sal_True );
1479 pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle);
1481 if( pStyle )
1482 sStyleName = pStyle->GetParentName();
1484 Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
1485 Reference< XPropertySetInfo > xPropSetInfo(
1486 xPropSet->getPropertySetInfo());
1488 // style
1489 if( !sStyleName.isEmpty() )
1491 sStyleName = rImport.GetStyleDisplayName( nFamily, sStyleName );
1492 const String& rPropName = (bPara) ? s_ParaStyleName : s_CharStyleName;
1493 const Reference < XNameContainer > & rStyles = (bPara)
1494 ? m_pImpl->m_xParaStyles
1495 : m_pImpl->m_xTextStyles;
1496 if( rStyles.is() &&
1497 xPropSetInfo->hasPropertyByName( rPropName ) &&
1498 rStyles->hasByName( sStyleName ) )
1500 xPropSet->setPropertyValue( rPropName, makeAny(sStyleName) );
1502 else
1503 sStyleName = OUString();
1506 /* The outline level needs to be only applied as list level, if the heading
1507 is not inside a list and if it by default applies the outline style. (#i70748#)
1509 bool bApplyOutlineLevelAsListLevel( false );
1510 // Numberings/Bullets in table not visible aftzer save/reload (#i80724#)
1511 if (bSetListAttrs && bPara
1512 && xPropSetInfo->hasPropertyByName( s_NumberingRules))
1514 // Set numbering rules
1515 Reference< XIndexReplace > const xNumRules(
1516 xPropSet->getPropertyValue(s_NumberingRules), UNO_QUERY);
1518 XMLTextListBlockContext * pListBlock(0);
1519 XMLTextListItemContext * pListItem(0);
1520 XMLNumberedParaContext * pNumberedParagraph(0);
1521 GetTextListHelper().ListContextTop(
1522 pListBlock, pListItem, pNumberedParagraph);
1524 OSL_ENSURE(!(pListBlock && pNumberedParagraph), "XMLTextImportHelper::"
1525 "SetStyleAndAttrs: both list and numbered-paragraph???");
1527 Reference < XIndexReplace > xNewNumRules;
1528 sal_Int8 nLevel(-1);
1529 ::rtl::OUString sListId;
1530 sal_Int16 nStartValue(-1);
1531 bool bNumberingIsNumber(true);
1533 if (pListBlock) {
1535 if (!pListItem) {
1536 bNumberingIsNumber = false; // list-header
1538 // consider text:style-override property of <text:list-item>
1539 xNewNumRules.set(
1540 (pListItem != 0 && pListItem->HasNumRulesOverride())
1541 ? pListItem->GetNumRulesOverride()
1542 : pListBlock->GetNumRules() );
1543 nLevel = static_cast<sal_Int8>(pListBlock->GetLevel());
1545 if ( pListItem && pListItem->HasStartValue() ) {
1546 nStartValue = pListItem->GetStartValue();
1549 // Inconsistent behavior regarding lists (#i92811#)
1550 sListId = m_pImpl->m_pTextListsHelper->GetListIdForListBlock(
1551 *pListBlock);
1553 else if (pNumberedParagraph)
1555 xNewNumRules.set(pNumberedParagraph->GetNumRules());
1556 nLevel = static_cast<sal_Int8>(pNumberedParagraph->GetLevel());
1557 sListId = pNumberedParagraph->GetListId();
1558 nStartValue = pNumberedParagraph->GetStartValue();
1562 if (pListBlock || pNumberedParagraph)
1564 // Assure that list style of automatic paragraph style is applied at paragraph. (#i101349#)
1565 sal_Bool bApplyNumRules = pStyle && pStyle->IsListStyleSet();
1566 if ( !bApplyNumRules )
1568 sal_Bool bSameNumRules = xNewNumRules == xNumRules;
1569 if( !bSameNumRules && xNewNumRules.is() && xNumRules.is() )
1571 // If the interface pointers are different then this does
1572 // not mean that the num rules are different. Further tests
1573 // are required then. However, if only one num rule is
1574 // set, no tests are required of course.
1575 Reference< XNamed > xNewNamed( xNewNumRules, UNO_QUERY );
1576 Reference< XNamed > xNamed( xNumRules, UNO_QUERY );
1577 if( xNewNamed.is() && xNamed.is() )
1579 bSameNumRules = xNewNamed->getName() == xNamed->getName();
1581 else
1583 Reference< XAnyCompare > xNumRuleCompare( xNumRules, UNO_QUERY );
1584 if( xNumRuleCompare.is() )
1586 bSameNumRules = (xNumRuleCompare->compare( Any(xNumRules), Any(xNewNumRules) ) == 0);
1590 bApplyNumRules = !bSameNumRules;
1593 if ( bApplyNumRules )
1595 // #102607# This may except when xNewNumRules contains
1596 // a Writer-NumRule-Implementation bug gets applied to
1597 // a shape. Since this may occur inside a document
1598 // (e.g. when edited), this must be handled
1599 // gracefully.
1602 xPropSet->setPropertyValue(
1603 s_NumberingRules, makeAny(xNewNumRules) );
1605 catch(const Exception&)
1607 ; // I would really like to use a warning here,
1608 // but I can't access the XMLErrorHandler from
1609 // here.
1613 if (!bNumberingIsNumber &&
1614 xPropSetInfo->hasPropertyByName(s_NumberingIsNumber))
1616 xPropSet->setPropertyValue(s_NumberingIsNumber, Any(sal_False));
1619 xPropSet->setPropertyValue( s_NumberingLevel, Any(nLevel) );
1621 if( pListBlock && pListBlock->IsRestartNumbering() )
1623 // TODO: property missing
1624 if (xPropSetInfo->hasPropertyByName(s_ParaIsNumberingRestart))
1626 sal_Bool bTmp = sal_True;
1627 xPropSet->setPropertyValue(s_ParaIsNumberingRestart,
1628 makeAny(bTmp) );
1630 pListBlock->ResetRestartNumbering();
1633 if ( 0 <= nStartValue &&
1634 xPropSetInfo->hasPropertyByName(s_NumberingStartValue))
1636 xPropSet->setPropertyValue(s_NumberingStartValue,
1637 makeAny(nStartValue));
1640 if (xPropSetInfo->hasPropertyByName(s_PropNameListId))
1642 if (!sListId.isEmpty()) {
1643 xPropSet->setPropertyValue(s_PropNameListId,
1644 makeAny(sListId) );
1648 GetTextListHelper().SetListItem( (XMLTextListItemContext *)0 );
1650 else
1652 /* If the paragraph is not in a list but its style, remove it from
1653 the list. Do not remove it, if the list of the style is
1654 the chapter numbering rule.
1656 if( xNumRules.is() )
1658 bool bRemove( true );
1659 // Special handling for document from OOo 2.x (#i70748#)
1660 sal_Int32 nUPD( 0 );
1661 sal_Int32 nBuild( 0 );
1662 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1663 DBG_ASSERT( ( bBuildIdFound && nUPD == 680 ) ||
1664 !pStyle ||
1665 !pStyle->IsListStyleSet() ||
1666 pStyle->GetListStyle().isEmpty(),
1667 "automatic paragraph style with list style name, but paragraph not in list???" );
1668 if ( ( bBuildIdFound && nUPD == 680 ) ||
1669 !pStyle || !pStyle->IsListStyleSet() )
1671 if (m_pImpl->m_xChapterNumbering.is())
1673 Reference< XNamed > xNumNamed( xNumRules, UNO_QUERY );
1674 Reference< XNamed > const xChapterNumNamed (
1675 m_pImpl->m_xChapterNumbering, UNO_QUERY);
1676 if ( xNumNamed.is() && xChapterNumNamed.is() &&
1677 xNumNamed->getName() == xChapterNumNamed->getName() )
1679 bRemove = false;
1680 // RFE: inserting headings into text documents (#i70748#)
1681 bApplyOutlineLevelAsListLevel = true;
1685 if ( bRemove )
1687 xPropSet->setPropertyValue( s_NumberingRules, Any() );
1693 // hard paragraph properties
1694 if( pStyle )
1696 pStyle->FillPropertySet( xPropSet );
1697 if( bPara && pStyle->HasMasterPageName() &&
1698 xPropSetInfo->hasPropertyByName(s_PageDescName))
1700 OUString sDisplayName(
1701 rImport.GetStyleDisplayName(
1702 XML_STYLE_FAMILY_MASTER_PAGE,
1703 pStyle->GetMasterPageName()) );
1704 if( sDisplayName.isEmpty() ||
1705 (m_pImpl->m_xPageStyles.is() &&
1706 m_pImpl->m_xPageStyles->hasByName( sDisplayName)))
1708 xPropSet->setPropertyValue(s_PageDescName,
1709 makeAny(sDisplayName));
1712 if( bPara && !pStyle->GetDropCapStyleName().isEmpty() &&
1713 m_pImpl->m_xTextStyles.is())
1715 OUString sDisplayName(
1716 rImport.GetStyleDisplayName(
1717 XML_STYLE_FAMILY_TEXT_TEXT,
1718 pStyle->GetDropCapStyleName()) );
1719 if (m_pImpl->m_xTextStyles->hasByName(sDisplayName) &&
1720 xPropSetInfo->hasPropertyByName( sDisplayName ) )
1722 xPropSet->setPropertyValue( pStyle->sDropCapCharStyleName, makeAny(sDisplayName) );
1726 // combined characters special treatment
1727 if (!bPara && pStyle->HasCombinedCharactersLetter())
1729 // insert combined characters text field
1730 if (m_pImpl->m_xServiceFactory.is())
1732 uno::Reference<beans::XPropertySet> const xTmp(
1733 m_pImpl->m_xServiceFactory->createInstance(
1734 s_ServiceCombinedCharacters), UNO_QUERY);
1735 if( xTmp.is() )
1737 // fix cursor if larger than possible for
1738 // combined characters field
1739 if (rCursor->getString().getLength() >
1740 MAX_COMBINED_CHARACTERS)
1742 rCursor->gotoRange(rCursor->getStart(), sal_False);
1743 rCursor->goRight(MAX_COMBINED_CHARACTERS, sal_True);
1746 // set field value (the combined character string)
1747 xTmp->setPropertyValue(s_Content,
1748 makeAny(rCursor->getString()));
1750 // insert the field over it's original text
1751 Reference<XTextRange> xRange(rCursor, UNO_QUERY);
1752 Reference<XTextContent> xTextContent(xTmp, UNO_QUERY);
1753 if (m_pImpl->m_xText.is() && xRange.is())
1755 // #i107225# the combined characters need to be inserted first
1756 // the selected text has to be removed afterwards
1757 m_pImpl->m_xText->insertTextContent( xRange->getStart(), xTextContent, sal_True );
1759 if( !xRange->getString().isEmpty() )
1763 uno::Reference< text::XTextCursor > xCrsr = xRange->getText()->createTextCursorByRange( xRange->getStart() );
1764 xCrsr->goLeft( 1, true );
1765 uno::Reference< beans::XPropertySet> xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW );
1766 //the hard properties of the removed text need to be applied to the combined characters field
1767 pStyle->FillPropertySet( xCrsrProperties );
1768 xCrsr->collapseToEnd();
1769 xCrsr->gotoRange( xRange->getEnd(), true );
1770 xCrsr->setString( ::rtl::OUString() );
1772 catch(const uno::Exception&)
1782 // outline level; set after list style has been set
1783 // Complete re-worked and corrected: (#i53198#)
1784 // - set outline level at paragraph
1785 // - set numbering level at paragraph, if none is already set
1786 // - assure that style is marked as an outline style for the corresponding
1787 // outline level.
1788 // - DO NOT set type of numbering rule to outline.
1789 // - DO NOT set numbering rule directly at the paragraph.
1791 // Some minor rework and adjust access to paragraph styles (#i70748#)
1792 if ( bPara )
1794 // Headings not numbered anymore in 3.1 (#i103817#)
1795 sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
1796 const bool bHasOutlineLevelProp(
1797 xPropSetInfo->hasPropertyByName(s_OutlineLevel));
1798 if ( bHasOutlineLevelProp )
1800 xPropSet->getPropertyValue(s_OutlineLevel)
1801 >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
1803 if ( nOutlineLevel > 0 )
1805 if ( bHasOutlineLevelProp )
1807 // In case that the value equals the value of its paragraph style
1808 // attribute outline level, the paragraph attribute value is left unset
1809 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel )
1811 xPropSet->setPropertyValue( s_OutlineLevel,
1812 makeAny( static_cast<sal_Int16>(nOutlineLevel) ) );
1816 // RFE: inserting headings into text documents (#i70748#)
1817 if ( bApplyOutlineLevelAsListLevel )
1819 sal_Int16 nNumLevel = -1;
1820 xPropSet->getPropertyValue( s_NumberingLevel ) >>= nNumLevel;
1821 if ( nNumLevel == -1 ||
1822 nNumLevel != (nOutlineLevel - 1) )
1824 xPropSet->setPropertyValue( s_NumberingLevel,
1825 makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) );
1828 /* Correction: (#i69629#)
1829 - for text document from version OOo 2.0.4/SO 8 PU4 and earlier
1830 the paragraph style of a heading should be assigned to the
1831 corresponding list level of the outline style.
1832 - for other text documents the paragraph style of a heading is only
1833 a candidate for an assignment to the list level of the outline
1834 style, if it has no direct list style property and (if exists) the
1835 automatic paragraph style has also no direct list style set.
1837 if (m_pImpl->m_xParaStyles->hasByName(sStyleName))
1839 bool bOutlineStyleCandidate( false );
1841 sal_Int32 nUPD( 0 );
1842 sal_Int32 nBuild( 0 );
1843 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1844 // Lost outline numbering in master document (#i73509#)
1845 // Check explicitly on certain versions (#i86058#)
1846 if ( rImport.IsTextDocInOOoFileFormat() ||
1847 ( bBuildIdFound &&
1848 ( nUPD == 645 || nUPD == 641 ) ) )
1850 bOutlineStyleCandidate = true;
1852 else if ( nUPD == 680 && nBuild <= 9073 ) /* BuildId of OOo 2.0.4/SO8 PU4 */
1854 bOutlineStyleCandidate = bOutlineLevelAttrFound;
1856 if ( bOutlineStyleCandidate )
1858 AddOutlineStyleCandidate( nOutlineLevel, sStyleName );
1860 // Assure that heading applies the outline style (#i103817#)
1861 if ( ( !pStyle || !pStyle->IsListStyleSet() ) &&
1862 !bOutlineStyleCandidate &&
1863 m_pImpl->m_xChapterNumbering.is())
1865 OUString sEmptyStr;
1866 if ( !lcl_HasListStyle( sStyleName,
1867 m_pImpl->m_xParaStyles, GetXMLImport(),
1868 s_NumberingStyleName,
1869 sEmptyStr ) )
1871 // heading not in a list --> apply outline style
1872 xPropSet->setPropertyValue( s_NumberingRules,
1873 makeAny(m_pImpl->m_xChapterNumbering) );
1874 xPropSet->setPropertyValue( s_NumberingLevel,
1875 makeAny(static_cast<sal_Int8>(nOutlineLevel - 1)));
1880 //handle for text:p,if the paragraphstyle outlinelevel is set to[1~10]
1881 else if( bHasOutlineLevelProp )
1883 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 )
1885 sal_Int16 nZero = 0;
1886 xPropSet->setPropertyValue(s_OutlineLevel,
1887 makeAny( static_cast<sal_Int16>(nZero) ));
1892 return sStyleName;
1895 void XMLTextImportHelper::FindOutlineStyleName( ::rtl::OUString& rStyleName,
1896 sal_Int8 nOutlineLevel )
1898 static ::rtl::OUString s_HeadingStyleName(
1899 "HeadingStyleName");
1901 // style name empty?
1902 if( rStyleName.isEmpty() )
1904 // Empty? Then we need o do stuff. Let's do error checking first.
1905 if (m_pImpl->m_xChapterNumbering.is() &&
1906 ( nOutlineLevel > 0 ) &&
1907 (nOutlineLevel <= m_pImpl->m_xChapterNumbering->getCount()))
1909 nOutlineLevel--; // for the remainder, the level's are 0-based
1911 // empty style name: look-up previously used name
1913 // if we don't have a previously used name, we'll use the default
1914 m_pImpl->InitOutlineStylesCandidates();
1915 if (m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel].empty())
1917 // no other name used previously? Then use default
1919 // iterate over property value sequence to find the style name
1920 Sequence<PropertyValue> aProperties;
1921 m_pImpl->m_xChapterNumbering->getByIndex( nOutlineLevel )
1922 >>= aProperties;
1923 for( sal_Int32 i = 0; i < aProperties.getLength(); i++ )
1925 if (aProperties[i].Name == s_HeadingStyleName)
1927 rtl::OUString aOutlineStyle;
1928 aProperties[i].Value >>= aOutlineStyle;
1929 m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel]
1930 .push_back( aOutlineStyle );
1931 break; // early out, if we found it!.
1936 // finally, we'll use the previously used style name for this
1937 // format (or the default we've just put into that style)
1938 // take last added one (#i71249#)
1939 rStyleName =
1940 m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel].back();
1942 // else: nothing we can do, so we'll leave it empty
1944 // else: we already had a style name, so we let it pass.
1947 void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel,
1948 const OUString& rStyleName )
1950 if (!rStyleName.isEmpty()
1951 && m_pImpl->m_xChapterNumbering.is()
1952 && (nOutlineLevel > 0)
1953 && (nOutlineLevel <= m_pImpl->m_xChapterNumbering->getCount()))
1955 m_pImpl->InitOutlineStylesCandidates();
1956 m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel-1].push_back(
1957 rStyleName);
1961 void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels )
1963 static ::rtl::OUString s_NumberingStyleName( "NumberingStyleName");
1964 static ::rtl::OUString s_HeadingStyleName( "HeadingStyleName");
1966 if ((m_pImpl->m_pOutlineStylesCandidates != NULL || bSetEmptyLevels) &&
1967 m_pImpl->m_xChapterNumbering.is() &&
1968 !IsInsertMode())
1970 bool bChooseLastOne( false );
1972 if ( GetXMLImport().IsTextDocInOOoFileFormat() )
1974 bChooseLastOne = true;
1976 else
1978 sal_Int32 nUPD( 0 );
1979 sal_Int32 nBuild( 0 );
1980 if ( GetXMLImport().getBuildIds( nUPD, nBuild ) )
1982 // check explicitly on certain versions
1983 bChooseLastOne = ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1984 ( nUPD == 680 && nBuild <= 9073 ); // OOo 2.0 - OOo 2.0.4
1989 OUString sOutlineStyleName;
1991 Reference<XPropertySet> xChapterNumRule(
1992 m_pImpl->m_xChapterNumbering, UNO_QUERY);
1993 const OUString sName("Name");
1994 xChapterNumRule->getPropertyValue(sName) >>= sOutlineStyleName;
1997 const sal_Int32 nCount = m_pImpl->m_xChapterNumbering->getCount();
1998 /* First collect all paragraph styles choosen for assignment to each
1999 list level of the outline style, then perform the intrinsic assignment.
2000 Reason: The assignment of a certain paragraph style to a list level
2001 of the outline style causes side effects on the children
2002 paragraph styles in Writer. (#i106218#)
2004 ::std::vector<OUString> sChosenStyles(nCount);
2005 for( sal_Int32 i=0; i < nCount; ++i )
2007 if ( bSetEmptyLevels ||
2008 (m_pImpl->m_pOutlineStylesCandidates &&
2009 !m_pImpl->m_pOutlineStylesCandidates[i].empty()))
2011 // determine, which candidate is one to be assigned to the list
2012 // level of the outline style
2013 if (m_pImpl->m_pOutlineStylesCandidates &&
2014 !m_pImpl->m_pOutlineStylesCandidates[i].empty())
2016 if ( bChooseLastOne )
2018 sChosenStyles[i] =
2019 m_pImpl->m_pOutlineStylesCandidates[i].back();
2021 else
2023 for (sal_uInt32 j = 0;
2024 j < m_pImpl->m_pOutlineStylesCandidates[i].size();
2025 ++j)
2027 if (!lcl_HasListStyle(
2028 m_pImpl->m_pOutlineStylesCandidates[i][j],
2029 m_pImpl->m_xParaStyles, GetXMLImport(),
2030 s_NumberingStyleName,
2031 sOutlineStyleName))
2033 sChosenStyles[i] =
2034 m_pImpl->m_pOutlineStylesCandidates[i][j];
2035 break;
2042 // Trashed outline numbering in ODF 1.1 text document created by OOo 3.x (#i106218#)
2043 Sequence < PropertyValue > aProps( 1 );
2044 PropertyValue *pProps = aProps.getArray();
2045 pProps->Name = s_HeadingStyleName;
2046 for ( sal_Int32 i = 0; i < nCount; ++i )
2048 // Paragraph style assignments in Outline of template lost from second level on (#i107610#)
2049 if ( bSetEmptyLevels || !sChosenStyles[i].isEmpty() )
2051 pProps->Value <<= sChosenStyles[i];
2052 m_pImpl->m_xChapterNumbering->replaceByIndex(i,
2053 makeAny( aProps ));
2059 void XMLTextImportHelper::SetHyperlink(
2060 SvXMLImport& rImport,
2061 const Reference < XTextCursor >& rCursor,
2062 const OUString& rHRef,
2063 const OUString& rName,
2064 const OUString& rTargetFrameName,
2065 const OUString& rStyleName,
2066 const OUString& rVisitedStyleName,
2067 XMLEventsImportContext* pEvents)
2069 static ::rtl::OUString s_HyperLinkURL( "HyperLinkURL");
2070 static ::rtl::OUString s_HyperLinkName( "HyperLinkName");
2071 static ::rtl::OUString s_HyperLinkTarget( "HyperLinkTarget");
2072 static ::rtl::OUString s_UnvisitedCharStyleName( "UnvisitedCharStyleName");
2073 static ::rtl::OUString s_VisitedCharStyleName( "VisitedCharStyleName");
2074 static ::rtl::OUString s_HyperLinkEvents( "HyperLinkEvents");
2076 Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
2077 Reference < XPropertySetInfo > xPropSetInfo(
2078 xPropSet->getPropertySetInfo());
2079 if (!xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
2080 return;
2082 xPropSet->setPropertyValue(s_HyperLinkURL, makeAny(rHRef));
2084 if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
2086 xPropSet->setPropertyValue(s_HyperLinkName, makeAny(rName));
2089 if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
2091 xPropSet->setPropertyValue(s_HyperLinkTarget,
2092 makeAny(rTargetFrameName));
2095 if ( (pEvents != NULL) &&
2096 xPropSetInfo->hasPropertyByName(s_HyperLinkEvents))
2098 // The API treats events at hyperlinks differently from most
2099 // other properties: You have to set a name replace with the
2100 // events in it. The easiest way to to this is to 1) get
2101 // events, 2) set new ones, and 3) then put events back.
2102 uno::Reference<XNameReplace> const xReplace(
2103 xPropSet->getPropertyValue(s_HyperLinkEvents), UNO_QUERY);
2104 if (xReplace.is())
2106 // set events
2107 pEvents->SetEvents(xReplace);
2109 // put events
2110 xPropSet->setPropertyValue(s_HyperLinkEvents, makeAny(xReplace));
2114 if (m_pImpl->m_xTextStyles.is())
2116 OUString sDisplayName(
2117 rImport.GetStyleDisplayName(
2118 XML_STYLE_FAMILY_TEXT_TEXT, rStyleName ) );
2119 if( !sDisplayName.isEmpty() &&
2120 xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) &&
2121 m_pImpl->m_xTextStyles->hasByName(sDisplayName))
2123 xPropSet->setPropertyValue(s_UnvisitedCharStyleName,
2124 makeAny(sDisplayName));
2127 sDisplayName =
2128 rImport.GetStyleDisplayName(
2129 XML_STYLE_FAMILY_TEXT_TEXT, rVisitedStyleName );
2130 if( !sDisplayName.isEmpty() &&
2131 xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) &&
2132 m_pImpl->m_xTextStyles->hasByName(sDisplayName))
2134 xPropSet->setPropertyValue(s_VisitedCharStyleName,
2135 makeAny(sDisplayName));
2140 void XMLTextImportHelper::SetRuby(
2141 SvXMLImport& rImport,
2142 const Reference < XTextCursor >& rCursor,
2143 const OUString& rStyleName,
2144 const OUString& rTextStyleName,
2145 const OUString& rText )
2147 Reference<XPropertySet> xPropSet(rCursor, UNO_QUERY);
2149 OUString sRubyText("RubyText");
2150 OUString sRubyCharStyleName("RubyCharStyleName");
2152 // if we have one Ruby property, we assume all of them are present
2153 if (xPropSet.is() &&
2154 xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText ))
2156 // the ruby text
2157 xPropSet->setPropertyValue(sRubyText, makeAny(rText));
2159 // the ruby style (ruby-adjust)
2160 XMLPropStyleContext *pStyle = 0;
2161 if (!rStyleName.isEmpty() && m_pImpl->m_xAutoStyles.Is())
2163 const SvXMLStyleContext* pTempStyle =
2164 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2165 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_RUBY,
2166 rStyleName, sal_True );
2167 pStyle = PTR_CAST(XMLPropStyleContext,pTempStyle);
2169 if (NULL != pStyle)
2170 pStyle->FillPropertySet( xPropSet );
2173 // the ruby text character style
2174 if (m_pImpl->m_xTextStyles.is())
2176 OUString sDisplayName(
2177 rImport.GetStyleDisplayName(
2178 XML_STYLE_FAMILY_TEXT_TEXT, rTextStyleName ) );
2179 if( (!sDisplayName.isEmpty()) &&
2180 m_pImpl->m_xTextStyles->hasByName( sDisplayName ))
2182 xPropSet->setPropertyValue(sRubyCharStyleName, makeAny(sDisplayName));
2188 void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles )
2190 m_pImpl->m_xAutoStyles = pStyles;
2193 void XMLTextImportHelper::SetFontDecls( XMLFontStylesContext *pFontDecls )
2195 m_pImpl->m_xFontDecls = pFontDecls;
2196 ((XMLTextImportPropertyMapper *)m_pImpl->m_xParaImpPrMap.get())
2197 ->SetFontDecls( pFontDecls );
2198 ((XMLTextImportPropertyMapper *)m_pImpl->m_xTextImpPrMap.get())
2199 ->SetFontDecls( pFontDecls );
2202 const XMLFontStylesContext *XMLTextImportHelper::GetFontDecls() const
2204 return (XMLFontStylesContext *)&m_pImpl->m_xFontDecls;
2207 SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
2208 SvXMLImport& rImport,
2209 sal_uInt16 nPrefix, const OUString& rLocalName,
2210 const Reference< XAttributeList > & xAttrList,
2211 XMLTextType eType )
2213 SvXMLImportContext *pContext = 0;
2215 const SvXMLTokenMap& rTokenMap = GetTextElemTokenMap();
2216 sal_Bool bHeading = sal_False;
2217 sal_Bool bContent = sal_True;
2218 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
2219 switch( nToken )
2221 case XML_TOK_TEXT_H:
2222 bHeading = sal_True;
2223 case XML_TOK_TEXT_P:
2224 pContext = new XMLParaContext( rImport,
2225 nPrefix, rLocalName,
2226 xAttrList, bHeading );
2227 if (m_pImpl->m_bProgress && XML_TEXT_TYPE_SHAPE != eType)
2229 rImport.GetProgressBarHelper()->Increment();
2231 break;
2232 case XML_TOK_TEXT_NUMBERED_PARAGRAPH:
2233 pContext = new XMLNumberedParaContext(
2234 rImport, nPrefix, rLocalName, xAttrList );
2235 break;
2236 case XML_TOK_TEXT_LIST:
2237 pContext = new XMLTextListBlockContext( rImport, *this,
2238 nPrefix, rLocalName,
2239 xAttrList );
2240 break;
2241 case XML_TOK_TABLE_TABLE:
2242 if( XML_TEXT_TYPE_BODY == eType ||
2243 XML_TEXT_TYPE_TEXTBOX == eType ||
2244 XML_TEXT_TYPE_SECTION == eType ||
2245 XML_TEXT_TYPE_HEADER_FOOTER == eType ||
2246 XML_TEXT_TYPE_CHANGED_REGION == eType ||
2247 XML_TEXT_TYPE_CELL == eType )
2248 pContext = CreateTableChildContext( rImport, nPrefix, rLocalName,
2249 xAttrList );
2250 break;
2251 case XML_TOK_TEXT_SEQUENCE_DECLS:
2252 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2253 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2255 pContext = new XMLVariableDeclsImportContext(
2256 rImport, *this, nPrefix, rLocalName, VarTypeSequence);
2257 bContent = sal_False;
2259 break;
2261 case XML_TOK_TEXT_VARFIELD_DECLS:
2262 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2263 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2265 pContext = new XMLVariableDeclsImportContext(
2266 rImport, *this, nPrefix, rLocalName, VarTypeSimple);
2267 bContent = sal_False;
2269 break;
2271 case XML_TOK_TEXT_USERFIELD_DECLS:
2272 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted)||
2273 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2275 pContext = new XMLVariableDeclsImportContext(
2276 rImport, *this, nPrefix, rLocalName, VarTypeUserField);
2277 bContent = sal_False;
2279 break;
2281 case XML_TOK_TEXT_DDE_DECLS:
2282 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2283 XML_TEXT_TYPE_HEADER_FOOTER == eType )
2285 pContext = new XMLDdeFieldDeclsImportContext(
2286 rImport, nPrefix, rLocalName);
2287 bContent = sal_False;
2289 break;
2291 case XML_TOK_TEXT_FRAME_PAGE:
2292 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2293 XML_TEXT_TYPE_TEXTBOX == eType ||
2294 XML_TEXT_TYPE_CHANGED_REGION == eType )
2296 TextContentAnchorType eAnchorType =
2297 XML_TEXT_TYPE_TEXTBOX == eType ? TextContentAnchorType_AT_FRAME
2298 : TextContentAnchorType_AT_PAGE;
2299 pContext = new XMLTextFrameContext( rImport, nPrefix,
2300 rLocalName, xAttrList,
2301 eAnchorType );
2302 bContent = sal_False;
2304 break;
2306 case XML_TOK_DRAW_A_PAGE:
2307 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2308 XML_TEXT_TYPE_TEXTBOX == eType ||
2309 XML_TEXT_TYPE_CHANGED_REGION == eType)
2311 TextContentAnchorType eAnchorType =
2312 XML_TEXT_TYPE_TEXTBOX == eType ? TextContentAnchorType_AT_FRAME
2313 : TextContentAnchorType_AT_PAGE;
2314 pContext = new XMLTextFrameHyperlinkContext( rImport, nPrefix,
2315 rLocalName, xAttrList,
2316 eAnchorType );
2317 bContent = sal_False;
2319 break;
2321 case XML_TOK_TEXT_INDEX_TITLE:
2322 case XML_TOK_TEXT_SECTION:
2323 pContext = new XMLSectionImportContext( rImport, nPrefix, rLocalName );
2324 break;
2326 case XML_TOK_TEXT_TOC:
2327 case XML_TOK_TEXT_OBJECT_INDEX:
2328 case XML_TOK_TEXT_TABLE_INDEX:
2329 case XML_TOK_TEXT_ILLUSTRATION_INDEX:
2330 case XML_TOK_TEXT_USER_INDEX:
2331 case XML_TOK_TEXT_ALPHABETICAL_INDEX:
2332 case XML_TOK_TEXT_BIBLIOGRAPHY_INDEX:
2333 if( XML_TEXT_TYPE_SHAPE != eType )
2334 pContext = new XMLIndexTOCContext( rImport, nPrefix, rLocalName );
2335 break;
2337 case XML_TOK_TEXT_TRACKED_CHANGES:
2338 pContext = new XMLTrackedChangesImportContext( rImport, nPrefix,
2339 rLocalName);
2340 bContent = sal_False;
2341 break;
2343 case XML_TOK_TEXT_CHANGE:
2344 case XML_TOK_TEXT_CHANGE_START:
2345 case XML_TOK_TEXT_CHANGE_END:
2346 pContext = new XMLChangeImportContext(
2347 rImport, nPrefix, rLocalName,
2348 (XML_TOK_TEXT_CHANGE_END != nToken),
2349 (XML_TOK_TEXT_CHANGE_START != nToken),
2350 sal_True);
2351 break;
2353 case XML_TOK_TEXT_FORMS:
2354 pContext = rImport.GetFormImport()->createOfficeFormsContext(rImport, nPrefix, rLocalName);
2355 bContent = sal_False;
2356 break;
2358 case XML_TOK_TEXT_AUTOMARK:
2359 if( XML_TEXT_TYPE_BODY == eType )
2361 pContext = new XMLAutoMarkFileContext(rImport, nPrefix,rLocalName);
2363 bContent = sal_False;
2364 break;
2366 case XML_TOK_TEXT_CALCULATION_SETTINGS:
2367 pContext = new XMLCalculationSettingsContext ( rImport, nPrefix, rLocalName, xAttrList);
2368 bContent = sal_False;
2369 break;
2371 default:
2372 if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) ||
2373 XML_TEXT_TYPE_TEXTBOX == eType ||
2374 XML_TEXT_TYPE_CHANGED_REGION == eType )
2376 Reference < XShapes > xShapes;
2377 pContext = rImport.GetShapeImport()->CreateGroupChildContext(
2378 rImport, nPrefix, rLocalName, xAttrList, xShapes );
2379 bContent = sal_False;
2383 // handle open redlines
2384 if ( (XML_TOK_TEXT_CHANGE != nToken) &&
2385 (XML_TOK_TEXT_CHANGE_END != nToken) &&
2386 (XML_TOK_TEXT_CHANGE_START != nToken) )
2388 // ResetOpenRedlineId();
2391 if( XML_TEXT_TYPE_BODY == eType && bContent )
2393 m_pImpl->m_bBodyContentStarted = sal_False;
2396 return pContext;
2399 SvXMLImportContext *XMLTextImportHelper::CreateTableChildContext(
2400 SvXMLImport&,
2401 sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/,
2402 const Reference< XAttributeList > & )
2404 return 0;
2407 /// get data style key for use with NumberFormat property
2408 sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName,
2409 sal_Bool* pIsSystemLanguage )
2411 const SvXMLStyleContext* pStyle =
2412 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2413 FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE,
2414 sStyleName, sal_True );
2416 // get appropriate context
2419 // first check if its a impress and draw only number format
2420 // this is needed since its also a SvXMLNumFormatContext,
2421 // that was needed to support them for controls in impress/draw also
2422 SdXMLNumberFormatImportContext* pSdNumStyle = PTR_CAST( SdXMLNumberFormatImportContext, pStyle );
2423 if( pSdNumStyle )
2425 return pSdNumStyle->GetDrawKey();
2427 else
2429 SvXMLNumFormatContext* pNumStyle = PTR_CAST( SvXMLNumFormatContext, pStyle );
2430 if( pNumStyle )
2432 if( pIsSystemLanguage != NULL )
2433 *pIsSystemLanguage = pNumStyle->IsSystemLanguage();
2435 // return key
2436 return pNumStyle->GetKey();
2439 return -1;
2442 const SvxXMLListStyleContext *XMLTextImportHelper::FindAutoListStyle( const OUString& rName ) const
2444 const SvxXMLListStyleContext *pStyle = 0;
2445 if (m_pImpl->m_xAutoStyles.Is())
2447 const SvXMLStyleContext* pTempStyle =
2448 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2449 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_LIST, rName,
2450 sal_True );
2451 pStyle = PTR_CAST( SvxXMLListStyleContext ,pTempStyle);
2454 return pStyle;
2457 XMLPropStyleContext *XMLTextImportHelper::FindAutoFrameStyle( const OUString& rName ) const
2459 XMLPropStyleContext *pStyle = 0;
2460 if (m_pImpl->m_xAutoStyles.Is())
2462 const SvXMLStyleContext* pTempStyle =
2463 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2464 FindStyleChildContext( XML_STYLE_FAMILY_SD_GRAPHICS_ID, rName,
2465 sal_True );
2466 pStyle = PTR_CAST( XMLPropStyleContext ,pTempStyle);
2469 return pStyle;
2472 XMLPropStyleContext* XMLTextImportHelper::FindSectionStyle(
2473 const OUString& rName ) const
2475 XMLPropStyleContext* pStyle = NULL;
2476 if (m_pImpl->m_xAutoStyles.Is())
2478 const SvXMLStyleContext* pTempStyle =
2479 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2480 FindStyleChildContext(
2481 XML_STYLE_FAMILY_TEXT_SECTION,
2482 rName, sal_True );
2483 pStyle = PTR_CAST( XMLPropStyleContext,pTempStyle);
2486 return pStyle;
2489 XMLPropStyleContext* XMLTextImportHelper::FindPageMaster(
2490 const OUString& rName ) const
2492 XMLPropStyleContext* pStyle = NULL;
2493 if (m_pImpl->m_xAutoStyles.Is())
2495 const SvXMLStyleContext* pTempStyle =
2496 ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)->
2497 FindStyleChildContext(
2498 XML_STYLE_FAMILY_PAGE_MASTER,
2499 rName, sal_True );
2500 pStyle = PTR_CAST( XMLPropStyleContext,pTempStyle);
2503 return pStyle;
2507 void XMLTextImportHelper::PushListContext(XMLTextListBlockContext *i_pListBlock)
2509 GetTextListHelper().PushListContext(i_pListBlock);
2512 void XMLTextImportHelper::PopListContext()
2514 GetTextListHelper().PopListContext();
2518 const SvXMLTokenMap& XMLTextImportHelper::GetTextNumberedParagraphAttrTokenMap()
2520 if (!m_pImpl->m_pTextNumberedParagraphAttrTokenMap.get())
2522 m_pImpl->m_pTextNumberedParagraphAttrTokenMap.reset(
2523 new SvXMLTokenMap( aTextNumberedParagraphAttrTokenMap ) );
2525 return *m_pImpl->m_pTextNumberedParagraphAttrTokenMap;
2528 const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockAttrTokenMap()
2530 if (!m_pImpl->m_pTextListBlockAttrTokenMap.get())
2532 m_pImpl->m_pTextListBlockAttrTokenMap.reset(
2533 new SvXMLTokenMap( aTextListBlockAttrTokenMap ) );
2535 return *m_pImpl->m_pTextListBlockAttrTokenMap;
2538 const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockElemTokenMap()
2540 if (!m_pImpl->m_pTextListBlockElemTokenMap.get())
2542 m_pImpl->m_pTextListBlockElemTokenMap.reset(
2543 new SvXMLTokenMap( aTextListBlockElemTokenMap ) );
2545 return *m_pImpl->m_pTextListBlockElemTokenMap;
2548 SvI18NMap& XMLTextImportHelper::GetRenameMap()
2550 if (!m_pImpl->m_pRenameMap.get())
2552 m_pImpl->m_pRenameMap.reset( new SvI18NMap() );
2554 return *m_pImpl->m_pRenameMap;
2557 void XMLTextImportHelper::InsertBookmarkStartRange(
2558 const OUString & sName,
2559 const Reference<XTextRange> & rRange,
2560 OUString const& i_rXmlId,
2561 ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & i_rpRDFaAttributes)
2563 m_pImpl->m_BookmarkStartRanges[sName] =
2564 ::boost::make_tuple(rRange, i_rXmlId, i_rpRDFaAttributes);
2565 m_pImpl->m_BookmarkVector.push_back(sName);
2568 sal_Bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange(
2569 const OUString & sName,
2570 Reference<XTextRange> & o_rRange,
2571 OUString & o_rXmlId,
2572 ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes)
2574 if (m_pImpl->m_BookmarkStartRanges.count(sName))
2576 Impl::BookmarkMapEntry_t & rEntry =
2577 (*m_pImpl->m_BookmarkStartRanges.find(sName)).second;
2578 o_rRange.set(rEntry.get<0>());
2579 o_rXmlId = rEntry.get<1>();
2580 o_rpRDFaAttributes = rEntry.get<2>();
2581 m_pImpl->m_BookmarkStartRanges.erase(sName);
2582 Impl::BookmarkVector_t::iterator it(m_pImpl->m_BookmarkVector.begin());
2583 while (it != m_pImpl->m_BookmarkVector.end() && it->compareTo(sName)!=0)
2585 ++it;
2587 if (it!=m_pImpl->m_BookmarkVector.end()) {
2588 m_pImpl->m_BookmarkVector.erase(it);
2590 return sal_True;
2592 else
2594 return sal_False;
2598 ::rtl::OUString XMLTextImportHelper::FindActiveBookmarkName()
2600 if (!m_pImpl->m_BookmarkVector.empty()) {
2601 return m_pImpl->m_BookmarkVector.back();
2602 } else return ::rtl::OUString(); // return the empty string on error...
2605 void XMLTextImportHelper::pushFieldCtx( ::rtl::OUString name, ::rtl::OUString type )
2607 m_pImpl->m_FieldStack.push(Impl::field_stack_item_t(
2608 Impl::field_name_type_t(name, type), Impl::field_params_t()));
2611 void XMLTextImportHelper::popFieldCtx()
2613 if ( !m_pImpl->m_FieldStack.empty() )
2614 m_pImpl->m_FieldStack.pop();
2617 void XMLTextImportHelper::addFieldParam( ::rtl::OUString name, ::rtl::OUString value )
2619 DBG_ASSERT(!m_pImpl->m_FieldStack.empty(),
2620 "stack is empty: not good! Do a pushFieldCtx before...");
2621 if (!m_pImpl->m_FieldStack.empty()) {
2622 Impl::field_stack_item_t & FieldStackItem(m_pImpl->m_FieldStack.top());
2623 FieldStackItem.second.push_back(Impl::field_param_t( name, value ));
2627 ::rtl::OUString XMLTextImportHelper::getCurrentFieldType()
2629 DBG_ASSERT(!m_pImpl->m_FieldStack.empty(),
2630 "stack is empty: not good! Do a pushFieldCtx before...");
2631 if (!m_pImpl->m_FieldStack.empty()) {
2632 return m_pImpl->m_FieldStack.top().first.second;
2633 } else return ::rtl::OUString();
2636 bool XMLTextImportHelper::hasCurrentFieldCtx()
2638 return !m_pImpl->m_FieldStack.empty();
2641 void XMLTextImportHelper::setCurrentFieldParamsTo(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField> &xFormField)
2643 DBG_ASSERT(!m_pImpl->m_FieldStack.empty(),
2644 "stack is empty: not good! Do a pushFieldCtx before...");
2645 if (!m_pImpl->m_FieldStack.empty() && xFormField.is())
2647 FieldParamImporter(&m_pImpl->m_FieldStack.top().second,
2648 xFormField->getParameters()).Import();
2653 void XMLTextImportHelper::ConnectFrameChains(
2654 const OUString& rFrmName,
2655 const OUString& rNextFrmName,
2656 const Reference < XPropertySet >& rFrmPropSet )
2658 static ::rtl::OUString s_ChainNextName( "ChainNextName");
2659 static ::rtl::OUString s_ChainPrevName( "ChainPrevName");
2661 if( rFrmName.isEmpty() )
2662 return;
2664 if( !rNextFrmName.isEmpty() )
2666 OUString sNextFrmName(GetRenameMap().Get( XML_TEXT_RENAME_TYPE_FRAME,
2667 rNextFrmName ));
2668 if (m_pImpl->m_xTextFrames.is()
2669 && m_pImpl->m_xTextFrames->hasByName(sNextFrmName))
2671 rFrmPropSet->setPropertyValue(s_ChainNextName,
2672 makeAny(sNextFrmName));
2674 else
2676 if (!m_pImpl->m_pPrevFrmNames.get())
2678 m_pImpl->m_pPrevFrmNames.reset( new std::vector<rtl::OUString> );
2679 m_pImpl->m_pNextFrmNames.reset( new std::vector<rtl::OUString> );
2681 m_pImpl->m_pPrevFrmNames->push_back(rFrmName);
2682 m_pImpl->m_pNextFrmNames->push_back(sNextFrmName);
2685 if (m_pImpl->m_pPrevFrmNames.get() && !m_pImpl->m_pPrevFrmNames->empty())
2687 for(std::vector<rtl::OUString>::iterator i = m_pImpl->m_pPrevFrmNames->begin(), j = m_pImpl->m_pNextFrmNames->begin(); i != m_pImpl->m_pPrevFrmNames->end() && j != m_pImpl->m_pNextFrmNames->end(); ++i, ++j)
2689 if((*j).equals(rFrmName))
2691 // The previuous frame must exist, because it existing than
2692 // inserting the entry
2693 rFrmPropSet->setPropertyValue(s_ChainPrevName, makeAny(*i));
2695 i = m_pImpl->m_pPrevFrmNames->erase(i);
2696 j = m_pImpl->m_pNextFrmNames->erase(j);
2698 // There cannot be more than one previous frames
2699 break;
2705 sal_Bool XMLTextImportHelper::IsInFrame() const
2707 static ::rtl::OUString s_TextFrame( "TextFrame");
2709 sal_Bool bIsInFrame = sal_False;
2711 // are we currently in a text frame? yes, if the cursor has a
2712 // TextFrame property and it's non-NULL
2713 Reference<XPropertySet> xPropSet(((XMLTextImportHelper *)this)->GetCursor(), UNO_QUERY);
2714 if (xPropSet.is())
2716 if (xPropSet->getPropertySetInfo()->hasPropertyByName(s_TextFrame))
2718 uno::Reference<XTextFrame> const xFrame(
2719 xPropSet->getPropertyValue(s_TextFrame), UNO_QUERY);
2721 if (xFrame.is())
2723 bIsInFrame = sal_True;
2728 return bIsInFrame;
2731 sal_Bool XMLTextImportHelper::IsInHeaderFooter() const
2733 return sal_False;
2736 Reference< XPropertySet> XMLTextImportHelper::createAndInsertOLEObject(
2737 SvXMLImport&,
2738 const OUString& /*rHRef*/,
2739 const OUString& /*rStyleName*/,
2740 const OUString& /*rTblName*/,
2741 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2743 Reference< XPropertySet> xPropSet;
2744 return xPropSet;
2747 Reference< XPropertySet> XMLTextImportHelper::createAndInsertOOoLink(
2748 SvXMLImport&,
2749 const OUString& /*rHRef*/,
2750 const OUString& /*rStyleName*/,
2751 const OUString& /*rTblName*/,
2752 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2754 Reference< XPropertySet> xPropSet;
2755 return xPropSet;
2758 Reference< XPropertySet> XMLTextImportHelper::createAndInsertApplet(
2759 const OUString& /*rCode*/,
2760 const OUString& /*rName*/,
2761 sal_Bool /*bMayScript*/,
2762 const OUString& /*rHRef*/,
2763 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2765 Reference< XPropertySet> xPropSet;
2766 return xPropSet;
2768 Reference< XPropertySet> XMLTextImportHelper::createAndInsertPlugin(
2769 const OUString& /*rMimeType*/,
2770 const OUString& /*rHRef*/,
2771 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2773 Reference< XPropertySet> xPropSet;
2774 return xPropSet;
2776 Reference< XPropertySet> XMLTextImportHelper::createAndInsertFloatingFrame(
2777 const OUString& /*rName*/,
2778 const OUString& /*rHRef*/,
2779 const OUString& /*rStyleName*/,
2780 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2782 Reference< XPropertySet> xPropSet;
2783 return xPropSet;
2786 void XMLTextImportHelper::endAppletOrPlugin(
2787 const Reference < XPropertySet> &,
2788 std::map < const rtl::OUString, rtl::OUString, UStringLess > &)
2791 // redline helper: dummy implementation to be overridden in sw/filter/xml
2792 void XMLTextImportHelper::RedlineAdd(
2793 const OUString& /*rType*/,
2794 const OUString& /*rId*/,
2795 const OUString& /*rAuthor*/,
2796 const OUString& /*rComment*/,
2797 const DateTime& /*rDateTime*/,
2798 sal_Bool /*bMergeLastPara*/)
2800 // dummy implementation: do nothing
2803 Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText(
2804 Reference<XTextCursor> & /*rOldCursor*/,
2805 const OUString& /*rId*/)
2807 // dummy implementation: do nothing
2808 Reference<XTextCursor> xRet;
2809 return xRet;
2812 void XMLTextImportHelper::RedlineSetCursor(
2813 const OUString& /*rId*/,
2814 sal_Bool /*bStart*/,
2815 sal_Bool /*bIsOutsideOfParagraph*/)
2817 // dummy implementation: do nothing
2820 void XMLTextImportHelper::RedlineAdjustStartNodeCursor(sal_Bool)
2822 // dummy implementation: do nothing
2825 void XMLTextImportHelper::SetShowChanges( sal_Bool )
2827 // dummy implementation: do nothing
2830 void XMLTextImportHelper::SetRecordChanges( sal_Bool )
2832 // dummy implementation: do nothing
2834 void XMLTextImportHelper::SetChangesProtectionKey(const Sequence<sal_Int8> &)
2836 // dummy implementation: do nothing
2840 OUString XMLTextImportHelper::GetOpenRedlineId()
2842 return m_pImpl->m_sOpenRedlineIdentifier;
2845 void XMLTextImportHelper::SetOpenRedlineId( ::rtl::OUString& rId)
2847 m_pImpl->m_sOpenRedlineIdentifier = rId;
2850 void XMLTextImportHelper::ResetOpenRedlineId()
2852 OUString sEmpty;
2853 SetOpenRedlineId(sEmpty);
2856 void
2857 XMLTextImportHelper::SetCellParaStyleDefault(::rtl::OUString const& rNewValue)
2859 m_pImpl->m_sCellParaStyleDefault = rNewValue;
2862 ::rtl::OUString const& XMLTextImportHelper::GetCellParaStyleDefault()
2864 return m_pImpl->m_sCellParaStyleDefault;
2867 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */