diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-08-17 19:21:35 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-08-20 16:40:09 +0200 |
commit | 102348fcd17ab4a862d6f15565f97d8a88cd9231 (patch) | |
tree | 7a78ea26c828e38360b697ad8e74070907b1ea9c /sw | |
parent | 851af7040e05e956a5c8f145679c8141a07fecb4 (diff) |
make SwXFrame derived constructors private
... so that new instances have to be created by the factory functions.
Change-Id: I643a154609b1a277d5cbc22d739ef8e357028f56
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unoframe.hxx | 20 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 5 |
4 files changed, 24 insertions, 12 deletions
diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 23af07c96fab..3e5bb973f0ac 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -85,6 +85,10 @@ protected: SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const SfxItemPropertySet* pPropSet); + template<class Interface, class Impl> + static css::uno::Reference<Interface> + CreateXFrame(SwDoc & rDoc, SwFrmFmt *const pFrmFmt); + public: static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); @@ -163,6 +167,8 @@ class SwXTextFrame : public SwXTextFrameBaseClass, public SwXFrame { protected: + friend class SwXFrame; // just for CreateXFrame + virtual const SwStartNode *GetStartNode() const SAL_OVERRIDE; virtual ::com::sun::star::uno::Reference< @@ -171,10 +177,11 @@ protected: throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE; virtual ~SwXTextFrame(); -public: + SwXTextFrame(SwDoc *pDoc); SwXTextFrame(SwFrmFmt& rFmt); +public: static SW_DLLPUBLIC css::uno::Reference<css::text::XTextFrame> CreateXTextFrame(SwDoc & rDoc, SwFrmFmt * pFrmFmt); @@ -240,11 +247,15 @@ class SwXTextGraphicObject : public SwXTextGraphicObjectBaseClass, public SwXFrame { protected: + friend class SwXFrame; // just for CreateXFrame + virtual ~SwXTextGraphicObject(); -public: + SwXTextGraphicObject( SwDoc *pDoc ); SwXTextGraphicObject(SwFrmFmt& rFmt); +public: + static css::uno::Reference<css::text::XTextContent> CreateXTextGraphicObject(SwDoc & rDoc, SwFrmFmt * pFrmFmt); @@ -288,12 +299,15 @@ class SwXTextEmbeddedObject : public SwXTextEmbeddedObjectBaseClass, public SwXFrame { protected: + friend class SwXFrame; // just for CreateXFrame + virtual ~SwXTextEmbeddedObject(); -public: SwXTextEmbeddedObject( SwDoc *pDoc ); SwXTextEmbeddedObject(SwFrmFmt& rFmt); +public: + static css::uno::Reference<css::text::XTextContent> CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrmFmt * pFrmFmt); diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 3fa2344af41d..6bda581aa904 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -531,22 +531,19 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 break; case SW_SERVICE_TYPE_TEXTFRAME: { - SwXTextFrame* pTextFrame = new SwXTextFrame( pDoc ); - xRet = (cppu::OWeakObject*)(SwXFrame*)pTextFrame; + xRet = SwXTextFrame::CreateXTextFrame(*pDoc, 0); } break; case SW_SERVICE_TYPE_GRAPHIC : case SW_SERVICE_TYPE_TEXT_GRAPHIC /* #i47503# */ : { - SwXTextGraphicObject* pGraphic = new SwXTextGraphicObject( pDoc ); - xRet = (cppu::OWeakObject*)(SwXFrame*)pGraphic; + xRet = SwXTextGraphicObject::CreateXTextGraphicObject(*pDoc, 0); } break; case SW_SERVICE_TYPE_OLE : { - SwXTextEmbeddedObject* pOle = new SwXTextEmbeddedObject( pDoc ); - xRet = (cppu::OWeakObject*)(SwXFrame*)pOle; + xRet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*pDoc, 0); } break; case SW_SERVICE_TYPE_BOOKMARK : diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 5a7b6d7c139d..225f52fd67dc 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1233,7 +1233,7 @@ SwXFrame::~SwXFrame() template<class Interface, class Impl> uno::Reference<Interface> -CreateXFrame(SwDoc & rDoc, SwFrmFmt *const pFrmFmt) +SwXFrame::CreateXFrame(SwDoc & rDoc, SwFrmFmt *const pFrmFmt) { assert(!pFrmFmt || &rDoc == pFrmFmt->GetDoc()); uno::Reference<Interface> xFrame; diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index fc0227af1f92..b901ab2f0bc6 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1670,8 +1670,9 @@ SwXText::convertToTextFrame( aAnchoredFrames.insert(pFrmFmt->GetName()); } - SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc); - const uno::Reference< text::XTextFrame > xNewFrame = pNewFrame; + const uno::Reference<text::XTextFrame> xNewFrame( + SwXTextFrame::CreateXTextFrame(*m_pImpl->m_pDoc, 0)); + SwXTextFrame *const pNewFrame = dynamic_cast<SwXTextFrame*>(xNewFrame.get()); pNewFrame->SetSelection( aStartPam ); try { |