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