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

Generated by: LCOV version 1.10