LibreOffice Module xmloff (master)  1
xmluconv.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 
20 #ifndef INCLUDED_XMLOFF_XMLUCONV_HXX
21 #define INCLUDED_XMLOFF_XMLUCONV_HXX
22 
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <sal/types.h>
26 
27 #include <memory>
28 
29 #include <rtl/ustring.hxx>
30 #include <rtl/ustrbuf.hxx>
31 #include <xmloff/xmltoken.hxx>
32 
33 #include <tools/fldunit.hxx>
34 
35 namespace com::sun::star {
36  namespace text { class XNumberingTypeInfo; }
37 }
38 
39 namespace basegfx
40 {
41  class B3DVector;
42 }
43 
44 namespace com::sun::star::beans { class XPropertySet; }
45 namespace com::sun::star::beans { struct PropertyValue; }
46 namespace com::sun::star::drawing { struct Position3D; }
47 namespace com::sun::star::frame { class XModel; }
48 namespace com::sun::star::uno { class XComponentContext; }
49 namespace com::sun::star::uno { template <class E> class Sequence; }
50 namespace com::sun::star::util { struct Date; }
51 template <typename EnumT> struct SvXMLEnumMapEntry;
52 template <typename EnumT> struct SvXMLEnumStringMapEntry;
53 
55 {
56 private:
57  const OUString& maTokenString;
58  sal_Int32 mnNextTokenPos;
60 
61 public:
62  SvXMLTokenEnumerator( const OUString& rString, sal_Unicode cSeparator = u' ' );
63 
64  bool getNextToken( OUString& rToken );
65 };
66 
78 {
79 private:
80  SvXMLUnitConverter(const SvXMLUnitConverter&) = delete;
81  SvXMLUnitConverter& operator=(const SvXMLUnitConverter&) = delete;
82 
83  struct SAL_DLLPRIVATE Impl;
84  ::std::unique_ptr<Impl> m_pImpl;
85 
86 public:
91  const css::uno::Reference< css::uno::XComponentContext >& xContext,
92  sal_Int16 eCoreMeasureUnit /*css::util::MeasureUnit*/,
93  sal_Int16 eXMLMeasureUnit /*css::util::MeasureUnit*/);
94 
96 
97  static sal_Int16 GetMeasureUnit(FieldUnit const nFieldUnit);
98 
100  void SetCoreMeasureUnit( sal_Int16 const eCoreMeasureUnit /*css::util::MeasureUnit*/);
101 
103  void SetXMLMeasureUnit( sal_Int16 const eXMLMeasureUnit /*css::util::MeasureUnit*/);
104 
106  sal_Int16 GetXMLMeasureUnit() const;
107 
109  const css::uno::Reference< css::text::XNumberingTypeInfo >& getNumTypeInfo() const;
110 
113  bool convertMeasureToCore( sal_Int32& rValue,
114  const OUString& rString,
115  sal_Int32 nMin = SAL_MIN_INT32,
116  sal_Int32 nMax = SAL_MAX_INT32) const;
117 
119  void convertMeasureToXML( OUStringBuffer& rBuffer,
120  sal_Int32 nMeasure ) const;
121 
123  OUString convertMeasureToXML( sal_Int32 nMeasure ) const;
124 
127  template<typename EnumT>
128  static bool convertEnum( EnumT& rEnum,
129  const OUString& rValue,
130  const SvXMLEnumMapEntry<EnumT> *pMap )
131  {
132  sal_uInt16 nTmp;
133  bool bRet = convertEnumImpl(nTmp, rValue,
134  reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(pMap));
135  if (bRet)
136  rEnum = static_cast<EnumT>(nTmp);
137  return bRet;
138  }
139 
142  template<typename EnumT>
143  static bool convertEnum( EnumT& rEnum,
144  const OUString& rValue,
145  const SvXMLEnumStringMapEntry<EnumT> *pMap )
146  {
147  sal_uInt16 nTmp;
148  bool bRet = convertEnumImpl(nTmp, rValue,
149  reinterpret_cast<const SvXMLEnumStringMapEntry<sal_uInt16>*>(pMap));
150  if (bRet)
151  rEnum = static_cast<EnumT>(nTmp);
152  return bRet;
153  }
154 
159  template<typename EnumT>
160  static bool convertEnum( OUStringBuffer& rBuffer,
161  EnumT nValue,
162  const SvXMLEnumMapEntry<EnumT> *pMap,
165  {
166  return convertEnumImpl(rBuffer, static_cast<sal_uInt16>(nValue),
167  reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(pMap), eDefault);
168  }
169 
172  void convertDouble(OUStringBuffer& rBuffer,
173  double fNumber) const;
174 
176  bool convertDouble(double& rValue, const OUString& rString) const;
177 
179  bool setNullDate (
180  const css::uno::Reference <css::frame::XModel>& xModel);
181 
183  void convertDateTime( OUStringBuffer& rBuffer,
184  const double& fDateTime,
185  bool const bAddTimeIf0AM = false);
186 
188  bool convertDateTime(double& fDateTime,
189  const OUString& rString);
190 
192 
194  static void convertDateTime( OUStringBuffer& rBuffer,
195  const double& fDateTime,
196  const css::util::Date& aNullDate,
197  bool bAddTimeIf0AM = false);
199  static bool convertDateTime( double& fDateTime,
200  const OUString& rString,
201  const css::util::Date& aNullDate);
202 
203 
205  static bool convertB3DVector( ::basegfx::B3DVector& rVector,
206  const OUString& rValue );
207 
209  static void convertB3DVector( OUStringBuffer &rBuffer,
210  const ::basegfx::B3DVector& rVector );
211 
213  bool convertPosition3D( css::drawing::Position3D& rPosition,
214  const OUString& rValue );
215 
217  void convertPosition3D( OUStringBuffer &rBuffer,
218  const css::drawing::Position3D& rVector );
219 
220 
222  bool convertNumFormat( sal_Int16& rType,
223  const OUString& rNumFormat,
224  const OUString& rNumLetterSync,
225  bool bNumberNone = false ) const;
226 
228  void convertNumFormat( OUStringBuffer& rBuffer,
229  sal_Int16 nType ) const;
230  static void convertNumLetterSync( OUStringBuffer& rBuffer,
231  sal_Int16 nType );
232 
233  static void convertPropertySet(css::uno::Sequence<css::beans::PropertyValue>& rProps,
234  const css::uno::Reference<css::beans::XPropertySet>& aProperties);
235  static void convertPropertySet(css::uno::Reference<css::beans::XPropertySet> const & rProperties,
236  const css::uno::Sequence<css::beans::PropertyValue>& aProps);
237 
238  OUString encodeStyleName( const OUString& rName,
239  bool *pEncoded=nullptr ) const;
241  static bool convertHex( sal_uInt32& nVal,
242  const OUString& rValue );
243 
245  static void convertHex( OUStringBuffer& rBuffer,
246  sal_uInt32 nVal );
247 
248 private:
249  static bool convertEnumImpl( sal_uInt16& rEnum,
250  const OUString& rValue,
251  const SvXMLEnumMapEntry<sal_uInt16> *pMap );
252 
253  static bool convertEnumImpl( sal_uInt16& rEnum,
254  const OUString& rValue,
256 
257  static bool convertEnumImpl( OUStringBuffer& rBuffer,
258  sal_uInt16 nValue,
259  const SvXMLEnumMapEntry<sal_uInt16> *pMap,
261 };
262 
263 #endif // INCLUDED_XMLOFF_XMLUCONV_HXX
264 
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FieldUnit
static bool convertEnum(EnumT &rEnum, const OUString &rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:128
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:77
sal_Int32 mnNextTokenPos
Definition: xmluconv.hxx:58
sal_Unicode mcSeparator
Definition: xmluconv.hxx:59
const OUString & maTokenString
Definition: xmluconv.hxx:57
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
sal_uInt16 sal_Unicode
static bool convertEnum(EnumT &rEnum, const OUString &rValue, const SvXMLEnumStringMapEntry< EnumT > *pMap)
convert string to enum using given token map, if the enum is not found in the map, this method will return false
Definition: xmluconv.hxx:143
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:47
Map a const char* (with length) to a sal_uInt16 value.
Definition: xmlement.hxx:70
class SAL_NO_VTABLE XPropertySet
static bool convertEnum(OUStringBuffer &rBuffer, EnumT nValue, const SvXMLEnumMapEntry< EnumT > *pMap, enum::xmloff::token::XMLTokenEnum eDefault=::xmloff::token::XML_TOKEN_INVALID)
convert enum to string using given enum map with an optional default token.
Definition: xmluconv.hxx:160
Map an XMLTokenEnum to an enum value.
Definition: ximpshap.hxx:40
def text(shape, st)
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
::std::unique_ptr< Impl > m_pImpl
Definition: xmluconv.hxx:84