writerfilter/source/ooxml/OOXMLFactory.cxx | 23 ----------- writerfilter/source/ooxml/OOXMLFactory.hxx | 35 ++++------------- writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 18 ++++---- writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx | 2 4 files changed, 19 insertions(+), 59 deletions(-)
New commits: commit 6b84bc7d24e2a862dd5edbd600be4959cd22c633 Author: Noel Grandin <noelgran...@gmail.com> Date: Sat Apr 25 21:23:34 2015 +0200 OOXMLFactory can be purely static it has no subclasses and no state, so it doesn't need locking or reference counting or even an instance Change-Id: I1e0f883946cb0e9bd26b49d12e58d813ce90a3b8 Reviewed-on: https://gerrit.libreoffice.org/15532 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noelgran...@gmail.com> diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx b/writerfilter/source/ooxml/OOXMLFactory.cxx index 6c92dae..f3bda37 100644 --- a/writerfilter/source/ooxml/OOXMLFactory.cxx +++ b/writerfilter/source/ooxml/OOXMLFactory.cxx @@ -38,29 +38,6 @@ OOXMLFactory_ns::~OOXMLFactory_ns() // class OOXMLFactory -typedef rtl::Static< osl::Mutex, OOXMLFactory > OOXMLFactory_Mutex; - -OOXMLFactory::Pointer_t OOXMLFactory::m_Instance; - -OOXMLFactory::OOXMLFactory() -{ - // multi-thread-safe mutex for all platforms - osl::MutexGuard aGuard(OOXMLFactory_Mutex::get()); - mnRefCnt = 0; -} - -OOXMLFactory::~OOXMLFactory() -{ -} - -OOXMLFactory::Pointer_t OOXMLFactory::getInstance() -{ - if (m_Instance.get() == nullptr) - m_Instance.reset(new OOXMLFactory()); - - return m_Instance; -} - void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler, const uno::Reference< xml::sax::XFastAttributeList > & Attribs) { diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx b/writerfilter/source/ooxml/OOXMLFactory.hxx index 720726d..acea3af 100644 --- a/writerfilter/source/ooxml/OOXMLFactory.hxx +++ b/writerfilter/source/ooxml/OOXMLFactory.hxx @@ -85,42 +85,25 @@ public: class OOXMLFactory { public: - typedef boost::intrusive_ptr<OOXMLFactory>Pointer_t; - static Pointer_t getInstance(); + static css::uno::Reference< css::xml::sax::XFastContextHandler> createFastChildContext(OOXMLFastContextHandler * pHandler, Token_t Element); - css::uno::Reference< css::xml::sax::XFastContextHandler> createFastChildContext(OOXMLFastContextHandler * pHandler, Token_t Element); + static css::uno::Reference< css::xml::sax::XFastContextHandler> createFastChildContextFromStart(OOXMLFastContextHandler * pHandler, Token_t Element); - css::uno::Reference< css::xml::sax::XFastContextHandler> createFastChildContextFromStart(OOXMLFastContextHandler * pHandler, Token_t Element); + static void attributes(OOXMLFastContextHandler * pHandler, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs); - void attributes(OOXMLFastContextHandler * pHandler, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs); + static void characters(OOXMLFastContextHandler * pHandler, const OUString & rString); - void characters(OOXMLFastContextHandler * pHandler, const OUString & rString); + static void startAction(OOXMLFastContextHandler * pHandler, Token_t nToken); + static void endAction(OOXMLFastContextHandler * pHandler, Token_t nToken); - void startAction(OOXMLFastContextHandler * pHandler, Token_t nToken); - void endAction(OOXMLFastContextHandler * pHandler, Token_t nToken); - - virtual ~OOXMLFactory(); -public: - sal_uInt32 mnRefCnt; private: - static Pointer_t m_Instance; - - OOXMLFactory(); - OOXMLFactory_ns::Pointer_t getFactoryForNamespace(Id id); + OOXMLFactory() {} + static OOXMLFactory_ns::Pointer_t getFactoryForNamespace(Id id); - css::uno::Reference< css::xml::sax::XFastContextHandler> createFastChildContextFromFactory(OOXMLFastContextHandler * pHandler, OOXMLFactory_ns::Pointer_t pFactory, Token_t Element); + static css::uno::Reference< css::xml::sax::XFastContextHandler> createFastChildContextFromFactory(OOXMLFastContextHandler * pHandler, OOXMLFactory_ns::Pointer_t pFactory, Token_t Element); }; - inline void intrusive_ptr_add_ref(OOXMLFactory* p) - { - p->mnRefCnt++; - } - inline void intrusive_ptr_release(OOXMLFactory* p) - { - if (!(--p->mnRefCnt)) - delete p; - } } } diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index bb72811..27338af 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -199,7 +199,7 @@ void OOXMLFastContextHandler::lcl_startFastElement const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/) throw (uno::RuntimeException, xml::sax::SAXException, std::exception) { - OOXMLFactory::getInstance()->startAction(this, Element); + OOXMLFactory::startAction(this, Element); if( Element == (NMSP_dmlWordDr|XML_positionV) ) inPositionV = true; else if( Element == (NMSP_dmlWordDr|XML_positionH) ) @@ -211,7 +211,7 @@ void OOXMLFastContextHandler::lcl_endFastElement (Token_t Element) throw (uno::RuntimeException, xml::sax::SAXException, std::exception) { - OOXMLFactory::getInstance()->endAction(this, Element); + OOXMLFactory::endAction(this, Element); } void SAL_CALL OOXMLFastContextHandler::endUnknownElement @@ -241,7 +241,7 @@ uno::Reference< xml::sax::XFastContextHandler > const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/) throw (uno::RuntimeException, xml::sax::SAXException, std::exception) { - return OOXMLFactory::getInstance()->createFastChildContext(this, Element); + return OOXMLFactory::createFastChildContext(this, Element); } uno::Reference< xml::sax::XFastContextHandler > SAL_CALL @@ -267,7 +267,7 @@ void OOXMLFastContextHandler::lcl_characters throw (uno::RuntimeException, xml::sax::SAXException, std::exception) { if (!m_bDiscardChildren) - OOXMLFactory::getInstance()->characters(this, rString); + OOXMLFactory::characters(this, rString); } void OOXMLFastContextHandler::setStream(Stream * pStream) @@ -284,17 +284,17 @@ void OOXMLFastContextHandler::attributes (const uno::Reference< xml::sax::XFastAttributeList > & Attribs) throw (uno::RuntimeException, xml::sax::SAXException) { - OOXMLFactory::getInstance()->attributes(this, Attribs); + OOXMLFactory::attributes(this, Attribs); } void OOXMLFastContextHandler::startAction(Token_t Element) { - OOXMLFactory::getInstance()->startAction(this, Element); + OOXMLFactory::startAction(this, Element); } void OOXMLFastContextHandler::endAction(Token_t Element) { - OOXMLFactory::getInstance()->endAction(this, Element); + OOXMLFactory::endAction(this, Element); } void OOXMLFastContextHandler::setId(Id rId) @@ -1647,7 +1647,7 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext case NMSP_vmlWord: case NMSP_vmlOffice: if (!bGroupShape) - xContextHandler.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element)); + xContextHandler.set(OOXMLFactory::createFastChildContextFromStart(this, Element)); // no break; default: if (!xContextHandler.is()) @@ -1831,7 +1831,7 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext !((oox::getBaseToken(Element) == XML_linkedTxbx) || (oox::getBaseToken(Element) == XML_txbx)); if ( bInNamespaces && (!bIsWrap || static_cast<OOXMLFastContextHandlerShape*>(mpParent)->isShapeSent()) ) - xResult.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element)); + xResult.set(OOXMLFactory::createFastChildContextFromStart(this, Element)); else if (mxContext.is() && !bSkipImages) { OOXMLFastContextHandlerWrapper * pWrapper = diff --git a/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx b/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx index cdd4644..76c81f0 100644 --- a/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx @@ -148,7 +148,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL return nullptr; } - return OOXMLFactory::getInstance()->createFastChildContextFromStart(getContextHandler().get(), Element); + return OOXMLFactory::createFastChildContextFromStart(getContextHandler().get(), Element); } uno::Reference< xml::sax::XFastContextHandler > SAL_CALL _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits