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

Generated by: LCOV version 1.10