1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtflde.cxx,v $
10 * $Revision: 1.84.102.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
36 * export of all text fields
38 #include "txtflde.hxx"
39 #include <xmloff/xmlexp.hxx>
40 #include <xmloff/xmlnumfe.hxx>
41 #include <xmloff/xmltoken.hxx>
42 #include <xmloff/xmlement.hxx>
43 #include <xmloff/xmluconv.hxx>
44 #include <xmloff/xmlnume.hxx>
45 #include "numehelp.hxx"
47 #include <xmloff/families.hxx>
48 #include <xmloff/XMLEventExport.hxx>
49 #include "XMLTextCharStyleNamesElementExport.hxx"
50 #include <xmloff/nmspmap.hxx>
51 #include <com/sun/star/util/DateTime.hpp>
52 #include <com/sun/star/util/Date.hpp>
53 #include <com/sun/star/lang/XServiceInfo.hpp>
54 #include <com/sun/star/text/UserDataPart.hpp>
55 #include <com/sun/star/text/PageNumberType.hpp>
56 #include <com/sun/star/style/NumberingType.hpp>
57 #include <com/sun/star/text/ReferenceFieldPart.hpp>
58 #include <com/sun/star/text/ReferenceFieldSource.hpp>
59 #include <com/sun/star/beans/XPropertySet.hpp>
60 #include <com/sun/star/beans/XPropertyState.hpp>
61 #include <com/sun/star/text/XTextField.hpp>
62 #include <com/sun/star/text/XDependentTextField.hpp>
63 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
65 #include <com/sun/star/text/SetVariableType.hpp>
66 #include <com/sun/star/text/PlaceholderType.hpp>
67 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
68 #include <com/sun/star/text/ChapterFormat.hpp>
69 #include <com/sun/star/text/TemplateDisplayFormat.hpp>
70 #include <com/sun/star/frame/XModel.hpp>
71 #include <com/sun/star/container/XNameReplace.hpp>
72 #include <com/sun/star/uno/Sequence.h>
73 #include <com/sun/star/util/NumberFormat.hpp>
74 #include <com/sun/star/text/BibliographyDataType.hpp>
75 #include <com/sun/star/sdb/CommandType.hpp>
76 #include <com/sun/star/rdf/XMetadatable.hpp>
77 #include <rtl/ustrbuf.hxx>
78 #include <tools/debug.hxx>
79 #include <rtl/math.hxx>
83 using ::rtl::OUString
;
84 using ::rtl::OUStringBuffer
;
86 using namespace ::std
;
87 using namespace ::com::sun::star
;
88 using namespace ::com::sun::star::uno
;
89 using namespace ::com::sun::star::text
;
90 using namespace ::com::sun::star::lang
;
91 using namespace ::com::sun::star::beans
;
92 using namespace ::com::sun::star::util
;
93 using namespace ::com::sun::star::style
;
94 using namespace ::com::sun::star::document
;
95 using namespace ::com::sun::star::container
;
96 using namespace ::xmloff::token
;
99 static sal_Char __READONLY_DATA FIELD_SERVICE_SENDER
[] = "ExtendedUser";
100 static sal_Char __READONLY_DATA FIELD_SERVICE_AUTHOR
[] = "Author";
101 static sal_Char __READONLY_DATA FIELD_SERVICE_JUMPEDIT
[] = "JumpEdit";
102 static sal_Char __READONLY_DATA FIELD_SERVICE_GETEXP
[] = "GetExpression";
103 static sal_Char __READONLY_DATA FIELD_SERVICE_SETEXP
[] = "SetExpression";
104 static sal_Char __READONLY_DATA FIELD_SERVICE_USER
[] = "User";
105 static sal_Char __READONLY_DATA FIELD_SERVICE_INPUT
[] = "Input";
106 static sal_Char __READONLY_DATA FIELD_SERVICE_USERINPUT
[] = "InputUser";
107 static sal_Char __READONLY_DATA FIELD_SERVICE_DATETIME
[] = "DateTime";
108 static sal_Char __READONLY_DATA FIELD_SERVICE_PAGENUMBER
[] = "PageNumber";
109 static sal_Char __READONLY_DATA FIELD_SERVICE_DB_NEXT
[] = "DatabaseNextSet";
110 static sal_Char __READONLY_DATA FIELD_SERVICE_DB_SELECT
[] = "DatabaseNumberOfSet";
111 static sal_Char __READONLY_DATA FIELD_SERVICE_DB_NUMBER
[] = "DatabaseSetNumber";
112 static sal_Char __READONLY_DATA FIELD_SERVICE_DB_DISPLAY
[] = "Database";
113 static sal_Char __READONLY_DATA FIELD_SERVICE_DB_NAME
[] = "DatabaseName";
114 static sal_Char __READONLY_DATA FIELD_SERVICE_CONDITIONAL_TEXT
[] = "ConditionalText";
115 static sal_Char __READONLY_DATA FIELD_SERVICE_HIDDEN_TEXT
[] = "HiddenText";
116 static sal_Char __READONLY_DATA FIELD_SERVICE_HIDDEN_PARAGRAPH
[] = "HiddenParagraph";
117 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
[] = "DocInfo.ChangeAuthor";
118 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
[] = "DocInfo.ChangeDateTime";
119 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_EDIT_TIME
[] = "DocInfo.EditTime";
120 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_DESCRIPTION
[] = "DocInfo.Description";
121 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
[] = "DocInfo.CreateAuthor";
122 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
[] = "DocInfo.CreateDateTime";
123 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_CUSTOM
[] = "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_DATE_TIME
[] = "DocInfo.PrintDateTime";
126 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_KEY_WORDS
[] = "DocInfo.KeyWords";
127 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_SUBJECT
[] = "DocInfo.Subject";
128 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_TITLE
[] = "DocInfo.Title";
129 static sal_Char __READONLY_DATA FIELD_SERVICE_DOC_INFO_REVISION
[] = "DocInfo.Revision";
130 static sal_Char __READONLY_DATA FIELD_SERVICE_FILE_NAME
[] = "FileName";
131 static sal_Char __READONLY_DATA FIELD_SERVICE_CHAPTER
[] = "Chapter";
132 static sal_Char __READONLY_DATA FIELD_SERVICE_TEMPLATE_NAME
[] = "TemplateName";
133 static sal_Char __READONLY_DATA FIELD_SERVICE_PAGE_COUNT
[] = "PageCount";
134 static sal_Char __READONLY_DATA FIELD_SERVICE_PARAGRAPH_COUNT
[] = "ParagraphCount";
135 static sal_Char __READONLY_DATA FIELD_SERVICE_WORD_COUNT
[] = "WordCount";
136 static sal_Char __READONLY_DATA FIELD_SERVICE_CHARACTER_COUNT
[] = "CharacterCount";
137 static sal_Char __READONLY_DATA FIELD_SERVICE_TABLE_COUNT
[] = "TableCount";
138 static sal_Char __READONLY_DATA FIELD_SERVICE_GRAPHIC_COUNT
[] = "GraphicObjectCount";
139 static sal_Char __READONLY_DATA FIELD_SERVICE_OBJECT_COUNT
[] = "EmbeddedObjectCount";
140 static sal_Char __READONLY_DATA FIELD_SERVICE_REFERENCE_PAGE_SET
[] = "ReferencePageSet";
141 static sal_Char __READONLY_DATA FIELD_SERVICE_REFERENCE_PAGE_GET
[] = "ReferencePageGet";
142 static sal_Char __READONLY_DATA FIELD_SERVICE_SHEET_NAME
[] = "SheetName";
143 static sal_Char __READONLY_DATA FIELD_SERVICE_MACRO
[] = "Macro";
144 static sal_Char __READONLY_DATA FIELD_SERVICE_GET_REFERENCE
[] = "GetReference";
145 static sal_Char __READONLY_DATA FIELD_SERVICE_DDE
[] = "DDE";
146 static sal_Char __READONLY_DATA FIELD_SERVICE_URL
[] = "URL";
147 static sal_Char __READONLY_DATA FIELD_SERVICE_BIBLIOGRAPHY
[] = "Bibliography";
148 static sal_Char __READONLY_DATA FIELD_SERVICE_SCRIPT
[] = "Script";
149 static sal_Char __READONLY_DATA FIELD_SERVICE_ANNOTATION
[] = "Annotation";
150 static sal_Char __READONLY_DATA FIELD_SERVICE_COMBINED_CHARACTERS
[] = "CombinedCharacters";
151 static sal_Char __READONLY_DATA FIELD_SERVICE_META
[] = "MetaField";
152 static sal_Char __READONLY_DATA FIELD_SERVICE_MEASURE
[] = "Measure";
153 static sal_Char __READONLY_DATA FIELD_SERVICE_TABLE_FORMULA
[] = "TableFormula";
154 static sal_Char __READONLY_DATA FIELD_SERVICE_DROP_DOWN
[] = "DropDown";
156 SvXMLEnumStringMapEntry __READONLY_DATA aFieldServiceNameMapping
[] =
158 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SENDER
, FIELD_ID_SENDER
),
159 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_AUTHOR
, FIELD_ID_AUTHOR
),
160 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_JUMPEDIT
, FIELD_ID_PLACEHOLDER
),
161 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GETEXP
, FIELD_ID_VARIABLE_GET
),
162 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SETEXP
, FIELD_ID_VARIABLE_SET
),
163 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USER
, FIELD_ID_USER_GET
),
164 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_INPUT
, FIELD_ID_TEXT_INPUT
),
165 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_USERINPUT
, FIELD_ID_USER_INPUT
),
166 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DATETIME
, FIELD_ID_TIME
),
167 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGENUMBER
, FIELD_ID_PAGENUMBER
),
168 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_SET
, FIELD_ID_REFPAGE_SET
),
169 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_REFERENCE_PAGE_GET
, FIELD_ID_REFPAGE_GET
),
171 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NEXT
, FIELD_ID_DATABASE_NEXT
),
172 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_SELECT
, FIELD_ID_DATABASE_SELECT
),
173 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NUMBER
, FIELD_ID_DATABASE_NUMBER
),
174 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_DISPLAY
, FIELD_ID_DATABASE_DISPLAY
),
175 // workaround for #no-bug#: Database/DataBase
176 ENUM_STRING_MAP_ENTRY( "DataBase", FIELD_ID_DATABASE_DISPLAY
),
177 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DB_NAME
, FIELD_ID_DATABASE_NAME
),
179 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_AUTHOR
, FIELD_ID_DOCINFO_CREATION_AUTHOR
),
180 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CREATE_DATE_TIME
, FIELD_ID_DOCINFO_CREATION_TIME
),
181 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_AUTHOR
, FIELD_ID_DOCINFO_SAVE_AUTHOR
),
182 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CHANGE_DATE_TIME
, FIELD_ID_DOCINFO_SAVE_TIME
),
183 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_EDIT_TIME
, FIELD_ID_DOCINFO_EDIT_DURATION
),
184 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_DESCRIPTION
, FIELD_ID_DOCINFO_DESCRIPTION
),
185 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_CUSTOM
, FIELD_ID_DOCINFO_CUSTOM
),
186 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_AUTHOR
, FIELD_ID_DOCINFO_PRINT_AUTHOR
),
187 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_PRINT_DATE_TIME
, FIELD_ID_DOCINFO_PRINT_TIME
),
188 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_KEY_WORDS
, FIELD_ID_DOCINFO_KEYWORDS
),
189 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_SUBJECT
, FIELD_ID_DOCINFO_SUBJECT
),
190 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_TITLE
, FIELD_ID_DOCINFO_TITLE
),
191 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DOC_INFO_REVISION
, FIELD_ID_DOCINFO_REVISION
),
193 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CONDITIONAL_TEXT
, FIELD_ID_CONDITIONAL_TEXT
),
194 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_TEXT
, FIELD_ID_HIDDEN_TEXT
),
195 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_HIDDEN_PARAGRAPH
, FIELD_ID_HIDDEN_PARAGRAPH
),
197 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_FILE_NAME
, FIELD_ID_FILE_NAME
),
198 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHAPTER
, FIELD_ID_CHAPTER
),
199 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TEMPLATE_NAME
, FIELD_ID_TEMPLATE_NAME
),
201 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PAGE_COUNT
, FIELD_ID_COUNT_PAGES
),
202 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_PARAGRAPH_COUNT
, FIELD_ID_COUNT_PARAGRAPHS
),
203 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_WORD_COUNT
, FIELD_ID_COUNT_WORDS
),
204 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_CHARACTER_COUNT
, FIELD_ID_COUNT_CHARACTERS
),
205 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_COUNT
, FIELD_ID_COUNT_TABLES
),
206 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GRAPHIC_COUNT
, FIELD_ID_COUNT_GRAPHICS
),
207 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_OBJECT_COUNT
, FIELD_ID_COUNT_OBJECTS
),
209 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MACRO
, FIELD_ID_MACRO
),
210 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_GET_REFERENCE
, FIELD_ID_REF_REFERENCE
),
211 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DDE
, FIELD_ID_DDE
),
213 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_BIBLIOGRAPHY
, FIELD_ID_BIBLIOGRAPHY
),
215 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SCRIPT
, FIELD_ID_SCRIPT
),
216 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION
, FIELD_ID_ANNOTATION
),
218 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS
, FIELD_ID_COMBINED_CHARACTERS
),
219 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META
, FIELD_ID_META
),
222 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME
, FIELD_ID_SHEET_NAME
),
223 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_URL
, FIELD_ID_URL
),
224 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_MEASURE
, FIELD_ID_MEASURE
),
227 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_TABLE_FORMULA
, FIELD_ID_TABLE_FORMULA
),
228 ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_DROP_DOWN
, FIELD_ID_DROP_DOWN
),
230 ENUM_STRING_MAP_END()
235 // property accessor helper functions
236 inline sal_Bool
GetBoolProperty(const OUString
&,
237 const Reference
<XPropertySet
> &);
238 inline sal_Bool
GetOptionalBoolProperty(const OUString
&,
239 const Reference
<XPropertySet
> &,
240 const Reference
<XPropertySetInfo
> &,
242 inline double GetDoubleProperty(const OUString
&,
243 const Reference
<XPropertySet
> &);
244 inline OUString
const GetStringProperty(const OUString
&,
245 const Reference
<XPropertySet
> &);
246 inline sal_Int32
GetIntProperty(const OUString
&,
247 const Reference
<XPropertySet
> &);
248 inline sal_Int16
GetInt16Property(const OUString
&,
249 const Reference
<XPropertySet
> &);
250 inline sal_Int8
GetInt8Property(const OUString
&,
251 const Reference
<XPropertySet
> &);
252 inline DateTime
const GetDateTimeProperty( const OUString
& sPropName
,
253 const Reference
<XPropertySet
> & xPropSet
);
254 inline Date
const GetDateProperty( const OUString
& sPropName
,
255 const Reference
<XPropertySet
> & xPropSet
);
256 inline Sequence
<OUString
> const GetStringSequenceProperty(
257 const OUString
& sPropName
,
258 const Reference
<XPropertySet
> & xPropSet
);
262 XMLTextFieldExport::XMLTextFieldExport( SvXMLExport
& rExp
,
263 XMLPropertyState
* pCombinedCharState
)
266 sServicePrefix(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.")),
267 sFieldMasterPrefix(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.FieldMaster.")),
268 sPresentationServicePrefix(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TextField.")),
270 sPropertyAdjust(RTL_CONSTASCII_USTRINGPARAM("Adjust")),
271 sPropertyAuthor(RTL_CONSTASCII_USTRINGPARAM("Author")),
272 sPropertyChapterFormat(RTL_CONSTASCII_USTRINGPARAM("ChapterFormat")),
273 sPropertyChapterNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("ChapterNumberingLevel")),
274 sPropertyCharStyleNames(RTL_CONSTASCII_USTRINGPARAM("CharStyleNames")),
275 sPropertyCondition(RTL_CONSTASCII_USTRINGPARAM("Condition")),
276 sPropertyContent(RTL_CONSTASCII_USTRINGPARAM("Content")),
277 sPropertyDataBaseName(RTL_CONSTASCII_USTRINGPARAM("DataBaseName")),
278 sPropertyDataBaseURL(RTL_CONSTASCII_USTRINGPARAM("DataBaseURL")),
279 sPropertyDataColumnName(RTL_CONSTASCII_USTRINGPARAM("DataColumnName")),
280 sPropertyDataCommandType(RTL_CONSTASCII_USTRINGPARAM("DataCommandType")),
281 sPropertyDataTableName(RTL_CONSTASCII_USTRINGPARAM("DataTableName")),
282 sPropertyDate(RTL_CONSTASCII_USTRINGPARAM("Date")),
283 sPropertyDateTime(RTL_CONSTASCII_USTRINGPARAM("DateTime")),
284 sPropertyDateTimeValue(RTL_CONSTASCII_USTRINGPARAM("DateTimeValue")),
285 sPropertyDDECommandElement(RTL_CONSTASCII_USTRINGPARAM("DDECommandElement")),
286 sPropertyDDECommandFile(RTL_CONSTASCII_USTRINGPARAM("DDECommandFile")),
287 sPropertyDDECommandType(RTL_CONSTASCII_USTRINGPARAM("DDECommandType")),
288 sPropertyDependentTextFields(RTL_CONSTASCII_USTRINGPARAM("DependentTextFields")),
289 sPropertyFalseContent(RTL_CONSTASCII_USTRINGPARAM("FalseContent")),
290 sPropertyFields(RTL_CONSTASCII_USTRINGPARAM("Fields")),
291 sPropertyFieldSubType(RTL_CONSTASCII_USTRINGPARAM("UserDataType")),
292 sPropertyFileFormat(RTL_CONSTASCII_USTRINGPARAM("FileFormat")),
293 sPropertyFullName(RTL_CONSTASCII_USTRINGPARAM("FullName")),
294 sPropertyHint(RTL_CONSTASCII_USTRINGPARAM("Hint")),
295 sPropertyInstanceName(RTL_CONSTASCII_USTRINGPARAM("InstanceName")),
296 sPropertyIsAutomaticUpdate(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticUpdate")),
297 sPropertyIsConditionTrue(RTL_CONSTASCII_USTRINGPARAM("IsConditionTrue")),
298 sPropertyIsDataBaseFormat(RTL_CONSTASCII_USTRINGPARAM("DataBaseFormat")),
299 sPropertyIsDate(RTL_CONSTASCII_USTRINGPARAM("IsDate")),
300 sPropertyIsExpression(RTL_CONSTASCII_USTRINGPARAM("IsExpression")),
301 sPropertyIsFixed(RTL_CONSTASCII_USTRINGPARAM("IsFixed")),
302 sPropertyIsFixedLanguage(RTL_CONSTASCII_USTRINGPARAM("IsFixedLanguage")),
303 sPropertyIsHidden(RTL_CONSTASCII_USTRINGPARAM("IsHidden")),
304 sPropertyIsInput(RTL_CONSTASCII_USTRINGPARAM("Input")),
305 sPropertyIsShowFormula(RTL_CONSTASCII_USTRINGPARAM("IsShowFormula")),
306 sPropertyIsVisible(RTL_CONSTASCII_USTRINGPARAM("IsVisible")),
307 sPropertyItems(RTL_CONSTASCII_USTRINGPARAM("Items")),
308 sPropertyLevel(RTL_CONSTASCII_USTRINGPARAM("Level")),
309 sPropertyMacro(RTL_CONSTASCII_USTRINGPARAM("Macro")),
310 sPropertyMeasureKind(RTL_CONSTASCII_USTRINGPARAM("Kind")),
311 sPropertyName(RTL_CONSTASCII_USTRINGPARAM("Name")),
312 sPropertyNumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")),
313 sPropertyNumberingSeparator(RTL_CONSTASCII_USTRINGPARAM("NumberingSeparator")),
314 sPropertyNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType")),
315 sPropertyOffset(RTL_CONSTASCII_USTRINGPARAM("Offset")),
316 sPropertyOn(RTL_CONSTASCII_USTRINGPARAM("On")),
317 sPropertyPlaceholder(RTL_CONSTASCII_USTRINGPARAM("PlaceHolder")),
318 sPropertyPlaceholderType(RTL_CONSTASCII_USTRINGPARAM("PlaceHolderType")),
319 sPropertyReferenceFieldPart(RTL_CONSTASCII_USTRINGPARAM("ReferenceFieldPart")),
320 sPropertyReferenceFieldSource(RTL_CONSTASCII_USTRINGPARAM("ReferenceFieldSource")),
321 sPropertyReferenceFieldType(RTL_CONSTASCII_USTRINGPARAM("ReferenceFieldType")),
322 sPropertyRevision(RTL_CONSTASCII_USTRINGPARAM("Revision")),
323 sPropertyScriptType(RTL_CONSTASCII_USTRINGPARAM("ScriptType")),
324 sPropertySelectedItem(RTL_CONSTASCII_USTRINGPARAM("SelectedItem")),
325 sPropertySequenceNumber(RTL_CONSTASCII_USTRINGPARAM("SequenceNumber")),
326 sPropertySequenceValue(RTL_CONSTASCII_USTRINGPARAM("SequenceValue")),
327 sPropertySetNumber(RTL_CONSTASCII_USTRINGPARAM("SetNumber")),
328 sPropertySourceName(RTL_CONSTASCII_USTRINGPARAM("SourceName")),
329 sPropertySubType(RTL_CONSTASCII_USTRINGPARAM("SubType")),
330 sPropertyTargetFrame(RTL_CONSTASCII_USTRINGPARAM("TargetFrame")),
331 sPropertyTrueContent(RTL_CONSTASCII_USTRINGPARAM("TrueContent")),
332 sPropertyURL(RTL_CONSTASCII_USTRINGPARAM("URL")),
333 sPropertyURLContent(RTL_CONSTASCII_USTRINGPARAM("URLContent")),
334 sPropertyUserText(RTL_CONSTASCII_USTRINGPARAM("UserText")),
335 sPropertyValue(RTL_CONSTASCII_USTRINGPARAM("Value")),
336 sPropertyVariableName(RTL_CONSTASCII_USTRINGPARAM("VariableName")),
337 sPropertyVariableSubType(RTL_CONSTASCII_USTRINGPARAM("VariableSubtype")),
338 sPropertyHelp(RTL_CONSTASCII_USTRINGPARAM("Help")),
339 sPropertyTooltip(RTL_CONSTASCII_USTRINGPARAM("Tooltip")),
340 sPropertyTextRange(RTL_CONSTASCII_USTRINGPARAM("TextRange")),
341 pCombinedCharactersPropertyState(pCombinedCharState
)
343 SetExportOnlyUsedFieldDeclarations();
346 XMLTextFieldExport::~XMLTextFieldExport()
348 delete pCombinedCharactersPropertyState
;
352 /// get the field ID (as in FieldIDEnum) from XTextField
353 enum FieldIdEnum
XMLTextFieldExport::GetFieldID(
354 const Reference
<XTextField
> & rTextField
,
355 const Reference
<XPropertySet
> & xPropSet
)
357 // get service names for rTextField (via XServiceInfo service)
358 Reference
<XServiceInfo
> xService(rTextField
, UNO_QUERY
);
359 const Sequence
<OUString
> aServices
= xService
->getSupportedServiceNames();
360 const OUString
* pNames
= aServices
.getConstArray();
361 sal_Int32 nCount
= aServices
.getLength();
363 OUString sFieldName
; // service name postfix of current field
365 // search for TextField service name
368 if( 0 == pNames
->compareTo(sServicePrefix
, sServicePrefix
.getLength()))
370 // TextField found => postfix is field type!
371 sFieldName
= pNames
->copy(sServicePrefix
.getLength());
378 // if this is not a normal text field, check if its a presentation text field
379 if( sFieldName
.getLength() == 0 )
381 const OUString
* pNames2
= aServices
.getConstArray();
382 sal_Int32 nCount2
= aServices
.getLength();
383 // search for TextField service name
386 if( 0 == pNames2
->compareTo(sPresentationServicePrefix
, sPresentationServicePrefix
.getLength()))
388 // TextField found => postfix is field type!
389 sFieldName
= pNames2
->copy(sPresentationServicePrefix
.getLength());
396 if( sFieldName
.getLength() != 0 )
398 if( sFieldName
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "Header" ) ) == 0 )
400 return FIELD_ID_DRAW_HEADER
;
402 else if( sFieldName
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "Footer" ) ) == 0 )
404 return FIELD_ID_DRAW_FOOTER
;
406 else if( sFieldName
.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "DateTime" ) ) == 0 )
408 return FIELD_ID_DRAW_DATE_TIME
;
413 // map postfix of service name to field ID
414 DBG_ASSERT(sFieldName
.getLength()>0, "no TextField service found!");
415 return MapFieldName(sFieldName
, xPropSet
);
418 enum FieldIdEnum
XMLTextFieldExport::MapFieldName(
419 const OUString
& sFieldName
, // field (master) name
420 const Reference
<XPropertySet
> & xPropSet
) // for subtype
422 // we'll proceed in 2 steps:
423 // a) map service name to preliminary FIELD_ID
424 // b) map those prelim. FIELD_IDs that correspond to several field types
425 // (in our (XML) world) to final FIELD IDs
428 // a) find prelim. FIELD_ID via aFieldServiceMapping
430 // check for non-empty service name
431 DBG_ASSERT(sFieldName
.getLength()>0, "no valid service name!");
432 enum FieldIdEnum nToken
= FIELD_ID_UNKNOWN
;
433 if (sFieldName
.getLength() > 0)
435 // map name to prelim. ID
437 sal_Bool bRet
= GetExport().GetMM100UnitConverter().convertEnum(
438 nTmp
, sFieldName
, aFieldServiceNameMapping
);
441 DBG_ASSERT(bRet
, "Unknown field service name encountered!");
444 nToken
= FIELD_ID_UNKNOWN
;
448 nToken
= (enum FieldIdEnum
)nTmp
;
451 // invalid service name
452 nToken
= FIELD_ID_UNKNOWN
;
455 // b) map prelim. to final FIELD_IDs
457 case FIELD_ID_VARIABLE_SET
:
458 if (GetBoolProperty(sPropertyIsInput
, xPropSet
))
460 nToken
= FIELD_ID_VARIABLE_INPUT
;
464 switch (GetIntProperty(sPropertySubType
, xPropSet
))
466 case SetVariableType::STRING
: // text field
467 case SetVariableType::VAR
: // num field
468 nToken
= FIELD_ID_VARIABLE_SET
;
470 case SetVariableType::SEQUENCE
:
471 nToken
= FIELD_ID_SEQUENCE
;
473 case SetVariableType::FORMULA
:
475 nToken
= FIELD_ID_UNKNOWN
;
481 case FIELD_ID_VARIABLE_GET
:
482 switch (GetIntProperty(sPropertySubType
, xPropSet
))
484 case SetVariableType::STRING
: // text field
485 case SetVariableType::VAR
: // num field
486 nToken
= FIELD_ID_VARIABLE_GET
;
488 case SetVariableType::FORMULA
:
489 nToken
= FIELD_ID_EXPRESSION
;
491 case SetVariableType::SEQUENCE
:
493 nToken
= FIELD_ID_UNKNOWN
;
499 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
501 nToken
= FIELD_ID_DATE
;
505 case FIELD_ID_PAGENUMBER
:
506 // NumberingType not available in non-Writer apps
507 if (xPropSet
->getPropertySetInfo()->
508 hasPropertyByName(sPropertyNumberingType
))
510 if (NumberingType::CHAR_SPECIAL
== GetIntProperty(
511 sPropertyNumberingType
, xPropSet
))
513 nToken
= FIELD_ID_PAGESTRING
;
518 case FIELD_ID_DOCINFO_CREATION_TIME
:
519 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
521 nToken
= FIELD_ID_DOCINFO_CREATION_DATE
;
525 case FIELD_ID_DOCINFO_PRINT_TIME
:
526 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
528 nToken
= FIELD_ID_DOCINFO_PRINT_DATE
;
532 case FIELD_ID_DOCINFO_SAVE_TIME
:
533 if (GetBoolProperty(sPropertyIsDate
, xPropSet
))
535 nToken
= FIELD_ID_DOCINFO_SAVE_DATE
;
539 case FIELD_ID_REF_REFERENCE
:
540 switch (GetInt16Property(sPropertyReferenceFieldSource
, xPropSet
))
542 case ReferenceFieldSource::REFERENCE_MARK
:
543 nToken
= FIELD_ID_REF_REFERENCE
;
545 case ReferenceFieldSource::SEQUENCE_FIELD
:
546 nToken
= FIELD_ID_REF_SEQUENCE
;
548 case ReferenceFieldSource::BOOKMARK
:
549 nToken
= FIELD_ID_REF_BOOKMARK
;
551 case ReferenceFieldSource::FOOTNOTE
:
552 nToken
= FIELD_ID_REF_FOOTNOTE
;
554 case ReferenceFieldSource::ENDNOTE
:
555 nToken
= FIELD_ID_REF_ENDNOTE
;
558 nToken
= FIELD_ID_UNKNOWN
;
563 case FIELD_ID_COMBINED_CHARACTERS
:
564 case FIELD_ID_SCRIPT
:
565 case FIELD_ID_ANNOTATION
:
566 case FIELD_ID_BIBLIOGRAPHY
:
569 case FIELD_ID_REFPAGE_SET
:
570 case FIELD_ID_REFPAGE_GET
:
571 case FIELD_ID_COUNT_PAGES
:
572 case FIELD_ID_COUNT_PARAGRAPHS
:
573 case FIELD_ID_COUNT_WORDS
:
574 case FIELD_ID_COUNT_CHARACTERS
:
575 case FIELD_ID_COUNT_TABLES
:
576 case FIELD_ID_COUNT_GRAPHICS
:
577 case FIELD_ID_COUNT_OBJECTS
:
578 case FIELD_ID_CONDITIONAL_TEXT
:
579 case FIELD_ID_HIDDEN_TEXT
:
580 case FIELD_ID_HIDDEN_PARAGRAPH
:
581 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
582 case FIELD_ID_DOCINFO_DESCRIPTION
:
583 case FIELD_ID_DOCINFO_CUSTOM
:
584 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
585 case FIELD_ID_DOCINFO_TITLE
:
586 case FIELD_ID_DOCINFO_SUBJECT
:
587 case FIELD_ID_DOCINFO_KEYWORDS
:
588 case FIELD_ID_DOCINFO_REVISION
:
589 case FIELD_ID_DOCINFO_EDIT_DURATION
:
590 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
591 case FIELD_ID_TEXT_INPUT
:
592 case FIELD_ID_USER_INPUT
:
593 case FIELD_ID_AUTHOR
:
594 case FIELD_ID_SENDER
:
595 case FIELD_ID_PLACEHOLDER
:
596 case FIELD_ID_USER_GET
:
597 case FIELD_ID_DATABASE_NEXT
:
598 case FIELD_ID_DATABASE_SELECT
:
599 case FIELD_ID_DATABASE_DISPLAY
:
600 case FIELD_ID_DATABASE_NAME
:
601 case FIELD_ID_DATABASE_NUMBER
:
602 case FIELD_ID_TEMPLATE_NAME
:
603 case FIELD_ID_CHAPTER
:
604 case FIELD_ID_FILE_NAME
:
606 case FIELD_ID_SHEET_NAME
:
607 case FIELD_ID_MEASURE
:
609 case FIELD_ID_TABLE_FORMULA
:
610 case FIELD_ID_DROP_DOWN
:
611 ; // these field IDs are final
615 nToken
= FIELD_ID_UNKNOWN
;
618 // ... and return final FIELD_ID
622 // is string or numeric field?
623 sal_Bool
XMLTextFieldExport::IsStringField(
624 FieldIdEnum nFieldType
,
625 const Reference
<XPropertySet
> & xPropSet
)
627 switch (nFieldType
) {
629 case FIELD_ID_VARIABLE_GET
:
630 case FIELD_ID_VARIABLE_SET
:
631 case FIELD_ID_VARIABLE_INPUT
:
633 // depends on field sub type
634 return ( GetIntProperty(sPropertySubType
, xPropSet
) ==
635 SetVariableType::STRING
);
638 case FIELD_ID_USER_GET
:
639 case FIELD_ID_USER_INPUT
:
641 Reference
<XTextField
> xTextField(xPropSet
, UNO_QUERY
);
642 DBG_ASSERT(xTextField
.is(), "field is no XTextField!");
643 sal_Bool bRet
= GetBoolProperty(sPropertyIsExpression
,
644 GetMasterPropertySet(xTextField
));
648 case FIELD_ID_META
://FIXME ?????? no idea...
649 return 0 > GetIntProperty(sPropertyNumberFormat
, xPropSet
);
651 case FIELD_ID_DATABASE_DISPLAY
:
652 // TODO: depends on... ???
653 // workaround #no-bug#: no data type
654 return 5100 == GetIntProperty(sPropertyNumberFormat
, xPropSet
);
656 case FIELD_ID_TABLE_FORMULA
:
657 // legacy field: always a number field (because it always has
661 case FIELD_ID_COUNT_PAGES
:
662 case FIELD_ID_COUNT_PARAGRAPHS
:
663 case FIELD_ID_COUNT_WORDS
:
664 case FIELD_ID_COUNT_CHARACTERS
:
665 case FIELD_ID_COUNT_TABLES
:
666 case FIELD_ID_COUNT_GRAPHICS
:
667 case FIELD_ID_COUNT_OBJECTS
:
668 case FIELD_ID_DOCINFO_SAVE_TIME
:
669 case FIELD_ID_DOCINFO_SAVE_DATE
:
670 case FIELD_ID_DOCINFO_CREATION_DATE
:
671 case FIELD_ID_DOCINFO_CREATION_TIME
:
672 case FIELD_ID_DOCINFO_PRINT_TIME
:
673 case FIELD_ID_DOCINFO_PRINT_DATE
:
674 case FIELD_ID_DOCINFO_EDIT_DURATION
:
675 case FIELD_ID_DOCINFO_REVISION
:
676 case FIELD_ID_DATABASE_NUMBER
:
677 case FIELD_ID_EXPRESSION
:
678 case FIELD_ID_SEQUENCE
:
681 case FIELD_ID_PAGENUMBER
:
682 case FIELD_ID_REFPAGE_SET
:
683 case FIELD_ID_REFPAGE_GET
:
687 case FIELD_ID_COMBINED_CHARACTERS
:
688 case FIELD_ID_BIBLIOGRAPHY
:
690 case FIELD_ID_REF_REFERENCE
:
691 case FIELD_ID_REF_SEQUENCE
:
692 case FIELD_ID_REF_BOOKMARK
:
693 case FIELD_ID_REF_FOOTNOTE
:
694 case FIELD_ID_REF_ENDNOTE
:
696 case FIELD_ID_TEMPLATE_NAME
:
697 case FIELD_ID_CHAPTER
:
698 case FIELD_ID_FILE_NAME
:
699 case FIELD_ID_CONDITIONAL_TEXT
:
700 case FIELD_ID_HIDDEN_TEXT
:
701 case FIELD_ID_HIDDEN_PARAGRAPH
:
702 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
703 case FIELD_ID_DOCINFO_DESCRIPTION
:
704 case FIELD_ID_DOCINFO_CUSTOM
:
705 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
706 case FIELD_ID_DOCINFO_TITLE
:
707 case FIELD_ID_DOCINFO_SUBJECT
:
708 case FIELD_ID_DOCINFO_KEYWORDS
:
709 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
710 case FIELD_ID_DATABASE_NAME
:
711 case FIELD_ID_TEXT_INPUT
:
712 case FIELD_ID_SENDER
:
713 case FIELD_ID_AUTHOR
:
714 case FIELD_ID_PAGESTRING
:
715 case FIELD_ID_SHEET_NAME
:
716 case FIELD_ID_MEASURE
:
718 case FIELD_ID_DROP_DOWN
:
722 case FIELD_ID_SCRIPT
:
723 case FIELD_ID_ANNOTATION
:
724 case FIELD_ID_DATABASE_NEXT
:
725 case FIELD_ID_DATABASE_SELECT
:
726 case FIELD_ID_VARIABLE_DECL
:
727 case FIELD_ID_USER_DECL
:
728 case FIELD_ID_SEQUENCE_DECL
:
729 case FIELD_ID_PLACEHOLDER
:
730 case FIELD_ID_UNKNOWN
:
731 case FIELD_ID_DRAW_HEADER
:
732 case FIELD_ID_DRAW_FOOTER
:
733 case FIELD_ID_DRAW_DATE_TIME
:
735 DBG_ERROR("unkown field type/field has no content");
736 return sal_True
; // invalid info; string in case of doubt
740 /// export the styles needed by the given field. Called on first pass
742 void XMLTextFieldExport::ExportFieldAutoStyle(
743 const Reference
<XTextField
> & rTextField
, sal_Bool bProgress
)
746 Reference
<XPropertySet
> xPropSet(rTextField
, UNO_QUERY
);
748 // add field master to list of used field masters (if desired)
749 if (NULL
!= pUsedMasters
)
751 Reference
<XDependentTextField
> xDepField(rTextField
, UNO_QUERY
);
754 Reference
<XText
> xOurText
= rTextField
->getAnchor()->getText();
756 map
<Reference
<XText
>, set
<OUString
> >::iterator aMapIter
=
757 pUsedMasters
->find(xOurText
);
759 // insert a list for our XText (if necessary)
760 if (aMapIter
== pUsedMasters
->end())
763 (*pUsedMasters
)[xOurText
] = aSet
;
764 aMapIter
= pUsedMasters
->find(xOurText
);
767 // insert this text field master
768 OUString sFieldMasterName
= GetStringProperty(
769 sPropertyInstanceName
, xDepField
->getTextFieldMaster());
770 if (sFieldMasterName
.getLength() > 0)
771 aMapIter
->second
.insert( sFieldMasterName
);
773 // else: no dependent field -> no master -> ignore
777 FieldIdEnum nToken
= GetFieldID(rTextField
, xPropSet
);
779 // export the character style for all fields
780 // with one exception: combined character fields export their own
782 Reference
<XPropertySet
> xRangePropSet(rTextField
->getAnchor(), UNO_QUERY
);
783 if (FIELD_ID_COMBINED_CHARACTERS
!= nToken
)
785 GetExport().GetTextParagraphExport()->Add(
786 XML_STYLE_FAMILY_TEXT_TEXT
, xRangePropSet
);
789 // process special styles for each field (e.g. data styles)
792 case FIELD_ID_DATABASE_DISPLAY
:
794 sal_Int32 nFormat
= GetIntProperty(sPropertyNumberFormat
, xPropSet
);
795 // workaround: #no-bug#; see IsStringField(...)
796 if ( (5100 != nFormat
) &&
797 !GetBoolProperty(sPropertyIsDataBaseFormat
, xPropSet
) )
799 GetExport().addDataStyle(nFormat
);
807 // date and time fields are always number fields, but the
808 // NumberFormat property is optional (e.g. Calc doesn't
810 Reference
<XPropertySetInfo
> xPropSetInfo(
811 xPropSet
->getPropertySetInfo() );
812 if ( xPropSetInfo
->hasPropertyByName( sPropertyNumberFormat
) )
815 GetIntProperty(sPropertyNumberFormat
, xPropSet
);
817 // nFormat may be -1 for numeric fields that display their
818 // variable name. (Maybe this should be a field type, then?)
821 if( ! GetOptionalBoolProperty(
822 sPropertyIsFixedLanguage
,
823 xPropSet
, xPropSetInfo
, sal_False
) )
826 GetExport().dataStyleForceSystemLanguage(nFormat
);
829 GetExport().addDataStyle( nFormat
,
830 nToken
== FIELD_ID_TIME
);
837 // recurse into content (does not export element, so can be done first)
838 ExportMetaField(xPropSet
, true, bProgress
);
839 // fall-through: for the meta-field itself!
840 case FIELD_ID_DOCINFO_PRINT_TIME
:
841 case FIELD_ID_DOCINFO_PRINT_DATE
:
842 case FIELD_ID_DOCINFO_CREATION_DATE
:
843 case FIELD_ID_DOCINFO_CREATION_TIME
:
844 case FIELD_ID_DOCINFO_SAVE_TIME
:
845 case FIELD_ID_DOCINFO_SAVE_DATE
:
846 case FIELD_ID_DOCINFO_EDIT_DURATION
:
847 case FIELD_ID_VARIABLE_SET
:
848 case FIELD_ID_VARIABLE_GET
:
849 case FIELD_ID_VARIABLE_INPUT
:
850 case FIELD_ID_USER_GET
:
851 case FIELD_ID_EXPRESSION
:
852 case FIELD_ID_TABLE_FORMULA
:
853 // register number format, if this is a numeric field
854 if (! IsStringField(nToken
, xPropSet
)) {
857 GetIntProperty(sPropertyNumberFormat
, xPropSet
);
859 // nFormat may be -1 for numeric fields that display their
860 // variable name. (Maybe this should be a field type, then?)
863 // handle formats for fixed language fields
864 // for all these fields (except table formula)
865 if( ( nToken
!= FIELD_ID_TABLE_FORMULA
) &&
866 ! GetOptionalBoolProperty(
867 sPropertyIsFixedLanguage
,
868 xPropSet
, xPropSet
->getPropertySetInfo(),
872 GetExport().dataStyleForceSystemLanguage(nFormat
);
875 GetExport().addDataStyle(nFormat
);
880 case FIELD_ID_COMBINED_CHARACTERS
:
882 // export text style with the addition of the combined characters
883 DBG_ASSERT(NULL
!= pCombinedCharactersPropertyState
,
884 "need proper PropertyState for combined characters");
885 const XMLPropertyState
*aStates
[] = { pCombinedCharactersPropertyState
, 0 };
886 GetExport().GetTextParagraphExport()->Add(
887 XML_STYLE_FAMILY_TEXT_TEXT
, xRangePropSet
,
892 case FIELD_ID_SCRIPT
:
893 case FIELD_ID_ANNOTATION
:
894 case FIELD_ID_BIBLIOGRAPHY
:
896 case FIELD_ID_REF_REFERENCE
:
897 case FIELD_ID_REF_SEQUENCE
:
898 case FIELD_ID_REF_BOOKMARK
:
899 case FIELD_ID_REF_FOOTNOTE
:
900 case FIELD_ID_REF_ENDNOTE
:
902 case FIELD_ID_REFPAGE_SET
:
903 case FIELD_ID_REFPAGE_GET
:
904 case FIELD_ID_COUNT_PAGES
:
905 case FIELD_ID_COUNT_PARAGRAPHS
:
906 case FIELD_ID_COUNT_WORDS
:
907 case FIELD_ID_COUNT_CHARACTERS
:
908 case FIELD_ID_COUNT_TABLES
:
909 case FIELD_ID_COUNT_GRAPHICS
:
910 case FIELD_ID_COUNT_OBJECTS
:
911 case FIELD_ID_CONDITIONAL_TEXT
:
912 case FIELD_ID_HIDDEN_TEXT
:
913 case FIELD_ID_HIDDEN_PARAGRAPH
:
914 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
915 case FIELD_ID_DOCINFO_DESCRIPTION
:
916 case FIELD_ID_DOCINFO_CUSTOM
:
917 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
918 case FIELD_ID_DOCINFO_TITLE
:
919 case FIELD_ID_DOCINFO_SUBJECT
:
920 case FIELD_ID_DOCINFO_KEYWORDS
:
921 case FIELD_ID_DOCINFO_REVISION
:
922 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
923 case FIELD_ID_SEQUENCE
:
924 case FIELD_ID_PAGENUMBER
:
925 case FIELD_ID_PAGESTRING
:
926 case FIELD_ID_AUTHOR
:
927 case FIELD_ID_SENDER
:
928 case FIELD_ID_PLACEHOLDER
:
929 case FIELD_ID_USER_INPUT
:
930 case FIELD_ID_TEXT_INPUT
:
931 case FIELD_ID_DATABASE_NEXT
:
932 case FIELD_ID_DATABASE_SELECT
:
933 case FIELD_ID_DATABASE_NAME
:
934 case FIELD_ID_DATABASE_NUMBER
:
935 case FIELD_ID_TEMPLATE_NAME
:
936 case FIELD_ID_CHAPTER
:
937 case FIELD_ID_FILE_NAME
:
938 case FIELD_ID_SHEET_NAME
:
939 case FIELD_ID_MEASURE
:
941 case FIELD_ID_DROP_DOWN
:
942 case FIELD_ID_DRAW_DATE_TIME
:
943 case FIELD_ID_DRAW_FOOTER
:
944 case FIELD_ID_DRAW_HEADER
:
945 ; // no formats for these fields!
948 case FIELD_ID_UNKNOWN
:
950 DBG_ERROR("unkown field type!");
951 // ignore -> no format for unkowns
956 /// export the given field to XML. Called on second pass through document
957 void XMLTextFieldExport::ExportField(
958 const Reference
<XTextField
> & rTextField
, sal_Bool bProgress
)
961 Reference
<XPropertySet
> xPropSet(rTextField
, UNO_QUERY
);
963 // get property set of range (for the attributes)
964 Reference
<XPropertySet
> xRangePropSet(rTextField
->getAnchor(), UNO_QUERY
);
967 enum FieldIdEnum nToken
= GetFieldID(rTextField
, xPropSet
);
969 // special treatment for combined characters field, because it is
970 // exported as a style
971 const XMLPropertyState
* aStates
[] = { pCombinedCharactersPropertyState
, 0 };
972 const XMLPropertyState
**pStates
=
973 FIELD_ID_COMBINED_CHARACTERS
== nToken
977 // find out whether we need to set the style or hyperlink
978 sal_Bool bHasHyperlink
;
979 sal_Bool bIsUICharStyle
;
980 sal_Bool bHasAutoStyle
;
981 OUString sStyle
= GetExport().GetTextParagraphExport()->
982 FindTextStyleAndHyperlink( xRangePropSet
, bHasHyperlink
, bIsUICharStyle
,
983 bHasAutoStyle
, pStates
);
984 sal_Bool bHasStyle
= (sStyle
.getLength() > 0);
986 // export hyperlink (if we have one)
987 Reference
< XPropertySetInfo
> xRangePropSetInfo
;
990 Reference
<XPropertyState
> xRangePropState( xRangePropSet
, UNO_QUERY
);
991 xRangePropSetInfo
= xRangePropSet
->getPropertySetInfo();
993 GetExport().GetTextParagraphExport()->addHyperlinkAttributes(
994 xRangePropSet
, xRangePropState
,
997 SvXMLElementExport
aHyperlink( GetExport(), bHasHyperlink
,
998 XML_NAMESPACE_TEXT
, XML_A
,
999 sal_False
, sal_False
);
1003 // export events (if supported)
1004 OUString
sHyperLinkEvents(RTL_CONSTASCII_USTRINGPARAM(
1005 "HyperLinkEvents"));
1006 if (xRangePropSetInfo
->hasPropertyByName(sHyperLinkEvents
))
1008 Any aAny
= xRangePropSet
->getPropertyValue(sHyperLinkEvents
);
1009 Reference
<XNameReplace
> xName
;
1011 GetExport().GetEventExport().Export(xName
, sal_False
);
1016 XMLTextCharStyleNamesElementExport
aCharStylesExport(
1017 GetExport(), bIsUICharStyle
&&
1018 GetExport().GetTextParagraphExport()
1019 ->GetCharStyleNamesPropInfoCache().hasProperty(
1020 xRangePropSet
, xRangePropSetInfo
), bHasAutoStyle
,
1021 xRangePropSet
, sPropertyCharStyleNames
);
1023 // export span with style (if necessary)
1024 // (except for combined characters field)
1027 // export <text:span> element
1028 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_STYLE_NAME
,
1029 GetExport().EncodeStyleName( sStyle
) );
1031 SvXMLElementExport
aSpan( GetExport(), bHasStyle
,
1032 XML_NAMESPACE_TEXT
, XML_SPAN
,
1033 sal_False
, sal_False
);
1035 // finally, export the field itself
1036 ExportFieldHelper( rTextField
, xPropSet
, xRangePropSet
, nToken
,
1041 /// export the given field to XML. Called on second pass through document
1042 void XMLTextFieldExport::ExportFieldHelper(
1043 const Reference
<XTextField
> & rTextField
,
1044 const Reference
<XPropertySet
> & rPropSet
,
1045 const Reference
<XPropertySet
> &,
1046 enum FieldIdEnum nToken
,
1047 sal_Bool bProgress
)
1049 // get property set info (because some attributes are not support
1050 // in all implementations)
1051 Reference
<XPropertySetInfo
> xPropSetInfo(rPropSet
->getPropertySetInfo());
1053 OUString sPresentation
= rTextField
->getPresentation(sal_False
);
1055 // process each field type
1057 case FIELD_ID_AUTHOR
:
1058 // author field: fixed, field (sub-)type
1059 ProcessBoolean(XML_FIXED
,
1060 GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_True
);
1061 ExportElement(MapAuthorFieldName(rPropSet
), sPresentation
);
1064 case FIELD_ID_SENDER
:
1065 // sender field: fixed, field (sub-)type
1066 ProcessBoolean(XML_FIXED
,
1067 GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_True
);
1068 ExportElement(MapSenderFieldName(rPropSet
), sPresentation
);
1071 case FIELD_ID_PLACEHOLDER
:
1072 // placeholder field: type, name, description
1073 ProcessString(XML_PLACEHOLDER_TYPE
,
1075 GetInt16Property(sPropertyPlaceholderType
, rPropSet
)));
1076 ProcessString(XML_DESCRIPTION
,
1077 GetStringProperty(sPropertyHint
,rPropSet
), sal_True
);
1078 ExportElement(XML_PLACEHOLDER
, sPresentation
);
1081 case FIELD_ID_VARIABLE_SET
:
1083 // variable set field: name, visible, format&value
1084 ProcessString(XML_NAME
,
1085 GetStringProperty(sPropertyVariableName
, rPropSet
));
1086 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1088 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1089 GetStringProperty(sPropertyContent
, rPropSet
),
1091 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1092 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1093 GetStringProperty(sPropertyContent
, rPropSet
),
1095 GetDoubleProperty(sPropertyValue
, rPropSet
),
1096 sal_True
, sal_True
, sal_True
,
1097 ! GetOptionalBoolProperty(
1098 sPropertyIsFixedLanguage
,
1099 rPropSet
, xPropSetInfo
, sal_False
) );
1100 ExportElement(XML_VARIABLE_SET
, sPresentation
);
1103 case FIELD_ID_VARIABLE_GET
:
1105 // variable get field: name, format&value
1106 ProcessString(XML_NAME
,
1107 GetStringProperty(sPropertyContent
, rPropSet
));
1108 sal_Bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1109 ProcessDisplay(sal_True
, bCmd
);
1110 // #i81766# for older versions export of the value-type
1111 sal_Bool bExportValueType
= !bCmd
&& ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE
);
1112 // show style, unless name will be shown
1113 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1114 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1115 sEmpty
, sEmpty
, 0.0, // values not used
1119 ! GetOptionalBoolProperty(
1120 sPropertyIsFixedLanguage
,
1121 rPropSet
, xPropSetInfo
, sal_False
) );
1122 ExportElement(XML_VARIABLE_GET
, sPresentation
);
1125 case FIELD_ID_VARIABLE_INPUT
:
1126 // variable input field: name, description, format&value
1127 ProcessString(XML_NAME
,
1128 GetStringProperty(sPropertyVariableName
, rPropSet
));
1129 ProcessString(XML_DESCRIPTION
,
1130 GetStringProperty(sPropertyHint
, rPropSet
));
1131 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1133 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1134 GetStringProperty(sPropertyContent
, rPropSet
),
1136 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1137 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1138 GetStringProperty(sPropertyContent
, rPropSet
),
1140 GetDoubleProperty(sPropertyValue
, rPropSet
),
1141 sal_True
, sal_True
, sal_True
,
1142 ! GetOptionalBoolProperty(
1143 sPropertyIsFixedLanguage
,
1144 rPropSet
, xPropSetInfo
, sal_False
) );
1145 ExportElement(XML_VARIABLE_INPUT
, sPresentation
);
1148 case FIELD_ID_USER_GET
:
1149 // user field: name, hidden, style
1151 sal_Bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1152 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1154 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1155 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1156 sEmpty
, sEmpty
, 0.0, // values not used
1157 sal_False
, sal_False
, !bCmd
,
1158 ! GetOptionalBoolProperty(
1159 sPropertyIsFixedLanguage
,
1160 rPropSet
, xPropSetInfo
, sal_False
) );
1162 // name from FieldMaster
1163 ProcessString(XML_NAME
,
1164 GetStringProperty(sPropertyName
,
1165 GetMasterPropertySet(rTextField
)));
1166 ExportElement(XML_USER_FIELD_GET
, sPresentation
);
1170 case FIELD_ID_USER_INPUT
:
1171 // user input field: name (from FieldMaster), description
1172 // ProcessString(XML_NAME,
1173 // GetStringProperty(sPropertyName,
1174 // GetMasterPropertySet(rTextField)));
1175 ProcessString(XML_NAME
,
1176 GetStringProperty(sPropertyContent
, rPropSet
));
1177 ProcessString(XML_DESCRIPTION
,
1178 GetStringProperty(sPropertyHint
, rPropSet
));
1179 ExportElement(XML_USER_FIELD_INPUT
, sPresentation
);
1182 case FIELD_ID_SEQUENCE
:
1184 // sequence field: name, formula, seq-format
1185 OUString sName
= GetStringProperty(sPropertyVariableName
, rPropSet
);
1186 // TODO: use reference name only if actually beeing referenced.
1187 ProcessString(XML_REF_NAME
,
1188 MakeSequenceRefName(
1189 GetInt16Property(sPropertySequenceValue
, rPropSet
),
1191 ProcessString(XML_NAME
, sName
);
1192 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1193 GetStringProperty(sPropertyContent
, rPropSet
),
1195 ProcessNumberingType(GetInt16Property(sPropertyNumberingType
,
1197 ExportElement(XML_SEQUENCE
, sPresentation
);
1201 case FIELD_ID_EXPRESSION
:
1203 // formula field: formula, format&value
1204 sal_Bool bCmd
= GetBoolProperty(sPropertyIsShowFormula
, rPropSet
);
1205 ProcessString(XML_FORMULA
, XML_NAMESPACE_OOOW
,
1206 GetStringProperty(sPropertyContent
, rPropSet
),
1208 ProcessDisplay(sal_True
, bCmd
);
1209 ProcessValueAndType(IsStringField(nToken
, rPropSet
),
1210 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1211 GetStringProperty(sPropertyContent
, rPropSet
),
1213 GetDoubleProperty(sPropertyValue
, rPropSet
),
1214 !bCmd
, !bCmd
, !bCmd
,
1215 ! GetOptionalBoolProperty(
1216 sPropertyIsFixedLanguage
,
1217 rPropSet
, xPropSetInfo
, sal_False
) );
1218 ExportElement(XML_EXPRESSION
, sPresentation
);
1222 case FIELD_ID_TEXT_INPUT
:
1223 // text input field: description and string-value
1224 ProcessString(XML_DESCRIPTION
,
1225 GetStringProperty(sPropertyHint
, rPropSet
));
1226 ProcessString(XML_HELP
,
1227 GetStringProperty(sPropertyHelp
, rPropSet
), true);
1228 ProcessString(XML_HINT
,
1229 GetStringProperty(sPropertyTooltip
, rPropSet
), true);
1230 ExportElement(XML_TEXT_INPUT
, sPresentation
);
1234 // all properties (except IsDate) are optional!
1235 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1237 ProcessValueAndType(sal_False
,
1238 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1239 sEmpty
, sEmpty
, 0.0, // not used
1240 sal_False
, sal_False
, sal_True
,
1241 ! GetOptionalBoolProperty(
1242 sPropertyIsFixedLanguage
,
1243 rPropSet
, xPropSetInfo
, sal_False
),
1246 if (xPropSetInfo
->hasPropertyByName(sPropertyDateTimeValue
))
1248 // no value -> current time
1249 ProcessDateTime(XML_TIME_VALUE
,
1250 GetDateTimeProperty(sPropertyDateTimeValue
,
1254 if (xPropSetInfo
->hasPropertyByName(sPropertyDateTime
))
1256 // no value -> current time
1257 ProcessDateTime(XML_TIME_VALUE
,
1258 GetDateTimeProperty(sPropertyDateTime
,rPropSet
),
1261 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1263 ProcessBoolean(XML_FIXED
,
1264 GetBoolProperty(sPropertyIsFixed
, rPropSet
),
1267 if (xPropSetInfo
->hasPropertyByName(sPropertyAdjust
))
1269 // adjust value given as integer in minutes
1270 ProcessDateTime(XML_TIME_ADJUST
,
1271 GetIntProperty(sPropertyAdjust
, rPropSet
),
1272 sal_False
, sal_True
, sal_True
);
1274 ExportElement(XML_TIME
, sPresentation
);
1278 // all properties (except IsDate) are optional!
1279 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberFormat
))
1281 ProcessValueAndType(sal_False
,
1282 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1283 sEmpty
, sEmpty
, 0.0, // not used
1284 sal_False
, sal_False
, sal_True
,
1285 ! GetOptionalBoolProperty(
1286 sPropertyIsFixedLanguage
,
1287 rPropSet
, xPropSetInfo
, sal_False
) );
1289 if (xPropSetInfo
->hasPropertyByName(sPropertyDateTimeValue
))
1291 // no value -> current date
1292 ProcessDateTime(XML_DATE_VALUE
,
1293 GetDateTimeProperty(sPropertyDateTimeValue
,
1295 // #96457#: date fields should also save time
1298 // TODO: remove double-handling after SRC614
1299 else if (xPropSetInfo
->hasPropertyByName(sPropertyDateTime
))
1301 ProcessDateTime(XML_DATE_VALUE
,
1302 GetDateTimeProperty(sPropertyDateTime
,rPropSet
),
1303 // #96457#: date fields should also save time
1306 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1308 ProcessBoolean(XML_FIXED
,
1309 GetBoolProperty(sPropertyIsFixed
, rPropSet
),
1312 if (xPropSetInfo
->hasPropertyByName(sPropertyAdjust
))
1314 // adjust value given as number of days
1315 ProcessDateTime(XML_DATE_ADJUST
,
1316 GetIntProperty(sPropertyAdjust
, rPropSet
),
1317 sal_True
, sal_True
, sal_True
);
1319 ExportElement(XML_DATE
, sPresentation
);
1322 case FIELD_ID_PAGENUMBER
:
1323 // all properties are optional
1324 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberingType
))
1326 ProcessNumberingType(GetInt16Property(sPropertyNumberingType
,
1329 if (xPropSetInfo
->hasPropertyByName(sPropertyOffset
))
1331 sal_Int32 nAdjust
= GetIntProperty(sPropertyOffset
, rPropSet
);
1333 if (xPropSetInfo
->hasPropertyByName(sPropertySubType
))
1335 // property SubType used in MapPageNumebrName
1336 ProcessString(XML_SELECT_PAGE
,
1337 MapPageNumberName(rPropSet
, nAdjust
));
1339 ProcessIntegerDef(XML_PAGE_ADJUST
, nAdjust
, 0);
1341 ExportElement(XML_PAGE_NUMBER
, sPresentation
);
1344 case FIELD_ID_PAGESTRING
:
1346 ProcessString(XML_STRING_VALUE
,
1347 GetStringProperty(sPropertyUserText
, rPropSet
),
1349 sal_Int32 nDummy
= 0; // MapPageNumberName need int
1350 ProcessString(XML_SELECT_PAGE
, MapPageNumberName(rPropSet
, nDummy
));
1351 if( 0 == ( GetExport().getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE
) )
1352 ExportElement(XML_PAGE_CONTINUATION
, sPresentation
);
1354 ExportElement(XML_PAGE_CONTINUATION_STRING
, sPresentation
);
1358 case FIELD_ID_DATABASE_NAME
:
1359 ProcessString(XML_TABLE_NAME
,
1360 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1361 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1362 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1364 ExportDataBaseElement(XML_DATABASE_NAME
, sPresentation
,
1365 rPropSet
, xPropSetInfo
);
1368 case FIELD_ID_DATABASE_NUMBER
:
1369 ProcessString(XML_TABLE_NAME
,
1370 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1371 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1372 ProcessNumberingType(
1373 GetInt16Property(sPropertyNumberingType
,rPropSet
));
1374 ProcessInteger(XML_VALUE
,
1375 GetIntProperty(sPropertySetNumber
, rPropSet
));
1376 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1378 ExportDataBaseElement(XML_DATABASE_ROW_NUMBER
, sPresentation
,
1379 rPropSet
, xPropSetInfo
);
1382 case FIELD_ID_DATABASE_NEXT
:
1383 ProcessString(XML_TABLE_NAME
,
1384 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1385 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1386 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1387 GetStringProperty(sPropertyCondition
, rPropSet
));
1388 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1389 "Unexpected presentation for database next field");
1390 ExportDataBaseElement(XML_DATABASE_NEXT
, OUString(),
1391 rPropSet
, xPropSetInfo
);
1394 case FIELD_ID_DATABASE_SELECT
:
1395 ProcessString(XML_TABLE_NAME
,
1396 GetStringProperty(sPropertyDataTableName
, rPropSet
));
1397 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, rPropSet
));
1398 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1399 GetStringProperty(sPropertyCondition
, rPropSet
));
1400 ProcessInteger(XML_ROW_NUMBER
,
1401 GetIntProperty(sPropertySetNumber
, rPropSet
));
1402 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1403 "Unexpected presentation for database select field");
1404 ExportDataBaseElement(XML_DATABASE_ROW_SELECT
, OUString(),
1405 rPropSet
, xPropSetInfo
);
1408 case FIELD_ID_DATABASE_DISPLAY
:
1410 // get database, table and column name from field master
1411 const Reference
<XPropertySet
> & xMaster
= GetMasterPropertySet(rTextField
);
1412 ProcessString(XML_TABLE_NAME
,
1413 GetStringProperty(sPropertyDataTableName
, xMaster
));
1414 ProcessCommandType(GetIntProperty(sPropertyDataCommandType
, xMaster
));
1415 ProcessString(XML_COLUMN_NAME
,
1416 GetStringProperty(sPropertyDataColumnName
, xMaster
));
1417 // export number format if available (happens only for numbers!)
1418 if (!GetBoolProperty(sPropertyIsDataBaseFormat
, rPropSet
))
1420 ProcessValueAndType(sal_False
, // doesn't happen for text
1421 GetIntProperty(sPropertyNumberFormat
,rPropSet
),
1422 sEmpty
, sEmpty
, 0.0, // not used
1423 sal_False
, sal_False
, sal_True
, sal_False
);
1425 ProcessDisplay(GetBoolProperty(sPropertyIsVisible
, rPropSet
),
1427 ExportDataBaseElement(XML_DATABASE_DISPLAY
, sPresentation
,
1428 xMaster
, xMaster
->getPropertySetInfo());
1432 case FIELD_ID_DOCINFO_REVISION
:
1433 ProcessBoolean(XML_FIXED
,
1434 GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_False
);
1435 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1438 case FIELD_ID_DOCINFO_EDIT_DURATION
:
1439 case FIELD_ID_DOCINFO_SAVE_TIME
:
1440 case FIELD_ID_DOCINFO_CREATION_TIME
:
1441 case FIELD_ID_DOCINFO_PRINT_TIME
:
1442 case FIELD_ID_DOCINFO_SAVE_DATE
:
1443 case FIELD_ID_DOCINFO_CREATION_DATE
:
1444 case FIELD_ID_DOCINFO_PRINT_DATE
:
1445 ProcessValueAndType(sal_False
,
1446 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1447 sEmpty
, sEmpty
, 0.0,
1448 sal_False
, sal_False
, sal_True
,
1449 ! GetOptionalBoolProperty(
1450 sPropertyIsFixedLanguage
,
1451 rPropSet
, xPropSetInfo
, sal_False
) );
1453 // todo: export date/time value, but values not available -> core bug
1454 ProcessBoolean(XML_FIXED
,
1455 GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_False
);
1456 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1459 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
1460 case FIELD_ID_DOCINFO_DESCRIPTION
:
1461 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
1462 case FIELD_ID_DOCINFO_TITLE
:
1463 case FIELD_ID_DOCINFO_SUBJECT
:
1464 case FIELD_ID_DOCINFO_KEYWORDS
:
1465 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
1466 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1468 ProcessBoolean(XML_FIXED
,
1469 GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_False
);
1471 ExportElement(MapDocInfoFieldName(nToken
), sPresentation
);
1474 case FIELD_ID_DOCINFO_CUSTOM
:
1476 uno::Any aAny
= rPropSet
->getPropertyValue( sPropertyName
);
1477 ::rtl::OUString sName
;
1479 ProcessString(XML_NAME
, sName
);
1480 ProcessBoolean(XML_FIXED
, GetBoolProperty(sPropertyIsFixed
, rPropSet
), sal_False
);
1481 ExportElement(XML_USER_DEFINED
, sPresentation
);
1485 case FIELD_ID_COUNT_PAGES
:
1486 case FIELD_ID_COUNT_PARAGRAPHS
:
1487 case FIELD_ID_COUNT_WORDS
:
1488 case FIELD_ID_COUNT_CHARACTERS
:
1489 case FIELD_ID_COUNT_TABLES
:
1490 case FIELD_ID_COUNT_GRAPHICS
:
1491 case FIELD_ID_COUNT_OBJECTS
:
1492 // all properties optional (applies to pages only, but I'll do
1493 // it for all for sake of common implementation)
1494 if (xPropSetInfo
->hasPropertyByName(sPropertyNumberingType
))
1496 ProcessNumberingType(GetInt16Property(sPropertyNumberingType
,
1499 ExportElement(MapCountFieldName(nToken
), sPresentation
);
1502 case FIELD_ID_CONDITIONAL_TEXT
:
1503 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1504 GetStringProperty(sPropertyCondition
, rPropSet
));
1505 ProcessString(XML_STRING_VALUE_IF_TRUE
,
1506 GetStringProperty(sPropertyTrueContent
, rPropSet
));
1507 ProcessString(XML_STRING_VALUE_IF_FALSE
,
1508 GetStringProperty(sPropertyFalseContent
, rPropSet
));
1509 ProcessBoolean(XML_CURRENT_VALUE
,
1510 GetBoolProperty(sPropertyIsConditionTrue
, rPropSet
),
1512 ExportElement(XML_CONDITIONAL_TEXT
, sPresentation
);
1515 case FIELD_ID_HIDDEN_TEXT
:
1516 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1517 GetStringProperty(sPropertyCondition
, rPropSet
));
1518 ProcessString(XML_STRING_VALUE
,
1519 GetStringProperty(sPropertyContent
, rPropSet
));
1520 ProcessBoolean(XML_IS_HIDDEN
,
1521 GetBoolProperty(sPropertyIsHidden
, rPropSet
),
1523 ExportElement(XML_HIDDEN_TEXT
, sPresentation
);
1526 case FIELD_ID_HIDDEN_PARAGRAPH
:
1527 ProcessString(XML_CONDITION
, XML_NAMESPACE_OOOW
,
1528 GetStringProperty(sPropertyCondition
, rPropSet
));
1529 ProcessBoolean(XML_IS_HIDDEN
,
1530 GetBoolProperty(sPropertyIsHidden
, rPropSet
),
1532 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1533 "Unexpected presentation for hidden paragraph field");
1534 ExportElement(XML_HIDDEN_PARAGRAPH
);
1537 case FIELD_ID_TEMPLATE_NAME
:
1538 ProcessString(XML_DISPLAY
,
1539 MapTemplateDisplayFormat(
1540 GetInt16Property(sPropertyFileFormat
, rPropSet
)));
1541 ExportElement(XML_TEMPLATE_NAME
, sPresentation
);
1544 case FIELD_ID_CHAPTER
:
1545 ProcessString(XML_DISPLAY
,
1546 MapChapterDisplayFormat(
1547 GetInt16Property(sPropertyChapterFormat
, rPropSet
)));
1548 // API numbers 0..9, we number 1..10
1549 ProcessInteger(XML_OUTLINE_LEVEL
,
1550 GetInt8Property(sPropertyLevel
, rPropSet
) + 1);
1551 ExportElement(XML_CHAPTER
, sPresentation
);
1554 case FIELD_ID_FILE_NAME
:
1555 // all properties are optional
1556 if (xPropSetInfo
->hasPropertyByName(sPropertyFileFormat
))
1558 ProcessString(XML_DISPLAY
,
1559 MapFilenameDisplayFormat(
1560 GetInt16Property(sPropertyFileFormat
, rPropSet
)));
1562 if (xPropSetInfo
->hasPropertyByName(sPropertyIsFixed
))
1564 ProcessBoolean(XML_FIXED
,
1565 GetBoolProperty(sPropertyIsFixed
, rPropSet
),
1568 ExportElement(XML_FILE_NAME
, sPresentation
);
1571 case FIELD_ID_REFPAGE_SET
:
1572 ProcessBoolean(XML_ACTIVE
,
1573 GetBoolProperty(sPropertyOn
, rPropSet
), sal_True
);
1574 ProcessIntegerDef(XML_PAGE_ADJUST
,
1575 GetInt16Property(sPropertyOffset
, rPropSet
), 0);
1576 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1577 "Unexpected presentation page variable field");
1578 ExportElement(XML_PAGE_VARIABLE_SET
);
1581 case FIELD_ID_REFPAGE_GET
:
1582 ProcessNumberingType(
1583 GetInt16Property(sPropertyNumberingType
, rPropSet
));
1584 ExportElement(XML_PAGE_VARIABLE_GET
, sPresentation
);
1587 case FIELD_ID_MACRO
:
1588 ExportMacro( rPropSet
, sPresentation
);
1591 case FIELD_ID_REF_SEQUENCE
:
1592 // reference to sequence: format, name, find value (and element)
1593 // was: if (nSeqNumber != -1) ...
1594 ProcessString(XML_REFERENCE_FORMAT
,
1595 MapReferenceType(GetInt16Property(
1596 sPropertyReferenceFieldPart
, rPropSet
)),
1598 ProcessString(XML_REF_NAME
,
1599 MakeSequenceRefName(
1600 GetInt16Property(sPropertySequenceNumber
, rPropSet
),
1601 GetStringProperty(sPropertySourceName
, rPropSet
) ) );
1604 GetInt16Property(sPropertyReferenceFieldSource
, rPropSet
)),
1608 case FIELD_ID_REF_REFERENCE
:
1609 case FIELD_ID_REF_BOOKMARK
:
1610 // reference to bookmarks, references: format, name (and element)
1611 ProcessString(XML_REFERENCE_FORMAT
,
1612 MapReferenceType(GetInt16Property(
1613 sPropertyReferenceFieldPart
, rPropSet
)),
1615 ProcessString(XML_REF_NAME
,
1616 GetStringProperty(sPropertySourceName
, rPropSet
));
1618 MapReferenceSource(GetInt16Property(
1619 sPropertyReferenceFieldSource
, rPropSet
)),
1623 case FIELD_ID_REF_FOOTNOTE
:
1624 case FIELD_ID_REF_ENDNOTE
:
1625 // reference to end-/footnote: format, generate name, (and element)
1626 GetExport().AddAttribute( XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
,
1627 FIELD_ID_REF_ENDNOTE
==nToken
? XML_ENDNOTE
: XML_FOOTNOTE
);
1628 ProcessString(XML_REFERENCE_FORMAT
,
1629 MapReferenceType(GetInt16Property(
1630 sPropertyReferenceFieldPart
, rPropSet
)),
1632 ProcessString(XML_REF_NAME
,
1633 MakeFootnoteRefName(GetInt16Property(
1634 sPropertySequenceNumber
, rPropSet
)));
1636 MapReferenceSource(GetInt16Property(
1637 sPropertyReferenceFieldSource
, rPropSet
)),
1642 // name from field master
1643 ProcessString(XML_CONNECTION_NAME
,
1645 GetStringProperty(sPropertyName
,
1646 GetMasterPropertySet(rTextField
)));
1647 ExportElement(XML_DDE_CONNECTION
, sPresentation
);
1650 case FIELD_ID_SHEET_NAME
:
1651 // name of spreadsheet (Calc only)
1652 ExportElement(XML_SHEET_NAME
, sPresentation
);
1657 // this field is a special case because it gets mapped onto a
1658 // hyperlink, rather than one of the regular text field.
1659 ProcessString(XML_HREF
, GetExport().GetRelativeReference(GetStringProperty(sPropertyURL
, rPropSet
)),
1660 sal_False
, XML_NAMESPACE_XLINK
);
1661 ProcessString(XML_TARGET_FRAME_NAME
,
1662 GetStringProperty(sPropertyTargetFrame
,rPropSet
),
1663 sal_True
, XML_NAMESPACE_OFFICE
);
1664 SvXMLElementExport
aUrlField(rExport
, XML_NAMESPACE_TEXT
, XML_A
,
1665 sal_False
, sal_False
);
1666 GetExport().Characters(sPresentation
);
1670 case FIELD_ID_BIBLIOGRAPHY
:
1672 ProcessBibliographyData(rPropSet
);
1673 ExportElement(XML_BIBLIOGRAPHY_MARK
, sPresentation
);
1677 case FIELD_ID_SCRIPT
:
1678 ProcessString(XML_LANGUAGE
,
1679 GetStringProperty(sPropertyScriptType
, rPropSet
),
1680 sal_True
, XML_NAMESPACE_SCRIPT
);
1681 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1682 "Unexpected presentation for script field");
1683 if (GetBoolProperty(sPropertyURLContent
, rPropSet
))
1685 ProcessString(XML_HREF
,
1686 GetExport().GetRelativeReference(GetStringProperty(sPropertyContent
, rPropSet
)),
1687 sal_False
, XML_NAMESPACE_XLINK
);
1688 ExportElement(XML_SCRIPT
);
1692 ExportElement(XML_SCRIPT
,
1693 GetStringProperty(sPropertyContent
, rPropSet
));
1697 case FIELD_ID_ANNOTATION
:
1699 // check for empty presentation (just in case)
1700 DBG_ASSERT(sPresentation
.equals(sEmpty
),
1701 "Unexpected presentation for annotation field");
1703 // annotation element + content
1704 SvXMLElementExport
aElem(GetExport(), XML_NAMESPACE_OFFICE
,
1705 XML_ANNOTATION
, sal_False
, sal_True
);
1708 OUString
aAuthor( GetStringProperty(sPropertyAuthor
, rPropSet
) );
1709 if( aAuthor
.getLength() )
1711 SvXMLElementExport
aCreatorElem( GetExport(), XML_NAMESPACE_DC
,
1712 XML_CREATOR
, sal_True
,
1714 GetExport().Characters(aAuthor
);
1718 DateTime
aDate( GetDateTimeProperty(sPropertyDateTimeValue
, rPropSet
) );
1720 OUStringBuffer aBuffer
;
1721 GetExport().GetMM100UnitConverter().convertDateTime(aBuffer
,
1724 SvXMLElementExport
aDateElem( GetExport(), XML_NAMESPACE_DC
,
1727 GetExport().Characters(aBuffer
.makeStringAndClear());
1730 com::sun::star::uno::Reference
< com::sun::star::text::XText
> xText
;
1733 com::sun::star::uno::Any aRet
= rPropSet
->getPropertyValue(sPropertyTextRange
);
1736 catch ( com::sun::star::uno::Exception
& )
1740 GetExport().GetTextParagraphExport()->exportText( xText
);
1742 ProcessParagraphSequence(GetStringProperty(sPropertyContent
,rPropSet
));
1746 case FIELD_ID_COMBINED_CHARACTERS
:
1748 // The style with the combined characters attribute has
1749 // already been handled in the ExportField method. So all that
1750 // is left to do now is to export the characters.
1751 GetExport().Characters(sPresentation
);
1757 ExportMetaField(rPropSet
, false, bProgress
);
1761 case FIELD_ID_MEASURE
:
1763 ProcessString(XML_KIND
, MapMeasureKind(GetInt16Property(sPropertyMeasureKind
, rPropSet
)));
1764 ExportElement( XML_MEASURE
, sPresentation
);
1768 case FIELD_ID_TABLE_FORMULA
:
1769 ProcessString( XML_FORMULA
, XML_NAMESPACE_OOOW
,
1770 GetStringProperty(sPropertyContent
, rPropSet
) );
1771 ProcessDisplay( sal_True
,
1772 GetBoolProperty(sPropertyIsShowFormula
, rPropSet
),
1774 ProcessValueAndType( sal_False
,
1775 GetIntProperty(sPropertyNumberFormat
, rPropSet
),
1776 sEmpty
, sEmpty
, 0.0f
,
1777 sal_False
, sal_False
, sal_True
,
1778 sal_False
, sal_False
);
1779 ExportElement( XML_TABLE_FORMULA
, sPresentation
);
1782 case FIELD_ID_DROP_DOWN
:
1784 ProcessString(XML_NAME
, GetStringProperty(sPropertyName
, rPropSet
));
1785 ProcessString(XML_HELP
,
1786 GetStringProperty(sPropertyHelp
, rPropSet
), true);
1787 ProcessString(XML_HINT
,
1788 GetStringProperty(sPropertyTooltip
, rPropSet
), true);
1789 SvXMLElementExport
aElem( GetExport(),
1790 XML_NAMESPACE_TEXT
, XML_DROPDOWN
,
1791 sal_False
, sal_False
);
1792 ProcessStringSequence
1793 (GetStringSequenceProperty( sPropertyItems
, rPropSet
),
1794 GetStringProperty( sPropertySelectedItem
, rPropSet
) );
1796 GetExport().Characters( sPresentation
);
1800 case FIELD_ID_DRAW_HEADER
:
1802 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_HEADER
, sal_False
, sal_False
);
1806 case FIELD_ID_DRAW_FOOTER
:
1808 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_FOOTER
, sal_False
, sal_False
);
1812 case FIELD_ID_DRAW_DATE_TIME
:
1814 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_PRESENTATION
, XML_DATE_TIME
, sal_False
, sal_False
);
1818 case FIELD_ID_UNKNOWN
:
1820 DBG_ERROR("unkown field type encountered!");
1821 // always export content
1822 GetExport().Characters(sPresentation
);
1827 /// export field declarations / field masters
1828 void XMLTextFieldExport::ExportFieldDeclarations()
1830 Reference
<XText
> xEmptyText
;
1831 ExportFieldDeclarations(xEmptyText
);
1834 /// export field declarations / field masters
1835 void XMLTextFieldExport::ExportFieldDeclarations(
1836 const Reference
<XText
> & rText
)
1838 // store lists for decl elements
1839 vector
<OUString
> aVarName
;
1840 vector
<OUString
> aUserName
;
1841 vector
<OUString
> aSeqName
;
1842 vector
<OUString
> aDdeName
;
1844 // get text fields supplier and field master name access
1845 Reference
<XTextFieldsSupplier
> xTextFieldsSupp(GetExport().GetModel(),
1847 if( !xTextFieldsSupp
.is() )
1850 Reference
<container::XNameAccess
> xFieldMasterNameAccess(
1851 xTextFieldsSupp
->getTextFieldMasters(), UNO_QUERY
);
1853 // where to get the text field masters from?
1854 // a) we get a specific XText: then use pUsedMasters
1855 // b) the XText is empty: then export all text fields
1856 Sequence
<OUString
> aFieldMasters
;
1859 // export only used masters
1860 DBG_ASSERT(NULL
!= pUsedMasters
,
1861 "field masters must be recorded in order to be "
1862 "written out separatly" );
1863 if (NULL
!= pUsedMasters
)
1865 map
<Reference
<XText
>, set
<OUString
> > ::iterator aMapIter
=
1866 pUsedMasters
->find(rText
);
1867 if (aMapIter
!= pUsedMasters
->end())
1869 // found the set of used field masters
1870 set
<OUString
> & rOurMasters
= aMapIter
->second
;
1872 // copy set to sequence
1873 aFieldMasters
.realloc( rOurMasters
.size() );
1875 for( set
<OUString
>::iterator aSetIter
= rOurMasters
.begin();
1876 aSetIter
!= rOurMasters
.end();
1879 aFieldMasters
[i
] = *aSetIter
;
1882 pUsedMasters
->erase(rText
);
1884 // else: XText not found -> ignore
1886 // else: no field masters have been recorded -> ignore
1890 // no XText: export all!
1891 aFieldMasters
= xFieldMasterNameAccess
->getElementNames();
1894 for(sal_Int32 i
=0; i
<aFieldMasters
.getLength(); i
++) {
1896 // get field master name
1897 OUString sFieldMaster
= aFieldMasters
[i
];
1899 // workaround for #no-bug#
1900 static const sal_Char sDB
[] =
1901 "com.sun.star.text.FieldMaster.DataBase.";
1902 if ( sFieldMaster
.matchIgnoreAsciiCaseAsciiL( sDB
, sizeof(sDB
)-1) )
1908 OUString sFieldMasterType
;
1910 ExplodeFieldMasterName(sFieldMaster
, sFieldMasterType
, sVarName
);
1912 // get XPropertySet of this field master
1913 Reference
<XPropertySet
> xPropSet
;
1914 Any aAny
= xFieldMasterNameAccess
->getByName(sFieldMaster
);
1917 // save interesting field masters
1918 if (0 == sFieldMasterType
.compareToAscii(FIELD_SERVICE_SETEXP
))
1920 sal_Int32 nType
= GetIntProperty(sPropertySubType
, xPropSet
);
1922 // sequence or variable?
1923 if ( SetVariableType::SEQUENCE
== nType
)
1925 aSeqName
.push_back( sFieldMaster
);
1929 aVarName
.push_back( sFieldMaster
);
1932 else if (0 == sFieldMasterType
.compareToAscii(FIELD_SERVICE_USER
))
1934 aUserName
.push_back( sFieldMaster
);
1936 else if (0 == sFieldMasterType
.compareToAscii(FIELD_SERVICE_DDE
))
1938 aDdeName
.push_back( sFieldMaster
);
1946 // now process fields:
1948 // variable field masters:
1949 if ( !aVarName
.empty() )
1951 SvXMLElementExport
aElem( GetExport(),
1954 sal_True
, sal_True
);
1956 for (vector
<OUString
>::iterator aVarIter
= aVarName
.begin();
1957 aVarIter
!= aVarName
.end();
1960 OUString sName
= *aVarIter
;
1962 // get field master property set
1963 Reference
<XPropertySet
> xPropSet
;
1964 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
1967 // field name and type
1968 OUString sFieldMasterType
;
1970 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
1972 // determine string/numeric field
1973 sal_Bool bIsString
= ( GetIntProperty(sPropertySubType
, xPropSet
)
1974 == SetVariableType::STRING
);
1976 // get dependent field property set
1977 Reference
<XPropertySet
> xFieldPropSet
;
1978 if (GetDependentFieldPropertySet(xPropSet
, xFieldPropSet
))
1980 // process value and type.
1981 ProcessValueAndType(
1983 GetIntProperty(sPropertyNumberFormat
, xFieldPropSet
),
1984 sEmpty
, sEmpty
, 0.0,
1985 sal_False
, sal_True
, sal_False
, sal_False
);
1989 // If no dependent field is found, only string and
1990 // float types can be supported
1992 // number format: 0 is default number format for 1st
1993 // language. should be: getDefaultNumberFormat(Locale)
1994 // from NumberFormats
1995 ProcessValueAndType(
1997 0, sEmpty
, sEmpty
, 0.0,
1998 sal_False
, sal_True
, sal_False
, sal_False
);
2001 ProcessString(XML_NAME
, sVarName
);
2002 ExportElement(XML_VARIABLE_DECL
, sal_True
);
2005 // else: no declarations element
2007 // sequence field masters:
2008 if ( !aSeqName
.empty() )
2010 SvXMLElementExport
aElem( GetExport(),
2013 sal_True
, sal_True
);
2015 for (vector
<OUString
>::iterator aSeqIter
= aSeqName
.begin();
2016 aSeqIter
!= aSeqName
.end();
2019 OUString sName
= *aSeqIter
;
2021 // get field master property set
2022 Reference
<XPropertySet
> xPropSet
;
2023 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2026 // field name and type
2027 OUString sFieldMasterType
;
2029 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2032 sal_Int32 nLevel
= 1 + GetIntProperty(
2033 sPropertyChapterNumberingLevel
, xPropSet
);
2034 DBG_ASSERT(nLevel
>= 0, "illegal outline level");
2035 DBG_ASSERT(nLevel
< 127, "possible illegal outline level");
2036 ProcessInteger(XML_DISPLAY_OUTLINE_LEVEL
, nLevel
);
2038 // separation character
2040 ProcessString(XML_SEPARATION_CHARACTER
, GetStringProperty(
2041 sPropertyNumberingSeparator
, xPropSet
));
2043 ProcessString(XML_NAME
, sVarName
);
2044 ExportElement(XML_SEQUENCE_DECL
, sal_True
);
2047 // else: no declarations element
2049 // user field field masters:
2050 if ( !aUserName
.empty() )
2052 SvXMLElementExport
aElem( GetExport(),
2054 XML_USER_FIELD_DECLS
,
2055 sal_True
, sal_True
);
2057 for (vector
<OUString
>::iterator aUserIter
= aUserName
.begin();
2058 aUserIter
!= aUserName
.end();
2061 OUString sName
= *aUserIter
;
2063 // get field master property set
2064 Reference
<XPropertySet
> xPropSet
;
2065 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2068 // field name and type
2069 OUString sFieldMasterType
;
2071 ExplodeFieldMasterName(sName
, sFieldMasterType
, sVarName
);
2073 if (GetBoolProperty(sPropertyIsExpression
, xPropSet
))
2076 ProcessValueAndType(
2079 GetDoubleProperty(sPropertyValue
, xPropSet
),
2087 // string: write regardless of default
2088 ProcessString(XML_VALUE_TYPE
, XML_STRING
, sal_False
,
2089 XML_NAMESPACE_OFFICE
);
2090 ProcessString(XML_STRING_VALUE
,
2091 GetStringProperty(sPropertyContent
, xPropSet
),
2092 sal_False
, XML_NAMESPACE_OFFICE
);
2094 ProcessString(XML_NAME
, sVarName
);
2095 ExportElement(XML_USER_FIELD_DECL
, sal_True
);
2098 // else: no declarations element
2100 // DDE field field masters:
2101 if ( !aDdeName
.empty() )
2103 SvXMLElementExport
aElem( GetExport(),
2105 XML_DDE_CONNECTION_DECLS
,
2106 sal_True
, sal_True
);
2108 for (vector
<OUString
>::iterator aDdeIter
= aDdeName
.begin();
2109 aDdeIter
!= aDdeName
.end();
2112 OUString sName
= *aDdeIter
;
2114 // get field master property set
2115 Reference
<XPropertySet
> xPropSet
;
2116 Any aAny
= xFieldMasterNameAccess
->getByName(sName
);
2119 // check if this connection is being used by a field
2120 Reference
<XPropertySet
> xDummy
;
2121 if (GetDependentFieldPropertySet(xPropSet
, xDummy
))
2124 ProcessString(XML_NAME
,
2125 GetStringProperty(sPropertyName
, xPropSet
),
2126 sal_False
, XML_NAMESPACE_OFFICE
);
2128 // export elements; can't use ProcessString because
2129 // elements are in office namespace
2130 ProcessString(XML_DDE_APPLICATION
,
2131 GetStringProperty(sPropertyDDECommandType
,
2133 sal_False
, XML_NAMESPACE_OFFICE
);
2134 ProcessString(XML_DDE_TOPIC
,
2135 GetStringProperty(sPropertyDDECommandFile
,
2137 sal_False
, XML_NAMESPACE_OFFICE
);
2138 ProcessString(XML_DDE_ITEM
,
2139 GetStringProperty(sPropertyDDECommandElement
,
2141 sal_False
, XML_NAMESPACE_OFFICE
);
2142 sal_Bool bIsAutomaticUpdate
= GetBoolProperty(
2143 sPropertyIsAutomaticUpdate
, xPropSet
);
2144 if (bIsAutomaticUpdate
)
2146 GetExport().AddAttribute(XML_NAMESPACE_OFFICE
,
2147 XML_AUTOMATIC_UPDATE
,
2151 ExportElement(XML_DDE_CONNECTION_DECL
, sal_True
);
2153 // else: no dependent field -> no export of field declaration
2156 // else: no declarations element
2159 void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
2160 sal_Bool bExportOnlyUsed
)
2162 delete pUsedMasters
;
2163 pUsedMasters
= NULL
;
2165 // create used masters set (if none is used)
2166 if (bExportOnlyUsed
)
2167 pUsedMasters
= new map
<Reference
<XText
>, set
<OUString
> > ;
2170 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2173 // can't call ExportElement(eElementName, const OUString&) with empty
2174 // string because xmlprinter only uses empty tags if no content
2175 // (not even empty content) was written.
2177 DBG_ASSERT(XML_TOKEN_INVALID
!= eElementName
, "invalid element name!");
2178 if (XML_TOKEN_INVALID
!= eElementName
)
2181 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2182 eElementName
, bAddSpace
, bAddSpace
);
2186 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName
,
2187 const OUString
& sContent
,
2190 DBG_ASSERT(eElementName
!= XML_TOKEN_INVALID
, "invalid element name!");
2191 if (eElementName
!= XML_TOKEN_INVALID
)
2194 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2195 eElementName
, bAddSpace
, bAddSpace
);
2197 GetExport().Characters(sContent
);
2199 // always export content
2200 GetExport().Characters(sContent
);
2204 void XMLTextFieldExport::ExportMacro(
2205 const Reference
<XPropertySet
> & rPropSet
,
2206 const OUString
& rContent
)
2208 // some strings we'll need
2209 OUString
sEventType( RTL_CONSTASCII_USTRINGPARAM( "EventType" ));
2210 OUString
sStarBasic( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ));
2211 OUString
sScript( RTL_CONSTASCII_USTRINGPARAM( "Script" ));
2212 OUString
sLibrary( RTL_CONSTASCII_USTRINGPARAM( "Library" ));
2213 OUString
sMacroName( RTL_CONSTASCII_USTRINGPARAM( "MacroName" ));
2214 OUString
sOnClick( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ));
2215 OUString
sPropertyMacroLibrary( RTL_CONSTASCII_USTRINGPARAM( "MacroLibrary" ));
2216 OUString
sPropertyMacroName( RTL_CONSTASCII_USTRINGPARAM( "MacroName" ));
2217 OUString
sPropertyScriptURL( RTL_CONSTASCII_USTRINGPARAM( "ScriptURL" ));
2220 // the description attribute
2221 ProcessString(XML_DESCRIPTION
,
2222 GetStringProperty(sPropertyHint
, rPropSet
),
2226 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_TEXT
,
2227 XML_EXECUTE_MACRO
, sal_False
, sal_False
);
2229 // the <office:events>-macro:
2231 // 1) build sequence of PropertyValues
2232 Sequence
<PropertyValue
> aSeq
;
2234 rPropSet
->getPropertyValue( sPropertyScriptURL
) >>= sName
;
2236 // if the ScriptURL property is not empty then this is a Scripting
2237 // Framework URL, otherwise treat it as a Basic Macro
2238 if (sName
.getLength() != 0)
2240 aSeq
= Sequence
<PropertyValue
> (2);
2241 PropertyValue
* pArr
= aSeq
.getArray();
2242 pArr
[0].Name
= sEventType
;
2243 pArr
[0].Value
<<= sScript
;
2244 pArr
[1].Name
= sScript
;
2245 pArr
[1].Value
= rPropSet
->getPropertyValue( sPropertyScriptURL
);
2249 aSeq
= Sequence
<PropertyValue
> (3);
2250 PropertyValue
* pArr
= aSeq
.getArray();
2251 pArr
[0].Name
= sEventType
;
2252 pArr
[0].Value
<<= sStarBasic
;
2253 pArr
[1].Name
= sLibrary
;
2254 pArr
[1].Value
= rPropSet
->getPropertyValue( sPropertyMacroLibrary
);
2255 pArr
[2].Name
= sMacroName
;
2256 pArr
[2].Value
= rPropSet
->getPropertyValue( sPropertyMacroName
);
2259 // 2) export the sequence
2260 GetExport().GetEventExport().ExportSingleEvent( aSeq
, sOnClick
, sal_False
);
2262 // and finally, the field presentation
2263 GetExport().Characters(rContent
);
2266 // FIXME: this is untested
2267 void XMLTextFieldExport::ExportMetaField(
2268 const Reference
<XPropertySet
> & i_xMeta
,
2269 bool i_bAutoStyles
, sal_Bool i_bProgress
)
2271 bool doExport(!i_bAutoStyles
); // do not export element if autostyles
2272 // check version >= 1.2
2273 switch (GetExport().getDefaultVersion()) {
2274 case SvtSaveOptions::ODFVER_011
: // fall thru
2275 case SvtSaveOptions::ODFVER_010
: doExport
= false; break;
2279 const Reference
< XEnumerationAccess
> xEA( i_xMeta
, UNO_QUERY_THROW
);
2280 const Reference
< XEnumeration
> xTextEnum( xEA
->createEnumeration() );
2284 const Reference
<rdf::XMetadatable
> xMeta( i_xMeta
, UNO_QUERY_THROW
);
2286 // style:data-style-name
2287 ProcessValueAndType(sal_False
,
2288 GetIntProperty(sPropertyNumberFormat
, i_xMeta
),
2289 sEmpty
, sEmpty
, 0.0, sal_False
, sal_False
, sal_True
,
2290 sal_False
, sal_False
/*, sal_False*/ );
2292 // text:meta-field without xml:id is invalid
2293 xMeta
->ensureMetadataReference();
2295 // xml:id for RDF metadata
2296 GetExport().AddAttributeXmlId(xMeta
);
2299 SvXMLElementExport
aElem( GetExport(), doExport
,
2300 XML_NAMESPACE_TEXT
, XML_META_FIELD
, sal_False
, sal_False
);
2302 // recurse to export content
2303 GetExport().GetTextParagraphExport()->
2304 exportTextRangeEnumeration( xTextEnum
, i_bAutoStyles
, i_bProgress
);
2307 /// export all data-style related attributes
2308 void XMLTextFieldExport::ProcessValueAndType(
2309 sal_Bool bIsString
, /// do we process a string or a number?
2310 sal_Int32 nFormatKey
, /// format key for NumberFormatter; inv. if string
2311 const OUString
& sContent
, /// string content; possibly invalid
2312 const OUString
& sDefault
, /// default string
2313 double fValue
, /// float content; possibly invalid
2314 sal_Bool bExportValue
, /// export value attribute?
2315 sal_Bool bExportValueType
, /// export value-type attribute?
2316 sal_Bool bExportStyle
, /// export style-sttribute?
2317 sal_Bool bForceSystemLanguage
, /// export language attributes?
2318 sal_Bool bTimeStyle
) // exporting a time style?
2320 // String or number?
2324 // string: attributes value-type=string, string-value=...
2326 if (bExportValue
|| bExportValueType
)
2328 XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
2329 GetExport(), sContent
, sDefault
, bExportValue
);
2336 // number: value-type=..., value...=..., data-style-name=...
2338 DBG_ASSERT(bExportValueType
|| !bExportValue
, "value w/o value type not supported!");
2340 // take care of illegal formats
2341 // (shouldn't happen, but does if document is corrupted)
2342 if (-1 != nFormatKey
)
2344 if (bExportValue
|| bExportValueType
)
2346 XMLNumberFormatAttributesExportHelper::
2347 SetNumberFormatAttributes(
2348 GetExport(), nFormatKey
, fValue
, bExportValue
);
2353 // don't export language (if desired)
2354 if( bForceSystemLanguage
)
2356 GetExport().dataStyleForceSystemLanguage( nFormatKey
);
2358 OUString sDataStyleName
=
2359 GetExport().getDataStyleName(nFormatKey
, bTimeStyle
);
2360 if( sDataStyleName
.getLength() > 0 )
2362 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
2363 XML_DATA_STYLE_NAME
,
2365 } // else: ignore (no valid number format)
2366 } // else: ignore (no number format)
2373 /// process display related properties
2374 void XMLTextFieldExport::ProcessDisplay(sal_Bool bIsVisible
,
2375 sal_Bool bIsCommand
,
2376 sal_Bool bValueDefault
)
2378 enum XMLTokenEnum eValue
;
2382 eValue
= bIsCommand
? XML_FORMULA
: XML_VALUE
;
2389 // omit attribute if default
2390 if (!bValueDefault
|| (eValue
!= XML_VALUE
))
2392 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, XML_DISPLAY
, eValue
);
2398 /// export boolean property
2399 void XMLTextFieldExport::ProcessBoolean(enum XMLTokenEnum eName
,
2400 sal_Bool bBool
, sal_Bool bDefault
)
2402 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2403 if ( XML_TOKEN_INVALID
== eName
)
2406 // write attribute (if different than default)
2407 // negate to force 0/1 values (and make sal_Bool comparable)
2408 if ((!bBool
) != (!bDefault
)) {
2409 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2410 (bBool
? XML_TRUE
: XML_FALSE
) );
2417 /// export string attribute
2418 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2419 const OUString
& sValue
,
2420 sal_Bool bOmitEmpty
,
2423 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2424 if ( XML_TOKEN_INVALID
== eName
)
2427 // check for empty string, if applicable
2428 if ( bOmitEmpty
&& (sValue
.getLength()==0) )
2432 GetExport().AddAttribute(nPrefix
, eName
, sValue
);
2435 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2436 sal_uInt16 nValuePrefix
,
2437 const OUString
& sValue
,
2438 sal_Bool bOmitEmpty
,
2442 GetExport().GetNamespaceMap().GetQNameByKey( nValuePrefix
, sValue
, sal_False
);
2443 ProcessString( eName
, sQValue
, bOmitEmpty
, nPrefix
);
2446 /// export a string attribute
2447 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2448 const ::rtl::OUString
& sValue
,
2449 const ::rtl::OUString
& sDefault
,
2452 if (sValue
!= sDefault
)
2454 ProcessString(eName
, sValue
, sal_False
, nPrefix
);
2458 /// export a string attribute
2459 void XMLTextFieldExport::ProcessString(enum XMLTokenEnum eName
,
2460 sal_uInt16 nValuePrefix
,
2461 const ::rtl::OUString
& sValue
,
2462 const ::rtl::OUString
& sDefault
,
2465 if (sValue
!= sDefault
)
2467 ProcessString(eName
, nValuePrefix
, sValue
, sal_False
, nPrefix
);
2472 /// export string attribute
2473 void XMLTextFieldExport::ProcessString(
2474 enum XMLTokenEnum eName
,
2475 enum XMLTokenEnum eValue
,
2476 sal_Bool bOmitEmpty
,
2479 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token" );
2480 DBG_ASSERT( bOmitEmpty
|| (eValue
!= XML_TOKEN_INVALID
),
2481 "invalid value token" );
2482 if ( XML_TOKEN_INVALID
== eName
)
2485 // check for empty string, if applicable
2486 if (bOmitEmpty
&& (eValue
== XML_TOKEN_INVALID
))
2489 GetExport().AddAttribute(nPrefix
, eName
, eValue
);
2492 /// export a string attribute
2493 void XMLTextFieldExport::ProcessString(
2494 enum XMLTokenEnum eName
,
2495 enum XMLTokenEnum eValue
,
2496 enum XMLTokenEnum eDefault
,
2499 if ( eValue
!= eDefault
)
2500 ProcessString( eName
, eValue
, sal_False
, nPrefix
);
2504 /// export a string as a sequence of paragraphs
2505 void XMLTextFieldExport::ProcessParagraphSequence(
2506 const ::rtl::OUString
& sParagraphSequence
)
2508 // iterate over all string-pieces separated by return (0x0a) and
2509 // put each inside a paragraph element.
2510 SvXMLTokenEnumerator
aEnumerator(sParagraphSequence
, sal_Char(0x0a));
2511 OUString aSubString
;
2512 while (aEnumerator
.getNextToken(aSubString
))
2514 SvXMLElementExport
aParagraph(
2515 GetExport(), XML_NAMESPACE_TEXT
, XML_P
, sal_True
, sal_False
);
2516 GetExport().Characters(aSubString
);
2520 // export an integer attribute
2521 void XMLTextFieldExport::ProcessInteger(enum XMLTokenEnum eName
,
2524 DBG_ASSERT( eName
!= XML_TOKEN_INVALID
, "invalid element token");
2525 if ( XML_TOKEN_INVALID
== eName
)
2528 GetExport().AddAttribute(XML_NAMESPACE_TEXT
, eName
,
2529 OUString::valueOf(nNum
));
2532 /// export an integer attribute, omit if default
2533 void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName
,
2534 sal_Int32 nNum
, sal_Int32 nDefault
)
2536 if (nNum
!= nDefault
)
2537 ProcessInteger(eName
, nNum
);
2542 /// export a numbering type
2543 void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType
)
2545 // process only if real format (not: like page descriptor)
2546 if (NumberingType::PAGE_DESCRIPTOR
!= nNumberingType
)
2548 OUStringBuffer
sTmp( 10 );
2549 // number type: num format
2550 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp
,
2552 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
2553 sTmp
.makeStringAndClear() );
2554 // and letter sync, if applicable
2555 GetExport().GetMM100UnitConverter().convertNumLetterSync( sTmp
,
2558 if (sTmp
.getLength())
2560 GetExport().AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_LETTER_SYNC
,
2561 sTmp
.makeStringAndClear() );
2564 // else: like page descriptor => ignore
2568 /// export a date, time, or duration
2569 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2572 sal_Bool bIsDuration
,
2573 sal_Bool bOmitDurationIfZero
,
2576 // truncate for date granularity
2579 dValue
= ::rtl::math::approxFloor(dValue
);
2582 OUStringBuffer aBuffer
;
2585 // date/time durationM handle bOmitDurationIfZero
2586 if (!bOmitDurationIfZero
|| !::rtl::math::approxEqual(dValue
, 0.0))
2588 rExport
.GetMM100UnitConverter().convertTime(aBuffer
, dValue
);
2594 rExport
.GetMM100UnitConverter().convertDateTime(aBuffer
, dValue
);
2598 ProcessString(eName
, aBuffer
.makeStringAndClear(), sal_True
, nPrefix
);
2601 /// export a date or time
2602 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2603 const DateTime
& rTime
,
2607 OUStringBuffer aBuffer
;
2609 DateTime
aDateTime(rTime
);
2614 aDateTime
.HundredthSeconds
= 0;
2615 aDateTime
.Seconds
= 0;
2616 aDateTime
.Minutes
= 0;
2617 aDateTime
.Hours
= 0;
2621 rExport
.GetMM100UnitConverter().convertDateTime(aBuffer
, aDateTime
);
2624 ProcessString(eName
, aBuffer
.makeStringAndClear(), sal_True
, nPrefix
);
2627 /// export date according to ISO 8601
2628 void XMLTextFieldExport::ProcessDate(
2629 enum XMLTokenEnum eName
,
2630 const ::com::sun::star::util::Date
& rDate
,
2633 // the easiest way: delegate to ProcessDateTime (as date)
2635 aDateTime
.Day
= rDate
.Day
;
2636 aDateTime
.Month
= rDate
.Month
;
2637 aDateTime
.Year
= rDate
.Year
;
2638 ProcessDateTime(eName
, aDateTime
, sal_True
, nPrefix
);
2642 /// export a date, time, or duration
2643 void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName
,
2646 sal_Bool bIsDuration
,
2647 sal_Bool bOmitDurationIfZero
,
2650 // handle bOmitDurationIfZero here, because we can precisely compare ints
2651 if (!(bIsDuration
&& bOmitDurationIfZero
&& (nMinutes
==0)))
2653 ProcessDateTime(eName
, (double)nMinutes
/ (double)(24*60),
2654 bIsDate
, bIsDuration
, bOmitDurationIfZero
, nPrefix
);
2659 SvXMLEnumMapEntry __READONLY_DATA aBibliographyDataTypeMap
[] =
2661 { XML_ARTICLE
, BibliographyDataType::ARTICLE
},
2662 { XML_BOOK
, BibliographyDataType::BOOK
},
2663 { XML_BOOKLET
, BibliographyDataType::BOOKLET
},
2664 { XML_CONFERENCE
, BibliographyDataType::CONFERENCE
},
2665 { XML_CUSTOM1
, BibliographyDataType::CUSTOM1
},
2666 { XML_CUSTOM2
, BibliographyDataType::CUSTOM2
},
2667 { XML_CUSTOM3
, BibliographyDataType::CUSTOM3
},
2668 { XML_CUSTOM4
, BibliographyDataType::CUSTOM4
},
2669 { XML_CUSTOM5
, BibliographyDataType::CUSTOM5
},
2670 { XML_EMAIL
, BibliographyDataType::EMAIL
},
2671 { XML_INBOOK
, BibliographyDataType::INBOOK
},
2672 { XML_INCOLLECTION
, BibliographyDataType::INCOLLECTION
},
2673 { XML_INPROCEEDINGS
, BibliographyDataType::INPROCEEDINGS
},
2674 { XML_JOURNAL
, BibliographyDataType::JOURNAL
},
2675 { XML_MANUAL
, BibliographyDataType::MANUAL
},
2676 { XML_MASTERSTHESIS
, BibliographyDataType::MASTERSTHESIS
},
2677 { XML_MISC
, BibliographyDataType::MISC
},
2678 { XML_PHDTHESIS
, BibliographyDataType::PHDTHESIS
},
2679 { XML_PROCEEDINGS
, BibliographyDataType::PROCEEDINGS
},
2680 { XML_TECHREPORT
, BibliographyDataType::TECHREPORT
},
2681 { XML_UNPUBLISHED
, BibliographyDataType::UNPUBLISHED
},
2682 { XML_WWW
, BibliographyDataType::WWW
},
2683 { XML_TOKEN_INVALID
, 0 }
2688 void XMLTextFieldExport::ProcessBibliographyData(
2689 const Reference
<XPropertySet
>& rPropSet
)
2692 Any aAny
= rPropSet
->getPropertyValue(sPropertyFields
);
2693 Sequence
<PropertyValue
> aValues
;
2696 // one attribute per value (unless empty)
2697 sal_Int32 nLength
= aValues
.getLength();
2698 for (sal_Int32 i
= 0; i
< nLength
; i
++)
2700 if (aValues
[i
].Name
.equalsAsciiL("BibiliographicType",
2701 sizeof("BibiliographicType")-1))
2703 sal_Int16 nTypeId
= 0;
2704 aValues
[i
].Value
>>= nTypeId
;
2705 OUStringBuffer sBuf
;
2707 if (SvXMLUnitConverter::convertEnum(sBuf
, nTypeId
,
2708 aBibliographyDataTypeMap
))
2710 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
2711 XML_BIBLIOGRAPHY_TYPE
,
2712 sBuf
.makeStringAndClear());
2714 // else: ignore this argument
2719 aValues
[i
].Value
>>= sStr
;
2721 if (sStr
.getLength() > 0)
2723 rExport
.AddAttribute(XML_NAMESPACE_TEXT
,
2724 MapBibliographyFieldName(aValues
[i
].Name
),
2731 /// export CommandTypeAttribute
2732 void XMLTextFieldExport::ProcessCommandType(
2733 sal_Int32 nCommandType
)
2735 enum XMLTokenEnum eToken
= XML_TOKEN_INVALID
;
2736 switch( nCommandType
)
2738 case sdb::CommandType::TABLE
: eToken
= XML_TABLE
; break;
2739 case sdb::CommandType::QUERY
: eToken
= XML_QUERY
; break;
2740 case sdb::CommandType::COMMAND
: eToken
= XML_COMMAND
; break;
2743 if( eToken
!= XML_TOKEN_INVALID
)
2744 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_TABLE_TYPE
, eToken
);
2748 void XMLTextFieldExport::ProcessStringSequence(
2749 const Sequence
<OUString
>& rSequence
,
2750 const OUString sSelected
)
2752 // find selected element
2753 sal_Int32 nSelected
= -1;
2754 sal_Int32 nLength
= rSequence
.getLength();
2755 const OUString
* pSequence
= rSequence
.getConstArray();
2756 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2758 if( pSequence
[i
] == sSelected
)
2762 // delegate to ProcessStringSequence(OUString,sal_Int32)
2763 ProcessStringSequence( rSequence
, nSelected
);
2766 void XMLTextFieldExport::ProcessStringSequence(
2767 const Sequence
<OUString
>& rSequence
,
2768 sal_Int32 nSelected
)
2770 sal_Int32 nLength
= rSequence
.getLength();
2771 const OUString
* pSequence
= rSequence
.getConstArray();
2772 for( sal_Int32 i
= 0; i
< nLength
; i
++ )
2774 if( i
== nSelected
)
2775 rExport
.AddAttribute( XML_NAMESPACE_TEXT
,
2776 XML_CURRENT_SELECTED
, XML_TRUE
);
2777 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_VALUE
, pSequence
[i
] );
2778 SvXMLElementExport
aElement( rExport
, XML_NAMESPACE_TEXT
, XML_LABEL
,
2779 sal_False
, sal_False
);
2783 void XMLTextFieldExport::ExportDataBaseElement(
2784 enum XMLTokenEnum eElementName
,
2785 const OUString
& sPresentation
,
2786 const Reference
<XPropertySet
>& rPropertySet
,
2787 const Reference
<XPropertySetInfo
>& rPropertySetInfo
)
2789 DBG_ASSERT( eElementName
!= XML_TOKEN_INVALID
, "need token" );
2790 DBG_ASSERT( rPropertySet
.is(), "need property set" );
2791 DBG_ASSERT( rPropertySetInfo
.is(), "need property set info" );
2793 // get database properties
2794 OUString sDataBaseName
;
2795 OUString sDataBaseURL
;
2797 if( ( rPropertySet
->getPropertyValue( sPropertyDataBaseName
) >>= sStr
)
2798 && ( sStr
.getLength() > 0 ) )
2800 sDataBaseName
= sStr
;
2802 else if( rPropertySetInfo
->hasPropertyByName( sPropertyDataBaseURL
) &&
2803 (rPropertySet
->getPropertyValue( sPropertyDataBaseURL
) >>= sStr
) &&
2804 (sStr
.getLength() > 0) )
2806 sDataBaseURL
= sStr
;
2809 // add database name property (if present)
2810 if( sDataBaseName
.getLength() > 0 )
2811 rExport
.AddAttribute( XML_NAMESPACE_TEXT
, XML_DATABASE_NAME
,
2813 SvXMLElementExport
aDataBaseElement( GetExport(),
2814 XML_NAMESPACE_TEXT
, eElementName
,
2815 sal_False
, sal_False
);
2817 // write URL as children
2818 if( sDataBaseURL
.getLength() > 0 )
2820 rExport
.AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sDataBaseURL
);
2821 SvXMLElementExport
aDataSourceElement(
2822 GetExport(), XML_NAMESPACE_FORM
, XML_CONNECTION_RESOURCE
,
2823 sal_False
, sal_False
);
2826 // write presentation
2827 rExport
.Characters( sPresentation
);
2832 // explode a field master name into field type and field name
2833 sal_Bool
XMLTextFieldExport::ExplodeFieldMasterName(
2834 const OUString
& sMasterName
, OUString
& sFieldType
, OUString
& sVarName
)
2836 sal_Int32 nLength
= sFieldMasterPrefix
.getLength();
2837 sal_Int32 nSeparator
= sMasterName
.indexOf('.', nLength
);
2838 sal_Bool bReturn
= sal_True
;
2841 // check for service name
2842 bReturn
&= (0 == sFieldMasterPrefix
.compareTo(sMasterName
, nLength
));
2846 if (nSeparator
<= nLength
) {
2847 nSeparator
= sMasterName
.getLength();
2848 DBG_WARNING("no field var name!");
2849 bReturn
= sal_False
;
2853 sFieldType
= sMasterName
.copy(nLength
, nSeparator
-nLength
);
2854 sVarName
= sMasterName
.copy(nSeparator
+1);
2861 // for XDependentTextFields, get PropertySet of FieldMaster
2862 Reference
<XPropertySet
> XMLTextFieldExport::GetMasterPropertySet(
2863 const Reference
<XTextField
> & rTextField
)
2865 // name, value => get Property set of TextFieldMaster
2866 Reference
<XDependentTextField
> xDep(rTextField
, UNO_QUERY
);
2867 return xDep
->getTextFieldMaster();
2870 // get PropertySet of (any; the first) dependent field
2871 sal_Bool
XMLTextFieldExport::GetDependentFieldPropertySet(
2872 const Reference
<XPropertySet
> & xMaster
,
2873 Reference
<XPropertySet
> & xField
)
2876 Sequence
<Reference
<XDependentTextField
> > aFields
;
2877 aAny
= xMaster
->getPropertyValue(sPropertyDependentTextFields
);
2881 if (aFields
.getLength() > 0)
2883 // get first one and return
2884 Reference
<XDependentTextField
> xTField
= aFields
[0];
2885 xField
= Reference
<XPropertySet
>(xTField
, UNO_QUERY
);
2886 DBG_ASSERT(xField
.is(),
2887 "Surprisinlgy, this TextField refuses to be a PropertySet!");
2897 /// map placeholder type
2898 enum XMLTokenEnum
XMLTextFieldExport::MapPlaceholderType(sal_uInt16 nType
)
2900 enum XMLTokenEnum eType
= XML_TEXT
;
2904 case PlaceholderType::TEXT
:
2908 case PlaceholderType::TABLE
:
2912 case PlaceholderType::TEXTFRAME
:
2913 eType
= XML_TEXT_BOX
;
2916 case PlaceholderType::GRAPHIC
:
2920 case PlaceholderType::OBJECT
:
2925 // unkown placeholder: XML_TEXT
2926 DBG_ERROR("unkown placeholder type");
2933 /// element name for author fields
2934 enum XMLTokenEnum
XMLTextFieldExport::MapAuthorFieldName(
2935 const Reference
<XPropertySet
> & xPropSet
)
2937 // Initalen oder voller Name?
2938 return GetBoolProperty(sPropertyFullName
, xPropSet
)
2939 ? XML_AUTHOR_NAME
: XML_AUTHOR_INITIALS
;
2942 enum XMLTokenEnum
XMLTextFieldExport::MapPageNumberName(
2943 const Reference
<XPropertySet
> & xPropSet
,
2946 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
2947 PageNumberType ePage
;
2948 Any aAny
= xPropSet
->getPropertyValue(sPropertySubType
);
2949 ePage
= *(PageNumberType
*)aAny
.getValue();
2953 case PageNumberType_PREV
:
2954 eName
= XML_PREVIOUS
;
2957 case PageNumberType_CURRENT
:
2958 eName
= XML_CURRENT
;
2960 case PageNumberType_NEXT
:
2965 DBG_ERROR("unknown page number type");
2966 eName
= XML_TOKEN_INVALID
;
2973 /// map TemplateDisplayFormat to XML
2974 enum XMLTokenEnum
XMLTextFieldExport::MapTemplateDisplayFormat(sal_Int16 nFormat
)
2976 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
2980 case TemplateDisplayFormat::FULL
:
2983 case TemplateDisplayFormat::PATH
:
2986 case TemplateDisplayFormat::NAME
:
2989 case TemplateDisplayFormat::NAME_AND_EXT
:
2990 eName
= XML_NAME_AND_EXTENSION
;
2992 case TemplateDisplayFormat::AREA
:
2995 case TemplateDisplayFormat::TITLE
:
2999 DBG_ERROR("unknown template display format");
3000 eName
= XML_TOKEN_INVALID
;
3007 /// map count/statistics field token to XML name
3008 enum XMLTokenEnum
XMLTextFieldExport::MapCountFieldName(FieldIdEnum nToken
)
3010 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3014 case FIELD_ID_COUNT_PAGES
:
3015 eElement
= XML_PAGE_COUNT
;
3017 case FIELD_ID_COUNT_PARAGRAPHS
:
3018 eElement
= XML_PARAGRAPH_COUNT
;
3020 case FIELD_ID_COUNT_WORDS
:
3021 eElement
= XML_WORD_COUNT
;
3023 case FIELD_ID_COUNT_CHARACTERS
:
3024 eElement
= XML_CHARACTER_COUNT
;
3026 case FIELD_ID_COUNT_TABLES
:
3027 eElement
= XML_TABLE_COUNT
;
3029 case FIELD_ID_COUNT_GRAPHICS
:
3030 eElement
= XML_IMAGE_COUNT
;
3032 case FIELD_ID_COUNT_OBJECTS
:
3033 eElement
= XML_OBJECT_COUNT
;
3036 DBG_ERROR("no count field token");
3037 eElement
= XML_TOKEN_INVALID
;
3044 /// map ChapterDisplayFormat to XML string
3045 enum XMLTokenEnum
XMLTextFieldExport::MapChapterDisplayFormat(sal_Int16 nFormat
)
3047 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3051 case ChapterFormat::NAME
:
3054 case ChapterFormat::NUMBER
:
3057 case ChapterFormat::NAME_NUMBER
:
3058 eName
= XML_NUMBER_AND_NAME
;
3060 case ChapterFormat::NO_PREFIX_SUFFIX
:
3061 eName
= XML_PLAIN_NUMBER_AND_NAME
;
3063 case ChapterFormat::DIGIT
:
3064 eName
= XML_PLAIN_NUMBER
;
3067 DBG_ERROR("unkown chapter display format");
3068 eName
= XML_TOKEN_INVALID
;
3076 /// map FilenameDisplayFormat to XML attribute names
3077 enum XMLTokenEnum
XMLTextFieldExport::MapFilenameDisplayFormat(sal_Int16 nFormat
)
3079 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3083 case FilenameDisplayFormat::FULL
:
3086 case FilenameDisplayFormat::PATH
:
3089 case FilenameDisplayFormat::NAME
:
3092 case FilenameDisplayFormat::NAME_AND_EXT
:
3093 eName
= XML_NAME_AND_EXTENSION
;
3096 DBG_ERROR("unknown filename display format");
3103 /// map ReferenceFieldPart to XML string
3104 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceType(sal_Int16 nType
)
3106 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3110 case ReferenceFieldPart::PAGE
:
3111 eElement
= XML_PAGE
;
3113 case ReferenceFieldPart::CHAPTER
:
3114 eElement
= XML_CHAPTER
;
3116 case ReferenceFieldPart::TEXT
:
3117 eElement
= XML_TEXT
;
3119 case ReferenceFieldPart::UP_DOWN
:
3120 eElement
= XML_DIRECTION
;
3122 case ReferenceFieldPart::CATEGORY_AND_NUMBER
:
3123 eElement
= XML_CATEGORY_AND_VALUE
;
3125 case ReferenceFieldPart::ONLY_CAPTION
:
3126 eElement
= XML_CAPTION
;
3128 case ReferenceFieldPart::ONLY_SEQUENCE_NUMBER
:
3129 eElement
= XML_VALUE
;
3131 case ReferenceFieldPart::PAGE_DESC
:
3132 // small hack: this value never gets written, because
3133 // XML_TEMPLATE is default
3134 eElement
= XML_TEMPLATE
;
3136 // --> OD 2007-09-14 #i81002#
3137 case ReferenceFieldPart::NUMBER
:
3138 eElement
= XML_NUMBER
;
3140 case ReferenceFieldPart::NUMBER_NO_CONTEXT
:
3141 eElement
= XML_NUMBER_NO_SUPERIOR
;
3143 case ReferenceFieldPart::NUMBER_FULL_CONTEXT
:
3144 eElement
= XML_NUMBER_ALL_SUPERIOR
;
3148 DBG_ERROR("unknown reference type");
3149 eElement
= XML_TEMPLATE
;
3156 /// map ReferenceFieldPart to XML string
3157 enum XMLTokenEnum
XMLTextFieldExport::MapReferenceSource(sal_Int16 nType
)
3159 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3163 case ReferenceFieldSource::REFERENCE_MARK
:
3164 eElement
= XML_REFERENCE_REF
;
3166 case ReferenceFieldSource::SEQUENCE_FIELD
:
3167 eElement
= XML_SEQUENCE_REF
;
3169 case ReferenceFieldSource::BOOKMARK
:
3170 eElement
= XML_BOOKMARK_REF
;
3172 case ReferenceFieldSource::FOOTNOTE
:
3173 case ReferenceFieldSource::ENDNOTE
:
3174 eElement
= XML_NOTE_REF
;
3177 DBG_ERROR("unkown reference source");
3185 /// element name for sender fields
3186 enum XMLTokenEnum
XMLTextFieldExport::MapSenderFieldName(
3187 const Reference
<XPropertySet
> & xPropSet
)
3189 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3192 switch (GetInt16Property(sPropertyFieldSubType
, xPropSet
))
3194 case UserDataPart::COMPANY
:
3195 eName
= XML_SENDER_COMPANY
;
3197 case UserDataPart::FIRSTNAME
:
3198 eName
= XML_SENDER_FIRSTNAME
;
3200 case UserDataPart::NAME
:
3201 eName
= XML_SENDER_LASTNAME
;
3203 case UserDataPart::SHORTCUT
:
3204 eName
= XML_SENDER_INITIALS
;
3206 case UserDataPart::STREET
:
3207 eName
= XML_SENDER_STREET
;
3209 case UserDataPart::COUNTRY
:
3210 eName
= XML_SENDER_COUNTRY
;
3212 case UserDataPart::ZIP
:
3213 eName
= XML_SENDER_POSTAL_CODE
;
3215 case UserDataPart::CITY
:
3216 eName
= XML_SENDER_CITY
;
3218 case UserDataPart::TITLE
:
3219 eName
= XML_SENDER_TITLE
;
3221 case UserDataPart::POSITION
:
3222 eName
= XML_SENDER_POSITION
;
3224 case UserDataPart::PHONE_PRIVATE
:
3225 eName
= XML_SENDER_PHONE_PRIVATE
;
3227 case UserDataPart::PHONE_COMPANY
:
3228 eName
= XML_SENDER_PHONE_WORK
;
3230 case UserDataPart::FAX
:
3231 eName
= XML_SENDER_FAX
;
3233 case UserDataPart::EMAIL
:
3234 eName
= XML_SENDER_EMAIL
;
3236 case UserDataPart::STATE
:
3237 eName
= XML_SENDER_STATE_OR_PROVINCE
;
3240 DBG_WARNING("unknown sender type");
3241 eName
= XML_TOKEN_INVALID
;
3248 enum XMLTokenEnum
XMLTextFieldExport::MapDocInfoFieldName(
3249 enum FieldIdEnum nToken
)
3251 enum XMLTokenEnum eElement
= XML_TOKEN_INVALID
;
3255 case FIELD_ID_DOCINFO_CREATION_AUTHOR
:
3256 eElement
= XML_INITIAL_CREATOR
;
3258 case FIELD_ID_DOCINFO_CREATION_DATE
:
3259 eElement
= XML_CREATION_DATE
;
3261 case FIELD_ID_DOCINFO_CREATION_TIME
:
3262 eElement
= XML_CREATION_TIME
;
3264 case FIELD_ID_DOCINFO_DESCRIPTION
:
3265 eElement
= XML_DESCRIPTION
;
3267 case FIELD_ID_DOCINFO_PRINT_TIME
:
3268 eElement
= XML_PRINT_TIME
;
3270 case FIELD_ID_DOCINFO_PRINT_DATE
:
3271 eElement
= XML_PRINT_DATE
;
3273 case FIELD_ID_DOCINFO_PRINT_AUTHOR
:
3274 eElement
= XML_PRINTED_BY
;
3276 case FIELD_ID_DOCINFO_TITLE
:
3277 eElement
= XML_TITLE
;
3279 case FIELD_ID_DOCINFO_SUBJECT
:
3280 eElement
= XML_SUBJECT
;
3282 case FIELD_ID_DOCINFO_KEYWORDS
:
3283 eElement
= XML_KEYWORDS
;
3285 case FIELD_ID_DOCINFO_REVISION
:
3286 eElement
= XML_EDITING_CYCLES
;
3288 case FIELD_ID_DOCINFO_EDIT_DURATION
:
3289 eElement
= XML_EDITING_DURATION
;
3291 case FIELD_ID_DOCINFO_SAVE_TIME
:
3292 eElement
= XML_MODIFICATION_TIME
;
3294 case FIELD_ID_DOCINFO_SAVE_DATE
:
3295 eElement
= XML_MODIFICATION_DATE
;
3297 case FIELD_ID_DOCINFO_SAVE_AUTHOR
:
3298 eElement
= XML_CREATOR
;
3301 DBG_WARNING("unknown docinfo field type!");
3302 eElement
= XML_TOKEN_INVALID
;
3309 enum XMLTokenEnum
XMLTextFieldExport::MapBibliographyFieldName(OUString sName
)
3311 enum XMLTokenEnum eName
= XML_TOKEN_INVALID
;
3313 if (sName
.equalsAsciiL("Identifier", sizeof("Identifier")-1))
3315 eName
= XML_IDENTIFIER
;
3317 else if (sName
.equalsAsciiL("BibiliographicType",
3318 sizeof("BibiliographicType")-1))
3320 eName
= XML_BIBLIOGRAPHY_TYPE
;
3322 else if (sName
.equalsAsciiL("Address", sizeof("Address")-1))
3324 eName
= XML_ADDRESS
;
3326 else if (sName
.equalsAsciiL("Annote", sizeof("Annote")-1))
3330 else if (sName
.equalsAsciiL("Author", sizeof("Author")-1))
3334 else if (sName
.equalsAsciiL("Booktitle", sizeof("Booktitle")-1))
3336 eName
= XML_BOOKTITLE
;
3338 else if (sName
.equalsAsciiL("Chapter", sizeof("Chapter")-1))
3340 eName
= XML_CHAPTER
;
3342 else if (sName
.equalsAsciiL("Edition", sizeof("Edition")-1))
3344 eName
= XML_EDITION
;
3346 else if (sName
.equalsAsciiL("Editor", sizeof("Editor")-1))
3350 else if (sName
.equalsAsciiL("Howpublished", sizeof("Howpublished")-1))
3352 eName
= XML_HOWPUBLISHED
;
3354 else if (sName
.equalsAsciiL("Institution", sizeof("Institution")-1))
3356 eName
= XML_INSTITUTION
;
3358 else if (sName
.equalsAsciiL("Journal", sizeof("Journal")-1))
3360 eName
= XML_JOURNAL
;
3362 else if (sName
.equalsAsciiL("Month", sizeof("Month")-1))
3366 else if (sName
.equalsAsciiL("Note", sizeof("Note")-1))
3370 else if (sName
.equalsAsciiL("Number", sizeof("Number")-1))
3374 else if (sName
.equalsAsciiL("Organizations", sizeof("Organizations")-1))
3376 eName
= XML_ORGANIZATIONS
;
3378 else if (sName
.equalsAsciiL("Pages", sizeof("Pages")-1))
3382 else if (sName
.equalsAsciiL("Publisher", sizeof("Publisher")-1))
3384 eName
= XML_PUBLISHER
;
3386 else if (sName
.equalsAsciiL("School", sizeof("School")-1))
3390 else if (sName
.equalsAsciiL("Series", sizeof("Series")-1))
3394 else if (sName
.equalsAsciiL("Title", sizeof("Title")-1))
3398 else if (sName
.equalsAsciiL("Report_Type", sizeof("Report_Type")-1))
3400 eName
= XML_REPORT_TYPE
;
3402 else if (sName
.equalsAsciiL("Volume", sizeof("Volume")-1))
3406 else if (sName
.equalsAsciiL("Year", sizeof("Year")-1))
3410 else if (sName
.equalsAsciiL("URL", sizeof("URL")-1))
3414 else if (sName
.equalsAsciiL("Custom1", sizeof("Custom1")-1))
3416 eName
= XML_CUSTOM1
;
3418 else if (sName
.equalsAsciiL("Custom2", sizeof("Custom2")-1))
3420 eName
= XML_CUSTOM2
;
3422 else if (sName
.equalsAsciiL("Custom3", sizeof("Custom3")-1))
3424 eName
= XML_CUSTOM3
;
3426 else if (sName
.equalsAsciiL("Custom4", sizeof("Custom4")-1))
3428 eName
= XML_CUSTOM4
;
3430 else if (sName
.equalsAsciiL("Custom5", sizeof("Custom5")-1))
3432 eName
= XML_CUSTOM5
;
3434 else if (sName
.equalsAsciiL("ISBN", sizeof("ISBN")-1))
3440 DBG_ERROR("Unknown bibliography info data");
3441 eName
= XML_TOKEN_INVALID
;
3447 enum XMLTokenEnum
XMLTextFieldExport::MapMeasureKind(sal_Int16 nKind
)
3459 OUString
XMLTextFieldExport::MakeFootnoteRefName(
3462 // generate foot-/endnote ID
3463 OUStringBuffer aBuf
;
3464 aBuf
.appendAscii("ftn");
3465 aBuf
.append((sal_Int32
)nSeqNo
);
3466 return aBuf
.makeStringAndClear();
3469 OUString
XMLTextFieldExport::MakeSequenceRefName(
3471 const OUString
& rSeqName
)
3473 // generate foot-/endnote ID
3474 OUStringBuffer aBuf
;
3475 aBuf
.appendAscii("ref");
3476 aBuf
.append(rSeqName
);
3477 aBuf
.append((sal_Int32
)nSeqNo
);
3478 return aBuf
.makeStringAndClear();
3482 // Property accessor helper functions
3485 // to be relegated (does that word exist?) to a more appropriate place
3489 inline sal_Bool
GetBoolProperty(
3490 const OUString
& sPropName
,
3491 const Reference
<XPropertySet
> & xPropSet
)
3493 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3494 sal_Bool bBool
= *(sal_Bool
*)aAny
.getValue();
3498 inline sal_Bool
GetOptionalBoolProperty(
3499 const OUString
& sPropName
,
3500 const Reference
<XPropertySet
> & xPropSet
,
3501 const Reference
<XPropertySetInfo
> & xPropSetInfo
,
3504 return xPropSetInfo
->hasPropertyByName( sPropName
)
3505 ? GetBoolProperty( sPropName
, xPropSet
) : bDefault
;
3508 inline double GetDoubleProperty(
3509 const OUString
& sPropName
,
3510 const Reference
<XPropertySet
> & xPropSet
)
3512 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3513 double fDouble
= 0.0;
3518 inline OUString
const GetStringProperty(
3519 const OUString
& sPropName
,
3520 const Reference
<XPropertySet
> & xPropSet
)
3522 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3528 inline sal_Int32
GetIntProperty(
3529 const OUString
& sPropName
,
3530 const Reference
<XPropertySet
> & xPropSet
)
3532 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3538 inline sal_Int16
GetInt16Property(
3539 const OUString
& sPropName
,
3540 const Reference
<XPropertySet
> & xPropSet
)
3542 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3548 inline sal_Int8
GetInt8Property(
3549 const OUString
& sPropName
,
3550 const Reference
<XPropertySet
> & xPropSet
)
3552 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3558 inline DateTime
const GetDateTimeProperty(
3559 const OUString
& sPropName
,
3560 const Reference
<XPropertySet
> & xPropSet
)
3562 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3568 inline Date
const GetDateProperty(
3569 const OUString
& sPropName
,
3570 const Reference
<XPropertySet
> & xPropSet
)
3572 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3578 inline Sequence
<OUString
> const GetStringSequenceProperty(
3579 const OUString
& sPropName
,
3580 const Reference
<XPropertySet
> & xPropSet
)
3582 Any aAny
= xPropSet
->getPropertyValue(sPropName
);
3583 Sequence
<OUString
> aSequence
;