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