You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2013/12/19 19:51:01 UTC

svn commit: r1552394 [1/4] - in /openoffice/trunk: ./ main/sw/ main/sw/inc/ main/sw/source/core/access/ main/sw/source/core/bastyp/ main/sw/source/core/crsr/ main/sw/source/core/doc/ main/sw/source/core/docnode/ main/sw/source/core/edit/ main/sw/source...

Author: orw
Date: Thu Dec 19 18:50:58 2013
New Revision: 1552394

URL: http://svn.apache.org/r1552394
Log:
123792: complete annotations on text ranges feature

        - rely annotations on text ranges on new annotation marks
        - support arbitrary text ranges for annotations
        - fix undo/redo regarding annotations an text ranges
        - support annotations on overlapping text ranges
        - fix *.docx import for annotations on overlapping text ranges
        - fix ODF import of annotations on text ranges

        cherry-picked from branch ooxml-osba


Added:
    openoffice/trunk/main/sw/inc/txtannotationfld.hxx
      - copied unchanged from r1551954, openoffice/branches/ooxml-osba/main/sw/inc/txtannotationfld.hxx
    openoffice/trunk/main/sw/source/core/crsr/annotationmark.cxx
      - copied unchanged from r1551920, openoffice/branches/ooxml-osba/main/sw/source/core/crsr/annotationmark.cxx
    openoffice/trunk/main/sw/source/core/inc/annotationmark.hxx
      - copied unchanged from r1551920, openoffice/branches/ooxml-osba/main/sw/source/core/inc/annotationmark.hxx
    openoffice/trunk/main/sw/source/ui/docvw/OverlayRanges.cxx
      - copied unchanged from r1551920, openoffice/branches/ooxml-osba/main/sw/source/ui/docvw/OverlayRanges.cxx
    openoffice/trunk/main/sw/source/ui/docvw/OverlayRanges.hxx
      - copied unchanged from r1551920, openoffice/branches/ooxml-osba/main/sw/source/ui/docvw/OverlayRanges.hxx
Modified:
    openoffice/trunk/   (props changed)
    openoffice/trunk/main/sw/Library_sw.mk
    openoffice/trunk/main/sw/inc/IDocumentMarkAccess.hxx
    openoffice/trunk/main/sw/inc/SidebarWin.hxx
    openoffice/trunk/main/sw/inc/doc.hxx
    openoffice/trunk/main/sw/inc/docufld.hxx
    openoffice/trunk/main/sw/inc/hintids.hxx
    openoffice/trunk/main/sw/inc/ndhints.hxx
    openoffice/trunk/main/sw/inc/postithelper.hxx
    openoffice/trunk/main/sw/inc/txatbase.hxx
    openoffice/trunk/main/sw/inc/unobookmark.hxx
    openoffice/trunk/main/sw/inc/unofield.hxx
    openoffice/trunk/main/sw/inc/unoport.hxx
    openoffice/trunk/main/sw/source/core/access/accpara.cxx
    openoffice/trunk/main/sw/source/core/bastyp/init.cxx
    openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx
    openoffice/trunk/main/sw/source/core/crsr/findtxt.cxx
    openoffice/trunk/main/sw/source/core/doc/dbgoutsw.cxx
    openoffice/trunk/main/sw/source/core/doc/docbm.cxx
    openoffice/trunk/main/sw/source/core/doc/doccomp.cxx
    openoffice/trunk/main/sw/source/core/doc/doccorr.cxx
    openoffice/trunk/main/sw/source/core/doc/docdde.cxx
    openoffice/trunk/main/sw/source/core/doc/docedt.cxx
    openoffice/trunk/main/sw/source/core/doc/docfld.cxx
    openoffice/trunk/main/sw/source/core/doc/docfmt.cxx
    openoffice/trunk/main/sw/source/core/doc/doclay.cxx
    openoffice/trunk/main/sw/source/core/doc/tblcpy.cxx
    openoffice/trunk/main/sw/source/core/doc/tblrwcl.cxx
    openoffice/trunk/main/sw/source/core/docnode/ndcopy.cxx
    openoffice/trunk/main/sw/source/core/docnode/nodes.cxx
    openoffice/trunk/main/sw/source/core/docnode/section.cxx
    openoffice/trunk/main/sw/source/core/edit/edfld.cxx
    openoffice/trunk/main/sw/source/core/edit/edlingu.cxx
    openoffice/trunk/main/sw/source/core/fields/docufld.cxx
    openoffice/trunk/main/sw/source/core/fields/postithelper.cxx
    openoffice/trunk/main/sw/source/core/fields/reffld.cxx
    openoffice/trunk/main/sw/source/core/frmedt/fefly1.cxx
    openoffice/trunk/main/sw/source/core/inc/MarkManager.hxx
    openoffice/trunk/main/sw/source/core/inc/UndoDelete.hxx
    openoffice/trunk/main/sw/source/core/inc/crossrefbookmark.hxx
    openoffice/trunk/main/sw/source/core/table/swtable.cxx
    openoffice/trunk/main/sw/source/core/text/inftxt.cxx
    openoffice/trunk/main/sw/source/core/text/itratr.cxx
    openoffice/trunk/main/sw/source/core/text/pormulti.cxx
    openoffice/trunk/main/sw/source/core/text/portxt.cxx
    openoffice/trunk/main/sw/source/core/text/txtfld.cxx
    openoffice/trunk/main/sw/source/core/text/txtfrm.cxx
    openoffice/trunk/main/sw/source/core/txtnode/atrfld.cxx
    openoffice/trunk/main/sw/source/core/txtnode/atrftn.cxx
    openoffice/trunk/main/sw/source/core/txtnode/ndtxt.cxx
    openoffice/trunk/main/sw/source/core/txtnode/thints.cxx
    openoffice/trunk/main/sw/source/core/txtnode/txtatr2.cxx
    openoffice/trunk/main/sw/source/core/undo/rolbck.cxx
    openoffice/trunk/main/sw/source/core/undo/unattr.cxx
    openoffice/trunk/main/sw/source/core/undo/unbkmk.cxx
    openoffice/trunk/main/sw/source/core/undo/undel.cxx
    openoffice/trunk/main/sw/source/core/undo/undobj.cxx
    openoffice/trunk/main/sw/source/core/unocore/unobkm.cxx
    openoffice/trunk/main/sw/source/core/unocore/unofield.cxx
    openoffice/trunk/main/sw/source/core/unocore/unoport.cxx
    openoffice/trunk/main/sw/source/core/unocore/unoportenum.cxx
    openoffice/trunk/main/sw/source/core/view/vprint.cxx
    openoffice/trunk/main/sw/source/filter/ascii/ascatr.cxx
    openoffice/trunk/main/sw/source/filter/html/css1atr.cxx
    openoffice/trunk/main/sw/source/filter/html/htmlatr.cxx
    openoffice/trunk/main/sw/source/filter/html/htmlgrin.cxx
    openoffice/trunk/main/sw/source/filter/html/swhtml.cxx
    openoffice/trunk/main/sw/source/filter/html/wrthtml.cxx
    openoffice/trunk/main/sw/source/filter/writer/writer.cxx
    openoffice/trunk/main/sw/source/filter/ww1/fltshell.cxx
    openoffice/trunk/main/sw/source/filter/ww8/attributeoutputbase.hxx
    openoffice/trunk/main/sw/source/filter/ww8/wrtw8nds.cxx
    openoffice/trunk/main/sw/source/filter/ww8/ww8atr.cxx
    openoffice/trunk/main/sw/source/filter/ww8/ww8par.cxx
    openoffice/trunk/main/sw/source/ui/dialog/uiregionsw.cxx
    openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx
    openoffice/trunk/main/sw/source/ui/docvw/AnnotationWin.cxx
    openoffice/trunk/main/sw/source/ui/docvw/PostItMgr.cxx
    openoffice/trunk/main/sw/source/ui/docvw/SidebarWin.cxx
    openoffice/trunk/main/sw/source/ui/fldui/fldmgr.cxx
    openoffice/trunk/main/sw/source/ui/fldui/fldref.cxx
    openoffice/trunk/main/sw/source/ui/inc/fldmgr.hxx
    openoffice/trunk/main/sw/source/ui/inc/wrtsh.hxx
    openoffice/trunk/main/sw/source/ui/shells/textfld.cxx
    openoffice/trunk/main/sw/source/ui/uiview/view2.cxx
    openoffice/trunk/main/sw/source/ui/uiview/viewmdi.cxx
    openoffice/trunk/main/sw/source/ui/utlui/bookctrl.cxx
    openoffice/trunk/main/sw/source/ui/utlui/content.cxx
    openoffice/trunk/main/sw/source/ui/utlui/navipi.cxx
    openoffice/trunk/main/sw/source/ui/wrtsh/wrtsh2.cxx
    openoffice/trunk/main/sw/source/ui/wrtsh/wrtsh3.cxx
    openoffice/trunk/main/writerfilter/source/dmapper/DomainMapper.cxx
    openoffice/trunk/main/writerfilter/source/dmapper/DomainMapper_Impl.cxx
    openoffice/trunk/main/writerfilter/source/dmapper/DomainMapper_Impl.hxx
    openoffice/trunk/main/writerfilter/source/dmapper/PropertyMap.cxx
    openoffice/trunk/main/xmloff/inc/txtfldi.hxx
    openoffice/trunk/main/xmloff/source/text/txtfldi.cxx
    openoffice/trunk/main/xmloff/source/text/txtparae.cxx

Propchange: openoffice/trunk/
------------------------------------------------------------------------------
  Merged /openoffice/branches/ooxml-osba:r1551920,1551954,1552283

