LCOV - code coverage report
Current view: top level - xmloff/source/text - txtimp.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 766 991 77.3 %
Date: 2015-06-13 12:38:46 Functions: 83 104 79.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11