summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-12-21 16:48:30 +0100
committerMichael Stahl <mst@openoffice.org>2010-12-21 16:48:30 +0100
commitf9ab560c8b9bb08d3ad7e6b72ea8a8ecbedcdf47 (patch)
tree7b0e30f5f3e8d37aedf937195a56744d6fc5fa5d /sw/inc
parentc6d658988ed10b4bdfe4d66b4deb4e1f79df33ff (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')
-rwxr-xr-xsw/inc/fmtmeta.hxx25
-rw-r--r--sw/inc/ndhints.hxx10
-rw-r--r--sw/inc/swtypes.hxx2
-rw-r--r--sw/inc/txtatr.hxx21
4 files changed, 37 insertions, 21 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
diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx
index c1d210464eb3..34224539e22b 100644
--- a/sw/inc/ndhints.hxx
+++ b/sw/inc/ndhints.hxx
@@ -33,7 +33,6 @@
#include "swtypes.hxx"
-//#include "numrule.hxx"
class SwTxtNode;
class SwRegHistory; // steht im RolBck.hxx
@@ -44,9 +43,16 @@ class SfxPoolItem;
class SfxItemSet;
class SwDoc;
+typedef enum {
+ COPY = true,
+ NEW = false,
+} CopyOrNew_t;
+
+// if COPY then pTxtNode must be given!
SW_DLLPRIVATE SwTxtAttr *
MakeTxtAttr( SwDoc & rDoc, SfxPoolItem & rNew,
- xub_StrLen nStt, xub_StrLen nEnd );
+ xub_StrLen const nStt, xub_StrLen const nEnd,
+ CopyOrNew_t const bIsCopy = NEW, SwTxtNode *const pTxtNode = 0);
SW_DLLPRIVATE SwTxtAttr *
MakeTxtAttr( SwDoc & rDoc, const SfxItemSet & rSet,
xub_StrLen nStt, xub_StrLen nEnd );
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index 0d37e63c367d..d754b450b3b4 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -228,6 +228,8 @@ namespace nsSetAttrMode
// functionality will be disabled)
/// force hint expand (only matters for hints with CH_TXTATR)
const SetAttrMode SETATTR_FORCEHINTEXPAND= 0x0080;
+ /// the inserted item is a copy -- intended for use in ndtxt.cxx
+ const SetAttrMode SETATTR_IS_COPY = 0x0100;
}
//Umrechnung Twip<-> 1/100 mm fuer UNO
diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx
index 65ecd951868c..75be35e44821 100644
--- a/sw/inc/txtatr.hxx
+++ b/sw/inc/txtatr.hxx
@@ -34,6 +34,11 @@
class SwTxtNode; // fuer SwTxtFld
class SwCharFmt;
+namespace sw {
+ class MetaFieldManager;
+}
+
+
// ATT_CHARFMT *********************************************
class SwTxtCharFmt : public SwTxtAttrEnd
@@ -61,7 +66,7 @@ public:
class SwTxtAttrNesting : public SwTxtAttrEnd
{
-public:
+protected:
SwTxtAttrNesting( SfxPoolItem & i_rAttr,
const xub_StrLen i_nStart, const xub_StrLen i_nEnd );
virtual ~SwTxtAttrNesting();
@@ -70,16 +75,20 @@ public:
class SwTxtMeta : public SwTxtAttrNesting
{
private:
- SwTxtNode * m_pTxtNode;
-
-public:
SwTxtMeta( SwFmtMeta & i_rAttr,
const xub_StrLen i_nStart, const xub_StrLen i_nEnd );
+
+public:
+ static SwTxtMeta * CreateTxtMeta(
+ ::sw::MetaFieldManager & i_rTargetDocManager,
+ SwTxtNode *const i_pTargetTxtNode,
+ SwFmtMeta & i_rAttr,
+ xub_StrLen const i_nStart, xub_StrLen const i_nEnd,
+ bool const i_bIsCopy);
+
virtual ~SwTxtMeta();
void ChgTxtNode(SwTxtNode * const pNode);
- SwTxtNode * GetTxtNode() const { return m_pTxtNode; }
-
};