allow XmlReader to parse a string
Change-Id: I3433e6f3766c1ea54ad53896c4e4d142d1e319a5
This commit is contained in:
@@ -44,6 +44,10 @@ public:
|
|||||||
com::sun::star::container::NoSuchElementException,
|
com::sun::star::container::NoSuchElementException,
|
||||||
com::sun::star::uno::RuntimeException));
|
com::sun::star::uno::RuntimeException));
|
||||||
|
|
||||||
|
//string is not copied so must persist for lifetime
|
||||||
|
//of XmlReader
|
||||||
|
explicit XmlReader(const char * str, sal_uInt64 len) SAL_THROW(());
|
||||||
|
|
||||||
~XmlReader();
|
~XmlReader();
|
||||||
|
|
||||||
enum { NAMESPACE_NONE = -2, NAMESPACE_UNKNOWN = -1, NAMESPACE_XML = 0 };
|
enum { NAMESPACE_NONE = -2, NAMESPACE_UNKNOWN = -1, NAMESPACE_XML = 0 };
|
||||||
@@ -170,6 +174,8 @@ private:
|
|||||||
|
|
||||||
SAL_DLLPRIVATE int toNamespaceId(NamespaceIris::size_type pos);
|
SAL_DLLPRIVATE int toNamespaceId(NamespaceIris::size_type pos);
|
||||||
|
|
||||||
|
SAL_DLLPRIVATE void init();
|
||||||
|
|
||||||
rtl::OUString fileUrl_;
|
rtl::OUString fileUrl_;
|
||||||
oslFileHandle fileHandle_;
|
oslFileHandle fileHandle_;
|
||||||
sal_uInt64 fileSize_;
|
sal_uInt64 fileSize_;
|
||||||
|
@@ -96,19 +96,38 @@ XmlReader::XmlReader(rtl::OUString const & fileUrl)
|
|||||||
rtl::OUString::valueOf(static_cast< sal_Int32 >(e)) + ")"),
|
rtl::OUString::valueOf(static_cast< sal_Int32 >(e)) + ")"),
|
||||||
css::uno::Reference< css::uno::XInterface >());
|
css::uno::Reference< css::uno::XInterface >());
|
||||||
}
|
}
|
||||||
|
init();
|
||||||
|
pos_ = static_cast< char * >(fileAddress_);
|
||||||
|
end_ = pos_ + fileSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlReader::XmlReader(const char * str, sal_uInt64 len)
|
||||||
|
SAL_THROW(())
|
||||||
|
: fileHandle_(NULL)
|
||||||
|
, fileSize_(len)
|
||||||
|
, fileAddress_(NULL)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
pos_ = str;
|
||||||
|
end_ = pos_ + fileSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XmlReader::init()
|
||||||
|
{
|
||||||
namespaceIris_.push_back(
|
namespaceIris_.push_back(
|
||||||
Span(
|
Span(
|
||||||
RTL_CONSTASCII_STRINGPARAM(
|
RTL_CONSTASCII_STRINGPARAM(
|
||||||
"http://www.w3.org/XML/1998/namespace")));
|
"http://www.w3.org/XML/1998/namespace")));
|
||||||
namespaces_.push_back(
|
namespaces_.push_back(
|
||||||
NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML));
|
NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML));
|
||||||
pos_ = static_cast< char * >(fileAddress_);
|
|
||||||
end_ = pos_ + fileSize_;
|
|
||||||
state_ = STATE_CONTENT;
|
state_ = STATE_CONTENT;
|
||||||
firstAttribute_ = true;
|
firstAttribute_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlReader::~XmlReader() {
|
XmlReader::~XmlReader() {
|
||||||
|
if (!fileHandle_)
|
||||||
|
return;
|
||||||
|
|
||||||
oslFileError e = osl_unmapMappedFile(fileHandle_, fileAddress_, fileSize_);
|
oslFileError e = osl_unmapMappedFile(fileHandle_, fileAddress_, fileSize_);
|
||||||
if (e != osl_File_E_None) {
|
if (e != osl_File_E_None) {
|
||||||
SAL_WARN(
|
SAL_WARN(
|
||||||
|
Reference in New Issue
Block a user