Don't use ImplDoTiledRendering for Android.
[LibreOffice.git] / xmloff / inc / txtflde.hxx
blob50614776caa626765cd60a27a927e6f18afe9318
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 /** @#file
21 * XML export of all text fields
24 #ifndef INCLUDED_XMLOFF_INC_TXTFLDE_HXX
25 #define INCLUDED_XMLOFF_INC_TXTFLDE_HXX
27 #include <com/sun/star/uno/Reference.h>
28 #include <xmloff/xmlnmspe.hxx>
30 #include <rtl/ustring.hxx>
31 #include <xmloff/xmltoken.hxx>
33 #include <map>
34 #include <set>
37 class SvXMLExport;
38 struct XMLPropertyState;
40 namespace com { namespace sun { namespace star {
41 namespace util { struct DateTime; }
42 namespace util { struct Date; }
43 namespace text { class XTextField; }
44 namespace text { class XText; }
45 namespace beans { class XPropertySet; }
46 namespace beans { class XPropertySetInfo; }
47 namespace frame { class XModel; }
48 namespace uno { template<typename A> class Sequence; }
49 } } }
52 /// field IDs,
53 // including translation between UNO speak and XML speak if appropriate
55 enum FieldIdEnum {
56 FIELD_ID_SENDER, // sender == extended user
57 FIELD_ID_AUTHOR,
58 FIELD_ID_DATE, // current date
59 FIELD_ID_TIME, // current time (+date)
60 FIELD_ID_PAGENUMBER, // page number
61 FIELD_ID_PAGESTRING, // page contination string (page number string)
62 FIELD_ID_REFPAGE_SET, // set reference page
63 FIELD_ID_REFPAGE_GET, // get reference page number
65 FIELD_ID_PLACEHOLDER, // placeholder field == jump edit field
67 FIELD_ID_VARIABLE_DECL, // field type for set variable
68 FIELD_ID_VARIABLE_GET, // get variable == get expression
69 FIELD_ID_VARIABLE_SET, // set variable == set expression
70 FIELD_ID_VARIABLE_INPUT, // input field (variable)
71 FIELD_ID_USER_DECL, // field type for user field
72 FIELD_ID_USER_GET, // user field
73 FIELD_ID_USER_INPUT, // input field (user field)
74 FIELD_ID_TEXT_INPUT, // input field (text)
75 FIELD_ID_EXPRESSION, // expression field = formula field
76 FIELD_ID_SEQUENCE_DECL, // field type for sequence
77 FIELD_ID_SEQUENCE, // sequence field
79 FIELD_ID_DATABASE_NEXT, // select next row
80 FIELD_ID_DATABASE_SELECT, // select row # (NumSet)
81 FIELD_ID_DATABASE_DISPLAY, // display data (form letter field)
82 FIELD_ID_DATABASE_NAME, // display current db name (database name)
83 FIELD_ID_DATABASE_NUMBER, // display row # (SetNumber)
85 FIELD_ID_DOCINFO_CREATION_AUTHOR, // docinfo fields
86 FIELD_ID_DOCINFO_CREATION_TIME,
87 FIELD_ID_DOCINFO_CREATION_DATE,
88 FIELD_ID_DOCINFO_DESCRIPTION,
89 FIELD_ID_DOCINFO_CUSTOM,
90 FIELD_ID_DOCINFO_PRINT_TIME,
91 FIELD_ID_DOCINFO_PRINT_DATE,
92 FIELD_ID_DOCINFO_PRINT_AUTHOR,
93 FIELD_ID_DOCINFO_TITLE,
94 FIELD_ID_DOCINFO_SUBJECT,
95 FIELD_ID_DOCINFO_KEYWORDS,
96 FIELD_ID_DOCINFO_REVISION,
97 FIELD_ID_DOCINFO_EDIT_DURATION,
98 FIELD_ID_DOCINFO_SAVE_TIME,
99 FIELD_ID_DOCINFO_SAVE_DATE,
100 FIELD_ID_DOCINFO_SAVE_AUTHOR,
102 FIELD_ID_CONDITIONAL_TEXT, // conditionally choose between 2 texts
103 FIELD_ID_HIDDEN_TEXT, // conditionally hide a text
104 FIELD_ID_HIDDEN_PARAGRAPH, // conditionally hide a paragraph
106 FIELD_ID_TEMPLATE_NAME, // display name of template
107 FIELD_ID_CHAPTER, // display name/number of current chapter
108 FIELD_ID_FILE_NAME, // display name of current file
110 FIELD_ID_COUNT_PARAGRAPHS, // statistics fields: - paragraphs
111 FIELD_ID_COUNT_WORDS, // - words
112 FIELD_ID_COUNT_CHARACTERS, // - chars
113 FIELD_ID_COUNT_PAGES, // - pages
114 FIELD_ID_COUNT_TABLES, // - tables
115 FIELD_ID_COUNT_GRAPHICS, // - graphics
116 FIELD_ID_COUNT_OBJECTS, // - objects
118 FIELD_ID_MACRO, // macro fields
119 FIELD_ID_REF_REFERENCE, // get reference field (reference)
120 FIELD_ID_REF_SEQUENCE, // get reference field (sequence)
121 FIELD_ID_REF_BOOKMARK, // get reference field (bookmark)
122 FIELD_ID_REF_FOOTNOTE, // get reference field (footnote)
123 FIELD_ID_REF_ENDNOTE, // get reference field (endnote)
124 FIELD_ID_DDE, // DDE field
126 FIELD_ID_BIBLIOGRAPHY, // bibliography index entry
128 FIELD_ID_SHEET_NAME, // name of current (spread-)sheet
129 FIELD_ID_URL, // URL field (only Calc, Draw, Impress)
131 FIELD_ID_SCRIPT, // script fields (for HTML pages, mostly)
132 FIELD_ID_ANNOTATION, // annotation (notice) field
134 FIELD_ID_COMBINED_CHARACTERS, // combined characters (asian typography)
136 FIELD_ID_META, // text:meta-field (RDF metadata)
138 FIELD_ID_MEASURE, // for measure shapes
140 FIELD_ID_TABLE_FORMULA, // DEPRECATED: table formulas (Writer 2.0)
141 FIELD_ID_DROP_DOWN, // DEPRECATED: dropdown fields (WW8)
143 FIELD_ID_DRAW_HEADER,
144 FIELD_ID_DRAW_FOOTER,
145 FIELD_ID_DRAW_DATE_TIME,
147 FIELD_ID_UNKNOWN // invalid or unknown field type!
152 class XMLTextFieldExport
154 SvXMLExport& rExport;
156 /// store used text field master names (NULL means: don't collect)
157 ::std::map<
158 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >,
159 ::std::set< OUString > > *
160 pUsedMasters;
162 public:
164 XMLTextFieldExport( SvXMLExport& rExp,
165 /// XMLPropertyState for the combined characters field
166 XMLPropertyState* pCombinedCharState = NULL );
167 virtual ~XMLTextFieldExport();
169 /// Export this field and the surrounding span element with the formatting.
170 /// To be called for every field in the document body.
171 void ExportField(const ::com::sun::star::uno::Reference <
172 ::com::sun::star::text::XTextField > & rTextField,
173 bool bProgress );
175 /// collect styles (character styles, data styles, ...) for this field
176 /// (if appropriate).
177 /// Also collect used field masters (if pUsedMasters is set)
178 /// to be called for every field during style export.
179 void ExportFieldAutoStyle(const ::com::sun::star::uno::Reference <
180 ::com::sun::star::text::XTextField > & rTextField,
181 const bool bProgress, const bool bRecursive );
183 /// export field declarations.
184 /// to be called once at beginning of document body.
185 void ExportFieldDeclarations();
187 /// export field declarations for fields used in the particular XText.
188 /// (Requires that a list of used field declarations has previously been
189 /// built-up in ExportFieldAutoStyle() )
190 void ExportFieldDeclarations(
191 const ::com::sun::star::uno::Reference <
192 ::com::sun::star::text::XText > & rText);
194 /// export all field declarations, or only those that have been used?
195 /// Calling this method will reset the list of used field declataions.
196 void SetExportOnlyUsedFieldDeclarations(
197 bool bExportOnlyUsed = true);
199 // determine element or attribute names
200 // (public, because they may be useful in related XML export classes)
201 static enum ::xmloff::token::XMLTokenEnum MapPlaceholderType(sal_uInt16 nType);
202 static enum ::xmloff::token::XMLTokenEnum MapTemplateDisplayFormat(sal_Int16 nType);
203 static enum ::xmloff::token::XMLTokenEnum MapChapterDisplayFormat(sal_Int16 nType);
204 static enum ::xmloff::token::XMLTokenEnum MapFilenameDisplayFormat(sal_Int16 nType);
205 static enum ::xmloff::token::XMLTokenEnum MapDocInfoFieldName(enum FieldIdEnum nToken);
206 static enum ::xmloff::token::XMLTokenEnum MapReferenceSource(sal_Int16 nType);
207 static enum ::xmloff::token::XMLTokenEnum MapReferenceType(sal_Int16 nType);
208 static enum ::xmloff::token::XMLTokenEnum MapCountFieldName(FieldIdEnum nToken);
209 static enum ::xmloff::token::XMLTokenEnum MapBibliographyFieldName(const OUString& sName);
210 static enum ::xmloff::token::XMLTokenEnum MapMeasureKind(sal_Int16 nKind);
211 enum ::xmloff::token::XMLTokenEnum MapPageNumberName(const ::com::sun::star::uno::Reference<
212 ::com::sun::star::beans::XPropertySet> & xPropSet,
213 sal_Int32& nOffset); /// also adjust page offset
214 enum ::xmloff::token::XMLTokenEnum MapAuthorFieldName(const ::com::sun::star::uno::Reference <
215 ::com::sun::star::beans::XPropertySet > & xPropSet);
216 enum ::xmloff::token::XMLTokenEnum MapSenderFieldName(const ::com::sun::star::uno::Reference <
217 ::com::sun::star::beans::XPropertySet > & xPropSet);
219 protected:
221 SvXMLExport& GetExport() { return rExport; }
223 /// export a field after <text:span> is already written
224 void ExportFieldHelper(
225 const ::com::sun::star::uno::Reference<
226 ::com::sun::star::text::XTextField> & rTextField,
227 const ::com::sun::star::uno::Reference<
228 ::com::sun::star::beans::XPropertySet> & rPropSet,
229 const ::com::sun::star::uno::Reference<
230 ::com::sun::star::beans::XPropertySet> & rRangePropSet,
231 enum FieldIdEnum nToken,
232 bool bProgress );
234 /// export an empty element
235 void ExportElement(enum ::xmloff::token::XMLTokenEnum eElement, /// element token
236 bool bAddSpace = false); /// add blanks around
237 /// element?
239 /// export an element with string content
240 void ExportElement(enum ::xmloff::token::XMLTokenEnum eElement, /// element token
241 const OUString& sContent, /// element content
242 bool bAddSpace = false); /// add blanks around
243 /// element?
245 /// export a macro (as used in the macro field)
246 void ExportMacro( const ::com::sun::star::uno::Reference<
247 ::com::sun::star::beans::XPropertySet> & rPropSet,
248 const OUString& rContent);
250 /// export text:meta-field (RDF metadata)
251 void ExportMetaField( const ::com::sun::star::uno::Reference<
252 ::com::sun::star::beans::XPropertySet> & i_xMeta,
253 bool i_bAutoStyles, bool i_bProgress );
255 /// export a boolean attribute
256 void ProcessBoolean(
257 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
258 bool bBool, /// attribute value
259 bool bDefault); /// attribute default; omit, if attribute differs
261 /// export an integer attribute
262 void ProcessInteger(
263 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
264 sal_Int32 nNum); /// attribute value
266 /// export an integer attribute, omit if default
267 void ProcessIntegerDef(
268 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
269 sal_Int32 nNum, /// attribute value
270 sal_Int32 nDefault); /// default value
272 /// export a string attribute
273 void ProcessString(
274 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
275 const OUString& sValue, /// attribute value
276 bool bOmitEmpty = false, /// omit attribute, if value is empty
277 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
279 /// export a string attribute that gets a QName value
280 void ProcessString(
281 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
282 sal_uInt16 nValuePrefix,
283 const OUString& sValue, /// attribute value
284 bool bOmitEmpty = false, /// omit attribute, if value is empty
285 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
288 /// export a string attribute, omit if default
289 void ProcessString(
290 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
291 const OUString& sValue, /// attribute value
292 const OUString& sDefault, /// default value; omit if equal
293 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
295 /// export a string attribute, omit if default
296 void ProcessString(
297 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
298 sal_uInt16 nValuePrefix,
299 const OUString& sValue, /// attribute value
300 const OUString& sDefault, /// default value; omit if equal
301 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
303 /// export a string attribute
304 void ProcessString(
305 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
306 enum ::xmloff::token::XMLTokenEnum eValue, /// attribute token
307 bool bOmitEmpty = false, /// omit attribute, if value is empty
308 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
310 /// export a string attribute, omit if default
311 void ProcessString(
312 enum ::xmloff::token::XMLTokenEnum eXmlName, /// attribute token (namespace text)
313 enum ::xmloff::token::XMLTokenEnum eValue, /// attribute value token
314 enum ::xmloff::token::XMLTokenEnum eDefault, /// default value token
315 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
317 /// export a string as a sequence of paragraphs
318 void ProcessParagraphSequence(
319 /// string containing the paragraphs
320 const OUString& sParagraphSequence);
322 /// export a numbering format (numeric, roman, alphabetic, etc.)
323 void ProcessNumberingType(
324 sal_Int16 nNumberingType); /// numbering type key
326 /// export display attribute (value, formula, none)
327 void ProcessDisplay(bool bIsVisible, /// is visible?
328 bool bIsCommand, /// is show command/show name?
329 bool bDefault = true); /// omit, if default
331 /// export all data-style related attributes
332 void ProcessValueAndType(
333 bool bIsString, /// do we process a string or a number?
334 sal_Int32 nFormatKey, /// format key for NumberFormatter; possibly -1
335 const OUString& sContent, /// string content; possibly invalid
336 const OUString& sDefault, /// default string
337 double fValue, /// float content; possibly invalid
338 bool bExportValue, /// export value attribute?
339 bool bExportValueType, /// export value-type attribute?
340 bool bExportStyle, /// export style-sttribute?
341 bool bForceSystemLanguage, /// no style language export
342 bool bTimeStyle = false); /// exporting a time style?
344 /// export times, dates and durations according to ISO 8601
345 void ProcessDateTime(
346 enum ::xmloff::token::XMLTokenEnum eXMLName, /// attribute token
347 double dValue, /// date/time value
348 bool bIsDate, /// export as date (rather than date/time)?
349 bool bIsDuration = false, /// export as duration
350 bool bOmitDurationIfZero = true, /// omit zero-length durat.
351 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
353 /// export a date, time, or duration
354 void ProcessDateTime(
355 enum ::xmloff::token::XMLTokenEnum eXMLName, /// attribute token
356 sal_Int32 nMinutes, /// date/time value in minutes
357 bool bIsDate, /// export as date?
358 bool bIsDuration, /// export as duration?
359 bool bOmitDurationIfZero, /// omit zero-length durations
360 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
362 /// export times, dates and durations according to ISO 8601
363 void ProcessDateTime(
364 enum ::xmloff::token::XMLTokenEnum eXMLName, /// attribute token
365 const ::com::sun::star::util::DateTime& rTime, /// date/time value
366 bool bIsDate, /// export as date (rather than date/time)?
367 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
369 /// export time or dateTime
370 void ProcessTimeOrDateTime(
371 enum ::xmloff::token::XMLTokenEnum eXMLName, /// attribute token
372 const ::com::sun::star::util::DateTime& rTime, /// date/time value
373 sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix
375 /// export all attributes for bibliography data fields
376 void ProcessBibliographyData(
377 const ::com::sun::star::uno::Reference <
378 ::com::sun::star::beans::XPropertySet > & rPropertySet);
380 /// export CommandTypeAttribute
381 void ProcessCommandType(
382 sal_Int32 nCommandType); /// com::sun::star::sdb::CommandType
384 void ProcessStringSequence(
385 const ::com::sun::star::uno::Sequence<OUString>& rSequence,
386 const OUString& sSelected );
388 void ProcessStringSequence(
389 const ::com::sun::star::uno::Sequence<OUString>& rSequence,
390 sal_Int32 nSelected );
392 /// export attributes that describe a data source
393 void ExportDataBaseElement(
394 enum ::xmloff::token::XMLTokenEnum eElement,
395 const OUString& sContent,
396 const ::com::sun::star::uno::Reference <
397 ::com::sun::star::beans::XPropertySet > & rPropertySet,
398 const ::com::sun::star::uno::Reference <
399 ::com::sun::star::beans::XPropertySetInfo > & rPropertySetInfo );
401 /// for XDependentTextFields, get PropertySet of FieldMaster
402 ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >
403 GetMasterPropertySet(const ::com::sun::star::uno::Reference <
404 ::com::sun::star::text::XTextField > & rTextField);
406 /// get PropertySet of (any) DependentTextField for this FieldMaster
407 bool GetDependentFieldPropertySet(
408 const ::com::sun::star::uno::Reference<
409 ::com::sun::star::beans::XPropertySet> & xmaster,
410 ::com::sun::star::uno::Reference<
411 ::com::sun::star::beans::XPropertySet> & xField);
414 /// get field ID from XTextField (and it's Property-Set)
415 enum FieldIdEnum GetFieldID(const ::com::sun::star::uno::Reference <
416 ::com::sun::star::text::XTextField > & rTextField,
417 const ::com::sun::star::uno::Reference <
418 ::com::sun::star::beans::XPropertySet > & xPropSet);
420 /// get field ID from XTextField service name (and it's PropertySet)
421 enum FieldIdEnum MapFieldName(const OUString& sFieldName,
422 const ::com::sun::star::uno::Reference <
423 ::com::sun::star::beans::XPropertySet> & xPropSet);
425 /// determine, whether field has string or numeric content
426 bool IsStringField(FieldIdEnum nFieldType, /// field ID
427 const ::com::sun::star::uno::Reference <
428 ::com::sun::star::beans::XPropertySet > & xPropSet);
431 /// explode a field master name into field type and field name
432 bool ExplodeFieldMasterName(
433 const OUString& sMasterName, /// name as returned by SO API
434 OUString& sFieldType, /// out: field type
435 OUString& sVarName); /// out: variable name
437 /// make reference name for a foot- or endnote
438 static OUString MakeFootnoteRefName(sal_Int16 nSeqNo);
440 /// make reference name for a sequence field
441 static OUString MakeSequenceRefName(sal_Int16 nSeqNo,
442 const OUString& rSeqName);
444 private:
445 // constants
447 // service names
448 const OUString sServicePrefix;
449 const OUString sFieldMasterPrefix;
450 const OUString sPresentationServicePrefix;
452 // property names
453 const OUString sPropertyAdjust;
454 const OUString sPropertyAuthor;
455 const OUString sPropertyChapterFormat;
456 const OUString sPropertyChapterNumberingLevel;
457 const OUString sPropertyCharStyleNames;
458 const OUString sPropertyCondition;
459 const OUString sPropertyContent;
460 const OUString sPropertyDataBaseName;
461 const OUString sPropertyDataBaseURL;
462 const OUString sPropertyDataColumnName;
463 const OUString sPropertyDataCommandType;
464 const OUString sPropertyDataTableName;
465 const OUString sPropertyDateTime;
466 const OUString sPropertyDateTimeValue;
467 const OUString sPropertyDDECommandElement;
468 const OUString sPropertyDDECommandFile;
469 const OUString sPropertyDDECommandType;
470 const OUString sPropertyDependentTextFields;
471 const OUString sPropertyFalseContent;
472 const OUString sPropertyFields;
473 const OUString sPropertyFieldSubType;
474 const OUString sPropertyFileFormat;
475 const OUString sPropertyFullName;
476 const OUString sPropertyHint;
477 const OUString sPropertyInitials;
478 const OUString sPropertyInstanceName;
479 const OUString sPropertyIsAutomaticUpdate;
480 const OUString sPropertyIsConditionTrue;
481 const OUString sPropertyIsDataBaseFormat;
482 const OUString sPropertyIsDate;
483 const OUString sPropertyIsExpression;
484 const OUString sPropertyIsFixed;
485 const OUString sPropertyIsFixedLanguage;
486 const OUString sPropertyIsHidden;
487 const OUString sPropertyIsInput;
488 const OUString sPropertyIsShowFormula;
489 const OUString sPropertyIsVisible;
490 const OUString sPropertyItems;
491 const OUString sPropertyLevel;
492 const OUString sPropertyMeasureKind;
493 const OUString sPropertyName;
494 const OUString sPropertyNumberFormat;
495 const OUString sPropertyNumberingSeparator;
496 const OUString sPropertyNumberingType;
497 const OUString sPropertyOffset;
498 const OUString sPropertyOn;
499 const OUString sPropertyPlaceholderType;
500 const OUString sPropertyReferenceFieldPart;
501 const OUString sPropertyReferenceFieldSource;
502 const OUString sPropertyScriptType;
503 const OUString sPropertySelectedItem;
504 const OUString sPropertySequenceNumber;
505 const OUString sPropertySequenceValue;
506 const OUString sPropertySetNumber;
507 const OUString sPropertySourceName;
508 const OUString sPropertySubType;
509 const OUString sPropertyTargetFrame;
510 const OUString sPropertyTrueContent;
511 const OUString sPropertyURL;
512 const OUString sPropertyURLContent;
513 const OUString sPropertyUserText;
514 const OUString sPropertyValue;
515 const OUString sPropertyVariableName;
516 const OUString sPropertyHelp;
517 const OUString sPropertyTooltip;
518 const OUString sPropertyTextRange;
520 const OUString sEmpty;
522 XMLPropertyState* pCombinedCharactersPropertyState;
531 #endif
533 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */