LCOV - code coverage report
Current view: top level - xmloff/source/text - txtflde.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 569 1283 44.3 %
Date: 2015-06-13 12:38:46 Functions: 45 65 69.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             : /** @#file
      22             :  *
      23             :  *  export of all text fields
      24             :  */
      25             : #include "txtflde.hxx"
      26             : #include <xmloff/XMLEventExport.hxx>
      27             : #include <xmloff/families.hxx>
      28             : #include <xmloff/nmspmap.hxx>
      29             : #include <xmloff/numehelp.hxx>
      30             : #include <xmloff/xmlement.hxx>
      31             : #include <xmloff/xmlexp.hxx>
      32             : #include <xmloff/xmlnume.hxx>
      33             : #include <xmloff/xmlnumfe.hxx>
      34             : #include <xmloff/xmltoken.hxx>
      35             : #include <xmloff/xmluconv.hxx>
      36             : #include <xmloff/maptype.hxx>
      37             : 
      38             : #include "XMLTextCharStyleNamesElementExport.hxx"
      39             : #include <sax/tools/converter.hxx>
      40             : 
      41             : #include <com/sun/star/util/DateTime.hpp>
      42             : #include <com/sun/star/util/Date.hpp>
      43             : #include <com/sun/star/lang/XServiceInfo.hpp>
      44             : #include <com/sun/star/text/UserDataPart.hpp>
      45             : #include <com/sun/star/text/PageNumberType.hpp>
      46             : #include <com/sun/star/style/NumberingType.hpp>
      47             : #include <com/sun/star/text/ReferenceFieldPart.hpp>
      48             : #include <com/sun/star/text/ReferenceFieldSource.hpp>
      49             : #include <com/sun/star/beans/XPropertySet.hpp>
      50             : #include <com/sun/star/beans/XPropertyState.hpp>
      51             : #include <com/sun/star/text/XTextField.hpp>
      52             : #include <com/sun/star/text/XDependentTextField.hpp>
      53             : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
      54             : 
      55             : #include <com/sun/star/text/SetVariableType.hpp>
      56             : #include <com/sun/star/text/PlaceholderType.hpp>
      57             : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
      58             : #include <com/sun/star/text/ChapterFormat.hpp>
      59             : #include <com/sun/star/text/TemplateDisplayFormat.hpp>
      60             : #include <com/sun/star/frame/XModel.hpp>
      61             : #include <com/sun/star/container/XNameReplace.hpp>
      62             : #include <com/sun/star/uno/Sequence.h>
      63             : #include <com/sun/star/util/NumberFormat.hpp>
      64             : #include <com/sun/star/text/BibliographyDataType.hpp>
      65             : #include <com/sun/star/sdb/CommandType.hpp>
      66             : #include <com/sun/star/rdf/XMetadatable.hpp>
      67             : #include <rtl/ustrbuf.hxx>
      68             : #include <tools/debug.hxx>
      69             : #include <rtl/math.hxx>
      70             : 
      71             : #include <vector>
      72             : 
      73             : 
      74             : using namespace ::std;
      75             : using namespace ::com::sun::star;
      76             : using namespace ::com::sun::star::uno;
      77             : using namespace ::com::sun::star::text;
      78             : using namespace ::com::sun::star::lang;
      79             : using namespace ::com::sun::star::beans;
      80             : using namespace ::com::sun::star::util;
      81             : using namespace ::com::sun::star::style;
      82             : using namespace ::com::sun::star::document;
      83             : using namespace ::com::sun::star::container;
      84             : using namespace ::xmloff::token;
      85             : 
      86             : 
      87             : static sal_Char const FIELD_SERVICE_SENDER[] = "ExtendedUser";
      88             : static sal_Char const FIELD_SERVICE_AUTHOR[] = "Author";
      89             : static sal_Char const FIELD_SERVICE_JUMPEDIT[] = "JumpEdit";
      90             : static sal_Char const FIELD_SERVICE_GETEXP[] = "GetExpression";
      91             : static sal_Char const FIELD_SERVICE_SETEXP[] = "SetExpression";
      92             : static sal_Char const FIELD_SERVICE_USER[] = "User";
      93             : static sal_Char const FIELD_SERVICE_INPUT[] = "Input";
      94             : static sal_Char const FIELD_SERVICE_USERINPUT[] = "InputUser";
      95             : static sal_Char const FIELD_SERVICE_DATETIME[] = "DateTime";
      96             : static sal_Char const FIELD_SERVICE_PAGENUMBER[] = "PageNumber";
      97             : static sal_Char const FIELD_SERVICE_DB_NEXT[] = "DatabaseNextSet";
      98             : static sal_Char const FIELD_SERVICE_DB_SELECT[] = "DatabaseNumberOfSet";
      99             : static sal_Char const FIELD_SERVICE_DB_NUMBER[] = "DatabaseSetNumber";
     100             : static sal_Char const FIELD_SERVICE_DB_DISPLAY[] = "Database";
     101             : static sal_Char const FIELD_SERVICE_DB_NAME[] = "DatabaseName";
     102             : static sal_Char const FIELD_SERVICE_CONDITIONAL_TEXT[] = "ConditionalText";
     103             : static sal_Char const FIELD_SERVICE_HIDDEN_TEXT[] = "HiddenText";
     104             : static sal_Char const FIELD_SERVICE_HIDDEN_PARAGRAPH[] = "HiddenParagraph";
     105             : static sal_Char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR[] = "DocInfo.ChangeAuthor";
     106             : static sal_Char const FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2[] = "docinfo.ChangeAuthor";
     107             : static sal_Char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME[] = "DocInfo.ChangeDateTime";
     108             : static sal_Char const FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2[] = "docinfo.ChangeDateTime";
     109             : static sal_Char const FIELD_SERVICE_DOC_INFO_EDIT_TIME[] = "DocInfo.EditTime";
     110             : static sal_Char const FIELD_SERVICE_DOC_INFO_EDIT_TIME2[] = "docinfo.EditTime";
     111             : static sal_Char const FIELD_SERVICE_DOC_INFO_DESCRIPTION[] = "DocInfo.Description";
     112             : static sal_Char const FIELD_SERVICE_DOC_INFO_DESCRIPTION2[] = "docinfo.Description";
     113             : static sal_Char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR[] = "DocInfo.CreateAuthor";
     114             : static sal_Char const FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2[] = "docinfo.CreateAuthor";
     115             : static sal_Char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME[] = "DocInfo.CreateDateTime";
     116             : static sal_Char const FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2[] = "docinfo.CreateDateTime";
     117             : static sal_Char const FIELD_SERVICE_DOC_INFO_CUSTOM[] = "DocInfo.Custom";
     118             : static sal_Char const FIELD_SERVICE_DOC_INFO_CUSTOM2[] = "docinfo.Custom";
     119             : static sal_Char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR[] = "DocInfo.PrintAuthor";
     120             : static sal_Char const FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2[] = "docinfo.PrintAuthor";
     121             : static sal_Char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME[] = "DocInfo.PrintDateTime";
     122             : static sal_Char const FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2[] = "docinfo.PrintDateTime";
     123             : static sal_Char const FIELD_SERVICE_DOC_INFO_KEY_WORDS[] = "DocInfo.KeyWords";
     124             : static sal_Char const FIELD_SERVICE_DOC_INFO_KEY_WORDS2[] = "docinfo.KeyWords";
     125             : static sal_Char const FIELD_SERVICE_DOC_INFO_SUBJECT[] = "DocInfo.Subject";
     126             : static sal_Char const FIELD_SERVICE_DOC_INFO_SUBJECT2[] = "docinfo.Subject";
     127             : static sal_Char const FIELD_SERVICE_DOC_INFO_TITLE[] = "DocInfo.Title";
     128             : static sal_Char const FIELD_SERVICE_DOC_INFO_TITLE2[] = "docinfo.Title";
     129             : static sal_Char const FIELD_SERVICE_DOC_INFO_REVISION[] = "DocInfo.Revision";
     130             : static sal_Char const FIELD_SERVICE_DOC_INFO_REVISION2[] = "docinfo.Revision";
     131             : static sal_Char const FIELD_SERVICE_FILE_NAME[] = "FileName";
     132             : static sal_Char const FIELD_SERVICE_CHAPTER[] = "Chapter";
     133             : static sal_Char const FIELD_SERVICE_TEMPLATE_NAME[] = "TemplateName";
     134             : static sal_Char const FIELD_SERVICE_PAGE_COUNT[] = "PageCount";
     135             : static sal_Char const FIELD_SERVICE_PARAGRAPH_COUNT[] = "ParagraphCount";
     136             : static sal_Char const FIELD_SERVICE_WORD_COUNT[] = "WordCount";
     137             : static sal_Char const FIELD_SERVICE_CHARACTER_COUNT[] = "CharacterCount";
     138             : static sal_Char const FIELD_SERVICE_TABLE_COUNT[] = "TableCount";
     139             : static sal_Char const FIELD_SERVICE_GRAPHIC_COUNT[] = "GraphicObjectCount";
     140             : static sal_Char const FIELD_SERVICE_OBJECT_COUNT[] = "EmbeddedObjectCount";
     141             : static sal_Char const FIELD_SERVICE_REFERENCE_PAGE_SET[] = "ReferencePageSet";
     142             : static sal_Char const FIELD_SERVICE_REFERENCE_PAGE_GET[] = "ReferencePageGet";
     143             : static sal_Char const FIELD_SERVICE_SHEET_NAME[] = "SheetName";
     144             : static sal_Char const FIELD_SERVICE_PAGE_NAME[] = "PageName";
     145             : static sal_Char const FIELD_SERVICE_MACRO[] = "Macro";
     146             : static sal_Char const FIELD_SERVICE_GET_REFERENCE[] = "GetReference";
     147             : static sal_Char const FIELD_SERVICE_DDE[] = "DDE";
     148             : static sal_Char const FIELD_SERVICE_URL[] = "URL";
     149             : static sal_Char const FIELD_SERVICE_BIBLIOGRAPHY[] = "Bibliography";
     150             : static sal_Char const FIELD_SERVICE_SCRIPT[] = "Script";
     151             : static sal_Char const FIELD_SERVICE_ANNOTATION[] = "Annotation";
     152             : static sal_Char const FIELD_SERVICE_COMBINED_CHARACTERS[] = "CombinedCharacters";
     153             : static sal_Char const FIELD_SERVICE_META[] = "MetadataField";
     154             : static sal_Char const FIELD_SERVICE_MEASURE[] = "Measure";
     155             : static sal_Char const FIELD_SERVICE_TABLE_FORMULA[] = "TableFormula";
     156             : static sal_Char const FIELD_SERVICE_DROP_DOWN[] = "DropDown";
     157             : 
     158             : SvXMLEnumStringMapEntry const aFieldServiceNameMapping[] =
     159             : {
     160             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SENDER, FIELD_ID_SENDER ),
     161             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_AUTHOR, FIELD_ID_AUTHOR ),
     162             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_JUMPEDIT, FIELD_ID_PLACEHOLDER ),
     163             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GETEXP, FIELD_ID_VARIABLE_GET ),
     164             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SETEXP, FIELD_ID_VARIABLE_SET ),
     165             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USER, FIELD_ID_USER_GET ),
     166             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_INPUT, FIELD_ID_TEXT_INPUT ),
     167             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USERINPUT, FIELD_ID_USER_INPUT ),
     168             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DATETIME, FIELD_ID_TIME ),
     169             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGENUMBER, FIELD_ID_PAGENUMBER ),
     170             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_SET, FIELD_ID_REFPAGE_SET ),
     171             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_GET, FIELD_ID_REFPAGE_GET ),
     172             : 
     173             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NEXT, FIELD_ID_DATABASE_NEXT ),
     174             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_SELECT, FIELD_ID_DATABASE_SELECT ),
     175             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NUMBER, FIELD_ID_DATABASE_NUMBER ),
     176             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_DISPLAY, FIELD_ID_DATABASE_DISPLAY ),
     177             :     // workaround for #no-bug#: Database/DataBase
     178             :     ENUM_STRING_MAP_ENTRY( "DataBase", FIELD_ID_DATABASE_DISPLAY ),
     179             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NAME, FIELD_ID_DATABASE_NAME ),
     180             : 
     181             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR, FIELD_ID_DOCINFO_CREATION_AUTHOR ),
     182             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR2, FIELD_ID_DOCINFO_CREATION_AUTHOR ),
     183             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME, FIELD_ID_DOCINFO_CREATION_TIME),
     184             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME2, FIELD_ID_DOCINFO_CREATION_TIME),
     185             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR, FIELD_ID_DOCINFO_SAVE_AUTHOR ),
     186             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR2, FIELD_ID_DOCINFO_SAVE_AUTHOR ),
     187             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME, FIELD_ID_DOCINFO_SAVE_TIME ),
     188             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME2, FIELD_ID_DOCINFO_SAVE_TIME ),
     189             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME, FIELD_ID_DOCINFO_EDIT_DURATION ),
     190             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME2, FIELD_ID_DOCINFO_EDIT_DURATION ),
     191             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION, FIELD_ID_DOCINFO_DESCRIPTION ),
     192             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION2, FIELD_ID_DOCINFO_DESCRIPTION ),
     193             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM, FIELD_ID_DOCINFO_CUSTOM ),
     194             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM2, FIELD_ID_DOCINFO_CUSTOM ),
     195             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR, FIELD_ID_DOCINFO_PRINT_AUTHOR ),
     196             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR2, FIELD_ID_DOCINFO_PRINT_AUTHOR ),
     197             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME, FIELD_ID_DOCINFO_PRINT_TIME ),
     198             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME2, FIELD_ID_DOCINFO_PRINT_TIME ),
     199             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS, FIELD_ID_DOCINFO_KEYWORDS ),
     200             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS2, FIELD_ID_DOCINFO_KEYWORDS ),
     201             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT, FIELD_ID_DOCINFO_SUBJECT ),
     202             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT2, FIELD_ID_DOCINFO_SUBJECT ),
     203             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE, FIELD_ID_DOCINFO_TITLE ),
     204             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE2, FIELD_ID_DOCINFO_TITLE ),
     205             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION, FIELD_ID_DOCINFO_REVISION ),
     206             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION2, FIELD_ID_DOCINFO_REVISION ),
     207             : 
     208             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CONDITIONAL_TEXT, FIELD_ID_CONDITIONAL_TEXT ),
     209             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_TEXT, FIELD_ID_HIDDEN_TEXT ),
     210             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_PARAGRAPH, FIELD_ID_HIDDEN_PARAGRAPH ),
     211             : 
     212             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_FILE_NAME, FIELD_ID_FILE_NAME ),
     213             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHAPTER, FIELD_ID_CHAPTER ),
     214             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TEMPLATE_NAME, FIELD_ID_TEMPLATE_NAME ),
     215             : 
     216             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT, FIELD_ID_COUNT_PAGES ),
     217             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PARAGRAPH_COUNT, FIELD_ID_COUNT_PARAGRAPHS ),
     218             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_WORD_COUNT, FIELD_ID_COUNT_WORDS ),
     219             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHARACTER_COUNT, FIELD_ID_COUNT_CHARACTERS ),
     220             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_COUNT, FIELD_ID_COUNT_TABLES ),
     221             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GRAPHIC_COUNT, FIELD_ID_COUNT_GRAPHICS ),
     222             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_OBJECT_COUNT, FIELD_ID_COUNT_OBJECTS ),
     223             : 
     224             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MACRO, FIELD_ID_MACRO ),
     225             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GET_REFERENCE, FIELD_ID_REF_REFERENCE ),
     226             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DDE, FIELD_ID_DDE ),
     227             : 
     228             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY, FIELD_ID_BIBLIOGRAPHY ),
     229             : 
     230             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT, FIELD_ID_SCRIPT ),
     231             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION, FIELD_ID_ANNOTATION ),
     232             : 
     233             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS, FIELD_ID_COMBINED_CHARACTERS ),
     234             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META, FIELD_ID_META ),
     235             : 
     236             :     // non-writer fields
     237             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME, FIELD_ID_SHEET_NAME ),
     238             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_NAME, FIELD_ID_PAGENAME ),
     239             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_URL, FIELD_ID_URL ),
     240             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MEASURE, FIELD_ID_MEASURE ),
     241             : 
     242             :     // deprecated fields
     243             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_FORMULA, FIELD_ID_TABLE_FORMULA ),
     244             :     ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DROP_DOWN, FIELD_ID_DROP_DOWN ),
     245             : 
     246             :     ENUM_STRING_MAP_END()
     247             : };
     248             : 
     249             : 
     250             : 
     251             : // property accessor helper functions
     252             : inline bool GetBoolProperty(const OUString&,
     253             :                                       const Reference<XPropertySet> &);
     254             : inline bool GetOptionalBoolProperty(const OUString&,
     255             :                                               const Reference<XPropertySet> &,
     256             :                                               const Reference<XPropertySetInfo> &,
     257             :                                               bool bDefault);
     258             : inline double GetDoubleProperty(const OUString&,
     259             :                                       const Reference<XPropertySet> &);
     260             : inline OUString const GetStringProperty(const OUString&,
     261             :                                         const Reference<XPropertySet> &);
     262             : inline sal_Int32 GetIntProperty(const OUString&,
     263             :                                       const Reference<XPropertySet> &);
     264             : inline sal_Int16 GetInt16Property(const OUString&,
     265             :                                         const Reference<XPropertySet> &);
     266             : inline sal_Int8 GetInt8Property(const OUString&,
     267             :                                       const Reference<XPropertySet> &);
     268             : inline util::DateTime const GetDateTimeProperty( const OUString& sPropName,
     269             :                                            const Reference<XPropertySet> & xPropSet);
     270             : inline Sequence<OUString> const GetStringSequenceProperty(
     271             :                                    const OUString& sPropName,
     272             :                                    const Reference<XPropertySet> & xPropSet);
     273             : 
     274             : 
     275             : 
     276        1059 : XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
     277             :                                         XMLPropertyState* pCombinedCharState)
     278             :     : rExport(rExp),
     279             :       pUsedMasters(NULL),
     280             :       sServicePrefix("com.sun.star.text.textfield."),
     281             :       sFieldMasterPrefix("com.sun.star.text.FieldMaster."),
     282             :       sPresentationServicePrefix("com.sun.star.presentation.TextField."),
     283             : 
     284             :     sPropertyAdjust("Adjust"),
     285             :     sPropertyAuthor("Author"),
     286             :     sPropertyChapterFormat("ChapterFormat"),
     287             :     sPropertyChapterNumberingLevel("ChapterNumberingLevel"),
     288             :     sPropertyCharStyleNames("CharStyleNames"),
     289             :     sPropertyCondition("Condition"),
     290             :     sPropertyContent("Content"),
     291             :     sPropertyDataBaseName("DataBaseName"),
     292             :     sPropertyDataBaseURL("DataBaseURL"),
     293             :     sPropertyDataColumnName("DataColumnName"),
     294             :     sPropertyDataCommandType("DataCommandType"),
     295             :     sPropertyDataTableName("DataTableName"),
     296             :     sPropertyDateTime("DateTime"),
     297             :     sPropertyDateTimeValue("DateTimeValue"),
     298             :     sPropertyDDECommandElement("DDECommandElement"),
     299             :     sPropertyDDECommandFile("DDECommandFile"),
     300             :     sPropertyDDECommandType("DDECommandType"),
     301             :     sPropertyDependentTextFields("DependentTextFields"),
     302             :     sPropertyFalseContent("FalseContent"),
     303             :     sPropertyFields("Fields"),
     304             :     sPropertyFieldSubType("UserDataType"),
     305             :     sPropertyFileFormat("FileFormat"),
     306             :     sPropertyFullName("FullName"),
     307             :     sPropertyHint("Hint"),
     308             :     sPropertyInitials("Initials"),
     309             :     sPropertyInstanceName("InstanceName"),
     310             :     sPropertyIsAutomaticUpdate("IsAutomaticUpdate"),
     311             :     sPropertyIsConditionTrue("IsConditionTrue"),
     312             :     sPropertyIsDataBaseFormat("DataBaseFormat"),
     313             :     sPropertyIsDate("IsDate"),
     314             :     sPropertyIsExpression("IsExpression"),
     315             :     sPropertyIsFixed("IsFixed"),
     316             :     sPropertyIsFixedLanguage("IsFixedLanguage"),
     317             :     sPropertyIsHidden("IsHidden"),
     318             :     sPropertyIsInput("Input"),
     319             :     sPropertyIsShowFormula("IsShowFormula"),
     320             :     sPropertyIsVisible("IsVisible"),
     321             :     sPropertyItems("Items"),
     322             :     sPropertyLevel("Level"),
     323             :     sPropertyMeasureKind("Kind"),
     324             :     sPropertyName("Name"),
     325             :     sPropertyNumberFormat("NumberFormat"),
     326             :     sPropertyNumberingSeparator("NumberingSeparator"),
     327             :     sPropertyNumberingType("NumberingType"),
     328             :     sPropertyOffset("Offset"),
     329             :     sPropertyOn("On"),
     330             :     sPropertyPlaceholderType("PlaceHolderType"),
     331             :     sPropertyReferenceFieldPart("ReferenceFieldPart"),
     332             :     sPropertyReferenceFieldSource("ReferenceFieldSource"),
     333             :     sPropertyScriptType("ScriptType"),
     334             :     sPropertySelectedItem("SelectedItem"),
     335             :     sPropertySequenceNumber("SequenceNumber"),
     336             :     sPropertySequenceValue("SequenceValue"),
     337             :     sPropertySetNumber("SetNumber"),
     338             :     sPropertySourceName("SourceName"),
     339             :     sPropertySubType("SubType"),
     340             :     sPropertyTargetFrame("TargetFrame"),
     341             :     sPropertyTrueContent("TrueContent"),
     342             :     sPropertyURL("URL"),
     343             :     sPropertyURLContent("URLContent"),
     344             :     sPropertyUserText("UserText"),
     345             :     sPropertyValue("Value"),
     346             :     sPropertyVariableName("VariableName"),
     347             :       sPropertyHelp("Help"),
     348             :       sPropertyTooltip("Tooltip"),
     349             :       sPropertyTextRange("TextRange"),
     350        1059 :       pCombinedCharactersPropertyState(pCombinedCharState)
     351             : {
     352        1059 :     SetExportOnlyUsedFieldDeclarations();
     353        1059 : }
     354             : 
     355        3177 : XMLTextFieldExport::~XMLTextFieldExport()
     356             : {
     357        1059 :     delete pCombinedCharactersPropertyState;
     358        1059 :     delete pUsedMasters;
     359        2118 : }
     360             : 
     361             : /// get the field ID (as in FieldIDEnum) from XTextField
     362         873 : enum FieldIdEnum XMLTextFieldExport::GetFieldID(
     363             :     const Reference<XTextField> & rTextField,
     364             :     const Reference<XPropertySet> & xPropSet)
     365             : {
     366             :     // get service names for rTextField (via XServiceInfo service)
     367         873 :     Reference<XServiceInfo> xService(rTextField, UNO_QUERY);
     368        1746 :     const Sequence<OUString> aServices = xService->getSupportedServiceNames();
     369         873 :     const OUString* pNames = aServices.getConstArray();
     370         873 :     sal_Int32 nCount = aServices.getLength();
     371             : 
     372        1746 :     OUString sFieldName;    // service name postfix of current field
     373             : 
     374             :     // search for TextField service name
     375        3214 :     while( nCount-- )
     376             :     {
     377        2237 :         if (pNames->matchIgnoreAsciiCase(sServicePrefix))
     378             :         {
     379             :             // TextField found => postfix is field type!
     380         769 :             sFieldName = pNames->copy(sServicePrefix.getLength());
     381         769 :             break;
     382             :         }
     383             : 
     384        1468 :         ++pNames;
     385             :     }
     386             : 
     387             :     // if this is not a normal text field, check if it's a presentation text field
     388         873 :     if( sFieldName.isEmpty() )
     389             :     {
     390         104 :         const OUString* pNames2 = aServices.getConstArray();
     391         104 :         sal_Int32 nCount2 = aServices.getLength();
     392             :         // search for TextField service name
     393         416 :         while( nCount2-- )
     394             :         {
     395         312 :             if( 0 == pNames2->compareTo(sPresentationServicePrefix, sPresentationServicePrefix.getLength()))
     396             :             {
     397             :                 // TextField found => postfix is field type!
     398         104 :                 sFieldName = pNames2->copy(sPresentationServicePrefix.getLength());
     399         104 :                 break;
     400             :             }
     401             : 
     402         208 :             ++pNames2;
     403             :         }
     404             : 
     405         104 :         if( !sFieldName.isEmpty() )
     406             :         {
     407         104 :             if( sFieldName == "Header" )
     408             :             {
     409          28 :                 return FIELD_ID_DRAW_HEADER;
     410             :             }
     411          76 :             else if( sFieldName == "Footer" )
     412             :             {
     413          38 :                 return FIELD_ID_DRAW_FOOTER;
     414             :             }
     415          38 :             else if( sFieldName == "DateTime" )
     416             :             {
     417          38 :                 return FIELD_ID_DRAW_DATE_TIME;
     418             :             }
     419             :         }
     420             :     }
     421             : 
     422             :     // map postfix of service name to field ID
     423             :     DBG_ASSERT(!sFieldName.isEmpty(), "no TextField service found!");
     424        1642 :     return MapFieldName(sFieldName, xPropSet);
     425             : }
     426             : 
     427         769 : enum FieldIdEnum XMLTextFieldExport::MapFieldName(
     428             :     const OUString& sFieldName,             // field (master) name
     429             :     const Reference<XPropertySet> & xPropSet)   // for subtype
     430             : {
     431             :     // we'll proceed in 2 steps:
     432             :     // a) map service name to preliminary FIELD_ID
     433             :     // b) map those prelim. FIELD_IDs that correspond to several field types
     434             :     //    (in our (XML) world) to final FIELD IDs
     435             : 
     436             : 
     437             :     // a) find prelim. FIELD_ID via aFieldServiceMapping
     438             : 
     439             :     // check for non-empty service name
     440             :     DBG_ASSERT(!sFieldName.isEmpty(), "no valid service name!");
     441         769 :     enum FieldIdEnum nToken = FIELD_ID_UNKNOWN;
     442         769 :     if (!sFieldName.isEmpty())
     443             :     {
     444             :         // map name to prelim. ID
     445             :         sal_uInt16 nTmp;
     446             :         bool bRet = SvXMLUnitConverter::convertEnum(
     447         769 :             nTmp, sFieldName, aFieldServiceNameMapping);
     448             : 
     449             :         // check return
     450             :         DBG_ASSERT(bRet, "Unknown field service name encountered!");
     451         769 :         if (! bRet)
     452             :         {
     453           0 :             nToken = FIELD_ID_UNKNOWN;
     454             :         }
     455             :         else
     456             :         {
     457         769 :             nToken = (enum FieldIdEnum)nTmp;
     458             :         }
     459             :     } else {
     460             :         // invalid service name
     461           0 :         nToken = FIELD_ID_UNKNOWN;
     462             :     }
     463             : 
     464             :     // b) map prelim. to final FIELD_IDs
     465         769 :     switch (nToken) {
     466             :         case FIELD_ID_VARIABLE_SET:
     467           2 :             if (GetBoolProperty(sPropertyIsInput, xPropSet))
     468             :             {
     469           0 :                 nToken = FIELD_ID_VARIABLE_INPUT;
     470             :             }
     471             :             else
     472             :             {
     473           2 :                 switch (GetIntProperty(sPropertySubType, xPropSet))
     474             :                 {
     475             :                     case SetVariableType::STRING:   // text field
     476             :                     case SetVariableType::VAR:      // num field
     477           2 :                         nToken = FIELD_ID_VARIABLE_SET;
     478           2 :                         break;
     479             :                     case SetVariableType::SEQUENCE:
     480           0 :                         nToken = FIELD_ID_SEQUENCE;
     481           0 :                         break;
     482             :                     case SetVariableType::FORMULA:
     483             :                     default:
     484           0 :                         nToken = FIELD_ID_UNKNOWN;
     485           0 :                         break;
     486             :                 }
     487             :             }
     488           2 :             break;
     489             : 
     490             :         case FIELD_ID_VARIABLE_GET:
     491           0 :             switch (GetIntProperty(sPropertySubType, xPropSet))
     492             :             {
     493             :                 case SetVariableType::STRING:   // text field
     494             :                 case SetVariableType::VAR:      // num field
     495           0 :                     nToken = FIELD_ID_VARIABLE_GET;
     496           0 :                     break;
     497             :                 case SetVariableType::FORMULA:
     498           0 :                     nToken = FIELD_ID_EXPRESSION;
     499           0 :                     break;
     500             :                 case SetVariableType::SEQUENCE:
     501             :                 default:
     502           0 :                     nToken = FIELD_ID_UNKNOWN;
     503           0 :                     break;
     504             :             }
     505           0 :             break;
     506             : 
     507             :         case FIELD_ID_TIME:
     508         124 :             if (GetBoolProperty(sPropertyIsDate, xPropSet))
     509             :             {
     510          66 :                 nToken = FIELD_ID_DATE;
     511             :             }
     512         124 :             break;
     513             : 
     514             :         case FIELD_ID_PAGENUMBER:
     515             :             // NumberingType not available in non-Writer apps
     516         366 :             if (xPropSet->getPropertySetInfo()->
     517         183 :                 hasPropertyByName(sPropertyNumberingType))
     518             :             {
     519          27 :                 if (NumberingType::CHAR_SPECIAL == GetIntProperty(
     520          27 :                                             sPropertyNumberingType, xPropSet))
     521             :                 {
     522           0 :                     nToken = FIELD_ID_PAGESTRING;
     523             :                 }
     524             :             }
     525         183 :             break;
     526             : 
     527             :         case FIELD_ID_DOCINFO_CREATION_TIME:
     528           0 :              if (GetBoolProperty(sPropertyIsDate, xPropSet))
     529             :             {
     530           0 :                 nToken = FIELD_ID_DOCINFO_CREATION_DATE;
     531             :             }
     532           0 :             break;
     533             : 
     534             :         case FIELD_ID_DOCINFO_PRINT_TIME:
     535           0 :              if (GetBoolProperty(sPropertyIsDate, xPropSet))
     536             :             {
     537           0 :                 nToken = FIELD_ID_DOCINFO_PRINT_DATE;
     538             :             }
     539           0 :             break;
     540             : 
     541             :         case FIELD_ID_DOCINFO_SAVE_TIME:
     542           0 :              if (GetBoolProperty(sPropertyIsDate, xPropSet))
     543             :             {
     544           0 :                 nToken = FIELD_ID_DOCINFO_SAVE_DATE;
     545             :             }
     546           0 :             break;
     547             : 
     548             :         case FIELD_ID_REF_REFERENCE:
     549           0 :             switch (GetInt16Property(sPropertyReferenceFieldSource, xPropSet))
     550             :             {
     551             :                 case ReferenceFieldSource::REFERENCE_MARK:
     552           0 :                     nToken = FIELD_ID_REF_REFERENCE;
     553           0 :                     break;
     554             :                 case ReferenceFieldSource::SEQUENCE_FIELD:
     555           0 :                     nToken = FIELD_ID_REF_SEQUENCE;
     556           0 :                     break;
     557             :                 case ReferenceFieldSource::BOOKMARK:
     558           0 :                     nToken = FIELD_ID_REF_BOOKMARK;
     559           0 :                     break;
     560             :                 case ReferenceFieldSource::FOOTNOTE:
     561           0 :                     nToken = FIELD_ID_REF_FOOTNOTE;
     562           0 :                     break;
     563             :                 case ReferenceFieldSource::ENDNOTE:
     564           0 :                     nToken = FIELD_ID_REF_ENDNOTE;
     565           0 :                     break;
     566             :                 default:
     567           0 :                     nToken = FIELD_ID_UNKNOWN;
     568           0 :                     break;
     569             :             }
     570           0 :             break;
     571             : 
     572             :         case FIELD_ID_COMBINED_CHARACTERS:
     573             :         case FIELD_ID_SCRIPT:
     574             :         case FIELD_ID_ANNOTATION:
     575             :         case FIELD_ID_BIBLIOGRAPHY:
     576             :         case FIELD_ID_DDE:
     577             :         case FIELD_ID_MACRO:
     578             :         case FIELD_ID_REFPAGE_SET:
     579             :         case FIELD_ID_REFPAGE_GET:
     580             :         case FIELD_ID_COUNT_PAGES:
     581             :         case FIELD_ID_COUNT_PARAGRAPHS:
     582             :         case FIELD_ID_COUNT_WORDS:
     583             :         case FIELD_ID_COUNT_CHARACTERS:
     584             :         case FIELD_ID_COUNT_TABLES:
     585             :         case FIELD_ID_COUNT_GRAPHICS:
     586             :         case FIELD_ID_COUNT_OBJECTS:
     587             :         case FIELD_ID_CONDITIONAL_TEXT:
     588             :         case FIELD_ID_HIDDEN_TEXT:
     589             :         case FIELD_ID_HIDDEN_PARAGRAPH:
     590             :         case FIELD_ID_DOCINFO_CREATION_AUTHOR:
     591             :         case FIELD_ID_DOCINFO_DESCRIPTION:
     592             :         case FIELD_ID_DOCINFO_CUSTOM:
     593             :         case FIELD_ID_DOCINFO_PRINT_AUTHOR:
     594             :         case FIELD_ID_DOCINFO_TITLE:
     595             :         case FIELD_ID_DOCINFO_SUBJECT:
     596             :         case FIELD_ID_DOCINFO_KEYWORDS:
     597             :         case FIELD_ID_DOCINFO_REVISION:
     598             :         case FIELD_ID_DOCINFO_EDIT_DURATION:
     599             :         case FIELD_ID_DOCINFO_SAVE_AUTHOR:
     600             :         case FIELD_ID_TEXT_INPUT:
     601             :         case FIELD_ID_USER_INPUT:
     602             :         case FIELD_ID_AUTHOR:
     603             :         case FIELD_ID_SENDER:
     604             :         case FIELD_ID_PLACEHOLDER:
     605             :         case FIELD_ID_USER_GET:
     606             :         case FIELD_ID_DATABASE_NEXT:
     607             :         case FIELD_ID_DATABASE_SELECT:
     608             :         case FIELD_ID_DATABASE_DISPLAY:
     609             :         case FIELD_ID_DATABASE_NAME:
     610             :         case FIELD_ID_DATABASE_NUMBER:
     611             :         case FIELD_ID_TEMPLATE_NAME:
     612             :         case FIELD_ID_CHAPTER:
     613             :         case FIELD_ID_FILE_NAME:
     614             :         case FIELD_ID_META:
     615             :         case FIELD_ID_SHEET_NAME:
     616             :         case FIELD_ID_PAGENAME:
     617             :         case FIELD_ID_MEASURE:
     618             :         case FIELD_ID_URL:
     619             :         case FIELD_ID_TABLE_FORMULA:
     620             :         case FIELD_ID_DROP_DOWN:
     621             :             ; // these field IDs are final
     622         460 :             break;
     623             : 
     624             :         default:
     625           0 :             nToken = FIELD_ID_UNKNOWN;
     626             :     }
     627             : 
     628             :     // ... and return final FIELD_ID
     629         769 :     return nToken;
     630             : }
     631             : 
     632             : // is string or numeric field?
     633          12 : bool XMLTextFieldExport::IsStringField(
     634             :     FieldIdEnum nFieldType,
     635             :     const Reference<XPropertySet> & xPropSet)
     636             : {
     637          12 :     switch (nFieldType) {
     638             : 
     639             :     case FIELD_ID_VARIABLE_GET:
     640             :     case FIELD_ID_VARIABLE_SET:
     641             :     case FIELD_ID_VARIABLE_INPUT:
     642             :     {
     643             :         // depends on field sub type
     644           2 :         return ( GetIntProperty(sPropertySubType, xPropSet) ==
     645           2 :                  SetVariableType::STRING                    );
     646             :     }
     647             : 
     648             :     case FIELD_ID_USER_GET:
     649             :     case FIELD_ID_USER_INPUT:
     650             :     {
     651           0 :         Reference<XTextField> xTextField(xPropSet, UNO_QUERY);
     652             :         DBG_ASSERT(xTextField.is(), "field is no XTextField!");
     653             :         bool bRet = GetBoolProperty(sPropertyIsExpression,
     654           0 :                                         GetMasterPropertySet(xTextField));
     655           0 :         return !bRet;
     656             :     }
     657             : 
     658             :     case FIELD_ID_META:
     659          10 :         return 0 > GetIntProperty(sPropertyNumberFormat, xPropSet);
     660             : 
     661             :     case FIELD_ID_DATABASE_DISPLAY:
     662             :         // TODO: depends on... ???
     663             :         // workaround #no-bug#: no data type
     664           0 :         return 5100 == GetIntProperty(sPropertyNumberFormat, xPropSet);
     665             : 
     666             :     case FIELD_ID_TABLE_FORMULA:
     667             :         // legacy field: always a number field (because it always has
     668             :         // a number format)
     669           0 :         return false;
     670             : 
     671             :     case FIELD_ID_COUNT_PAGES:
     672             :     case FIELD_ID_COUNT_PARAGRAPHS:
     673             :     case FIELD_ID_COUNT_WORDS:
     674             :     case FIELD_ID_COUNT_CHARACTERS:
     675             :     case FIELD_ID_COUNT_TABLES:
     676             :     case FIELD_ID_COUNT_GRAPHICS:
     677             :     case FIELD_ID_COUNT_OBJECTS:
     678             :     case FIELD_ID_DOCINFO_SAVE_TIME:
     679             :     case FIELD_ID_DOCINFO_SAVE_DATE:
     680             :     case FIELD_ID_DOCINFO_CREATION_DATE:
     681             :     case FIELD_ID_DOCINFO_CREATION_TIME:
     682             :     case FIELD_ID_DOCINFO_PRINT_TIME:
     683             :     case FIELD_ID_DOCINFO_PRINT_DATE:
     684             :     case FIELD_ID_DOCINFO_EDIT_DURATION:
     685             :     case FIELD_ID_DOCINFO_REVISION:
     686             :     case FIELD_ID_DATABASE_NUMBER:
     687             :     case FIELD_ID_EXPRESSION:
     688             :     case FIELD_ID_SEQUENCE:
     689             :     case FIELD_ID_DATE:
     690             :     case FIELD_ID_TIME:
     691             :     case FIELD_ID_PAGENUMBER:
     692             :     case FIELD_ID_REFPAGE_SET:
     693             :     case FIELD_ID_REFPAGE_GET:
     694             :     case FIELD_ID_DOCINFO_CUSTOM:
     695             :         // always number
     696           0 :         return false;
     697             : 
     698             :     case FIELD_ID_COMBINED_CHARACTERS:
     699             :     case FIELD_ID_BIBLIOGRAPHY:
     700             :     case FIELD_ID_DDE:
     701             :     case FIELD_ID_REF_REFERENCE:
     702             :     case FIELD_ID_REF_SEQUENCE:
     703             :     case FIELD_ID_REF_BOOKMARK:
     704             :     case FIELD_ID_REF_FOOTNOTE:
     705             :     case FIELD_ID_REF_ENDNOTE:
     706             :     case FIELD_ID_MACRO:
     707             :     case FIELD_ID_TEMPLATE_NAME:
     708             :     case FIELD_ID_CHAPTER:
     709             :     case FIELD_ID_FILE_NAME:
     710             :     case FIELD_ID_CONDITIONAL_TEXT:
     711             :     case FIELD_ID_HIDDEN_TEXT:
     712             :     case FIELD_ID_HIDDEN_PARAGRAPH:
     713             :     case FIELD_ID_DOCINFO_CREATION_AUTHOR:
     714             :     case FIELD_ID_DOCINFO_DESCRIPTION:
     715             :     case FIELD_ID_DOCINFO_PRINT_AUTHOR:
     716             :     case FIELD_ID_DOCINFO_TITLE:
     717             :     case FIELD_ID_DOCINFO_SUBJECT:
     718             :     case FIELD_ID_DOCINFO_KEYWORDS:
     719             :     case FIELD_ID_DOCINFO_SAVE_AUTHOR:
     720             :     case FIELD_ID_DATABASE_NAME:
     721             :     case FIELD_ID_TEXT_INPUT:
     722             :     case FIELD_ID_SENDER:
     723             :     case FIELD_ID_AUTHOR:
     724             :     case FIELD_ID_PAGENAME:
     725             :     case FIELD_ID_PAGESTRING:
     726             :     case FIELD_ID_SHEET_NAME:
     727             :     case FIELD_ID_MEASURE:
     728             :     case FIELD_ID_URL:
     729             :     case FIELD_ID_DROP_DOWN:
     730             :         // always string:
     731           0 :         return true;
     732             : 
     733             :     case FIELD_ID_SCRIPT:
     734             :     case FIELD_ID_ANNOTATION:
     735             :        case FIELD_ID_DATABASE_NEXT:
     736             :     case FIELD_ID_DATABASE_SELECT:
     737             :     case FIELD_ID_VARIABLE_DECL:
     738             :     case FIELD_ID_USER_DECL:
     739             :     case FIELD_ID_SEQUENCE_DECL:
     740             :     case FIELD_ID_PLACEHOLDER:
     741             :     case FIELD_ID_UNKNOWN:
     742             :     case FIELD_ID_DRAW_HEADER:
     743             :     case FIELD_ID_DRAW_FOOTER:
     744             :     case FIELD_ID_DRAW_DATE_TIME:
     745             :     default:
     746             :         OSL_FAIL("unknown field type/field has no content");
     747           0 :         return true; // invalid info; string in case of doubt
     748             :     }
     749             : }
     750             : 
     751             : /// export the styles needed by the given field. Called on first pass
     752             : /// through document
     753         446 : void XMLTextFieldExport::ExportFieldAutoStyle(
     754             :     const Reference<XTextField> & rTextField, const bool bProgress,
     755             :     const bool bRecursive )
     756             : {
     757             :     // get property set
     758         446 :     Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
     759             : 
     760             :     // add field master to list of used field masters (if desired)
     761         446 :     if (NULL != pUsedMasters)
     762             :     {
     763         326 :         Reference<XDependentTextField> xDepField(rTextField, UNO_QUERY);
     764         326 :         if (xDepField.is())
     765             :         {
     766          21 :             Reference<XText> xOurText = rTextField->getAnchor()->getText();
     767             : 
     768             :             map<Reference<XText>, set<OUString> >::iterator aMapIter =
     769          21 :                 pUsedMasters->find(xOurText);
     770             : 
     771             :             // insert a list for our XText (if necessary)
     772          21 :             if (aMapIter == pUsedMasters->end())
     773             :             {
     774           9 :                 set<OUString> aSet;
     775           9 :                 (*pUsedMasters)[xOurText] = aSet;
     776           9 :                 aMapIter = pUsedMasters->find(xOurText);
     777             :             }
     778             : 
     779             :             // insert this text field master
     780             :             OUString sFieldMasterName = GetStringProperty(
     781          42 :                 sPropertyInstanceName, xDepField->getTextFieldMaster());
     782          21 :             if (!sFieldMasterName.isEmpty())
     783          21 :                 aMapIter->second.insert( sFieldMasterName );
     784         326 :         }
     785             :         // else: no dependent field -> no master -> ignore
     786             :     }
     787             : 
     788             :     // get Field ID
     789         446 :     FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
     790             : 
     791             :     // export the character style for all fields
     792             :     // with one exception: combined character fields export their own
     793             :     //                     text style below
     794         892 :     Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
     795         446 :     if (FIELD_ID_COMBINED_CHARACTERS != nToken)
     796             :     {
     797         446 :         GetExport().GetTextParagraphExport()->Add(
     798         446 :             XML_STYLE_FAMILY_TEXT_TEXT, xRangePropSet);
     799             :     }
     800             : 
     801             :     // process special styles for each field (e.g. data styles)
     802         446 :     switch (nToken) {
     803             : 
     804             :     case FIELD_ID_DATABASE_DISPLAY:
     805             :     {
     806          60 :         sal_Int32 nFormat = GetIntProperty(sPropertyNumberFormat, xPropSet);
     807             :         // workaround: #no-bug#; see IsStringField(...)
     808         120 :         if ( (5100 != nFormat) &&
     809          60 :              !GetBoolProperty(sPropertyIsDataBaseFormat, xPropSet) )
     810             :         {
     811           0 :                 GetExport().addDataStyle(nFormat);
     812             :         }
     813          60 :         break;
     814             :     }
     815             : 
     816             :     case FIELD_ID_DATE:
     817             :     case FIELD_ID_TIME:
     818             :         {
     819             :             // date and time fields are always number fields, but the
     820             :             // NumberFormat property is optional (e.g. Calc doesn't
     821             :             // support it)
     822             :             Reference<XPropertySetInfo> xPropSetInfo(
     823          62 :                 xPropSet->getPropertySetInfo() );
     824          62 :             if ( xPropSetInfo->hasPropertyByName( sPropertyNumberFormat ) )
     825             :             {
     826             :                 sal_Int32 nFormat =
     827          57 :                     GetIntProperty(sPropertyNumberFormat, xPropSet);
     828             : 
     829             :                 // nFormat may be -1 for numeric fields that display their
     830             :                 //  variable name. (Maybe this should be a field type, then?)
     831          57 :                 if (nFormat != -1)
     832             :                 {
     833          57 :                     if( ! GetOptionalBoolProperty(
     834             :                             sPropertyIsFixedLanguage,
     835          57 :                             xPropSet, xPropSetInfo, false ) )
     836             :                     {
     837             :                         nFormat =
     838          57 :                             GetExport().dataStyleForceSystemLanguage(nFormat);
     839             :                     }
     840             : 
     841          57 :                     GetExport().addDataStyle( nFormat,
     842          57 :                                               nToken == FIELD_ID_TIME );
     843             :                 }
     844          62 :             }
     845             :         }
     846          62 :         break;
     847             : 
     848             :     case FIELD_ID_META:
     849             :         // recurse into content (does not export element, so can be done first)
     850          10 :         if (bRecursive)
     851             :         {
     852           0 :             ExportMetaField(xPropSet, true, bProgress);
     853             :         }
     854             :         // fall-through: for the meta-field itself!
     855             :     case FIELD_ID_DOCINFO_PRINT_TIME:
     856             :     case FIELD_ID_DOCINFO_PRINT_DATE:
     857             :     case FIELD_ID_DOCINFO_CREATION_DATE:
     858             :     case FIELD_ID_DOCINFO_CREATION_TIME:
     859             :     case FIELD_ID_DOCINFO_SAVE_TIME:
     860             :     case FIELD_ID_DOCINFO_SAVE_DATE:
     861             :     case FIELD_ID_DOCINFO_EDIT_DURATION:
     862             :     case FIELD_ID_VARIABLE_SET:
     863             :     case FIELD_ID_VARIABLE_GET:
     864             :     case FIELD_ID_VARIABLE_INPUT:
     865             :     case FIELD_ID_USER_GET:
     866             :     case FIELD_ID_EXPRESSION:
     867             :     case FIELD_ID_TABLE_FORMULA:
     868             :     case FIELD_ID_DOCINFO_CUSTOM:
     869             :         // register number format, if this is a numeric field
     870          11 :         if (! IsStringField(nToken, xPropSet)) {
     871             : 
     872             :             sal_Int32 nFormat =
     873           3 :                 GetIntProperty(sPropertyNumberFormat, xPropSet);
     874             : 
     875             :             // nFormat may be -1 for numeric fields that display their
     876             :             //  variable name. (Maybe this should be a field type, then?)
     877           3 :             if (nFormat != -1)
     878             :             {
     879             :                 // handle formats for fixed language fields
     880             :                 // for all these fields (except table formula)
     881          12 :                 if( ( nToken != FIELD_ID_TABLE_FORMULA ) &&
     882             :                     ! GetOptionalBoolProperty(
     883             :                           sPropertyIsFixedLanguage,
     884           3 :                           xPropSet, xPropSet->getPropertySetInfo(),
     885          12 :                           false ) )
     886             :                 {
     887             :                     nFormat =
     888           1 :                         GetExport().dataStyleForceSystemLanguage(nFormat);
     889             :                 }
     890             : 
     891           3 :                 GetExport().addDataStyle(nFormat);
     892             :             }
     893             :         }
     894          11 :         break;
     895             : 
     896             :     case FIELD_ID_COMBINED_CHARACTERS:
     897             :     {
     898             :         // export text style with the addition of the combined characters
     899             :         DBG_ASSERT(NULL != pCombinedCharactersPropertyState,
     900             :                    "need proper PropertyState for combined characters");
     901           0 :         const XMLPropertyState *aStates[] = { pCombinedCharactersPropertyState, 0 };
     902           0 :         GetExport().GetTextParagraphExport()->Add(
     903             :             XML_STYLE_FAMILY_TEXT_TEXT, xRangePropSet,
     904           0 :             aStates);
     905           0 :         break;
     906             :     }
     907             : 
     908             :     case FIELD_ID_SCRIPT:
     909             :     case FIELD_ID_ANNOTATION:
     910             :     case FIELD_ID_BIBLIOGRAPHY:
     911             :     case FIELD_ID_DDE:
     912             :     case FIELD_ID_REF_REFERENCE:
     913             :     case FIELD_ID_REF_SEQUENCE:
     914             :     case FIELD_ID_REF_BOOKMARK:
     915             :     case FIELD_ID_REF_FOOTNOTE:
     916             :     case FIELD_ID_REF_ENDNOTE:
     917             :     case FIELD_ID_MACRO:
     918             :     case FIELD_ID_REFPAGE_SET:
     919             :     case FIELD_ID_REFPAGE_GET:
     920             :     case FIELD_ID_COUNT_PAGES:
     921             :     case FIELD_ID_COUNT_PARAGRAPHS:
     922             :     case FIELD_ID_COUNT_WORDS:
     923             :     case FIELD_ID_COUNT_CHARACTERS:
     924             :     case FIELD_ID_COUNT_TABLES:
     925             :     case FIELD_ID_COUNT_GRAPHICS:
     926             :     case FIELD_ID_COUNT_OBJECTS:
     927             :     case FIELD_ID_CONDITIONAL_TEXT:
     928             :     case FIELD_ID_HIDDEN_TEXT:
     929             :     case FIELD_ID_HIDDEN_PARAGRAPH:
     930             :     case FIELD_ID_DOCINFO_CREATION_AUTHOR:
     931             :     case FIELD_ID_DOCINFO_DESCRIPTION:
     932             :     case FIELD_ID_DOCINFO_PRINT_AUTHOR:
     933             :     case FIELD_ID_DOCINFO_TITLE:
     934             :     case FIELD_ID_DOCINFO_SUBJECT:
     935             :     case FIELD_ID_DOCINFO_KEYWORDS:
     936             :     case FIELD_ID_DOCINFO_REVISION:
     937             :     case FIELD_ID_DOCINFO_SAVE_AUTHOR:
     938             :     case FIELD_ID_SEQUENCE:
     939             :     case FIELD_ID_PAGENAME:
     940             :     case FIELD_ID_PAGENUMBER:
     941             :     case FIELD_ID_PAGESTRING:
     942             :     case FIELD_ID_AUTHOR:
     943             :     case FIELD_ID_SENDER:
     944             :     case FIELD_ID_PLACEHOLDER:
     945             :     case FIELD_ID_USER_INPUT:
     946             :     case FIELD_ID_TEXT_INPUT:
     947             :     case FIELD_ID_DATABASE_NEXT:
     948             :     case FIELD_ID_DATABASE_SELECT:
     949             :     case FIELD_ID_DATABASE_NAME:
     950             :     case FIELD_ID_DATABASE_NUMBER:
     951             :     case FIELD_ID_TEMPLATE_NAME:
     952             :     case FIELD_ID_CHAPTER:
     953             :     case FIELD_ID_FILE_NAME:
     954             :     case FIELD_ID_SHEET_NAME:
     955             :     case FIELD_ID_MEASURE:
     956             :     case FIELD_ID_URL:
     957             :     case FIELD_ID_DROP_DOWN:
     958             :     case FIELD_ID_DRAW_DATE_TIME:
     959             :     case FIELD_ID_DRAW_FOOTER:
     960             :     case FIELD_ID_DRAW_HEADER:
     961             :         ; // no formats for these fields!
     962         313 :         break;
     963             : 
     964             :     case FIELD_ID_UNKNOWN:
     965             :     default:
     966             :         OSL_FAIL("unknown field type!");
     967             :         // ignore -> no format for ukowns
     968           0 :         break;
     969         446 :     }
     970         446 : }
     971             : 
     972             : /// export the given field to XML. Called on second pass through document
     973         427 : void XMLTextFieldExport::ExportField(
     974             :     const Reference<XTextField> & rTextField, bool bProgress )
     975             : {
     976             :     // get property set
     977         427 :     Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY);
     978             : 
     979             :     // get property set of range (for the attributes)
     980         854 :     Reference <XPropertySet> xRangePropSet(rTextField->getAnchor(), UNO_QUERY);
     981             : 
     982             :     // get Field ID
     983         427 :     enum FieldIdEnum nToken = GetFieldID(rTextField, xPropSet);
     984             : 
     985             :     // special treatment for combined characters field, because it is
     986             :     // exported as a style
     987         427 :     const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState, 0 };
     988             :     const XMLPropertyState **pStates =
     989             :                 FIELD_ID_COMBINED_CHARACTERS == nToken
     990             :                     ? aStates
     991         427 :                     : 0;
     992             : 
     993             :     // find out whether we need to set the style or hyperlink
     994             :     bool bHasHyperlink;
     995             :     bool bIsUICharStyle;
     996             :     bool bHasAutoStyle;
     997         427 :     OUString sStyle = GetExport().GetTextParagraphExport()->
     998             :         FindTextStyleAndHyperlink( xRangePropSet, bHasHyperlink, bIsUICharStyle,
     999         854 :                                    bHasAutoStyle, pStates );
    1000         427 :     bool bHasStyle = !sStyle.isEmpty();
    1001             : 
    1002             :     // export hyperlink (if we have one)
    1003         854 :     Reference < XPropertySetInfo > xRangePropSetInfo;
    1004         427 :     if( bHasHyperlink )
    1005             :     {
    1006           0 :         Reference<XPropertyState> xRangePropState( xRangePropSet, UNO_QUERY );
    1007           0 :         xRangePropSetInfo = xRangePropSet->getPropertySetInfo();
    1008             :         bHasHyperlink =
    1009           0 :             GetExport().GetTextParagraphExport()->addHyperlinkAttributes(
    1010             :                 xRangePropSet, xRangePropState,
    1011           0 :                 xRangePropSetInfo );
    1012             :     }
    1013         427 :     SvXMLElementExport aHyperlink( GetExport(), bHasHyperlink,
    1014             :                                    XML_NAMESPACE_TEXT, XML_A,
    1015        1281 :                                    false, false );
    1016             : 
    1017         427 :     if( bHasHyperlink )
    1018             :     {
    1019             :         // export events (if supported)
    1020           0 :         OUString sHyperLinkEvents("HyperLinkEvents");
    1021           0 :         if (xRangePropSetInfo->hasPropertyByName(sHyperLinkEvents))
    1022             :         {
    1023           0 :             Any aAny = xRangePropSet->getPropertyValue(sHyperLinkEvents);
    1024           0 :             Reference<XNameReplace> xName;
    1025           0 :             aAny >>= xName;
    1026           0 :             GetExport().GetEventExport().Export(xName, false);
    1027           0 :         }
    1028             :     }
    1029             : 
    1030             :     {
    1031             :         XMLTextCharStyleNamesElementExport aCharStylesExport(
    1032         854 :             GetExport(), bIsUICharStyle &&
    1033           0 :                          GetExport().GetTextParagraphExport()
    1034         427 :                              ->GetCharStyleNamesPropInfoCache().hasProperty(
    1035           0 :                                         xRangePropSet, xRangePropSetInfo ), bHasAutoStyle,
    1036        1708 :             xRangePropSet, sPropertyCharStyleNames );
    1037             : 
    1038             :         // export span with style (if necessary)
    1039             :         // (except for combined characters field)
    1040         427 :         if( bHasStyle )
    1041             :         {
    1042             :             // export <text:span> element
    1043          46 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
    1044          92 :                             GetExport().EncodeStyleName( sStyle ) );
    1045             :         }
    1046         427 :         SvXMLElementExport aSpan( GetExport(), bHasStyle,
    1047             :                                   XML_NAMESPACE_TEXT, XML_SPAN,
    1048        1281 :                                   false, false);
    1049             : 
    1050             :         // finally, export the field itself
    1051             :         ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken,
    1052         854 :             bProgress );
    1053         427 :     }
    1054         427 : }
    1055             : 
    1056             : /// export the given field to XML. Called on second pass through document
    1057         427 : void XMLTextFieldExport::ExportFieldHelper(
    1058             :     const Reference<XTextField> & rTextField,
    1059             :     const Reference<XPropertySet> & rPropSet,
    1060             :     const Reference<XPropertySet> &,
    1061             :     enum FieldIdEnum nToken,
    1062             :     bool bProgress )
    1063             : {
    1064             :     // get property set info (because some attributes are not support
    1065             :     // in all implementations)
    1066         427 :     Reference<XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
    1067             : 
    1068         854 :     OUString sPresentation = rTextField->getPresentation(sal_False);
    1069             : 
    1070             :     // process each field type
    1071         427 :     switch (nToken) {
    1072             :     case FIELD_ID_AUTHOR:
    1073             :         // author field: fixed, field (sub-)type
    1074             :         ProcessBoolean(XML_FIXED,
    1075           0 :                        GetBoolProperty(sPropertyIsFixed, rPropSet), true);
    1076           0 :         ExportElement(MapAuthorFieldName(rPropSet), sPresentation);
    1077           0 :         break;
    1078             : 
    1079             :     case FIELD_ID_SENDER:
    1080             :         // sender field: fixed, field (sub-)type
    1081             :         ProcessBoolean(XML_FIXED,
    1082           0 :                        GetBoolProperty(sPropertyIsFixed, rPropSet), true);
    1083           0 :         ExportElement(MapSenderFieldName(rPropSet), sPresentation);
    1084           0 :         break;
    1085             : 
    1086             :     case FIELD_ID_PLACEHOLDER:
    1087             :         // placeholder field: type, name, description
    1088             :         ProcessString(XML_PLACEHOLDER_TYPE,
    1089             :                       MapPlaceholderType(
    1090           0 :                         GetInt16Property(sPropertyPlaceholderType, rPropSet)));
    1091             :         ProcessString(XML_DESCRIPTION,
    1092           0 :                       GetStringProperty(sPropertyHint,rPropSet), true);
    1093           0 :         ExportElement(XML_PLACEHOLDER, sPresentation);
    1094           0 :         break;
    1095             : 
    1096             :     case FIELD_ID_VARIABLE_SET:
    1097             :     {
    1098             :         // variable set field: name, visible, format&value
    1099             :         ProcessString(XML_NAME,
    1100           1 :                       GetStringProperty(sPropertyVariableName, rPropSet));
    1101           1 :         ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
    1102           1 :                        false);
    1103             :         ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
    1104             :                       GetStringProperty(sPropertyContent, rPropSet),
    1105           1 :                       sPresentation);
    1106           1 :         ProcessValueAndType(IsStringField(nToken, rPropSet),
    1107             :                             GetIntProperty(sPropertyNumberFormat, rPropSet),
    1108             :                             GetStringProperty(sPropertyContent, rPropSet),
    1109             :                             sPresentation,
    1110             :                             GetDoubleProperty(sPropertyValue, rPropSet),
    1111             :                             true, true, true,
    1112             :                             ! GetOptionalBoolProperty(
    1113             :                                  sPropertyIsFixedLanguage,
    1114           2 :                                  rPropSet, xPropSetInfo, false ) );
    1115           1 :         ExportElement(XML_VARIABLE_SET, sPresentation);
    1116           1 :         break;
    1117             :     }
    1118             :     case FIELD_ID_VARIABLE_GET:
    1119             :     {
    1120             :         // variable get field: name, format&value
    1121             :         ProcessString(XML_NAME,
    1122           0 :                       GetStringProperty(sPropertyContent, rPropSet));
    1123           0 :         bool bCmd = GetBoolProperty(sPropertyIsShowFormula, rPropSet);
    1124           0 :         ProcessDisplay(true, bCmd);
    1125             :         // #i81766# for older versions export of the value-type
    1126           0 :         bool bExportValueType = !bCmd && ( GetExport().getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE );
    1127             :         // show style, unless name will be shown
    1128           0 :         ProcessValueAndType(IsStringField(nToken, rPropSet),
    1129             :                             GetIntProperty(sPropertyNumberFormat, rPropSet),
    1130             :                             sEmpty, sEmpty, 0.0, // values not used
    1131             :                             false,
    1132             :                             bExportValueType,
    1133           0 :                             !bCmd,
    1134             :                             ! GetOptionalBoolProperty(
    1135             :                                  sPropertyIsFixedLanguage,
    1136           0 :                                  rPropSet, xPropSetInfo, false ) );
    1137           0 :         ExportElement(XML_VARIABLE_GET, sPresentation);
    1138           0 :         break;
    1139             :     }
    1140             :     case FIELD_ID_VARIABLE_INPUT:
    1141             :         // variable input field: name, description, format&value
    1142             :         ProcessString(XML_NAME,
    1143           0 :                       GetStringProperty(sPropertyVariableName, rPropSet));
    1144             :         ProcessString(XML_DESCRIPTION,
    1145           0 :                       GetStringProperty(sPropertyHint , rPropSet));
    1146           0 :         ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
    1147           0 :                        false);
    1148             :         ProcessString(XML_FORMULA, XML_NAMESPACE_OOOW,
    1149             :                       GetStringProperty(sPropertyContent, rPropSet),
    1150           0 :                       sPresentation);
    1151           0 :         ProcessValueAndType(IsStringField(nToken, rPropSet),
    1152             :                             GetIntProperty(sPropertyNumberFormat, rPropSet),
    1153             :                             GetStringProperty(sPropertyContent, rPropSet),
    1154             :                             sPresentation,
    1155             :                             GetDoubleProperty(sPropertyValue, rPropSet),
    1156             :                             true, true, true,
    1157             :                             ! GetOptionalBoolProperty(
    1158             :                                  sPropertyIsFixedLanguage,
    1159           0 :                                  rPropSet, xPropSetInfo, false ) );
    1160           0 :         ExportElement(XML_VARIABLE_INPUT, sPresentation);
    1161           0 :         break;
    1162             : 
    1163             :     case FIELD_ID_USER_GET:
    1164             :         // user field: name, hidden, style
    1165             :     {
    1166           0 :         bool bCmd = GetBoolProperty(sPropertyIsShowFormula, rPropSet);
    1167           0 :         ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
    1168           0 :                        bCmd);
    1169           0 :         ProcessValueAndType(IsStringField(nToken, rPropSet),
    1170             :                             GetIntProperty(sPropertyNumberFormat, rPropSet),
    1171             :                             sEmpty, sEmpty, 0.0, // values not used
    1172           0 :                             false, false, !bCmd,
    1173             :                             ! GetOptionalBoolProperty(
    1174             :                                  sPropertyIsFixedLanguage,
    1175           0 :                                  rPropSet, xPropSetInfo, false ) );
    1176             : 
    1177             :         // name from FieldMaster
    1178             :         ProcessString(XML_NAME,
    1179             :                       GetStringProperty(sPropertyName,
    1180           0 :                                         GetMasterPropertySet(rTextField)));
    1181           0 :         ExportElement(XML_USER_FIELD_GET, sPresentation);
    1182           0 :         break;
    1183             :     }
    1184             : 
    1185             :     case FIELD_ID_USER_INPUT:
    1186             :         // user input field: name (from FieldMaster), description
    1187             : //      ProcessString(XML_NAME,
    1188             : //                    GetStringProperty(sPropertyName,
    1189             : //                                      GetMasterPropertySet(rTextField)));
    1190             :         ProcessString(XML_NAME,
    1191           3 :                       GetStringProperty(sPropertyContent, rPropSet));
    1192             :         ProcessString(XML_DESCRIPTION,
    1193           3 :                       GetStringProperty(sPropertyHint, rPropSet));
    1194           3 :         ExportElement(XML_USER_FIELD_INPUT, sPresentation);
    1195           3 :         break;
    1196             : 
    1197             :     case FIELD_ID_SEQUENCE:
    1198             :     {
    1199             :         // sequence field: name, formula, seq-format
    1200           0 :         OUString sName = GetStringProperty(sPropertyVariableName, rPropSet);
    1201             :         // TODO: use reference name only if actually being referenced.
    1202             :         ProcessString(XML_REF_NAME,
    1203             :                       MakeSequenceRefName(
    1204           0 :                           GetInt16Property(sPropertySequenceValue, rPropSet),
    1205           0 :                           sName));
    1206           0 :         ProcessString(XML_NAME, sName);
    1207             :         ProcessString(XML_FORMULA,  XML_NAMESPACE_OOOW,
    1208             :                       GetStringProperty(sPropertyContent, rPropSet),
    1209           0 :                       sPresentation);
    1210             :         ProcessNumberingType(GetInt16Property(sPropertyNumberingType,
    1211           0 :                                               rPropSet));
    1212           0 :         ExportElement(XML_SEQUENCE, sPresentation);
    1213           0 :         break;
    1214             :     }
    1215             : 
    1216             :     case FIELD_ID_EXPRESSION:
    1217             :     {
    1218             :         // formula field: formula, format&value
    1219           0 :         bool bCmd = GetBoolProperty(sPropertyIsShowFormula, rPropSet);
    1220             :         ProcessString(XML_FORMULA,  XML_NAMESPACE_OOOW,
    1221             :                       GetStringProperty(sPropertyContent, rPropSet),
    1222           0 :                       sPresentation);
    1223           0 :         ProcessDisplay(true, bCmd);
    1224           0 :         ProcessValueAndType(IsStringField(nToken, rPropSet),
    1225             :                             GetIntProperty(sPropertyNumberFormat, rPropSet),
    1226             :                             GetStringProperty(sPropertyContent, rPropSet),
    1227             :                             sPresentation,
    1228             :                             GetDoubleProperty(sPropertyValue, rPropSet),
    1229           0 :                             !bCmd, !bCmd, !bCmd,
    1230             :                             ! GetOptionalBoolProperty(
    1231             :                                  sPropertyIsFixedLanguage,
    1232           0 :                                  rPropSet, xPropSetInfo, false ) );
    1233           0 :         ExportElement(XML_EXPRESSION, sPresentation);
    1234           0 :         break;
    1235             :     }
    1236             : 
    1237             :     case FIELD_ID_TEXT_INPUT:
    1238             :         // text input field: description and string-value
    1239             :         ProcessString(XML_DESCRIPTION,
    1240           9 :                       GetStringProperty(sPropertyHint, rPropSet));
    1241             :         ProcessString(XML_HELP,
    1242           9 :                       GetStringProperty(sPropertyHelp, rPropSet), true);
    1243             :         ProcessString(XML_HINT,
    1244           9 :                       GetStringProperty(sPropertyTooltip, rPropSet), true);
    1245           9 :         ExportElement(XML_TEXT_INPUT, sPresentation);
    1246           9 :         break;
    1247             : 
    1248             :     case FIELD_ID_TIME:
    1249             :         // all properties (except IsDate) are optional!
    1250          29 :         if (xPropSetInfo->hasPropertyByName(sPropertyNumberFormat))
    1251             :         {
    1252             :             ProcessValueAndType(false,
    1253             :                                 GetIntProperty(sPropertyNumberFormat,rPropSet),
    1254             :                                 sEmpty, sEmpty, 0.0, // not used
    1255             :                                 false, false, true,
    1256             :                                 ! GetOptionalBoolProperty(
    1257             :                                     sPropertyIsFixedLanguage,
    1258          24 :                                     rPropSet, xPropSetInfo, false ),
    1259          24 :                                 true);
    1260             :         }
    1261          29 :         if (xPropSetInfo->hasPropertyByName(sPropertyDateTimeValue))
    1262             :         {
    1263             :             // no value -> current time
    1264             :             ProcessTimeOrDateTime(XML_TIME_VALUE,
    1265             :                             GetDateTimeProperty(sPropertyDateTimeValue,
    1266           0 :                                                 rPropSet),
    1267           0 :                             XML_NAMESPACE_TEXT);
    1268             :         }
    1269          29 :         if (xPropSetInfo->hasPropertyByName(sPropertyDateTime))
    1270             :         {
    1271             :             // no value -> current time
    1272             :             ProcessTimeOrDateTime(XML_TIME_VALUE,
    1273          24 :                             GetDateTimeProperty(sPropertyDateTime,rPropSet),
    1274          24 :                             XML_NAMESPACE_TEXT);
    1275             :         }
    1276          29 :         if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
    1277             :         {
    1278             :             ProcessBoolean(XML_FIXED,
    1279          24 :                            GetBoolProperty(sPropertyIsFixed, rPropSet),
    1280          24 :                            false);
    1281             :         }
    1282          29 :         if (xPropSetInfo->hasPropertyByName(sPropertyAdjust))
    1283             :         {
    1284             :             // adjust value given as integer in minutes
    1285             :             ProcessDateTime(XML_TIME_ADJUST,
    1286             :                             GetIntProperty(sPropertyAdjust, rPropSet),
    1287           0 :                             false, true, true);
    1288             :         }
    1289          29 :         ExportElement(XML_TIME, sPresentation);
    1290          29 :         break;
    1291             : 
    1292             :     case FIELD_ID_DATE:
    1293             :         // all properties (except IsDate) are optional!
    1294          33 :         if (xPropSetInfo->hasPropertyByName(sPropertyNumberFormat))
    1295             :         {
    1296             :             ProcessValueAndType(false,
    1297             :                                 GetIntProperty(sPropertyNumberFormat,rPropSet),
    1298             :                                 sEmpty, sEmpty, 0.0, // not used
    1299             :                                 false, false, true,
    1300             :                                 ! GetOptionalBoolProperty(
    1301             :                                     sPropertyIsFixedLanguage,
    1302          33 :                                     rPropSet, xPropSetInfo, false ) );
    1303             :         }
    1304          33 :         if (xPropSetInfo->hasPropertyByName(sPropertyDateTimeValue))
    1305             :         {
    1306             :             // no value -> current date
    1307             :             ProcessDateTime(XML_DATE_VALUE,
    1308             :                             GetDateTimeProperty(sPropertyDateTimeValue,
    1309           3 :                                                 rPropSet),
    1310             :                             // #96457#: date fields should also save time
    1311           3 :                             false);
    1312             :         }
    1313             :         // TODO: remove double-handling after SRC614
    1314          30 :         else if (xPropSetInfo->hasPropertyByName(sPropertyDateTime))
    1315             :         {
    1316             :             ProcessDateTime(XML_DATE_VALUE,
    1317          30 :                             GetDateTimeProperty(sPropertyDateTime,rPropSet),
    1318             :                             // #96457#: date fields should also save time
    1319          30 :                             false);
    1320             :         }
    1321          33 :         if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
    1322             :         {
    1323             :             ProcessBoolean(XML_FIXED,
    1324          33 :                            GetBoolProperty(sPropertyIsFixed, rPropSet),
    1325          33 :                            false);
    1326             :         }
    1327          33 :         if (xPropSetInfo->hasPropertyByName(sPropertyAdjust))
    1328             :         {
    1329             :             // adjust value given as number of days
    1330             :             ProcessDateTime(XML_DATE_ADJUST,
    1331             :                             GetIntProperty(sPropertyAdjust, rPropSet),
    1332           3 :                             true, true, true);
    1333             :         }
    1334          33 :         ExportElement(XML_DATE, sPresentation);
    1335          33 :         break;
    1336             : 
    1337             :     case FIELD_ID_PAGENUMBER:
    1338             :         // all properties are optional
    1339          87 :         if (xPropSetInfo->hasPropertyByName(sPropertyNumberingType))
    1340             :         {
    1341             :             ProcessNumberingType(GetInt16Property(sPropertyNumberingType,
    1342           9 :                                                   rPropSet));
    1343             :         }
    1344          87 :         if (xPropSetInfo->hasPropertyByName(sPropertyOffset))
    1345             :         {
    1346           9 :             sal_Int32 nAdjust = GetIntProperty(sPropertyOffset, rPropSet);
    1347             : 
    1348           9 :             if (xPropSetInfo->hasPropertyByName(sPropertySubType))
    1349             :             {
    1350             :                 // property SubType used in MapPageNumebrName
    1351             :                 ProcessString(XML_SELECT_PAGE,
    1352           9 :                               MapPageNumberName(rPropSet, nAdjust));
    1353             :             }
    1354           9 :             ProcessIntegerDef(XML_PAGE_ADJUST, nAdjust, 0);
    1355             :         }
    1356          87 :         ExportElement(XML_PAGE_NUMBER, sPresentation);
    1357          87 :         break;
    1358             : 
    1359             :     case FIELD_ID_PAGESTRING:
    1360             :     {
    1361             :         ProcessString(XML_STRING_VALUE,
    1362             :                       GetStringProperty(sPropertyUserText, rPropSet),
    1363           0 :                       sPresentation);
    1364           0 :         sal_Int32 nDummy = 0; // MapPageNumberName need int
    1365           0 :         ProcessString(XML_SELECT_PAGE, MapPageNumberName(rPropSet, nDummy));
    1366           0 :         if( !( GetExport().getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE ) )
    1367           0 :             ExportElement(XML_PAGE_CONTINUATION, sPresentation);
    1368             :         else
    1369           0 :             ExportElement(XML_PAGE_CONTINUATION_STRING, sPresentation);
    1370           0 :         break;
    1371             :     }
    1372             : 
    1373             :     case FIELD_ID_DATABASE_NAME:
    1374             :         ProcessString(XML_TABLE_NAME,
    1375           0 :                       GetStringProperty(sPropertyDataTableName, rPropSet));
    1376           0 :         ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
    1377           0 :         ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
    1378           0 :                        false);
    1379             :         ExportDataBaseElement(XML_DATABASE_NAME, sPresentation,
    1380           0 :                               rPropSet, xPropSetInfo);
    1381           0 :         break;
    1382             : 
    1383             :     case FIELD_ID_DATABASE_NUMBER:
    1384             :         ProcessString(XML_TABLE_NAME,
    1385           0 :                       GetStringProperty(sPropertyDataTableName, rPropSet));
    1386           0 :         ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
    1387             :         ProcessNumberingType(
    1388           0 :             GetInt16Property(sPropertyNumberingType,rPropSet));
    1389             :         ProcessInteger(XML_VALUE,
    1390           0 :                        GetIntProperty(sPropertySetNumber, rPropSet));
    1391           0 :         ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
    1392           0 :                        false);
    1393             :         ExportDataBaseElement(XML_DATABASE_ROW_NUMBER, sPresentation,
    1394           0 :                               rPropSet, xPropSetInfo);
    1395           0 :         break;
    1396             : 
    1397             :     case FIELD_ID_DATABASE_NEXT:
    1398             :         ProcessString(XML_TABLE_NAME,
    1399           0 :                       GetStringProperty(sPropertyDataTableName, rPropSet));
    1400           0 :         ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
    1401             :         ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
    1402           0 :                       GetStringProperty(sPropertyCondition, rPropSet));
    1403             :         DBG_ASSERT(sPresentation.equals(sEmpty),
    1404             :                    "Unexpected presentation for database next field");
    1405             :         ExportDataBaseElement(XML_DATABASE_NEXT, OUString(),
    1406           0 :                               rPropSet, xPropSetInfo);
    1407           0 :         break;
    1408             : 
    1409             :     case FIELD_ID_DATABASE_SELECT:
    1410             :         ProcessString(XML_TABLE_NAME,
    1411           0 :                       GetStringProperty(sPropertyDataTableName, rPropSet));
    1412           0 :         ProcessCommandType(GetIntProperty(sPropertyDataCommandType, rPropSet));
    1413             :         ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
    1414           0 :                       GetStringProperty(sPropertyCondition, rPropSet));
    1415             :         ProcessInteger(XML_ROW_NUMBER,
    1416           0 :                        GetIntProperty(sPropertySetNumber, rPropSet));
    1417             :         DBG_ASSERT(sPresentation.equals(sEmpty),
    1418             :                    "Unexpected presentation for database select field");
    1419             :         ExportDataBaseElement(XML_DATABASE_ROW_SELECT, OUString(),
    1420           0 :                               rPropSet, xPropSetInfo);
    1421           0 :         break;
    1422             : 
    1423             :     case FIELD_ID_DATABASE_DISPLAY:
    1424             :     {
    1425             :         // get database, table and column name from field master
    1426          60 :         const Reference<XPropertySet> & xMaster = GetMasterPropertySet(rTextField);
    1427             :         ProcessString(XML_TABLE_NAME,
    1428          60 :                       GetStringProperty(sPropertyDataTableName, xMaster));
    1429          60 :         ProcessCommandType(GetIntProperty(sPropertyDataCommandType, xMaster));
    1430             :         ProcessString(XML_COLUMN_NAME,
    1431          60 :                       GetStringProperty(sPropertyDataColumnName, xMaster));
    1432             :         // export number format if available (happens only for numbers!)
    1433          60 :         if (!GetBoolProperty(sPropertyIsDataBaseFormat, rPropSet))
    1434             :         {
    1435             :             ProcessValueAndType(false,  // doesn't happen for text
    1436             :                                 GetIntProperty(sPropertyNumberFormat,rPropSet),
    1437             :                                 sEmpty, sEmpty, 0.0, // not used
    1438           0 :                                 false, false, true, false);
    1439             :         }
    1440          60 :         ProcessDisplay(GetBoolProperty(sPropertyIsVisible, rPropSet),
    1441          60 :                        false);
    1442             :         ExportDataBaseElement(XML_DATABASE_DISPLAY, sPresentation,
    1443          60 :                               xMaster, xMaster->getPropertySetInfo());
    1444          60 :         break;
    1445             :     }
    1446             : 
    1447             :     case FIELD_ID_DOCINFO_REVISION:
    1448             :         ProcessBoolean(XML_FIXED,
    1449           0 :                        GetBoolProperty(sPropertyIsFixed, rPropSet), false);
    1450           0 :         ExportElement(MapDocInfoFieldName(nToken), sPresentation);
    1451           0 :         break;
    1452             : 
    1453             :     case FIELD_ID_DOCINFO_EDIT_DURATION:
    1454             :     case FIELD_ID_DOCINFO_SAVE_TIME:
    1455             :     case FIELD_ID_DOCINFO_CREATION_TIME:
    1456             :     case FIELD_ID_DOCINFO_PRINT_TIME:
    1457             :     case FIELD_ID_DOCINFO_SAVE_DATE:
    1458             :     case FIELD_ID_DOCINFO_CREATION_DATE:
    1459             :     case FIELD_ID_DOCINFO_PRINT_DATE:
    1460             :         ProcessValueAndType(false,
    1461             :                             GetIntProperty(sPropertyNumberFormat, rPropSet),
    1462             :                             sEmpty, sEmpty, 0.0,
    1463             :                             false, false, true,
    1464             :                             ! GetOptionalBoolProperty(
    1465             :                                     sPropertyIsFixedLanguage,
    1466           0 :                                     rPropSet, xPropSetInfo, false ) );
    1467             : 
    1468             :         // todo: export date/time value, but values not available -> core bug
    1469             :         ProcessBoolean(XML_FIXED,
    1470           0 :                        GetBoolProperty(sPropertyIsFixed, rPropSet), false);
    1471           0 :         ExportElement(MapDocInfoFieldName(nToken), sPresentation);
    1472           0 :         break;
    1473             : 
    1474             :     case FIELD_ID_DOCINFO_CREATION_AUTHOR:
    1475             :     case FIELD_ID_DOCINFO_DESCRIPTION:
    1476             :     case FIELD_ID_DOCINFO_PRINT_AUTHOR:
    1477             :     case FIELD_ID_DOCINFO_TITLE:
    1478             :     case FIELD_ID_DOCINFO_SUBJECT:
    1479             :     case FIELD_ID_DOCINFO_KEYWORDS:
    1480             :     case FIELD_ID_DOCINFO_SAVE_AUTHOR:
    1481          32 :         if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
    1482             :         {
    1483             :             ProcessBoolean(XML_FIXED,
    1484           3 :                            GetBoolProperty(sPropertyIsFixed, rPropSet), false);
    1485             :         }
    1486          32 :         ExportElement(MapDocInfoFieldName(nToken), sPresentation);
    1487          32 :         break;
    1488             : 
    1489             :     case FIELD_ID_DOCINFO_CUSTOM:
    1490             :     {
    1491             :         ProcessValueAndType(false,  // doesn't happen for text
    1492             :                                 GetIntProperty(sPropertyNumberFormat,rPropSet),
    1493             :                                 sEmpty, sEmpty, 0.0, // not used
    1494             :                                 false, false, true,
    1495             :                                 ! GetOptionalBoolProperty(
    1496             :                                     sPropertyIsFixedLanguage,
    1497           0 :                                     rPropSet, xPropSetInfo, false ));
    1498           0 :         uno::Any aAny = rPropSet->getPropertyValue( sPropertyName );
    1499           0 :         OUString sName;
    1500           0 :         aAny >>= sName;
    1501           0 :         ProcessString(XML_NAME, sName);
    1502           0 :         ProcessBoolean(XML_FIXED, GetBoolProperty(sPropertyIsFixed, rPropSet), false);
    1503           0 :         ExportElement(XML_USER_DEFINED, sPresentation);
    1504           0 :         break;
    1505             :     }
    1506             : 
    1507             :     case FIELD_ID_COUNT_PAGES:
    1508             :     case FIELD_ID_COUNT_PARAGRAPHS:
    1509             :     case FIELD_ID_COUNT_WORDS:
    1510             :     case FIELD_ID_COUNT_CHARACTERS:
    1511             :     case FIELD_ID_COUNT_TABLES:
    1512             :     case FIELD_ID_COUNT_GRAPHICS:
    1513             :     case FIELD_ID_COUNT_OBJECTS:
    1514             :         // all properties optional (applies to pages only, but I'll do
    1515             :         // it for all for sake of common implementation)
    1516          33 :         if (xPropSetInfo->hasPropertyByName(sPropertyNumberingType))
    1517             :         {
    1518             :             ProcessNumberingType(GetInt16Property(sPropertyNumberingType,
    1519           4 :                                                   rPropSet));
    1520             :         }
    1521          33 :         ExportElement(MapCountFieldName(nToken), sPresentation);
    1522          33 :         break;
    1523             : 
    1524             :     case FIELD_ID_CONDITIONAL_TEXT:
    1525             :         ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
    1526           0 :                       GetStringProperty(sPropertyCondition, rPropSet));
    1527             :         ProcessString(XML_STRING_VALUE_IF_TRUE,
    1528           0 :                       GetStringProperty(sPropertyTrueContent, rPropSet));
    1529             :         ProcessString(XML_STRING_VALUE_IF_FALSE,
    1530           0 :                       GetStringProperty(sPropertyFalseContent, rPropSet));
    1531             :         ProcessBoolean(XML_CURRENT_VALUE,
    1532           0 :                        GetBoolProperty(sPropertyIsConditionTrue, rPropSet),
    1533           0 :                        false);
    1534           0 :         ExportElement(XML_CONDITIONAL_TEXT, sPresentation);
    1535           0 :         break;
    1536             : 
    1537             :     case FIELD_ID_HIDDEN_TEXT:
    1538             :         ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
    1539           0 :                       GetStringProperty(sPropertyCondition, rPropSet));
    1540             :         ProcessString(XML_STRING_VALUE,
    1541           0 :                       GetStringProperty(sPropertyContent, rPropSet));
    1542             :         ProcessBoolean(XML_IS_HIDDEN,
    1543           0 :                        GetBoolProperty(sPropertyIsHidden, rPropSet),
    1544           0 :                        false);
    1545           0 :         ExportElement(XML_HIDDEN_TEXT, sPresentation);
    1546           0 :         break;
    1547             : 
    1548             :     case FIELD_ID_HIDDEN_PARAGRAPH:
    1549             :         ProcessString(XML_CONDITION, XML_NAMESPACE_OOOW,
    1550           0 :                       GetStringProperty(sPropertyCondition, rPropSet));
    1551             :         ProcessBoolean(XML_IS_HIDDEN,
    1552           0 :                        GetBoolProperty(sPropertyIsHidden, rPropSet),
    1553           0 :                        false);
    1554             :         DBG_ASSERT(sPresentation.equals(sEmpty),
    1555             :                    "Unexpected presentation for hidden paragraph field");
    1556           0 :         ExportElement(XML_HIDDEN_PARAGRAPH);
    1557           0 :         break;
    1558             : 
    1559             :     case FIELD_ID_TEMPLATE_NAME:
    1560             :         ProcessString(XML_DISPLAY,
    1561             :                       MapTemplateDisplayFormat(
    1562           0 :                           GetInt16Property(sPropertyFileFormat, rPropSet)));
    1563           0 :         ExportElement(XML_TEMPLATE_NAME, sPresentation);
    1564           0 :         break;
    1565             : 
    1566             :     case FIELD_ID_CHAPTER:
    1567             :         ProcessString(XML_DISPLAY,
    1568             :                       MapChapterDisplayFormat(
    1569           3 :                           GetInt16Property(sPropertyChapterFormat, rPropSet)));
    1570             :         // API numbers 0..9, we number 1..10
    1571             :         ProcessInteger(XML_OUTLINE_LEVEL,
    1572           3 :                        GetInt8Property(sPropertyLevel, rPropSet) + 1);
    1573           3 :         ExportElement(XML_CHAPTER, sPresentation);
    1574           3 :         break;
    1575             : 
    1576             :     case FIELD_ID_FILE_NAME:
    1577             :         // all properties are optional
    1578           0 :         if (xPropSetInfo->hasPropertyByName(sPropertyFileFormat))
    1579             :         {
    1580             :             ProcessString(XML_DISPLAY,
    1581             :                           MapFilenameDisplayFormat(
    1582           0 :                              GetInt16Property(sPropertyFileFormat, rPropSet)));
    1583             :         }
    1584           0 :         if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed))
    1585             :         {
    1586             :             ProcessBoolean(XML_FIXED,
    1587           0 :                            GetBoolProperty(sPropertyIsFixed, rPropSet),
    1588           0 :                            false);
    1589             :         }
    1590           0 :         ExportElement(XML_FILE_NAME, sPresentation);
    1591           0 :         break;
    1592             : 
    1593             :     case FIELD_ID_REFPAGE_SET:
    1594             :         ProcessBoolean(XML_ACTIVE,
    1595           0 :                        GetBoolProperty(sPropertyOn, rPropSet), true);
    1596             :         ProcessIntegerDef(XML_PAGE_ADJUST,
    1597           0 :                        GetInt16Property(sPropertyOffset, rPropSet), 0);
    1598             :         DBG_ASSERT(sPresentation.equals(sEmpty),
    1599             :                    "Unexpected presentation page variable field");
    1600           0 :         ExportElement(XML_PAGE_VARIABLE_SET);
    1601           0 :         break;
    1602             : 
    1603             :     case FIELD_ID_REFPAGE_GET:
    1604             :         ProcessNumberingType(
    1605           0 :             GetInt16Property(sPropertyNumberingType, rPropSet));
    1606           0 :         ExportElement(XML_PAGE_VARIABLE_GET, sPresentation);
    1607           0 :         break;
    1608             : 
    1609             :     case FIELD_ID_MACRO:
    1610           0 :         ExportMacro( rPropSet, sPresentation );
    1611           0 :         break;
    1612             : 
    1613             :     case FIELD_ID_REF_SEQUENCE:
    1614             :         // reference to sequence: format, name, find value (and element)
    1615             :         // was: if (nSeqNumber != -1) ...
    1616             :         ProcessString(XML_REFERENCE_FORMAT,
    1617             :                       MapReferenceType(GetInt16Property(
    1618           0 :                           sPropertyReferenceFieldPart, rPropSet)),
    1619           0 :                       XML_TEMPLATE);
    1620             :         ProcessString(XML_REF_NAME,
    1621             :                       MakeSequenceRefName(
    1622           0 :                           GetInt16Property(sPropertySequenceNumber, rPropSet),
    1623           0 :                           GetStringProperty(sPropertySourceName, rPropSet) ) );
    1624             :         ExportElement(
    1625             :             MapReferenceSource(
    1626           0 :                 GetInt16Property(sPropertyReferenceFieldSource, rPropSet)),
    1627           0 :             sPresentation);
    1628           0 :         break;
    1629             : 
    1630             :     case FIELD_ID_REF_REFERENCE:
    1631             :     case FIELD_ID_REF_BOOKMARK:
    1632             :         // reference to bookmarks, references: format, name (and element)
    1633             :         ProcessString(XML_REFERENCE_FORMAT,
    1634             :                       MapReferenceType(GetInt16Property(
    1635           0 :                           sPropertyReferenceFieldPart, rPropSet)),
    1636           0 :                       XML_TEMPLATE);
    1637             :         ProcessString(XML_REF_NAME,
    1638           0 :                       GetStringProperty(sPropertySourceName, rPropSet));
    1639             :         ExportElement(
    1640             :             MapReferenceSource(GetInt16Property(
    1641           0 :                 sPropertyReferenceFieldSource, rPropSet)),
    1642           0 :             sPresentation);
    1643           0 :         break;
    1644             : 
    1645             :     case FIELD_ID_REF_FOOTNOTE:
    1646             :     case FIELD_ID_REF_ENDNOTE:
    1647             :         // reference to end-/footnote: format, generate name, (and element)
    1648           0 :         GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
    1649           0 :             FIELD_ID_REF_ENDNOTE==nToken ? XML_ENDNOTE : XML_FOOTNOTE );
    1650             :         ProcessString(XML_REFERENCE_FORMAT,
    1651             :                       MapReferenceType(GetInt16Property(
    1652           0 :                           sPropertyReferenceFieldPart, rPropSet)),
    1653           0 :                       XML_TEMPLATE);
    1654             :         ProcessString(XML_REF_NAME,
    1655             :                       MakeFootnoteRefName(GetInt16Property(
    1656           0 :                           sPropertySequenceNumber, rPropSet)));
    1657             :         ExportElement(
    1658             :             MapReferenceSource(GetInt16Property(
    1659           0 :                 sPropertyReferenceFieldSource, rPropSet)),
    1660           0 :             sPresentation);
    1661           0 :         break;
    1662             : 
    1663             :     case FIELD_ID_DDE:
    1664             :         // name from field master
    1665             :          ProcessString(XML_CONNECTION_NAME,
    1666             : 
    1667             :                        GetStringProperty(sPropertyName,
    1668           0 :                                          GetMasterPropertySet(rTextField)));
    1669           0 :         ExportElement(XML_DDE_CONNECTION, sPresentation);
    1670           0 :         break;
    1671             : 
    1672             :     case FIELD_ID_SHEET_NAME:
    1673             :         // name of spreadsheet (Calc only)
    1674          58 :         ExportElement(XML_SHEET_NAME, sPresentation);
    1675          58 :         break;
    1676             : 
    1677             :     case FIELD_ID_PAGENAME:
    1678             :     {
    1679           0 :         if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012)
    1680             :         {
    1681           0 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_LO_EXT, XML_PAGE_NAME, false, false );
    1682           0 :             GetExport().Characters( sPresentation );
    1683             :         }
    1684           0 :         break;
    1685             :     }
    1686             : 
    1687             :     case FIELD_ID_URL:
    1688             :     {
    1689             :         // this field is a special case because it gets mapped onto a
    1690             :         // hyperlink, rather than one of the regular text field.
    1691           0 :         ProcessString(XML_HREF, GetExport().GetRelativeReference(GetStringProperty(sPropertyURL, rPropSet)),
    1692           0 :                       false, XML_NAMESPACE_XLINK);
    1693             :         ProcessString(XML_TARGET_FRAME_NAME,
    1694             :                       GetStringProperty(sPropertyTargetFrame,rPropSet),
    1695           0 :                       true, XML_NAMESPACE_OFFICE);
    1696           0 :         GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
    1697             :         SvXMLElementExport aUrlField(rExport, XML_NAMESPACE_TEXT, XML_A,
    1698           0 :                                      false, false);
    1699           0 :         GetExport().Characters(sPresentation);
    1700           0 :         break;
    1701             :     }
    1702             : 
    1703             :     case FIELD_ID_BIBLIOGRAPHY:
    1704             :     {
    1705           0 :         ProcessBibliographyData(rPropSet);
    1706           0 :         ExportElement(XML_BIBLIOGRAPHY_MARK, sPresentation);
    1707           0 :         break;
    1708             :     }
    1709             : 
    1710             :     case FIELD_ID_SCRIPT:
    1711             :         ProcessString(XML_LANGUAGE,
    1712             :                       GetStringProperty(sPropertyScriptType, rPropSet),
    1713           0 :                       true, XML_NAMESPACE_SCRIPT);
    1714             :         DBG_ASSERT(sPresentation.equals(sEmpty),
    1715             :                    "Unexpected presentation for script field");
    1716           0 :         if (GetBoolProperty(sPropertyURLContent, rPropSet))
    1717             :         {
    1718             :             ProcessString(XML_HREF,
    1719           0 :                           GetExport().GetRelativeReference(GetStringProperty(sPropertyContent, rPropSet)),
    1720           0 :                           false, XML_NAMESPACE_XLINK);
    1721           0 :             ExportElement(XML_SCRIPT);
    1722             :         }
    1723             :         else
    1724             :         {
    1725             :             ExportElement(XML_SCRIPT,
    1726           0 :                           GetStringProperty(sPropertyContent, rPropSet));
    1727             :         }
    1728           0 :         break;
    1729             : 
    1730             :     case FIELD_ID_ANNOTATION:
    1731             :     {
    1732             :         // check for empty presentation (just in case)
    1733             :         DBG_ASSERT(sPresentation.equals(sEmpty),
    1734             :                    "Unexpected presentation for annotation field");
    1735             : 
    1736             :         // annotation element + content
    1737          17 :         OUString aName;
    1738          17 :         rPropSet->getPropertyValue(sPropertyName) >>= aName;
    1739          17 :         if (!aName.isEmpty())
    1740           2 :             GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, aName);
    1741          17 :         SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_OFFICE,
    1742          34 :                                  XML_ANNOTATION, false, true);
    1743             : 
    1744             :         // author
    1745          34 :         OUString aAuthor( GetStringProperty(sPropertyAuthor, rPropSet) );
    1746          17 :         if( !aAuthor.isEmpty() )
    1747             :         {
    1748          17 :             SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_DC,
    1749             :                                               XML_CREATOR, true,
    1750          17 :                                               false );
    1751          17 :             GetExport().Characters(aAuthor);
    1752             :         }
    1753             : 
    1754             :         // date time
    1755          17 :         util::DateTime aDate( GetDateTimeProperty(sPropertyDateTimeValue, rPropSet) );
    1756             :         {
    1757          17 :             OUStringBuffer aBuffer;
    1758          17 :             ::sax::Converter::convertDateTime(aBuffer, aDate, 0, true);
    1759          17 :             SvXMLElementExport aDateElem( GetExport(), XML_NAMESPACE_DC,
    1760             :                                               XML_DATE, true,
    1761          34 :                                               false );
    1762          34 :             GetExport().Characters(aBuffer.makeStringAndClear());
    1763             :         }
    1764             : 
    1765          17 :         if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012)
    1766             :         {
    1767             :             // initials
    1768          17 :             OUString aInitials( GetStringProperty(sPropertyInitials, rPropSet) );
    1769          17 :             if( !aInitials.isEmpty() )
    1770             :             {
    1771           2 :                 SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_LO_EXT,
    1772             :                         XML_SENDER_INITIALS, true,
    1773           2 :                         false );
    1774           2 :                 GetExport().Characters(aInitials);
    1775          17 :             }
    1776             :         }
    1777             : 
    1778          34 :         com::sun::star::uno::Reference < com::sun::star::text::XText > xText;
    1779             :         try
    1780             :         {
    1781          17 :             com::sun::star::uno::Any aRet = rPropSet->getPropertyValue(sPropertyTextRange);
    1782          17 :             aRet >>= xText;
    1783             :         }
    1784           0 :         catch ( com::sun::star::uno::Exception& )
    1785             :         {}
    1786             : 
    1787          17 :         if ( xText.is() )
    1788          17 :             GetExport().GetTextParagraphExport()->exportText( xText );
    1789             :         else
    1790           0 :             ProcessParagraphSequence(GetStringProperty(sPropertyContent,rPropSet));
    1791          34 :         break;
    1792             :     }
    1793             : 
    1794             :     case FIELD_ID_COMBINED_CHARACTERS:
    1795             :     {
    1796             :         // The style with the combined characters attribute has
    1797             :         // already been handled in the ExportField method. So all that
    1798             :         // is left to do now is to export the characters.
    1799           0 :         GetExport().Characters(sPresentation);
    1800           0 :         break;
    1801             :     }
    1802             : 
    1803             :     case FIELD_ID_META:
    1804             :     {
    1805          10 :         ExportMetaField(rPropSet, false, bProgress);
    1806          10 :         break;
    1807             :     }
    1808             : 
    1809             :     case FIELD_ID_MEASURE:
    1810             :     {
    1811           0 :         ProcessString(XML_KIND, MapMeasureKind(GetInt16Property(sPropertyMeasureKind, rPropSet)));
    1812           0 :         ExportElement( XML_MEASURE, sPresentation );
    1813           0 :         break;
    1814             :     }
    1815             : 
    1816             :     case FIELD_ID_TABLE_FORMULA:
    1817             :         ProcessString( XML_FORMULA,  XML_NAMESPACE_OOOW,
    1818           0 :                        GetStringProperty(sPropertyContent, rPropSet) );
    1819             :         ProcessDisplay( true,
    1820           0 :                         GetBoolProperty(sPropertyIsShowFormula, rPropSet),
    1821           0 :                         true );
    1822             :         ProcessValueAndType( false,
    1823             :                              GetIntProperty(sPropertyNumberFormat, rPropSet),
    1824             :                              sEmpty, sEmpty, 0.0f,
    1825             :                              false, false, true,
    1826           0 :                              false, false );
    1827           0 :         ExportElement( XML_TABLE_FORMULA, sPresentation );
    1828           0 :         break;
    1829             : 
    1830             :     case FIELD_ID_DROP_DOWN:
    1831             :     {
    1832           0 :         ProcessString(XML_NAME, GetStringProperty(sPropertyName, rPropSet));
    1833             :         ProcessString(XML_HELP,
    1834           0 :                       GetStringProperty(sPropertyHelp, rPropSet), true);
    1835             :         ProcessString(XML_HINT,
    1836           0 :                       GetStringProperty(sPropertyTooltip, rPropSet), true);
    1837           0 :         SvXMLElementExport aElem( GetExport(),
    1838             :                                   XML_NAMESPACE_TEXT, XML_DROP_DOWN,
    1839           0 :                                   false, false );
    1840             :         ProcessStringSequence
    1841             :             (GetStringSequenceProperty( sPropertyItems, rPropSet ),
    1842           0 :              GetStringProperty( sPropertySelectedItem, rPropSet ) );
    1843             : 
    1844           0 :         GetExport().Characters( sPresentation );
    1845             :     }
    1846           0 :     break;
    1847             : 
    1848             :     case FIELD_ID_DRAW_HEADER:
    1849             :     {
    1850          14 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_HEADER, false, false );
    1851             :     }
    1852          14 :     break;
    1853             : 
    1854             :     case FIELD_ID_DRAW_FOOTER:
    1855             :     {
    1856          19 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_FOOTER, false, false );
    1857             :     }
    1858          19 :     break;
    1859             : 
    1860             :     case FIELD_ID_DRAW_DATE_TIME:
    1861             :     {
    1862          19 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_PRESENTATION, XML_DATE_TIME, false, false );
    1863             :     }
    1864          19 :     break;
    1865             : 
    1866             : 
    1867             :     case FIELD_ID_UNKNOWN:
    1868             :     default:
    1869             :         OSL_FAIL("unknown field type encountered!");
    1870             :         // always export content
    1871           0 :         GetExport().Characters(sPresentation);
    1872         427 :     }
    1873         427 : }
    1874             : 
    1875             : 
    1876             : /// export field declarations / field masters
    1877          73 : void XMLTextFieldExport::ExportFieldDeclarations()
    1878             : {
    1879          73 :     Reference<XText> xEmptyText;
    1880          73 :     ExportFieldDeclarations(xEmptyText);
    1881          73 : }
    1882             : 
    1883             : /// export field declarations / field masters
    1884         241 : void XMLTextFieldExport::ExportFieldDeclarations(
    1885             :     const Reference<XText> & rText )
    1886             : {
    1887             :     // store lists for decl elements
    1888         241 :     vector<OUString>                    aVarName;
    1889         337 :     vector<OUString>                    aUserName;
    1890         337 :     vector<OUString>                    aSeqName;
    1891         337 :     vector<OUString>                    aDdeName;
    1892             : 
    1893             :     // get text fields supplier and field master name access
    1894         241 :     Reference<XTextFieldsSupplier> xTextFieldsSupp(GetExport().GetModel(),
    1895         337 :                                                    UNO_QUERY);
    1896         241 :     if( !xTextFieldsSupp.is() )
    1897         386 :         return;
    1898             : 
    1899             :     Reference<container::XNameAccess> xFieldMasterNameAccess(
    1900         192 :         xTextFieldsSupp->getTextFieldMasters(), UNO_QUERY);
    1901             : 
    1902             :     // where to get the text field masters from?
    1903             :     // a) we get a specific XText: then use pUsedMasters
    1904             :     // b) the XText is empty: then export all text fields
    1905         192 :     Sequence<OUString> aFieldMasters;
    1906          96 :     if (rText.is())
    1907             :     {
    1908             :         // export only used masters
    1909             :         DBG_ASSERT(NULL != pUsedMasters,
    1910             :                    "field masters must be recorded in order to be "
    1911             :                    "written out separatly" );
    1912          23 :         if (NULL != pUsedMasters)
    1913             :         {
    1914             :             map<Reference<XText>, set<OUString> > ::iterator aMapIter =
    1915          23 :                 pUsedMasters->find(rText);
    1916          23 :             if (aMapIter != pUsedMasters->end())
    1917             :             {
    1918             :                 // found the set of used field masters
    1919           9 :                 set<OUString> & rOurMasters = aMapIter->second;
    1920             : 
    1921             :                 // copy set to sequence
    1922           9 :                 aFieldMasters.realloc( rOurMasters.size() );
    1923           9 :                 sal_Int32 i = 0;
    1924          27 :                 for( set<OUString>::iterator aSetIter = rOurMasters.begin();
    1925          18 :                      aSetIter != rOurMasters.end();
    1926             :                      ++aSetIter, ++i )
    1927             :                 {
    1928           0 :                     aFieldMasters[i] = *aSetIter;
    1929             :                 }
    1930             : 
    1931           9 :                 pUsedMasters->erase(rText);
    1932             :             }
    1933             :             // else: XText not found -> ignore
    1934             :         }
    1935             :         // else: no field masters have been recorded -> ignore
    1936             :     }
    1937             :     else
    1938             :     {
    1939             :         // no XText: export all!
    1940          73 :         aFieldMasters = xFieldMasterNameAccess->getElementNames();
    1941             :     }
    1942             : 
    1943         451 :     for(sal_Int32 i=0; i<aFieldMasters.getLength(); i++) {
    1944             : 
    1945             :         // get field master name
    1946         355 :         OUString sFieldMaster = aFieldMasters[i];
    1947             : 
    1948             :         // workaround for #no-bug#
    1949         355 :         if ( sFieldMaster.startsWithIgnoreAsciiCase(
    1950             :                  "com.sun.star.text.FieldMaster.DataBase.") )
    1951             :         {
    1952          57 :             continue;
    1953             :         }
    1954             : 
    1955             : 
    1956         596 :         OUString sFieldMasterType;
    1957         596 :         OUString sVarName;
    1958         298 :         ExplodeFieldMasterName(sFieldMaster, sFieldMasterType, sVarName);
    1959             : 
    1960             :         // get XPropertySet of this field master
    1961         596 :         Reference<XPropertySet> xPropSet;
    1962         596 :         Any aAny = xFieldMasterNameAccess->getByName(sFieldMaster);
    1963         298 :         aAny >>= xPropSet;
    1964             : 
    1965             :         // save interesting field masters
    1966         298 :         if (sFieldMasterType == FIELD_SERVICE_SETEXP)
    1967             :         {
    1968         294 :             sal_Int32 nType = GetIntProperty(sPropertySubType, xPropSet);
    1969             : 
    1970             :             // sequence or variable?
    1971         294 :             if ( SetVariableType::SEQUENCE == nType )
    1972             :             {
    1973         293 :                 aSeqName.push_back( sFieldMaster );
    1974             :             }
    1975             :             else
    1976             :             {
    1977           1 :                 aVarName.push_back( sFieldMaster );
    1978             :             }
    1979             :         }
    1980           4 :         else if (sFieldMasterType == FIELD_SERVICE_USER)
    1981             :         {
    1982           3 :             aUserName.push_back( sFieldMaster );
    1983             :         }
    1984           1 :         else if (sFieldMasterType == FIELD_SERVICE_DDE)
    1985             :         {
    1986           0 :             aDdeName.push_back( sFieldMaster );
    1987             :         }
    1988             :         else
    1989             :         {
    1990             :             ; // ignore
    1991             :         }
    1992         298 :     }
    1993             : 
    1994             :     // now process fields:
    1995             : 
    1996             :     // variable field masters:
    1997          96 :     if ( !aVarName.empty() )
    1998             :     {
    1999           1 :         SvXMLElementExport aElem( GetExport(),
    2000             :                                   XML_NAMESPACE_TEXT,
    2001             :                                   XML_VARIABLE_DECLS,
    2002           1 :                                   true, true );
    2003             : 
    2004           6 :         for (vector<OUString>::iterator aVarIter = aVarName.begin();
    2005           4 :              aVarIter != aVarName.end();
    2006             :              ++aVarIter) {
    2007             : 
    2008           1 :             OUString sName = *aVarIter;
    2009             : 
    2010             :             // get field master property set
    2011           2 :             Reference<XPropertySet> xPropSet;
    2012           2 :             Any aAny = xFieldMasterNameAccess->getByName(sName);
    2013           1 :             aAny >>= xPropSet;
    2014             : 
    2015             :             // field name and type
    2016           2 :             OUString sFieldMasterType;
    2017           2 :             OUString sVarName;
    2018           1 :             ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
    2019             : 
    2020             :             // determine string/numeric field
    2021           1 :             bool bIsString = ( GetIntProperty(sPropertySubType, xPropSet)
    2022           1 :                                    == SetVariableType::STRING );
    2023             : 
    2024             :             // get dependent field property set
    2025           2 :             Reference<XPropertySet> xFieldPropSet;
    2026           1 :             if (GetDependentFieldPropertySet(xPropSet, xFieldPropSet))
    2027             :             {
    2028             :                 // process value and type.
    2029             :                 ProcessValueAndType(
    2030             :                     bIsString,
    2031             :                     GetIntProperty(sPropertyNumberFormat, xFieldPropSet),
    2032             :                     sEmpty, sEmpty, 0.0,
    2033           1 :                     false, true, false, false);
    2034             :             }
    2035             :             else
    2036             :             {
    2037             :                 // If no dependent field is found, only string and
    2038             :                 // float types can be supported
    2039             : 
    2040             :                 // number format: 0 is default number format for 1st
    2041             :                 // language. should be: getDefaultNumberFormat(Locale)
    2042             :                 // from NumberFormats
    2043             :                 ProcessValueAndType(
    2044             :                     bIsString,
    2045             :                     0, sEmpty, sEmpty, 0.0,
    2046           0 :                     false, true, false, false);
    2047             :             }
    2048             : 
    2049           1 :             ProcessString(XML_NAME, sVarName);
    2050           1 :             ExportElement(XML_VARIABLE_DECL, true);
    2051           2 :         }
    2052             :     }
    2053             :     // else: no declarations element
    2054             : 
    2055             :     // sequence field masters:
    2056          96 :     if ( !aSeqName.empty() )
    2057             :     {
    2058          73 :         SvXMLElementExport aElem( GetExport(),
    2059             :                                   XML_NAMESPACE_TEXT,
    2060             :                                   XML_SEQUENCE_DECLS,
    2061          73 :                                   true, true );
    2062             : 
    2063        1098 :         for (vector<OUString>::iterator aSeqIter = aSeqName.begin();
    2064         732 :              aSeqIter != aSeqName.end();
    2065             :              ++aSeqIter) {
    2066             : 
    2067         293 :             OUString sName = *aSeqIter;
    2068             : 
    2069             :             // get field master property set
    2070         586 :             Reference<XPropertySet> xPropSet;
    2071         586 :             Any aAny = xFieldMasterNameAccess->getByName(sName);
    2072         293 :             aAny >>= xPropSet;
    2073             : 
    2074             :             // field name and type
    2075         586 :             OUString sFieldMasterType;
    2076         586 :             OUString sVarName;
    2077         293 :             ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
    2078             : 
    2079             :             // outline level
    2080             :             sal_Int32 nLevel = 1 + GetIntProperty(
    2081         293 :                 sPropertyChapterNumberingLevel, xPropSet);
    2082             :             DBG_ASSERT(nLevel >= 0, "illegal outline level");
    2083             :             DBG_ASSERT(nLevel < 127, "possible illegal outline level");
    2084         293 :             ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL, nLevel);
    2085             : 
    2086             :             // separation character
    2087         293 :             if (nLevel > 0) {
    2088             :                 ProcessString(XML_SEPARATION_CHARACTER, GetStringProperty(
    2089           1 :                     sPropertyNumberingSeparator, xPropSet));
    2090             :             }
    2091         293 :             ProcessString(XML_NAME, sVarName);
    2092         293 :             ExportElement(XML_SEQUENCE_DECL, true);
    2093         366 :         }
    2094             :     }
    2095             :     // else: no declarations element
    2096             : 
    2097             :     // user field field masters:
    2098          96 :     if ( !aUserName.empty() )
    2099             :     {
    2100           3 :         SvXMLElementExport aElem( GetExport(),
    2101             :                                   XML_NAMESPACE_TEXT,
    2102             :                                   XML_USER_FIELD_DECLS,
    2103           3 :                                   true, true );
    2104             : 
    2105          18 :         for (vector<OUString>::iterator aUserIter = aUserName.begin();
    2106          12 :              aUserIter != aUserName.end();
    2107             :              ++aUserIter) {
    2108             : 
    2109           3 :             OUString sName = *aUserIter;
    2110             : 
    2111             :             // get field master property set
    2112           6 :             Reference<XPropertySet> xPropSet;
    2113           6 :             Any aAny = xFieldMasterNameAccess->getByName(sName);
    2114           3 :             aAny >>= xPropSet;
    2115             : 
    2116             :             // field name and type
    2117           6 :             OUString sFieldMasterType;
    2118           6 :             OUString sVarName;
    2119           3 :             ExplodeFieldMasterName(sName, sFieldMasterType, sVarName);
    2120             : 
    2121           3 :             if (GetBoolProperty(sPropertyIsExpression, xPropSet))
    2122             :             {
    2123             :                 // expression:
    2124             :                 ProcessValueAndType(
    2125             :                     false,
    2126             :                     0, sEmpty, sEmpty,
    2127             :                     GetDoubleProperty(sPropertyValue, xPropSet),
    2128             :                     true,
    2129             :                     true,
    2130             :                     false,
    2131           0 :                     false);
    2132             :             }
    2133             :             else
    2134             :             {
    2135             :                 // string: write regardless of default
    2136             :                 ProcessString(XML_VALUE_TYPE, XML_STRING, false,
    2137           3 :                               XML_NAMESPACE_OFFICE);
    2138             :                 ProcessString(XML_STRING_VALUE,
    2139             :                               GetStringProperty(sPropertyContent, xPropSet),
    2140           3 :                               false, XML_NAMESPACE_OFFICE );
    2141             :             }
    2142           3 :             ProcessString(XML_NAME, sVarName);
    2143           3 :             ExportElement(XML_USER_FIELD_DECL, true);
    2144           6 :         }
    2145             :     }
    2146             :     // else: no declarations element
    2147             : 
    2148             :     // DDE field field masters:
    2149          96 :     if ( !aDdeName.empty() )
    2150             :     {
    2151           0 :         SvXMLElementExport aElem( GetExport(),
    2152             :                                   XML_NAMESPACE_TEXT,
    2153             :                                   XML_DDE_CONNECTION_DECLS,
    2154           0 :                                   true, true );
    2155             : 
    2156           0 :         for (vector<OUString>::iterator aDdeIter = aDdeName.begin();
    2157           0 :              aDdeIter != aDdeName.end();
    2158             :              ++aDdeIter)
    2159             :         {
    2160           0 :             OUString sName = *aDdeIter;
    2161             : 
    2162             :             // get field master property set
    2163           0 :             Reference<XPropertySet> xPropSet;
    2164           0 :             Any aAny = xFieldMasterNameAccess->getByName(sName);
    2165           0 :             aAny >>= xPropSet;
    2166             : 
    2167             :             // check if this connection is being used by a field
    2168           0 :             Reference<XPropertySet> xDummy;
    2169           0 :             if (GetDependentFieldPropertySet(xPropSet, xDummy))
    2170             :             {
    2171             : 
    2172             :                 ProcessString(XML_NAME,
    2173             :                               GetStringProperty(sPropertyName, xPropSet),
    2174           0 :                               false, XML_NAMESPACE_OFFICE);
    2175             : 
    2176             :                 // export elements; can't use ProcessString because
    2177             :                 // elements are in office namespace
    2178             :                 ProcessString(XML_DDE_APPLICATION,
    2179             :                               GetStringProperty(sPropertyDDECommandType,
    2180             :                                                 xPropSet),
    2181           0 :                               false, XML_NAMESPACE_OFFICE);
    2182             :                 ProcessString(XML_DDE_TOPIC,
    2183             :                               GetStringProperty(sPropertyDDECommandFile,
    2184             :                                                 xPropSet),
    2185           0 :                               false, XML_NAMESPACE_OFFICE);
    2186             :                 ProcessString(XML_DDE_ITEM,
    2187             :                               GetStringProperty(sPropertyDDECommandElement,
    2188             :                                                 xPropSet),
    2189           0 :                               false, XML_NAMESPACE_OFFICE);
    2190             :                 bool bIsAutomaticUpdate = GetBoolProperty(
    2191           0 :                     sPropertyIsAutomaticUpdate, xPropSet);
    2192           0 :                 if (bIsAutomaticUpdate)
    2193             :                 {
    2194           0 :                     GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
    2195             :                                              XML_AUTOMATIC_UPDATE,
    2196           0 :                                              XML_TRUE);
    2197             :                 }
    2198             : 
    2199           0 :                 ExportElement(XML_DDE_CONNECTION_DECL, true);
    2200             :             }
    2201             :             // else: no dependent field -> no export of field declaration
    2202           0 :         }
    2203          96 :     }
    2204             :     // else: no declarations element
    2205             : }
    2206             : 
    2207        1130 : void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
    2208             :     bool bExportOnlyUsed)
    2209             : {
    2210        1130 :     delete pUsedMasters;
    2211        1130 :     pUsedMasters = NULL;
    2212             : 
    2213             :     // create used masters set (if none is used)
    2214        1130 :     if (bExportOnlyUsed)
    2215        1059 :         pUsedMasters = new map<Reference<XText>, set<OUString> > ;
    2216        1130 : }
    2217             : 
    2218         297 : void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
    2219             :                                        bool bAddSpace)
    2220             : {
    2221             :     // can't call ExportElement(eElementName, const OUString&) with empty
    2222             :     // string because xmlprinter only uses empty tags if no content
    2223             :     // (not even empty content) was written.
    2224             : 
    2225             :     DBG_ASSERT(XML_TOKEN_INVALID != eElementName, "invalid element name!");
    2226         297 :     if (XML_TOKEN_INVALID != eElementName)
    2227             :     {
    2228             :         // Element
    2229         297 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
    2230         594 :                                   eElementName, bAddSpace, bAddSpace );
    2231             :     } // else: ignore
    2232         297 : }
    2233             : 
    2234         288 : void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,
    2235             :                                        const OUString& sContent,
    2236             :                                        bool bAddSpace)
    2237             : {
    2238             :     DBG_ASSERT(eElementName != XML_TOKEN_INVALID, "invalid element name!");
    2239         288 :     if (eElementName != XML_TOKEN_INVALID)
    2240             :     {
    2241             :         // Element
    2242         288 :         if (eElementName == XML_SENDER_INITIALS)
    2243             :         {
    2244           0 :             if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012)
    2245             :             {
    2246           0 :                 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_LO_EXT,
    2247           0 :                         eElementName, bAddSpace, bAddSpace );
    2248             :                 // export content
    2249           0 :                 GetExport().Characters(sContent);
    2250             :             }
    2251             :         }
    2252             :         else
    2253             :         {
    2254         288 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
    2255         576 :                                       eElementName, bAddSpace, bAddSpace );
    2256             :             // export content
    2257         288 :             GetExport().Characters(sContent);
    2258             :         }
    2259             :     } else {
    2260             :         // always export content
    2261           0 :         GetExport().Characters(sContent);
    2262             :     }
    2263         288 : }
    2264             : 
    2265           0 : void XMLTextFieldExport::ExportMacro(
    2266             :     const Reference<XPropertySet> & rPropSet,
    2267             :     const OUString& rContent )
    2268             : {
    2269             :     // some strings we'll need
    2270           0 :     OUString sEventType( "EventType" );
    2271           0 :     OUString sStarBasic( "StarBasic" );
    2272           0 :     OUString sScript( "Script" );
    2273           0 :     OUString sLibrary( "Library" );
    2274           0 :     OUString sMacroName( "MacroName" );
    2275           0 :     OUString sOnClick( "OnClick" );
    2276           0 :     OUString sPropertyMacroLibrary( "MacroLibrary" );
    2277           0 :     OUString sPropertyMacroName( "MacroName" );
    2278           0 :     OUString sPropertyScriptURL( "ScriptURL" );
    2279             : 
    2280             : 
    2281             :     // the description attribute
    2282             :     ProcessString(XML_DESCRIPTION,
    2283             :                   GetStringProperty(sPropertyHint, rPropSet),
    2284           0 :                   rContent);
    2285             : 
    2286             :     // the element
    2287           0 :     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
    2288           0 :                               XML_EXECUTE_MACRO, false, false );
    2289             : 
    2290             :     // the <office:events>-macro:
    2291             : 
    2292             :     // 1) build sequence of PropertyValues
    2293           0 :     Sequence<PropertyValue> aSeq;
    2294           0 :     OUString sName;
    2295           0 :     rPropSet->getPropertyValue( sPropertyScriptURL ) >>= sName;
    2296             : 
    2297             :     // if the ScriptURL property is not empty then this is a Scripting
    2298             :     // Framework URL, otherwise treat it as a Basic Macro
    2299           0 :     if (!sName.isEmpty())
    2300             :     {
    2301           0 :         aSeq = Sequence<PropertyValue> (2);
    2302           0 :         PropertyValue* pArr = aSeq.getArray();
    2303           0 :         pArr[0].Name = sEventType;
    2304           0 :         pArr[0].Value <<= sScript;
    2305           0 :         pArr[1].Name = sScript;
    2306           0 :         pArr[1].Value = rPropSet->getPropertyValue( sPropertyScriptURL );
    2307             :     }
    2308             :     else
    2309             :     {
    2310           0 :         aSeq = Sequence<PropertyValue> (3);
    2311           0 :         PropertyValue* pArr = aSeq.getArray();
    2312           0 :         pArr[0].Name = sEventType;
    2313           0 :         pArr[0].Value <<= sStarBasic;
    2314           0 :         pArr[1].Name = sLibrary;
    2315           0 :         pArr[1].Value = rPropSet->getPropertyValue( sPropertyMacroLibrary );
    2316           0 :         pArr[2].Name = sMacroName;
    2317           0 :         pArr[2].Value = rPropSet->getPropertyValue( sPropertyMacroName );
    2318             :     }
    2319             : 
    2320             :     // 2) export the sequence
    2321           0 :     GetExport().GetEventExport().ExportSingleEvent( aSeq, sOnClick, false );
    2322             : 
    2323             :     // and finally, the field presentation
    2324           0 :     GetExport().Characters(rContent);
    2325           0 : }
    2326             : 
    2327          10 : void XMLTextFieldExport::ExportMetaField(
    2328             :     const Reference<XPropertySet> & i_xMeta,
    2329             :     bool i_bAutoStyles, bool i_bProgress )
    2330             : {
    2331          10 :     bool doExport(!i_bAutoStyles); // do not export element if autostyles
    2332             :     // check version >= 1.2
    2333          10 :     switch (GetExport().getDefaultVersion()) {
    2334             :         case SvtSaveOptions::ODFVER_011: // fall through
    2335           0 :         case SvtSaveOptions::ODFVER_010: doExport = false; break;
    2336          10 :         default: break;
    2337             :     }
    2338             : 
    2339          10 :     const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW );
    2340          20 :     const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() );
    2341             : 
    2342          10 :     if (doExport)
    2343             :     {
    2344          10 :         const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW );
    2345             : 
    2346             :         // style:data-style-name
    2347             :         ProcessValueAndType(false,
    2348             :             GetIntProperty(sPropertyNumberFormat, i_xMeta),
    2349             :             sEmpty, sEmpty, 0.0, false, false, true,
    2350          10 :             false, false /*, sal_False*/ );
    2351             : 
    2352             :         // text:meta-field without xml:id is invalid
    2353          10 :         xMeta->ensureMetadataReference();
    2354             : 
    2355             :         // xml:id for RDF metadata
    2356          10 :         GetExport().AddAttributeXmlId(xMeta);
    2357             :     }
    2358             : 
    2359          10 :     SvXMLElementExport aElem( GetExport(), doExport,
    2360          30 :         XML_NAMESPACE_TEXT, XML_META_FIELD, false, false );
    2361             : 
    2362             :     // recurse to export content
    2363          10 :     GetExport().GetTextParagraphExport()->
    2364          30 :         exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_bProgress );
    2365          10 : }
    2366             : 
    2367             : /// export all data-style related attributes
    2368          69 : void XMLTextFieldExport::ProcessValueAndType(
    2369             :     bool bIsString,     /// do we process a string or a number?
    2370             :     sal_Int32 nFormatKey,   /// format key for NumberFormatter; inv. if string
    2371             :     const OUString& sContent,   /// string content; possibly invalid
    2372             :     const OUString& sDefault,   /// default string
    2373             :     double fValue,          /// float content; possibly invalid
    2374             :     bool bExportValue,  /// export value attribute?
    2375             :     bool bExportValueType,  /// export value-type attribute?
    2376             :     bool bExportStyle,  /// export style-sttribute?
    2377             :     bool bForceSystemLanguage, /// export language attributes?
    2378             :     bool bTimeStyle)    // exporting a time style?
    2379             : {
    2380             :     // String or number?
    2381          69 :     if (bIsString)
    2382             :     {
    2383             : 
    2384             :         // string: attributes value-type=string, string-value=...
    2385             : 
    2386           0 :         if (bExportValue || bExportValueType)
    2387             :         {
    2388             :             XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
    2389           0 :                 GetExport(), sContent, sDefault, bExportValue);
    2390             :         }
    2391             : 
    2392             :     }
    2393             :     else
    2394             :     {
    2395             : 
    2396             :         // number: value-type=..., value...=..., data-style-name=...
    2397             : 
    2398             :         DBG_ASSERT(bExportValueType || !bExportValue, "value w/o value type not supported!");
    2399             : 
    2400             :         // take care of illegal formats
    2401             :         // (shouldn't happen, but does if document is corrupted)
    2402          69 :         if (-1 != nFormatKey)
    2403             :         {
    2404          61 :             if (bExportValue || bExportValueType)
    2405             :             {
    2406             :                 XMLNumberFormatAttributesExportHelper::
    2407             :                     SetNumberFormatAttributes(
    2408           2 :                         GetExport(), nFormatKey, fValue, bExportValue);
    2409             :             }
    2410             : 
    2411          61 :             if (bExportStyle)
    2412             :             {
    2413             :                 // don't export language (if desired)
    2414          60 :                 if( bForceSystemLanguage )
    2415             :                     nFormatKey =
    2416          57 :                         GetExport().dataStyleForceSystemLanguage( nFormatKey );
    2417             : 
    2418             :                 OUString sDataStyleName =
    2419          60 :                     GetExport().getDataStyleName(nFormatKey, bTimeStyle);
    2420          60 :                 if( !sDataStyleName.isEmpty() )
    2421             :                 {
    2422          60 :                     GetExport().AddAttribute( XML_NAMESPACE_STYLE,
    2423             :                                               XML_DATA_STYLE_NAME,
    2424          60 :                                                 sDataStyleName );
    2425          60 :                 } // else: ignore (no valid number format)
    2426             :             }  // else: ignore (no number format)
    2427             :         }
    2428             :     }
    2429          69 : }
    2430             : 
    2431             : 
    2432             : 
    2433             : /// process display related properties
    2434          61 : void XMLTextFieldExport::ProcessDisplay(bool bIsVisible,
    2435             :                                         bool bIsCommand,
    2436             :                                         bool bValueDefault)
    2437             : {
    2438             :     enum XMLTokenEnum eValue;
    2439             : 
    2440          61 :     if (bIsVisible)
    2441             :     {
    2442          61 :         eValue = bIsCommand ? XML_FORMULA : XML_VALUE;
    2443             :     }
    2444             :     else
    2445             :     {
    2446           0 :         eValue = XML_NONE;
    2447             :     }
    2448             : 
    2449             :     // omit attribute if default
    2450          61 :     if (!bValueDefault || (eValue != XML_VALUE))
    2451             :     {
    2452           0 :         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eValue);
    2453             :     }
    2454          61 : }
    2455             : 
    2456             : 
    2457             : 
    2458             : /// export boolean property
    2459          60 : void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName,
    2460             :                                         bool bBool, bool bDefault)
    2461             : {
    2462             :     DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token");
    2463          60 :     if ( XML_TOKEN_INVALID == eName )
    2464          60 :         return;
    2465             : 
    2466             :     // write attribute (if different than default)
    2467             :     // negate to force 0/1 values (and make sal_Bool comparable)
    2468          60 :     if ((!bBool) != (!bDefault)) {
    2469           0 :         GetExport().AddAttribute(XML_NAMESPACE_TEXT, eName,
    2470           0 :                                  (bBool ? XML_TRUE : XML_FALSE) );
    2471             :     }
    2472             : }
    2473             : 
    2474             : 
    2475             : 
    2476             : 
    2477             : /// export string attribute
    2478         512 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
    2479             :                                        const OUString& sValue,
    2480             :                                        bool bOmitEmpty,
    2481             :                                        sal_uInt16 nPrefix)
    2482             : {
    2483             :     DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token");
    2484         512 :     if ( XML_TOKEN_INVALID == eName )
    2485           0 :         return;
    2486             : 
    2487             :     // check for empty string, if applicable
    2488         512 :     if ( bOmitEmpty && sValue.isEmpty() )
    2489          18 :         return;
    2490             : 
    2491             :     // write attribute
    2492         494 :     GetExport().AddAttribute(nPrefix, eName, sValue);
    2493             : }
    2494             : 
    2495           0 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
    2496             :                                        sal_uInt16 nValuePrefix,
    2497             :                                        const OUString& sValue,
    2498             :                                        bool bOmitEmpty,
    2499             :                                        sal_uInt16 nPrefix)
    2500             : {
    2501             :     OUString sQValue =
    2502           0 :         GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix, sValue, false );
    2503           0 :     ProcessString( eName, sQValue, bOmitEmpty, nPrefix );
    2504           0 : }
    2505             : 
    2506             : /// export a string attribute
    2507           0 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
    2508             :                                        const OUString& sValue,
    2509             :                                        const OUString& sDefault,
    2510             :                                        sal_uInt16 nPrefix)
    2511             : {
    2512           0 :     if (sValue != sDefault)
    2513             :     {
    2514           0 :         ProcessString(eName, sValue, false, nPrefix);
    2515             :     }
    2516           0 : }
    2517             : 
    2518             : /// export a string attribute
    2519           1 : void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName,
    2520             :                                        sal_uInt16 nValuePrefix,
    2521             :                                        const OUString& sValue,
    2522             :                                        const OUString& sDefault,
    2523             :                                        sal_uInt16 nPrefix)
    2524             : {
    2525           1 :     if (sValue != sDefault)
    2526             :     {
    2527           0 :         ProcessString(eName, nValuePrefix, sValue, false, nPrefix);
    2528             :     }
    2529           1 : }
    2530             : 
    2531             : 
    2532             : /// export string attribute
    2533          15 : void XMLTextFieldExport::ProcessString(
    2534             :     enum XMLTokenEnum eName,
    2535             :     enum XMLTokenEnum eValue,
    2536             :     bool bOmitEmpty,
    2537             :     sal_uInt16 nPrefix)
    2538             : {
    2539             :     DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token" );
    2540             :     DBG_ASSERT( bOmitEmpty || (eValue != XML_TOKEN_INVALID),
    2541             :                 "invalid value token" );
    2542          15 :     if ( XML_TOKEN_INVALID == eName )
    2543           0 :         return;
    2544             : 
    2545             :     // check for empty string, if applicable
    2546          15 :     if (bOmitEmpty && (eValue == XML_TOKEN_INVALID))
    2547           0 :         return;
    2548             : 
    2549          15 :     GetExport().AddAttribute(nPrefix, eName, eValue);
    2550             : }
    2551             : 
    2552             : /// export a string attribute
    2553           0 : void XMLTextFieldExport::ProcessString(
    2554             :     enum XMLTokenEnum eName,
    2555             :     enum XMLTokenEnum eValue,
    2556             :     enum XMLTokenEnum eDefault,
    2557             :     sal_uInt16 nPrefix)
    2558             : {
    2559           0 :     if ( eValue != eDefault )
    2560           0 :         ProcessString( eName, eValue, false, nPrefix);
    2561           0 : }
    2562             : 
    2563             : 
    2564             : /// export a string as a sequence of paragraphs
    2565           0 : void XMLTextFieldExport::ProcessParagraphSequence(
    2566             :     const OUString& sParagraphSequence)
    2567             : {
    2568             :     // iterate over all string-pieces separated by return (0x0a) and
    2569             :     // put each inside a paragraph element.
    2570           0 :     SvXMLTokenEnumerator aEnumerator(sParagraphSequence, sal_Char(0x0a));
    2571           0 :     OUString aSubString;
    2572           0 :     while (aEnumerator.getNextToken(aSubString))
    2573             :     {
    2574             :         SvXMLElementExport aParagraph(
    2575           0 :             GetExport(), XML_NAMESPACE_TEXT, XML_P, true, false);
    2576           0 :         GetExport().Characters(aSubString);
    2577           0 :     }
    2578           0 : }
    2579             : 
    2580             : // export an integer attribute
    2581         296 : void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName,
    2582             :                                         sal_Int32 nNum)
    2583             : {
    2584             :     DBG_ASSERT( eName != XML_TOKEN_INVALID, "invalid element token");
    2585         296 :     if ( XML_TOKEN_INVALID == eName )
    2586         296 :         return;
    2587             : 
    2588         296 :     GetExport().AddAttribute(XML_NAMESPACE_TEXT, eName,
    2589         592 :                              OUString::number(nNum));
    2590             : }
    2591             : 
    2592             : /// export an integer attribute, omit if default
    2593           9 : void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName,
    2594             :                                         sal_Int32 nNum, sal_Int32 nDefault)
    2595             : {
    2596           9 :     if (nNum != nDefault)
    2597           0 :         ProcessInteger(eName, nNum);
    2598           9 : }
    2599             : 
    2600             : 
    2601             : 
    2602             : /// export a numbering type
    2603          13 : void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType)
    2604             : {
    2605             :     // process only if real format (not: like page descriptor)
    2606          13 :     if (NumberingType::PAGE_DESCRIPTOR != nNumberingType)
    2607             :     {
    2608           0 :         OUStringBuffer sTmp( 10 );
    2609             :         // number type: num format
    2610           0 :         GetExport().GetMM100UnitConverter().convertNumFormat( sTmp,
    2611           0 :                                                               nNumberingType );
    2612           0 :         GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
    2613           0 :                                       sTmp.makeStringAndClear() );
    2614             :         // and letter sync, if applicable
    2615           0 :         SvXMLUnitConverter::convertNumLetterSync( sTmp, nNumberingType );
    2616             : 
    2617           0 :         if (!sTmp.isEmpty())
    2618             :         {
    2619           0 :             GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC,
    2620           0 :                                      sTmp.makeStringAndClear() );
    2621           0 :         }
    2622             :     }
    2623             :     // else: like page descriptor => ignore
    2624          13 : }
    2625             : 
    2626             : 
    2627             : /// export a date, time, or duration
    2628           0 : void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
    2629             :                                          double dValue,
    2630             :                                          bool bIsDate,
    2631             :                                          bool bIsDuration,
    2632             :                                          bool bOmitDurationIfZero,
    2633             :                                          sal_uInt16 nPrefix)
    2634             : {
    2635             :     // truncate for date granularity
    2636           0 :     if (bIsDate)
    2637             :     {
    2638           0 :         dValue = ::rtl::math::approxFloor(dValue);
    2639             :     }
    2640             : 
    2641           0 :     OUStringBuffer aBuffer;
    2642           0 :     if (bIsDuration)
    2643             :     {
    2644             :         // date/time durationM handle bOmitDurationIfZero
    2645           0 :         if (!bOmitDurationIfZero || !::rtl::math::approxEqual(dValue, 0.0))
    2646             :         {
    2647           0 :             ::sax::Converter::convertDuration(aBuffer, dValue);
    2648             :         }
    2649             :     }
    2650             :     else
    2651             :     {
    2652             :         // date/time value
    2653           0 :         rExport.GetMM100UnitConverter().convertDateTime(aBuffer, dValue);
    2654             :     }
    2655             : 
    2656             :     // output attribute
    2657           0 :     ProcessString(eName, aBuffer.makeStringAndClear(), true, nPrefix);
    2658           0 : }
    2659             : 
    2660             : /// export a date or time
    2661          33 : void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
    2662             :                                          const util::DateTime& rTime,
    2663             :                                          bool bIsDate,
    2664             :                                          sal_uInt16 nPrefix)
    2665             : {
    2666          33 :     OUStringBuffer aBuffer;
    2667             : 
    2668          33 :     util::DateTime aDateTime(rTime);
    2669             : 
    2670             :     // truncate dates
    2671          33 :     if(bIsDate)
    2672             :     {
    2673           0 :         aDateTime.NanoSeconds = 0;
    2674           0 :         aDateTime.Seconds = 0;
    2675           0 :         aDateTime.Minutes = 0;
    2676           0 :         aDateTime.Hours = 0;
    2677             :     }
    2678             : 
    2679             :     // date/time value
    2680          33 :     ::sax::Converter::convertDateTime(aBuffer, aDateTime, 0);
    2681             : 
    2682             :     // output attribute
    2683          33 :     ProcessString(eName, aBuffer.makeStringAndClear(), true, nPrefix);
    2684          33 : }
    2685             : 
    2686             : /// export a date, time, or duration
    2687           3 : void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
    2688             :                                          sal_Int32 nMinutes,
    2689             :                                          bool bIsDate,
    2690             :                                          bool bIsDuration,
    2691             :                                          bool bOmitDurationIfZero,
    2692             :                                          sal_uInt16 nPrefix)
    2693             : {
    2694             :     // handle bOmitDurationIfZero here, because we can precisely compare ints
    2695           3 :     if (!(bIsDuration && bOmitDurationIfZero && (nMinutes==0)))
    2696             :     {
    2697             :         ProcessDateTime(eName, (double)nMinutes / (double)(24*60),
    2698           0 :                         bIsDate, bIsDuration, bOmitDurationIfZero, nPrefix);
    2699             :     }
    2700           3 : }
    2701             : 
    2702             : /// export a time or dateTime
    2703          24 : void XMLTextFieldExport::ProcessTimeOrDateTime(enum XMLTokenEnum eName,
    2704             :                                          const util::DateTime& rTime,
    2705             :                                          sal_uInt16 nPrefix)
    2706             : {
    2707          24 :     OUStringBuffer aBuffer;
    2708             : 
    2709             :     // date/time value
    2710          24 :     ::sax::Converter::convertTimeOrDateTime(aBuffer, rTime, 0);
    2711             : 
    2712             :     // output attribute
    2713          24 :     ProcessString(eName, aBuffer.makeStringAndClear(), true, nPrefix);
    2714          24 : }
    2715             : 
    2716             : 
    2717             : SvXMLEnumMapEntry const aBibliographyDataTypeMap[] =
    2718             : {
    2719             :     { XML_ARTICLE,          BibliographyDataType::ARTICLE },
    2720             :     { XML_BOOK,             BibliographyDataType::BOOK },
    2721             :     { XML_BOOKLET,          BibliographyDataType::BOOKLET },
    2722             :     { XML_CONFERENCE,       BibliographyDataType::CONFERENCE },
    2723             :     { XML_CUSTOM1,          BibliographyDataType::CUSTOM1 },
    2724             :     { XML_CUSTOM2,          BibliographyDataType::CUSTOM2 },
    2725             :     { XML_CUSTOM3,          BibliographyDataType::CUSTOM3 },
    2726             :     { XML_CUSTOM4,          BibliographyDataType::CUSTOM4 },
    2727             :     { XML_CUSTOM5,          BibliographyDataType::CUSTOM5 },
    2728             :     { XML_EMAIL,            BibliographyDataType::EMAIL },
    2729             :     { XML_INBOOK,           BibliographyDataType::INBOOK },
    2730             :     { XML_INCOLLECTION,     BibliographyDataType::INCOLLECTION },
    2731             :     { XML_INPROCEEDINGS,    BibliographyDataType::INPROCEEDINGS },
    2732             :     { XML_JOURNAL,          BibliographyDataType::JOURNAL },
    2733             :     { XML_MANUAL,           BibliographyDataType::MANUAL },
    2734             :     { XML_MASTERSTHESIS,    BibliographyDataType::MASTERSTHESIS },
    2735             :     { XML_MISC,             BibliographyDataType::MISC },
    2736             :     { XML_PHDTHESIS,        BibliographyDataType::PHDTHESIS },
    2737             :     { XML_PROCEEDINGS,      BibliographyDataType::PROCEEDINGS },
    2738             :     { XML_TECHREPORT,       BibliographyDataType::TECHREPORT },
    2739             :     { XML_UNPUBLISHED,      BibliographyDataType::UNPUBLISHED },
    2740             :     { XML_WWW,              BibliographyDataType::WWW },
    2741             :     { XML_TOKEN_INVALID, 0 }
    2742             : };
    2743             : 
    2744             : 
    2745             : 
    2746           0 : void XMLTextFieldExport::ProcessBibliographyData(
    2747             :     const Reference<XPropertySet>& rPropSet)
    2748             : {
    2749             :     // get the values
    2750           0 :     Any aAny = rPropSet->getPropertyValue(sPropertyFields);
    2751           0 :     Sequence<PropertyValue> aValues;
    2752           0 :     aAny >>= aValues;
    2753             : 
    2754             :     // one attribute per value (unless empty)
    2755           0 :     sal_Int32 nLength = aValues.getLength();
    2756           0 :     for (sal_Int32 i = 0; i < nLength; i++)
    2757             :     {
    2758           0 :         if( aValues[i].Name == "BibiliographicType" )
    2759             :         {
    2760           0 :             sal_Int16 nTypeId = 0;
    2761           0 :             aValues[i].Value >>= nTypeId;
    2762           0 :             OUStringBuffer sBuf;
    2763             : 
    2764           0 :             if (SvXMLUnitConverter::convertEnum(sBuf, nTypeId,
    2765           0 :                                                 aBibliographyDataTypeMap))
    2766             :             {
    2767             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
    2768             :                                      XML_BIBLIOGRAPHY_TYPE,
    2769           0 :                                      sBuf.makeStringAndClear());
    2770           0 :             }
    2771             :             // else: ignore this argument
    2772             :         }
    2773             :         else
    2774             :         {
    2775           0 :             OUString sStr;
    2776           0 :             aValues[i].Value >>= sStr;
    2777             : 
    2778           0 :             if (!sStr.isEmpty())
    2779             :             {
    2780             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
    2781           0 :                                      MapBibliographyFieldName(aValues[i].Name),
    2782           0 :                                      sStr);
    2783           0 :             }
    2784             :         }
    2785           0 :     }
    2786           0 : }
    2787             : 
    2788             : /// export CommandTypeAttribute
    2789          60 : void XMLTextFieldExport::ProcessCommandType(
    2790             :     sal_Int32 nCommandType)
    2791             : {
    2792          60 :     enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
    2793          60 :     switch( nCommandType )
    2794             :     {
    2795          60 :         case sdb::CommandType::TABLE:   eToken = XML_TABLE; break;
    2796           0 :         case sdb::CommandType::QUERY:   eToken = XML_QUERY; break;
    2797           0 :         case sdb::CommandType::COMMAND: eToken = XML_COMMAND; break;
    2798             :     }
    2799             : 
    2800          60 :     if( eToken != XML_TOKEN_INVALID )
    2801          60 :         rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_TABLE_TYPE, eToken );
    2802          60 : }
    2803             : 
    2804             : 
    2805           0 : void XMLTextFieldExport::ProcessStringSequence(
    2806             :     const Sequence<OUString>& rSequence,
    2807             :     const OUString& sSelected )
    2808             : {
    2809             :     // find selected element
    2810           0 :     sal_Int32 nSelected = -1;
    2811           0 :     sal_Int32 nLength = rSequence.getLength();
    2812           0 :     const OUString* pSequence = rSequence.getConstArray();
    2813           0 :     for( sal_Int32 i = 0; i < nLength; i++ )
    2814             :     {
    2815           0 :         if( pSequence[i] == sSelected )
    2816           0 :             nSelected = i;
    2817             :     }
    2818             : 
    2819             :     // delegate to ProcessStringSequence(OUString,sal_Int32)
    2820           0 :     ProcessStringSequence( rSequence, nSelected );
    2821           0 : }
    2822             : 
    2823           0 : void XMLTextFieldExport::ProcessStringSequence(
    2824             :     const Sequence<OUString>& rSequence,
    2825             :     sal_Int32 nSelected )
    2826             : {
    2827           0 :     sal_Int32 nLength = rSequence.getLength();
    2828           0 :     const OUString* pSequence = rSequence.getConstArray();
    2829           0 :     for( sal_Int32 i = 0; i < nLength; i++ )
    2830             :     {
    2831           0 :         if( i == nSelected )
    2832             :             rExport.AddAttribute( XML_NAMESPACE_TEXT,
    2833           0 :                                   XML_CURRENT_SELECTED, XML_TRUE );
    2834           0 :         rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_VALUE, pSequence[i] );
    2835             :         SvXMLElementExport aElement( rExport, XML_NAMESPACE_TEXT, XML_LABEL,
    2836           0 :                                      false, false );
    2837           0 :     }
    2838           0 : }
    2839             : 
    2840          60 : void XMLTextFieldExport::ExportDataBaseElement(
    2841             :     enum XMLTokenEnum eElementName,
    2842             :     const OUString& sPresentation,
    2843             :     const Reference<XPropertySet>& rPropertySet,
    2844             :     const Reference<XPropertySetInfo>& rPropertySetInfo )
    2845             : {
    2846             :     DBG_ASSERT( eElementName != XML_TOKEN_INVALID, "need token" );
    2847             :     DBG_ASSERT( rPropertySet.is(), "need property set" );
    2848             :     DBG_ASSERT( rPropertySetInfo.is(), "need property set info" );
    2849             : 
    2850             :     // get database properties
    2851          60 :     OUString sDataBaseName;
    2852         120 :     OUString sDataBaseURL;
    2853         120 :     OUString sStr;
    2854         180 :     if( ( rPropertySet->getPropertyValue( sPropertyDataBaseName ) >>= sStr )
    2855         180 :         && !sStr.isEmpty() )
    2856             :     {
    2857          60 :         sDataBaseName = sStr;
    2858             :     }
    2859           0 :     else if( rPropertySetInfo->hasPropertyByName( sPropertyDataBaseURL ) &&
    2860           0 :              (rPropertySet->getPropertyValue( sPropertyDataBaseURL ) >>= sStr) &&
    2861           0 :              !sStr.isEmpty() )
    2862             :     {
    2863           0 :         sDataBaseURL = sStr;
    2864             :     }
    2865             : 
    2866             :     // add database name property (if present)
    2867          60 :     if( !sDataBaseName.isEmpty() )
    2868             :         rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_DATABASE_NAME,
    2869          60 :                               sDataBaseName );
    2870          60 :     SvXMLElementExport aDataBaseElement( GetExport(),
    2871             :                                          XML_NAMESPACE_TEXT, eElementName,
    2872         120 :                                          false, false );
    2873             : 
    2874             :     // write URL as children
    2875          60 :     if( !sDataBaseURL.isEmpty() )
    2876             :     {
    2877           0 :         rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sDataBaseURL );
    2878             :         SvXMLElementExport aDataSourceElement(
    2879           0 :             GetExport(), XML_NAMESPACE_FORM, XML_CONNECTION_RESOURCE,
    2880           0 :             false, false );
    2881             :     }
    2882             : 
    2883             :     // write presentation
    2884         120 :     rExport.Characters( sPresentation );
    2885          60 : }
    2886             : 
    2887             : 
    2888             : 
    2889             : // explode a field master name into field type and field name
    2890         595 : bool XMLTextFieldExport::ExplodeFieldMasterName(
    2891             :     const OUString& sMasterName, OUString& sFieldType, OUString& sVarName)
    2892             : {
    2893         595 :     sal_Int32 nLength = sFieldMasterPrefix.getLength();
    2894         595 :     sal_Int32 nSeparator = sMasterName.indexOf('.', nLength);
    2895         595 :     bool bReturn = true;
    2896             : 
    2897             : #ifdef DBG_UTIL
    2898             :     // check for service name
    2899             :     bReturn &= (0 == sFieldMasterPrefix.compareTo(sMasterName, nLength));
    2900             : #endif
    2901             : 
    2902             :     // '.' found?
    2903         595 :     if (nSeparator <= nLength) {
    2904           1 :         nSeparator = sMasterName.getLength();
    2905             :         SAL_WARN("xmloff.text", "no field var name!");
    2906           1 :         bReturn = false;
    2907             :     }
    2908             :     else
    2909             :     {
    2910         594 :         sFieldType = sMasterName.copy(nLength, nSeparator-nLength);
    2911         594 :         sVarName = sMasterName.copy(nSeparator+1);
    2912             :     }
    2913             : 
    2914         595 :     return bReturn;
    2915             : }
    2916             : 
    2917             : 
    2918             : // for XDependentTextFields, get PropertySet of FieldMaster
    2919          60 : Reference<XPropertySet> XMLTextFieldExport::GetMasterPropertySet(
    2920             :     const Reference<XTextField> & rTextField)
    2921             : {
    2922             :     // name, value => get Property set of TextFieldMaster
    2923          60 :     Reference<XDependentTextField> xDep(rTextField, UNO_QUERY);
    2924          60 :     return xDep->getTextFieldMaster();
    2925             : }
    2926             : 
    2927             : // get PropertySet of (any; the first) dependent field
    2928           1 : bool XMLTextFieldExport::GetDependentFieldPropertySet(
    2929             :     const Reference<XPropertySet> & xMaster,
    2930             :     Reference<XPropertySet> & xField)
    2931             : {
    2932           1 :     Any aAny;
    2933           2 :     Sequence<Reference<XDependentTextField> > aFields;
    2934           1 :     aAny = xMaster->getPropertyValue(sPropertyDependentTextFields);
    2935           1 :     aAny >>= aFields;
    2936             : 
    2937             :     // any fields?
    2938           1 :     if (aFields.getLength() > 0)
    2939             :     {
    2940             :         // get first one and return
    2941           1 :         Reference<XDependentTextField> xTField = aFields[0];
    2942           1 :         xField = Reference<XPropertySet>(xTField, UNO_QUERY);
    2943             :         DBG_ASSERT(xField.is(),
    2944             :                   "Surprisinlgy, this TextField refuses to be a PropertySet!");
    2945           1 :         return true;
    2946             :     }
    2947             :     else
    2948             :     {
    2949           0 :         return false;
    2950           1 :     }
    2951             : }
    2952             : 
    2953             : 
    2954             : /// map placeholder type
    2955           0 : enum XMLTokenEnum XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType)
    2956             : {
    2957           0 :     enum XMLTokenEnum eType = XML_TEXT;
    2958             : 
    2959           0 :     switch (nType)
    2960             :     {
    2961             :         case PlaceholderType::TEXT:
    2962           0 :             eType = XML_TEXT;
    2963           0 :             break;
    2964             : 
    2965             :         case PlaceholderType::TABLE:
    2966           0 :             eType = XML_TABLE;
    2967           0 :             break;
    2968             : 
    2969             :         case PlaceholderType::TEXTFRAME:
    2970           0 :             eType = XML_TEXT_BOX;
    2971           0 :             break;
    2972             : 
    2973             :         case PlaceholderType::GRAPHIC:
    2974           0 :             eType = XML_IMAGE;
    2975           0 :             break;
    2976             : 
    2977             :         case PlaceholderType::OBJECT:
    2978           0 :             eType = XML_OBJECT;
    2979           0 :             break;
    2980             : 
    2981             :         default:
    2982             :             // unknown placeholder: XML_TEXT
    2983             :             OSL_FAIL("unknown placeholder type");
    2984             :     }
    2985             : 
    2986           0 :     return eType;
    2987             : }
    2988             : 
    2989             : 
    2990             : /// element name for author fields
    2991           0 : enum XMLTokenEnum XMLTextFieldExport::MapAuthorFieldName(
    2992             :     const Reference<XPropertySet> & xPropSet)
    2993             : {
    2994             :     // Initalen oder voller Name?
    2995           0 :     return GetBoolProperty(sPropertyFullName, xPropSet)
    2996           0 :         ? XML_AUTHOR_NAME : XML_AUTHOR_INITIALS;
    2997             : }
    2998             : 
    2999           9 : enum XMLTokenEnum XMLTextFieldExport::MapPageNumberName(
    3000             :     const Reference<XPropertySet> & xPropSet,
    3001             :     sal_Int32& nOffset)
    3002             : {
    3003           9 :     enum XMLTokenEnum eName = XML_TOKEN_INVALID;
    3004             :     PageNumberType ePage;
    3005           9 :     Any aAny = xPropSet->getPropertyValue(sPropertySubType);
    3006           9 :     ePage = *static_cast<PageNumberType const *>(aAny.getValue());
    3007             : 
    3008           9 :     switch (ePage)
    3009             :     {
    3010             :         case PageNumberType_PREV:
    3011           0 :             eName = XML_PREVIOUS;
    3012           0 :             nOffset += 1;
    3013           0 :             break;
    3014             :         case PageNumberType_CURRENT:
    3015           9 :             eName = XML_CURRENT;
    3016           9 :             break;
    3017             :         case PageNumberType_NEXT:
    3018           0 :             eName = XML_NEXT;
    3019           0 :             nOffset -= 1;
    3020           0 :             break;
    3021             :         default:
    3022             :             OSL_FAIL("unknown page number type");
    3023           0 :             eName = XML_TOKEN_INVALID;
    3024           0 :             break;
    3025             :     }
    3026             : 
    3027           9 :     return eName;
    3028             : }
    3029             : 
    3030             : /// map TemplateDisplayFormat to XML
    3031           0 : enum XMLTokenEnum XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat)
    3032             : {
    3033           0 :     enum XMLTokenEnum eName = XML_TOKEN_INVALID;
    3034             : 
    3035           0 :     switch (nFormat)
    3036             :     {
    3037             :         case TemplateDisplayFormat::FULL:
    3038           0 :             eName = XML_FULL;
    3039           0 :             break;
    3040             :         case TemplateDisplayFormat::PATH:
    3041           0 :             eName = XML_PATH;
    3042           0 :             break;
    3043             :         case TemplateDisplayFormat::NAME:
    3044           0 :             eName = XML_NAME;
    3045           0 :             break;
    3046             :         case TemplateDisplayFormat::NAME_AND_EXT:
    3047           0 :             eName = XML_NAME_AND_EXTENSION;
    3048           0 :             break;
    3049             :         case TemplateDisplayFormat::AREA:
    3050           0 :             eName = XML_AREA;
    3051           0 :             break;
    3052             :         case TemplateDisplayFormat::TITLE:
    3053           0 :             eName = XML_TITLE;
    3054           0 :             break;
    3055             :         default:
    3056             :             OSL_FAIL("unknown template display format");
    3057           0 :             eName = XML_TOKEN_INVALID;
    3058           0 :             break;
    3059             :     }
    3060             : 
    3061           0 :     return eName;
    3062             : }
    3063             : 
    3064             : /// map count/statistics field token to XML name
    3065          33 : enum XMLTokenEnum XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken)
    3066             : {
    3067          33 :     enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
    3068             : 
    3069          33 :     switch (nToken)
    3070             :     {
    3071             :         case FIELD_ID_COUNT_PAGES:
    3072          33 :             eElement = XML_PAGE_COUNT;
    3073          33 :             break;
    3074             :         case FIELD_ID_COUNT_PARAGRAPHS:
    3075           0 :             eElement = XML_PARAGRAPH_COUNT;
    3076           0 :             break;
    3077             :         case FIELD_ID_COUNT_WORDS:
    3078           0 :             eElement = XML_WORD_COUNT;
    3079           0 :             break;
    3080             :         case FIELD_ID_COUNT_CHARACTERS:
    3081           0 :             eElement = XML_CHARACTER_COUNT;
    3082           0 :             break;
    3083             :         case FIELD_ID_COUNT_TABLES:
    3084           0 :             eElement = XML_TABLE_COUNT;
    3085           0 :             break;
    3086             :         case FIELD_ID_COUNT_GRAPHICS:
    3087           0 :             eElement = XML_IMAGE_COUNT;
    3088           0 :             break;
    3089             :         case FIELD_ID_COUNT_OBJECTS:
    3090           0 :             eElement = XML_OBJECT_COUNT;
    3091           0 :             break;
    3092             :         default:
    3093             :             OSL_FAIL("no count field token");
    3094           0 :             eElement = XML_TOKEN_INVALID;
    3095           0 :             break;
    3096             :     }
    3097             : 
    3098          33 :     return eElement;
    3099             : }
    3100             : 
    3101             : /// map ChapterDisplayFormat to XML string
    3102           3 : enum XMLTokenEnum XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat)
    3103             : {
    3104           3 :     enum XMLTokenEnum eName = XML_TOKEN_INVALID;
    3105             : 
    3106           3 :     switch (nFormat)
    3107             :     {
    3108             :         case ChapterFormat::NAME:
    3109           3 :             eName = XML_NAME;
    3110           3 :             break;
    3111             :         case ChapterFormat::NUMBER:
    3112           0 :             eName = XML_NUMBER;
    3113           0 :             break;
    3114             :         case ChapterFormat::NAME_NUMBER:
    3115           0 :             eName = XML_NUMBER_AND_NAME;
    3116           0 :             break;
    3117             :         case ChapterFormat::NO_PREFIX_SUFFIX:
    3118           0 :             eName = XML_PLAIN_NUMBER_AND_NAME;
    3119           0 :             break;
    3120             :         case ChapterFormat::DIGIT:
    3121           0 :             eName = XML_PLAIN_NUMBER;
    3122           0 :             break;
    3123             :         default:
    3124             :             OSL_FAIL("unknown chapter display format");
    3125           0 :             eName = XML_TOKEN_INVALID;
    3126           0 :             break;
    3127             :     }
    3128             : 
    3129           3 :     return eName;
    3130             : }
    3131             : 
    3132             : 
    3133             : /// map FilenameDisplayFormat to XML attribute names
    3134           0 : enum XMLTokenEnum XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat)
    3135             : {
    3136           0 :     enum XMLTokenEnum eName = XML_TOKEN_INVALID;
    3137             : 
    3138           0 :     switch (nFormat)
    3139             :     {
    3140             :         case FilenameDisplayFormat::FULL:
    3141           0 :             eName = XML_FULL;
    3142           0 :             break;
    3143             :         case FilenameDisplayFormat::PATH:
    3144           0 :             eName = XML_PATH;
    3145           0 :             break;
    3146             :         case FilenameDisplayFormat::NAME:
    3147           0 :             eName = XML_NAME;
    3148           0 :             break;
    3149             :         case FilenameDisplayFormat::NAME_AND_EXT:
    3150           0 :             eName = XML_NAME_AND_EXTENSION;
    3151           0 :             break;
    3152             :         default:
    3153             :             OSL_FAIL("unknown filename display format");
    3154             :     }
    3155             : 
    3156           0 :     return eName;
    3157             : }
    3158             : 
    3159             : 
    3160             : /// map ReferenceFieldPart to XML string
    3161           2 : enum XMLTokenEnum XMLTextFieldExport::MapReferenceType(sal_Int16 nType)
    3162             : {
    3163           2 :     enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
    3164             : 
    3165           2 :     switch (nType)
    3166             :     {
    3167             :         case ReferenceFieldPart::PAGE:
    3168           0 :             eElement = XML_PAGE;
    3169           0 :             break;
    3170             :         case ReferenceFieldPart::CHAPTER:
    3171           0 :             eElement = XML_CHAPTER;
    3172           0 :             break;
    3173             :         case ReferenceFieldPart::TEXT:
    3174           2 :             eElement = XML_TEXT;
    3175           2 :             break;
    3176             :         case ReferenceFieldPart::UP_DOWN:
    3177           0 :             eElement = XML_DIRECTION;
    3178           0 :             break;
    3179             :         case ReferenceFieldPart::CATEGORY_AND_NUMBER:
    3180           0 :             eElement = XML_CATEGORY_AND_VALUE;
    3181           0 :             break;
    3182             :         case ReferenceFieldPart::ONLY_CAPTION:
    3183           0 :             eElement = XML_CAPTION;
    3184           0 :             break;
    3185             :         case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER:
    3186           0 :             eElement = XML_VALUE;
    3187           0 :             break;
    3188             :         case ReferenceFieldPart::PAGE_DESC:
    3189             :             // small hack: this value never gets written, because
    3190             :             // XML_TEMPLATE is default
    3191           0 :             eElement = XML_TEMPLATE;
    3192           0 :             break;
    3193             :         // Core implementation for direct cross-references (#i81002#)
    3194             :         case ReferenceFieldPart::NUMBER:
    3195           0 :             eElement = XML_NUMBER;
    3196           0 :             break;
    3197             :         case ReferenceFieldPart::NUMBER_NO_CONTEXT:
    3198           0 :             eElement = XML_NUMBER_NO_SUPERIOR;
    3199           0 :             break;
    3200             :         case ReferenceFieldPart::NUMBER_FULL_CONTEXT:
    3201           0 :             eElement = XML_NUMBER_ALL_SUPERIOR;
    3202           0 :             break;
    3203             :         default:
    3204             :             OSL_FAIL("unknown reference type");
    3205           0 :             eElement = XML_TEMPLATE;
    3206           0 :             break;
    3207             :     }
    3208             : 
    3209           2 :     return eElement;
    3210             : }
    3211             : 
    3212             : /// map ReferenceFieldPart to XML string
    3213           0 : enum XMLTokenEnum XMLTextFieldExport::MapReferenceSource(sal_Int16 nType)
    3214             : {
    3215           0 :     enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
    3216             : 
    3217           0 :     switch (nType)
    3218             :     {
    3219             :         case ReferenceFieldSource::REFERENCE_MARK:
    3220           0 :             eElement = XML_REFERENCE_REF;
    3221           0 :             break;
    3222             :         case ReferenceFieldSource::SEQUENCE_FIELD:
    3223           0 :             eElement = XML_SEQUENCE_REF;
    3224           0 :             break;
    3225             :         case ReferenceFieldSource::BOOKMARK:
    3226           0 :             eElement = XML_BOOKMARK_REF;
    3227           0 :             break;
    3228             :         case ReferenceFieldSource::FOOTNOTE:
    3229             :         case ReferenceFieldSource::ENDNOTE:
    3230           0 :             eElement = XML_NOTE_REF;
    3231           0 :             break;
    3232             :         default:
    3233             :             OSL_FAIL("unknown reference source");
    3234           0 :             break;
    3235             :     }
    3236             : 
    3237           0 :     return eElement;
    3238             : }
    3239             : 
    3240             : 
    3241             : /// element name for sender fields
    3242           0 : enum XMLTokenEnum XMLTextFieldExport::MapSenderFieldName(
    3243             :     const Reference<XPropertySet> & xPropSet)
    3244             : {
    3245           0 :     enum XMLTokenEnum eName = XML_TOKEN_INVALID;
    3246             : 
    3247             :     // sub-field type
    3248           0 :     switch (GetInt16Property(sPropertyFieldSubType, xPropSet))
    3249             :     {
    3250             :         case UserDataPart::COMPANY :
    3251           0 :             eName = XML_SENDER_COMPANY;
    3252           0 :             break;
    3253             :         case UserDataPart::FIRSTNAME :
    3254           0 :             eName = XML_SENDER_FIRSTNAME;
    3255           0 :             break;
    3256             :         case UserDataPart::NAME :
    3257           0 :             eName = XML_SENDER_LASTNAME;
    3258           0 :             break;
    3259             :         case UserDataPart::SHORTCUT :
    3260           0 :             eName = XML_SENDER_INITIALS;
    3261           0 :             break;
    3262             :         case UserDataPart::STREET :
    3263           0 :             eName = XML_SENDER_STREET;
    3264           0 :             break;
    3265             :         case UserDataPart::COUNTRY :
    3266           0 :             eName = XML_SENDER_COUNTRY;
    3267           0 :             break;
    3268             :         case UserDataPart::ZIP :
    3269           0 :             eName = XML_SENDER_POSTAL_CODE;
    3270           0 :             break;
    3271             :         case UserDataPart::CITY :
    3272           0 :             eName = XML_SENDER_CITY;
    3273           0 :             break;
    3274             :         case UserDataPart::TITLE :
    3275           0 :             eName = XML_SENDER_TITLE;
    3276           0 :             break;
    3277             :         case UserDataPart::POSITION :
    3278           0 :             eName = XML_SENDER_POSITION;
    3279           0 :             break;
    3280             :         case UserDataPart::PHONE_PRIVATE :
    3281           0 :             eName = XML_SENDER_PHONE_PRIVATE;
    3282           0 :             break;
    3283             :         case UserDataPart::PHONE_COMPANY :
    3284           0 :             eName = XML_SENDER_PHONE_WORK;
    3285           0 :             break;
    3286             :         case UserDataPart::FAX :
    3287           0 :             eName = XML_SENDER_FAX;
    3288           0 :             break;
    3289             :         case UserDataPart::EMAIL :
    3290           0 :             eName = XML_SENDER_EMAIL;
    3291           0 :             break;
    3292             :         case UserDataPart::STATE :
    3293           0 :             eName = XML_SENDER_STATE_OR_PROVINCE;
    3294           0 :             break;
    3295             :         default:
    3296             :             SAL_WARN("xmloff.text", "unknown sender type");
    3297           0 :             eName = XML_TOKEN_INVALID;
    3298           0 :             break;
    3299             :     }
    3300             : 
    3301           0 :     return eName;
    3302             : }
    3303             : 
    3304          32 : enum XMLTokenEnum XMLTextFieldExport::MapDocInfoFieldName(
    3305             :     enum FieldIdEnum nToken)
    3306             : {
    3307          32 :     enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
    3308             : 
    3309          32 :     switch (nToken)
    3310             :     {
    3311             :         case FIELD_ID_DOCINFO_CREATION_AUTHOR:
    3312           0 :             eElement = XML_INITIAL_CREATOR;
    3313           0 :             break;
    3314             :         case FIELD_ID_DOCINFO_CREATION_DATE:
    3315           0 :             eElement = XML_CREATION_DATE;
    3316           0 :             break;
    3317             :         case FIELD_ID_DOCINFO_CREATION_TIME:
    3318           0 :             eElement = XML_CREATION_TIME;
    3319           0 :             break;
    3320             :         case FIELD_ID_DOCINFO_DESCRIPTION:
    3321           0 :             eElement = XML_DESCRIPTION;
    3322           0 :             break;
    3323             :         case FIELD_ID_DOCINFO_PRINT_TIME:
    3324           0 :             eElement = XML_PRINT_TIME;
    3325           0 :             break;
    3326             :         case FIELD_ID_DOCINFO_PRINT_DATE:
    3327           0 :             eElement = XML_PRINT_DATE;
    3328           0 :             break;
    3329             :         case FIELD_ID_DOCINFO_PRINT_AUTHOR:
    3330           0 :             eElement = XML_PRINTED_BY;
    3331           0 :             break;
    3332             :         case FIELD_ID_DOCINFO_TITLE:
    3333          32 :             eElement = XML_TITLE;
    3334          32 :             break;
    3335             :         case FIELD_ID_DOCINFO_SUBJECT:
    3336           0 :             eElement = XML_SUBJECT;
    3337           0 :             break;
    3338             :         case FIELD_ID_DOCINFO_KEYWORDS:
    3339           0 :             eElement = XML_KEYWORDS;
    3340           0 :             break;
    3341             :         case FIELD_ID_DOCINFO_REVISION:
    3342           0 :             eElement = XML_EDITING_CYCLES;
    3343           0 :             break;
    3344             :         case FIELD_ID_DOCINFO_EDIT_DURATION:
    3345           0 :             eElement = XML_EDITING_DURATION;
    3346           0 :             break;
    3347             :         case FIELD_ID_DOCINFO_SAVE_TIME:
    3348           0 :             eElement = XML_MODIFICATION_TIME;
    3349           0 :             break;
    3350             :         case FIELD_ID_DOCINFO_SAVE_DATE:
    3351           0 :             eElement = XML_MODIFICATION_DATE;
    3352           0 :             break;
    3353             :         case FIELD_ID_DOCINFO_SAVE_AUTHOR:
    3354           0 :             eElement = XML_CREATOR;
    3355           0 :             break;
    3356             :         default:
    3357             :             SAL_WARN("xmloff.text", "unknown docinfo field type!");
    3358           0 :             eElement = XML_TOKEN_INVALID;
    3359           0 :             break;
    3360             :     }
    3361             : 
    3362          32 :     return eElement;
    3363             : }
    3364             : 
    3365           0 : enum XMLTokenEnum XMLTextFieldExport::MapBibliographyFieldName(const OUString& sName)
    3366             : {
    3367           0 :     enum XMLTokenEnum eName = XML_TOKEN_INVALID;
    3368             : 
    3369           0 :     if( sName == "Identifier" )
    3370             :     {
    3371           0 :         eName = XML_IDENTIFIER;
    3372             :     }
    3373           0 :     else if( sName == "BibiliographicType" )
    3374             :     {
    3375           0 :         eName = XML_BIBLIOGRAPHY_TYPE;
    3376             :     }
    3377           0 :     else if( sName == "Address" )
    3378             :     {
    3379           0 :         eName = XML_ADDRESS;
    3380             :     }
    3381           0 :     else if( sName == "Annote" )
    3382             :     {
    3383           0 :         eName = XML_ANNOTE;
    3384             :     }
    3385           0 :     else if( sName == "Author" )
    3386             :     {
    3387           0 :         eName = XML_AUTHOR;
    3388             :     }
    3389           0 :     else if( sName == "Booktitle" )
    3390             :     {
    3391           0 :         eName = XML_BOOKTITLE;
    3392             :     }
    3393           0 :     else if( sName == "Chapter" )
    3394             :     {
    3395           0 :         eName = XML_CHAPTER;
    3396             :     }
    3397           0 :     else if( sName == "Edition" )
    3398             :     {
    3399           0 :         eName = XML_EDITION;
    3400             :     }
    3401           0 :     else if( sName == "Editor" )
    3402             :     {
    3403           0 :         eName = XML_EDITOR;
    3404             :     }
    3405           0 :     else if( sName == "Howpublished" )
    3406             :     {
    3407           0 :         eName = XML_HOWPUBLISHED;
    3408             :     }
    3409           0 :     else if( sName == "Institution" )
    3410             :     {
    3411           0 :         eName = XML_INSTITUTION;
    3412             :     }
    3413           0 :     else if( sName == "Journal" )
    3414             :     {
    3415           0 :         eName = XML_JOURNAL;
    3416             :     }
    3417           0 :     else if( sName =="Month" )
    3418             :     {
    3419           0 :         eName = XML_MONTH;
    3420             :     }
    3421           0 :     else if( sName == "Note" )
    3422             :     {
    3423           0 :         eName = XML_NOTE;
    3424             :     }
    3425           0 :     else if( sName == "Number" )
    3426             :     {
    3427           0 :         eName = XML_NUMBER;
    3428             :     }
    3429           0 :     else if( sName == "Organizations" )
    3430             :     {
    3431           0 :         eName = XML_ORGANIZATIONS;
    3432             :     }
    3433           0 :     else if( sName == "Pages" )
    3434             :     {
    3435           0 :         eName = XML_PAGES;
    3436             :     }
    3437           0 :     else if( sName == "Publisher" )
    3438             :     {
    3439           0 :         eName = XML_PUBLISHER;
    3440             :     }
    3441           0 :     else if( sName == "School" )
    3442             :     {
    3443           0 :         eName = XML_SCHOOL;
    3444             :     }
    3445           0 :     else if( sName == "Series" )
    3446             :     {
    3447           0 :         eName = XML_SERIES;
    3448             :     }
    3449           0 :     else if( sName == "Title" )
    3450             :     {
    3451           0 :         eName = XML_TITLE;
    3452             :     }
    3453           0 :     else if( sName == "Report_Type" )
    3454             :     {
    3455           0 :         eName = XML_REPORT_TYPE;
    3456             :     }
    3457           0 :     else if( sName == "Volume" )
    3458             :     {
    3459           0 :         eName = XML_VOLUME;
    3460             :     }
    3461           0 :     else if( sName == "Year" )
    3462             :     {
    3463           0 :         eName = XML_YEAR;
    3464             :     }
    3465           0 :     else if( sName == "URL" )
    3466             :     {
    3467           0 :         eName = XML_URL;
    3468             :     }
    3469           0 :     else if( sName == "Custom1" )
    3470             :     {
    3471           0 :         eName = XML_CUSTOM1;
    3472             :     }
    3473           0 :     else if( sName == "Custom2" )
    3474             :     {
    3475           0 :         eName = XML_CUSTOM2;
    3476             :     }
    3477           0 :     else if( sName == "Custom3" )
    3478             :     {
    3479           0 :         eName = XML_CUSTOM3;
    3480             :     }
    3481           0 :     else if( sName == "Custom4" )
    3482             :     {
    3483           0 :         eName = XML_CUSTOM4;
    3484             :     }
    3485           0 :     else if( sName == "Custom5" )
    3486             :     {
    3487           0 :         eName = XML_CUSTOM5;
    3488             :     }
    3489           0 :     else if( sName == "ISBN" )
    3490             :     {
    3491           0 :         eName = XML_ISBN;
    3492             :     }
    3493             :     else
    3494             :     {
    3495             :         OSL_FAIL("Unknown bibliography info data");
    3496           0 :         eName = XML_TOKEN_INVALID;
    3497             :     }
    3498             : 
    3499           0 :     return eName;
    3500             : }
    3501             : 
    3502           0 : enum XMLTokenEnum XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind)
    3503             : {
    3504           0 :     switch( nKind )
    3505             :     {
    3506             :     case 0:
    3507           0 :         return XML_VALUE;
    3508             :     case 1:
    3509           0 :         return XML_UNIT;
    3510             :     }
    3511           0 :     return XML_GAP;
    3512             : }
    3513             : 
    3514           0 : OUString XMLTextFieldExport::MakeFootnoteRefName(
    3515             :     sal_Int16 nSeqNo)
    3516             : {
    3517             :     // generate foot-/endnote ID
    3518           0 :     OUStringBuffer aBuf;
    3519           0 :     aBuf.appendAscii("ftn");
    3520           0 :     aBuf.append((sal_Int32)nSeqNo);
    3521           0 :     return aBuf.makeStringAndClear();
    3522             : }
    3523             : 
    3524           0 : OUString XMLTextFieldExport::MakeSequenceRefName(
    3525             :     sal_Int16 nSeqNo,
    3526             :     const OUString& rSeqName)
    3527             : {
    3528             :     // generate foot-/endnote ID
    3529           0 :     OUStringBuffer aBuf;
    3530           0 :     aBuf.appendAscii("ref");
    3531           0 :     aBuf.append(rSeqName);
    3532           0 :     aBuf.append((sal_Int32)nSeqNo);
    3533           0 :     return aBuf.makeStringAndClear();
    3534             : }
    3535             : 
    3536             : 
    3537             : // Property accessor helper functions
    3538             : 
    3539             : 
    3540             : // to be relegated (does that word exist?) to a more appropriate place
    3541             : 
    3542             : 
    3543             : 
    3544         380 : inline bool GetBoolProperty(
    3545             :     const OUString& sPropName,
    3546             :     const Reference<XPropertySet> & xPropSet)
    3547             : {
    3548         380 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3549         380 :     bool bBool = *static_cast<sal_Bool const *>(aAny.getValue());
    3550         380 :     return bBool;
    3551             : }
    3552             : 
    3553         118 : inline bool GetOptionalBoolProperty(
    3554             :     const OUString& sPropName,
    3555             :     const Reference<XPropertySet> & xPropSet,
    3556             :     const Reference<XPropertySetInfo> & xPropSetInfo,
    3557             :     bool bDefault)
    3558             : {
    3559         118 :     return xPropSetInfo->hasPropertyByName( sPropName )
    3560         118 :         ? GetBoolProperty( sPropName, xPropSet ) : bDefault;
    3561             : }
    3562             : 
    3563           1 : inline double GetDoubleProperty(
    3564             :     const OUString& sPropName,
    3565             :     const Reference<XPropertySet> & xPropSet)
    3566             : {
    3567           1 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3568           1 :     double fDouble = 0.0;
    3569           1 :     aAny >>= fDouble;
    3570           1 :     return fDouble;
    3571             : }
    3572             : 
    3573         215 : inline OUString const GetStringProperty(
    3574             :     const OUString& sPropName,
    3575             :     const Reference<XPropertySet> & xPropSet)
    3576             : {
    3577         215 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3578         215 :     OUString sString;
    3579         215 :     aAny >>= sString;
    3580         215 :     return sString;
    3581             : }
    3582             : 
    3583         890 : inline sal_Int32 GetIntProperty(
    3584             :     const OUString& sPropName,
    3585             :     const Reference<XPropertySet> & xPropSet)
    3586             : {
    3587         890 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3588         890 :     sal_Int32 nInt = 0;
    3589         890 :     aAny >>= nInt;
    3590         890 :     return nInt;
    3591             : }
    3592             : 
    3593          16 : inline sal_Int16 GetInt16Property(
    3594             :     const OUString& sPropName,
    3595             :     const Reference<XPropertySet> & xPropSet)
    3596             : {
    3597          16 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3598          16 :     sal_Int16 nInt = 0;
    3599          16 :     aAny >>= nInt;
    3600          16 :     return nInt;
    3601             : }
    3602             : 
    3603           3 : inline sal_Int8 GetInt8Property(
    3604             :     const OUString& sPropName,
    3605             :     const Reference<XPropertySet> & xPropSet)
    3606             : {
    3607           3 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3608           3 :     sal_Int8 nInt = 0;
    3609           3 :     aAny >>= nInt;
    3610           3 :     return nInt;
    3611             : }
    3612             : 
    3613          74 : inline util::DateTime const GetDateTimeProperty(
    3614             :     const OUString& sPropName,
    3615             :     const Reference<XPropertySet> & xPropSet)
    3616             : {
    3617          74 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3618          74 :     util::DateTime aTime;
    3619          74 :     aAny >>= aTime;
    3620          74 :     return aTime;
    3621             : }
    3622             : 
    3623           0 : inline Sequence<OUString> const GetStringSequenceProperty(
    3624             :     const OUString& sPropName,
    3625             :     const Reference<XPropertySet> & xPropSet)
    3626             : {
    3627           0 :     Any aAny = xPropSet->getPropertyValue(sPropName);
    3628           0 :     Sequence<OUString> aSequence;
    3629           0 :     aAny >>= aSequence;
    3630           0 :     return aSequence;
    3631             : }
    3632             : 
    3633             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11