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 #ifndef INCLUDED_XMLOFF_INC_TXTFLDE_HXX
25 #define INCLUDED_XMLOFF_INC_TXTFLDE_HXX
26 
27 #include <com/sun/star/uno/Reference.h>
28 #include <xmloff/xmlnamespace.hxx>
29 
30 #include <rtl/ustring.hxx>
31 #include <xmloff/xmltoken.hxx>
32 
33 #include <map>
34 #include <set>
35 #include <memory>
36 #include <string_view>
37 
38 class SvXMLExport;
39 struct XMLPropertyState;
40 
41 namespace com::sun::star {
42  namespace util { struct DateTime; }
43  namespace util { struct Date; }
44  namespace text { class XTextField; }
45  namespace text { class XText; }
46  namespace beans { class XPropertySet; }
47  namespace beans { class XPropertySetInfo; }
48  namespace frame { class XModel; }
49  namespace uno { template<typename A> class Sequence; }
50 }
51 
52 
54 // including translation between UNO speak and XML speak if appropriate
55 
57  FIELD_ID_SENDER, // sender == extended user
59  FIELD_ID_DATE, // current date
60  FIELD_ID_TIME, // current time (+date)
61  FIELD_ID_PAGENAME, // page/slide name
62  FIELD_ID_PAGENUMBER, // page number
63  FIELD_ID_PAGESTRING, // page continuation string (page number string)
64  FIELD_ID_REFPAGE_SET, // set reference page
65  FIELD_ID_REFPAGE_GET, // get reference page number
66 
67  FIELD_ID_PLACEHOLDER, // placeholder field == jump edit field
68 
69  FIELD_ID_VARIABLE_GET, // get variable == get expression
70  FIELD_ID_VARIABLE_SET, // set variable == set expression
71  FIELD_ID_VARIABLE_INPUT, // input field (variable)
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, // sequence field
77 
78  FIELD_ID_DATABASE_NEXT, // select next row
79  FIELD_ID_DATABASE_SELECT, // select row # (NumSet)
80  FIELD_ID_DATABASE_DISPLAY, // display data (form letter field)
81  FIELD_ID_DATABASE_NAME, // display current db name (database name)
82  FIELD_ID_DATABASE_NUMBER, // display row # (SetNumber)
83 
100 
101  FIELD_ID_CONDITIONAL_TEXT, // conditionally choose between 2 texts
102  FIELD_ID_HIDDEN_TEXT, // conditionally hide a text
103  FIELD_ID_HIDDEN_PARAGRAPH, // conditionally hide a paragraph
104 
105  FIELD_ID_TEMPLATE_NAME, // display name of template
106  FIELD_ID_CHAPTER, // display name/number of current chapter
107  FIELD_ID_FILE_NAME, // display name of current file
108 
109  FIELD_ID_COUNT_PARAGRAPHS, // statistics fields: - paragraphs
114  FIELD_ID_COUNT_GRAPHICS, // - graphics
116 
117  FIELD_ID_MACRO, // macro fields
118  FIELD_ID_REF_REFERENCE, // get reference field (reference)
119  FIELD_ID_REF_SEQUENCE, // get reference field (sequence)
120  FIELD_ID_REF_BOOKMARK, // get reference field (bookmark)
121  FIELD_ID_REF_FOOTNOTE, // get reference field (footnote)
122  FIELD_ID_REF_ENDNOTE, // get reference field (endnote)
123  FIELD_ID_DDE, // DDE field
124 
125  FIELD_ID_BIBLIOGRAPHY, // bibliography index entry
126 
127  FIELD_ID_SHEET_NAME, // name of current (spread-)sheet
128  FIELD_ID_URL, // URL field (only Calc, Draw, Impress)
129 
130  FIELD_ID_SCRIPT, // script fields (for HTML pages, mostly)
131  FIELD_ID_ANNOTATION, // annotation (notice) field
132 
133  FIELD_ID_COMBINED_CHARACTERS, // combined characters (asian typography)
134 
135  FIELD_ID_META, // text:meta-field (RDF metadata)
136 
137  FIELD_ID_MEASURE, // for measure shapes
138 
139  FIELD_ID_TABLE_FORMULA, // DEPRECATED: table formulas (Writer 2.0)
140  FIELD_ID_DROP_DOWN, // DEPRECATED: dropdown fields (WW8)
141 
145 
146  FIELD_ID_UNKNOWN // invalid or unknown field type!
147 };
148 
149 
151 {
153 
155  std::unique_ptr< ::std::map<
156  css::uno::Reference< css::text::XText >,
157  ::std::set< OUString > > >
159 
160 public:
161 
164  std::unique_ptr<XMLPropertyState> pCombinedCharState );
166 
169  void ExportField(const css::uno::Reference < css::text::XTextField > & rTextField,
170  bool bProgress, bool & rPrevCharIsSpace);
171 
176  void ExportFieldAutoStyle(const css::uno::Reference < css::text::XTextField > & rTextField,
177  const bool bProgress, const bool bRecursive );
178 
182 
187  const css::uno::Reference < css::text::XText > & rText);
188 
192  bool bExportOnlyUsed = true);
193 
194  // determine element or attribute names
195  // (public, because they may be useful in related XML export classes)
204  static enum ::xmloff::token::XMLTokenEnum MapBibliographyFieldName(std::u16string_view sName);
205  static enum ::xmloff::token::XMLTokenEnum MapMeasureKind(sal_Int16 nKind);
206  static enum ::xmloff::token::XMLTokenEnum MapPageNumberName(const css::uno::Reference< css::beans::XPropertySet> & xPropSet,
207  sal_Int32& nOffset);
208  static enum ::xmloff::token::XMLTokenEnum MapAuthorFieldName(const css::uno::Reference< css::beans::XPropertySet > & xPropSet);
209  static enum ::xmloff::token::XMLTokenEnum MapSenderFieldName(const css::uno::Reference< css::beans::XPropertySet > & xPropSet);
210 
211 private:
212 
214 
216  void ExportFieldHelper(
217  const css::uno::Reference< css::text::XTextField> & rTextField,
218  const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
219  const css::uno::Reference< css::beans::XPropertySet> & rRangePropSet,
220  enum FieldIdEnum nToken,
221  bool bProgress,
222  bool & rPrevCharIsSpace);
223 
226  bool bAddSpace = false);
227 
231  const OUString& sContent);
232 
234  void ExportMacro( const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
235  const OUString& rContent);
236 
238  void ExportMetaField( const css::uno::Reference< css::beans::XPropertySet> & i_xMeta,
239  bool i_bAutoStyles, bool i_bProgress,
240  bool & rPrevCharIsSpace);
241 
243  void ProcessBoolean(
245  bool bBool,
246  bool bDefault);
247 
249  void ProcessInteger(
251  sal_Int32 nNum);
252 
254  void ProcessIntegerDef(
256  sal_Int32 nNum,
257  sal_Int32 nDefault);
258 
260  void ProcessString(
262  const OUString& sValue,
263  bool bOmitEmpty = false,
264  sal_uInt16 nPrefix = XML_NAMESPACE_TEXT);
265 
267  void ProcessString(
269  sal_uInt16 nValuePrefix,
270  const OUString& sValue);
271 
272 
274  void ProcessString(
276  const OUString& sValue,
277  std::u16string_view sDefault);
278 
280  void ProcessString(
282  sal_uInt16 nValuePrefix,
283  const OUString& sValue,
284  std::u16string_view sDefault);
285 
287  void ProcessString(
290  sal_uInt16 nPrefix = XML_NAMESPACE_TEXT);
291 
293  void ProcessString(
297 
301  std::u16string_view sParagraphSequence);
302 
305  sal_Int16 nNumberingType);
306 
308  void ProcessDisplay(bool bIsVisible,
309  bool bIsCommand);
310 
312  void ProcessValueAndType(
313  bool bIsString,
314  sal_Int32 nFormatKey,
315  const OUString& sContent,
316  std::u16string_view sDefault,
317  double fValue,
318  bool bExportValue,
319  bool bExportValueType,
320  bool bExportStyle,
321  bool bForceSystemLanguage,
322  bool bTimeStyle = false);
323 
325  void ProcessDateTime(
327  double dValue,
328  bool bIsDate,
329  bool bIsDuration,
330  bool bOmitDurationIfZero = true,
331  sal_uInt16 nPrefix = XML_NAMESPACE_TEXT);
332 
334  void ProcessDateTime(
336  sal_Int32 nMinutes,
337  bool bIsDate,
338  bool bIsDuration);
339 
341  void ProcessDateTime(
343  const css::util::DateTime& rTime);
344 
348  const css::util::DateTime& rTime);
349 
352  const css::uno::Reference <
353  css::beans::XPropertySet > & rPropertySet);
354 
356  void ProcessCommandType(
357  sal_Int32 nCommandType);
358 
360  const css::uno::Sequence<OUString>& rSequence,
361  const OUString& sSelected );
362 
364  const css::uno::Sequence<OUString>& rSequence,
365  sal_Int32 nSelected );
366 
370  const OUString& sContent,
371  const css::uno::Reference < css::beans::XPropertySet > & rPropertySet,
372  const css::uno::Reference < css::beans::XPropertySetInfo > & rPropertySetInfo );
373 
375  static css::uno::Reference < css::beans::XPropertySet >
376  GetMasterPropertySet(const css::uno::Reference < css::text::XTextField > & rTextField);
377 
379  static bool GetDependentFieldPropertySet(
380  const css::uno::Reference< css::beans::XPropertySet> & xmaster,
381  css::uno::Reference< css::beans::XPropertySet> & xField);
382 
383 
385  static enum FieldIdEnum GetFieldID(const css::uno::Reference < css::text::XTextField > & rTextField,
386  const css::uno::Reference < css::beans::XPropertySet > & xPropSet);
387 
389  static enum FieldIdEnum MapFieldName(std::u16string_view sFieldName,
390  const css::uno::Reference < css::beans::XPropertySet> & xPropSet);
391 
393  static bool IsStringField(FieldIdEnum nFieldType,
394  const css::uno::Reference < css::beans::XPropertySet > & xPropSet);
395 
396 
398  static void ExplodeFieldMasterName(
399  const OUString& sMasterName,
400  OUString& sFieldType,
401  OUString& sVarName);
402 
404  static OUString MakeFootnoteRefName(sal_Int16 nSeqNo);
405 
407  static OUString MakeSequenceRefName(sal_Int16 nSeqNo,
408  std::u16string_view rSeqName);
409 
410  std::unique_ptr<XMLPropertyState> pCombinedCharactersPropertyState;
411 
412 };
413 
414 
415 #endif
416 
417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
SvXMLExport & rExport
Definition: txtflde.hxx:152
static bool IsStringField(FieldIdEnum nFieldType, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
determine, whether field has string or numeric content
Definition: txtflde.cxx:631
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:3070
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:2313
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:748
static OUString MakeSequenceRefName(sal_Int16 nSeqNo, std::u16string_view rSeqName)
make reference name for a sequence field
Definition: txtflde.cxx:3457
void ProcessInteger(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum)
attribute default; omit, if attribute differs
Definition: txtflde.cxx:2552
static enum::xmloff::token::XMLTokenEnum MapCountFieldName(FieldIdEnum nToken)
map count/statistics field token to XML name
Definition: txtflde.cxx:3001
static enum::xmloff::token::XMLTokenEnum MapReferenceType(sal_Int16 nType)
map ReferenceFieldPart to XML string
Definition: txtflde.cxx:3097
void ExportFieldDeclarations()
export field declarations.
Definition: txtflde.cxx:1914
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:158
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:971
void ProcessParagraphSequence(std::u16string_view sParagraphSequence)
default value token
Definition: txtflde.cxx:2536
void ProcessDisplay(bool bIsVisible, bool bIsCommand)
numbering type key
Definition: txtflde.cxx:2420
SvXMLExport & GetExport()
Definition: txtflde.hxx:213
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:384
static enum::xmloff::token::XMLTokenEnum MapChapterDisplayFormat(sal_Int16 nType)
map ChapterDisplayFormat to XML string
Definition: txtflde.cxx:3038
XMLTextFieldExport(SvXMLExport &rExp, std::unique_ptr< XMLPropertyState > pCombinedCharState)
Definition: txtflde.cxx:371
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:2660
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
exports com.sun.star. text
static enum::xmloff::token::XMLTokenEnum MapMeasureKind(sal_Int16 nKind)
Definition: txtflde.cxx:3438
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:2355
void ProcessBoolean(enum::xmloff::token::XMLTokenEnum eXmlName, bool bBool, bool bDefault)
export a boolean attribute
Definition: txtflde.cxx:2443
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:2787
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:3149
static OUString MakeFootnoteRefName(sal_Int16 nSeqNo)
out: variable name
Definition: txtflde.cxx:3450
static void ExplodeFieldMasterName(const OUString &sMasterName, OUString &sFieldType, OUString &sVarName)
explode a field master name into field type and field name
Definition: txtflde.cxx:2836
void ProcessCommandType(sal_Int32 nCommandType)
export CommandTypeAttribute
Definition: txtflde.cxx:2743
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:1056
static enum::xmloff::token::XMLTokenEnum MapSenderFieldName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
element name for sender fields
Definition: txtflde.cxx:3178
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:2214
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:2855
exports com.sun.star. beans
static enum::xmloff::token::XMLTokenEnum MapTemplateDisplayFormat(sal_Int16 nType)
map TemplateDisplayFormat to XML
Definition: txtflde.cxx:2967
void ProcessBibliographyData(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet)
date/time value
Definition: txtflde.cxx:2701
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:2864
std::unique_ptr< XMLPropertyState > pCombinedCharactersPropertyState
Definition: txtflde.hxx:410
FieldIdEnum
field IDs,
Definition: txtflde.hxx:56
void ProcessNumberingType(sal_Int16 nNumberingType)
export a numbering format (numeric, roman, alphabetic, etc.)
Definition: txtflde.cxx:2573
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:122
static enum::xmloff::token::XMLTokenEnum MapBibliographyFieldName(std::u16string_view sName)
Definition: txtflde.cxx:3301
static enum::xmloff::token::XMLTokenEnum MapDocInfoFieldName(enum FieldIdEnum nToken)
Definition: txtflde.cxx:3240
static enum::xmloff::token::XMLTokenEnum MapPageNumberName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, sal_Int32 &nOffset)
Definition: txtflde.cxx:2935
void ExportMacro(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const OUString &rContent)
element content
Definition: txtflde.cxx:2257
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:437
void ProcessIntegerDef(enum::xmloff::token::XMLTokenEnum eXmlName, sal_Int32 nNum, sal_Int32 nDefault)
attribute value
Definition: txtflde.cxx:2564
static enum::xmloff::token::XMLTokenEnum MapAuthorFieldName(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
also adjust page offset
Definition: txtflde.cxx:2927
static enum::xmloff::token::XMLTokenEnum MapPlaceholderType(sal_uInt16 nType)
map placeholder type
Definition: txtflde.cxx:2891