diff options
author | Michael Stahl <mst@openoffice.org> | 2010-12-21 16:48:30 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2010-12-21 16:48:30 +0100 |
commit | f9ab560c8b9bb08d3ad7e6b72ea8a8ecbedcdf47 (patch) | |
tree | 7b0e30f5f3e8d37aedf937195a56744d6fc5fa5d /sw/inc/fmtmeta.hxx | |
parent | c6d658988ed10b4bdfe4d66b4deb4e1f79df33ff (diff) |
sw34bf03: #i115315#: refactor the copying of meta/meta-field:
no longer delay the call to DoCopy() until after the new hint is inserted,
but do it before; this fixes a crash on drag&drop in the same text node.
this is also quite a bit less ugly, but there are still some hacks required:
DoCopy() is now called by a new factory CreateTxtMeta().
DoCopy() needs to know the text node where the hint will be inserted.
so the MakeTxtAttr() function needs to know whether it should insert a copy,
and the target text node.
this requires a new bit in the SetAttrMode enum: SETATTR_IS_COPY.
also, sw::Meta can no longer get the text node from SwTxtMeta, because it is
copied before the SwTxtMeta is inserted, so it now has a SwTxtNode* member.
furthermore the notification stuff is refactored a bit.
Diffstat (limited to 'sw/inc/fmtmeta.hxx')
-rwxr-xr-x | sw/inc/fmtmeta.hxx | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx index d09df11bb1aa..5a382c36fd56 100755 --- a/sw/inc/fmtmeta.hxx +++ b/sw/inc/fmtmeta.hxx @@ -74,17 +74,13 @@ namespace com { namespace sun { namespace star { * <li>The pool item is cloned (because it is non-poolable); the clone * points to the same metadatable entity, but the metadatable entity's * reverse pointer is unchanged.</li> - * <li>A new text hint is created, taking over the new pool item. - * Unfortunately, this also makes the metadatable entity point at the - * cloned pool item.</li> - * <li>The text hint is inserted into the hints array of some text node.</li> - * <li>The DoCopy() method must be called at the new pool item: - * it will clone the metadatable entity (using RegisterAsCopyOf), - * and fix the reverse pointer of the original to point at the - * original pool item. + * <li>The DoCopy() method is called at the new pool item: + * it will clone the metadatable entity (using RegisterAsCopyOf). * This is necessary, because first, a metadatable entity may * only be inserted once into a document, and second, the copy may be * inserted into a different document than the source document!</li> + * <li>A new text hint is created, taking over the new pool item.</li> + * <li>The text hint is inserted into the hints array of some text node.</li> * </ol> */ @@ -99,7 +95,7 @@ class SwFmtMeta : public SfxPoolItem { private: - friend class SwTxtMeta; // needs SetTxtAttr + friend class SwTxtMeta; // needs SetTxtAttr, DoCopy friend class ::sw::Meta; // needs m_pTxtAttr ::boost::shared_ptr< ::sw::Meta > m_pMeta; @@ -108,6 +104,10 @@ private: SwTxtMeta * GetTxtAttr() { return m_pTxtAttr; } void SetTxtAttr(SwTxtMeta * const i_pTxtAttr); + /// this method <em>must</em> be called when the hint is actually copied + void DoCopy(::sw::MetaFieldManager & i_rTargetDocManager, + SwTxtNode & i_rTargetTxtNode); + explicit SwFmtMeta( const USHORT i_nWhich ); public: @@ -119,14 +119,11 @@ public: // SfxPoolItem virtual int operator==( const SfxPoolItem & ) const; virtual SfxPoolItem * Clone( SfxItemPool *pPool = 0 ) const; -// TYPEINFO(); /// notify clients registered at m_pMeta that this meta is being (re-)moved void NotifyChangeTxtNode(SwTxtNode *const pTxtNode); static SwFmtMeta * CreatePoolDefault( const USHORT i_nWhich ); ::sw::Meta * GetMeta() { return m_pMeta.get(); } - /// this method <em>must</em> be called when the hint is actually copied - void DoCopy( SwFmtMeta & rOriginalMeta ); }; @@ -146,6 +143,7 @@ protected: ::com::sun::star::rdf::XMetadatable> m_wXMeta; SwFmtMeta * m_pFmt; + SwTxtNode * m_pTxtNode; SwTxtMeta * GetTxtAttr() const; SwTxtNode * GetTxtNode() const; // returns 0 if not in document (undo) @@ -153,7 +151,8 @@ protected: SwFmtMeta * GetFmtMeta() const { return m_pFmt; } void SetFmtMeta( SwFmtMeta * const i_pFmt ) { m_pFmt = i_pFmt; }; - void NotifyChangeTxtNode(); + void NotifyChangeTxtNodeImpl(); + void NotifyChangeTxtNode(SwTxtNode *const pTxtNode); ::com::sun::star::uno::WeakReference< ::com::sun::star::rdf::XMetadatable> const& GetXMeta() const |