Modified: openoffice/trunk/main/sw/Library_sw.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/Library_sw.mk?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/Library_sw.mk (original)
+++ openoffice/trunk/main/sw/Library_sw.mk Thu Dec 19 18:50:58 2013
@@ -130,6 +130,7 @@ $(eval $(call gb_Library_add_exception_o
 	sw/source/core/bastyp/swregion \
 	sw/source/core/bastyp/swtypes \
 	sw/source/core/bastyp/tabcol \
+	sw/source/core/crsr/annotationmark \
 	sw/source/core/crsr/BlockCursor \
 	sw/source/core/crsr/bookmrk \
 	sw/source/core/crsr/callnk \
@@ -576,6 +577,7 @@ $(eval $(call gb_Library_add_exception_o
 	sw/source/ui/docvw/AnchorOverlayObject \
 	sw/source/ui/docvw/AnnotationMenuButton \
 	sw/source/ui/docvw/AnnotationWin \
+	sw/source/ui/docvw/OverlayRanges \
 	sw/source/ui/docvw/PostItMgr \
 	sw/source/ui/docvw/ShadowOverlayObject \
 	sw/source/ui/docvw/SidebarTxtControl \

Modified: openoffice/trunk/main/sw/inc/IDocumentMarkAccess.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/IDocumentMarkAccess.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/IDocumentMarkAccess.hxx (original)
+++ openoffice/trunk/main/sw/inc/IDocumentMarkAccess.hxx Thu Dec 19 18:50:58 2013
@@ -50,6 +50,7 @@ class IDocumentMarkAccess
             BOOKMARK,
             CROSSREF_HEADING_BOOKMARK,
             CROSSREF_NUMITEM_BOOKMARK,
+            ANNOTATIONMARK,
             TEXT_FIELDMARK,
             CHECKBOX_FIELDMARK,
             NAVIGATOR_REMINDER
@@ -86,6 +87,10 @@ class IDocumentMarkAccess
             const rtl::OUString& rName, 
             const rtl::OUString& rType) = 0;
 
+        virtual sw::mark::IMark* makeAnnotationMark(
+            const SwPaM& rPaM,
+            const ::rtl::OUString& rName ) = 0;
+
         /** Returns a mark in the document for a paragraph.
             If there is none, a mark will be created.
 
@@ -159,6 +164,9 @@ class IDocumentMarkAccess
             const xub_StrLen nOffset) =0;
 
         /** Deletes marks in a range
+
+            Note: navigator reminders are excluded
+
         */
         virtual void deleteMarks(
             const SwNodeIndex& rStt,
@@ -187,15 +195,17 @@ class IDocumentMarkAccess
 
         /** returns a STL-like random access iterator to the begin of the sequence of marks.
         */
-        virtual const_iterator_t getMarksBegin() const =0;
+        virtual const_iterator_t getAllMarksBegin() const =0;
 
         /** returns a STL-like random access iterator to the end of the sequence of marks.
         */
-        virtual const_iterator_t getMarksEnd() const =0;
+        virtual const_iterator_t getAllMarksEnd() const =0;
 
         /** returns the number of marks.
+
+            Note: annotation marks are excluded
         */
-        virtual sal_Int32 getMarksCount() const =0;
+        virtual sal_Int32 getAllMarksCount() const =0;
 
         /** Finds a mark by name.
 
@@ -203,12 +213,12 @@ class IDocumentMarkAccess
             [in] the name of the mark to find.
 
             @returns
-            an iterator pointing to the mark, or pointing to getMarksEnd() if nothing was found. 
+            an iterator pointing to the mark, or pointing to getAllMarksEnd() if nothing was found.
         */
         virtual const_iterator_t findMark(const ::rtl::OUString& rMark) const =0;
 
 
-        // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK)
+        // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
 
         /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
         */
@@ -238,6 +248,17 @@ class IDocumentMarkAccess
         virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
         virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
 
+        // Marks exclusive annotation marks
+        virtual const_iterator_t getCommonMarksBegin() const = 0;
+        virtual const_iterator_t getCommonMarksEnd() const = 0;
+        virtual sal_Int32 getCommonMarksCount() const = 0;
+
+        // Annotation Marks
+        virtual const_iterator_t getAnnotationMarksBegin() const = 0;
+        virtual const_iterator_t getAnnotationMarksEnd() const = 0;
+        virtual sal_Int32 getAnnotationMarksCount() const = 0;
+        virtual const_iterator_t findAnnotationMark( const ::rtl::OUString& rName ) const = 0;
+
         // Returns the MarkType used to create the mark
         static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark);
 

Modified: openoffice/trunk/main/sw/inc/SidebarWin.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/SidebarWin.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/SidebarWin.hxx (original)
+++ openoffice/trunk/main/sw/inc/SidebarWin.hxx Thu Dec 19 18:50:58 2013
@@ -46,9 +46,11 @@ class SwEditWin;
 class SwView;
 class Edit;
 class MenuButton;
-//class SwRedline;
 class SwFrm;
 
+namespace sw { namespace overlay {
+    class OverlayRanges;
+}}
 
 namespace sw { namespace sidebarwindows {
 
@@ -63,7 +65,7 @@ typedef sal_Int64 SwPostItBits;
 
 class SwSidebarWin : public Window
 {
-	public:
+    public:
         SwSidebarWin( SwEditWin& rEditWin,
                       WinBits nBits,
                       SwPostItMgr& aMgr,
@@ -76,7 +78,7 @@ class SwSidebarWin : public Window
                                   long nY,
                                   long nWidth,
                                   long nHeight,
-                                  const SwRect &aRect,
+                                  const SwRect& aAnchorRect,
                                   const long PageBorder);
         void SetPosAndSize();
         void TranslateTopPosition(const long aAmount);
@@ -91,50 +93,57 @@ class SwSidebarWin : public Window
         inline ScrollBar* Scrollbar() { return mpVScrollbar; }
         inline ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;}
         inline ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;}
+        inline ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay;}
 
         long            GetPostItTextHeight();
 
-		void			SwitchToPostIt(sal_uInt16 aDirection);
-		virtual void	SwitchToFieldPos();
+        void            SwitchToPostIt(sal_uInt16 aDirection);
+        virtual void    SwitchToFieldPos();
 
         virtual sal_uInt32 MoveCaret() = 0;
 
-		virtual void	UpdateData() = 0;
-		virtual void	SetPostItText() = 0;
-		virtual void	Delete();
-		virtual void	GotoPos() = 0;
+        virtual void    UpdateData() = 0;
+        virtual void    SetPostItText() = 0;
+        virtual void    Delete();
+        virtual void    GotoPos() = 0;
 
         virtual String  GetAuthor() = 0;
         virtual Date    GetDate() = 0;
         virtual Time    GetTime() = 0;
 
-		void			ExecuteCommand(sal_uInt16 nSlot);
-		void			InitControls();
+        void            ExecuteCommand(sal_uInt16 nSlot);
+        void            InitControls();
         void            HidePostIt();
         void            DoResize();
-		void			ResizeIfNeccessary(long aOldHeight, long aNewHeight);
-		void			SetScrollbar();
+        void            ResizeIfNeccessary(long aOldHeight, long aNewHeight);
+        void            SetScrollbar();
 
-		void			SetVirtualPosSize( const Point& aPoint, const Size& aSize);
-		const Point		VirtualPos()	{ return mPosSize.TopLeft(); }
-		const Size		VirtualSize()	{ return mPosSize.GetSize(); }
+        void            SetVirtualPosSize( const Point& aPoint, const Size& aSize);
+        const Point     VirtualPos()	{ return mPosSize.TopLeft(); }
+        const Size      VirtualSize()	{ return mPosSize.GetSize(); }
 
         void            ShowAnchorOnly(const Point &aPoint);
         void            ShowNote();
         void            HideNote();
 
-		void			ResetAttributes();
+        void            ResetAttributes();
 
         void            SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition);
-		void			SetReadonly(sal_Bool bSet);
-		sal_Bool			IsReadOnly()		{ return mbReadonly;}
-		bool			IsPreview()			{ return nFlags & PB_Preview;}
+        void            SetReadonly(sal_Bool bSet);
+        sal_Bool        IsReadOnly()
+        {
+            return mbReadonly;
+        }
+        bool            IsPreview()
+        {
+            return nFlags & PB_Preview;
+        }
 
-        void            SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor);
+        void         SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor);
         const Color& ColorAnchor() { return mColorAnchor; }
         const Color& ColorDark() { return mColorDark; }
         const Color& ColorLight() { return mColorLight; }
-		void			Rescale();
+        void         Rescale();
 
         void            SetViewState(::sw::sidebarwindows::ViewState bViewState);
 
@@ -142,28 +151,28 @@ class SwSidebarWin : public Window
         void            SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; };
         virtual bool    CalcFollow() = 0;
 
-#if 0
-#endif
+        sal_Int32   GetMetaHeight();
+        sal_Int32   GetMinimumSizeWithMeta();
+        sal_Int32   GetMinimumSizeWithoutMeta();
+        sal_Int32   GetMetaButtonAreaWidth();
+        sal_Int32   GetScrollbarWidth();
 
-		sal_Int32		GetMetaHeight();
-		sal_Int32		GetMinimumSizeWithMeta();
-		sal_Int32		GetMinimumSizeWithoutMeta();
-		sal_Int32		GetMetaButtonAreaWidth();
-		sal_Int32		GetScrollbarWidth();
+        void    SetSpellChecking();
 
-		void			SetSpellChecking();
+        void    ToggleInsMode();
 
-		void			ToggleInsMode();
-
-		virtual	void	ActivatePostIt();
-		virtual void	DeactivatePostIt();
+        virtual void    ActivatePostIt();
+        virtual void    DeactivatePostIt();
 
         void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus,
                                 const Color& aColor);
         SwPostItHelper::SwLayoutStatus GetLayoutStatus() { return mLayoutStatus; }
         Color GetChangeColor() { return mChangeColor; }
 
-		virtual bool	IsProtected() {return mbReadonly;};
+        virtual bool IsProtected()
+        {
+            return mbReadonly;
+        }
 
         DECL_LINK( WindowEventListener, VclSimpleEvent* );
         inline bool IsMouseOverSidebarWin() const { return mbMouseOver; }
@@ -213,6 +222,7 @@ class SwSidebarWin : public Window
 
         sw::sidebarwindows::AnchorOverlayObject* mpAnchor;
         sw::sidebarwindows::ShadowOverlayObject* mpShadow;
+        sw::overlay::OverlayRanges* mpTextRangeOverlay;
 
         Color           mColorAnchor;
         Color           mColorDark;

Modified: openoffice/trunk/main/sw/inc/doc.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/doc.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/doc.hxx (original)
+++ openoffice/trunk/main/sw/inc/doc.hxx Thu Dec 19 18:50:58 2013
@@ -1108,12 +1108,14 @@ public:
 								const SwSelBoxes* pSelBoxes = 0,
 								SwFrmFmt *pParent = 0 );
 
-	void CopyWithFlyInFly( const SwNodeRange& rRg,
-                            const xub_StrLen nEndContentIndex,
-							const SwNodeIndex& rInsPos,
-							sal_Bool bMakeNewFrms = sal_True,
-							sal_Bool bDelRedlines = sal_True,
-							sal_Bool bCopyFlyAtFly = sal_False ) const;
+    void CopyWithFlyInFly(
+        const SwNodeRange& rRg,
+        const xub_StrLen nEndContentIndex,
+        const SwNodeIndex& rInsPos,
+        const SwPaM* pCopiedPaM = NULL,
+        const sal_Bool bMakeNewFrms = sal_True,
+        const sal_Bool bDelRedlines = sal_True,
+        const sal_Bool bCopyFlyAtFly = sal_False ) const;
 
     sal_Bool SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet );
 

Modified: openoffice/trunk/main/sw/inc/docufld.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/docufld.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/docufld.hxx (original)
+++ openoffice/trunk/main/sw/inc/docufld.hxx Thu Dec 19 18:50:58 2013
@@ -500,12 +500,16 @@ public:
 class SwPostItFieldType : public SwFieldType
 {
 private:
-	SwDoc*	mpDoc;
+    SwDoc* mpDoc;
 public:
-	SwPostItFieldType(SwDoc* pDoc);
+    SwPostItFieldType(SwDoc* pDoc);
 
-	virtual SwFieldType*    Copy() const;
-	SwDoc* GetDoc()			{return mpDoc;};
+    virtual SwFieldType* Copy() const;
+
+    SwDoc* GetDoc() const
+    {
+        return mpDoc;
+    };
 };
 
 
@@ -518,7 +522,7 @@ class SW_DLLPUBLIC SwPostItField : publi
     String      msName;             // name (identifier) of the comment/annotation
     DateTime    maDateTime;         // creation date and time
 
