Kaydet (Commit) 71eb2737 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

css.xml.sax service ctor clean-up

Change-Id: I556904861e93a145cfe65f61218926851e4e8eb0
üst 3b9b2e2d
......@@ -457,6 +457,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/dom,\
SAXDocumentBuilder \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/sax,\
FastParser \
FastShapeContextHandler \
FastTokenHandler \
Parser \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_COM_SUN_STAR_XML_SAX_FASTPARSER_IDL
#define INCLUDED_COM_SUN_STAR_XML_SAX_FASTPARSER_IDL
#include <com/sun/star/xml/sax/XFastParser.idl>
module com { module sun { module star { module xml { module sax {
service FastParser: XFastParser;
}; }; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -24,9 +24,7 @@
module com { module sun { module star { module xml { module sax {
service FastShapeContextHandler : XFastShapeContextHandler
{
};
service FastShapeContextHandler : XFastShapeContextHandler;
}; }; }; }; };
......
......@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <com/sun/star/xml/sax/FastParser.hpp>
#include "oox/core/fastparser.hxx"
#include "oox/core/fasttokenhandler.hxx"
......@@ -72,8 +75,7 @@ FastParser::FastParser( const Reference< XComponentContext >& rxContext ) throw(
mpParser(NULL)
{
// create a fast parser instance
Reference< XMultiComponentFactory > xFactory( rxContext->getServiceManager(), UNO_SET_THROW );
mxParser.set( xFactory->createInstanceWithContext( "com.sun.star.xml.sax.FastParser", rxContext ), UNO_QUERY_THROW );
mxParser = css::xml::sax::FastParser::create(rxContext);
mpParser = dynamic_cast<sax_fastparser::FastSaxParser*>(mxParser.get());
// create the fast tokenhandler
......
......@@ -18,6 +18,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/sax/XFastParser.hpp>
#include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
#include <com/sun/star/xml/sax/FastParser.hpp>
#include <com/sun/star/xml/sax/FastToken.hpp>
namespace oox {
......@@ -221,15 +222,11 @@ bool DocumentDecryption::readAgileEncryptionInfo(Reference< XInputStream >& xInp
mEngine.reset(engine);
AgileEncryptionInfo& info = engine->getInfo();
Reference<XMultiComponentFactory> xFactory( mxContext->getServiceManager(), UNO_SET_THROW );
Reference<XFastDocumentHandler> xFastDocumentHandler( new AgileDocumentHandler(info) );
Reference<XFastTokenHandler> xFastTokenHandler ( new AgileTokenHandler );
Reference<XFastParser> xParser;
xParser.set( xFactory->createInstanceWithContext( "com.sun.star.xml.sax.FastParser", mxContext ), UNO_QUERY_THROW );
if (!xParser.is())
return false;
Reference<XFastParser> xParser(
css::xml::sax::FastParser::create(mxContext));
xParser->setFastDocumentHandler( xFastDocumentHandler );
xParser->setTokenHandler( xFastTokenHandler );
......
......@@ -10,6 +10,7 @@
#include <sal/config.h>
#include <com/sun/star/io/Pipe.hpp>
#include <com/sun/star/xml/sax/FastParser.hpp>
#include <com/sun/star/xml/sax/FastTokenHandler.hpp>
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <com/sun/star/xml/sax/XFastParser.hpp>
......@@ -44,11 +45,7 @@ private:
void ParserTest::setUp()
{
test::BootstrapFixture::setUp();
mxParser.set(
m_xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.xml.sax.FastParser", m_xContext),
uno::UNO_QUERY );
CPPUNIT_ASSERT_MESSAGE("No FastParser!", mxParser.is());
mxParser = css::xml::sax::FastParser::create(m_xContext);
mxParser->setTokenHandler(
css::xml::sax::FastTokenHandler::create(m_xContext));
}
......
......@@ -22,6 +22,7 @@
#include <set>
#include <comphelper/servicehelper.hxx>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/xml/sax/FastShapeContextHandler.hpp>
#include <resourcemodel/QNameToString.hxx>
#include <resourcemodel/XPathLogger.hxx>
#include <resourcemodel/util.hxx>
......@@ -56,7 +57,6 @@ static const sal_uInt8 cFieldEnd = 0x15;
namespace writerfilter {
namespace ooxml
{
using ::com::sun::star::lang::XMultiComponentFactory;
using namespace ::com::sun::star;
using namespace ::std;
......@@ -2033,47 +2033,26 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape
: OOXMLFastContextHandlerProperties(pContext), m_bShapeSent( false ),
m_bShapeStarted(false)
{
uno::Reference<uno::XComponentContext> xContext(getComponentContext());
if (xContext.is())
mrShapeContext.set( getDocument( )->getShapeContext( ) );
if ( !mrShapeContext.is( ) )
{
uno::Reference<XMultiComponentFactory> rServiceManager
(xContext->getServiceManager());
mrShapeContext.set( getDocument( )->getShapeContext( ) );
if ( !mrShapeContext.is( ) )
{
// Define the shape context for the whole document
mrShapeContext.set
(rServiceManager->
createInstanceWithContext
("com.sun.star.xml.sax.FastShapeContextHandler", xContext),
uno::UNO_QUERY);
getDocument()->setShapeContext( mrShapeContext );
}
// Define the shape context for the whole document
mrShapeContext = css::xml::sax::FastShapeContextHandler::create(
getComponentContext());
getDocument()->setShapeContext( mrShapeContext );
}
if (mrShapeContext.is())
{
mrShapeContext->setModel(getDocument()->getModel());
mrShapeContext->setDrawPage(getDocument()->getDrawPage());
mrShapeContext->setInputStream(getDocument()->getStorageStream());
mrShapeContext->setModel(getDocument()->getModel());
mrShapeContext->setDrawPage(getDocument()->getDrawPage());
mrShapeContext->setInputStream(getDocument()->getStorageStream());
#ifdef DEBUG_ELEMENT
debug_logger->startElement("setRelationFragmentPath");
debug_logger->attribute("path", mpParserState->getTarget());
debug_logger->endElement();
#endif
mrShapeContext->setRelationFragmentPath
(mpParserState->getTarget());
}
#ifdef DEBUG_CONTEXT_STACK
else
{
debug_logger->startElement("error");
debug_logger->chars(std::string("failed to get shape handler"));
debug_logger->endElement();
}
debug_logger->startElement("setRelationFragmentPath");
debug_logger->attribute("path", mpParserState->getTarget());
debug_logger->endElement();
#endif
}
mrShapeContext->setRelationFragmentPath
(mpParserState->getTarget());
}
OOXMLFastContextHandlerShape::~OOXMLFastContextHandlerShape()
......
......@@ -321,13 +321,7 @@ uno::Reference &lt; xml::sax::XFastParser &gt; OOXMLStreamImpl::getFastParser()
{
if (! mxFastParser.is())
{
uno::Reference &lt; lang::XMultiComponentFactory &gt; xFactory =
uno::Reference &lt; lang::XMultiComponentFactory &gt;
(mxContext->getServiceManager());
mxFastParser.set(xFactory->createInstanceWithContext
( "com.sun.star.xml.sax.FastParser",
mxContext ), uno::UNO_QUERY_THROW);
mxFastParser = css::xml::sax::FastParser::create(mxContext);
</xsl:text>
<xsl:for-each select="//namespace-alias">
<xsl:text>
......@@ -346,7 +340,8 @@ uno::Reference &lt; xml::sax::XFastParser &gt; OOXMLStreamImpl::getFastParser()
</xsl:template>
<xsl:template match="/">
<xsl:text>
<xsl:text>
#include &lt;com/sun/star/xml/sax/FastParser.hpp&gt;
#include "ooxml/OOXMLFactory.hxx"
#include "ooxml/OOXMLFastHelper.hxx"
#include "ooxml/OOXMLStreamImpl.hxx"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment