use rtl::Reference in FastParser
instead of storing both a raw pointer and a uno::Reference Change-Id: I6b67a6098a3ccdce7e29ee8d601c743897032eaf
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||||
#include <com/sun/star/xml/sax/SAXException.hpp>
|
#include <com/sun/star/xml/sax/SAXException.hpp>
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
|
#include <rtl/ref.hxx>
|
||||||
#include <sal/types.h>
|
#include <sal/types.h>
|
||||||
|
|
||||||
namespace com { namespace sun { namespace star {
|
namespace com { namespace sun { namespace star {
|
||||||
@@ -57,10 +58,12 @@ class FastParser
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// @throws css::uno::RuntimeException
|
/// @throws css::uno::RuntimeException
|
||||||
explicit FastParser(
|
explicit FastParser()
|
||||||
const css::uno::Reference< css::uno::XComponentContext >& rxContext )
|
|
||||||
throw( css::uno::RuntimeException );
|
throw( css::uno::RuntimeException );
|
||||||
|
|
||||||
|
FastParser(const FastParser&) = delete;
|
||||||
|
FastParser& operator=(const FastParser&) = delete;
|
||||||
|
|
||||||
virtual ~FastParser();
|
virtual ~FastParser();
|
||||||
|
|
||||||
/** Registers an OOXML namespace at the parser.
|
/** Registers an OOXML namespace at the parser.
|
||||||
@@ -110,13 +113,9 @@ public:
|
|||||||
getTokenHandler() const { return mxTokenHandler; }
|
getTokenHandler() const { return mxTokenHandler; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
css::uno::Reference< css::xml::sax::XFastParser >
|
css::uno::Reference<css::xml::sax::XFastTokenHandler> mxTokenHandler;
|
||||||
mxParser;
|
const NamespaceMap& mrNamespaceMap;
|
||||||
css::uno::Reference< css::xml::sax::XFastTokenHandler >
|
rtl::Reference<sax_fastparser::FastSaxParser> mxParser;
|
||||||
mxTokenHandler;
|
|
||||||
const NamespaceMap& mrNamespaceMap;
|
|
||||||
|
|
||||||
sax_fastparser::FastSaxParser* mpParser;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -230,7 +230,7 @@ public:
|
|||||||
|
|
||||||
void importDocumentProperties();
|
void importDocumentProperties();
|
||||||
|
|
||||||
FastParser* createParser() const;
|
static FastParser* createParser();
|
||||||
|
|
||||||
bool isMSO2007Document() const;
|
bool isMSO2007Document() const;
|
||||||
|
|
||||||
|
@@ -63,13 +63,11 @@ InputStreamCloseGuard::~InputStreamCloseGuard()
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
FastParser::FastParser( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
|
FastParser::FastParser() throw( RuntimeException ) :
|
||||||
mrNamespaceMap( StaticNamespaceMap::get() ),
|
mrNamespaceMap( StaticNamespaceMap::get() )
|
||||||
mpParser(nullptr)
|
|
||||||
{
|
{
|
||||||
// create a fast parser instance
|
// create a fast parser instance
|
||||||
mxParser = css::xml::sax::FastParser::create(rxContext);
|
mxParser = new sax_fastparser::FastSaxParser;
|
||||||
mpParser = dynamic_cast<sax_fastparser::FastSaxParser*>(mxParser.get());
|
|
||||||
|
|
||||||
// create the fast tokenhandler
|
// create the fast tokenhandler
|
||||||
mxTokenHandler.set( new FastTokenHandler );
|
mxTokenHandler.set( new FastTokenHandler );
|
||||||
|
@@ -403,7 +403,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq
|
|||||||
if( aZipStorage.isStorage() )
|
if( aZipStorage.isStorage() )
|
||||||
{
|
{
|
||||||
// create the fast parser, register the XML namespaces, set document handler
|
// create the fast parser, register the XML namespaces, set document handler
|
||||||
FastParser aParser( mxContext );
|
FastParser aParser;
|
||||||
aParser.registerNamespace( NMSP_packageRel );
|
aParser.registerNamespace( NMSP_packageRel );
|
||||||
aParser.registerNamespace( NMSP_officeRel );
|
aParser.registerNamespace( NMSP_officeRel );
|
||||||
aParser.registerNamespace( NMSP_packageContentTypes );
|
aParser.registerNamespace( NMSP_packageContentTypes );
|
||||||
|
@@ -188,7 +188,6 @@ struct XmlFilterBaseImpl
|
|||||||
|
|
||||||
XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
|
XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
|
||||||
mxContext(rxContext),
|
mxContext(rxContext),
|
||||||
maFastParser( rxContext ),
|
|
||||||
maBinSuffix( ".bin" ),
|
maBinSuffix( ".bin" ),
|
||||||
mrNamespaceMap(StaticNamespaceMap::get())
|
mrNamespaceMap(StaticNamespaceMap::get())
|
||||||
{
|
{
|
||||||
@@ -268,9 +267,9 @@ void XmlFilterBase::importDocumentProperties()
|
|||||||
checkDocumentProperties(xDocProps);
|
checkDocumentProperties(xDocProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
FastParser* XmlFilterBase::createParser() const
|
FastParser* XmlFilterBase::createParser()
|
||||||
{
|
{
|
||||||
FastParser* pParser = new FastParser(getComponentContext());
|
FastParser* pParser = new FastParser;
|
||||||
registerNamespaces(*pParser);
|
registerNamespaces(*pParser);
|
||||||
return pParser;
|
return pParser;
|
||||||
}
|
}
|
||||||
@@ -305,7 +304,7 @@ OUString XmlFilterBase::getFragmentPathFromFirstTypeFromOfficeDoc( const OUStrin
|
|||||||
|
|
||||||
bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler )
|
bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHandler )
|
||||||
{
|
{
|
||||||
FastParser aParser(mxImpl->mxContext);
|
FastParser aParser;
|
||||||
registerNamespaces(aParser);
|
registerNamespaces(aParser);
|
||||||
return importFragment(rxHandler, aParser);
|
return importFragment(rxHandler, aParser);
|
||||||
}
|
}
|
||||||
|
@@ -159,7 +159,7 @@ void SAL_CALL DocumentPropertiesImport::importProperties(
|
|||||||
if( aCoreStreams.getLength() > 1 )
|
if( aCoreStreams.getLength() > 1 )
|
||||||
throw IOException( "Unexpected core properties stream!" );
|
throw IOException( "Unexpected core properties stream!" );
|
||||||
|
|
||||||
::oox::core::FastParser aParser( mxContext );
|
::oox::core::FastParser aParser;
|
||||||
aParser.registerNamespace( NMSP_packageMetaCorePr );
|
aParser.registerNamespace( NMSP_packageMetaCorePr );
|
||||||
aParser.registerNamespace( NMSP_dc );
|
aParser.registerNamespace( NMSP_dc );
|
||||||
aParser.registerNamespace( NMSP_dcTerms );
|
aParser.registerNamespace( NMSP_dcTerms );
|
||||||
|
@@ -265,7 +265,7 @@ void RevisionHeadersFragment::finalizeImport()
|
|||||||
const RevisionMetadata& rData = it->second;
|
const RevisionMetadata& rData = it->second;
|
||||||
pCT->SetUser(rData.maUserName);
|
pCT->SetUser(rData.maUserName);
|
||||||
pCT->SetFixDateTimeLocal(rData.maDateTime);
|
pCT->SetFixDateTimeLocal(rData.maDateTime);
|
||||||
std::unique_ptr<oox::core::FastParser> xParser(getOoxFilter().createParser());
|
std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
|
||||||
rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionLogFragment(*this, aPath, *pCT));
|
rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionLogFragment(*this, aPath, *pCT));
|
||||||
importOoxFragment(xFragment, *xParser);
|
importOoxFragment(xFragment, *xParser);
|
||||||
}
|
}
|
||||||
|
@@ -244,7 +244,7 @@ public:
|
|||||||
SAL_INFO( "sc.filter", "got solar\n" );
|
SAL_INFO( "sc.filter", "got solar\n" );
|
||||||
|
|
||||||
std::unique_ptr<oox::core::FastParser> xParser(
|
std::unique_ptr<oox::core::FastParser> xParser(
|
||||||
mrWorkbookHandler.getOoxFilter().createParser() );
|
oox::core::XmlFilterBase::createParser() );
|
||||||
|
|
||||||
SAL_INFO( "sc.filter", "start import\n" );
|
SAL_INFO( "sc.filter", "start import\n" );
|
||||||
mrWorkbookHandler.importOoxFragment( mxHandler, *xParser );
|
mrWorkbookHandler.importOoxFragment( mxHandler, *xParser );
|
||||||
@@ -504,7 +504,7 @@ void WorkbookFragment::finalizeImport()
|
|||||||
OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
|
OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
|
||||||
if (!aRevHeadersPath.isEmpty())
|
if (!aRevHeadersPath.isEmpty())
|
||||||
{
|
{
|
||||||
std::unique_ptr<oox::core::FastParser> xParser(getOoxFilter().createParser());
|
std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
|
||||||
rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
|
rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
|
||||||
importOoxFragment(xFragment, *xParser);
|
importOoxFragment(xFragment, *xParser);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user