-    OutlinerParaObject*	mpText;
+    OutlinerParaObject* mpText;
     SwTextAPIObject* m_pTextObject;
 
 public:
@@ -544,13 +548,13 @@ public:
     }
 
     // Author
-    virtual const String& 	GetPar1() const;
-    virtual void			SetPar1(const String& rStr);
+    virtual const String& GetPar1() const;
+    virtual void SetPar1(const String& rStr);
 
     // Text
-    virtual String          GetPar2() const;
-    virtual void            SetPar2(const String& rStr);
-    inline const String&    GetContent() const
+    virtual String GetPar2() const;
+    virtual void SetPar2(const String& rStr);
+    inline const String& GetContent() const
     {
         return msCommentContent;
     }
@@ -559,7 +563,7 @@ public:
     void SetName(const String& rStr);
     const String& GetName() const;
 
-    const OutlinerParaObject*	GetTextObject() const;
+    const OutlinerParaObject* GetTextObject() const;
     void SetTextObject( OutlinerParaObject* pText );
 
     sal_uInt32 GetNumberOfParagraphs() const;

Modified: openoffice/trunk/main/sw/inc/hintids.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/hintids.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/hintids.hxx (original)
+++ openoffice/trunk/main/sw/inc/hintids.hxx Thu Dec 19 18:50:58 2013
@@ -141,7 +141,7 @@ RES_TXTATR_NOEND_BEGIN = RES_TXTATR_WITH
     RES_TXTATR_FIELD = RES_TXTATR_NOEND_BEGIN,      // 53
     RES_TXTATR_FLYCNT,                              // 54
     RES_TXTATR_FTN,                                 // 55
-    RES_TXTATR_DUMMY4,                              // 56
+    RES_TXTATR_ANNOTATION,                          // 56
     RES_TXTATR_DUMMY3,                              // 57
     RES_TXTATR_DUMMY1,                              // 58
     RES_TXTATR_DUMMY2,                              // 59

Modified: openoffice/trunk/main/sw/inc/ndhints.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/ndhints.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/ndhints.hxx (original)
+++ openoffice/trunk/main/sw/inc/ndhints.hxx Thu Dec 19 18:50:58 2013
@@ -45,17 +45,24 @@ typedef enum {
 } CopyOrNew_t;
 
 // if COPY then pTxtNode must be given!
-SW_DLLPRIVATE SwTxtAttr *
-MakeTxtAttr( SwDoc & rDoc, SfxPoolItem & rNew,
-        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 );
+SW_DLLPRIVATE SwTxtAttr * MakeTxtAttr(
+    SwDoc & rDoc,
+    SfxPoolItem & rNew,
+    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 );
 
 // create redline dummy text hint that must not be inserted into hints array
