allow XmlReader to parse a string

Change-Id: I3433e6f3766c1ea54ad53896c4e4d142d1e319a5
This commit is contained in:
Caolán McNamara 2012-10-15 15:48:30 +01:00
parent 239847102b
commit 794a7c67e8
2 changed files with 27 additions and 2 deletions

View File

@ -44,6 +44,10 @@ public:
com::sun::star::container::NoSuchElementException,
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();
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 void init();
rtl::OUString fileUrl_;
oslFileHandle fileHandle_;
sal_uInt64 fileSize_;

View File

@ -96,19 +96,38 @@ XmlReader::XmlReader(rtl::OUString const & fileUrl)
rtl::OUString::valueOf(static_cast< sal_Int32 >(e)) + ")"),
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(
Span(
RTL_CONSTASCII_STRINGPARAM(
"http://www.w3.org/XML/1998/namespace")));
namespaces_.push_back(
NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML));
pos_ = static_cast< char * >(fileAddress_);
end_ = pos_ + fileSize_;
state_ = STATE_CONTENT;
firstAttribute_ = true;
}
XmlReader::~XmlReader() {
if (!fileHandle_)
return;
oslFileError e = osl_unmapMappedFile(fileHandle_, fileAddress_, fileSize_);
if (e != osl_File_E_None) {
SAL_WARN(