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

Generated by: LCOV version 1.10