-SW_DLLPRIVATE SwTxtAttr*
-MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr );
+SW_DLLPRIVATE SwTxtAttr* MakeRedlineTxtAttr(
+    SwDoc & rDoc,
+    SfxPoolItem& rAttr );
 
 
 /*

Modified: openoffice/trunk/main/sw/inc/postithelper.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/postithelper.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/postithelper.hxx (original)
+++ openoffice/trunk/main/sw/inc/postithelper.hxx Thu Dec 19 18:50:58 2013
@@ -49,15 +49,24 @@ struct SwLayoutInfo
 {
     const SwFrm* mpAnchorFrm;
     SwRect mPosition;
+
+    // optional start of the annotation
+    sal_uLong mnStartNodeIdx;
+    xub_StrLen mnStartContent;
+
     SwRect mPageFrame;
     SwRect mPagePrtArea;
     unsigned long mnPageNumber;
+
     sw::sidebarwindows::SidebarPosition meSidebarPosition;
-	sal_uInt16 mRedlineAuthor;
+
+    sal_uInt16 mRedlineAuthor;
 
     SwLayoutInfo()
         : mpAnchorFrm(0)
         , mPosition()
+        , mnStartNodeIdx( 0 )
+        , mnStartContent( STRING_NOTFOUND )
         , mPageFrame()
         , mPagePrtArea()
         , mnPageNumber(1)
@@ -73,7 +82,11 @@ namespace SwPostItHelper
         INVISIBLE, VISIBLE, INSERTED, DELETED, NONE, HIDDEN
     };
 
-    SwLayoutStatus getLayoutInfos( std::vector< SwLayoutInfo >&, SwPosition& );
+    SwLayoutStatus getLayoutInfos(
+        SwLayoutInfo& o_rInfo,
+        const SwPosition& rAnchorPos,
+        const SwPosition* pAnnotationStartPos = NULL );
+
     long getLayoutHeight( const SwRootFrm* pRoot );
     void setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode );
     unsigned long getPageInfo( SwRect& rPageFrm, const SwRootFrm* , const Point& );
@@ -96,12 +109,17 @@ public:
         , bFocus(aFocus)
         , mLayoutStatus( SwPostItHelper::INVISIBLE )
         , maLayoutInfo()
-	{}
-    virtual ~SwSidebarItem(){}
+    {
+    }
+
+    virtual ~SwSidebarItem()
+    {
+    }
+
     virtual SwPosition GetAnchorPosition() const = 0;
-	virtual bool UseElement() = 0;
-    virtual SwFmtFld* GetFmtFld() const = 0;
-	virtual SfxBroadcaster* GetBroadCaster() const = 0;
+    virtual bool UseElement() = 0;
+    virtual const SwFmtFld& GetFmtFld() const = 0;
+    virtual const SfxBroadcaster* GetBroadCaster() const = 0;
     virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( SwEditWin& rEditWin,
                                                                 WinBits nBits,
                                                                 SwPostItMgr& aMgr,
@@ -131,25 +149,38 @@ public:
 
 class SwAnnotationItem: public SwSidebarItem
 {
-	private:
-	SwFmtFld* pFmtFld;
+public:
+    SwAnnotationItem(
+        SwFmtFld& rFmtFld,
+        const bool bShow,
+        const bool bFocus)
+        : SwSidebarItem( bShow, bFocus )
+        , mrFmtFld( rFmtFld )
+    {
+    }
+
+    virtual ~SwAnnotationItem()
+    {
+    }
 
-	public:
-    SwAnnotationItem( SwFmtFld* p,
-                      const bool aShow,
-                      const bool aFocus)
-        : SwSidebarItem( aShow, aFocus )
-        , pFmtFld(p)
-    {}
-    virtual ~SwAnnotationItem() {}
     virtual SwPosition GetAnchorPosition() const;
-	virtual bool UseElement();
-    virtual SwFmtFld* GetFmtFld() const {return pFmtFld;}
-	virtual SfxBroadcaster* GetBroadCaster() const { return dynamic_cast<SfxBroadcaster *> (pFmtFld); }
-    virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( SwEditWin& rEditWin,
-                                                                WinBits nBits,
-                                                                SwPostItMgr& aMgr,
-                                                                SwPostItBits aBits);
+    virtual bool UseElement();
+    virtual const SwFmtFld& GetFmtFld() const
+    {
+        return mrFmtFld;
+    }
+    virtual const SfxBroadcaster* GetBroadCaster() const
+    {
+        return dynamic_cast<const SfxBroadcaster *> (&mrFmtFld);
+    }
+    virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow(
+        SwEditWin& rEditWin,
+        WinBits nBits,
+        SwPostItMgr& aMgr,
+        SwPostItBits aBits );
+
+private:
+    SwFmtFld& mrFmtFld;
 };
 
 #endif // _POSTITHELPER_HXX

Modified: openoffice/trunk/main/sw/inc/txatbase.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/txatbase.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/txatbase.hxx (original)
+++ openoffice/trunk/main/sw/inc/txatbase.hxx Thu Dec 19 18:50:58 2013
@@ -187,6 +187,7 @@ inline const SwFmtFld& SwTxtAttr::GetFmt
 {
     ASSERT( m_pAttr
             && ( m_pAttr->Which() == RES_TXTATR_FIELD
+                 || m_pAttr->Which() == RES_TXTATR_ANNOTATION
                  || m_pAttr->Which() == RES_TXTATR_INPUTFIELD ),
             "Wrong attribute" );
     return (const SwFmtFld&)(*m_pAttr);

Modified: openoffice/trunk/main/sw/inc/unobookmark.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/unobookmark.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/unobookmark.hxx (original)
+++ openoffice/trunk/main/sw/inc/unobookmark.hxx Thu Dec 19 18:50:58 2013
@@ -88,7 +88,7 @@ public:
     /// descriptor
     SwXBookmark();
 
-    static ::com::sun::star::uno::Reference<::com::sun::star::text::XTextContent>
+    static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
         CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark);
 
     /// @return IMark for this, but only if it lives in pDoc
@@ -246,7 +246,7 @@ public:
     SwXFieldmark( bool isReplacementObject );
 
     // (as the parent class) newly created <SwXFieldmark> instances for an existing <IMark> instance needs to be registered in the Mark
-    static ::com::sun::star::uno::Reference<::com::sun::star::text::XTextContent>
+    static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
         CreateXFieldmark(
             SwDoc & rDoc,
             ::sw::mark::IMark & rBookmark );

Modified: openoffice/trunk/main/sw/inc/unofield.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/unofield.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/unofield.hxx (original)
+++ openoffice/trunk/main/sw/inc/unofield.hxx Thu Dec 19 18:50:58 2013
@@ -129,8 +129,8 @@ class SwXTextField : public cppu::WeakIm
 >,
 			public SwClient
 {
-	SwEventListenerContainer	aLstnrCntnr;
-	const SwFmtFld* 			pFmtFld;
+	SwEventListenerContainer	m_aLstnrCntnr;
+	const SwFmtFld* 			m_pFmtFld;
 	SwDoc* 						m_pDoc;
 	SwTextAPIObject*			m_pTextObject;
 
@@ -197,7 +197,7 @@ public:
 	void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
 
 	const SwField*  	GetField() const;
-	const SwFmtFld* 	GetFldFmt(){return GetField() ? pFmtFld : 0; };
+	const SwFmtFld* 	GetFldFmt(){return GetField() ? m_pFmtFld : 0; };
 
 	void Invalidate();
 

Modified: openoffice/trunk/main/sw/inc/unoport.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/unoport.hxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/unoport.hxx (original)
+++ openoffice/trunk/main/sw/inc/unoport.hxx Thu Dec 19 18:50:58 2013
@@ -81,7 +81,9 @@ enum SwTextPortionType
     PORTION_META,
 	PORTION_FIELD_START,
 	PORTION_FIELD_END,
-	PORTION_FIELD_START_END
+	PORTION_FIELD_START_END,
+    PORTION_ANNOTATION,
+    PORTION_ANNOTATION_END
 };
 
 

Modified: openoffice/trunk/main/sw/source/core/access/accpara.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/access/accpara.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/access/accpara.cxx (original)
+++ openoffice/trunk/main/sw/source/core/access/accpara.cxx Thu Dec 19 18:50:58 2013
@@ -1650,12 +1650,16 @@ String SwAccessibleParagraph::GetFieldTy
 			for( sal_uInt16 i = 0; i < nSize; ++i ) 
 			{
 				const SwTxtAttr* pHt = (*pSwpHints)[i];
-				if (pHt->Which() == RES_TXTATR_FIELD && (nFldIndex-- == 0))
+				if ( ( pHt->Which() == RES_TXTATR_FIELD
+                       || pHt->Which() == RES_TXTATR_ANNOTATION
+                       || pHt->Which() == RES_TXTATR_INPUTFIELD )
+                     && (nFldIndex-- == 0))
 				{
 					pTxtFld = (SwTxtFld *)pHt;
 					break;
 				}
-				else if (pHt->Which() == RES_TXTATR_REFMARK && (nFldIndex-- == 0))
+				else if ( pHt->Which() == RES_TXTATR_REFMARK
+                          && (nFldIndex-- == 0) )
 					strTypeName = String(OUString(RTL_CONSTASCII_USTRINGPARAM("set reference")));
 			}
 		}

Modified: openoffice/trunk/main/sw/source/core/bastyp/init.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/bastyp/init.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/bastyp/init.cxx (original)
+++ openoffice/trunk/main/sw/source/core/bastyp/init.cxx Thu Dec 19 18:50:58 2013
@@ -320,7 +320,7 @@ SfxItemInfo __FAR_DATA aSlotTab[] =
     { 0, 0 },                                           // RES_TXTATR_FIELD
     { 0, 0 },                                           // RES_TXTATR_FLYCNT
     { 0, 0 },                                           // RES_TXTATR_FTN
-    { 0, SFX_ITEM_POOLABLE },                           // RES_TXTATR_DUMMY4
+    { 0, 0 },                                           // RES_TXTATR_ANNOTATION
     { 0, SFX_ITEM_POOLABLE },                           // RES_TXTATR_DUMMY3
     { 0, SFX_ITEM_POOLABLE },                           // RES_TXTATR_DUMMY1
     { 0, SFX_ITEM_POOLABLE },                           // RES_TXTATR_DUMMY2
@@ -533,9 +533,9 @@ void _InitCore()
     aAttrTab[ RES_TXTATR_FIELD- POOLATTR_BEGIN ] = new SwFmtFld( RES_TXTATR_FIELD );
     aAttrTab[ RES_TXTATR_FLYCNT - POOLATTR_BEGIN ] = new SwFmtFlyCnt( 0 );
     aAttrTab[ RES_TXTATR_FTN - POOLATTR_BEGIN ] = new SwFmtFtn;
+    aAttrTab[ RES_TXTATR_ANNOTATION - POOLATTR_BEGIN ] = new SwFmtFld( RES_TXTATR_ANNOTATION );
 
 // TextAttr - Dummies
-    aAttrTab[ RES_TXTATR_DUMMY4 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY4 );
     aAttrTab[ RES_TXTATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY3 );
     aAttrTab[ RES_TXTATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY1 );
     aAttrTab[ RES_TXTATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY2 );

Modified: openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx (original)
+++ openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx Thu Dec 19 18:50:58 2013
@@ -184,7 +184,6 @@ namespace sw { namespace mark
         if(nCount == SAL_MAX_INT32)
         {
             sal_Int32 nRandom;
-            ::rtl::OUStringBuffer sUniquePostfixBuffer;
             rtl_random_getBytes(aPool, &nRandom, sizeof(nRandom));
             sUniquePostfix = ::rtl::OUStringBuffer(13).appendAscii("_").append(static_cast<sal_Int32>(abs(nRandom))).makeStringAndClear();
             nCount = 0;

Modified: openoffice/trunk/main/sw/source/core/crsr/findtxt.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/crsr/findtxt.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/crsr/findtxt.cxx (original)
+++ openoffice/trunk/main/sw/source/core/crsr/findtxt.cxx Thu Dec 19 18:50:58 2013
@@ -131,14 +131,16 @@ String& lcl_CleanStr(
                 case RES_TXTATR_FLYCNT:
                 case RES_TXTATR_FTN:
                 case RES_TXTATR_FIELD:
+                case RES_TXTATR_ANNOTATION:
                 case RES_TXTATR_REFMARK:
                 case RES_TXTATR_TOXMARK:
                 case RES_TXTATR_META:
                 case RES_TXTATR_METAFIELD:
                     {
-                        sal_Bool bEmpty = RES_TXTATR_FIELD != pHt->Which() ||
-                            !(static_cast<SwTxtFld const*>(pHt)
-                                ->GetFmtFld().GetField()->ExpandField(true).Len());
+                        const bool bEmpty =
+                            ( pHt->Which() != RES_TXTATR_FIELD
+                              && pHt->Which() != RES_TXTATR_ANNOTATION )
+                            || !(static_cast<SwTxtFld const*>(pHt)->GetFmtFld().GetField()->ExpandField(true).Len());
                         if ( bEmpty && nStart == nAkt )
                         {
                             rArr.Insert( nAkt, rArr.Count() );
@@ -195,8 +197,7 @@ xub_StrLen GetPostIt(xub_StrLen aCount,c
         {
             aIndex++;
             const SwTxtAttr* pTxtAttr = (*pHts)[i];
-            if ( (pTxtAttr->Which()==RES_TXTATR_FIELD)
-                 && (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD))
+            if ( pTxtAttr->Which() == RES_TXTATR_ANNOTATION )
             {
                 aCount--;
                 if (!aCount)
@@ -208,8 +209,7 @@ xub_StrLen GetPostIt(xub_StrLen aCount,c
     for (xub_StrLen i = aIndex; i <pHts->Count();i++)
     {
         const SwTxtAttr* pTxtAttr = (*pHts)[i];
-        if ( (pTxtAttr->Which()==RES_TXTATR_FIELD)
-             && (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD))
+        if ( pTxtAttr->Which() == RES_TXTATR_ANNOTATION )
             break;
         else
             aIndex++;
@@ -303,8 +303,7 @@ sal_uInt8 SwPaM::Find( const SearchOptio
                 {
                     const xub_StrLen aPos = *(*pHts)[i]->GetStart();
                     const SwTxtAttr* pTxtAttr = (*pHts)[i];
-                    if ( (pTxtAttr->Which()==RES_TXTATR_FIELD)
-                         && (pTxtAttr->GetFmtFld().GetField()->Which()==RES_POSTITFLD))
+                    if ( pTxtAttr->Which()==RES_TXTATR_ANNOTATION )
                     {
                         if ( (aPos >= nStart) && (aPos <= nEnde) )
                             aNumberPostits++;

Modified: openoffice/trunk/main/sw/source/core/doc/dbgoutsw.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/dbgoutsw.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/dbgoutsw.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/dbgoutsw.cxx Thu Dec 19 18:50:58 2013
@@ -178,7 +178,7 @@ map<sal_uInt16,String,CompareUShort> & G
         aItemWhichMap[RES_TXTATR_FIELD] = String("TXTATR_FIELD", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_TXTATR_FLYCNT] = String("TXTATR_FLYCNT", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_TXTATR_FTN] = String("TXTATR_FTN", RTL_TEXTENCODING_ASCII_US);
-        aItemWhichMap[RES_TXTATR_DUMMY4] = String("TXTATR_DUMMY4", RTL_TEXTENCODING_ASCII_US);
+        aItemWhichMap[RES_TXTATR_ANNOTATION] = String("TXTATR_ANNOTATION", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_TXTATR_DUMMY3] = String("TXTATR_DUMMY3", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_TXTATR_DUMMY1] = String("TXTATR_DUMMY1", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_TXTATR_DUMMY2] = String("TXTATR_DUMMY2", RTL_TEXTENCODING_ASCII_US);

Modified: openoffice/trunk/main/sw/source/core/doc/docbm.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/docbm.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/docbm.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/docbm.cxx Thu Dec 19 18:50:58 2013
@@ -30,6 +30,7 @@
 #include <boost/bind.hpp>
 #include <cntfrm.hxx>
 #include <crossrefbookmark.hxx>
+#include <annotationmark.hxx>
 #include <dcontact.hxx>
 #include <doc.hxx>
 #include <docary.hxx>
@@ -279,6 +280,8 @@ IDocumentMarkAccess::MarkType IDocumentM
         return CROSSREF_HEADING_BOOKMARK;
     else if(*pMarkTypeInfo == typeid(CrossRefNumItemBookmark))
         return CROSSREF_NUMITEM_BOOKMARK;
+    else if(*pMarkTypeInfo == typeid(AnnotationMark))
+        return ANNOTATIONMARK;
     else if(*pMarkTypeInfo == typeid(TextFieldmark))
         return TEXT_FIELDMARK;
     else if(*pMarkTypeInfo == typeid(CheckboxFieldmark))
@@ -317,20 +320,15 @@ bool SAL_DLLPUBLIC_EXPORT IDocumentMarkA
 namespace sw { namespace mark
 {
     MarkManager::MarkManager(SwDoc& rDoc)
-        : m_pDoc(&rDoc)
+        : m_vAllMarks()
+        , m_vBookmarks()
+        , m_vFieldmarks()
+        , m_vAnnotationMarks()
+        , m_vCommonMarks()
+        , m_pDoc(&rDoc)
     { }
-#if OSL_DEBUG_LEVEL > 1
-    void MarkManager::dumpFieldmarks( ) const
-    {
-        const_iterator_t pIt = m_vFieldmarks.begin();
-        for (; pIt != m_vFieldmarks.end( ); pIt++)
-        {
-            rtl::OUString str = (*pIt)->ToString();
-            OSL_TRACE("%s\n",
-                ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr());
-        }
-    }
-#endif
+
+
     ::sw::mark::IMark* MarkManager::makeMark(const SwPaM& rPaM,
         const ::rtl::OUString& rName,
         const IDocumentMarkAccess::MarkType eType)
@@ -351,7 +349,7 @@ namespace sw { namespace mark
         }
 #endif
         // see for example _SaveCntntIdx, Shells
-        OSL_PRECOND(m_vMarks.size() < USHRT_MAX,
+        OSL_PRECOND(m_vAllMarks.size() < USHRT_MAX,
             "MarkManager::makeMark(..)"
             " - more than USHRT_MAX marks are not supported correctly");
         // There should only be one CrossRefBookmark per Textnode per Type
@@ -389,6 +387,9 @@ namespace sw { namespace mark
             case IDocumentMarkAccess::UNO_BOOKMARK:
                 pMarkBase = new UnoMark(rPaM);
                 break;
+            case IDocumentMarkAccess::ANNOTATIONMARK:
+                pMarkBase = new AnnotationMark( rPaM, rName );
+                break;
         }
         OSL_ENSURE( pMarkBase!=NULL,
             "MarkManager::makeMark(..)"
@@ -399,35 +400,41 @@ namespace sw { namespace mark
             pMarkBase->Swap();
 
         // for performance reasons, we trust UnoMarks to have a (generated) unique name
-        if(eType != IDocumentMarkAccess::UNO_BOOKMARK)
-            pMarkBase->SetName(getUniqueMarkName(pMarkBase->GetName()));
+        if ( eType != IDocumentMarkAccess::UNO_BOOKMARK )
+            pMarkBase->SetName( getUniqueMarkName( pMarkBase->GetName() ) );
 
         // register mark
-        lcl_InsertMarkSorted(m_vMarks, pMark);
+        lcl_InsertMarkSorted( m_vAllMarks, pMark );
         switch(eType)
         {
             case IDocumentMarkAccess::BOOKMARK:
             case IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK:
             case IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK:
-            // if(dynamic_cast<IBookmark*>)
+                lcl_InsertMarkSorted(m_vCommonMarks, pMark);
+                // if(dynamic_cast<IBookmark*>)
                 lcl_InsertMarkSorted(m_vBookmarks, pMark);
                 break;
             case IDocumentMarkAccess::TEXT_FIELDMARK:
             case IDocumentMarkAccess::CHECKBOX_FIELDMARK:
-            // if(dynamic_cast<IFieldmark*>
+                lcl_InsertMarkSorted(m_vCommonMarks, pMark);
+                // if(dynamic_cast<IFieldmark*>
                 lcl_InsertMarkSorted(m_vFieldmarks, pMark);
                 break;
+            case IDocumentMarkAccess::ANNOTATIONMARK:
+                lcl_InsertMarkSorted( m_vAnnotationMarks, pMark );
+                break;
             case IDocumentMarkAccess::NAVIGATOR_REMINDER:
             case IDocumentMarkAccess::DDE_BOOKMARK:
             case IDocumentMarkAccess::UNO_BOOKMARK:
-            // no special array for these
+                lcl_InsertMarkSorted(m_vCommonMarks, pMark);
+                // no special array for these
                 break;
         }
         pMarkBase->InitDoc(m_pDoc);
 #if 0
         OSL_TRACE("--- makeType ---");
         OSL_TRACE("Marks");
-        lcl_DebugMarks(m_vMarks);
+        lcl_DebugMarks(m_vAllMarks);
         OSL_TRACE("Bookmarks");
         lcl_DebugMarks(m_vBookmarks);
         OSL_TRACE("Fieldmarks");
@@ -436,7 +443,9 @@ namespace sw { namespace mark
         return pMark.get();
     }
 
-    ::sw::mark::IFieldmark* MarkManager::makeFieldBookmark( const SwPaM& rPaM,
+
+    ::sw::mark::IFieldmark* MarkManager::makeFieldBookmark(
+        const SwPaM& rPaM,
         const rtl::OUString& rName,
         const rtl::OUString& rType )
     {
@@ -447,9 +456,11 @@ namespace sw { namespace mark
 
         return pFieldMark;
     }
-            
-    ::sw::mark::IFieldmark* MarkManager::makeNoTextFieldBookmark( const SwPaM& rPaM, 
-        const rtl::OUString& rName, 
+
+
+    ::sw::mark::IFieldmark* MarkManager::makeNoTextFieldBookmark(
+        const SwPaM& rPaM,
+        const rtl::OUString& rName,
         const rtl::OUString& rType)
     {
         sw::mark::IMark* pMark = makeMark( rPaM, rName, 
@@ -460,8 +471,10 @@ namespace sw { namespace mark
         return pFieldMark;
     }
 
-    ::sw::mark::IMark* MarkManager::getMarkForTxtNode(const SwTxtNode& rTxtNode,
-        const IDocumentMarkAccess::MarkType eType)
+
+    ::sw::mark::IMark* MarkManager::getMarkForTxtNode(
+        const SwTxtNode& rTxtNode,
+        const IDocumentMarkAccess::MarkType eType )
     {
         SwPosition aPos(rTxtNode);
         aPos.nContent.Assign(&(const_cast<SwTxtNode&>(rTxtNode)), 0);
@@ -472,7 +485,16 @@ namespace sw { namespace mark
         return makeMark(aPaM, ::rtl::OUString(), eType);
     }
 
-    void MarkManager::repositionMark( ::sw::mark::IMark* const io_pMark,
+
+    sw::mark::IMark* MarkManager::makeAnnotationMark(
+        const SwPaM& rPaM,
+        const ::rtl::OUString& rName )
+    {
+        return makeMark( rPaM, rName, IDocumentMarkAccess::ANNOTATIONMARK );
+    }
+
+    void MarkManager::repositionMark(
+        ::sw::mark::IMark* const io_pMark,
         const SwPaM& rPaM)
     {
         OSL_PRECOND(io_pMark->GetMarkPos().GetDoc() == m_pDoc,
@@ -491,37 +513,46 @@ namespace sw { namespace mark
         sortMarks();
     }
 
-    bool MarkManager::renameMark(::sw::mark::IMark* io_pMark, const ::rtl::OUString& rNewName)
+
+    bool MarkManager::renameMark(
+        ::sw::mark::IMark* io_pMark,
+        const ::rtl::OUString& rNewName )
     {
         OSL_PRECOND(io_pMark->GetMarkPos().GetDoc() == m_pDoc,
             "<MarkManager::repositionMark(..)>"
             " - Mark is not in my doc.");
-        if(io_pMark->GetName() == rNewName)
+        if ( io_pMark->GetName() == rNewName )
             return true;
-        if(findMark(rNewName) != getMarksEnd())
+        if ( findMark(rNewName) != m_vAllMarks.end() )
             return false;
         dynamic_cast< ::sw::mark::MarkBase* >(io_pMark)->SetName(rNewName);
         return true;
     }
 
-    void MarkManager::correctMarksAbsolute(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const xub_StrLen nOffset)
+
+    void MarkManager::correctMarksAbsolute(
+        const SwNodeIndex& rOldNode,
+        const SwPosition& rNewPos,
+        const xub_StrLen nOffset)
     {
         const SwNode* const pOldNode = &rOldNode.GetNode();
         SwPosition aNewPos(rNewPos);
         aNewPos.nContent += nOffset;
         bool isSortingNeeded = false;
-        for(iterator_t ppMark = m_vMarks.begin();
-            ppMark != m_vMarks.end();
+
+        for(iterator_t ppMark = m_vAllMarks.begin();
+            ppMark != m_vAllMarks.end();
             ppMark++)
         {
-            // is on position ??
-            bool bChangedPos = false, bChangedOPos = false;
             ::sw::mark::MarkBase* pMark = dynamic_cast< ::sw::mark::MarkBase* >(ppMark->get());
+            // is on position ??
+            bool bChangedPos = false;
             if(&pMark->GetMarkPos().nNode.GetNode() == pOldNode)
             {
                 pMark->SetMarkPos(aNewPos);
                 bChangedPos = true;
             }
+            bool bChangedOPos = false;
             if (pMark->IsExpanded() &&
                 &pMark->GetOtherMarkPos().nNode.GetNode() == pOldNode)
             {
@@ -531,23 +562,26 @@ namespace sw { namespace mark
             // illegal selection? collapse the mark and restore sorting later
             isSortingNeeded |= lcl_FixCorrectedMark(bChangedPos, bChangedOPos, pMark);
         }
+
         // restore sorting if needed
         if(isSortingNeeded)
             sortMarks();
 #if 0
         OSL_TRACE("correctMarksAbsolute");
-        lcl_DebugMarks(m_vMarks);
+        lcl_DebugMarks(m_vAllMarks);
 #endif
     }
 
+
     void MarkManager::correctMarksRelative(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const xub_StrLen nOffset)
     {
         const SwNode* const pOldNode = &rOldNode.GetNode();
         SwPosition aNewPos(rNewPos);
         aNewPos.nContent += nOffset;
         bool isSortingNeeded = false;
-        for(iterator_t ppMark = m_vMarks.begin();
-            ppMark != m_vMarks.end();
+
+        for(iterator_t ppMark = m_vAllMarks.begin();
+            ppMark != m_vAllMarks.end();
             ppMark++)
         {
             // is on position ??
@@ -571,15 +605,17 @@ namespace sw { namespace mark
             // illegal selection? collapse the mark and restore sorting later
             isSortingNeeded |= lcl_FixCorrectedMark(bChangedPos, bChangedOPos, pMark);
         }
+
         // restore sorting if needed
         if(isSortingNeeded)
             sortMarks();
 #if 0
         OSL_TRACE("correctMarksRelative");
-        lcl_DebugMarks(m_vMarks);
+        lcl_DebugMarks(m_vAllMarks);
 #endif
     }
 
+
     void MarkManager::deleteMarks(
             const SwNodeIndex& rStt,
             const SwNodeIndex& rEnd,
@@ -589,10 +625,11 @@ namespace sw { namespace mark
     {
         vector<const_iterator_t> vMarksToDelete;
         bool isSortingNeeded = false;
+
         // copy all bookmarks in the move area to a vector storing all position data as offset
         // reassignment is performed after the move
-        for(iterator_t ppMark = m_vMarks.begin();
-            ppMark != m_vMarks.end();
+        for(iterator_t ppMark = m_vAllMarks.begin();
+            ppMark != m_vAllMarks.end();
             ppMark++)
         {
             // navigator marks should not be moved
@@ -679,7 +716,7 @@ namespace sw { namespace mark
         }
 
         // we just remembered the iterators to delete, so we do not need to search
-        // for the shared_ptr<> (the entry in m_vMarks) again
+        // for the shared_ptr<> (the entry in m_vAllMarks) again
         // reverse iteration, since erasing an entry invalidates iterators
         // behind it (the iterators in vMarksToDelete are sorted)
         for(vector<const_iterator_t>::reverse_iterator pppMark = vMarksToDelete.rbegin();
@@ -692,49 +729,69 @@ namespace sw { namespace mark
             sortMarks();
 #if 0
         OSL_TRACE("deleteMarks");
-        lcl_DebugMarks(m_vMarks);
+        lcl_DebugMarks(m_vAllMarks);
 #endif
     }
 
+
     void MarkManager::deleteMark(const const_iterator_t ppMark)
     {
-        if(ppMark == m_vMarks.end()) return;
+        if(ppMark == m_vAllMarks.end()) return;
 
         switch(IDocumentMarkAccess::GetType(**ppMark))
         {
             case IDocumentMarkAccess::BOOKMARK:
             case IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK:
             case IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK:
-            // if(dynamic_cast<IBookmark*>)
-            {
-                IDocumentMarkAccess::iterator_t ppBookmark = lcl_FindMark(m_vBookmarks, *ppMark);
-                OSL_ENSURE(ppBookmark != m_vBookmarks.end(),
-                    "<MarkManager::deleteMark(..)>"
-                    " - Bookmark not found.");
-                m_vBookmarks.erase(ppBookmark);
+                // if(dynamic_cast<IBookmark*>)
+                {
+                    IDocumentMarkAccess::iterator_t ppBookmark = lcl_FindMark(m_vBookmarks, *ppMark);
+                    OSL_ENSURE(ppBookmark != m_vBookmarks.end(),
+                        "<MarkManager::deleteMark(..)>"
+                        " - Bookmark not found.");
+                    m_vBookmarks.erase(ppBookmark);
+
+                    ppBookmark = lcl_FindMark(m_vCommonMarks, *ppMark);
+                    m_vCommonMarks.erase(ppBookmark);
+                }
                 break;
-            }
+
             case IDocumentMarkAccess::TEXT_FIELDMARK:
             case IDocumentMarkAccess::CHECKBOX_FIELDMARK:
-            // if(dynamic_cast<IFieldmark*>
-            {
-                IDocumentMarkAccess::iterator_t ppFieldmark = lcl_FindMark(m_vFieldmarks, *ppMark);
-                OSL_ENSURE(ppFieldmark != m_vFieldmarks.end(),
-                    "<MarkManager::deleteMark(..)>"
-                    " - Bookmark not found.");
-                m_vFieldmarks.erase(ppFieldmark);
+                // if(dynamic_cast<IFieldmark*>
+                {
+                    IDocumentMarkAccess::iterator_t ppFieldmark = lcl_FindMark(m_vFieldmarks, *ppMark);
+                    OSL_ENSURE(ppFieldmark != m_vFieldmarks.end(),
+                        "<MarkManager::deleteMark(..)>"
+                        " - Bookmark not found.");
+                    m_vFieldmarks.erase(ppFieldmark);
 
-                sw::mark::TextFieldmark* pTextFieldmark = dynamic_cast<sw::mark::TextFieldmark*>(ppMark->get());
-                if ( pTextFieldmark )
+                    sw::mark::TextFieldmark* pTextFieldmark = dynamic_cast<sw::mark::TextFieldmark*>(ppMark->get());
+                    if ( pTextFieldmark )
+                    {
+                        pTextFieldmark->ReleaseDoc(m_pDoc);
+                    }
+
+                    ppFieldmark = lcl_FindMark(m_vCommonMarks, *ppMark);
+                    m_vCommonMarks.erase(ppFieldmark);
+                }
+                break;
+
+            case IDocumentMarkAccess::ANNOTATIONMARK:
                 {
-                    pTextFieldmark->ReleaseDoc(m_pDoc);
+                    IDocumentMarkAccess::iterator_t ppAnnotationMark = lcl_FindMark(m_vAnnotationMarks, *ppMark);
+                    OSL_ENSURE( ppAnnotationMark != m_vAnnotationMarks.end(), "<MarkManager::deleteMark(..)> - Annotation Mark not found." );
+                    m_vAnnotationMarks.erase(ppAnnotationMark);
                 }
                 break;
-            }
+
             case IDocumentMarkAccess::NAVIGATOR_REMINDER:
             case IDocumentMarkAccess::DDE_BOOKMARK:
             case IDocumentMarkAccess::UNO_BOOKMARK:
-            // no special array for these
+                {
+                    IDocumentMarkAccess::iterator_t ppOtherMark = lcl_FindMark(m_vCommonMarks, *ppMark);
+                    m_vCommonMarks.erase(ppOtherMark);
+                }
                 break;
         }
         DdeBookmark* const pDdeBookmark = dynamic_cast<DdeBookmark*>(ppMark->get());
@@ -747,9 +804,9 @@ namespace sw { namespace mark
         // the temporary hold instance assures that the mark is deleted after the
         // mark container has been updated. Thus, the mark could not be found anymore
         // in the mark container by other calls trying to recursively delete the mark.
-        iterator_t aToBeDeletedMarkIter = m_vMarks.begin() + (ppMark - m_vMarks.begin());
+        iterator_t aToBeDeletedMarkIter = m_vAllMarks.begin() + (ppMark - m_vAllMarks.begin());
         pMark_t pToBeDeletedMark = *aToBeDeletedMarkIter;
-        m_vMarks.erase( aToBeDeletedMarkIter );
+        m_vAllMarks.erase( aToBeDeletedMarkIter );
     }
 
     void MarkManager::deleteMark(const IMark* const pMark)
@@ -759,22 +816,18 @@ namespace sw { namespace mark
             " - Mark is not in my doc.");
         // finds the last Mark that is starting before pMark
         // (pMarkLow < pMark)
-        iterator_t pMarkLow = lower_bound(
-            m_vMarks.begin(), m_vMarks.end(),
-            pMark->GetMarkStart(),
-            bind(&IMark::StartsBefore, _1, _2));
-        // finds the first Mark that pMark is starting before
-        // (pMark < pMarkHigh)
-        //iterator_t pMarkHigh = upper_bound(
-        //    pMarkLow, m_vMarks.end(),
-        //    pMark->GetMarkStart(),
-        //    bind(&IMark::StartsBefore, _2, _1));
-        // since it should be rare that pMark isnt found at all
-        // we skip the bisect search on the upper bound
-        iterator_t pMarkHigh = m_vMarks.end();
-        iterator_t pMarkFound = find_if(
-            pMarkLow, pMarkHigh,
-            bind(equal_to<const IMark*>(), bind(&boost::shared_ptr<IMark>::get, _1), pMark));
+        iterator_t pMarkLow =
+            lower_bound(
+                m_vAllMarks.begin(),
+                m_vAllMarks.end(),
+                pMark->GetMarkStart(),
+                bind(&IMark::StartsBefore, _1, _2) );
+        iterator_t pMarkHigh = m_vAllMarks.end();
+        iterator_t pMarkFound =
+            find_if(
+                pMarkLow,
+                pMarkHigh,
+                bind(equal_to<const IMark*>(), bind(&boost::shared_ptr<IMark>::get, _1), pMark) );
         if(pMarkFound != pMarkHigh)
             deleteMark(pMarkFound);
     }
@@ -783,20 +836,24 @@ namespace sw { namespace mark
     {
         m_vFieldmarks.clear();
         m_vBookmarks.clear();
+
+        m_vCommonMarks.clear();
+
+        m_vAnnotationMarks.clear();
+
 #ifdef DEBUG
-        for(iterator_t pBkmk = m_vMarks.begin();
-            pBkmk != m_vMarks.end();
+        for(iterator_t pBkmk = m_vAllMarks.begin();
+            pBkmk != m_vAllMarks.end();
             ++pBkmk)
-            OSL_ENSURE(pBkmk->unique(),
-                "<MarkManager::clearAllMarks(..)>"
-                " - a Bookmark is still in use.");
+            OSL_ENSURE( pBkmk->unique(),
+                        "<MarkManager::clearAllMarks(..)> - a Bookmark is still in use.");
 #endif
-        m_vMarks.clear();
+        m_vAllMarks.clear();
     }
 
     IDocumentMarkAccess::const_iterator_t MarkManager::findMark(const ::rtl::OUString& rName) const
     {
-        return lcl_FindMarkByName(rName, m_vMarks.begin(), m_vMarks.end());
+        return lcl_FindMarkByName(rName, m_vAllMarks.begin(), m_vAllMarks.end());
     }
 
     IDocumentMarkAccess::const_iterator_t MarkManager::findBookmark(const ::rtl::OUString& rName) const
@@ -804,14 +861,14 @@ namespace sw { namespace mark
         return lcl_FindMarkByName(rName, m_vBookmarks.begin(), m_vBookmarks.end());
     }
 
-    IDocumentMarkAccess::const_iterator_t MarkManager::getMarksBegin() const
-        { return m_vMarks.begin(); }
+    IDocumentMarkAccess::const_iterator_t MarkManager::getAllMarksBegin() const
+        { return m_vAllMarks.begin(); }
 
-    IDocumentMarkAccess::const_iterator_t MarkManager::getMarksEnd() const
-        { return m_vMarks.end(); }
+    IDocumentMarkAccess::const_iterator_t MarkManager::getAllMarksEnd() const
+        { return m_vAllMarks.end(); }
 
-    sal_Int32 MarkManager::getMarksCount() const
-        { return m_vMarks.size(); }
+    sal_Int32 MarkManager::getAllMarksCount() const
+        { return m_vAllMarks.size(); }
 
     IDocumentMarkAccess::const_iterator_t MarkManager::getBookmarksBegin() const
         { return m_vBookmarks.begin(); }
@@ -838,28 +895,87 @@ namespace sw { namespace mark
     IFieldmark* MarkManager::getFieldmarkBefore(const SwPosition& rPos) const
         { return dynamic_cast<IFieldmark*>(lcl_getMarkBefore(m_vFieldmarks, rPos)); }
 
+
+    IDocumentMarkAccess::const_iterator_t MarkManager::getCommonMarksBegin() const
+    {
+        return m_vCommonMarks.begin();
+    }
+
+    IDocumentMarkAccess::const_iterator_t MarkManager::getCommonMarksEnd() const
+    {
+        return m_vCommonMarks.end();
+    }
+
+    sal_Int32 MarkManager::getCommonMarksCount() const
+    {
+        return m_vCommonMarks.size();
+    }
+
+
+    IDocumentMarkAccess::const_iterator_t MarkManager::getAnnotationMarksBegin() const
+    {
+        return m_vAnnotationMarks.begin();
+    }
+
+    IDocumentMarkAccess::const_iterator_t MarkManager::getAnnotationMarksEnd() const
+    {
+        return m_vAnnotationMarks.end();
+    }
+
+    sal_Int32 MarkManager::getAnnotationMarksCount() const
+    {
+        return m_vAnnotationMarks.size();
+    }
+
+    IDocumentMarkAccess::const_iterator_t MarkManager::findAnnotationMark( const ::rtl::OUString& rName ) const
+    {
+        return lcl_FindMarkByName( rName, m_vAnnotationMarks.begin(), m_vAnnotationMarks.end() );
+    }
+
+
     ::rtl::OUString MarkManager::getUniqueMarkName(const ::rtl::OUString& rName) const
     {
         OSL_ENSURE(rName.getLength(),
-            "<MarkManager::getUniqueMarkName(..)>"
-            " - a name should be proposed");
-        if(findMark(rName) == getMarksEnd()) return rName;
+            "<MarkManager::getUniqueMarkName(..)> - a name should be proposed");
+        if ( findMark(rName) == getAllMarksEnd() )
+        {
+            return rName;
+        }
+
         ::rtl::OUStringBuffer sBuf;
         ::rtl::OUString sTmp;
         for(sal_Int32 nCnt = 1; nCnt < SAL_MAX_INT32; nCnt++)
         {
             sTmp = sBuf.append(rName).append(nCnt).makeStringAndClear();
-            if(findMark(sTmp) == getMarksEnd()) break;
+            if ( findMark(sTmp) == getAllMarksEnd() )
+            {
+                break;
+            }
         }
         return sTmp;
     }
 
     void MarkManager::sortMarks()
     {
-        sort(m_vMarks.begin(), m_vMarks.end(), &lcl_MarkOrderingByStart);
+        sort(m_vAllMarks.begin(), m_vAllMarks.end(), &lcl_MarkOrderingByStart);
+        sort(m_vCommonMarks.begin(), m_vCommonMarks.end(), &lcl_MarkOrderingByStart);
         sort(m_vBookmarks.begin(), m_vBookmarks.end(), &lcl_MarkOrderingByStart);
         sort(m_vFieldmarks.begin(), m_vFieldmarks.end(), &lcl_MarkOrderingByStart);
+        sort(m_vAnnotationMarks.begin(), m_vAnnotationMarks.end(), &lcl_MarkOrderingByStart);
+    }
+
+#if OSL_DEBUG_LEVEL > 1
+    void MarkManager::dumpFieldmarks( ) const
+    {
+        const_iterator_t pIt = m_vFieldmarks.begin();
+        for (; pIt != m_vFieldmarks.end( ); pIt++)
+        {
+            rtl::OUString str = (*pIt)->ToString();
+            OSL_TRACE("%s\n",
+                ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr());
+        }
     }
+#endif
 
 }} // namespace ::sw::mark
 
@@ -1241,41 +1357,36 @@ void _SaveCntntIdx(SwDoc* pDoc,
     aSave.SetTypeAndCount( 0x8000, 0 );
 
     IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
-    const sal_Int32 nBkmks = pMarkAccess->getMarksCount();
-    for(; aSave.GetCount() < nBkmks; aSave.IncCount())
+    const sal_Int32 nMarksCount = pMarkAccess->getAllMarksCount();
+    for ( ; aSave.GetCount() < nMarksCount; aSave.IncCount() )
     {
-        bool bEqual = false;
-        bool bLower = false;
-        const ::sw::mark::IMark* pBkmk = (pMarkAccess->getMarksBegin() + aSave.GetCount())->get();
+        bool bMarkPosEqual = false;
+        const ::sw::mark::IMark* pBkmk = (pMarkAccess->getAllMarksBegin() + aSave.GetCount())->get();
         if(pBkmk->GetMarkPos().nNode.GetIndex() == nNode
             && pBkmk->GetMarkPos().nContent.GetIndex() <= nCntnt)
         {
             if(pBkmk->GetMarkPos().nContent.GetIndex() < nCntnt)
             {
-                bLower = true; // a hint for the other position...
                 aSave.SetContent(pBkmk->GetMarkPos().nContent.GetIndex());
                 aSave.Add(rSaveArr);
             }
             else // if a bookmark position is equal nCntnt, the other position
-                bEqual = true; // has to decide if it is added to the array
+                bMarkPosEqual = true; // has to decide if it is added to the array
         }
 
         if(pBkmk->IsExpanded()
             && pBkmk->GetOtherMarkPos().nNode.GetIndex() == nNode
             && pBkmk->GetOtherMarkPos().nContent.GetIndex() <= nCntnt)
         {
-            if(bLower || pBkmk->GetOtherMarkPos().nContent.GetIndex() < nCntnt)
-            {
-                if(bEqual)
-                { // the other position is before, the (main) position is equal
-                    aSave.SetContent(pBkmk->GetMarkPos().nContent.GetIndex());
-                    aSave.Add(rSaveArr);
-                }
-                aSave.SetContent(pBkmk->GetOtherMarkPos().nContent.GetIndex());
-                aSave.IncType();
+            if(bMarkPosEqual)
+            { // the other position is before, the (main) position is equal
+                aSave.SetContent(pBkmk->GetMarkPos().nContent.GetIndex());
                 aSave.Add(rSaveArr);
-                aSave.DecType();
             }
+            aSave.SetContent(pBkmk->GetOtherMarkPos().nContent.GetIndex());
+            aSave.IncType();
+            aSave.Add(rSaveArr);
+            aSave.DecType();
         }
     }
 
@@ -1467,7 +1578,7 @@ void _RestoreCntntIdx(SwDoc* pDoc,
         {
             case 0x8000:
             {
-                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getMarksBegin()[aSave.GetCount()].get());
+                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getAllMarksBegin()[aSave.GetCount()].get());
                 SwPosition aNewPos(pMark->GetMarkPos());
                 aNewPos.nNode = *pCNd;
                 aNewPos.nContent.Assign(pCNd, aSave.GetContent() + nOffset);
@@ -1476,7 +1587,7 @@ void _RestoreCntntIdx(SwDoc* pDoc,
             break;
             case 0x8001:
             {
-                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getMarksBegin()[aSave.GetCount()].get());
+                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getAllMarksBegin()[aSave.GetCount()].get());
                 SwPosition aNewPos(pMark->GetOtherMarkPos());
                 aNewPos.nNode = *pCNd;
                 aNewPos.nContent.Assign(pCNd, aSave.GetContent() + nOffset);
@@ -1634,7 +1745,7 @@ void _RestoreCntntIdx(SvULongs& rSaveArr
             {
             case 0x8000:
             {
-                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getMarksBegin()[aSave.GetCount()].get());
+                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getAllMarksBegin()[aSave.GetCount()].get());
                 SwPosition aNewPos(pMark->GetMarkPos());
                 aNewPos.nNode = rNd;
                 aNewPos.nContent.Assign(pCNd, Min(aSave.GetContent(), nLen));
@@ -1643,7 +1754,7 @@ void _RestoreCntntIdx(SvULongs& rSaveArr
             break;
             case 0x8001:
             {
-                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getMarksBegin()[aSave.GetCount()].get());
+                MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getAllMarksBegin()[aSave.GetCount()].get());
                 SwPosition aNewPos(pMark->GetOtherMarkPos());
                 aNewPos.nNode = rNd;
                 aNewPos.nContent.Assign(pCNd, Min(aSave.GetContent(), nLen));

Modified: openoffice/trunk/main/sw/source/core/doc/doccomp.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/doccomp.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/doccomp.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/doccomp.cxx Thu Dec 19 18:50:58 2013
@@ -1354,8 +1354,11 @@ void SwCompareData::ShowInsert( sal_uLon
 
 }
 
-void SwCompareData::ShowDelete( const CompareData& rData, sal_uLong nStt,
-								sal_uLong nEnd, sal_uLong nInsPos )
+void SwCompareData::ShowDelete(
+    const CompareData& rData,
+    sal_uLong nStt,
+    sal_uLong nEnd,
+    sal_uLong nInsPos )
 {
 	SwNodeRange aRg(
 		((SwCompareLine*)rData.GetLine( nStt ))->GetNode(), 0,

Modified: openoffice/trunk/main/sw/source/core/doc/doccorr.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/doccorr.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/doccorr.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/doccorr.cxx Thu Dec 19 18:50:58 2013
@@ -204,7 +204,9 @@ void SwDoc::CorrAbs(const SwNodeIndex& r
     aNewPos.nContent += nOffset;
 
     getIDocumentMarkAccess()->correctMarksAbsolute(rOldNode, rNewPos, nOffset);
-    {   // fix redlines
+
+    // fix redlines
+    {
         SwRedlineTbl& rTbl = *pRedlineTbl;
         for (sal_uInt16 n = 0; n < rTbl.Count(); )
         {

Modified: openoffice/trunk/main/sw/source/core/doc/docdde.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/docdde.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/docdde.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/docdde.cxx Thu Dec 19 18:50:58 2013
@@ -55,16 +55,20 @@ using namespace ::com::sun::star;
 namespace
 {
 
-    static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName, bool bCaseSensitive)
+    static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(
+        const IDocumentMarkAccess& rMarkAccess,
+        const String& rName,
+        const bool bCaseSensitive )
     {
         //Iterating over all bookmarks, checking DdeBookmarks
         const ::rtl::OUString sNameLc = bCaseSensitive ? rName : GetAppCharClass().lower(rName);
-        for(IDocumentMarkAccess::const_iterator_t ppMark = rMarkAccess.getMarksBegin();
-            ppMark != rMarkAccess.getMarksEnd();
+        for(IDocumentMarkAccess::const_iterator_t ppMark = rMarkAccess.getCommonMarksBegin();
+            ppMark != rMarkAccess.getCommonMarksEnd();
             ppMark++)
         {
-            if (::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get()))
+            if ( IDocumentMarkAccess::GetType( *(ppMark->get()) ) == IDocumentMarkAccess::DDE_BOOKMARK)
             {
+                ::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get());
                 if (
                     (bCaseSensitive && (pBkmk->GetName() == sNameLc)) ||
                     (!bCaseSensitive && GetAppCharClass().lower(pBkmk->GetName()) == String(sNameLc))

Modified: openoffice/trunk/main/sw/source/core/doc/docedt.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/docedt.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/docedt.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/docedt.cxx Thu Dec 19 18:50:58 2013
@@ -1690,30 +1690,6 @@ bool SwDoc::DeleteRangeImplImpl(SwPaM & 
 		}
 	}
 
-    // Delete fieldmarks before postits, but let's leave them alone during import.
-    if ( GetIDocumentUndoRedo().DoesUndo()
-         && pStt->nNode == pEnd->nNode
-         && (pEnd->nContent.GetIndex() - pStt->nContent.GetIndex()) == 1 )
-    {
-        SwTxtNode* pTxtNd = rPam.Start()->nNode.GetNode().GetTxtNode();
-        xub_StrLen nIndex = rPam.Start()->nContent.GetIndex();
-        // We may have a postit here.
-        if (pTxtNd->GetTxt().GetChar(nIndex) == CH_TXTATR_INWORD)
-        {
-            SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt(nIndex, RES_TXTATR_FIELD);
-            if ( pTxtAttr != NULL
-                 && pTxtAttr->GetFmtFld().GetField()->Which() == RES_POSTITFLD )
-            {
-                const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pTxtAttr->GetFmtFld().GetField());
-                IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark(pField->GetName());
-                if (ppMark != getIDocumentMarkAccess()->getMarksEnd())
-                {
-                    getIDocumentMarkAccess()->deleteMark(ppMark);
-                }
-            }
-        }
-    }
-
 	{
 		// Bug 26675:	DataChanged vorm loeschen verschicken, dann bekommt
 		//			man noch mit, welche Objecte sich im Bereich befinden.

Modified: openoffice/trunk/main/sw/source/core/doc/docfld.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/docfld.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/docfld.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/docfld.cxx Thu Dec 19 18:50:58 2013
@@ -278,11 +278,11 @@ const SwFldTypes* SwDoc::GetFldTypes() c
 	Beschreibung: Den ersten Typen mit ResId und Namen finden
  --------------------------------------------------------------------*/
 
