33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/util/Date.hpp>
35#include <com/sun/star/util/Time.hpp>
36#include <com/sun/star/util/DateTime.hpp>
37#include <com/sun/star/util/Duration.hpp>
38#include <com/sun/star/xforms/XDataTypeRepository.hpp>
39#include <com/sun/star/xsd/DataTypeClass.hpp>
40#include <com/sun/star/xsd/WhiteSpaceTreatment.hpp>
48using com::sun::star::uno::Exception;
49using com::sun::star::uno::Any;
51using com::sun::star::util::Duration;
52using com::sun::star::xml::sax::XFastAttributeList;
53using com::sun::star::xforms::XDataTypeRepository;
60 OUString sTypeName ) :
62 mxRepository( rRepository ),
63 msTypeName(
std::move( sTypeName ))
107 return Any( rValue );
121 return bSuccess ?
Any(
static_cast<sal_Int16
>(
nValue ) ) :
Any();
128 aValue <<= css::xsd::WhiteSpaceTreatment::Preserve;
130 aValue <<= css::xsd::WhiteSpaceTreatment::Replace;
132 aValue <<= css::xsd::WhiteSpaceTreatment::Collapse;
140 return bSuccess ?
Any( fValue ) :
Any();
148 sal_Int32 nPos1 = rValue.indexOf(
'-' );
149 sal_Int32 nPos2 = rValue.indexOf(
'-', nPos1 + 1 );
150 if( nPos1 > 0 && nPos2 > 0 )
153 aDate.Year =
static_cast<sal_uInt16
>(
155 aDate.Month =
static_cast<sal_uInt16
>(
156 o3tl::toInt32(rValue.subView( nPos1 + 1, nPos2 - nPos1 - 1 )) );
157 aDate.Day =
static_cast<sal_uInt16
>(
166 util::DateTime aDateTime;
168 return bSuccess ?
Any( aDateTime ) :
Any();
177 css::util::Time aTime;
178 aTime.Hours = aDuration.Hours;
179 aTime.Minutes = aDuration.Minutes;
180 aTime.Seconds = aDuration.Seconds;
181 aTime.NanoSeconds = aDuration.NanoSeconds;
189 sal_Int32 nElementToken,
198 sValue = aIter.toString();
204 OUString sPropertyName;
209 sPropertyName =
"Length";
213 sPropertyName =
"MinLength";
217 sPropertyName =
"MaxLength";
221 sPropertyName =
"TotalDigits";
225 sPropertyName =
"FractionDigits";
229 sPropertyName =
"Pattern";
233 sPropertyName =
"WhiteSpace";
250 sPropertyName =
"MinInclusive";
253 sPropertyName =
"MinExclusive";
256 sPropertyName =
"MaxInclusive";
259 sPropertyName =
"MaxExclusive";
268 case css::xsd::DataTypeClass::DECIMAL:
269 case css::xsd::DataTypeClass::DOUBLE:
270 case css::xsd::DataTypeClass::FLOAT:
271 sPropertyName +=
"Double";
274 case css::xsd::DataTypeClass::DATETIME:
275 sPropertyName +=
"DateTime";
278 case css::xsd::DataTypeClass::DATE:
279 sPropertyName +=
"Date";
282 case css::xsd::DataTypeClass::TIME:
283 sPropertyName +=
"Time";
286 case css::xsd::DataTypeClass::gYear:
287 case css::xsd::DataTypeClass::gDay:
288 case css::xsd::DataTypeClass::gMonth:
289 sPropertyName +=
"Int";
293 case css::xsd::DataTypeClass::STRING:
294 case css::xsd::DataTypeClass::anyURI:
295 case css::xsd::DataTypeClass::BOOLEAN:
313 OSL_FAIL(
"unknown facet" );
319 && !sPropertyName.isEmpty()
320 && pConvert !=
nullptr
321 &&
mxDataType->getPropertySetInfo()->hasPropertyByName(sPropertyName) )
325 mxDataType->setPropertyValue( sPropertyName, pConvert( sValue ) );
static Any xforms_dateTime(const OUString &rValue)
static Any xforms_int32(const OUString &rValue)
static Any xforms_string(const OUString &rValue)
static Any xforms_int16(const OUString &rValue)
static Any xforms_date(const OUString &rValue)
static Any xforms_whitespace(const OUString &rValue)
static Any xforms_time(const OUString &rValue)
Any(* convert_t)(const OUString &)
static Any xforms_double(const OUString &rValue)
SchemaRestrictionContext(SvXMLImport &rImport, css::uno::Reference< css::xforms::XDataTypeRepository > const &rRepository, OUString sTypeName)
css::uno::Reference< css::beans::XPropertySet > mxDataType
virtual SvXMLImportContext * HandleChild(sal_Int32 nElementToken, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
will be called for each child element
css::uno::Reference< css::xforms::XDataTypeRepository > mxRepository
OUString const msTypeName
virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
will be called for each attribute
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImport & GetImport()
SvXMLImportContext(SvXMLImport &rImport)
A contexts constructor does anything that is required if an element starts.
handle attributes through an SvXMLTokenMap
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static bool parseDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
sal_Int32 getToken() const
OUString toString() const
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN_IF(condition, area, stream)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
constexpr sal_Int32 TOKEN_MASK