28#include <rtl/strbuf.hxx>
37#include <com/sun/star/util/DateTime.hpp>
38#include <rtl/math.hxx>
39#include <osl/diagnose.h>
43#define TYPE_DATETIME 3
52 ,
const Reference< XFastAttributeList > & _xAttrList
53 ,
const Reference< XPropertySet >& _xControl
54 ,OXMLControlProperty* _pContainer) :
57 ,m_pContainer(_pContainer)
62 OSL_ENSURE(
m_xControl.is(),
"Control is NULL!");
66 switch( aIter.getToken() )
69 m_bIsList = aIter.toView() ==
"true";
74 static std::map< OUString, css::uno::Type >
const s_aTypeNameMap
88 const std::map< OUString, css::uno::Type >::const_iterator aTypePos = s_aTypeNameMap.find(aIter.toString());
89 OSL_ENSURE(s_aTypeNameMap.end() != aTypePos,
"OXMLControlProperty::OXMLControlProperty: invalid type!");
90 if (s_aTypeNameMap.end() != aTypePos)
91 m_aPropType = aTypePos->second;
95 m_aSetting.Name = aIter.toString();
112 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
114 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
149 OSL_FAIL(
"Unknown property found!");
182 switch (_rExpectedType.getTypeClass())
184 case TypeClass_BOOLEAN:
190 OStringBuffer(
"OXMLControlProperty::convertString: could not convert \"" +
192 "\" into a boolean!").getStr());
196 case TypeClass_SHORT:
203 OStringBuffer(
"OXMLControlProperty::convertString: could not convert \"" +
205 "\" into an integer!").getStr());
206 if (TypeClass_SHORT == _rExpectedType.getTypeClass())
207 aReturn <<= static_cast<sal_Int16>(
nValue);
212 case TypeClass_HYPER:
214 OSL_FAIL(
"OXMLControlProperty::convertString: 64-bit integers not implemented yet!");
217 case TypeClass_DOUBLE:
223 OStringBuffer(
"OXMLControlProperty::convertString: could not convert \"" +
225 "\" into a double!").getStr());
229 case TypeClass_STRING:
230 aReturn <<= _rReadCharacters;
232 case TypeClass_STRUCT:
239 if ( _rExpectedType.equals(s_aDateType) )
241 else if ( _rExpectedType.equals(s_aTimeType) )
243 else if ( _rExpectedType.equals(s_aDateTimeType) )
252 OStringBuffer(
"OPropertyImport::convertString: could not convert \"" +
254 "\" into a double!").getStr());
262 "OPropertyImport::convertString: a Date value with a fractional part?");
268 OSL_ENSURE((
static_cast<sal_uInt32
>(
nValue)) == 0,
269 "OPropertyImport::convertString: a tools::Time value with more than a fractional part?");
278 css::util::DateTime aDateTime;
279 aDateTime.NanoSeconds = aTime.NanoSeconds;
280 aDateTime.Seconds = aTime.Seconds;
281 aDateTime.Minutes = aTime.Minutes;
282 aDateTime.Hours = aTime.Hours;
283 aDateTime.Day = aDate.Day;
284 aDateTime.Month = aDate.Month;
285 aDateTime.Year = aDate.Year;
286 aReturn <<= aDateTime;
294 OSL_FAIL(
"OPropertyImport::convertString: unsupported property type!");
298 OSL_FAIL(
"OXMLControlProperty::convertString: invalid type class!");
306 css::util::Time aTime;
307 sal_uInt64 nIntValue = ::rtl::math::round(
_nValue * 86400000000000.0);
308 aTime.NanoSeconds =
static_cast<sal_uInt16
>( nIntValue % 1000000000 );
309 nIntValue /= 1000000000;
310 aTime.Seconds =
static_cast<sal_uInt16
>( nIntValue % 60 );
312 aTime.Minutes =
static_cast<sal_uInt16
>( nIntValue % 60 );
314 OSL_ENSURE(nIntValue < 24,
"OPropertyImport::implGetTime: more than a day?");
315 aTime.Hours =
static_cast< sal_uInt16
>( nIntValue );
324 css::util::Date aDate;
325 ::utl::typeConvert(aToolsDate, aDate);
SvXMLImport & GetImport()
css::uno::Type const & get()
css::uno::Reference< css::beans::XPropertySet > m_xControl
ORptFilter & GetOwnImport()
OXMLControlProperty(const OXMLControlProperty &)=delete
css::uno::Type m_aPropType
OXMLControlProperty * m_pContainer
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
void addValue(const OUString &_sValue)
adds value to property
css::beans::PropertyValue m_aSetting
css::uno::Sequence< css::uno::Any > m_aSequence
static css::util::Time implGetTime(double _nValue)
OUStringBuffer m_aCharBuffer
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual ~OXMLControlProperty() override
virtual void SAL_CALL characters(const OUString &rChars) override
static css::util::Date implGetDate(double _nValue)
static css::uno::Any convertString(const css::uno::Type &_rExpectedType, const OUString &_rReadCharacters)
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool convertBool(bool &rBool, std::u16string_view rString)
constexpr T & temporary(T &&x)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
#define PROGRESS_BAR_STEP
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)