-SwFieldType* SwDoc::GetFldType( sal_uInt16 nResId, const String& rName,
-		 bool bDbFieldMatching // used in some UNO calls for RES_DBFLD
-								   // to use different string matching code
-								   // #i51815#
-		 ) const
+SwFieldType* SwDoc::GetFldType(
+    sal_uInt16 nResId,
+    const String& rName,
+    bool bDbFieldMatching // used in some UNO calls for RES_DBFLD to use different string matching code #i51815#
+    ) const
 {
 	sal_uInt16 nSize = pFldTypes->Count(), i = 0;
 	const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
@@ -2210,7 +2210,7 @@ bool SwDoc::SetFieldsDirty( bool b, cons
 							n < nEnd; ++n )
 					{
 						const SwTxtAttr* pAttr = pTNd->GetSwpHints()[ n ];
-						if( RES_TXTATR_FIELD == pAttr->Which() )
+						if ( pAttr->Which() == RES_TXTATR_FIELD )
 						{
 							b = sal_True;
 							break;

Modified: openoffice/trunk/main/sw/source/core/doc/docfmt.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/docfmt.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/docfmt.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/docfmt.cxx Thu Dec 19 18:50:58 2013
@@ -719,7 +719,7 @@ static bool lcl_InsAttr(
                                 : pNode->Len();
                 SwRegHistory history( pNode, *pNode, pHistory );
                 bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags )
-                    || bRet;
+                       || bRet;
 
                 if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
                                 && pDoc->GetRedlineTbl().Count())))
@@ -733,8 +733,10 @@ static bool lcl_InsAttr(
                         pUndo->SaveRedlineData( aPam, bTxtIns );
 
                     if( pDoc->IsRedlineOn() )
-                        pDoc->AppendRedline( new SwRedline( bTxtIns
-                                ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
+                        pDoc->AppendRedline(
+                            new SwRedline(
+                                bTxtIns ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_FORMAT, aPam ),
+                                true);
                     else if( bTxtIns )
                         pDoc->SplitRedline( aPam );
                 }

Modified: openoffice/trunk/main/sw/source/core/doc/doclay.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/doclay.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/doclay.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/doclay.cxx Thu Dec 19 18:50:58 2013
@@ -389,9 +389,11 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt
 |*
 |*************************************************************************/
 
-SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource,
-								const SwFmtAnchor& rNewAnchor,
-                                bool bSetTxtFlyAtt, bool bMakeFrms )
+SwFrmFmt *SwDoc::CopyLayoutFmt(
+    const SwFrmFmt& rSource,
+    const SwFmtAnchor& rNewAnchor,
+    bool bSetTxtFlyAtt,
+    bool bMakeFrms )
 {
     const bool bFly = RES_FLYFRMFMT == rSource.Which();
     const bool bDraw = RES_DRAWFRMFMT == rSource.Which();
@@ -497,7 +499,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const Sw
 
 		// sorge dafuer das auch Fly's in Fly's kopiert werden
 		aIdx = *pSttNd->EndOfSectionNode();
-        pSrcDoc->CopyWithFlyInFly( aRg, 0, aIdx, sal_False, sal_True, sal_True );
+        pSrcDoc->CopyWithFlyInFly( aRg, 0, aIdx, NULL, sal_False, sal_True, sal_True );
 	}
 	else
 	{

Modified: openoffice/trunk/main/sw/source/core/doc/tblcpy.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/tblcpy.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/tblcpy.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/tblcpy.cxx Thu Dec 19 18:50:58 2013
@@ -561,7 +561,7 @@ void lcl_CpyBox( const SwTable& rCpyTbl,
 
 	SwNodeIndex aSavePos( aInsIdx, -1 );
     if( pRg.get() )
-        pCpyDoc->CopyWithFlyInFly( *pRg, 0, aInsIdx, sal_False );
+        pCpyDoc->CopyWithFlyInFly( *pRg, 0, aInsIdx, NULL, sal_False );
     else
 		pDoc->GetNodes().MakeTxtNode( aInsIdx, (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
 	aSavePos++;

Modified: openoffice/trunk/main/sw/source/core/doc/tblrwcl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/tblrwcl.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/tblrwcl.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/tblrwcl.cxx Thu Dec 19 18:50:58 2013
@@ -2098,7 +2098,7 @@ sal_Bool lcl_CopyBoxToDoc( const _FndBox
                             *rpFndBox->GetBox()->GetSttNd()->EndOfSectionNode() );
                 SwNodeIndex aInsIdx( *pBox->GetSttNd(), 1 );
 
-                pFromDoc->CopyWithFlyInFly( aCpyRg, 0, aInsIdx, sal_False );
+                pFromDoc->CopyWithFlyInFly( aCpyRg, 0, aInsIdx, NULL, sal_False );
                 // den initialen TextNode loeschen
                 pCpyPara->pDoc->GetNodes().Delete( aInsIdx, 1 );
             }

Modified: openoffice/trunk/main/sw/source/core/docnode/ndcopy.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/docnode/ndcopy.cxx?rev=1552394&r1=1552393&r2=1552394&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/docnode/ndcopy.cxx (original)
+++ openoffice/trunk/main/sw/source/core/docnode/ndcopy.cxx Thu Dec 19 18:50:58 2013
@@ -132,7 +132,9 @@ namespace
     }
 
     // TODO: use SaveBookmark (from _DelBookmarks)
-    static void lcl_CopyBookmarks(const SwPaM& rPam, SwPaM& rCpyPam)
+    static void lcl_CopyBookmarks(
+        const SwPaM& rPam,
+        SwPaM& rCpyPam )
     {
         const SwDoc* pSrcDoc = rPam.GetDoc();
         SwDoc* pDestDoc =  rCpyPam.GetDoc();
@@ -144,19 +146,23 @@ namespace
 
         typedef ::std::vector< const ::sw::mark::IMark* > mark_vector_t;
         mark_vector_t vMarksToCopy;
-        for(IDocumentMarkAccess::const_iterator_t ppMark = pSrcMarkAccess->getMarksBegin();
-            ppMark != pSrcMarkAccess->getMarksEnd();
-            ppMark++)
+        for ( IDocumentMarkAccess::const_iterator_t ppMark = pSrcMarkAccess->getAllMarksBegin();
+              ppMark != pSrcMarkAccess->getAllMarksEnd();
+              ppMark++ )
         {
             const ::sw::mark::IMark* const pMark = ppMark->get();
+
             const SwPosition& rMarkStart = pMark->GetMarkStart();
             const SwPosition& rMarkEnd = pMark->GetMarkEnd();
-            // only include marks that are in the range and not touching
-            // both start and end
-            bool bIsNotOnBoundary = pMark->IsExpanded()
+            // only include marks that are in the range and not touching both start and end
+            // - not for annotation marks.
+            const bool bIsNotOnBoundary =
+                pMark->IsExpanded()
                 ? (rMarkStart != rStt || rMarkEnd != rEnd)  // rMarkStart != rMarkEnd
                 : (rMarkStart != rStt && rMarkEnd != rEnd); // rMarkStart == rMarkEnd
-            if(rMarkStart >= rStt && rMarkEnd <= rEnd && bIsNotOnBoundary)
+            if ( rMarkStart >= rStt && rMarkEnd <= rEnd
+                 && ( bIsNotOnBoundary
+                      || IDocumentMarkAccess::GetType( *pMark ) == IDocumentMarkAccess::ANNOTATIONMARK ) )
             {
                 vMarksToCopy.push_back(pMark);
             }
@@ -1245,13 +1251,13 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPos
 			if( aInsPos == pEnd->nNode )
 			{
 				SwNodeIndex aSaveIdx( aInsPos, -1 );
-                CopyWithFlyInFly( aRg, 0,aInsPos, bMakeNewFrms, sal_False );
+                CopyWithFlyInFly( aRg, 0, aInsPos, &rPam, bMakeNewFrms, sal_False );
 				aSaveIdx++;
 				pEnd->nNode = aSaveIdx;
 				pEnd->nContent.Assign( aSaveIdx.GetNode().GetTxtNode(), 0 );
 			}
 			else
-                CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, bMakeNewFrms, sal_False );
+                CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam, bMakeNewFrms, sal_False );
 
             bCopyBookmarks = false;
 
@@ -1281,7 +1287,7 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPos
 	aCpyPam.Exchange();
 
 	// dann kopiere noch alle Bookmarks
-    if( bCopyBookmarks && getIDocumentMarkAccess()->getMarksCount() )
+    if( bCopyBookmarks && getIDocumentMarkAccess()->getAllMarksCount() )
 		lcl_CopyBookmarks( rPam, aCpyPam );
 
 	if( nsRedlineMode_t::REDLINE_DELETE_REDLINES & eOld )
@@ -1318,22 +1324,27 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPos
 
 //  ----- Copy-Methode vom SwDoc - "kopiere Fly's in Fly's" ------
 
-void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex,
-							const SwNodeIndex& rInsPos, sal_Bool bMakeNewFrms,
-							sal_Bool bDelRedlines, sal_Bool bCopyFlyAtFly ) const
+void SwDoc::CopyWithFlyInFly(
+    const SwNodeRange& rRg,
+    const xub_StrLen nEndContentIndex,
+    const SwNodeIndex& rInsPos,
+    const SwPaM* pCopiedPaM,
+    const sal_Bool bMakeNewFrms,
+    const sal_Bool bDelRedlines,
+    const sal_Bool bCopyFlyAtFly ) const
 {
-	SwDoc* pDest = rInsPos.GetNode().GetDoc();
+    SwDoc* pDest = rInsPos.GetNode().GetDoc();
 
-	_SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 );
+    _SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 );
 
-	SwNodeIndex aSavePos( rInsPos, -1 );
-	sal_Bool bEndIsEqualEndPos = rInsPos == rRg.aEnd;
-	GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, sal_True );
-	aSavePos++;
-	if( bEndIsEqualEndPos )
-		((SwNodeIndex&)rRg.aEnd) = aSavePos;
+    SwNodeIndex aSavePos( rInsPos, -1 );
+    sal_Bool bEndIsEqualEndPos = rInsPos == rRg.aEnd;
+    GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, sal_True );
+    aSavePos++;
+    if( bEndIsEqualEndPos )
+        ((SwNodeIndex&)rRg.aEnd) = aSavePos;
 
-	aRedlRest.Restore();
+    aRedlRest.Restore();
 
 #ifdef DBG_UTIL
 	{
@@ -1359,21 +1370,23 @@ void SwDoc::CopyWithFlyInFly( const SwNo
         CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly );
     }
 
-	SwNodeRange aCpyRange( aSavePos, rInsPos );
+    SwNodeRange aCpyRange( aSavePos, rInsPos );
 
-	// dann kopiere noch alle Bookmarks
-    if( getIDocumentMarkAccess()->getMarksCount() )
-	{
-		SwPaM aRgTmp( rRg.aStart, rRg.aEnd );
-		SwPaM aCpyTmp( aCpyRange.aStart, aCpyRange.aEnd );
+    // dann kopiere noch alle Bookmarks
+    if( getIDocumentMarkAccess()->getAllMarksCount() )
+    {
+        SwPaM aRgTmp( rRg.aStart, rRg.aEnd );
+        SwPaM aCpyTmp( aCpyRange.aStart, aCpyRange.aEnd );
 
-		lcl_CopyBookmarks( aRgTmp, aCpyTmp );
-	}
+        lcl_CopyBookmarks(
+            pCopiedPaM != NULL ? *pCopiedPaM : aRgTmp,
+            aCpyTmp );
+    }
 
-	if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->GetRedlineMode() ))
-		lcl_DeleteRedlines( rRg, aCpyRange );
+    if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->GetRedlineMode() ))
+        lcl_DeleteRedlines( rRg, aCpyRange );
 
-	pDest->GetNodes()._DelDummyNodes( aCpyRange );
+    pDest->GetNodes()._DelDummyNodes( aCpyRange );
 }
 
 void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest )
@@ -1392,9 +1405,11 @@ void lcl_ChainFmts( SwFlyFrmFmt *pSrc, S
 	}
 }
 
-void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg,
-        const xub_StrLen nEndContentIndex, const SwNodeIndex& rStartIdx,
-        const bool bCopyFlyAtFly ) const
+void SwDoc::CopyFlyInFlyImpl(
+    const SwNodeRange& rRg,
+    const xub_StrLen nEndContentIndex,
+    const SwNodeIndex& rStartIdx,
+    const bool bCopyFlyAtFly ) const
 {
 	// Bug 22727: suche erst mal alle Flys zusammen, sortiere sie entsprechend
 	//			  ihrer Ordnungsnummer und kopiere sie erst dann. Damit wird