LibreOffice Module xmloff (master)  1
txtflde.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
24 #pragma once
25 
26 #include <com/sun/star/uno/Reference.h>
27 #include <xmloff/xmlnamespace.hxx>
28 
29 #include <rtl/ustring.hxx>
30 #include <xmloff/xmltoken.hxx>
31 
32 #include <map>
33 #include <set>
34 #include <memory>
35 #include <string_view>
36 
37 class SvXMLExport;
38 struct XMLPropertyState;
39 
40 namespace com::sun::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 }
50 
51 
53 // including translation between UNO speak and XML speak if appropriate
54 
56  FIELD_ID_SENDER, // sender == extended user
58  FIELD_ID_DATE, // current date
59  FIELD_ID_TIME, // current time (+date)
60  FIELD_ID_PAGENAME, // page/slide name
61  FIELD_ID_PAGENUMBER, // page number
62  FIELD_ID_PAGESTRING, // page continuation string (page number string)
63  FIELD_ID_REFPAGE_SET, // set reference page
64  FIELD_ID_REFPAGE_GET, // get reference page number
65 
66  FIELD_ID_PLACEHOLDER, // placeholder field == jump edit field
67 
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_GET, // user field
72  FIELD_ID_USER_INPUT, // input field (user field)
73  FIELD_ID_TEXT_INPUT, // input field (text)
74  FIELD_ID_EXPRESSION, // expression field = formula field
75  FIELD_ID_SEQUENCE, // sequence field
76 
77  FIELD_ID_DATABASE_NEXT, // select next row
78  FIELD_ID_DATABASE_SELECT, // select row # (NumSet)
79  FIELD_ID_DATABASE_DISPLAY, // display data (form letter field)
80  FIELD_ID_DATABASE_NAME, // display current db name (database name)
81  FIELD_ID_DATABASE_NUMBER, // display row # (SetNumber)
82 
99 
100  FIELD_ID_CONDITIONAL_TEXT, // conditionally choose between 2 texts
101  FIELD_ID_HIDDEN_TEXT, // conditionally hide a text
102  FIELD_ID_HIDDEN_PARAGRAPH, // conditionally hide a paragraph
103 
104  FIELD_ID_TEMPLATE_NAME, // display name of template
105  FIELD_ID_CHAPTER, // display name/number of current chapter
106  FIELD_ID_FILE_NAME, // display name of current file
107 
108  FIELD_ID_COUNT_PARAGRAPHS, // statistics fields: - paragraphs
113  FIELD_ID_COUNT_GRAPHICS, // - graphics
115 
116  FIELD_ID_MACRO, // macro fields
117  FIELD_ID_REF_REFERENCE, // get reference field (reference)
118  FIELD_ID_REF_SEQUENCE, // get reference field (sequence)
119  FIELD_ID_REF_BOOKMARK, // get reference field (bookmark)
120  FIELD_ID_REF_FOOTNOTE, // get reference field (footnote)
121  FIELD_ID_REF_ENDNOTE, // get reference field (endnote)
122  FIELD_ID_DDE, // DDE field
123 
124  FIELD_ID_BIBLIOGRAPHY, // bibliography index entry
125 
126  FIELD_ID_SHEET_NAME, // name of current (spread-)sheet
127  FIELD_ID_URL, // URL field (only Calc, Draw, Impress)
128 
129  FIELD_ID_SCRIPT, // script fields (for HTML pages, mostly)
130  FIELD_ID_ANNOTATION, // annotation (notice) field
131 
132  FIELD_ID_COMBINED_CHARACTERS, // combined characters (asian typography)
133 
134  FIELD_ID_META, // text:meta-field (RDF metadata)
135 
136  FIELD_ID_MEASURE, // for measure shapes
137 
138  FIELD_ID_TABLE_FORMULA, // DEPRECATED: table formulas (Writer 2.0)
139  FIELD_ID_DROP_DOWN, // DEPRECATED: dropdown fields (WW8)
140 
144 
145  FIELD_ID_UNKNOWN // invalid or unknown field type!
146 };
147 
148 
150 {
152 
154  std::unique_ptr< ::std::map<
155  css::uno::Reference< css::text::XText >,
156  ::std::set< OUString > > >
158 
159 public:
160 
163  std::unique_ptr<XMLPropertyState> pCombinedCharState );
165 
168  void ExportField(const css::uno::Reference < css::text::XTextField > & rTextField,
169  bool bProgress, bool & rPrevCharIsSpace);
170 
175  void ExportFieldAutoStyle(const css::uno::Reference < css::text::XTextField > & rTextField,
176  const bool bProgress, const bool bRecursive );
177 
181 
186  const css::uno::Reference < css::text::XText > & rText);
187 
191  bool bExportOnlyUsed = true);
192 
193  // determine element or attribute names
194  // (public, because they may be useful in related XML export classes)
203  static enum ::xmloff::token::XMLTokenEnum MapBibliographyFieldName(std::u16string_view sName);
204  static enum ::xmloff::token::XMLTokenEnum MapMeasureKind(sal_Int16 nKind);
205  static enum ::xmloff::token::XMLTokenEnum MapPageNumberName(const css::uno::Reference< css::beans::XPropertySet> & xPropSet,
206  sal_Int32& nOffset);
207  static enum ::xmloff::token::XMLTokenEnum MapAuthorFieldName(const css::uno::Reference< css::beans::XPropertySet > & xPropSet);
208  static enum ::xmloff::token::XMLTokenEnum MapSenderFieldName(const css::uno::Reference< css::beans::XPropertySet > & xPropSet);
209 
210 private:
211 
213 
215  void ExportFieldHelper(
216  const css::uno::Reference< css::text::XTextField> & rTextField,
217  const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
218  const css::uno::Reference< css::beans::XPropertySet> & rRangePropSet,
219  enum FieldIdEnum nToken,
220  bool bProgress,
221  bool & rPrevCharIsSpace);
222 
225  bool bAddSpace = false);
226 
230  const OUString& sContent);
231 
233  void ExportMacro( const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
234  const OUString& rContent);
235 
237  void ExportMetaField( const css::uno::Reference< css::beans::XPropertySet> & i_xMeta,
238  bool i_bAutoStyles, bool i_bProgress,
239  bool & rPrevCharIsSpace);
240 
242  void ProcessBoolean(
244  bool bBool,
245  bool bDefault);
246 
248  void ProcessInteger(
250  sal_Int32 nNum);
251 
253  void ProcessIntegerDef(
255  sal_Int32 nNum,
256  sal_Int32 nDefault);
257 
259  void ProcessString(
261  const OUString& sValue,
262  bool bOmitEmpty = false,
263  sal_uInt16 nPrefix = XML_NAMESPACE_TEXT);
264 
266  void ProcessString(
268  sal_uInt16 nValuePrefix,
269  const OUString& sValue);
270 
271 
273  void ProcessString(
275  const OUString& sValue,
276  std::u16string_view sDefault);
277 
279  void ProcessString(
281  sal_uInt16 nValuePrefix,
282  const OUString& sValue,
283  std::u16string_view sDefault);
284 
286  void ProcessString(
289  sal_uInt16 nPrefix = XML_NAMESPACE_TEXT);
290 
292  void ProcessString(
296 
300  std::u16string_view sParagraphSequence);
301 
304  sal_Int16 nNumberingType);
305 
307  void ProcessDisplay(bool bIsVisible,
308  bool bIsCommand);
309 
311  void ProcessValueAndType(
312  bool bIsString,
313  sal_Int32 nFormatKey,
314  const OUString& sContent,
315  std::u16string_view sDefault,
316  double fValue,
317  bool bExportValue,
318  bool bExportValueType,
319  bool bExportStyle,
320  bool bForceSystemLanguage,
321  bool bTimeStyle = false);
322 
324  void ProcessDateTime(
326  double dValue,
327  bool bIsDate,
328  bool bIsDuration,
329  bool bOmitDurationIfZero = true,
330  sal_uInt16 nPrefix = XML_NAMESPACE_TEXT);
331 
333  void ProcessDateTime(
335  sal_Int32 nMinutes,
336  bool bIsDate,
337  bool bIsDuration);
338 
340  void ProcessDateTime(
342  const css::util::DateTime& rTime);
343 
347  const css::util::DateTime& rTime);
348 
351  const css::uno::Reference <
352  css::beans::XPropertySet > & rPropertySet);
353 
355  void ProcessCommandType(
356  sal_Int32 nCommandType);
357 
359  const css::uno::Sequence<OUString>& rSequence,
360  const OUString& sSelected );
361 
363  const css::uno::Sequence<OUString>& rSequence,
364  sal_Int32 nSelected );
365 
369  const OUString& sContent,
370  const css::uno::Reference < css::beans::XPropertySet > & rPropertySet,
371  const css::uno::Reference < css::beans::XPropertySetInfo > & rPropertySetInfo );
372 
374  static css::uno::Reference < css::beans::XPropertySet >
375  GetMasterPropertySet(const css::uno::Reference < css::text::XTextField > & rTextField);
376 
378  static bool GetDependentFieldPropertySet(
379  const css::uno::Reference< css::beans::XPropertySet> & xmaster,
380  css::uno::Reference< css::beans::XPropertySet> & xField);
381 
382 
384  static enum FieldIdEnum GetFieldID(const css::uno::Reference < css::text::XTextField > & rTextField,
385  const css::uno::Reference < css::beans::XPropertySet > & xPropSet);
386 
388  static enum FieldIdEnum MapFieldName(std::u16string_view sFieldName,
389  const css::uno::Reference < css::beans::XPropertySet> & xPropSet);
390 
392  static bool IsStringField(FieldIdEnum nFieldType,
393  const css::uno::Reference < css::beans::XPropertySet > & xPropSet);
394 
395 
397  static void ExplodeFieldMasterName(
398  const OUString& sMasterName,
399  OUString& sFieldType,
400  OUString& sVarName);
401 
403  static OUString MakeFootnoteRefName(sal_Int16 nSeqNo);
404 
406  static OUString MakeSequenceRefName(sal_Int16 nSeqNo,
407  std::u16string_view rSeqName);
408 
409  std::unique_ptr<XMLPropertyState> pCombinedCharactersPropertyState;
410 
411 };
412 
413 
414 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
SvXMLExport & rExport
Definition: txtflde.hxx:151
static bool IsStringField(FieldIdEnum nFieldType, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
determine, whether field has string or numeric content
Definition: txtflde.cxx:632
void ProcessStringSequence(const css::uno::Sequence< OUString > &rSequence, const OUString &sSelected)
css::sdb::CommandType
static enum::xmloff::token::XMLTokenEnum MapFilenameDisplayFormat(sal_Int16 nType)
map FilenameDisplayFormat to XML attribute names
Definition: txtflde.cxx:3083
void ExportElement(enum::xmloff::token::XMLTokenEnum eElement, bool bAddSpace=false)
export an empty element
void ExportMetaField(const css::uno::Reference< css::beans::XPropertySet > &i_xMeta, bool i_bAutoStyles, bool i_bProgress, bool &rPrevCharIsSpace)
export text:meta-field (RDF metadata)
Definition: txtflde.cxx:2318
void ExportFieldAutoStyle(const css::uno::Reference< css::text::XTextField > &rTextField, const bool bProgress, const bool bRecursive)
collect styles (character styles, data styles, ...) for this field (if appropriate).
Definition: txtflde.cxx:749
static OUString MakeSequenceRefName(sal_Int16 nSeqNo, std::u16string_view rSeqName)
make reference name for a sequence field
Definition: txtflde.cxx:3474
void ProcessInteger(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum)
attribute default; omit, if attribute differs
Definition: txtflde.cxx:2557
static enum::xmloff::token::XMLTokenEnum MapCountFieldName(FieldIdEnum nToken)
map count/statistics field token to XML name
Definition: txtflde.cxx:3014
static enum::xmloff::token::XMLTokenEnum MapReferenceType(sal_Int16 nType)
map ReferenceFieldPart to XML string
Definition: txtflde.cxx:3110
void ExportFieldDeclarations()
export field declarations.
Definition: txtflde.cxx:1923
std::unique_ptr< ::std::map< css::uno::Reference< css::text::XText >,::std::set< OUString > > > pUsedMasters
store used text field master names (NULL means: don't collect)
Definition: txtflde.hxx:157
void ExportField(const css::uno::Reference< css::text::XTextField > &rTextField, bool bProgress, bool &rPrevCharIsSpace)
Export this field and the surrounding span element with the formatting.
Definition: txtflde.cxx:972
void ProcessParagraphSequence(std::u16string_view sParagraphSequence)
default value token
Definition: txtflde.cxx:2541
void ProcessDisplay(bool bIsVisible, bool bIsCommand)
numbering type key
Definition: txtflde.cxx:2425
SvXMLExport & GetExport()
Definition: txtflde.hxx:212
static enum FieldIdEnum GetFieldID(const css::uno::Reference< css::text::XTextField > &rTextField, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
get field ID from XTextField (and it's Property-Set)
Definition: txtflde.cxx:385
static enum::xmloff::token::XMLTokenEnum MapChapterDisplayFormat(sal_Int16 nType)
map ChapterDisplayFormat to XML string
Definition: txtflde.cxx:3051
XMLTextFieldExport(SvXMLExport &rExp, std::unique_ptr< XMLPropertyState > pCombinedCharState)
Definition: txtflde.cxx:372
exports com.sun.star. frame
void ProcessString(enum::xmloff::token::XMLTokenEnum eXmlName, const OUString &sValue, bool bOmitEmpty=false, sal_uInt16 nPrefix=XML_NAMESPACE_TEXT)
default value
void ProcessTimeOrDateTime(enum::xmloff::token::XMLTokenEnum eXMLName, const css::util::DateTime &rTime)
date/time value
Definition: txtflde.cxx:2665
exports com.sun.star. text
static enum::xmloff::token::XMLTokenEnum MapMeasureKind(sal_Int16 nKind)
Definition: txtflde.cxx:3455
void ProcessValueAndType(bool bIsString, sal_Int32 nFormatKey, const OUString &sContent, std::u16string_view sDefault, double fValue, bool bExportValue, bool bExportValueType, bool bExportStyle, bool bForceSystemLanguage, bool bTimeStyle=false)
is show command/show name?
Definition: txtflde.cxx:2360
void ProcessBoolean(enum::xmloff::token::XMLTokenEnum eXmlName, bool bBool, bool bDefault)
export a boolean attribute
Definition: txtflde.cxx:2448
void ExportDataBaseElement(enum::xmloff::token::XMLTokenEnum eElement, const OUString &sContent, const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, const css::uno::Reference< css::beans::XPropertySetInfo > &rPropertySetInfo)
export attributes that describe a data source
Definition: txtflde.cxx:2800
class SAL_NO_VTABLE XPropertySet
constexpr sal_uInt16 XML_NAMESPACE_TEXT
void ProcessDateTime(enum::xmloff::token::XMLTokenEnum eXMLName, double dValue, bool bIsDate, bool bIsDuration, bool bOmitDurationIfZero=true, sal_uInt16 nPrefix=XML_NAMESPACE_TEXT)
exporting a time style?
static enum::xmloff::token::XMLTokenEnum MapReferenceSource(sal_Int16 nType)
map ReferenceFieldPart to XML string
Definition: txtflde.cxx:3162
static OUString MakeFootnoteRefName(sal_Int16 nSeqNo)
out: variable name
Definition: txtflde.cxx:3467
static void ExplodeFieldMasterName(const OUString &sMasterName, OUString &sFieldType, OUString &sVarName)
explode a field master name into field type and field name
Definition: txtflde.cxx:2849
void ProcessCommandType(sal_Int32 nCommandType)
export CommandTypeAttribute
Definition: txtflde.cxx:2756
void ExportFieldHelper(const css::uno::Reference< css::text::XTextField > &rTextField, const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const css::uno::Reference< css::beans::XPropertySet > &rRangePropSet, enum FieldIdEnum nToken, bool bProgress, bool &rPrevCharIsSpace)
export a field after is already written
Definition: txtflde.cxx:1057
static enum::xmloff::token::XMLTokenEnum MapSenderFieldName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
element name for sender fields
Definition: txtflde.cxx:3191
void SetExportOnlyUsedFieldDeclarations(bool bExportOnlyUsed=true)
export all field declarations, or only those that have been used? Calling this method will reset the ...
Definition: txtflde.cxx:2223
static css::uno::Reference< css::beans::XPropertySet > GetMasterPropertySet(const css::uno::Reference< css::text::XTextField > &rTextField)
for XDependentTextFields, get PropertySet of FieldMaster
Definition: txtflde.cxx:2868
exports com.sun.star. beans
static enum::xmloff::token::XMLTokenEnum MapTemplateDisplayFormat(sal_Int16 nType)
map TemplateDisplayFormat to XML
Definition: txtflde.cxx:2980
void ProcessBibliographyData(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet)
date/time value
Definition: txtflde.cxx:2706
static bool GetDependentFieldPropertySet(const css::uno::Reference< css::beans::XPropertySet > &xmaster, css::uno::Reference< css::beans::XPropertySet > &xField)
get PropertySet of (any) DependentTextField for this FieldMaster
Definition: txtflde.cxx:2877
std::unique_ptr< XMLPropertyState > pCombinedCharactersPropertyState
Definition: txtflde.hxx:409
FieldIdEnum
field IDs,
Definition: txtflde.hxx:55
void ProcessNumberingType(sal_Int16 nNumberingType)
export a numbering format (numeric, roman, alphabetic, etc.)
Definition: txtflde.cxx:2578
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:139
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
static enum::xmloff::token::XMLTokenEnum MapBibliographyFieldName(std::u16string_view sName)
Definition: txtflde.cxx:3314
static enum::xmloff::token::XMLTokenEnum MapDocInfoFieldName(enum FieldIdEnum nToken)
Definition: txtflde.cxx:3253
static enum::xmloff::token::XMLTokenEnum MapPageNumberName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, sal_Int32 &nOffset)
Definition: txtflde.cxx:2948
void ExportMacro(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const OUString &rContent)
element content
Definition: txtflde.cxx:2266
static enum FieldIdEnum MapFieldName(std::u16string_view sFieldName, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
get field ID from XTextField service name (and it's PropertySet)
Definition: txtflde.cxx:438
void ProcessIntegerDef(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum, sal_Int32 nDefault)
attribute value
Definition: txtflde.cxx:2569
static enum::xmloff::token::XMLTokenEnum MapAuthorFieldName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
also adjust page offset
Definition: txtflde.cxx:2940
static enum::xmloff::token::XMLTokenEnum MapPlaceholderType(sal_uInt16 nType)
map placeholder type
Definition: txtflde.cxx:2904