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>
This commit is contained in:
Noel Grandin
2015-04-25 21:23:34 +02:00
parent 6ec2d48f70
commit 6b84bc7d24
4 changed files with 19 additions and 59 deletions

View File

@@ -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)
{

View File

@@ -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() {}
static OOXMLFactory_ns::Pointer_t getFactoryForNamespace(Id id);
OOXMLFactory();
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;
}
}
}

View File

@@ -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 =

View File

@@ -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