summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/fmtatr2.cxx
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-01-08 17:13:49 +0100
committerMichael Stahl <mst@openoffice.org>2010-01-08 17:13:49 +0100
commit1115bc8db0a08bd3bc99e20919f700d30f286664 (patch)
treed96a61f8c47d054225ca87981f256461e159a8fd /sw/source/core/txtnode/fmtatr2.cxx
parent7aebbae28405cfd42be4d2d681942ed395e4e2af (diff)
swunolocking1: #i105557#: fix locking for SwXMeta:
move SwClient base to pImpl struct, and use UnoImplPtr to lock destructor. replace broken SwClient iteration with a WeakReference in sw::Meta. make constructor protected, and add factory function CreateXMeta. use new XUnoTunnel and XServiceInfo helpers.
Diffstat (limited to 'sw/source/core/txtnode/fmtatr2.cxx')
-rw-r--r--sw/source/core/txtnode/fmtatr2.cxx31
1 files changed, 5 insertions, 26 deletions
diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx
index 066817d5b0..686b4a67af 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -57,7 +57,6 @@
#include <ndtxt.hxx> // for meta
#include <doc.hxx> // for meta
#include <unometa.hxx>
-#include <unotextrange.hxx>
#include <docsh.hxx>
#include <svtools/zforlist.hxx> // GetNumberFormat
@@ -750,6 +749,10 @@ void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew )
{
NotifyChangeTxtNode();
SwModify::Modify(pOld, pNew);
+ if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
+ { // invalidate cached uno object
+ SetXMeta(uno::Reference<rdf::XMetadatable>(0));
+ }
}
// sw::Metadatable
@@ -788,31 +791,7 @@ bool Meta::IsInContent() const
::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable >
Meta::MakeUnoObject()
{
- // re-use existing SwXMeta
- SwClientIter iter( *this );
- SwClient * pClient( iter.First( TYPE( SwXMeta ) ) );
- while (pClient) {
- SwXMeta *const pMeta( dynamic_cast<SwXMeta*>(pClient) );
- if (pMeta && pMeta->GetCoreObject() == this) {
- return pMeta;
- }
- pClient = iter.Next();
- }
-
- // create new SwXMeta
- SwTxtMeta * const pTxtAttr( GetTxtAttr() );
- OSL_ENSURE(pTxtAttr, "MakeUnoObject: no text attr?");
- if (!pTxtAttr) return 0;
- SwTxtNode * const pTxtNode( pTxtAttr->GetTxtNode() );
- OSL_ENSURE(pTxtNode, "MakeUnoObject: no text node?");
- if (!pTxtNode) return 0;
- const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart());
- const uno::Reference<text::XText> xParentText(
- SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) );
- if (!xParentText.is()) return 0;
- return (RES_TXTATR_META == m_pFmt->Which())
- ? new SwXMeta (pTxtNode->GetDoc(), xParentText, 0, pTxtAttr)
- : new SwXMetaField(pTxtNode->GetDoc(), xParentText, 0, pTxtAttr);
+ return SwXMeta::CreateXMeta(*this);
}
/*************************************************************************