update emoji autocorrect entries from po-files
[LibreOffice.git] / include / xmloff / xmluconv.hxx
blob94f8c43f18b862b8b6eadc3d2f5fcf7573ad68d1
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 #ifndef INCLUDED_XMLOFF_XMLUCONV_HXX
21 #define INCLUDED_XMLOFF_XMLUCONV_HXX
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <sal/types.h>
27 #include <memory>
28 #include <limits.h>
30 #include <rtl/ustring.hxx>
31 #include <rtl/ustrbuf.hxx>
32 #include <xmloff/xmlement.hxx>
33 #include <xmloff/xmltoken.hxx>
34 #include <com/sun/star/util/Date.hpp>
35 #include <com/sun/star/frame/XModel.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/drawing/Position3D.hpp>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <tools/fldunit.hxx>
41 #include <tools/mapunit.hxx>
43 namespace tools { class Time; }
45 namespace com { namespace sun { namespace star {
46 namespace util { struct DateTime; }
47 namespace text { class XNumberingTypeInfo; }
48 }}}
50 namespace basegfx
52 class B3DVector;
55 class XMLOFF_DLLPUBLIC SvXMLTokenEnumerator
57 private:
58 const OUString& maTokenString;
59 sal_Int32 mnNextTokenPos;
60 sal_Unicode mcSeparator;
62 public:
63 SvXMLTokenEnumerator( const OUString& rString, sal_Unicode cSeparator = sal_Unicode(' ') );
65 bool getNextToken( OUString& rToken );
68 /** the SvXMLTypeConverter converts values of various types from
69 their internal representation to the textual form used in xml
70 and back.
71 Most of the methods are static but the SvXMLTypeConverter can
72 also store default units for both numerical and textual measures.
74 @attention:
75 a lot of the methods here have been moved to <sax/tools/converter.hxx>!
78 class XMLOFF_DLLPUBLIC SvXMLUnitConverter
80 private:
81 SvXMLUnitConverter(const SvXMLUnitConverter&) SAL_DELETED_FUNCTION;
82 SvXMLUnitConverter& operator=(const SvXMLUnitConverter&) SAL_DELETED_FUNCTION;
84 struct Impl;
85 ::std::unique_ptr<Impl> m_pImpl;
87 public:
88 /** constructs a SvXMLUnitConverter. The core measure unit is the
89 default unit for numerical measures, the XML measure unit is
90 the default unit for textual measures */
91 SvXMLUnitConverter(
92 const ::com::sun::star::uno::Reference<
93 ::com::sun::star::uno::XComponentContext >& xContext,
94 sal_Int16 eCoreMeasureUnit /*css::util::MeasureUnit*/,
95 sal_Int16 eXMLMeasureUnit /*css::util::MeasureUnit*/);
97 virtual ~SvXMLUnitConverter();
99 static sal_Int16 GetMeasureUnit(FieldUnit const nFieldUnit);
101 /** sets the default unit for numerical measures */
102 void SetCoreMeasureUnit( sal_Int16 const eCoreMeasureUnit /*css::util::MeasureUnit*/);
104 /** sets the default unit for textual measures */
105 void SetXMLMeasureUnit( sal_Int16 const eXMLMeasureUnit /*css::util::MeasureUnit*/);
107 /** gets the default unit for textual measures */
108 sal_Int16 GetXMLMeasureUnit() const;
110 /** gets XNumberingTypeInfo */
111 const ::com::sun::star::uno::Reference<
112 ::com::sun::star::text::XNumberingTypeInfo >& getNumTypeInfo() const;
114 /** convert string to measure with meCoreMeasureUnit,
115 using optional min and max values*/
116 bool convertMeasureToCore( sal_Int32& rValue,
117 const OUString& rString,
118 sal_Int32 nMin = SAL_MIN_INT32,
119 sal_Int32 nMax = SAL_MAX_INT32) const;
121 /** convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit */
122 void convertMeasureToXML( OUStringBuffer& rBuffer,
123 sal_Int32 nMeasure ) const;
125 /** convert string to enum using given enum map, if the enum is
126 not found in the map, this method will return false */
127 static bool convertEnum( sal_uInt16& rEnum,
128 const OUString& rValue,
129 const SvXMLEnumMapEntry *pMap );
131 /** convert string to enum using given token map, if the enum is
132 not found in the map, this method will return false */
133 static bool convertEnum( sal_uInt16& rEnum,
134 const OUString& rValue,
135 const SvXMLEnumStringMapEntry *pMap );
137 /** convert enum to string using given enum map with an optional
138 default token. If the enum is not found in the map,
139 this method will either use the given default or return
140 false if not default is set */
141 static bool convertEnum( OUStringBuffer& rBuffer,
142 unsigned int nValue,
143 const SvXMLEnumMapEntry *pMap,
144 enum ::xmloff::token::XMLTokenEnum eDefault =
145 ::xmloff::token::XML_TOKEN_INVALID );
147 /** convert double number to string (using ::rtl::math) and DO
148 convert to export MapUnit using meCoreMeasureUnit/meXMLMeasureUnit */
149 void convertDouble(OUStringBuffer& rBuffer,
150 double fNumber, bool bWriteUnits) const;
152 /** convert string to double number (using ::rtl::math) and DO convert. */
153 bool convertDouble(double& rValue, const OUString& rString, bool bLookForUnits) const;
155 /** get the Null Date of the XModel and set it to the UnitConverter */
156 bool setNullDate (
157 const com::sun::star::uno::Reference <com::sun::star::frame::XModel>& xModel);
159 /** convert double to ISO Date Time String */
160 void convertDateTime( OUStringBuffer& rBuffer,
161 const double& fDateTime,
162 bool const bAddTimeIf0AM = false);
164 /** convert ISO Date Time String to double */
165 bool convertDateTime(double& fDateTime,
166 const OUString& rString);
168 /// these 2 functions use tools Date, so they're not yet moved to sax
170 /** convert double to ISO Date Time String */
171 static void convertDateTime( OUStringBuffer& rBuffer,
172 const double& fDateTime,
173 const com::sun::star::util::Date& aNullDate,
174 bool bAddTimeIf0AM = false);
175 /** convert ISO Date Time String to double */
176 static bool convertDateTime( double& fDateTime,
177 const OUString& rString,
178 const com::sun::star::util::Date& aNullDate);
181 /** convert string to ::basegfx::B3DVector */
182 static bool convertB3DVector( ::basegfx::B3DVector& rVector,
183 const OUString& rValue );
185 /** convert B3DVector to string */
186 static void convertB3DVector( OUStringBuffer &rBuffer,
187 const ::basegfx::B3DVector& rVector );
189 /** convert string to Position3D */
190 bool convertPosition3D( com::sun::star::drawing::Position3D& rPosition,
191 const OUString& rValue );
193 /** convert Position3D to string */
194 void convertPosition3D( OUStringBuffer &rBuffer,
195 const com::sun::star::drawing::Position3D& rVector );
198 /** convert num-forat and num-letter-sync values to NumberingType */
199 bool convertNumFormat( sal_Int16& rType,
200 const OUString& rNumFormat,
201 const OUString& rNumLetterSync,
202 bool bNumberNone = false ) const;
204 /** convert NumberingType to num-forat and num-letter-sync values */
205 void convertNumFormat( OUStringBuffer& rBuffer,
206 sal_Int16 nType ) const;
207 static void convertNumLetterSync( OUStringBuffer& rBuffer,
208 sal_Int16 nType );
210 static void convertPropertySet(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProps,
211 const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& aProperties);
212 static void convertPropertySet(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& rProperties,
213 const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
215 OUString encodeStyleName( const OUString& rName,
216 bool *pEncoded=0 ) const;
217 /** convert string (hex) to number (sal_uInt32) */
218 static bool convertHex( sal_uInt32& nVal,
219 const OUString& rValue );
221 /** convert number (sal_uInt32) to string (hex) */
222 static void convertHex( OUStringBuffer& rBuffer,
223 sal_uInt32 nVal );
226 #endif // INCLUDED_XMLOFF_XMLUCONV_HXX
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */