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

Generated by: LCOV version 1.10