1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <boost/scoped_array.hpp>
25 #include <com/sun/star/container/XEnumerationAccess.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
29 #include <com/sun/star/text/XTextFramesSupplier.hpp>
30 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
31 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
32 #include <com/sun/star/text/XFormField.hpp>
33 #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
34 #include <xmloff/xmlnmspe.hxx>
35 #include <xmloff/txtstyli.hxx>
36 #include <xmloff/xmlnumi.hxx>
37 #include <xmloff/maptype.hxx>
39 #include "txtparai.hxx"
40 #include <xmloff/txtprmap.hxx>
41 #include <xmloff/txtimppr.hxx>
42 #include <xmloff/xmlimp.hxx>
43 #include "txtvfldi.hxx"
44 #include <xmloff/i18nmap.hxx>
45 #include "XMLTextListItemContext.hxx"
46 #include "XMLTextListBlockContext.hxx"
47 #include "XMLTextFrameContext.hxx"
48 #include "XMLTextFrameHyperlinkContext.hxx"
49 #include "XMLSectionImportContext.hxx"
50 #include "XMLIndexTOCContext.hxx"
51 #include <xmloff/XMLFontStylesContext.hxx>
52 #include <xmloff/XMLEventsImportContext.hxx>
53 #include "XMLTrackedChangesImportContext.hxx"
54 #include "XMLChangeImportContext.hxx"
55 #include "XMLAutoMarkFileContext.hxx"
57 #include "XMLCalculationSettingsContext.hxx"
58 #include "XMLNumberStylesImport.hxx"
59 // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#)
60 #include <com/sun/star/beans/XPropertyState.hpp>
61 #include <txtlists.hxx>
62 #include <xmloff/odffields.hxx>
64 using ::com::sun::star::ucb::XAnyCompare
;
66 using namespace ::std
;
67 using namespace ::com::sun::star
;
68 using namespace ::com::sun::star::uno
;
69 using namespace ::com::sun::star::beans
;
70 using namespace ::com::sun::star::text
;
71 using namespace ::com::sun::star::frame
;
72 using namespace ::com::sun::star::style
;
73 using namespace ::com::sun::star::container
;
74 using namespace ::com::sun::star::drawing
;
75 using namespace ::com::sun::star::xml::sax
;
76 using namespace ::com::sun::star::lang
;
77 using namespace ::xmloff::token
;
78 using namespace ::com::sun::star::ucb
;
80 static const SvXMLTokenMapEntry aTextElemTokenMap
[] =
82 { XML_NAMESPACE_TEXT
, XML_P
, XML_TOK_TEXT_P
},
83 { XML_NAMESPACE_LO_EXT
, XML_P
, XML_TOK_TEXT_P
},
84 { XML_NAMESPACE_TEXT
, XML_H
, XML_TOK_TEXT_H
},
85 { XML_NAMESPACE_TEXT
, XML_LIST
, XML_TOK_TEXT_LIST
},
86 { XML_NAMESPACE_DRAW
, XML_FRAME
, XML_TOK_TEXT_FRAME_PAGE
},
87 { XML_NAMESPACE_DRAW
, XML_A
, XML_TOK_DRAW_A_PAGE
},
88 { XML_NAMESPACE_TABLE
,XML_TABLE
, XML_TOK_TABLE_TABLE
},
89 { XML_NAMESPACE_LO_EXT
,XML_TABLE
, XML_TOK_TABLE_TABLE
},
90 { XML_NAMESPACE_TEXT
, XML_VARIABLE_DECLS
, XML_TOK_TEXT_VARFIELD_DECLS
},
91 { XML_NAMESPACE_TEXT
, XML_USER_FIELD_DECLS
, XML_TOK_TEXT_USERFIELD_DECLS
},
92 { XML_NAMESPACE_TEXT
, XML_SEQUENCE_DECLS
, XML_TOK_TEXT_SEQUENCE_DECLS
},
93 { XML_NAMESPACE_TEXT
, XML_DDE_CONNECTION_DECLS
, XML_TOK_TEXT_DDE_DECLS
},
94 { XML_NAMESPACE_TEXT
, XML_SECTION
, XML_TOK_TEXT_SECTION
},
95 { XML_NAMESPACE_TEXT
, XML_TABLE_OF_CONTENT
, XML_TOK_TEXT_TOC
},
96 { XML_NAMESPACE_TEXT
, XML_OBJECT_INDEX
, XML_TOK_TEXT_OBJECT_INDEX
},
97 { XML_NAMESPACE_TEXT
, XML_TABLE_INDEX
, XML_TOK_TEXT_TABLE_INDEX
},
98 { XML_NAMESPACE_TEXT
, XML_ILLUSTRATION_INDEX
, XML_TOK_TEXT_ILLUSTRATION_INDEX
},
99 { XML_NAMESPACE_TEXT
, XML_USER_INDEX
, XML_TOK_TEXT_USER_INDEX
},
100 { XML_NAMESPACE_TEXT
, XML_ALPHABETICAL_INDEX
, XML_TOK_TEXT_ALPHABETICAL_INDEX
},
101 { XML_NAMESPACE_TEXT
, XML_BIBLIOGRAPHY
, XML_TOK_TEXT_BIBLIOGRAPHY_INDEX
},
102 { XML_NAMESPACE_TEXT
, XML_INDEX_TITLE
, XML_TOK_TEXT_INDEX_TITLE
},
103 { XML_NAMESPACE_TEXT
, XML_TRACKED_CHANGES
, XML_TOK_TEXT_TRACKED_CHANGES
},
104 { XML_NAMESPACE_TEXT
, XML_CHANGE_START
, XML_TOK_TEXT_CHANGE_START
},
105 { XML_NAMESPACE_TEXT
, XML_CHANGE_END
, XML_TOK_TEXT_CHANGE_END
},
106 { XML_NAMESPACE_TEXT
, XML_CHANGE
, XML_TOK_TEXT_CHANGE
},
107 { XML_NAMESPACE_OFFICE
, XML_FORMS
, XML_TOK_TEXT_FORMS
},
108 { XML_NAMESPACE_TABLE
, XML_CALCULATION_SETTINGS
, XML_TOK_TEXT_CALCULATION_SETTINGS
},
109 { XML_NAMESPACE_TEXT
, XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE
, XML_TOK_TEXT_AUTOMARK
},
111 { XML_NAMESPACE_TEXT
, XML_NUMBERED_PARAGRAPH
, XML_TOK_TEXT_NUMBERED_PARAGRAPH
},
116 static const SvXMLTokenMapEntry aTextPElemTokenMap
[] =
118 { XML_NAMESPACE_TEXT
, XML_SPAN
, XML_TOK_TEXT_SPAN
},
119 { XML_NAMESPACE_TEXT
, XML_TAB
, XML_TOK_TEXT_TAB_STOP
},
120 { XML_NAMESPACE_TEXT
, XML_LINE_BREAK
, XML_TOK_TEXT_LINE_BREAK
},
121 { XML_NAMESPACE_TEXT
, XML_SOFT_PAGE_BREAK
, XML_TOK_TEXT_SOFT_PAGE_BREAK
},
122 { XML_NAMESPACE_TEXT
, XML_S
, XML_TOK_TEXT_S
},
123 { XML_NAMESPACE_TEXT
, XML_A
, XML_TOK_TEXT_HYPERLINK
},
124 { XML_NAMESPACE_TEXT
, XML_RUBY
, XML_TOK_TEXT_RUBY
},
126 { XML_NAMESPACE_TEXT
, XML_NOTE
, XML_TOK_TEXT_NOTE
},
127 { XML_NAMESPACE_TEXT
, XML_BOOKMARK
, XML_TOK_TEXT_BOOKMARK
},
128 { XML_NAMESPACE_TEXT
, XML_BOOKMARK_START
, XML_TOK_TEXT_BOOKMARK_START
},
129 { XML_NAMESPACE_TEXT
, XML_BOOKMARK_END
, XML_TOK_TEXT_BOOKMARK_END
},
130 { XML_NAMESPACE_TEXT
, XML_REFERENCE_MARK
, XML_TOK_TEXT_REFERENCE
},
131 { XML_NAMESPACE_TEXT
, XML_REFERENCE_MARK_START
,
132 XML_TOK_TEXT_REFERENCE_START
},
133 { XML_NAMESPACE_TEXT
, XML_REFERENCE_MARK_END
,
134 XML_TOK_TEXT_REFERENCE_END
},
136 { XML_NAMESPACE_DRAW
, XML_FRAME
, XML_TOK_TEXT_FRAME
},
137 { XML_NAMESPACE_DRAW
, XML_A
, XML_TOK_DRAW_A
},
140 { XML_NAMESPACE_TEXT
, XML_TOC_MARK
, XML_TOK_TEXT_TOC_MARK
},
141 { XML_NAMESPACE_TEXT
, XML_TOC_MARK_START
, XML_TOK_TEXT_TOC_MARK_START
},
142 { XML_NAMESPACE_TEXT
, XML_TOC_MARK_END
, XML_TOK_TEXT_TOC_MARK_END
},
143 { XML_NAMESPACE_TEXT
, XML_USER_INDEX_MARK
, XML_TOK_TEXT_USER_INDEX_MARK
},
144 { XML_NAMESPACE_TEXT
, XML_USER_INDEX_MARK_START
,
145 XML_TOK_TEXT_USER_INDEX_MARK_START
},
146 { XML_NAMESPACE_TEXT
, XML_USER_INDEX_MARK_END
,
147 XML_TOK_TEXT_USER_INDEX_MARK_END
},
148 { XML_NAMESPACE_TEXT
, XML_ALPHABETICAL_INDEX_MARK
,
149 XML_TOK_TEXT_ALPHA_INDEX_MARK
},
150 { XML_NAMESPACE_TEXT
, XML_ALPHABETICAL_INDEX_MARK_START
,
151 XML_TOK_TEXT_ALPHA_INDEX_MARK_START
},
152 { XML_NAMESPACE_TEXT
, XML_ALPHABETICAL_INDEX_MARK_END
,
153 XML_TOK_TEXT_ALPHA_INDEX_MARK_END
},
156 { XML_NAMESPACE_TEXT
, XML_SENDER_FIRSTNAME
,XML_TOK_TEXT_SENDER_FIRSTNAME
},
157 { XML_NAMESPACE_TEXT
, XML_SENDER_LASTNAME
, XML_TOK_TEXT_SENDER_LASTNAME
},
158 { XML_NAMESPACE_LO_EXT
, XML_SENDER_INITIALS
, XML_TOK_TEXT_SENDER_INITIALS
},
159 { XML_NAMESPACE_TEXT
, XML_SENDER_INITIALS
, XML_TOK_TEXT_SENDER_INITIALS
},
160 { XML_NAMESPACE_TEXT
, XML_SENDER_TITLE
, XML_TOK_TEXT_SENDER_TITLE
},
161 { XML_NAMESPACE_TEXT
, XML_SENDER_POSITION
, XML_TOK_TEXT_SENDER_POSITION
},
162 { XML_NAMESPACE_TEXT
, XML_SENDER_EMAIL
, XML_TOK_TEXT_SENDER_EMAIL
},
163 { XML_NAMESPACE_TEXT
, XML_SENDER_PHONE_PRIVATE
,
164 XML_TOK_TEXT_SENDER_PHONE_PRIVATE
},
165 { XML_NAMESPACE_TEXT
, XML_SENDER_FAX
, XML_TOK_TEXT_SENDER_FAX
},
166 { XML_NAMESPACE_TEXT
, XML_SENDER_COMPANY
, XML_TOK_TEXT_SENDER_COMPANY
},
167 { XML_NAMESPACE_TEXT
, XML_SENDER_PHONE_WORK
,
168 XML_TOK_TEXT_SENDER_PHONE_WORK
},
169 { XML_NAMESPACE_TEXT
, XML_SENDER_STREET
, XML_TOK_TEXT_SENDER_STREET
},
170 { XML_NAMESPACE_TEXT
, XML_SENDER_CITY
, XML_TOK_TEXT_SENDER_CITY
},
171 { XML_NAMESPACE_TEXT
, XML_SENDER_POSTAL_CODE
,
172 XML_TOK_TEXT_SENDER_POSTAL_CODE
},
173 { XML_NAMESPACE_TEXT
, XML_SENDER_COUNTRY
, XML_TOK_TEXT_SENDER_COUNTRY
},
174 { XML_NAMESPACE_TEXT
, XML_SENDER_STATE_OR_PROVINCE
,
175 XML_TOK_TEXT_SENDER_STATE_OR_PROVINCE
},
177 // misc. document fields
178 { XML_NAMESPACE_TEXT
, XML_AUTHOR_NAME
, XML_TOK_TEXT_AUTHOR_NAME
},
179 { XML_NAMESPACE_TEXT
, XML_AUTHOR_INITIALS
, XML_TOK_TEXT_AUTHOR_INITIALS
},
180 { XML_NAMESPACE_TEXT
, XML_DATE
, XML_TOK_TEXT_DATE
},
181 { XML_NAMESPACE_TEXT
, XML_TIME
, XML_TOK_TEXT_TIME
},
182 { XML_NAMESPACE_TEXT
, XML_PAGE_NUMBER
, XML_TOK_TEXT_PAGE_NUMBER
},
183 { XML_NAMESPACE_TEXT
, XML_PAGE_CONTINUATION_STRING
,
184 XML_TOK_TEXT_PAGE_CONTINUATION_STRING
},
187 { XML_NAMESPACE_TEXT
, XML_VARIABLE_SET
, XML_TOK_TEXT_VARIABLE_SET
},
188 { XML_NAMESPACE_TEXT
, XML_VARIABLE_GET
, XML_TOK_TEXT_VARIABLE_GET
},
189 { XML_NAMESPACE_TEXT
, XML_VARIABLE_INPUT
, XML_TOK_TEXT_VARIABLE_INPUT
},
190 { XML_NAMESPACE_TEXT
, XML_USER_FIELD_GET
, XML_TOK_TEXT_USER_FIELD_GET
},
191 { XML_NAMESPACE_TEXT
, XML_USER_FIELD_INPUT
,XML_TOK_TEXT_USER_FIELD_INPUT
},
192 { XML_NAMESPACE_TEXT
, XML_SEQUENCE
, XML_TOK_TEXT_SEQUENCE
},
193 { XML_NAMESPACE_TEXT
, XML_EXPRESSION
, XML_TOK_TEXT_EXPRESSION
},
194 { XML_NAMESPACE_TEXT
, XML_TEXT_INPUT
, XML_TOK_TEXT_TEXT_INPUT
},
197 { XML_NAMESPACE_TEXT
, XML_DATABASE_DISPLAY
,
198 XML_TOK_TEXT_DATABASE_DISPLAY
},
199 { XML_NAMESPACE_TEXT
, XML_DATABASE_NEXT
,
200 XML_TOK_TEXT_DATABASE_NEXT
},
201 { XML_NAMESPACE_TEXT
, XML_DATABASE_ROW_SELECT
,
202 XML_TOK_TEXT_DATABASE_SELECT
},
203 { XML_NAMESPACE_TEXT
, XML_DATABASE_ROW_NUMBER
,
204 XML_TOK_TEXT_DATABASE_ROW_NUMBER
},
205 { XML_NAMESPACE_TEXT
, XML_DATABASE_NAME
, XML_TOK_TEXT_DATABASE_NAME
},
208 { XML_NAMESPACE_TEXT
, XML_INITIAL_CREATOR
,
209 XML_TOK_TEXT_DOCUMENT_CREATION_AUTHOR
},
210 { XML_NAMESPACE_TEXT
, XML_DESCRIPTION
, XML_TOK_TEXT_DOCUMENT_DESCRIPTION
},
211 { XML_NAMESPACE_TEXT
, XML_PRINTED_BY
, XML_TOK_TEXT_DOCUMENT_PRINT_AUTHOR
},
212 { XML_NAMESPACE_TEXT
, XML_TITLE
, XML_TOK_TEXT_DOCUMENT_TITLE
},
213 { XML_NAMESPACE_TEXT
, XML_SUBJECT
, XML_TOK_TEXT_DOCUMENT_SUBJECT
},
214 { XML_NAMESPACE_TEXT
, XML_KEYWORDS
, XML_TOK_TEXT_DOCUMENT_KEYWORDS
},
215 { XML_NAMESPACE_TEXT
, XML_CREATOR
, XML_TOK_TEXT_DOCUMENT_SAVE_AUTHOR
},
216 { XML_NAMESPACE_TEXT
, XML_EDITING_CYCLES
,
217 XML_TOK_TEXT_DOCUMENT_REVISION
},
218 { XML_NAMESPACE_TEXT
, XML_CREATION_DATE
,
219 XML_TOK_TEXT_DOCUMENT_CREATION_DATE
},
220 { XML_NAMESPACE_TEXT
, XML_CREATION_TIME
,
221 XML_TOK_TEXT_DOCUMENT_CREATION_TIME
},
222 { XML_NAMESPACE_TEXT
, XML_PRINT_DATE
, XML_TOK_TEXT_DOCUMENT_PRINT_DATE
},
223 { XML_NAMESPACE_TEXT
, XML_PRINT_TIME
, XML_TOK_TEXT_DOCUMENT_PRINT_TIME
},
224 { XML_NAMESPACE_TEXT
, XML_MODIFICATION_DATE
,
225 XML_TOK_TEXT_DOCUMENT_SAVE_DATE
},
226 { XML_NAMESPACE_TEXT
, XML_MODIFICATION_TIME
,
227 XML_TOK_TEXT_DOCUMENT_SAVE_TIME
},
228 { XML_NAMESPACE_TEXT
, XML_EDITING_DURATION
,
229 XML_TOK_TEXT_DOCUMENT_EDIT_DURATION
},
230 { XML_NAMESPACE_TEXT
, XML_USER_DEFINED
,
231 XML_TOK_TEXT_DOCUMENT_USER_DEFINED
},
234 { XML_NAMESPACE_TEXT
, XML_PLACEHOLDER
, XML_TOK_TEXT_PLACEHOLDER
},
235 { XML_NAMESPACE_TEXT
, XML_HIDDEN_TEXT
, XML_TOK_TEXT_HIDDEN_TEXT
},
236 { XML_NAMESPACE_TEXT
, XML_HIDDEN_PARAGRAPH
,
237 XML_TOK_TEXT_HIDDEN_PARAGRAPH
},
238 { XML_NAMESPACE_TEXT
, XML_CONDITIONAL_TEXT
,
239 XML_TOK_TEXT_CONDITIONAL_TEXT
},
240 { XML_NAMESPACE_TEXT
, XML_FILE_NAME
, XML_TOK_TEXT_FILENAME
},
241 { XML_NAMESPACE_TEXT
, XML_CHAPTER
, XML_TOK_TEXT_CHAPTER
},
242 { XML_NAMESPACE_TEXT
, XML_TEMPLATE_NAME
, XML_TOK_TEXT_TEMPLATENAME
},
243 { XML_NAMESPACE_TEXT
, XML_PARAGRAPH_COUNT
, XML_TOK_TEXT_PARAGRAPH_COUNT
},
244 { XML_NAMESPACE_TEXT
, XML_WORD_COUNT
, XML_TOK_TEXT_WORD_COUNT
},
245 { XML_NAMESPACE_TEXT
, XML_TABLE_COUNT
, XML_TOK_TEXT_TABLE_COUNT
},
246 { XML_NAMESPACE_TEXT
, XML_CHARACTER_COUNT
, XML_TOK_TEXT_CHARACTER_COUNT
},
247 { XML_NAMESPACE_TEXT
, XML_IMAGE_COUNT
, XML_TOK_TEXT_IMAGE_COUNT
},
248 { XML_NAMESPACE_TEXT
, XML_OBJECT_COUNT
, XML_TOK_TEXT_OBJECT_COUNT
},
249 { XML_NAMESPACE_TEXT
, XML_PAGE_COUNT
, XML_TOK_TEXT_PAGE_COUNT
},
250 { XML_NAMESPACE_TEXT
, XML_PAGE_VARIABLE_GET
, XML_TOK_TEXT_GET_PAGE_VAR
},
251 { XML_NAMESPACE_TEXT
, XML_PAGE_VARIABLE_SET
, XML_TOK_TEXT_SET_PAGE_VAR
},
252 { XML_NAMESPACE_TEXT
, XML_EXECUTE_MACRO
, XML_TOK_TEXT_MACRO
},
253 { XML_NAMESPACE_TEXT
, XML_DDE_CONNECTION
, XML_TOK_TEXT_DDE
},
254 { XML_NAMESPACE_TEXT
, XML_REFERENCE_REF
, XML_TOK_TEXT_REFERENCE_REF
},
255 { XML_NAMESPACE_TEXT
, XML_BOOKMARK_REF
, XML_TOK_TEXT_BOOKMARK_REF
},
256 { XML_NAMESPACE_TEXT
, XML_SEQUENCE_REF
, XML_TOK_TEXT_SEQUENCE_REF
},
257 { XML_NAMESPACE_TEXT
, XML_NOTE_REF
, XML_TOK_TEXT_NOTE_REF
},
258 { XML_NAMESPACE_TEXT
, XML_BIBLIOGRAPHY_MARK
,
259 XML_TOK_TEXT_BIBLIOGRAPHY_MARK
},
260 { XML_NAMESPACE_OFFICE
, XML_ANNOTATION
, XML_TOK_TEXT_ANNOTATION
},
261 { XML_NAMESPACE_OFFICE
, XML_ANNOTATION_END
, XML_TOK_TEXT_ANNOTATION_END
},
262 { XML_NAMESPACE_TEXT
, XML_SCRIPT
, XML_TOK_TEXT_SCRIPT
},
263 { XML_NAMESPACE_TEXT
, XML_TABLE_FORMULA
, XML_TOK_TEXT_TABLE_FORMULA
},
264 { XML_NAMESPACE_TEXT
, XML_DROP_DOWN
, XML_TOK_TEXT_DROP_DOWN
},
267 { XML_NAMESPACE_TEXT
, XML_SHEET_NAME
, XML_TOK_TEXT_SHEET_NAME
},
270 { XML_NAMESPACE_TEXT
, XML_MEASURE
, XML_TOK_TEXT_MEASURE
},
271 { XML_NAMESPACE_LO_EXT
, XML_PAGE_NAME
, XML_TOK_TEXT_PAGE_NAME
},
272 { XML_NAMESPACE_TEXT
, XML_PAGE_NAME
, XML_TOK_TEXT_PAGE_NAME
},
275 { XML_NAMESPACE_TEXT
, XML_META
, XML_TOK_TEXT_META
},
276 { XML_NAMESPACE_TEXT
, XML_META_FIELD
, XML_TOK_TEXT_META_FIELD
},
278 // redlining (aka change tracking)
279 { XML_NAMESPACE_TEXT
, XML_CHANGE_START
, XML_TOK_TEXTP_CHANGE_START
},
280 { XML_NAMESPACE_TEXT
, XML_CHANGE_END
, XML_TOK_TEXTP_CHANGE_END
},
281 { XML_NAMESPACE_TEXT
, XML_CHANGE
, XML_TOK_TEXTP_CHANGE
},
283 { XML_NAMESPACE_PRESENTATION
, XML_HEADER
, XML_TOK_DRAW_HEADER
},
284 { XML_NAMESPACE_PRESENTATION
, XML_FOOTER
, XML_TOK_DRAW_FOOTER
},
285 { XML_NAMESPACE_PRESENTATION
, XML_DATE_TIME
, XML_TOK_DRAW_DATE_TIME
},
286 { XML_NAMESPACE_TEXT
, XML_PAGE_CONTINUATION
, XML_TOK_TEXT_PAGE_CONTINUATION
},
288 { XML_NAMESPACE_FIELD
, XML_FIELDMARK
, XML_TOK_TEXT_FIELDMARK
},
289 { XML_NAMESPACE_FIELD
, XML_FIELDMARK_START
, XML_TOK_TEXT_FIELDMARK_START
},
290 { XML_NAMESPACE_FIELD
, XML_FIELDMARK_END
, XML_TOK_TEXT_FIELDMARK_END
},
296 static const SvXMLTokenMapEntry aTextPAttrTokenMap
[] =
298 { XML_NAMESPACE_XML
, XML_ID
, XML_TOK_TEXT_P_XMLID
},
299 { XML_NAMESPACE_XHTML
, XML_ABOUT
, XML_TOK_TEXT_P_ABOUT
},
300 { XML_NAMESPACE_XHTML
, XML_PROPERTY
, XML_TOK_TEXT_P_PROPERTY
},
301 { XML_NAMESPACE_XHTML
, XML_CONTENT
, XML_TOK_TEXT_P_CONTENT
},
302 { XML_NAMESPACE_XHTML
, XML_DATATYPE
, XML_TOK_TEXT_P_DATATYPE
},
303 { XML_NAMESPACE_TEXT
, XML_ID
, XML_TOK_TEXT_P_TEXTID
},
304 { XML_NAMESPACE_TEXT
, XML_STYLE_NAME
, XML_TOK_TEXT_P_STYLE_NAME
},
305 { XML_NAMESPACE_TEXT
, XML_COND_STYLE_NAME
,
306 XML_TOK_TEXT_P_COND_STYLE_NAME
},
307 { XML_NAMESPACE_TEXT
, XML_OUTLINE_LEVEL
,XML_TOK_TEXT_P_LEVEL
},
308 { XML_NAMESPACE_TEXT
, XML_IS_LIST_HEADER
,XML_TOK_TEXT_P_IS_LIST_HEADER
},
309 { XML_NAMESPACE_TEXT
, XML_RESTART_NUMBERING
,XML_TOK_TEXT_P_RESTART_NUMBERING
},
310 { XML_NAMESPACE_TEXT
, XML_START_VALUE
,XML_TOK_TEXT_P_START_VALUE
},
314 static const SvXMLTokenMapEntry aTextNumberedParagraphAttrTokenMap
[] =
316 { XML_NAMESPACE_XML
, XML_ID
, XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID
},
317 { XML_NAMESPACE_TEXT
, XML_LIST_ID
,
318 XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID
},
319 { XML_NAMESPACE_TEXT
, XML_LEVEL
, XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL
},
320 { XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
321 XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME
},
322 { XML_NAMESPACE_TEXT
, XML_CONTINUE_NUMBERING
,
323 XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING
},
324 { XML_NAMESPACE_TEXT
, XML_START_VALUE
,
325 XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE
},
329 static const SvXMLTokenMapEntry aTextListBlockAttrTokenMap
[] =
331 { XML_NAMESPACE_XML
, XML_ID
, XML_TOK_TEXT_LIST_BLOCK_XMLID
},
332 { XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
333 XML_TOK_TEXT_LIST_BLOCK_STYLE_NAME
},
334 { XML_NAMESPACE_TEXT
, XML_CONTINUE_NUMBERING
,
335 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_NUMBERING
},
336 { XML_NAMESPACE_TEXT
, XML_CONTINUE_LIST
,
337 XML_TOK_TEXT_LIST_BLOCK_CONTINUE_LIST
},
341 static const SvXMLTokenMapEntry aTextListBlockElemTokenMap
[] =
343 { XML_NAMESPACE_TEXT
, XML_LIST_HEADER
, XML_TOK_TEXT_LIST_HEADER
},
344 { XML_NAMESPACE_TEXT
, XML_LIST_ITEM
, XML_TOK_TEXT_LIST_ITEM
},
348 static const SvXMLTokenMapEntry aTextFrameAttrTokenMap
[] =
350 { XML_NAMESPACE_DRAW
, XML_STYLE_NAME
, XML_TOK_TEXT_FRAME_STYLE_NAME
},
351 { XML_NAMESPACE_DRAW
, XML_NAME
, XML_TOK_TEXT_FRAME_NAME
},
352 { XML_NAMESPACE_TEXT
, XML_ANCHOR_TYPE
, XML_TOK_TEXT_FRAME_ANCHOR_TYPE
},
353 { XML_NAMESPACE_TEXT
, XML_ANCHOR_PAGE_NUMBER
, XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER
},
354 { XML_NAMESPACE_SVG
, XML_X
, XML_TOK_TEXT_FRAME_X
},
355 { XML_NAMESPACE_SVG
, XML_Y
, XML_TOK_TEXT_FRAME_Y
},
356 { XML_NAMESPACE_SVG
, XML_WIDTH
, XML_TOK_TEXT_FRAME_WIDTH
},
357 { XML_NAMESPACE_FO
, XML_MIN_WIDTH
, XML_TOK_TEXT_FRAME_MIN_WIDTH
},
358 { XML_NAMESPACE_STYLE
, XML_REL_WIDTH
, XML_TOK_TEXT_FRAME_REL_WIDTH
},
359 { XML_NAMESPACE_SVG
, XML_HEIGHT
, XML_TOK_TEXT_FRAME_HEIGHT
},
360 { XML_NAMESPACE_FO
, XML_MIN_HEIGHT
, XML_TOK_TEXT_FRAME_MIN_HEIGHT
},
361 { XML_NAMESPACE_STYLE
, XML_REL_HEIGHT
, XML_TOK_TEXT_FRAME_REL_HEIGHT
},
362 { XML_NAMESPACE_DRAW
, XML_CHAIN_NEXT_NAME
, XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME
},
363 { XML_NAMESPACE_XLINK
, XML_HREF
, XML_TOK_TEXT_FRAME_HREF
},
364 { XML_NAMESPACE_DRAW
, XML_NAME
, XML_TOK_TEXT_FRAME_FILTER_NAME
},
365 { XML_NAMESPACE_DRAW
, XML_ZINDEX
, XML_TOK_TEXT_FRAME_Z_INDEX
},
366 { XML_NAMESPACE_SVG
, XML_TRANSFORM
, XML_TOK_TEXT_FRAME_TRANSFORM
},
367 { XML_NAMESPACE_DRAW
, XML_CLASS_ID
, XML_TOK_TEXT_FRAME_CLASS_ID
},
368 { XML_NAMESPACE_DRAW
, XML_CODE
, XML_TOK_TEXT_FRAME_CODE
},
369 { XML_NAMESPACE_DRAW
, XML_OBJECT
, XML_TOK_TEXT_FRAME_OBJECT
},
370 { XML_NAMESPACE_DRAW
, XML_ARCHIVE
, XML_TOK_TEXT_FRAME_ARCHIVE
},
371 { XML_NAMESPACE_DRAW
, XML_MAY_SCRIPT
, XML_TOK_TEXT_FRAME_MAY_SCRIPT
},
372 { XML_NAMESPACE_DRAW
, XML_MIME_TYPE
, XML_TOK_TEXT_FRAME_MIME_TYPE
},
373 { XML_NAMESPACE_DRAW
, XML_APPLET_NAME
, XML_TOK_TEXT_FRAME_APPLET_NAME
},
374 { XML_NAMESPACE_DRAW
, XML_FRAME_NAME
, XML_TOK_TEXT_FRAME_FRAME_NAME
},
375 { XML_NAMESPACE_DRAW
, XML_NOTIFY_ON_UPDATE_OF_RANGES
, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE
},
376 { XML_NAMESPACE_DRAW
, XML_NOTIFY_ON_UPDATE_OF_TABLE
, XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE
},
380 static const SvXMLTokenMapEntry aTextContourAttrTokenMap
[] =
382 { XML_NAMESPACE_SVG
, XML_WIDTH
, XML_TOK_TEXT_CONTOUR_WIDTH
},
383 { XML_NAMESPACE_SVG
, XML_HEIGHT
, XML_TOK_TEXT_CONTOUR_HEIGHT
},
384 { XML_NAMESPACE_SVG
, XML_VIEWBOX
, XML_TOK_TEXT_CONTOUR_VIEWBOX
},
385 { XML_NAMESPACE_SVG
, XML_D
, XML_TOK_TEXT_CONTOUR_D
},
386 { XML_NAMESPACE_DRAW
,XML_POINTS
, XML_TOK_TEXT_CONTOUR_POINTS
},
387 { XML_NAMESPACE_DRAW
,XML_RECREATE_ON_EDIT
, XML_TOK_TEXT_CONTOUR_AUTO
},
391 static const SvXMLTokenMapEntry aTextHyperlinkAttrTokenMap
[] =
393 { XML_NAMESPACE_XLINK
, XML_HREF
, XML_TOK_TEXT_HYPERLINK_HREF
},
394 { XML_NAMESPACE_OFFICE
, XML_NAME
, XML_TOK_TEXT_HYPERLINK_NAME
},
395 { XML_NAMESPACE_XLINK
, XML_SHOW
, XML_TOK_TEXT_HYPERLINK_SHOW
},
396 { XML_NAMESPACE_OFFICE
, XML_TARGET_FRAME_NAME
, XML_TOK_TEXT_HYPERLINK_TARGET_FRAME
},
397 { XML_NAMESPACE_TEXT
, XML_STYLE_NAME
, XML_TOK_TEXT_HYPERLINK_STYLE_NAME
},
398 { XML_NAMESPACE_TEXT
, XML_VISITED_STYLE_NAME
, XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME
},
399 { XML_NAMESPACE_OFFICE
, XML_SERVER_MAP
, XML_TOK_TEXT_HYPERLINK_SERVER_MAP
},
403 static const SvXMLTokenMapEntry aTextMasterPageElemTokenMap
[] =
405 { XML_NAMESPACE_STYLE
, XML_HEADER
, XML_TOK_TEXT_MP_HEADER
},
406 { XML_NAMESPACE_STYLE
, XML_FOOTER
, XML_TOK_TEXT_MP_FOOTER
},
407 { XML_NAMESPACE_STYLE
, XML_HEADER_LEFT
, XML_TOK_TEXT_MP_HEADER_LEFT
},
408 { XML_NAMESPACE_STYLE
, XML_FOOTER_LEFT
, XML_TOK_TEXT_MP_FOOTER_LEFT
},
409 { XML_NAMESPACE_STYLE
, XML_HEADER_FIRST
, XML_TOK_TEXT_MP_HEADER_FIRST
},
410 { XML_NAMESPACE_STYLE
, XML_FOOTER_FIRST
, XML_TOK_TEXT_MP_FOOTER_FIRST
},
415 static const SvXMLTokenMapEntry aTextFieldAttrTokenMap
[] =
417 { XML_NAMESPACE_TEXT
, XML_FIXED
, XML_TOK_TEXTFIELD_FIXED
},
418 { XML_NAMESPACE_TEXT
, XML_DESCRIPTION
, XML_TOK_TEXTFIELD_DESCRIPTION
},
419 { XML_NAMESPACE_TEXT
, XML_HELP
, XML_TOK_TEXTFIELD_HELP
},
420 { XML_NAMESPACE_TEXT
, XML_HINT
, XML_TOK_TEXTFIELD_HINT
},
421 { XML_NAMESPACE_TEXT
, XML_PLACEHOLDER_TYPE
,
422 XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE
},
423 { XML_NAMESPACE_TEXT
, XML_NAME
, XML_TOK_TEXTFIELD_NAME
},
424 { XML_NAMESPACE_TEXT
, XML_FORMULA
, XML_TOK_TEXTFIELD_FORMULA
},
425 { XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
, XML_TOK_TEXTFIELD_NUM_FORMAT
},
426 { XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
,
427 XML_TOK_TEXTFIELD_NUM_LETTER_SYNC
},
428 { XML_NAMESPACE_TEXT
, XML_DISPLAY_FORMULA
,
429 XML_TOK_TEXTFIELD_DISPLAY_FORMULA
},
430 { XML_NAMESPACE_TEXT
, XML_VALUE_TYPE
, XML_TOK_TEXTFIELD_VALUE_TYPE
}, // #i32362#: src680m48++ saves text:value-type
431 { XML_NAMESPACE_OFFICE
, XML_VALUE_TYPE
, XML_TOK_TEXTFIELD_VALUE_TYPE
},
432 { XML_NAMESPACE_TEXT
, XML_VALUE
, XML_TOK_TEXTFIELD_VALUE
},
433 { XML_NAMESPACE_OFFICE
, XML_VALUE
, XML_TOK_TEXTFIELD_VALUE
},
434 { XML_NAMESPACE_TEXT
, XML_STRING_VALUE
, XML_TOK_TEXTFIELD_STRING_VALUE
},
435 { XML_NAMESPACE_OFFICE
, XML_STRING_VALUE
, XML_TOK_TEXTFIELD_STRING_VALUE
},
436 { XML_NAMESPACE_TEXT
, XML_DATE_VALUE
, XML_TOK_TEXTFIELD_DATE_VALUE
},
437 { XML_NAMESPACE_OFFICE
, XML_DATE_VALUE
, XML_TOK_TEXTFIELD_DATE_VALUE
},
438 { XML_NAMESPACE_TEXT
, XML_TIME_VALUE
, XML_TOK_TEXTFIELD_TIME_VALUE
},
439 { XML_NAMESPACE_OFFICE
, XML_TIME_VALUE
, XML_TOK_TEXTFIELD_TIME_VALUE
},
440 { XML_NAMESPACE_OFFICE
, XML_BOOLEAN_VALUE
, XML_TOK_TEXTFIELD_BOOL_VALUE
},
441 { XML_NAMESPACE_OFFICE
, XML_CURRENCY
, XML_TOK_TEXTFIELD_CURRENCY
},
442 { XML_NAMESPACE_STYLE
, XML_DATA_STYLE_NAME
,
443 XML_TOK_TEXTFIELD_DATA_STYLE_NAME
},
444 { XML_NAMESPACE_TEXT
, XML_DISPLAY_OUTLINE_LEVEL
,
445 XML_TOK_TEXTFIELD_NUMBERING_LEVEL
},
446 { XML_NAMESPACE_TEXT
, XML_SEPARATION_CHARACTER
,
447 XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR
},
448 { XML_NAMESPACE_TEXT
, XML_DISPLAY
, XML_TOK_TEXTFIELD_DISPLAY
},
449 { XML_NAMESPACE_TEXT
, XML_TIME_ADJUST
, XML_TOK_TEXTFIELD_TIME_ADJUST
},
450 { XML_NAMESPACE_TEXT
, XML_DATE_ADJUST
, XML_TOK_TEXTFIELD_DATE_ADJUST
},
451 { XML_NAMESPACE_TEXT
, XML_PAGE_ADJUST
, XML_TOK_TEXTFIELD_PAGE_ADJUST
},
452 { XML_NAMESPACE_TEXT
, XML_SELECT_PAGE
, XML_TOK_TEXTFIELD_SELECT_PAGE
},
453 { XML_NAMESPACE_TEXT
, XML_DATABASE_NAME
, XML_TOK_TEXTFIELD_DATABASE_NAME
},
454 { XML_NAMESPACE_TEXT
, XML_TABLE_NAME
, XML_TOK_TEXTFIELD_TABLE_NAME
},
455 { XML_NAMESPACE_TEXT
, XML_COLUMN_NAME
, XML_TOK_TEXTFIELD_COLUMN_NAME
},
456 { XML_NAMESPACE_TEXT
, XML_ROW_NUMBER
, XML_TOK_TEXTFIELD_ROW_NUMBER
},
457 { XML_NAMESPACE_TEXT
, XML_CONDITION
, XML_TOK_TEXTFIELD_CONDITION
},
458 { XML_NAMESPACE_TEXT
, XML_STRING_VALUE_IF_TRUE
,
459 XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE
},
460 { XML_NAMESPACE_TEXT
, XML_STRING_VALUE_IF_FALSE
,
461 XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE
},
462 { XML_NAMESPACE_TEXT
, XML_EDITING_CYCLES
, XML_TOK_TEXTFIELD_REVISION
},
463 { XML_NAMESPACE_TEXT
, XML_OUTLINE_LEVEL
, XML_TOK_TEXTFIELD_OUTLINE_LEVEL
},
464 { XML_NAMESPACE_TEXT
, XML_ACTIVE
, XML_TOK_TEXTFIELD_ACTIVE
},
465 { XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
, XML_TOK_TEXTFIELD_NOTE_CLASS
},
466 { XML_NAMESPACE_TEXT
, XML_REFERENCE_FORMAT
,
467 XML_TOK_TEXTFIELD_REFERENCE_FORMAT
},
468 { XML_NAMESPACE_TEXT
, XML_REF_NAME
, XML_TOK_TEXTFIELD_REF_NAME
},
469 { XML_NAMESPACE_TEXT
, XML_CONNECTION_NAME
,
470 XML_TOK_TEXTFIELD_CONNECTION_NAME
},
471 { XML_NAMESPACE_XLINK
, XML_HREF
, XML_TOK_TEXTFIELD_HREF
},
472 { XML_NAMESPACE_OFFICE
, XML_TARGET_FRAME_NAME
,
473 XML_TOK_TEXTFIELD_TARGET_FRAME
},
474 { XML_NAMESPACE_TEXT
, XML_ANNOTATION
, XML_TOK_TEXTFIELD_ANNOTATION
},
475 { XML_NAMESPACE_SCRIPT
, XML_LANGUAGE
, XML_TOK_TEXTFIELD_LANGUAGE
},
476 { XML_NAMESPACE_TEXT
, XML_KIND
, XML_TOK_TEXTFIELD_MEASURE_KIND
},
477 { XML_NAMESPACE_TEXT
, XML_IS_HIDDEN
, XML_TOK_TEXTFIELD_IS_HIDDEN
},
478 { XML_NAMESPACE_TEXT
, XML_CURRENT_VALUE
,
479 XML_TOK_TEXTFIELD_CURRENT_VALUE
},
480 { XML_NAMESPACE_TEXT
, XML_TABLE_TYPE
, XML_TOK_TEXTFIELD_TABLE_TYPE
},
481 { XML_NAMESPACE_OFFICE
, XML_NAME
, XML_TOK_TEXT_NAME
},
487 // maximum allowed length of combined characters field
488 #define MAX_COMBINED_CHARACTERS 6
490 struct XMLTextImportHelper::Impl
491 : private ::boost::noncopyable
493 std::unique_ptr
<SvXMLTokenMap
> m_xTextElemTokenMap
;
494 std::unique_ptr
<SvXMLTokenMap
> m_xTextPElemTokenMap
;
495 std::unique_ptr
<SvXMLTokenMap
> m_xTextPAttrTokenMap
;
496 std::unique_ptr
<SvXMLTokenMap
> m_xTextFieldAttrTokenMap
;
497 std::unique_ptr
<SvXMLTokenMap
> m_xTextNumberedParagraphAttrTokenMap
;
498 std::unique_ptr
<SvXMLTokenMap
> m_xTextListBlockAttrTokenMap
;
499 std::unique_ptr
<SvXMLTokenMap
> m_xTextListBlockElemTokenMap
;
500 std::unique_ptr
<SvXMLTokenMap
> m_xTextFrameAttrTokenMap
;
501 std::unique_ptr
<SvXMLTokenMap
> m_xTextContourAttrTokenMap
;
502 std::unique_ptr
<SvXMLTokenMap
> m_xTextHyperlinkAttrTokenMap
;
503 std::unique_ptr
<SvXMLTokenMap
> m_xTextMasterPageElemTokenMap
;
504 std::unique_ptr
< std::vector
<OUString
> > m_xPrevFrmNames
;
505 std::unique_ptr
< std::vector
<OUString
> > m_xNextFrmNames
;
506 std::unique_ptr
<XMLTextListsHelper
> m_xTextListsHelper
;
508 SvXMLImportContextRef m_xAutoStyles
;
509 SvXMLImportContextRef m_xFontDecls
;
511 rtl::Reference
< SvXMLImportPropertyMapper
> m_xParaImpPrMap
;
512 rtl::Reference
< SvXMLImportPropertyMapper
> m_xTextImpPrMap
;
513 rtl::Reference
< SvXMLImportPropertyMapper
> m_xFrameImpPrMap
;
514 rtl::Reference
< SvXMLImportPropertyMapper
> m_xSectionImpPrMap
;
515 rtl::Reference
< SvXMLImportPropertyMapper
> m_xRubyImpPrMap
;
517 std::unique_ptr
<SvI18NMap
> m_xRenameMap
;
519 /* Change and extend data structure:
520 - data structure contains candidates of paragraph styles, which
521 will be assigned to the outline style
522 - data structure contains more than one candidate for each list level
523 of the outline style (#i69629#)
525 ::boost::scoped_array
< ::std::vector
< OUString
> >
526 m_xOutlineStylesCandidates
;
528 // start range, xml:id, RDFa stuff
529 typedef ::boost::tuple
<
530 uno::Reference
<text::XTextRange
>, OUString
,
531 std::shared_ptr
< ::xmloff::ParsedRDFaAttributes
> >
533 /// start ranges for open bookmarks
534 ::std::map
< OUString
, BookmarkMapEntry_t
> m_BookmarkStartRanges
;
536 typedef ::std::vector
< OUString
> BookmarkVector_t
;
537 BookmarkVector_t m_BookmarkVector
;
539 /// name of the last 'open' redline that started between paragraphs
540 OUString m_sOpenRedlineIdentifier
;
542 uno::Reference
<text::XText
> m_xText
;
543 uno::Reference
<text::XTextCursor
> m_xCursor
;
544 uno::Reference
<text::XTextRange
> m_xCursorAsRange
;
545 uno::Reference
<container::XNameContainer
> m_xParaStyles
;
546 uno::Reference
<container::XNameContainer
> m_xTextStyles
;
547 uno::Reference
<container::XNameContainer
> m_xNumStyles
;
548 uno::Reference
<container::XNameContainer
> m_xFrameStyles
;
549 uno::Reference
<container::XNameContainer
> m_xPageStyles
;
550 uno::Reference
<container::XIndexReplace
> m_xChapterNumbering
;
551 uno::Reference
<container::XNameAccess
> m_xTextFrames
;
552 uno::Reference
<container::XNameAccess
> m_xGraphics
;
553 uno::Reference
<container::XNameAccess
> m_xObjects
;
554 uno::Reference
<lang::XMultiServiceFactory
> m_xServiceFactory
;
556 SvXMLImport
& m_rSvXMLImport
;
558 bool m_bInsertMode
: 1;
559 bool m_bStylesOnlyMode
: 1;
560 bool m_bBlockMode
: 1;
561 bool m_bProgress
: 1;
562 bool m_bOrganizerMode
: 1;
563 bool m_bBodyContentStarted
: 1;
566 /// Are we inside a <text:deletion> element (deleted redline section)
567 bool m_bInsideDeleteContext
: 1;
569 typedef ::std::pair
< OUString
, OUString
> field_name_type_t
;
570 typedef ::std::pair
< OUString
, OUString
> field_param_t
;
571 typedef ::std::vector
< field_param_t
> field_params_t
;
572 typedef ::std::pair
< field_name_type_t
, field_params_t
> field_stack_item_t
;
573 typedef ::std::stack
< field_stack_item_t
> field_stack_t
;
575 field_stack_t m_FieldStack
;
577 OUString m_sCellParaStyleDefault
;
579 Impl( uno::Reference
<frame::XModel
> const& rModel
,
580 SvXMLImport
& rImport
,
581 bool const bInsertMode
, bool const bStylesOnlyMode
,
582 bool const bProgress
, bool const bBlockMode
,
583 bool const bOrganizerMode
)
584 : m_xTextListsHelper( new XMLTextListsHelper() )
585 // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#)
586 , m_xServiceFactory( rModel
, UNO_QUERY
)
587 , m_rSvXMLImport( rImport
)
588 , m_bInsertMode( bInsertMode
)
589 , m_bStylesOnlyMode( bStylesOnlyMode
)
590 , m_bBlockMode( bBlockMode
)
591 , m_bProgress( bProgress
)
592 , m_bOrganizerMode( bOrganizerMode
)
593 , m_bBodyContentStarted( true )
594 , m_bInsideDeleteContext( false )
598 void InitOutlineStylesCandidates()
600 if (!m_xOutlineStylesCandidates
)
602 size_t const size(m_xChapterNumbering
->getCount());
603 m_xOutlineStylesCandidates
.reset(
604 new ::std::vector
< OUString
>[size
] );
611 uno::Reference
< text::XText
> & XMLTextImportHelper::GetText()
613 return m_xImpl
->m_xText
;
616 uno::Reference
< text::XTextCursor
> & XMLTextImportHelper::GetCursor()
618 return m_xImpl
->m_xCursor
;
621 uno::Reference
< text::XTextRange
> & XMLTextImportHelper::GetCursorAsRange()
623 return m_xImpl
->m_xCursorAsRange
;
626 bool XMLTextImportHelper::IsInsertMode() const
628 return m_xImpl
->m_bInsertMode
;
631 bool XMLTextImportHelper::IsStylesOnlyMode() const
633 return m_xImpl
->m_bStylesOnlyMode
;
636 bool XMLTextImportHelper::IsBlockMode() const
638 return m_xImpl
->m_bBlockMode
;
641 bool XMLTextImportHelper::IsOrganizerMode() const
643 return m_xImpl
->m_bOrganizerMode
;
646 bool XMLTextImportHelper::IsProgress() const
648 return m_xImpl
->m_bProgress
;
651 uno::Reference
<container::XNameContainer
> const&
652 XMLTextImportHelper::GetParaStyles() const
654 return m_xImpl
->m_xParaStyles
;
657 uno::Reference
<container::XNameContainer
> const&
658 XMLTextImportHelper::GetTextStyles() const
660 return m_xImpl
->m_xTextStyles
;
663 uno::Reference
<container::XNameContainer
> const&
664 XMLTextImportHelper::GetNumberingStyles() const
666 return m_xImpl
->m_xNumStyles
;
669 uno::Reference
<container::XNameContainer
> const&
670 XMLTextImportHelper::GetFrameStyles() const
672 return m_xImpl
->m_xFrameStyles
;
675 uno::Reference
<container::XNameContainer
> const&
676 XMLTextImportHelper::GetPageStyles() const
678 return m_xImpl
->m_xPageStyles
;
681 uno::Reference
<container::XIndexReplace
> const&
682 XMLTextImportHelper::GetChapterNumbering() const
684 return m_xImpl
->m_xChapterNumbering
;
687 rtl::Reference
< SvXMLImportPropertyMapper
> const&
688 XMLTextImportHelper::GetParaImportPropertySetMapper() const
690 return m_xImpl
->m_xParaImpPrMap
;
693 rtl::Reference
< SvXMLImportPropertyMapper
> const&
694 XMLTextImportHelper::GetTextImportPropertySetMapper() const
696 return m_xImpl
->m_xTextImpPrMap
;
699 rtl::Reference
< SvXMLImportPropertyMapper
> const&
700 XMLTextImportHelper::GetSectionImportPropertySetMapper() const
702 return m_xImpl
->m_xSectionImpPrMap
;
705 rtl::Reference
< SvXMLImportPropertyMapper
> const&
706 XMLTextImportHelper::GetRubyImportPropertySetMapper() const
708 return m_xImpl
->m_xRubyImpPrMap
;
711 void XMLTextImportHelper::SetInsideDeleteContext(bool const bNew
)
713 m_xImpl
->m_bInsideDeleteContext
= bNew
;
716 bool XMLTextImportHelper::IsInsideDeleteContext() const
718 return m_xImpl
->m_bInsideDeleteContext
;
721 SvXMLImport
& XMLTextImportHelper::GetXMLImport()
723 return m_xImpl
->m_rSvXMLImport
;
726 XMLTextListsHelper
& XMLTextImportHelper::GetTextListHelper()
728 return *m_xImpl
->m_xTextListsHelper
;
731 const SvXMLTokenMap
& XMLTextImportHelper::GetTextElemTokenMap()
733 if (!m_xImpl
->m_xTextElemTokenMap
.get())
735 m_xImpl
->m_xTextElemTokenMap
.reset(
736 new SvXMLTokenMap( aTextElemTokenMap
));
738 return *m_xImpl
->m_xTextElemTokenMap
;
741 const SvXMLTokenMap
& XMLTextImportHelper::GetTextPElemTokenMap()
743 if (!m_xImpl
->m_xTextPElemTokenMap
.get())
745 m_xImpl
->m_xTextPElemTokenMap
.reset(
746 new SvXMLTokenMap( aTextPElemTokenMap
));
748 return *m_xImpl
->m_xTextPElemTokenMap
;
751 const SvXMLTokenMap
& XMLTextImportHelper::GetTextPAttrTokenMap()
753 if (!m_xImpl
->m_xTextPAttrTokenMap
.get())
755 m_xImpl
->m_xTextPAttrTokenMap
.reset(
756 new SvXMLTokenMap( aTextPAttrTokenMap
));
758 return *m_xImpl
->m_xTextPAttrTokenMap
;
761 const SvXMLTokenMap
& XMLTextImportHelper::GetTextFrameAttrTokenMap()
763 if (!m_xImpl
->m_xTextFrameAttrTokenMap
.get())
765 m_xImpl
->m_xTextFrameAttrTokenMap
.reset(
766 new SvXMLTokenMap( aTextFrameAttrTokenMap
));
768 return *m_xImpl
->m_xTextFrameAttrTokenMap
;
771 const SvXMLTokenMap
& XMLTextImportHelper::GetTextContourAttrTokenMap()
773 if (!m_xImpl
->m_xTextContourAttrTokenMap
.get())
775 m_xImpl
->m_xTextContourAttrTokenMap
.reset(
776 new SvXMLTokenMap( aTextContourAttrTokenMap
));
778 return *m_xImpl
->m_xTextContourAttrTokenMap
;
781 const SvXMLTokenMap
& XMLTextImportHelper::GetTextHyperlinkAttrTokenMap()
783 if (!m_xImpl
->m_xTextHyperlinkAttrTokenMap
.get())
785 m_xImpl
->m_xTextHyperlinkAttrTokenMap
.reset(
786 new SvXMLTokenMap( aTextHyperlinkAttrTokenMap
));
788 return *m_xImpl
->m_xTextHyperlinkAttrTokenMap
;
791 const SvXMLTokenMap
& XMLTextImportHelper::GetTextMasterPageElemTokenMap()
793 if (!m_xImpl
->m_xTextMasterPageElemTokenMap
.get())
795 m_xImpl
->m_xTextMasterPageElemTokenMap
.reset(
796 new SvXMLTokenMap( aTextMasterPageElemTokenMap
));
798 return *m_xImpl
->m_xTextMasterPageElemTokenMap
;
801 const SvXMLTokenMap
& XMLTextImportHelper::GetTextFieldAttrTokenMap()
803 if (!m_xImpl
->m_xTextFieldAttrTokenMap
.get())
805 m_xImpl
->m_xTextFieldAttrTokenMap
.reset(
806 new SvXMLTokenMap( aTextFieldAttrTokenMap
));
808 return *m_xImpl
->m_xTextFieldAttrTokenMap
;
814 class FieldParamImporter
817 typedef pair
<OUString
,OUString
> field_param_t
;
818 typedef vector
<field_param_t
> field_params_t
;
819 FieldParamImporter(const field_params_t
* const pInParams
, Reference
<XNameContainer
> xOutParams
)
820 : m_pInParams(pInParams
)
821 , m_xOutParams(xOutParams
)
826 const field_params_t
* const m_pInParams
;
827 Reference
<XNameContainer
> m_xOutParams
;
830 void FieldParamImporter::Import()
832 ::std::vector
<OUString
> vListEntries
;
833 ::std::map
<OUString
, Any
> vOutParams
;
834 for(field_params_t::const_iterator pCurrent
= m_pInParams
->begin();
835 pCurrent
!= m_pInParams
->end();
838 if(pCurrent
->first
== ODF_FORMDROPDOWN_RESULT
)
841 vOutParams
[pCurrent
->first
] = makeAny(pCurrent
->second
.toInt32());
843 else if(pCurrent
->first
== ODF_FORMCHECKBOX_RESULT
)
846 vOutParams
[pCurrent
->first
] = makeAny(pCurrent
->second
.toBoolean());
848 else if(pCurrent
->first
== ODF_FORMDROPDOWN_LISTENTRY
)
851 vListEntries
.push_back(pCurrent
->second
);
854 vOutParams
[pCurrent
->first
] = makeAny(pCurrent
->second
);
856 if(!vListEntries
.empty())
858 Sequence
<OUString
> vListEntriesSeq(vListEntries
.size());
859 copy(vListEntries
.begin(), vListEntries
.end(), vListEntriesSeq
.begin());
860 vOutParams
[OUString(ODF_FORMDROPDOWN_LISTENTRY
)] = makeAny(vListEntriesSeq
);
862 for(::std::map
<OUString
, Any
>::const_iterator pCurrent
= vOutParams
.begin();
863 pCurrent
!= vOutParams
.end();
868 m_xOutParams
->insertByName(pCurrent
->first
, pCurrent
->second
);
870 catch(const ElementExistException
&)
877 XMLTextImportHelper::XMLTextImportHelper(
878 uno::Reference
<frame::XModel
> const& rModel
,
879 SvXMLImport
& rImport
,
880 bool const bInsertMode
, bool const bStylesOnlyMode
,
881 bool const bProgress
, bool const bBlockMode
,
882 bool const bOrganizerMode
)
883 : m_xImpl( new Impl(rModel
, rImport
, bInsertMode
, bStylesOnlyMode
,
884 bProgress
, bBlockMode
, bOrganizerMode
) )
885 , m_xBackpatcherImpl( MakeBackpatcherImpl() )
887 static const char s_PropNameDefaultListId
[] = "DefaultListId";
889 Reference
< XChapterNumberingSupplier
> xCNSupplier( rModel
, UNO_QUERY
);
891 if (xCNSupplier
.is())
893 // note: m_xChapterNumbering is accessed to import some fields
894 m_xImpl
->m_xChapterNumbering
= xCNSupplier
->getChapterNumberingRules();
895 // the AutoCorrect document doesn't have a proper outline numbering
896 if (!IsBlockMode() && m_xImpl
->m_xChapterNumbering
.is())
898 Reference
< XPropertySet
> const xNumRuleProps(
899 m_xImpl
->m_xChapterNumbering
, UNO_QUERY
);
900 if ( xNumRuleProps
.is() )
902 Reference
< XPropertySetInfo
> xNumRulePropSetInfo(
903 xNumRuleProps
->getPropertySetInfo());
904 if (xNumRulePropSetInfo
.is() &&
905 xNumRulePropSetInfo
->hasPropertyByName(
906 s_PropNameDefaultListId
))
909 xNumRuleProps
->getPropertyValue(s_PropNameDefaultListId
)
911 assert( !sListId
.isEmpty() &&
912 "no default list id found at chapter numbering rules instance. Serious defect -> please inform OD." );
913 if ( !sListId
.isEmpty() )
915 Reference
< XNamed
> const xChapterNumNamed(
916 m_xImpl
->m_xChapterNumbering
, UNO_QUERY
);
917 if ( xChapterNumNamed
.is() )
919 m_xImpl
->m_xTextListsHelper
->KeepListAsProcessed(
921 xChapterNumNamed
->getName(),
930 Reference
< XStyleFamiliesSupplier
> xFamiliesSupp( rModel
, UNO_QUERY
);
931 // DBG_ASSERT( xFamiliesSupp.is(), "no chapter numbering supplier" ); for clipboard there may be documents without styles
933 if( xFamiliesSupp
.is() )
935 Reference
< XNameAccess
> xFamilies(xFamiliesSupp
->getStyleFamilies());
937 const OUString
aParaStyles("ParagraphStyles");
938 if( xFamilies
->hasByName( aParaStyles
) )
940 m_xImpl
->m_xParaStyles
.set(xFamilies
->getByName(aParaStyles
),
944 const OUString
aCharStyles("CharacterStyles");
945 if( xFamilies
->hasByName( aCharStyles
) )
947 m_xImpl
->m_xTextStyles
.set(xFamilies
->getByName(aCharStyles
),
951 const OUString
aNumStyles("NumberingStyles");
952 if( xFamilies
->hasByName( aNumStyles
) )
954 m_xImpl
->m_xNumStyles
.set(xFamilies
->getByName(aNumStyles
),
958 const OUString
aFrameStyles("FrameStyles");
959 if( xFamilies
->hasByName( aFrameStyles
) )
961 m_xImpl
->m_xFrameStyles
.set(xFamilies
->getByName(aFrameStyles
),
965 const OUString
aPageStyles("PageStyles");
966 if( xFamilies
->hasByName( aPageStyles
) )
968 m_xImpl
->m_xPageStyles
.set(xFamilies
->getByName(aPageStyles
),
973 Reference
< XTextFramesSupplier
> xTFS( rModel
, UNO_QUERY
);
976 m_xImpl
->m_xTextFrames
.set(xTFS
->getTextFrames());
979 Reference
< XTextGraphicObjectsSupplier
> xTGOS( rModel
, UNO_QUERY
);
982 m_xImpl
->m_xGraphics
.set(xTGOS
->getGraphicObjects());
985 Reference
< XTextEmbeddedObjectsSupplier
> xTEOS( rModel
, UNO_QUERY
);
988 m_xImpl
->m_xObjects
.set(xTEOS
->getEmbeddedObjects());
991 XMLPropertySetMapper
*pPropMapper
=
992 new XMLTextPropertySetMapper( TextPropMap::PARA
, false );
993 m_xImpl
->m_xParaImpPrMap
=
994 new XMLTextImportPropertyMapper( pPropMapper
, rImport
);
996 pPropMapper
= new XMLTextPropertySetMapper( TextPropMap::TEXT
, false );
997 m_xImpl
->m_xTextImpPrMap
=
998 new XMLTextImportPropertyMapper( pPropMapper
, rImport
);
1000 pPropMapper
= new XMLTextPropertySetMapper( TextPropMap::FRAME
, false );
1001 m_xImpl
->m_xFrameImpPrMap
=
1002 new XMLTextImportPropertyMapper( pPropMapper
, rImport
);
1004 pPropMapper
= new XMLTextPropertySetMapper( TextPropMap::SECTION
, false );
1005 m_xImpl
->m_xSectionImpPrMap
=
1006 new XMLTextImportPropertyMapper( pPropMapper
, rImport
);
1008 pPropMapper
= new XMLTextPropertySetMapper( TextPropMap::RUBY
, false );
1009 m_xImpl
->m_xRubyImpPrMap
=
1010 new SvXMLImportPropertyMapper( pPropMapper
, rImport
);
1013 XMLTextImportHelper::~XMLTextImportHelper()
1017 SvXMLImportPropertyMapper
*XMLTextImportHelper::CreateShapeExtPropMapper(SvXMLImport
& rImport
)
1019 XMLPropertySetMapper
*pPropMapper
=
1020 new XMLTextPropertySetMapper( TextPropMap::FRAME
, false );
1021 return new XMLTextImportPropertyMapper( pPropMapper
, rImport
);
1024 SvXMLImportPropertyMapper
*XMLTextImportHelper::CreateParaExtPropMapper(SvXMLImport
& rImport
)
1026 XMLPropertySetMapper
*pPropMapper
=
1027 new XMLTextPropertySetMapper( TextPropMap::SHAPE_PARA
, false );
1028 return new XMLTextImportPropertyMapper( pPropMapper
, rImport
);
1031 SvXMLImportPropertyMapper
*XMLTextImportHelper::CreateParaDefaultExtPropMapper(SvXMLImport
& rImport
)
1033 XMLPropertySetMapper
* pPropMapper
=
1034 new XMLTextPropertySetMapper( TextPropMap::SHAPE_PARA
, false );
1035 SvXMLImportPropertyMapper
* pImportMapper
= new XMLTextImportPropertyMapper( pPropMapper
, rImport
);
1038 new XMLTextPropertySetMapper( TextPropMap::TEXT_ADDITIONAL_DEFAULTS
, false );
1039 pImportMapper
->ChainImportMapper( new XMLTextImportPropertyMapper( pPropMapper
, rImport
) );
1041 return pImportMapper
;
1044 SvXMLImportPropertyMapper
*
1045 XMLTextImportHelper::CreateTableDefaultExtPropMapper(
1046 SvXMLImport
& rImport
)
1048 XMLPropertySetMapper
*pPropMapper
=
1049 new XMLTextPropertySetMapper( TextPropMap::TABLE_DEFAULTS
, false );
1050 return new SvXMLImportPropertyMapper( pPropMapper
, rImport
);
1053 SvXMLImportPropertyMapper
*
1054 XMLTextImportHelper::CreateTableRowDefaultExtPropMapper(
1055 SvXMLImport
& rImport
)
1057 XMLPropertySetMapper
*pPropMapper
=
1058 new XMLTextPropertySetMapper( TextPropMap::TABLE_ROW_DEFAULTS
, false );
1059 return new SvXMLImportPropertyMapper( pPropMapper
, rImport
);
1062 void XMLTextImportHelper::SetCursor( const Reference
< XTextCursor
> & rCursor
)
1064 m_xImpl
->m_xCursor
.set(rCursor
);
1065 m_xImpl
->m_xText
.set(rCursor
->getText());
1066 m_xImpl
->m_xCursorAsRange
.set( rCursor
, UNO_QUERY
);
1069 void XMLTextImportHelper::ResetCursor()
1071 m_xImpl
->m_xCursor
.set(0);
1072 m_xImpl
->m_xText
.set(0);
1073 m_xImpl
->m_xCursorAsRange
.set(0);
1077 bool XMLTextImportHelper::HasFrameByName( const OUString
& rName
) const
1079 return (m_xImpl
->m_xTextFrames
.is() &&
1080 m_xImpl
->m_xTextFrames
->hasByName(rName
))
1081 || (m_xImpl
->m_xGraphics
.is() &&
1082 m_xImpl
->m_xGraphics
->hasByName(rName
))
1083 || (m_xImpl
->m_xObjects
.is() &&
1084 m_xImpl
->m_xObjects
->hasByName(rName
));
1087 void XMLTextImportHelper::InsertString( const OUString
& rChars
)
1089 assert(m_xImpl
->m_xText
.is());
1090 assert(m_xImpl
->m_xCursorAsRange
.is());
1091 if (m_xImpl
->m_xText
.is())
1093 m_xImpl
->m_xText
->insertString(m_xImpl
->m_xCursorAsRange
,
1098 void XMLTextImportHelper::InsertString( const OUString
& rChars
,
1099 bool& rIgnoreLeadingSpace
)
1101 assert(m_xImpl
->m_xText
.is());
1102 assert(m_xImpl
->m_xCursorAsRange
.is());
1103 if (m_xImpl
->m_xText
.is())
1105 sal_Int32 nLen
= rChars
.getLength();
1106 OUStringBuffer
sChars( nLen
);
1108 for( sal_Int32 i
=0; i
< nLen
; i
++ )
1110 sal_Unicode c
= rChars
[i
];
1117 if( !rIgnoreLeadingSpace
)
1118 sChars
.append( (sal_Unicode
)0x20 );
1119 rIgnoreLeadingSpace
= true;
1122 rIgnoreLeadingSpace
= false;
1127 m_xImpl
->m_xText
->insertString(m_xImpl
->m_xCursorAsRange
,
1128 sChars
.makeStringAndClear(), sal_False
);
1132 void XMLTextImportHelper::InsertControlCharacter( sal_Int16 nControl
)
1134 assert(m_xImpl
->m_xText
.is());
1135 assert(m_xImpl
->m_xCursorAsRange
.is());
1136 if (m_xImpl
->m_xText
.is())
1138 m_xImpl
->m_xText
->insertControlCharacter(
1139 m_xImpl
->m_xCursorAsRange
, nControl
, sal_False
);
1143 void XMLTextImportHelper::InsertTextContent(
1144 Reference
< XTextContent
> & xContent
)
1146 assert(m_xImpl
->m_xText
.is());
1147 assert(m_xImpl
->m_xCursorAsRange
.is());
1148 if (m_xImpl
->m_xText
.is())
1150 // note: this may throw IllegalArgumentException and callers handle it
1151 m_xImpl
->m_xText
->insertTextContent( m_xImpl
->m_xCursorAsRange
, xContent
, sal_False
);
1155 void XMLTextImportHelper::DeleteParagraph()
1157 assert(m_xImpl
->m_xText
.is());
1158 assert(m_xImpl
->m_xCursor
.is());
1159 assert(m_xImpl
->m_xCursorAsRange
.is());
1161 bool bDelete
= true;
1162 Reference
< XEnumerationAccess
> const xEnumAccess(
1163 m_xImpl
->m_xCursor
, UNO_QUERY
);
1164 if( xEnumAccess
.is() )
1166 Reference
< XEnumeration
> xEnum(xEnumAccess
->createEnumeration());
1167 SAL_WARN_IF(!xEnum
->hasMoreElements(), "xmloff.text",
1168 "empty text enumeration");
1169 if( xEnum
->hasMoreElements() )
1171 Reference
< XComponent
> xComp( xEnum
->nextElement(), UNO_QUERY
);
1182 if (m_xImpl
->m_xCursor
->goLeft( 1, sal_True
))
1185 m_xImpl
->m_xText
->insertString(m_xImpl
->m_xCursorAsRange
,
1191 OUString
XMLTextImportHelper::ConvertStarFonts( const OUString
& rChars
,
1192 const OUString
& rStyleName
,
1195 SvXMLImport
& rImport
) const
1197 OUStringBuffer
sChars( rChars
);
1198 bool bConverted
= false;
1199 for( sal_Int32 j
=0; j
<rChars
.getLength(); j
++ )
1201 sal_Unicode c
= rChars
[j
];
1202 if( c
>= 0xf000 && c
<= 0xf0ff )
1204 if( (rFlags
& CONV_STAR_FONT_FLAGS_VALID
) == 0 )
1206 XMLTextStyleContext
*pStyle
= 0;
1207 sal_uInt16 nFamily
= bPara
? XML_STYLE_FAMILY_TEXT_PARAGRAPH
1208 : XML_STYLE_FAMILY_TEXT_TEXT
;
1209 if (!rStyleName
.isEmpty() && m_xImpl
->m_xAutoStyles
.Is())
1211 const SvXMLStyleContext
* pTempStyle
=
1212 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
1213 FindStyleChildContext( nFamily
, rStyleName
,
1215 pStyle
= const_cast<XMLTextStyleContext
*>(PTR_CAST( XMLTextStyleContext
,pTempStyle
));
1220 sal_Int32 nCount
= pStyle
->_GetProperties().size();
1223 rtl::Reference
< SvXMLImportPropertyMapper
> xImpPrMap
=
1224 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)
1225 ->GetImportPropertyMapper(nFamily
);
1226 if( xImpPrMap
.is() )
1228 rtl::Reference
<XMLPropertySetMapper
> rPropMapper
=
1229 xImpPrMap
->getPropertySetMapper();
1230 for( sal_Int32 i
=0; i
< nCount
; i
++ )
1232 const XMLPropertyState
& rProp
= pStyle
->_GetProperties()[i
];
1233 sal_Int32 nIdx
= rProp
.mnIndex
;
1234 sal_uInt32 nContextId
= rPropMapper
->GetEntryContextId(nIdx
);
1235 if( CTF_FONTFAMILYNAME
== nContextId
)
1237 rFlags
&= ~(CONV_FROM_STAR_BATS
|CONV_FROM_STAR_MATH
);
1239 rProp
.maValue
>>= sFontName
;
1240 OUString
sStarBats( "StarBats" );
1241 OUString
sStarMath( "StarMath" );
1242 if( sFontName
.equalsIgnoreAsciiCase( sStarBats
) )
1243 rFlags
|= CONV_FROM_STAR_BATS
;
1244 else if( sFontName
.equalsIgnoreAsciiCase( sStarMath
) )
1245 rFlags
|= CONV_FROM_STAR_MATH
;
1254 rFlags
|= CONV_STAR_FONT_FLAGS_VALID
;
1256 if( (rFlags
& CONV_FROM_STAR_BATS
) != 0 )
1258 sChars
[j
] = rImport
.ConvStarBatsCharToStarSymbol( c
);
1261 else if( (rFlags
& CONV_FROM_STAR_MATH
) != 0 )
1263 sChars
[j
] = rImport
.ConvStarMathCharToStarSymbol( c
);
1269 return bConverted
? sChars
.makeStringAndClear() : rChars
;
1272 /* Helper method to determine, if a paragraph style has a list style (inclusive
1273 an empty one) inherits a list style (inclusive an empty one) from one of its parents (#i69629#)
1275 /* Apply special case, that found list style equals the chapter numbering, also
1276 to the found list styles of the parent styles. (#i73973#)
1278 static bool lcl_HasListStyle( const OUString
& sStyleName
,
1279 const Reference
< XNameContainer
>& xParaStyles
,
1280 SvXMLImport
& rImport
,
1281 const OUString
& sNumberingStyleName
,
1282 const OUString
& sOutlineStyleName
)
1286 if ( !xParaStyles
->hasByName( sStyleName
) )
1292 Reference
< XPropertyState
> xPropState( xParaStyles
->getByName( sStyleName
),
1294 if ( !xPropState
.is() )
1300 if ( xPropState
->getPropertyState( sNumberingStyleName
) == PropertyState_DIRECT_VALUE
)
1304 // special case: the set list style equals the chapter numbering
1305 Reference
< XPropertySet
> xPropSet( xPropState
, UNO_QUERY
);
1306 if ( xPropSet
.is() )
1308 OUString sListStyle
;
1309 xPropSet
->getPropertyValue( sNumberingStyleName
) >>= sListStyle
;
1310 if ( !sListStyle
.isEmpty() &&
1311 sListStyle
== sOutlineStyleName
)
1319 // Tools.Outline settings lost on Save (#i77708#)
1320 sal_Int32
nUPD( 0 );
1321 sal_Int32
nBuild( 0 );
1322 // Don't use UPD for versioning: xmloff/source/text/txtstyli.cxx and txtimp.cxx (#i86058#)
1323 const bool bBuildIdFound
= rImport
.getBuildIds( nUPD
, nBuild
);
1324 // search list style at parent
1325 Reference
<XStyle
> xStyle( xPropState
, UNO_QUERY
);
1326 while ( xStyle
.is() )
1328 OUString
aParentStyle( xStyle
->getParentStyle() );
1329 if ( !aParentStyle
.isEmpty() )
1332 rImport
.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH
,
1335 if ( aParentStyle
.isEmpty() || !xParaStyles
->hasByName( aParentStyle
) )
1337 // no list style found
1342 xPropState
= Reference
< XPropertyState
>(
1343 xParaStyles
->getByName( aParentStyle
),
1345 if ( !xPropState
.is() )
1350 if ( xPropState
->getPropertyState( sNumberingStyleName
) == PropertyState_DIRECT_VALUE
)
1354 // Special case: the found list style equals the chapter numbering (#i73973#)
1355 Reference
< XPropertySet
> xPropSet( xPropState
, UNO_QUERY
);
1356 if ( xPropSet
.is() )
1358 OUString sListStyle
;
1359 xPropSet
->getPropertyValue( sNumberingStyleName
) >>= sListStyle
;
1360 if ( !sListStyle
.isEmpty() &&
1361 sListStyle
== sOutlineStyleName
)
1365 // Special handling for text documents from OOo version prior OOo 2.4 (#i77708#)
1366 /* Check explicitly on certain versions and on import of
1367 text documents in OpenOffice.org file format (#i86058#)
1369 else if ( sListStyle
.isEmpty() &&
1370 ( rImport
.IsTextDocInOOoFileFormat() ||
1372 ( ( nUPD
== 641 ) || ( nUPD
== 645 ) || // prior OOo 2.0
1373 ( nUPD
== 680 && nBuild
<= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1
1382 // search list style at parent
1383 xStyle
= Reference
<XStyle
>( xPropState
, UNO_QUERY
);
1391 OUString
XMLTextImportHelper::SetStyleAndAttrs(
1392 SvXMLImport
& rImport
,
1393 const Reference
< XTextCursor
>& rCursor
,
1394 const OUString
& rStyleName
,
1396 bool bOutlineLevelAttrFound
,
1397 sal_Int8 nOutlineLevel
,
1398 // Numberings/Bullets in table not visible after save/reload (#i80724#)
1399 bool bSetListAttrs
)
1401 static const char s_ParaStyleName
[] = "ParaStyleName";
1402 static const char s_CharStyleName
[] = "CharStyleName";
1403 static const char s_NumberingRules
[] = "NumberingRules";
1404 static const char s_NumberingIsNumber
[] = "NumberingIsNumber";
1405 static const char s_NumberingLevel
[] = "NumberingLevel";
1406 static const char s_ParaIsNumberingRestart
[] = "ParaIsNumberingRestart";
1407 static const char s_NumberingStartValue
[] = "NumberingStartValue";
1408 static const char s_PropNameListId
[] = "ListId";
1409 static const char s_PageDescName
[] = "PageDescName";
1410 static const char s_ServiceCombinedCharacters
[] = "com.sun.star.text.TextField.CombinedCharacters";
1411 static const char s_Content
[] = "Content";
1412 static const char s_OutlineLevel
[] = "OutlineLevel";
1413 static const char s_NumberingStyleName
[] = "NumberingStyleName";
1415 const sal_uInt16 nFamily
= bPara
? XML_STYLE_FAMILY_TEXT_PARAGRAPH
1416 : XML_STYLE_FAMILY_TEXT_TEXT
;
1417 XMLTextStyleContext
*pStyle
= 0;
1418 OUString
sStyleName( rStyleName
);
1419 if (!sStyleName
.isEmpty() && m_xImpl
->m_xAutoStyles
.Is())
1421 const SvXMLStyleContext
* pTempStyle
=
1422 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
1423 FindStyleChildContext( nFamily
, sStyleName
, true );
1424 pStyle
= const_cast<XMLTextStyleContext
*>(PTR_CAST( XMLTextStyleContext
,pTempStyle
));
1427 sStyleName
= pStyle
->GetParentName();
1429 Reference
< XPropertySet
> xPropSet( rCursor
, UNO_QUERY
);
1430 Reference
< XPropertySetInfo
> xPropSetInfo(
1431 xPropSet
->getPropertySetInfo());
1434 if( !sStyleName
.isEmpty() )
1436 sStyleName
= rImport
.GetStyleDisplayName( nFamily
, sStyleName
);
1437 const OUString rPropName
= bPara
? s_ParaStyleName
: s_CharStyleName
;
1438 const Reference
< XNameContainer
> & rStyles
= (bPara
)
1439 ? m_xImpl
->m_xParaStyles
1440 : m_xImpl
->m_xTextStyles
;
1442 xPropSetInfo
->hasPropertyByName( rPropName
) &&
1443 rStyles
->hasByName( sStyleName
) )
1445 xPropSet
->setPropertyValue( rPropName
, makeAny(sStyleName
) );
1451 /* The outline level needs to be only applied as list level, if the heading
1452 is not inside a list and if it by default applies the outline style. (#i70748#)
1454 bool bApplyOutlineLevelAsListLevel( false );
1455 // Numberings/Bullets in table not visible after save/reload (#i80724#)
1456 if (bSetListAttrs
&& bPara
1457 && xPropSetInfo
->hasPropertyByName( s_NumberingRules
))
1459 // Set numbering rules
1460 Reference
< XIndexReplace
> const xNumRules(
1461 xPropSet
->getPropertyValue(s_NumberingRules
), UNO_QUERY
);
1463 XMLTextListBlockContext
* pListBlock(0);
1464 XMLTextListItemContext
* pListItem(0);
1465 XMLNumberedParaContext
* pNumberedParagraph(0);
1466 GetTextListHelper().ListContextTop(
1467 pListBlock
, pListItem
, pNumberedParagraph
);
1469 assert(!(pListBlock
&& pNumberedParagraph
) && "XMLTextImportHelper::"
1470 "SetStyleAndAttrs: both list and numbered-paragraph???");
1472 Reference
< XIndexReplace
> xNewNumRules
;
1473 sal_Int8
nLevel(-1);
1475 sal_Int16
nStartValue(-1);
1476 bool bNumberingIsNumber(true);
1481 bNumberingIsNumber
= false; // list-header
1483 // consider text:style-override property of <text:list-item>
1485 (pListItem
!= 0 && pListItem
->HasNumRulesOverride())
1486 ? pListItem
->GetNumRulesOverride()
1487 : pListBlock
->GetNumRules() );
1488 nLevel
= static_cast<sal_Int8
>(pListBlock
->GetLevel());
1490 if ( pListItem
&& pListItem
->HasStartValue() ) {
1491 nStartValue
= pListItem
->GetStartValue();
1494 // Inconsistent behavior regarding lists (#i92811#)
1495 sListId
= m_xImpl
->m_xTextListsHelper
->GetListIdForListBlock(
1498 else if (pNumberedParagraph
)
1500 xNewNumRules
.set(pNumberedParagraph
->GetNumRules());
1501 nLevel
= static_cast<sal_Int8
>(pNumberedParagraph
->GetLevel());
1502 sListId
= pNumberedParagraph
->GetListId();
1503 nStartValue
= pNumberedParagraph
->GetStartValue();
1507 if (pListBlock
|| pNumberedParagraph
)
1509 // Assure that list style of automatic paragraph style is applied at paragraph. (#i101349#)
1510 bool bApplyNumRules
= pStyle
&& pStyle
->IsListStyleSet();
1511 if ( !bApplyNumRules
)
1513 bool bSameNumRules
= xNewNumRules
== xNumRules
;
1514 if( !bSameNumRules
&& xNewNumRules
.is() && xNumRules
.is() )
1516 // If the interface pointers are different then this does
1517 // not mean that the num rules are different. Further tests
1518 // are required then. However, if only one num rule is
1519 // set, no tests are required of course.
1520 Reference
< XNamed
> xNewNamed( xNewNumRules
, UNO_QUERY
);
1521 Reference
< XNamed
> xNamed( xNumRules
, UNO_QUERY
);
1522 if( xNewNamed
.is() && xNamed
.is() )
1524 bSameNumRules
= xNewNamed
->getName() == xNamed
->getName();
1528 Reference
< XAnyCompare
> xNumRuleCompare( xNumRules
, UNO_QUERY
);
1529 if( xNumRuleCompare
.is() )
1531 bSameNumRules
= (xNumRuleCompare
->compare( Any(xNumRules
), Any(xNewNumRules
) ) == 0);
1535 bApplyNumRules
= !bSameNumRules
;
1538 if ( bApplyNumRules
)
1540 // #102607# This may except when xNewNumRules contains
1541 // a Writer-NumRule-Implementation bug gets applied to
1542 // a shape. Since this may occur inside a document
1543 // (e.g. when edited), this must be handled
1547 xPropSet
->setPropertyValue(
1548 s_NumberingRules
, makeAny(xNewNumRules
) );
1550 catch(const Exception
&)
1552 ; // I would really like to use a warning here,
1553 // but I can't access the XMLErrorHandler from
1558 if (!bNumberingIsNumber
&&
1559 xPropSetInfo
->hasPropertyByName(s_NumberingIsNumber
))
1561 xPropSet
->setPropertyValue(s_NumberingIsNumber
, Any(sal_False
));
1564 xPropSet
->setPropertyValue( s_NumberingLevel
, Any(nLevel
) );
1566 if( pListBlock
&& pListBlock
->IsRestartNumbering() )
1568 // TODO: property missing
1569 if (xPropSetInfo
->hasPropertyByName(s_ParaIsNumberingRestart
))
1572 xPropSet
->setPropertyValue(s_ParaIsNumberingRestart
,
1575 pListBlock
->ResetRestartNumbering();
1578 if ( 0 <= nStartValue
&&
1579 xPropSetInfo
->hasPropertyByName(s_NumberingStartValue
))
1581 xPropSet
->setPropertyValue(s_NumberingStartValue
,
1582 makeAny(nStartValue
));
1585 if (xPropSetInfo
->hasPropertyByName(s_PropNameListId
))
1587 if (!sListId
.isEmpty()) {
1588 xPropSet
->setPropertyValue(s_PropNameListId
,
1593 GetTextListHelper().SetListItem( (XMLTextListItemContext
*)0 );
1597 /* If the paragraph is not in a list but its style, remove it from
1598 the list. Do not remove it, if the list of the style is
1599 the chapter numbering rule.
1601 if( xNumRules
.is() )
1603 bool bRemove( true );
1604 // Special handling for document from OOo 2.x (#i70748#)
1605 sal_Int32
nUPD( 0 );
1606 sal_Int32
nBuild( 0 );
1607 const bool bBuildIdFound
= rImport
.getBuildIds( nUPD
, nBuild
);
1608 if ( ( bBuildIdFound
&& nUPD
== 680 ) ||
1609 !pStyle
|| !pStyle
->IsListStyleSet() )
1611 if (m_xImpl
->m_xChapterNumbering
.is())
1613 Reference
< XNamed
> xNumNamed( xNumRules
, UNO_QUERY
);
1614 Reference
< XNamed
> const xChapterNumNamed (
1615 m_xImpl
->m_xChapterNumbering
, UNO_QUERY
);
1616 if ( xNumNamed
.is() && xChapterNumNamed
.is() &&
1617 xNumNamed
->getName() == xChapterNumNamed
->getName() )
1620 // RFE: inserting headings into text documents (#i70748#)
1621 bApplyOutlineLevelAsListLevel
= true;
1627 SAL_INFO_IF(!pStyle
->GetListStyle().isEmpty(),
1629 "automatic paragraph style with list style name, but paragraph not in list???");
1633 xPropSet
->setPropertyValue( s_NumberingRules
, Any() );
1639 // hard paragraph properties
1642 pStyle
->FillPropertySet( xPropSet
);
1643 if( bPara
&& pStyle
->HasMasterPageName() &&
1644 xPropSetInfo
->hasPropertyByName(s_PageDescName
))
1646 OUString
sDisplayName(
1647 rImport
.GetStyleDisplayName(
1648 XML_STYLE_FAMILY_MASTER_PAGE
,
1649 pStyle
->GetMasterPageName()) );
1650 if( sDisplayName
.isEmpty() ||
1651 (m_xImpl
->m_xPageStyles
.is() &&
1652 m_xImpl
->m_xPageStyles
->hasByName( sDisplayName
)))
1654 xPropSet
->setPropertyValue(s_PageDescName
,
1655 makeAny(sDisplayName
));
1658 if( bPara
&& !pStyle
->GetDropCapStyleName().isEmpty() &&
1659 m_xImpl
->m_xTextStyles
.is())
1661 OUString
sDisplayName(
1662 rImport
.GetStyleDisplayName(
1663 XML_STYLE_FAMILY_TEXT_TEXT
,
1664 pStyle
->GetDropCapStyleName()) );
1665 if (m_xImpl
->m_xTextStyles
->hasByName(sDisplayName
) &&
1666 xPropSetInfo
->hasPropertyByName( pStyle
->sDropCapCharStyleName
) )
1668 xPropSet
->setPropertyValue( pStyle
->sDropCapCharStyleName
, makeAny(sDisplayName
) );
1672 // combined characters special treatment
1673 if (!bPara
&& pStyle
->HasCombinedCharactersLetter())
1675 // insert combined characters text field
1676 if (m_xImpl
->m_xServiceFactory
.is())
1678 uno::Reference
<beans::XPropertySet
> const xTmp(
1679 m_xImpl
->m_xServiceFactory
->createInstance(
1680 s_ServiceCombinedCharacters
), UNO_QUERY
);
1683 // fix cursor if larger than possible for
1684 // combined characters field
1685 if (rCursor
->getString().getLength() >
1686 MAX_COMBINED_CHARACTERS
)
1688 rCursor
->gotoRange(rCursor
->getStart(), sal_False
);
1689 rCursor
->goRight(MAX_COMBINED_CHARACTERS
, sal_True
);
1692 // set field value (the combined character string)
1693 xTmp
->setPropertyValue(s_Content
,
1694 makeAny(rCursor
->getString()));
1696 // insert the field over it's original text
1697 Reference
<XTextContent
> xTextContent(xTmp
, UNO_QUERY
);
1698 if (m_xImpl
->m_xText
.is() && rCursor
.is())
1700 // #i107225# the combined characters need to be inserted first
1701 // the selected text has to be removed afterwards
1702 m_xImpl
->m_xText
->insertTextContent( rCursor
->getStart(), xTextContent
, sal_True
);
1704 if( !rCursor
->getString().isEmpty() )
1708 uno::Reference
< text::XTextCursor
> xCrsr
= rCursor
->getText()->createTextCursorByRange( rCursor
->getStart() );
1709 xCrsr
->goLeft( 1, true );
1710 uno::Reference
< beans::XPropertySet
> xCrsrProperties( xCrsr
, uno::UNO_QUERY_THROW
);
1711 //the hard properties of the removed text need to be applied to the combined characters field
1712 pStyle
->FillPropertySet( xCrsrProperties
);
1713 xCrsr
->collapseToEnd();
1714 xCrsr
->gotoRange( rCursor
->getEnd(), true );
1715 xCrsr
->setString( OUString() );
1717 catch(const uno::Exception
&)
1727 // outline level; set after list style has been set
1728 // Complete re-worked and corrected: (#i53198#)
1729 // - set outline level at paragraph
1730 // - set numbering level at paragraph, if none is already set
1731 // - assure that style is marked as an outline style for the corresponding
1733 // - DO NOT set type of numbering rule to outline.
1734 // - DO NOT set numbering rule directly at the paragraph.
1736 // Some minor rework and adjust access to paragraph styles (#i70748#)
1739 // Headings not numbered anymore in 3.1 (#i103817#)
1740 sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle
= 0;
1741 const bool bHasOutlineLevelProp(
1742 xPropSetInfo
->hasPropertyByName(s_OutlineLevel
));
1743 if ( bHasOutlineLevelProp
)
1745 xPropSet
->getPropertyValue(s_OutlineLevel
)
1746 >>= nCurrentOutlineLevelInheritedFromParagraphStyle
;
1748 if ( nOutlineLevel
> 0 )
1750 if ( bHasOutlineLevelProp
)
1752 // In case that the value equals the value of its paragraph style
1753 // attribute outline level, the paragraph attribute value is left unset
1754 if ( nCurrentOutlineLevelInheritedFromParagraphStyle
!= nOutlineLevel
)
1756 xPropSet
->setPropertyValue( s_OutlineLevel
,
1757 makeAny( static_cast<sal_Int16
>(nOutlineLevel
) ) );
1761 // RFE: inserting headings into text documents (#i70748#)
1762 if ( bApplyOutlineLevelAsListLevel
)
1764 sal_Int16 nNumLevel
= -1;
1765 xPropSet
->getPropertyValue( s_NumberingLevel
) >>= nNumLevel
;
1766 if ( nNumLevel
== -1 ||
1767 nNumLevel
!= (nOutlineLevel
- 1) )
1769 xPropSet
->setPropertyValue( s_NumberingLevel
,
1770 makeAny( static_cast<sal_Int8
>(nOutlineLevel
- 1) ) );
1773 /* Correction: (#i69629#)
1774 - for text document from version OOo 2.0.4/SO 8 PU4 and earlier
1775 the paragraph style of a heading should be assigned to the
1776 corresponding list level of the outline style.
1777 - for other text documents the paragraph style of a heading is only
1778 a candidate for an assignment to the list level of the outline
1779 style, if it has no direct list style property and (if exists) the
1780 automatic paragraph style has also no direct list style set.
1782 if (m_xImpl
->m_xParaStyles
.is() && m_xImpl
->m_xParaStyles
->hasByName(sStyleName
))
1784 bool bOutlineStyleCandidate( false );
1786 sal_Int32
nUPD( 0 );
1787 sal_Int32
nBuild( 0 );
1788 const bool bBuildIdFound
= rImport
.getBuildIds( nUPD
, nBuild
);
1789 // Lost outline numbering in master document (#i73509#)
1790 // Check explicitly on certain versions (#i86058#)
1791 if ( rImport
.IsTextDocInOOoFileFormat() ||
1793 ( nUPD
== 645 || nUPD
== 641 ) ) )
1795 bOutlineStyleCandidate
= true;
1797 else if ( nUPD
== 680 && nBuild
<= 9073 ) /* BuildId of OOo 2.0.4/SO8 PU4 */
1799 bOutlineStyleCandidate
= bOutlineLevelAttrFound
;
1801 if ( bOutlineStyleCandidate
)
1803 AddOutlineStyleCandidate( nOutlineLevel
, sStyleName
);
1805 // Assure that heading applies the outline style (#i103817#)
1806 if ( ( !pStyle
|| !pStyle
->IsListStyleSet() ) &&
1807 !bOutlineStyleCandidate
&&
1808 m_xImpl
->m_xChapterNumbering
.is())
1811 if ( !lcl_HasListStyle( sStyleName
,
1812 m_xImpl
->m_xParaStyles
, GetXMLImport(),
1813 s_NumberingStyleName
,
1816 // heading not in a list --> apply outline style
1817 xPropSet
->setPropertyValue( s_NumberingRules
,
1818 makeAny(m_xImpl
->m_xChapterNumbering
) );
1819 xPropSet
->setPropertyValue( s_NumberingLevel
,
1820 makeAny(static_cast<sal_Int8
>(nOutlineLevel
- 1)));
1825 //handle for text:p,if the paragraphstyle outlinelevel is set to[1~10]
1826 else if( bHasOutlineLevelProp
)
1828 if ( nCurrentOutlineLevelInheritedFromParagraphStyle
!= 0 )
1830 sal_Int16 nZero
= 0;
1831 xPropSet
->setPropertyValue(s_OutlineLevel
,
1832 makeAny( static_cast<sal_Int16
>(nZero
) ));
1840 void XMLTextImportHelper::FindOutlineStyleName( OUString
& rStyleName
,
1841 sal_Int8 nOutlineLevel
)
1843 static const char s_HeadingStyleName
[] = "HeadingStyleName";
1845 // style name empty?
1846 if( rStyleName
.isEmpty() )
1848 // Empty? Then we need o do stuff. Let's do error checking first.
1849 if (m_xImpl
->m_xChapterNumbering
.is() &&
1850 ( nOutlineLevel
> 0 ) &&
1851 (nOutlineLevel
<= m_xImpl
->m_xChapterNumbering
->getCount()))
1853 nOutlineLevel
--; // for the remainder, the level's are 0-based
1855 // empty style name: look-up previously used name
1857 // if we don't have a previously used name, we'll use the default
1858 m_xImpl
->InitOutlineStylesCandidates();
1859 if (m_xImpl
->m_xOutlineStylesCandidates
[nOutlineLevel
].empty())
1861 // no other name used previously? Then use default
1863 // iterate over property value sequence to find the style name
1864 Sequence
<PropertyValue
> aProperties
;
1865 m_xImpl
->m_xChapterNumbering
->getByIndex( nOutlineLevel
)
1867 for( sal_Int32 i
= 0; i
< aProperties
.getLength(); i
++ )
1869 if (aProperties
[i
].Name
== s_HeadingStyleName
)
1871 OUString aOutlineStyle
;
1872 aProperties
[i
].Value
>>= aOutlineStyle
;
1873 m_xImpl
->m_xOutlineStylesCandidates
[nOutlineLevel
]
1874 .push_back( aOutlineStyle
);
1875 break; // early out, if we found it!.
1880 // finally, we'll use the previously used style name for this
1881 // format (or the default we've just put into that style)
1882 // take last added one (#i71249#)
1884 m_xImpl
->m_xOutlineStylesCandidates
[nOutlineLevel
].back();
1886 // else: nothing we can do, so we'll leave it empty
1888 // else: we already had a style name, so we let it pass.
1891 void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel
,
1892 const OUString
& rStyleName
)
1894 if (!rStyleName
.isEmpty()
1895 && m_xImpl
->m_xChapterNumbering
.is()
1896 && (nOutlineLevel
> 0)
1897 && (nOutlineLevel
<= m_xImpl
->m_xChapterNumbering
->getCount()))
1899 m_xImpl
->InitOutlineStylesCandidates();
1900 m_xImpl
->m_xOutlineStylesCandidates
[nOutlineLevel
-1].push_back(
1905 void XMLTextImportHelper::SetOutlineStyles( bool bSetEmptyLevels
)
1907 static const char s_NumberingStyleName
[] = "NumberingStyleName";
1908 static const char s_HeadingStyleName
[] = "HeadingStyleName";
1910 if ((m_xImpl
->m_xOutlineStylesCandidates
!= 0 || bSetEmptyLevels
) &&
1911 m_xImpl
->m_xChapterNumbering
.is() &&
1914 bool bChooseLastOne( false );
1916 if ( GetXMLImport().IsTextDocInOOoFileFormat() )
1918 bChooseLastOne
= true;
1922 sal_Int32
nUPD( 0 );
1923 sal_Int32
nBuild( 0 );
1924 if ( GetXMLImport().getBuildIds( nUPD
, nBuild
) )
1926 // check explicitly on certain versions
1927 bChooseLastOne
= ( nUPD
== 641 ) || ( nUPD
== 645 ) || // prior OOo 2.0
1928 ( nUPD
== 680 && nBuild
<= 9073 ); // OOo 2.0 - OOo 2.0.4
1933 OUString sOutlineStyleName
;
1935 Reference
<XPropertySet
> xChapterNumRule(
1936 m_xImpl
->m_xChapterNumbering
, UNO_QUERY
);
1937 const OUString
sName("Name");
1938 xChapterNumRule
->getPropertyValue(sName
) >>= sOutlineStyleName
;
1941 const sal_Int32 nCount
= m_xImpl
->m_xChapterNumbering
->getCount();
1942 /* First collect all paragraph styles chosen for assignment to each
1943 list level of the outline style, then perform the intrinsic assignment.
1944 Reason: The assignment of a certain paragraph style to a list level
1945 of the outline style causes side effects on the children
1946 paragraph styles in Writer. (#i106218#)
1948 ::std::vector
<OUString
> sChosenStyles(nCount
);
1949 for( sal_Int32 i
=0; i
< nCount
; ++i
)
1951 if ( bSetEmptyLevels
||
1952 (m_xImpl
->m_xOutlineStylesCandidates
&&
1953 !m_xImpl
->m_xOutlineStylesCandidates
[i
].empty()))
1955 // determine, which candidate is one to be assigned to the list
1956 // level of the outline style
1957 if (m_xImpl
->m_xOutlineStylesCandidates
&&
1958 !m_xImpl
->m_xOutlineStylesCandidates
[i
].empty())
1960 if ( bChooseLastOne
)
1963 m_xImpl
->m_xOutlineStylesCandidates
[i
].back();
1967 for (sal_uInt32 j
= 0;
1968 j
< m_xImpl
->m_xOutlineStylesCandidates
[i
].size();
1971 if (!lcl_HasListStyle(
1972 m_xImpl
->m_xOutlineStylesCandidates
[i
][j
],
1973 m_xImpl
->m_xParaStyles
,
1975 s_NumberingStyleName
,
1979 m_xImpl
->m_xOutlineStylesCandidates
[i
][j
];
1987 // Trashed outline numbering in ODF 1.1 text document created by OOo 3.x (#i106218#)
1988 Sequence
< PropertyValue
> aProps( 1 );
1989 PropertyValue
*pProps
= aProps
.getArray();
1990 pProps
->Name
= s_HeadingStyleName
;
1991 for ( sal_Int32 i
= 0; i
< nCount
; ++i
)
1993 // Paragraph style assignments in Outline of template lost from second level on (#i107610#)
1994 if ( bSetEmptyLevels
|| !sChosenStyles
[i
].isEmpty() )
1996 pProps
->Value
<<= sChosenStyles
[i
];
1997 m_xImpl
->m_xChapterNumbering
->replaceByIndex(i
,
2004 void XMLTextImportHelper::SetHyperlink(
2005 SvXMLImport
& rImport
,
2006 const Reference
< XTextCursor
>& rCursor
,
2007 const OUString
& rHRef
,
2008 const OUString
& rName
,
2009 const OUString
& rTargetFrameName
,
2010 const OUString
& rStyleName
,
2011 const OUString
& rVisitedStyleName
,
2012 XMLEventsImportContext
* pEvents
)
2014 static const char s_HyperLinkURL
[] = "HyperLinkURL";
2015 static const char s_HyperLinkName
[] = "HyperLinkName";
2016 static const char s_HyperLinkTarget
[] = "HyperLinkTarget";
2017 static const char s_UnvisitedCharStyleName
[] = "UnvisitedCharStyleName";
2018 static const char s_VisitedCharStyleName
[] = "VisitedCharStyleName";
2019 static const char s_HyperLinkEvents
[] = "HyperLinkEvents";
2021 Reference
< XPropertySet
> xPropSet( rCursor
, UNO_QUERY
);
2022 Reference
< XPropertySetInfo
> xPropSetInfo(
2023 xPropSet
->getPropertySetInfo());
2024 if (!xPropSetInfo
.is() || !xPropSetInfo
->hasPropertyByName(s_HyperLinkURL
))
2027 xPropSet
->setPropertyValue(s_HyperLinkURL
, makeAny(rHRef
));
2029 if (xPropSetInfo
->hasPropertyByName(s_HyperLinkName
))
2031 xPropSet
->setPropertyValue(s_HyperLinkName
, makeAny(rName
));
2034 if (xPropSetInfo
->hasPropertyByName(s_HyperLinkTarget
))
2036 xPropSet
->setPropertyValue(s_HyperLinkTarget
,
2037 makeAny(rTargetFrameName
));
2040 if ( (pEvents
!= NULL
) &&
2041 xPropSetInfo
->hasPropertyByName(s_HyperLinkEvents
))
2043 // The API treats events at hyperlinks differently from most
2044 // other properties: You have to set a name replace with the
2045 // events in it. The easiest way to do this is to 1) get
2046 // events, 2) set new ones, and 3) then put events back.
2047 uno::Reference
<XNameReplace
> const xReplace(
2048 xPropSet
->getPropertyValue(s_HyperLinkEvents
), UNO_QUERY
);
2052 pEvents
->SetEvents(xReplace
);
2055 xPropSet
->setPropertyValue(s_HyperLinkEvents
, makeAny(xReplace
));
2059 if (m_xImpl
->m_xTextStyles
.is())
2061 OUString
sDisplayName(
2062 rImport
.GetStyleDisplayName(
2063 XML_STYLE_FAMILY_TEXT_TEXT
, rStyleName
) );
2064 if( !sDisplayName
.isEmpty() &&
2065 xPropSetInfo
->hasPropertyByName(s_UnvisitedCharStyleName
) &&
2066 m_xImpl
->m_xTextStyles
->hasByName(sDisplayName
))
2068 xPropSet
->setPropertyValue(s_UnvisitedCharStyleName
,
2069 makeAny(sDisplayName
));
2073 rImport
.GetStyleDisplayName(
2074 XML_STYLE_FAMILY_TEXT_TEXT
, rVisitedStyleName
);
2075 if( !sDisplayName
.isEmpty() &&
2076 xPropSetInfo
->hasPropertyByName(s_VisitedCharStyleName
) &&
2077 m_xImpl
->m_xTextStyles
->hasByName(sDisplayName
))
2079 xPropSet
->setPropertyValue(s_VisitedCharStyleName
,
2080 makeAny(sDisplayName
));
2085 void XMLTextImportHelper::SetRuby(
2086 SvXMLImport
& rImport
,
2087 const Reference
< XTextCursor
>& rCursor
,
2088 const OUString
& rStyleName
,
2089 const OUString
& rTextStyleName
,
2090 const OUString
& rText
)
2092 Reference
<XPropertySet
> xPropSet(rCursor
, UNO_QUERY
);
2094 OUString
sRubyText("RubyText");
2095 OUString
sRubyCharStyleName("RubyCharStyleName");
2097 // if we have one Ruby property, we assume all of them are present
2098 if (xPropSet
.is() &&
2099 xPropSet
->getPropertySetInfo()->hasPropertyByName( sRubyText
))
2102 xPropSet
->setPropertyValue(sRubyText
, makeAny(rText
));
2104 // the ruby style (ruby-adjust)
2105 if (!rStyleName
.isEmpty() && m_xImpl
->m_xAutoStyles
.Is())
2107 const SvXMLStyleContext
* pTempStyle
=
2108 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
2109 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_RUBY
,
2111 XMLPropStyleContext
*pStyle
= const_cast<XMLPropStyleContext
*>(PTR_CAST(XMLPropStyleContext
,pTempStyle
));
2114 pStyle
->FillPropertySet( xPropSet
);
2117 // the ruby text character style
2118 if (m_xImpl
->m_xTextStyles
.is())
2120 OUString
sDisplayName(
2121 rImport
.GetStyleDisplayName(
2122 XML_STYLE_FAMILY_TEXT_TEXT
, rTextStyleName
) );
2123 if( (!sDisplayName
.isEmpty()) &&
2124 m_xImpl
->m_xTextStyles
->hasByName( sDisplayName
))
2126 xPropSet
->setPropertyValue(sRubyCharStyleName
, makeAny(sDisplayName
));
2132 void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext
*pStyles
)
2134 m_xImpl
->m_xAutoStyles
= pStyles
;
2137 SvXMLImportContext
*XMLTextImportHelper::CreateTextChildContext(
2138 SvXMLImport
& rImport
,
2139 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
2140 const Reference
< XAttributeList
> & xAttrList
,
2143 SvXMLImportContext
*pContext
= 0;
2145 const SvXMLTokenMap
& rTokenMap
= GetTextElemTokenMap();
2146 bool bHeading
= false;
2147 bool bContent
= true;
2148 sal_uInt16 nToken
= rTokenMap
.Get( nPrefix
, rLocalName
);
2151 case XML_TOK_TEXT_H
:
2153 case XML_TOK_TEXT_P
:
2154 pContext
= new XMLParaContext( rImport
,
2155 nPrefix
, rLocalName
,
2156 xAttrList
, bHeading
);
2157 if (m_xImpl
->m_bProgress
&& XML_TEXT_TYPE_SHAPE
!= eType
)
2159 rImport
.GetProgressBarHelper()->Increment();
2162 case XML_TOK_TEXT_NUMBERED_PARAGRAPH
:
2163 pContext
= new XMLNumberedParaContext(
2164 rImport
, nPrefix
, rLocalName
, xAttrList
);
2166 case XML_TOK_TEXT_LIST
:
2167 pContext
= new XMLTextListBlockContext( rImport
, *this,
2168 nPrefix
, rLocalName
,
2171 case XML_TOK_TABLE_TABLE
:
2172 if( XML_TEXT_TYPE_BODY
== eType
||
2173 XML_TEXT_TYPE_TEXTBOX
== eType
||
2174 XML_TEXT_TYPE_SECTION
== eType
||
2175 XML_TEXT_TYPE_HEADER_FOOTER
== eType
||
2176 XML_TEXT_TYPE_CHANGED_REGION
== eType
||
2177 XML_TEXT_TYPE_CELL
== eType
)
2178 pContext
= CreateTableChildContext( rImport
, nPrefix
, rLocalName
,
2181 case XML_TOK_TEXT_SEQUENCE_DECLS
:
2182 if ((XML_TEXT_TYPE_BODY
== eType
&& m_xImpl
->m_bBodyContentStarted
) ||
2183 XML_TEXT_TYPE_HEADER_FOOTER
== eType
)
2185 pContext
= new XMLVariableDeclsImportContext(
2186 rImport
, *this, nPrefix
, rLocalName
, VarTypeSequence
);
2191 case XML_TOK_TEXT_VARFIELD_DECLS
:
2192 if ((XML_TEXT_TYPE_BODY
== eType
&& m_xImpl
->m_bBodyContentStarted
) ||
2193 XML_TEXT_TYPE_HEADER_FOOTER
== eType
)
2195 pContext
= new XMLVariableDeclsImportContext(
2196 rImport
, *this, nPrefix
, rLocalName
, VarTypeSimple
);
2201 case XML_TOK_TEXT_USERFIELD_DECLS
:
2202 if ((XML_TEXT_TYPE_BODY
== eType
&& m_xImpl
->m_bBodyContentStarted
)||
2203 XML_TEXT_TYPE_HEADER_FOOTER
== eType
)
2205 pContext
= new XMLVariableDeclsImportContext(
2206 rImport
, *this, nPrefix
, rLocalName
, VarTypeUserField
);
2211 case XML_TOK_TEXT_DDE_DECLS
:
2212 if ((XML_TEXT_TYPE_BODY
== eType
&& m_xImpl
->m_bBodyContentStarted
) ||
2213 XML_TEXT_TYPE_HEADER_FOOTER
== eType
)
2215 pContext
= new XMLDdeFieldDeclsImportContext(
2216 rImport
, nPrefix
, rLocalName
);
2221 case XML_TOK_TEXT_FRAME_PAGE
:
2222 if ((XML_TEXT_TYPE_BODY
== eType
&& m_xImpl
->m_bBodyContentStarted
) ||
2223 XML_TEXT_TYPE_TEXTBOX
== eType
||
2224 XML_TEXT_TYPE_CHANGED_REGION
== eType
)
2226 TextContentAnchorType eAnchorType
=
2227 XML_TEXT_TYPE_TEXTBOX
== eType
? TextContentAnchorType_AT_FRAME
2228 : TextContentAnchorType_AT_PAGE
;
2229 pContext
= new XMLTextFrameContext( rImport
, nPrefix
,
2230 rLocalName
, xAttrList
,
2236 case XML_TOK_DRAW_A_PAGE
:
2237 if ((XML_TEXT_TYPE_BODY
== eType
&& m_xImpl
->m_bBodyContentStarted
) ||
2238 XML_TEXT_TYPE_TEXTBOX
== eType
||
2239 XML_TEXT_TYPE_CHANGED_REGION
== eType
)
2241 TextContentAnchorType eAnchorType
=
2242 XML_TEXT_TYPE_TEXTBOX
== eType
? TextContentAnchorType_AT_FRAME
2243 : TextContentAnchorType_AT_PAGE
;
2244 pContext
= new XMLTextFrameHyperlinkContext( rImport
, nPrefix
,
2245 rLocalName
, xAttrList
,
2251 case XML_TOK_TEXT_INDEX_TITLE
:
2252 case XML_TOK_TEXT_SECTION
:
2253 pContext
= new XMLSectionImportContext( rImport
, nPrefix
, rLocalName
);
2256 case XML_TOK_TEXT_TOC
:
2257 case XML_TOK_TEXT_OBJECT_INDEX
:
2258 case XML_TOK_TEXT_TABLE_INDEX
:
2259 case XML_TOK_TEXT_ILLUSTRATION_INDEX
:
2260 case XML_TOK_TEXT_USER_INDEX
:
2261 case XML_TOK_TEXT_ALPHABETICAL_INDEX
:
2262 case XML_TOK_TEXT_BIBLIOGRAPHY_INDEX
:
2263 if( XML_TEXT_TYPE_SHAPE
!= eType
)
2264 pContext
= new XMLIndexTOCContext( rImport
, nPrefix
, rLocalName
);
2267 case XML_TOK_TEXT_TRACKED_CHANGES
:
2268 pContext
= new XMLTrackedChangesImportContext( rImport
, nPrefix
,
2273 case XML_TOK_TEXT_CHANGE
:
2274 case XML_TOK_TEXT_CHANGE_START
:
2275 case XML_TOK_TEXT_CHANGE_END
:
2276 pContext
= new XMLChangeImportContext(
2277 rImport
, nPrefix
, rLocalName
,
2278 (XML_TOK_TEXT_CHANGE_END
!= nToken
),
2279 (XML_TOK_TEXT_CHANGE_START
!= nToken
),
2283 case XML_TOK_TEXT_FORMS
:
2284 pContext
= xmloff::OFormLayerXMLImport::createOfficeFormsContext(rImport
, nPrefix
, rLocalName
);
2288 case XML_TOK_TEXT_AUTOMARK
:
2289 if( XML_TEXT_TYPE_BODY
== eType
)
2291 pContext
= new XMLAutoMarkFileContext(rImport
, nPrefix
,rLocalName
);
2296 case XML_TOK_TEXT_CALCULATION_SETTINGS
:
2297 pContext
= new XMLCalculationSettingsContext ( rImport
, nPrefix
, rLocalName
, xAttrList
);
2302 if ((XML_TEXT_TYPE_BODY
== eType
&& m_xImpl
->m_bBodyContentStarted
) ||
2303 XML_TEXT_TYPE_TEXTBOX
== eType
||
2304 XML_TEXT_TYPE_CHANGED_REGION
== eType
)
2306 Reference
< XShapes
> xShapes
;
2307 pContext
= rImport
.GetShapeImport()->CreateGroupChildContext(
2308 rImport
, nPrefix
, rLocalName
, xAttrList
, xShapes
);
2313 // handle open redlines
2314 if ( (XML_TOK_TEXT_CHANGE
!= nToken
) &&
2315 (XML_TOK_TEXT_CHANGE_END
!= nToken
) &&
2316 (XML_TOK_TEXT_CHANGE_START
!= nToken
) )
2318 // ResetOpenRedlineId();
2321 if( XML_TEXT_TYPE_BODY
== eType
&& bContent
)
2323 m_xImpl
->m_bBodyContentStarted
= false;
2329 SvXMLImportContext
*XMLTextImportHelper::CreateTableChildContext(
2331 sal_uInt16
/*nPrefix*/, const OUString
& /*rLocalName*/,
2332 const Reference
< XAttributeList
> & )
2337 /// get data style key for use with NumberFormat property
2338 sal_Int32
XMLTextImportHelper::GetDataStyleKey(const OUString
& sStyleName
,
2339 bool* pIsSystemLanguage
)
2341 const SvXMLStyleContext
* pStyle
=
2342 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
2343 FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE
,
2346 // get appropriate context
2349 // first check if it's a impress and draw only number format
2350 // this is needed since its also a SvXMLNumFormatContext,
2351 // that was needed to support them for controls in impress/draw also
2352 const SdXMLNumberFormatImportContext
* pSdNumStyle
= PTR_CAST( SdXMLNumberFormatImportContext
, pStyle
);
2355 return pSdNumStyle
->GetDrawKey();
2359 SvXMLNumFormatContext
* pNumStyle
= const_cast<SvXMLNumFormatContext
*>(PTR_CAST( SvXMLNumFormatContext
, pStyle
));
2362 if( pIsSystemLanguage
!= NULL
)
2363 *pIsSystemLanguage
= pNumStyle
->IsSystemLanguage();
2366 return pNumStyle
->GetKey();
2372 const SvxXMLListStyleContext
*XMLTextImportHelper::FindAutoListStyle( const OUString
& rName
) const
2374 const SvxXMLListStyleContext
*pStyle
= 0;
2375 if (m_xImpl
->m_xAutoStyles
.Is())
2377 const SvXMLStyleContext
* pTempStyle
=
2378 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
2379 FindStyleChildContext( XML_STYLE_FAMILY_TEXT_LIST
, rName
,
2381 pStyle
= PTR_CAST( SvxXMLListStyleContext
,pTempStyle
);
2387 XMLPropStyleContext
*XMLTextImportHelper::FindAutoFrameStyle( const OUString
& rName
) const
2389 XMLPropStyleContext
*pStyle
= 0;
2390 if (m_xImpl
->m_xAutoStyles
.Is())
2392 const SvXMLStyleContext
* pTempStyle
=
2393 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
2394 FindStyleChildContext( XML_STYLE_FAMILY_SD_GRAPHICS_ID
, rName
,
2396 pStyle
= const_cast<XMLPropStyleContext
*>(PTR_CAST( XMLPropStyleContext
,pTempStyle
));
2402 XMLPropStyleContext
* XMLTextImportHelper::FindSectionStyle(
2403 const OUString
& rName
) const
2405 XMLPropStyleContext
* pStyle
= NULL
;
2406 if (m_xImpl
->m_xAutoStyles
.Is())
2408 const SvXMLStyleContext
* pTempStyle
=
2409 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
2410 FindStyleChildContext(
2411 XML_STYLE_FAMILY_TEXT_SECTION
,
2413 pStyle
= const_cast<XMLPropStyleContext
*>(PTR_CAST( XMLPropStyleContext
,pTempStyle
));
2419 XMLPropStyleContext
* XMLTextImportHelper::FindPageMaster(
2420 const OUString
& rName
) const
2422 XMLPropStyleContext
* pStyle
= NULL
;
2423 if (m_xImpl
->m_xAutoStyles
.Is())
2425 const SvXMLStyleContext
* pTempStyle
=
2426 static_cast<SvXMLStylesContext
*>(&m_xImpl
->m_xAutoStyles
)->
2427 FindStyleChildContext(
2428 XML_STYLE_FAMILY_PAGE_MASTER
,
2430 pStyle
= const_cast<XMLPropStyleContext
*>(PTR_CAST( XMLPropStyleContext
,pTempStyle
));
2437 void XMLTextImportHelper::PushListContext(XMLTextListBlockContext
*i_pListBlock
)
2439 GetTextListHelper().PushListContext(i_pListBlock
);
2442 void XMLTextImportHelper::PopListContext()
2444 GetTextListHelper().PopListContext();
2448 const SvXMLTokenMap
& XMLTextImportHelper::GetTextNumberedParagraphAttrTokenMap()
2450 if (!m_xImpl
->m_xTextNumberedParagraphAttrTokenMap
.get())
2452 m_xImpl
->m_xTextNumberedParagraphAttrTokenMap
.reset(
2453 new SvXMLTokenMap( aTextNumberedParagraphAttrTokenMap
) );
2455 return *m_xImpl
->m_xTextNumberedParagraphAttrTokenMap
;
2458 const SvXMLTokenMap
& XMLTextImportHelper::GetTextListBlockAttrTokenMap()
2460 if (!m_xImpl
->m_xTextListBlockAttrTokenMap
.get())
2462 m_xImpl
->m_xTextListBlockAttrTokenMap
.reset(
2463 new SvXMLTokenMap( aTextListBlockAttrTokenMap
) );
2465 return *m_xImpl
->m_xTextListBlockAttrTokenMap
;
2468 const SvXMLTokenMap
& XMLTextImportHelper::GetTextListBlockElemTokenMap()
2470 if (!m_xImpl
->m_xTextListBlockElemTokenMap
.get())
2472 m_xImpl
->m_xTextListBlockElemTokenMap
.reset(
2473 new SvXMLTokenMap( aTextListBlockElemTokenMap
) );
2475 return *m_xImpl
->m_xTextListBlockElemTokenMap
;
2478 SvI18NMap
& XMLTextImportHelper::GetRenameMap()
2480 if (!m_xImpl
->m_xRenameMap
.get())
2482 m_xImpl
->m_xRenameMap
.reset( new SvI18NMap() );
2484 return *m_xImpl
->m_xRenameMap
;
2487 void XMLTextImportHelper::InsertBookmarkStartRange(
2488 const OUString
& sName
,
2489 const Reference
<XTextRange
> & rRange
,
2490 OUString
const& i_rXmlId
,
2491 std::shared_ptr
< ::xmloff::ParsedRDFaAttributes
> & i_rpRDFaAttributes
)
2493 m_xImpl
->m_BookmarkStartRanges
[sName
] =
2494 ::boost::make_tuple(rRange
, i_rXmlId
, i_rpRDFaAttributes
);
2495 m_xImpl
->m_BookmarkVector
.push_back(sName
);
2498 bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange(
2499 const OUString
& sName
,
2500 Reference
<XTextRange
> & o_rRange
,
2501 OUString
& o_rXmlId
,
2502 std::shared_ptr
< ::xmloff::ParsedRDFaAttributes
> & o_rpRDFaAttributes
)
2504 if (m_xImpl
->m_BookmarkStartRanges
.count(sName
))
2506 Impl::BookmarkMapEntry_t
& rEntry
=
2507 (*m_xImpl
->m_BookmarkStartRanges
.find(sName
)).second
;
2508 o_rRange
.set(rEntry
.get
<0>());
2509 o_rXmlId
= rEntry
.get
<1>();
2510 o_rpRDFaAttributes
= rEntry
.get
<2>();
2511 m_xImpl
->m_BookmarkStartRanges
.erase(sName
);
2512 Impl::BookmarkVector_t::iterator
it(m_xImpl
->m_BookmarkVector
.begin());
2513 while (it
!= m_xImpl
->m_BookmarkVector
.end() && it
->compareTo(sName
)!=0)
2517 if (it
!=m_xImpl
->m_BookmarkVector
.end())
2519 m_xImpl
->m_BookmarkVector
.erase(it
);
2529 OUString
XMLTextImportHelper::FindActiveBookmarkName()
2531 if (!m_xImpl
->m_BookmarkVector
.empty())
2533 return m_xImpl
->m_BookmarkVector
.back();
2537 return OUString(); // return the empty string on error...
2541 void XMLTextImportHelper::pushFieldCtx( const OUString
& name
, const OUString
& type
)
2543 m_xImpl
->m_FieldStack
.push(Impl::field_stack_item_t(
2544 Impl::field_name_type_t(name
, type
), Impl::field_params_t()));
2547 void XMLTextImportHelper::popFieldCtx()
2549 if ( !m_xImpl
->m_FieldStack
.empty() )
2550 m_xImpl
->m_FieldStack
.pop();
2553 void XMLTextImportHelper::addFieldParam( const OUString
& name
, const OUString
& value
)
2555 assert(!m_xImpl
->m_FieldStack
.empty());
2556 if (!m_xImpl
->m_FieldStack
.empty()) {
2557 Impl::field_stack_item_t
& FieldStackItem(m_xImpl
->m_FieldStack
.top());
2558 FieldStackItem
.second
.push_back(Impl::field_param_t( name
, value
));
2562 OUString
XMLTextImportHelper::getCurrentFieldType()
2564 assert(!m_xImpl
->m_FieldStack
.empty());
2565 if (!m_xImpl
->m_FieldStack
.empty())
2567 return m_xImpl
->m_FieldStack
.top().first
.second
;
2575 bool XMLTextImportHelper::hasCurrentFieldCtx()
2577 return !m_xImpl
->m_FieldStack
.empty();
2580 void XMLTextImportHelper::setCurrentFieldParamsTo(::com::sun::star::uno::Reference
< ::com::sun::star::text::XFormField
> &xFormField
)
2582 assert(!m_xImpl
->m_FieldStack
.empty());
2583 if (!m_xImpl
->m_FieldStack
.empty() && xFormField
.is())
2585 FieldParamImporter(&m_xImpl
->m_FieldStack
.top().second
,
2586 xFormField
->getParameters()).Import();
2591 void XMLTextImportHelper::ConnectFrameChains(
2592 const OUString
& rFrmName
,
2593 const OUString
& rNextFrmName
,
2594 const Reference
< XPropertySet
>& rFrmPropSet
)
2596 static const char s_ChainNextName
[] = "ChainNextName";
2597 static const char s_ChainPrevName
[] = "ChainPrevName";
2599 if( rFrmName
.isEmpty() )
2602 if( !rNextFrmName
.isEmpty() )
2604 OUString
sNextFrmName(GetRenameMap().Get( XML_TEXT_RENAME_TYPE_FRAME
,
2606 if (m_xImpl
->m_xTextFrames
.is()
2607 && m_xImpl
->m_xTextFrames
->hasByName(sNextFrmName
))
2609 rFrmPropSet
->setPropertyValue(s_ChainNextName
,
2610 makeAny(sNextFrmName
));
2614 if (!m_xImpl
->m_xPrevFrmNames
.get())
2616 m_xImpl
->m_xPrevFrmNames
.reset( new std::vector
<OUString
> );
2617 m_xImpl
->m_xNextFrmNames
.reset( new std::vector
<OUString
> );
2619 m_xImpl
->m_xPrevFrmNames
->push_back(rFrmName
);
2620 m_xImpl
->m_xNextFrmNames
->push_back(sNextFrmName
);
2623 if (m_xImpl
->m_xPrevFrmNames
.get() && !m_xImpl
->m_xPrevFrmNames
->empty())
2625 for(std::vector
<OUString
>::iterator i
= m_xImpl
->m_xPrevFrmNames
->begin(), j
= m_xImpl
->m_xNextFrmNames
->begin(); i
!= m_xImpl
->m_xPrevFrmNames
->end() && j
!= m_xImpl
->m_xNextFrmNames
->end(); ++i
, ++j
)
2627 if((*j
).equals(rFrmName
))
2629 // The previuous frame must exist, because it existing than
2630 // inserting the entry
2631 rFrmPropSet
->setPropertyValue(s_ChainPrevName
, makeAny(*i
));
2633 i
= m_xImpl
->m_xPrevFrmNames
->erase(i
);
2634 j
= m_xImpl
->m_xNextFrmNames
->erase(j
);
2636 // There cannot be more than one previous frames
2643 bool XMLTextImportHelper::IsInFrame() const
2645 static const char s_TextFrame
[] = "TextFrame";
2647 bool bIsInFrame
= false;
2649 // are we currently in a text frame? yes, if the cursor has a
2650 // TextFrame property and it's non-NULL
2651 Reference
<XPropertySet
> xPropSet(const_cast<XMLTextImportHelper
*>(this)->GetCursor(), UNO_QUERY
);
2654 if (xPropSet
->getPropertySetInfo()->hasPropertyByName(s_TextFrame
))
2656 uno::Reference
<XTextFrame
> const xFrame(
2657 xPropSet
->getPropertyValue(s_TextFrame
), UNO_QUERY
);
2669 bool XMLTextImportHelper::IsInHeaderFooter() const
2674 Reference
< XPropertySet
> XMLTextImportHelper::createAndInsertOLEObject(
2676 const OUString
& /*rHRef*/,
2677 const OUString
& /*rStyleName*/,
2678 const OUString
& /*rTblName*/,
2679 sal_Int32
/*nWidth*/, sal_Int32
/*nHeight*/ )
2681 Reference
< XPropertySet
> xPropSet
;
2685 Reference
< XPropertySet
> XMLTextImportHelper::createAndInsertOOoLink(
2687 const OUString
& /*rHRef*/,
2688 const OUString
& /*rStyleName*/,
2689 const OUString
& /*rTblName*/,
2690 sal_Int32
/*nWidth*/, sal_Int32
/*nHeight*/ )
2692 Reference
< XPropertySet
> xPropSet
;
2696 Reference
< XPropertySet
> XMLTextImportHelper::createAndInsertApplet(
2697 const OUString
& /*rCode*/,
2698 const OUString
& /*rName*/,
2699 bool /*bMayScript*/,
2700 const OUString
& /*rHRef*/,
2701 sal_Int32
/*nWidth*/, sal_Int32
/*nHeight*/ )
2703 Reference
< XPropertySet
> xPropSet
;
2706 Reference
< XPropertySet
> XMLTextImportHelper::createAndInsertPlugin(
2707 const OUString
& /*rMimeType*/,
2708 const OUString
& /*rHRef*/,
2709 sal_Int32
/*nWidth*/, sal_Int32
/*nHeight*/ )
2711 Reference
< XPropertySet
> xPropSet
;
2714 Reference
< XPropertySet
> XMLTextImportHelper::createAndInsertFloatingFrame(
2715 const OUString
& /*rName*/,
2716 const OUString
& /*rHRef*/,
2717 const OUString
& /*rStyleName*/,
2718 sal_Int32
/*nWidth*/, sal_Int32
/*nHeight*/ )
2720 Reference
< XPropertySet
> xPropSet
;
2724 void XMLTextImportHelper::endAppletOrPlugin(
2725 const Reference
< XPropertySet
> &,
2726 std::map
< const OUString
, OUString
> &)
2729 // redline helper: dummy implementation to be overridden in sw/filter/xml
2730 void XMLTextImportHelper::RedlineAdd( const OUString
& /*rType*/,
2731 const OUString
& /*rId*/,
2732 const OUString
& /*rAuthor*/,
2733 const OUString
& /*rComment*/,
2734 const util::DateTime
& /*rDateTime*/,
2735 bool /*bMergeLastPara*/)
2737 // dummy implementation: do nothing
2740 Reference
<XTextCursor
> XMLTextImportHelper::RedlineCreateText(
2741 Reference
<XTextCursor
> & /*rOldCursor*/,
2742 const OUString
& /*rId*/)
2744 // dummy implementation: do nothing
2745 Reference
<XTextCursor
> xRet
;
2749 void XMLTextImportHelper::RedlineSetCursor(
2750 const OUString
& /*rId*/,
2752 bool /*bIsOutsideOfParagraph*/)
2754 // dummy implementation: do nothing
2757 void XMLTextImportHelper::RedlineAdjustStartNodeCursor(bool)
2759 // dummy implementation: do nothing
2762 void XMLTextImportHelper::SetShowChanges( bool )
2764 // dummy implementation: do nothing
2767 void XMLTextImportHelper::SetRecordChanges( bool )
2769 // dummy implementation: do nothing
2771 void XMLTextImportHelper::SetChangesProtectionKey(const Sequence
<sal_Int8
> &)
2773 // dummy implementation: do nothing
2777 OUString
XMLTextImportHelper::GetOpenRedlineId()
2779 return m_xImpl
->m_sOpenRedlineIdentifier
;
2782 void XMLTextImportHelper::SetOpenRedlineId( OUString
& rId
)
2784 m_xImpl
->m_sOpenRedlineIdentifier
= rId
;
2787 void XMLTextImportHelper::ResetOpenRedlineId()
2790 SetOpenRedlineId(sEmpty
);
2794 XMLTextImportHelper::SetCellParaStyleDefault(OUString
const& rNewValue
)
2796 m_xImpl
->m_sCellParaStyleDefault
= rNewValue
;
2799 OUString
const& XMLTextImportHelper::GetCellParaStyleDefault()
2801 return m_xImpl
->m_sCellParaStyleDefault
;
2804 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */