summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2015-04-25 21:23:34 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-04-28 11:58:11 +0000
commit6b84bc7d24e2a862dd5edbd600be4959cd22c633 (patch)
tree137844a4d3dc2442cc84a208cf5b069d70290e16
parent6ec2d48f70ed7d428e37fdc21c15f6fd4f826e02 (diff)
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 <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--writerfilter/source/ooxml/OOXMLFactory.cxx23
-rw-r--r--writerfilter/source/ooxml/OOXMLFactory.hxx35
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx18
-rw-r--r--writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx2
4 files changed, 19 insertions, 59 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx b/writerfilter/source/ooxml/OOXMLFactory.cxx
index 6c92daefcb41..f3bda37e0582 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 720726dc4cec..acea3afa2171 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 bb72811ce13d..27338af35778 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 cdd4644cd4b6..76c81f01d885 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