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