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