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