Commits

os  committed 1fe1a69

os148: fieldmark implementation moved from cws os138

  • Participants
  • Parent commits 2d88b30

Comments (0)

Files changed (50)

File offapi/com/sun/star/text/GenericTextDocument.idl

 #ifndef __com_sun_star_lang_Locale_idl__
 #include <com/sun/star/lang/Locale.idl>
 #endif
-
+#ifndef __com_sun_star_text_XFieldmarksSupplier_idl__
+#include <com/sun/star/text/XFieldmarksSupplier.idl>
+#endif
 //=============================================================================
 
  module com {  module sun {  module star {  module text {
 
 	/// @since OOo 1.1.2
 	[optional] interface com::sun::star::util::XNumberFormatsSupplier;
+        
+        /// @since OOo 2.3
+        [optional] interface com::sun::star::text::XFieldmarksSupplier;
     //-------------------------------------------------------------------------
 
 	/** contains the identifier of the default locale of the document.

File offapi/com/sun/star/text/makefile.mk

     XFormField.idl \
     XFlatParagraph.idl \
     XFlatParagraphIterator.idl \
-    XFlatParagraphIteratorProvider.idl
+    XFlatParagraphIteratorProvider.idl\
+    XFieldmarksSupplier.idl
 
 # ------------------------------------------------------------------
 

File sw/AllLangResTarget_sw.mk

 	sw/source/ui/dialog/wordcountdialog.src \
 	sw/source/ui/dochdl/dochdl.src \
 	sw/source/ui/dochdl/selglos.src \
-	sw/source/ui/docvw/access.src \
+    sw/source/ui/docvw/annotation.src \
+    sw/source/ui/docvw/access.src \
 	sw/source/ui/docvw/docvw.src \
 	sw/source/ui/envelp/envelp.src \
 	sw/source/ui/envelp/envfmt.src \
 	sw/source/ui/envelp/mailmrge.src \
 	sw/source/ui/fldui/DropDownFieldDialog.src \
 	sw/source/ui/fldui/changedb.src \
+    sw/source/ui/fldui/fieldmarkdialog.src \
 	sw/source/ui/fldui/flddb.src \
 	sw/source/ui/fldui/flddinf.src \
 	sw/source/ui/fldui/flddok.src \
 	sw/source/ui/fldui/fldtdlg.src \
 	sw/source/ui/fldui/fldui.src \
 	sw/source/ui/fldui/fldvar.src \
-	sw/source/ui/fldui/inpdlg.src \
+    sw/source/ui/fldui/inpdlg.src \
 	sw/source/ui/fldui/javaedit.src \
 	sw/source/ui/fmtui/tmpdlg.src \
 	sw/source/ui/frmdlg/column.src \

File sw/Library_sw.mk

 	sw/source/core/edit/edws \
 	sw/source/core/except/dbgloop \
 	sw/source/core/except/errhdl \
-	sw/source/core/fields/authfld \
+    sw/source/core/fields/DateTimeFieldmark \
+    sw/source/core/fields/ReferenceFieldmark \
+    sw/source/core/fields/authfld \
 	sw/source/core/fields/cellfml \
 	sw/source/core/fields/chpfld \
 	sw/source/core/fields/dbfld \
 	sw/source/core/fields/ddetbl \
 	sw/source/core/fields/docufld \
 	sw/source/core/fields/expfld \
+    sw/source/core/fields/fieldmarkdata \
 	sw/source/core/fields/fldbas \
 	sw/source/core/fields/flddat \
 	sw/source/core/fields/flddropdown \
 	sw/source/core/fields/macrofld \
 	sw/source/core/fields/postithelper \
 	sw/source/core/fields/reffld \
+    sw/source/core/fields/richfieldmark \
 	sw/source/core/fields/scrptfld \
 	sw/source/core/fields/tblcalc \
 	sw/source/core/fields/textapi \
 	sw/source/core/unocore/unoevent \
 	sw/source/core/unocore/unoevtlstnr \
 	sw/source/core/unocore/unofield \
+    sw/source/core/unocore/unofieldmarks \
 	sw/source/core/unocore/unoflatpara \
 	sw/source/core/unocore/unoframe \
 	sw/source/core/unocore/unoftn \
 	sw/source/core/unocore/unoredline \
 	sw/source/core/unocore/unoredlines \
 	sw/source/core/unocore/unorefmk \
+    sw/source/core/unocore/unorichfieldmark \
 	sw/source/core/unocore/unosect \
 	sw/source/core/unocore/unosett \
 	sw/source/core/unocore/unosrch \
 	sw/source/ui/envelp/labelcfg \
 	sw/source/ui/envelp/labimg \
 	sw/source/ui/envelp/syncbtn \
-	sw/source/ui/fldui/fldmgr \
+    sw/source/ui/fldui/FldRefTreeListBox \
+    sw/source/ui/fldui/fldmgr \
 	sw/source/ui/fldui/fldwrap \
 	sw/source/ui/fldui/xfldui \
 	sw/source/ui/frmdlg/colex \

File sw/Library_swui.mk

 	sw/source/ui/fldui/DropDownFieldDialog \
 	sw/source/ui/fldui/FldRefTreeListBox \
 	sw/source/ui/fldui/changedb \
+    sw/source/ui/fldui/fieldmarkdialog \
 	sw/source/ui/fldui/flddb \
 	sw/source/ui/fldui/flddinf \
 	sw/source/ui/fldui/flddok \

File sw/Module_sw.mk

 	Library_sw \
 	Library_swd \
 	Library_swui \
+    Library_vbaswobj \
 	Package_misc \
 	Package_uiconfig \
 	Package_xml \

File sw/inc/IDocumentFieldsAccess.hxx

 class SwNode;
 
 namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
-
+namespace sw{ namespace mark{
+    class IRichFieldmark;
+    class IFieldmarkData;
+}}
  /** Document fields related interfaces
  */
  class IDocumentFieldsAccess
     */
 	virtual void InsDelFldInFldLst(bool bIns, const SwTxtFld& rFld) = 0;
 
+    /** update a Fielmark with new FieldmarkData
+     */
+
 protected:
     virtual ~IDocumentFieldsAccess() {};
  };

File sw/inc/IDocumentMarkAccess.hxx

 
 namespace sw { namespace mark {
     class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
+    class IRichFieldmark;
+    class IFieldmarkData;
 }}
 
 /** Provides access to the marks of a document.
             CROSSREF_NUMITEM_BOOKMARK,
             TEXT_FIELDMARK,
             CHECKBOX_FIELDMARK,
-            NAVIGATOR_REMINDER
+            NAVIGATOR_REMINDER,
+            DATETIME_FIELD,
+            REFERENCE_FIELD
         };
 
         typedef ::boost::shared_ptr< ::sw::mark::IMark> pMark_t;
         virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
         virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
 
+        /** Generates a new field mark in the document for a certain selection.
+
+           @param rPaM
+           [in] the selection being marked.
+
+           @param rData
+           [in] the initial field attributes
+
+           @param eMark
+           [in] the type of the new mark.
+
+           @returns
+           a pointer to the new mark (name might have changed).
+        */
+        virtual ::sw::mark::IRichFieldmark* makeRichFieldmark(const SwPaM& rPaM,
+                    const ::sw::mark::IFieldmarkData& rData,
+                    MarkType eMark) = 0;
+        /** updates a given mark 
+            @param rToUpdate 
+            [in] current field mark
+         
+            @param rNew
+            [in] new field parameters
+         */
+        virtual void updateRichFieldmark( const sw::mark::IRichFieldmark& rToUpdate, 
+                                    const sw::mark::IFieldmarkData& rNew ) = 0;
+        /** returns the number of IRichFieldmarks.
+        */
+        virtual sal_Int32 getRichFieldmarksCount() const = 0;
+        /** returns a STL-like random access iterator to the begin of the sequence of IRichFieldmarks.
+        */
+        virtual const_iterator_t getRichFieldmarksBegin() const = 0;
+        /** returns a STL-like random access iterator to the end of the sequence of IRichFieldmarks.
+        */
+        virtual const_iterator_t getRichFieldmarksEnd() const = 0;
+        virtual ::sw::mark::IRichFieldmark* getRichFieldmarkFor(const SwPosition& pos) const =0;
+        virtual ::sw::mark::IRichFieldmark* getRichFieldmarkBefore(const SwPosition& pos) const =0;
+        virtual ::sw::mark::IRichFieldmark* getRichFieldmarkAfter(const SwPosition& pos) const =0;
+        
         // Returns the MarkType used to create the mark
         static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark);
     protected:

File sw/inc/IMark.hxx

 
 namespace sw { namespace mark
 {
+    class IFieldmarkData;
+    
     class IMark
         : virtual public SwModify // inherited as interface
         , public ::boost::totally_ordered<IMark>
             virtual bool IsChecked() const =0;
             virtual void SetChecked(bool checked) =0;
     };
+
+    class IRichFieldmark 
+        : virtual public IFieldmark
+    {
+        public:
+            /* if necessary remove current field result and create a new result
+             * 
+             */
+            virtual void Update() = 0;
+            /* move field content to/from temp. position and show/hide field command instead 
+             * 
+             */
+            virtual void SetShowCommand( bool bCommand ) = 0; 
+            virtual bool IsShowCommand() const = 0; 
+            
+            virtual const IFieldmarkData& GetData() const = 0;
+            virtual IFieldmarkData* CloneData() const = 0;
+    };
 }}
 #endif

File sw/inc/cmdid.h

 #define FN_UNO_TABLE_NAME                   (FN_EXTRA2 + 111)
 #define FN_UNO_META                         (FN_EXTRA2 + 112)
 #define FN_UNO_NESTED_TEXT_CONTENT          (FN_EXTRA2 + 113)
+#define FN_UNO_TEXT_FIELDMARK               (FN_EXTRA2 + 114)
 
 // #i972: bool items to be passed to SwFrmPage for evaluation
 #define FN_OLE_IS_MATH                      (FN_EXTRA2 + 114)

File sw/inc/crsrsh.hxx

 // <--
 struct SwPosition;
 
+namespace sw{ namespace mark{
+    class Fieldmark;
+}}
+
 namespace com { namespace sun { namespace star { namespace util {
     struct SearchOptions;
 } } } }
         SW_NUMLABEL         = 0x0200, // #i23726#
         SW_CONTENT_CHECK    = 0x0400, // --> FME 2005-05-13 #i43742# <--
         SW_SMARTTAG         = 0x0800,
-        SW_FORMCTRL         = 0x1000
+        SW_FORMCTRL         = 0x1000,
+        SW_FIELDMARK        = 0x2000
 #ifndef PRODUCT
         ,SW_CURR_ATTRS      = 0x4000        // nur zum Debuggen
         ,SW_TABLEBOXVALUE   = 0x8000        // nur zum Debuggen
         const SfxPoolItem* pAttr;
         const SwRedline* pRedl;
         SwCntntNode * pNode; // #i23726#
-        const sw::mark::IFieldmark* pFldmark;
+        const sw::mark::IFieldmark* pFieldmark;
     } aFnd;
 
     int nDist; // #i23726#
     bool GoPrevBookmark();
 
     bool IsFormProtected();
+    ::sw::mark::IRichFieldmark* GetCurrentRichFieldmark();
+
     ::sw::mark::IFieldmark* GetCurrentFieldmark();
     ::sw::mark::IFieldmark* GetFieldmarkAfter();
     ::sw::mark::IFieldmark* GetFieldmarkBefore();

File sw/inc/doc.hxx

 	virtual void SetNewFldLst( bool bFlag);
 	virtual void InsDelFldInFldLst(bool bIns, const SwTxtFld& rFld);
 
+
     /** Returns the field at a certain position.
        @param rPos position to search at
        @return pointer to field at the given position or NULL in case no field is found

File sw/inc/fldui.hrc

 #define DLG_JAVAEDIT      	(RC_FLDDLG_BEGIN + 10)
 #define DLG_FLD_INSERT		(RC_FLDDLG_BEGIN + 11)
 #define DLG_FLD_DROPDOWN    (RC_FLDDLG_BEGIN + 12)
+#define DLG_EDIT_FIELDMARK      (RC_FLDDLG_BEGIN + 13)
 
 /*--------------------------------------------------------------------
 	Beschreibung: TypeId

File sw/inc/swabstdlg.hxx

 	class XResultSet;
 	}
 }}}
+namespace sw{ namespace mark{ 
+    class IRichFieldmark; 
+    class IFieldmarkData; 
+    
+}}
 
 typedef   void (*SwLabDlgMethod) (::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& xModel,	const SwLabItem& rItem);
 
 			 STAR_REFERENCE( container::XNameAccess ) & xThird ) = 0;
 };
 
+class AbstractSwFieldmarkDialog : public VclAbstractDialog
+{
+public:
+    virtual const sw::mark::IFieldmarkData& GetChangedData() const = 0;
+};
+    
 class AbstractSwModalRedlineAcceptDlg : public VclAbstractDialog //add for SwModalRedlineAcceptDlg
 {
 public:
 
 	virtual AbstractSwFldDlg * CreateSwFldDlg ( SfxBindings* pB, SwChildWinWrapper* pCW, Window *pParent, int nResId ) = 0; //add for SwFldDlg
 	virtual SfxAbstractDialog*	 CreateSwFldEditDlg ( SwView& rVw, int nResId ) = 0; //add for SwFldEditDlg
-	virtual AbstractSwRenameXNamedDlg * CreateSwRenameXNamedDlg( Window* pParent, //add for SwRenameXNamedDlg
+    virtual AbstractSwFieldmarkDialog*   CreateFieldmarkDialog( SwView& rVw, const sw::mark::IRichFieldmark& rCurFieldmark ) = 0;
+    virtual AbstractSwRenameXNamedDlg * CreateSwRenameXNamedDlg( Window* pParent, //add for SwRenameXNamedDlg
 																STAR_REFERENCE( container::XNamed ) & xNamed,
 																STAR_REFERENCE( container::XNameAccess ) & xNameAccess, int nResId ) = 0;
 	virtual AbstractSwModalRedlineAcceptDlg * CreateSwModalRedlineAcceptDlg ( Window *pParent, int nResId ) = 0; //add for SwModalRedlineAcceptDlg

File sw/inc/unobookmark.hxx

         throw (::com::sun::star::lang::IllegalArgumentException,
                 ::com::sun::star::uno::RuntimeException);
 
-    const ::sw::mark::IMark* GetBookmark() const;
+    ::sw::mark::IMark* GetBookmark();
 
     virtual ~SwXBookmark();
 
     /// @param pDoc and pMark != 0, but not & because of ImplInheritanceHelper
     SwXBookmark(::sw::mark::IMark *const pMark, SwDoc *const pDoc);
 
+    SwDoc* GetDoc();
 public:
 
     /// descriptor

File sw/inc/unocoll.hxx

 #define SW_SERVICE_TYPE_FIELDMARK                       107
 #define SW_SERVICE_TYPE_FORMFIELDMARK                   108
 #define SW_SERVICE_TYPE_META                            109
-
-#define SW_SERVICE_LAST                 SW_SERVICE_TYPE_META
+#define SW_SERVICE_FIELDMARK_REFERENCE                  110
+#define SW_SERVICE_LAST                 SW_SERVICE_FIELDMARK_REFERENCE
 
 #define SW_SERVICE_INVALID			USHRT_MAX
 

File sw/inc/unofield.hxx

 #include <calbck.hxx>
 #include <unocoll.hxx>
 #include <RefreshListenerContainer.hxx>
+#include <IMark.hxx>
 
 
 class SwFieldType;
     sal_uInt16                      m_nServiceId;
 	SwFieldProperties_Impl* 	m_pProps;
 	String 						m_sTypeName;
+    // new member
+    ::sw::mark::IRichFieldmark*  m_pFieldmark;
+
 
 
 	//SwFieldType* GetFldType() const { return (SwFieldType*)GetRegisteredIn(); }

File sw/inc/unomap.hxx

 #define PROPERTY_MAP_PARA_AUTO_STYLE                    96
 #define PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM				97
 #define PROPERTY_MAP_METAFIELD                          98
+#define PROPERTY_MAP_FIELDMARK_DATETIME                 99
+#define PROPERTY_MAP_FIELDMARK_REFERENCE                100
 
-#define PROPERTY_MAP_END                                99
+#define PROPERTY_MAP_END                                101
 
 //S&E
 #define WID_WORDS				 0

File sw/inc/unoport.hxx

     PORTION_META,
 	PORTION_FIELD_START,
 	PORTION_FIELD_END,
-	PORTION_FIELD_START_END
+    PORTION_FIELD_START_END,
+    PORTION_FIELDMARK_START,
+    PORTION_FIELDMARK_END
 };
 
 

File sw/inc/unoprnms.hxx

 // <--
 /* 0738 */  UNO_NAME_META,       // #i91565#
 /* 0739 */  UNO_NAME_NESTED_TEXT_CONTENT, // #i109601#
-/* 0740 */  SW_PROPNAME_END
+/* 0740 */  UNO_NAME_TEXT_FIELDMARK,
+/* 0741 */  SW_PROPNAME_END
 };
 
 

File sw/inc/unotxdoc.hxx

 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
 #include <com/sun/star/text/XPagePrintable.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/text/XFieldmarksSupplier.hpp>
 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
 
 #include <viewopt.hxx>
 
-#define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
-Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32
+#define __IFC33 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \
+Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32, Ifc33
 
-#define __CLASS_IFC32 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \
+#define __CLASS_IFC33 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \
 class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13, class Ifc14, class Ifc15, class Ifc16, \
 class Ifc17, class Ifc18, class Ifc19, class Ifc20, class Ifc21, class Ifc22, class Ifc23, class Ifc24,\
-class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 , class Ifc32
+class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 , class Ifc32, class Ifc33
 
-#define __PUBLIC_IFC32 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \
+#define __PUBLIC_IFC33 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \
 public Ifc13, public Ifc14, public Ifc15, public Ifc16, public Ifc17, public Ifc18, \
 public Ifc19, public Ifc20, public Ifc21, public Ifc22, public Ifc23, public Ifc24, \
 public Ifc25, public Ifc26, public Ifc27, public Ifc28, public Ifc29, public Ifc30, \
-public Ifc31, public Ifc32
+public Ifc31, public Ifc32, public Ifc33
 #include <cppuhelper/implbase_ex.hxx>
 #include <cppuhelper/implbase_ex_pre.hxx>
-#define __IFC_EX_TYPE_INIT32( class_cast ) \
+#define __IFC_EX_TYPE_INIT33( class_cast ) \
     __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \
     __IFC_EX_TYPE_INIT( class_cast, 3 ), __IFC_EX_TYPE_INIT( class_cast, 4 ), \
     __IFC_EX_TYPE_INIT( class_cast, 5 ), __IFC_EX_TYPE_INIT( class_cast, 6 ), \
     __IFC_EX_TYPE_INIT( class_cast, 25 ), __IFC_EX_TYPE_INIT( class_cast, 26 ), \
     __IFC_EX_TYPE_INIT( class_cast, 27 ), __IFC_EX_TYPE_INIT( class_cast, 28 ), \
     __IFC_EX_TYPE_INIT( class_cast, 29 ), __IFC_EX_TYPE_INIT( class_cast, 30 ), \
-    __IFC_EX_TYPE_INIT( class_cast, 31 ), __IFC_EX_TYPE_INIT( class_cast, 32)
+    __IFC_EX_TYPE_INIT( class_cast, 31 ), __IFC_EX_TYPE_INIT( class_cast, 32 ), \
+    __IFC_EX_TYPE_INIT( class_cast, 33 )
 #include <cppuhelper/implbase_ex_post.hxx>
 
-__DEF_IMPLHELPER_EX( 32 )
+__DEF_IMPLHELPER_EX( 33 )
 
 namespace css = ::com::sun::star;
 
  ******************************************************************************/
 
 
-typedef cppu::WeakImplHelper32
+typedef cppu::WeakImplHelper33
 <
 	css::text::XTextDocument,
 	css::text::XLineNumberingProperties,
     css::xforms::XFormsSupplier,
     css::text::XFlatParagraphIteratorProvider,
 	css::document::XDocumentLanguages,
-    css::util::XCloneable
+    css::util::XCloneable,
+    ::com::sun::star::text::XFieldmarksSupplier
 >
 SwXTextDocumentBaseClass;
 
 	css::uno::Reference< css::container::XNameAccess > *			pxLinkTargetSupplier;
 	css::uno::Reference< css::container::XEnumerationAccess >* 	pxXRedlines;
 	css::uno::Reference< css::container::XNameContainer> 		xXFormsContainer;
+    ::com::sun::star::uno::Reference< ::com::sun::star::container::XContentEnumerationAccess >* pxFieldmarks;
 
     //temporary frame to enable PDF export if no valid view is available
     SfxViewFrame*                                   m_pHiddenViewFrame;
 	virtual css::uno::Reference< css::container::XEnumerationAccess >  SAL_CALL getTextFields(void) throw( css::uno::RuntimeException );
 	virtual css::uno::Reference< css::container::XNameAccess >  SAL_CALL getTextFieldMasters(void) throw( css::uno::RuntimeException );
 
-	// css::text::XTextEmbeddedObjectsSupplier
+    // ::com::sun::star::text::XFieldmarksSupplier
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XContentEnumerationAccess > SAL_CALL getFieldmarks(  ) throw (::com::sun::star::uno::RuntimeException);
+    
+    // css::text::XTextEmbeddedObjectsSupplier
 	virtual css::uno::Reference< css::container::XNameAccess >  SAL_CALL getEmbeddedObjects(void) throw( css::uno::RuntimeException );
 
 //	// css::text::XTextShapesSupplier

File sw/source/core/crsr/bookmrk.cxx

 #include <unobookmark.hxx>
 #include <rtl/random.h>
 #include <xmloff/odffields.hxx>
-
+#include <crsskip.hxx>
 
 SV_IMPL_REF( SwServerObject )
 
             rPos.nContent.Assign(pTxtNode, pTxtNode->Len());
         }
     };
-
-    static void lcl_AssureFieldMarksSet(Fieldmark* const pField,
-        SwDoc* const io_pDoc,
-        const sal_Unicode aStartMark,
-        const sal_Unicode aEndMark)
-    {
-        SwPosition& rStart = pField->GetMarkStart();
-        SwPosition& rEnd = pField->GetMarkEnd();
-        SwTxtNode const * const pStartTxtNode = io_pDoc->GetNodes()[rStart.nNode]->GetTxtNode();
-        SwTxtNode const * const pEndTxtNode = io_pDoc->GetNodes()[rEnd.nNode]->GetTxtNode();
-        const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
-        const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(rEnd.nContent.GetIndex()-1);
-        SwPaM aStartPaM(rStart);
-        SwPaM aEndPaM(rEnd);
-        io_pDoc->StartUndo(UNDO_UI_REPLACE, NULL);
-        if(ch_start != aStartMark)
-        {
-            io_pDoc->InsertString(aStartPaM, aStartMark);
-        }
-        if ( aEndMark && ( ch_end != aEndMark ) && ( rStart != rEnd ) )
-        {
-            io_pDoc->InsertString(aEndPaM, aEndMark);
-        }
-        io_pDoc->EndUndo(UNDO_UI_REPLACE, NULL);
-    };
 }
 
 namespace sw { namespace mark
     {
         return GetMarkStart() <= rPos && rPos <= GetMarkEnd();
     }
+    const SwPosition& MarkBase::GetMarkPos() const
+    { 
+        return *m_pPos1; 
+    }
+    const SwPosition& MarkBase::GetOtherMarkPos() const
+    {
+        OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
+        return *m_pPos2;
+    }
+    const ::rtl::OUString& MarkBase::GetName() const
+    { 
+        return m_aName; 
+    }
+    const SwPosition& MarkBase::GetMarkStart() const
+    {
+        if(!m_pPos2 /* !IsExpanded()*/) return *m_pPos1;
+        return *m_pPos1 < *m_pPos2 ? *m_pPos1 : *m_pPos2;
+    }
+    const SwPosition& MarkBase::GetMarkEnd() const
+    {
+        if(!m_pPos2 /* !IsExpanded()*/ ) return *m_pPos1;
+        return *m_pPos1 > *m_pPos2 ? *m_pPos1 : *m_pPos2;
+    }
+    bool MarkBase::IsExpanded() const
+    { 
+        return m_pPos2; 
+    }
+    void MarkBase::SetName(const ::rtl::OUString& rName)
+    { 
+        m_aName = rName; 
+    }
+    void MarkBase::ClearOtherMarkPos()
+    { 
+        m_pPos2.reset(); 
+    }
 
+    void MarkBase::Swap()
+    {
+        if(m_pPos2)
+            m_pPos1.swap(m_pPos2);
+    }
+    void MarkBase::InitDoc(SwDoc* const)
+    {
+    }
     void MarkBase::SetMarkPos(const SwPosition& rNewPos)
     {
         ::boost::scoped_ptr<SwPosition>(new SwPosition(rNewPos)).swap(m_pPos1);
     }
 
     MarkBase::~MarkBase()
-    { }
+    { 
+    }
 
     ::rtl::OUString MarkBase::GenerateNewName(const ::rtl::OUString& rPrefix)
     {
 
     NavigatorReminder::NavigatorReminder(const SwPaM& rPaM)
         : MarkBase(rPaM, our_sNamePrefix)
-    { }
+    { 
+    }
 
     const ::rtl::OUString NavigatorReminder::our_sNamePrefix = ::rtl::OUString::createFromAscii("__NavigatorReminder__");
 
     UnoMark::UnoMark(const SwPaM& aPaM)
         : MarkBase(aPaM, MarkBase::GenerateNewName(our_sNamePrefix))
-    { }
+    {
+    }
 
     const ::rtl::OUString UnoMark::our_sNamePrefix = ::rtl::OUString::createFromAscii("__UnoMark__");
 
     DdeBookmark::DdeBookmark(const SwPaM& aPaM)
         : MarkBase(aPaM, MarkBase::GenerateNewName(our_sNamePrefix))
         , m_aRefObj(NULL)
-    { }
+    {
+    }
 
     void DdeBookmark::SetRefObject(SwServerObject* pObj)
     {
         m_aName = rName;
     }
 
+    Bookmark::~Bookmark()
+    {
+    }    
+    
     void Bookmark::InitDoc(SwDoc* const io_pDoc)
     {
         if(io_pDoc->DoesUndo())
     Fieldmark::Fieldmark(const SwPaM& rPaM)
         : MarkBase(rPaM, MarkBase::GenerateNewName(our_sNamePrefix))
     {
-        if(!IsExpanded())
-            SetOtherMarkPos(GetMarkPos());
+        SwPaM aTempPaM( *rPaM.GetPoint() );
+        aTempPaM.SetMark();
+        String sMarkStartEnd;
+        sMarkStartEnd.AllocBuffer( 2 );
+        sal_Unicode* pStartEnd = sMarkStartEnd.GetBufferAccess();
+        pStartEnd[0] = CH_TXT_ATR_FIELDSTART;
+        pStartEnd[1] = CH_TXT_ATR_FIELDEND;
+        sMarkStartEnd.ReleaseBufferAccess( 2 );
+        aTempPaM.GetDoc()->InsertString( aTempPaM, sMarkStartEnd );
+        SwPosition aTmpPos( aTempPaM.Start()->nNode, aTempPaM.Start()->nContent );
+        --aTmpPos.nContent;
+        SetMarkPos( aTmpPos );
+        --aTmpPos.nContent;
+        SetOtherMarkPos(aTmpPos);
     }
 
+    Fieldmark::~Fieldmark()
+    {
+    }
+        
+    ::rtl::OUString Fieldmark::GetFieldname() const
+    { 
+        return m_aFieldname; 
+    }
+    ::rtl::OUString Fieldmark::GetFieldHelptext() const
+    { 
+        return m_aFieldHelptext; 
+    }
+
+    void Fieldmark::SetFieldname(const ::rtl::OUString& aFieldname)
+    { 
+        m_aFieldname = aFieldname; 
+    }
+    void Fieldmark::SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
+    { 
+        m_aFieldHelptext = aFieldHelptext; 
+    }
+
+    void Fieldmark::AssureFieldMarksSet( SwDoc* const io_pDoc )
+    {
+        const sal_Unicode uStartMark = CH_TXT_ATR_FIELDSTART;
+        const sal_Unicode uEndMark =  CH_TXT_ATR_FIELDEND;
+        const SwPosition& rStart = GetMarkStart();
+        const SwPosition& rEnd = GetMarkEnd();
+        SwTxtNode const * const pStartTxtNode = io_pDoc->GetNodes()[rStart.nNode]->GetTxtNode();
+        SwTxtNode const * const pEndTxtNode = io_pDoc->GetNodes()[rEnd.nNode]->GetTxtNode();
+        const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
+        const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(rEnd.nContent.GetIndex()-1);
+        const SwPaM aStartPaM(rStart);
+        const SwPaM aEndPaM(rEnd);
+        io_pDoc->StartUndo(UNDO_UI_REPLACE, NULL);
+        if(ch_start != uStartMark)
+        {
+            io_pDoc->InsertString(aStartPaM, uStartMark);
+        }
+        if(uEndMark && ch_end != uEndMark)
+        {
+            io_pDoc->InsertString(aStartPaM, uEndMark);
+        }
+        io_pDoc->EndUndo(UNDO_UI_REPLACE, NULL);
+    };
     rtl::OUString Fieldmark::ToString( ) const
     {
         rtl::OUStringBuffer buf;
 
     TextFieldmark::TextFieldmark(const SwPaM& rPaM)
         : Fieldmark(rPaM)
-    { }
-
-    void TextFieldmark::InitDoc(SwDoc* const io_pDoc)
     {
-        lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND);
     }
-
+    TextFieldmark::~TextFieldmark()
+    { 
+    }
+    void TextFieldmark::InitDoc(SwDoc* const /*io_pDoc*/)
+    {
+        //AssureFieldMarksSet(io_pDoc);
+    }
     CheckboxFieldmark::CheckboxFieldmark(const SwPaM& rPaM)
-        : Fieldmark(rPaM)
-    { }
+        : Fieldmark(rPaM),
+        m_bChecked( false )
+    { 
+    }
+    CheckboxFieldmark::~CheckboxFieldmark()
+    { 
+    }
 
     void CheckboxFieldmark::InitDoc(SwDoc* const io_pDoc)
     {
-        lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FORMELEMENT, CH_TXT_ATR_FIELDEND);
+        AssureFieldMarksSet(io_pDoc);
 
         // For some reason the end mark is moved from 1 by the Insert: we don't
         // want this for checkboxes
-        this->GetMarkEnd( ).nContent--;
+        OSL_ASSERT("mark end position might be wrong here!");
+        //this->GetMarkEnd( ).nContent--;
     }
     void CheckboxFieldmark::SetChecked(bool checked)
     {
-        (*GetParameters())[::rtl::OUString::createFromAscii(ODF_FORMCHECKBOX_RESULT)] = makeAny(checked);
+        m_bChecked = checked;
     }
 
     bool CheckboxFieldmark::IsChecked() const
     {
-        bool bResult = false;
-        parameter_map_t::const_iterator pResult = GetParameters()->find(::rtl::OUString::createFromAscii(ODF_FORMCHECKBOX_RESULT));
-        if(pResult != GetParameters()->end())
-            pResult->second >>= bResult;
-        return bResult;
+        return m_bChecked; 
     }
 
 }}

File sw/source/core/crsr/crbm.cxx

     return getIDocumentSettingAccess()->get(IDocumentSettingAccess::PROTECT_FORM);
 }
 
+::sw::mark::IRichFieldmark* SwCrsrShell::GetCurrentRichFieldmark()
+{
+    return getIDocumentMarkAccess()->getRichFieldmarkFor(*GetCrsr()->GetPoint());
+}
+
 ::sw::mark::IFieldmark* SwCrsrShell::GetCurrentFieldmark()
 {
     // TODO: Refactor

File sw/source/core/crsr/crstrvl.cxx

                     }
                 }
 
-                if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD )
+                if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD | SwContentAtPos::SW_FIELDMARK)
 					& rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo )
                 {
                     pTxtAttr = pTxtNd->GetTxtAttrForCharAt(
 						rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FIELD;
 						bRet = TRUE;
 					}
+                    //search for a Fieldmark
+                    
+                    ::sw::mark::IFieldmark* pFieldmark = GetDoc()->getIDocumentMarkAccess()->getFieldmarkFor(aPos);
+                    if( pFieldmark )
+                    {
+                        if( bSetCrsr )
+                        {
+                            //mark fieldmark
+                        }
+                        rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FIELDMARK;
+                        rCntntAtPos.aFnd.pFieldmark = pFieldmark;
+                        bRet = TRUE;
+                    }    
 				}
 
 		if( !bRet && SwContentAtPos::SW_FORMCTRL & rCntntAtPos.eCntntAtPos )
             sw::mark::IFieldmark* pFldBookmark = pMarksAccess->getFieldmarkFor( aPos );
 		    if( bCrsrFoundExact && pTxtNd && pFldBookmark) {
 			    rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FORMCTRL;
-    			rCntntAtPos.aFnd.pFldmark = pFldBookmark;
+                rCntntAtPos.aFnd.pFieldmark = pFldBookmark;
 	    		bRet=TRUE;
 		    }
 		}

File sw/source/core/doc/docbm.cxx

 #include <unocrsr.hxx>
 #include <viscrs.hxx>
 #include <stdio.h>
-
+#include <DateTimeFieldmark.hxx>
+#include <ReferenceFieldmark.hxx>
 
 using namespace ::std;
 using namespace ::boost;
         return CHECKBOX_FIELDMARK;
     else if(*pMarkTypeInfo == typeid(NavigatorReminder))
         return NAVIGATOR_REMINDER;
+    else if(*pMarkTypeInfo == typeid(DateTimeFieldmark))
+        return DATETIME_FIELD;
+    else if(*pMarkTypeInfo == typeid(ReferenceFieldmark))
+        return REFERENCE_FIELD;
     else
     {
         OSL_ENSURE(false,
             case IDocumentMarkAccess::UNO_BOOKMARK:
                 pMark = shared_ptr<IMark>(new UnoMark(rPaM));
                 break;
+            case IDocumentMarkAccess::DATETIME_FIELD:
+                pMark = shared_ptr<IMark>(new DateTimeFieldmark(rPaM));
+            break;
+            case IDocumentMarkAccess::REFERENCE_FIELD:
+                pMark = shared_ptr<IMark>(new ReferenceFieldmark(rPaM));
+            break;
         }
         OSL_ENSURE(pMark.get(),
             "MarkManager::makeMark(..)"
             // if(dynamic_cast<IFieldmark*>
                 lcl_InsertMarkSorted(m_vFieldmarks, pMark);
                 break;
+            case IDocumentMarkAccess::REFERENCE_FIELD:
+            case IDocumentMarkAccess::DATETIME_FIELD:
+                lcl_InsertMarkSorted(m_vRichFieldmarks, pMark);
+            break;
             case IDocumentMarkAccess::NAVIGATOR_REMINDER:
             case IDocumentMarkAccess::DDE_BOOKMARK:
             case IDocumentMarkAccess::UNO_BOOKMARK:
         lcl_DebugMarks(m_vBookmarks);
         OSL_TRACE("Fieldmarks");
         lcl_DebugMarks(m_vFieldmarks);
+        OSL_TRACE("RichFieldmarks");
+        lcl_DebugMarks(m_vRichFieldmarks);
 #endif
         return pMark.get();
     }
                 m_vFieldmarks.erase(ppFieldmark);
                 break;
             }
+            case IDocumentMarkAccess::REFERENCE_FIELD:
+            case IDocumentMarkAccess::DATETIME_FIELD:
+            {    
+                IDocumentMarkAccess::iterator_t ppFieldmark = lcl_FindMark(m_vRichFieldmarks, *ppMark);
+                OSL_ENSURE(ppFieldmark != m_vRichFieldmarks.end(),
+                    "<MarkManager::deleteMark(..)>"
+                    " - RichFieldmark not found.");
+                m_vRichFieldmarks.erase(ppFieldmark);
+            }
+            break;
             case IDocumentMarkAccess::NAVIGATOR_REMINDER:
             case IDocumentMarkAccess::DDE_BOOKMARK:
             case IDocumentMarkAccess::UNO_BOOKMARK:
     void MarkManager::clearAllMarks()
     {
         m_vFieldmarks.clear();
+        m_vRichFieldmarks.clear();
         m_vBookmarks.clear();
 #ifdef DEBUG
         for(iterator_t pBkmk = m_vMarks.begin();
             m_vFieldmarks.begin(),
             m_vFieldmarks.end( ),
             bind(&IMark::IsCoveringPosition, _1, rPos));
-        if(pFieldmark == m_vFieldmarks.end()) return NULL;
+        if(pFieldmark == m_vFieldmarks.end()) 
+            return NULL;
         return dynamic_cast<IFieldmark*>(pFieldmark->get());
     }
 
     IFieldmark* MarkManager::getFieldmarkBefore(const SwPosition& rPos) const
         { return dynamic_cast<IFieldmark*>(lcl_getMarkBefore(m_vFieldmarks, rPos)); }
 
+
+    /*-- 02.12.2009 12:49:23---------------------------------------------------
+
+      -----------------------------------------------------------------------*/
+    IRichFieldmark* MarkManager::makeRichFieldmark(const SwPaM& rPaM, const IFieldmarkData& rData, MarkType eMark)
+    {
+        //TODO: group undo 
+        m_pDoc->StartUndo( UNDO_FIELD, 0 );
+        IRichFieldmark* pRich = dynamic_cast< IRichFieldmark* >( makeMark( rPaM, ::rtl::OUString(), eMark ) );
+        OSL_ENSURE(pRich, "no rich fieldmark created");
+        if( pRich )
+        {
+            updateRichFieldmark( *pRich, rData );
+        }    
+        m_pDoc->EndUndo( UNDO_FIELD, 0 );
+        return pRich;
+    }
+
+    /*-- 02.12.2009 12:49:23---------------------------------------------------
+
+      -----------------------------------------------------------------------*/
+    void MarkManager::updateRichFieldmark( const sw::mark::IRichFieldmark& rToUpdate, const sw::mark::IFieldmarkData& rNew )
+    {
+        //todo: add Undo
+        RichFieldmark* pMark = dynamic_cast< RichFieldmark* >(&const_cast<sw::mark::IRichFieldmark&>(rToUpdate));
+        bool bRet = false;
+        if( pMark )
+        {
+            bRet = pMark->SetData( rNew );
+        }
+        OSL_ENSURE(bRet, "field mark data unchanged");
+        (void) bRet; //prevent warning
+    }
+    /*-- 04.12.2009 11:56:39---------------------------------------------------
+        
+      -----------------------------------------------------------------------*/
+    sal_Int32 MarkManager::getRichFieldmarksCount() const
+    {
+        return m_vRichFieldmarks.size();
+    }
+    /*-- 04.12.2009 11:56:39---------------------------------------------------
+        
+      -----------------------------------------------------------------------*/
+    IDocumentMarkAccess::const_iterator_t MarkManager::getRichFieldmarksBegin() const
+    {
+        return m_vRichFieldmarks.begin();
+    }
+    /*-- 04.12.2009 11:56:39---------------------------------------------------
+        
+      -----------------------------------------------------------------------*/
+    IDocumentMarkAccess::const_iterator_t MarkManager::getRichFieldmarksEnd() const
+    {
+        return m_vRichFieldmarks.end();
+    }
+    /*-- 04.12.2009 11:56:39---------------------------------------------------
+        
+      -----------------------------------------------------------------------*/
+    IRichFieldmark* MarkManager::getRichFieldmarkFor(const SwPosition& rPos) const
+    {
+        const_iterator_t pFieldmark = find_if(
+                m_vRichFieldmarks.begin(),
+                m_vRichFieldmarks.end(),
+            bind(&IMark::IsCoveringPosition, _1, rPos));
+
+        if(pFieldmark == m_vRichFieldmarks.end()) 
+            return NULL;
+        return dynamic_cast<IRichFieldmark*>(pFieldmark->get());
+    }
+    /*-- 04.12.2009 11:56:39---------------------------------------------------
+        
+      -----------------------------------------------------------------------*/
+    IRichFieldmark* MarkManager::getRichFieldmarkAfter(const SwPosition& rPos) const
+    { 
+        return dynamic_cast<IRichFieldmark*>(lcl_getMarkAfter(m_vRichFieldmarks, rPos)); 
+    }
+    /*-- 04.12.2009 11:56:39---------------------------------------------------
+        
+      -----------------------------------------------------------------------*/
+    IRichFieldmark* MarkManager::getRichFieldmarkBefore(const SwPosition& rPos) const
+    { 
+        return dynamic_cast<IRichFieldmark*>(lcl_getMarkBefore(m_vRichFieldmarks, rPos)); 
+    }
+                    
     ::rtl::OUString MarkManager::getUniqueMarkName(const ::rtl::OUString& rName) const
     {
         OSL_ENSURE(rName.getLength(),

File sw/source/core/doc/docfld.cxx

 #include <authfld.hxx>
 #include <txtinet.hxx>
 #include <fmtcntnt.hxx>
-#ifndef _POOLFMT_HRC
 #include <poolfmt.hrc>      // fuer InitFldTypes
-#endif
+#include <IDocumentMarkAccess.hxx>
+#include <IMark.hxx>
+
 
 #include <SwUndoField.hxx>
 
 		}
 	}
 
-	if( !IsExpFldsLocked() )
+    IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess();
+    for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getRichFieldmarksBegin();
+        ppMark != pMarkAccess->getRichFieldmarksEnd();ppMark++)
+    {
+        ::sw::mark::IRichFieldmark* pRichMark = dynamic_cast< ::sw::mark::IRichFieldmark* >(ppMark->get());
+        if( pRichMark )
+            pRichMark->Update();
+    }
+
+/*    
+        virtual void updateRichFieldmark( const sw::mark::IRichFieldmark& rToUpdate, 
+                                    const sw::mark::IFieldmarkData& rNew ) = 0;
+        virtual sal_Int32 getRichFieldmarksCount() const = 0;
+        virtual const_iterator_t getRichFieldmarksBegin() const = 0;
+    
+*/    
+    if( !IsExpFldsLocked() )
 		UpdateExpFlds( 0, FALSE );		// Expression-Felder Updaten
 
 	// Tabellen

File sw/source/core/edit/edfld.cxx

 	return pCurFld;
 }
 
-
 /*************************************************************************
 |*
 |*					SwEditShell::UpdateFlds()

File sw/source/core/inc/MarkManager.hxx

             virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& rPos) const;
             virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& rPos) const;
             virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& rPos) const;
+            
+            virtual ::sw::mark::IRichFieldmark* getRichFieldmarkFor(const SwPosition& rPos) const;
+            virtual ::sw::mark::IRichFieldmark* getRichFieldmarkBefore(const SwPosition& pos) const;
+            virtual ::sw::mark::IRichFieldmark* getRichFieldmarkAfter(const SwPosition& pos) const;
+            virtual ::sw::mark::IRichFieldmark* makeRichFieldmark(const SwPaM& rPaM, const ::sw::mark::IFieldmarkData& rData, MarkType eMark);
+            virtual const_iterator_t getRichFieldmarksBegin() const;
+            virtual const_iterator_t getRichFieldmarksEnd() const;
+            virtual void updateRichFieldmark( const sw::mark::IRichFieldmark& rToUpdate, const sw::mark::IFieldmarkData& rNew );
+            virtual sal_Int32 getRichFieldmarksCount() const;
 
         private:
             // make names
             container_t m_vMarks;
             container_t m_vBookmarks;
             container_t m_vFieldmarks;
+            container_t m_vRichFieldmarks;
             SwDoc * const m_pDoc;
     };
 }}

File sw/source/core/inc/bookmrk.hxx

     {
         public:
             //getters
-            virtual SwPosition& GetMarkPos() const
-                { return *m_pPos1; }
-            virtual const ::rtl::OUString& GetName() const
-                { return m_aName; }
+            virtual const SwPosition& GetMarkPos() const;
+            virtual const ::rtl::OUString& GetName() const;
             virtual bool IsCoveringPosition(const SwPosition& rPos) const;
-            virtual SwPosition& GetOtherMarkPos() const
-            {
-                OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
-                return *m_pPos2;
-            }
-            virtual SwPosition& GetMarkStart() const
-            {
-                if( !IsExpanded() ) return GetMarkPos( );
-                if ( GetMarkPos( ) < GetOtherMarkPos( ) )
-                    return GetMarkPos();
-                else
-                    return GetOtherMarkPos( );
-            }
-            virtual SwPosition& GetMarkEnd() const
-            {
-                if( !IsExpanded() ) return GetMarkPos();
-                if ( GetMarkPos( ) > GetOtherMarkPos( ) )
-                    return GetMarkPos( );
-                else
-                    return GetOtherMarkPos( );
-            }
-            virtual bool IsExpanded() const
-                { return m_pPos2; }
+            virtual const SwPosition& GetOtherMarkPos() const;
+            virtual const SwPosition& GetMarkStart() const;
+            virtual const SwPosition& GetMarkEnd() const;
+            virtual bool IsExpanded() const;
 
             //setters
-            virtual void SetName(const ::rtl::OUString& rName)
-                { m_aName = rName; }
+            virtual void SetName(const ::rtl::OUString& rName);
             virtual void SetMarkPos(const SwPosition& rNewPos);
             virtual void SetOtherMarkPos(const SwPosition& rNewPos);
-            virtual void ClearOtherMarkPos()
-                { m_pPos2.reset(); }
+            virtual void ClearOtherMarkPos();
 
             virtual rtl::OUString ToString( ) const;
 
-            virtual void Swap()
-            {
-                if(m_pPos2)
-                    m_pPos1.swap(m_pPos2);
-            }
+            virtual void Swap();
 
-            virtual void InitDoc(SwDoc* const)
-            {}
+            virtual void InitDoc(SwDoc* const);
 
             virtual ~MarkBase();
 
                 const KeyCode& rCode,
                 const ::rtl::OUString& rName,
                 const ::rtl::OUString& rShortName);
+            virtual ~Bookmark();
             virtual void InitDoc(SwDoc* const io_Doc);
 
             virtual const ::rtl::OUString& GetShortName() const
     {
         public:
             Fieldmark(const SwPaM& rPaM);
+            ~Fieldmark();
 
             // getters
-            virtual ::rtl::OUString GetFieldname() const
-                { return m_aFieldname; }
-            virtual ::rtl::OUString GetFieldHelptext() const
-                { return m_aFieldHelptext; }
+            virtual ::rtl::OUString GetFieldname() const;
+            virtual ::rtl::OUString GetFieldHelptext() const;
 
             virtual IFieldmark::parameter_map_t* GetParameters()
                 { return &m_vParams; }
                 { return &m_vParams; }
 
             // setters
-            virtual void SetFieldname(const ::rtl::OUString& aFieldname)
-                { m_aFieldname = aFieldname; }
-            virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
-                { m_aFieldHelptext = aFieldHelptext; }
+            virtual void SetFieldname(const ::rtl::OUString& aFieldname);
+            virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext);
 
             virtual void Invalidate();
             virtual rtl::OUString ToString() const;
+        protected:            
+            void AssureFieldMarksSet( SwDoc* const io_pDoc );
+
         private:
             ::rtl::OUString m_aFieldname;
             ::rtl::OUString m_aFieldHelptext;
     {
         public:
             TextFieldmark(const SwPaM& rPaM);
+            virtual ~TextFieldmark();
+            
             virtual void InitDoc(SwDoc* const io_pDoc);
     };
 
     {
         public:
             CheckboxFieldmark(const SwPaM& rPaM);
+            virtual ~CheckboxFieldmark();
             virtual void InitDoc(SwDoc* const io_pDoc);
             bool IsChecked() const;
             void SetChecked(bool checked);
+        private:
+            bool m_bChecked;
     };
 
 }}

File sw/source/core/text/inftxt.cxx

         {
             SwTxtNode *pNd = pFrm->GetTxtNode();
             const ::sw::mark::IMark* pFieldmark = NULL;
+            const ::sw::mark::IMark* pRichFieldmark = NULL;
             if(pNd)
             {
                 const SwDoc *doc=pNd->GetDoc();

File sw/source/core/unocore/unobkm.cxx

 }
 
 
-const ::sw::mark::IMark* SwXBookmark::GetBookmark() const
+::sw::mark::IMark* SwXBookmark::GetBookmark()
 {
     return m_pImpl->m_pRegisteredBookmark;
 }
     OSL_ENSURE(false,
         "SwXBookmark::removeVetoableChangeListener(): not implemented");
 }
+SwDoc* SwXBookmark::GetDoc() 
+{
+    return m_pImpl->m_pDoc;
+}    
 
 /******************************************************************
  * SwXFieldmark
         throw uno::RuntimeException();
     return uno::Reference<container::XNameContainer>(new SwXFieldmarkParameters(pBkm));
 }
-

File sw/source/core/unocore/unocoll.cxx

     { "com.sun.star.text.Fieldmark",                          SW_SERVICE_TYPE_FIELDMARK },
     { "com.sun.star.text.FormFieldmark",                      SW_SERVICE_TYPE_FORMFIELDMARK },
     { "com.sun.star.text.InContentMetadata",                  SW_SERVICE_TYPE_META },
+    { "com.sun.star.text.ReferenceFieldmark",                 SW_SERVICE_FIELDMARK_REFERENCE },
 
     // case-correct versions of the service names (see #i67811)
     { CSS_TEXT_TEXTFIELD_DATE_TIME,                   SW_SERVICE_FIELDTYPE_DATETIME },
         case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS       :
         case SW_SERVICE_FIELDTYPE_DROPDOWN                  :
         case SW_SERVICE_FIELDTYPE_TABLE_FORMULA:
+        case SW_SERVICE_FIELDMARK_REFERENCE:
             xRet = (cppu::OWeakObject*)new SwXTextField(nObjectType);
             break;
         case SW_SERVICE_FIELDTYPE_ANNOTATION:

File sw/source/core/unocore/unocrsrhelper.cxx

 #include <unosett.hxx>
 #include <unoframe.hxx>
 #include <unocrsr.hxx>
+#include <unorichfieldmark.hxx>
 #include <doc.hxx>
 #include <IDocumentRedlineAccess.hxx>
 #include <fmtftn.hxx>
 				eNewState = PropertyState_DEFAULT_VALUE;
 		}
 		break;
+        case FN_UNO_TEXT_FIELDMARK:
+        {
+            const SwPosition *pPos = rPam.Start();
+            IDocumentMarkAccess* const pMarkAccess = rPam.GetDoc()->getIDocumentMarkAccess();
+            ::sw::mark::IRichFieldmark* pRichMark = pMarkAccess->getRichFieldmarkFor( *pPos );
+            if( pRichMark )
+            {
+                if( rPam.HasMark() )
+                {
+                    const SwPosition *pEnd = rPam.End();
+                    if( pMarkAccess->getRichFieldmarkFor( *pEnd ) != pRichMark )
+                        pRichMark = 0;
+                }    
+            }
+            if( pRichMark )
+            {
+                SwXBookmark* pFieldmark = new SwXRichFieldmark( *pRichMark, *rPam.GetDoc() );
+                *pAny <<= uno::Reference< text::XTextContent >(pFieldmark);
+            }    
+            else
+                eNewState = PropertyState_DEFAULT_VALUE;
+
+        }        
+        break;
 /*				laesst sich nicht feststellen
 * 				case FN_UNO_BOOKMARK:
 		{

File sw/source/core/unocore/unofield.cxx

 #include <editeng/outliner.hxx>
 #include <docsh.hxx>
 #include <fmtmeta.hxx> // MetaFieldManager
+#include <fieldmarkdata.hxx>
 
 using ::rtl::OUString;
 using namespace ::com::sun::star;
 	case SW_SERVICE_FIELDMASTER_DUMMY4:
 	case SW_SERVICE_FIELDMASTER_DUMMY5: nRet = PROPERTY_MAP_FLDMSTR_DUMMY0; break;
 	case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT: nRet = PROPERTY_MAP_FLDTYP_HIDDEN_TEXT; break;
+    case SW_SERVICE_FIELDMARK_REFERENCE: nRet = PROPERTY_MAP_FIELDMARK_REFERENCE; break;
 	default:
 		DBG_ERROR( "wrong service id" );
 		nRet = USHRT_MAX;
 			break;
 			case SW_SERVICE_FIELDTYPE_DATETIME:
 			{
-				sal_uInt16 nSub = 0;
+/*               sal_uInt16 nSub = 0;
 				if(m_pProps->bBool1)
 					nSub |= FIXEDFLD;
 				if(m_pProps->bBool2)
 					pFld->PutValue( aVal, FIELD_PROP_DATE_TIME );
 				}
 				((SwDateTimeField*)pFld)->SetOffset(m_pProps->nSubType);
+ */
+                sw::mark::DateTimeFieldmarkData aDateTimeData(
+                    m_pProps->bBool4, m_pProps->nFormat, m_pProps->pDateTime, 
+                                m_pProps->bBool1, m_pProps->bBool2, m_pProps->nSubType);
+                m_pFieldmark = 
+                    dynamic_cast< ::sw::mark::IRichFieldmark*>( pDoc->getIDocumentMarkAccess()->makeRichFieldmark(
+                        aPam, aDateTimeData, IDocumentMarkAccess::DATETIME_FIELD));
+                m_pFieldmark->Update();
 			}
 			break;
+            case SW_SERVICE_FIELDMARK_REFERENCE:
+            {    
+                sw::mark::ReferenceFieldmarkData aReferenceData( m_pProps->sPar1 );
+                m_pFieldmark = 
+                    dynamic_cast< ::sw::mark::IRichFieldmark*>( pDoc->getIDocumentMarkAccess()->makeRichFieldmark(
+                        aPam, aReferenceData, IDocumentMarkAccess::REFERENCE_FIELD));
+                m_pFieldmark->Update();
+            }
+            break;
 			case SW_SERVICE_FIELDTYPE_FILE_NAME:
 			{
 				SwFieldType* pFldType = pDoc->GetSysFldType(RES_FILENAMEFLD);
 		const_cast<SwFmtFld*>(pFmtFld)->Modify( 0, 0 );
 		// <--
     }
+    else if( m_pFieldmark && GetRegisteredIn() )
+    {
+        m_pFieldmark->Update();
+    }    
     else
         m_bCallUpdate = sal_True;
 }
  *
  * --------------------------------------------------*/
 
-static OUString OldNameToNewName_Impl( const OUString &rOld )
+OUString OldNameToNewName_Impl( const OUString &rOld )
 {
 	static OUString aOldNamePart1( OUString::createFromAscii(".TextField.DocInfo.") );
 	static OUString aOldNamePart2( OUString::createFromAscii(".TextField.") );
 		((SwModify*)GetRegisteredIn())->Remove(this);
 		aLstnrCntnr.Disposing();
 		pFmtFld = 0;
+        m_pFieldmark = 0;
 		m_pDoc = 0;
 	}
 }

File sw/source/core/unocore/unomap.cxx

                     { SW_PROP_NMID(UNO_NAME_IS_FIELD_USED),      FIELD_PROP_IS_FIELD_USED,      CPPU_E2T(CPPUTYPE_FLOAT), PropertyAttribute::READONLY, 0},\
                     { SW_PROP_NMID(UNO_NAME_IS_FIELD_DISPLAYED), FIELD_PROP_IS_FIELD_DISPLAYED, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::READONLY, 0},\
 
+#define _DATETIMEFIELD_PROPERTIES \
+                    {SW_PROP_NMID(UNO_NAME_ADJUST), FIELD_PROP_SUBTYPE,     CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE,    0},\
+                    {SW_PROP_NMID(UNO_NAME_DATE_TIME_VALUE), FIELD_PROP_DATE_TIME,  CPPU_E2T(CPPUTYPE_DATETIME), PROPERTY_NONE, 0},\
+                    {SW_PROP_NMID(UNO_NAME_IS_FIXED),       FIELD_PROP_BOOL1,   CPPU_E2T(CPPUTYPE_BOOLEAN)  , PROPERTY_NONE,0},\
+                    {SW_PROP_NMID(UNO_NAME_IS_DATE),    FIELD_PROP_BOOL2,   CPPU_E2T(CPPUTYPE_BOOLEAN)  , PROPERTY_NONE,0},\
+                    {SW_PROP_NMID(UNO_NAME_NUMBER_FORMAT), FIELD_PROP_FORMAT,   CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE,    0},\
+                    {SW_PROP_NMID(UNO_NAME_IS_FIXED_LANGUAGE), FIELD_PROP_BOOL4, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE,    0},
 
 const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(sal_uInt16 nPropertyId)
 {
 			{
                 static SfxItemPropertyMapEntry aDateTimeFieldPropMap[] =
 				{
-					{SW_PROP_NMID(UNO_NAME_ADJUST), FIELD_PROP_SUBTYPE, 	CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE,	0},
-					{SW_PROP_NMID(UNO_NAME_DATE_TIME_VALUE), FIELD_PROP_DATE_TIME,  CPPU_E2T(CPPUTYPE_DATETIME), PROPERTY_NONE,	0},
-					{SW_PROP_NMID(UNO_NAME_IS_FIXED),		FIELD_PROP_BOOL1,	CPPU_E2T(CPPUTYPE_BOOLEAN)  , PROPERTY_NONE,0},
-					{SW_PROP_NMID(UNO_NAME_IS_DATE), 	FIELD_PROP_BOOL2,	CPPU_E2T(CPPUTYPE_BOOLEAN)  , PROPERTY_NONE,0},
-					{SW_PROP_NMID(UNO_NAME_NUMBER_FORMAT), FIELD_PROP_FORMAT,	CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE,	0},
-                    {SW_PROP_NMID(UNO_NAME_IS_FIXED_LANGUAGE), FIELD_PROP_BOOL4, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE,    0},
+                    _DATETIMEFIELD_PROPERTIES
                     COMMON_FLDTYP_PROPERTIES
                     {0,0,0,0,0,0}
 				};
                 aMapEntriesArr[nPropertyId] = aMetaFieldMap;
             }
             break;
-
+            case PROPERTY_MAP_FIELDMARK_DATETIME:
+            {    
+                static SfxItemPropertyMapEntry aDateTimeFieldmarkPropMap[] =
+                {
+                    COMMON_TEXT_CONTENT_PROPERTIES
+                    _DATETIMEFIELD_PROPERTIES
+                    COMMON_FLDTYP_PROPERTIES
+                    {0,0,0,0,0,0}
+                };
+                aMapEntriesArr[nPropertyId] = aDateTimeFieldmarkPropMap;
+            }
+            break;
+            case PROPERTY_MAP_FIELDMARK_REFERENCE:
+            {    
+                static SfxItemPropertyMapEntry aReferenceFieldmarkPropMap[] =
+                {
+                    COMMON_TEXT_CONTENT_PROPERTIES
+                    {SW_PROP_NMID(UNO_NAME_SOURCE_NAME),        FIELD_PROP_PAR1,    CPPU_E2T(CPPUTYPE_OUSTRING),   PROPERTY_NONE, 0},
+                    COMMON_FLDTYP_PROPERTIES
+                    {0,0,0,0,0,0}
+                };
+                aMapEntriesArr[nPropertyId] = aReferenceFieldmarkPropMap;
+            }
+            break;
             default:
                 DBG_ERROR( "unexpected property map ID" );
 		}
                 aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_METAFIELD;
             }
             break;
+            case PROPERTY_MAP_FIELDMARK_DATETIME:
+            {
+                static SfxItemPropertySet aPROPERTY_MAP_FIELDMARK_DATETIME(pEntries);
+                aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FIELDMARK_DATETIME;
+            }
+            break;
+            case PROPERTY_MAP_FIELDMARK_REFERENCE:
+            {
+                static SfxItemPropertySet aPROPERTY_MAP_FIELDMARK_REFERENCE(pEntries);
+                aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FIELDMARK_REFERENCE;
+            }
+            break;
         }
     }
     return aPropertySetArr[nPropertyId];

File sw/source/core/unocore/unoport.cxx

                 case PORTION_FIELD_START:pRet = "TextFieldStart";break;
                 case PORTION_FIELD_END:pRet = "TextFieldEnd";break;
                 case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break;
+                case PORTION_FIELDMARK_START:pRet = "TextFieldmarkStart";break;
+                case PORTION_FIELDMARK_END:  pRet = "TextFieldmarkEnd";break;
                 default:
                     pRet = 0;
                 }

File sw/source/core/unocore/unoportenum.cxx

 #include <boost/bind.hpp>
 #include <algorithm>
 #include <stack>
+#include <map>
 
 
 using namespace ::com::sun::star;
             }
         }
     }
+    typedef std::map< xub_StrLen, bool > RichFieldmarks_t;
+    static void lcl_FillRichFieldmarkArray(SwDoc& rDoc, SwUnoCrsr& rUnoCrsr, RichFieldmarks_t& rRichFieldmarks)
+    {
+        IDocumentMarkAccess* const pMarkAccess = rDoc.getIDocumentMarkAccess();
+        if(!pMarkAccess->getRichFieldmarksCount())
+            return;
+
+        // no need to consider marks starting after aEndOfPara
+        SwPosition aEndOfPara(*rUnoCrsr.GetPoint());
+        aEndOfPara.nContent = aEndOfPara.nNode.GetNode().GetTxtNode()->Len();
+        const IDocumentMarkAccess::const_iterator_t pCandidatesEnd = upper_bound(
+            pMarkAccess->getRichFieldmarksBegin(),
+            pMarkAccess->getRichFieldmarksEnd(),
+            aEndOfPara,
+            bind(&::sw::mark::IMark::StartsAfter, _2, _1)); // finds the first that starts after
+
+        // search for all bookmarks that start or end in this paragraph
+        const SwNodeIndex nOwnNode = rUnoCrsr.GetPoint()->nNode;
+        for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getRichFieldmarksBegin();
+            ppMark != pCandidatesEnd;
+            ++ppMark)
+        {
+            ::sw::mark::IMark* const pRichmark = ppMark->get();
+            bool hasOther = pRichmark->IsExpanded();
+
+            const SwPosition& rStartPos = pRichmark->GetMarkStart();
+            if(rStartPos.nNode == nOwnNode)
+            {
+                xub_StrLen nIndex = rStartPos.nContent.GetIndex();
+                const sal_Unicode cChar = rStartPos.nNode.GetNode().GetTxtNode()->GetTxt().GetChar(nIndex);
+                OSL_ENSURE( CH_TXT_ATR_FIELDSTART == cChar,"wrong character at field mark start");
+                rRichFieldmarks[nIndex] = true;
+            }
+
+            const SwPosition& rEndPos = pRichmark->GetMarkEnd();
+            if(rEndPos.nNode == nOwnNode)
+            {
+                auto_ptr<SwPosition> pCrossRefEndPos;
+                const SwPosition* pEndPos = NULL;
+                if(hasOther)
+                {
+                    xub_StrLen nIndex = rEndPos.nContent.GetIndex();
+                    const sal_Unicode cChar = rEndPos.nNode.GetNode().GetTxtNode()->GetTxt().GetChar(nIndex);
+                    OSL_ENSURE( CH_TXT_ATR_FIELDEND == cChar,"wrong character at field mark start");
+                    rRichFieldmarks[nIndex] = false;
+                }
+            }
+        }
+    }   
 }
 
 
     }
 
     const sal_Unicode Char = pTxtNode->GetTxt().GetChar(start);
-    if (CH_TXT_ATR_FIELDSTART == Char)
+    ::sw::mark::IFieldmark* pFieldmark = pDoc->getIDocumentMarkAccess()->
+                getFieldmarkFor(*pUnoCrsr->GetMark());
+    if( pFieldmark )
     {
-        ::sw::mark::IFieldmark* pFieldmark = NULL;
-        if (pDoc)
+        if (CH_TXT_ATR_FIELDSTART == Char)
         {
-            pFieldmark = pDoc->getIDocumentMarkAccess()->
-                getFieldmarkFor(*pUnoCrsr->GetMark());
+            SwXTextPortion* pPortion = new SwXTextPortion(
+                pUnoCrsr, i_xParentText, PORTION_FIELD_START);
+            xRef = pPortion;
+            if (pPortion && pFieldmark && pDoc)
+                pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
         }
-        SwXTextPortion* pPortion = new SwXTextPortion(
-            pUnoCrsr, i_xParentText, PORTION_FIELD_START);
-        xRef = pPortion;
-        if (pPortion && pFieldmark && pDoc)
-            pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
-    }
-    else if (CH_TXT_ATR_FIELDEND == Char)
-    {
-        ::sw::mark::IFieldmark* pFieldmark = NULL;
-        if (pDoc)
+        else if (CH_TXT_ATR_FIELDEND == Char)
         {
-            pFieldmark = pDoc->getIDocumentMarkAccess()->
-                getFieldmarkFor(*pUnoCrsr->GetMark());
+            SwXTextPortion* pPortion = new SwXTextPortion(
+                pUnoCrsr, i_xParentText, PORTION_FIELD_END);
+            xRef = pPortion;
+            if (pPortion && pFieldmark && pDoc)
+                pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
         }
-        SwXTextPortion* pPortion = new SwXTextPortion(
-            pUnoCrsr, i_xParentText, PORTION_FIELD_END);
-        xRef = pPortion;
-        if (pPortion && pFieldmark && pDoc)
-            pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
-    }
-    else if (CH_TXT_ATR_FORMELEMENT == Char)
-    {
-        ::sw::mark::IFieldmark* pFieldmark = NULL;
-        if (pDoc)
+        else if (CH_TXT_ATR_FORMELEMENT == Char)
         {
-            pFieldmark = pDoc->getIDocumentMarkAccess()->
-                getFieldmarkFor(*pUnoCrsr->GetMark());
+            SwXTextPortion* pPortion = new SwXTextPortion(
+                pUnoCrsr, i_xParentText, PORTION_FIELD_START_END);
+            xRef = pPortion;
+            if (pPortion && pFieldmark && pDoc)
+                pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc));
         }
-        SwXTextPortion* pPortion = new SwXTextPortion(
-            pUnoCrsr, i_xParentText, PORTION_FIELD_START_END);
-        xRef = pPortion;
-        if (pPortion && pFieldmark && pDoc)
-            pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc));
-    }
-    else
-    {
-        ASSERT(false, "no fieldmark found?");
+        else
+        {
+            ASSERT(false, "no fieldmark found?");
+        }
     }
     return xRef;
 }
 		rBkmArr.erase( aIter++ );
 	}
 }
+static void
+lcl_ExportFieldmarks(
+    TextRangeList_t& rPortions, 
+    Reference<XText> const& xParent, 
+    SwUnoCrsr * const pUnoCrsr, 
+    RichFieldmarks_t& rRichFieldmarks, 
+    const ULONG nIndex )
+{
+    RichFieldmarks_t::iterator aElement = rRichFieldmarks.find( xub_StrLen( nIndex ) );
+    if( aElement != rRichFieldmarks.end() )
+    {
+        pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE);
+        SwXTextPortion* pPortion = 0;
+            pPortion =
+                new SwXTextPortion(pUnoCrsr, xParent, aElement->second ? PORTION_FIELDMARK_START : PORTION_FIELDMARK_END );
+        rPortions.push_back(pPortion);
+        *pUnoCrsr->Start() = *pUnoCrsr->End();
+        rRichFieldmarks.erase( aElement );
+    }    
+}    
 
 static void
 lcl_ExportSoftPageBreak(
 lcl_ExportBkmAndRedline(
     TextRangeList_t & rPortions,
     Reference<XText> const & xParent,
-    const SwUnoCrsr * const pUnoCrsr,
+    SwUnoCrsr * const pUnoCrsr,
     SwXBookmarkPortion_ImplList& rBkmArr,
     SwXRedlinePortion_ImplList& rRedlineArr,
     SwSoftPageBreakList& rBreakArr,
+    RichFieldmarks_t& rRichFieldmarks,
     const ULONG nIndex)
 {
     if (rBkmArr.size())
 
     if (rBreakArr.size())
         lcl_ExportSoftPageBreak(rPortions, xParent, pUnoCrsr, rBreakArr, nIndex);
+
+    if( rRichFieldmarks.size() )
+        lcl_ExportFieldmarks(rPortions, xParent, pUnoCrsr, rRichFieldmarks, nIndex );
 }
 
 //-----------------------------------------------------------------------------
 lcl_GetNextIndex(
     SwXBookmarkPortion_ImplList const & rBkmArr,
     SwXRedlinePortion_ImplList const & rRedlineArr,
-    SwSoftPageBreakList const & rBreakArr )
+    SwSoftPageBreakList const & rBreakArr, 
+    RichFieldmarks_t& rRichFieldmarks )
 {
 	sal_Int32 nRet = -1;
 	if(rBkmArr.size())
 		if(nRet < 0 || *rBreakArr.begin() < static_cast<sal_uInt32>(nRet))
 			nRet = *rBreakArr.begin();
 	}
+    if( rRichFieldmarks.size() )
+    {
+        xub_StrLen nPos = rRichFieldmarks.begin()->first;
+        if( nRet < 0 || nPos < static_cast<xub_StrLen>(nRet))
+            nRet = nPos;
+    }    
 	return nRet;
 };
 
 
     FieldMarks_t FieldMarks;
     SwXBookmarkPortion_ImplList Bookmarks;
+    RichFieldmarks_t RichFieldmarks;
     SwXRedlinePortion_ImplList Redlines;
     SwSoftPageBreakList SoftPageBreaks;
 
     SwDoc * const pDoc = pUnoCrsr->GetDoc();
     lcl_FillFieldMarkArray(FieldMarks, *pUnoCrsr, i_nStartPos);
     lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, Bookmarks);
+    lcl_FillRichFieldmarkArray(*pDoc, *pUnoCrsr, RichFieldmarks);
     lcl_FillRedlineArray(*pDoc, *pUnoCrsr, Redlines);
     lcl_FillSoftPageBreakArray(*pUnoCrsr, SoftPageBreaks);
 
                 i_xParentText, pUnoCrsr, i_rFrames, nCurrentIndex);
 
         lcl_ExportBkmAndRedline( *PortionStack.top().first, i_xParentText,
-            pUnoCrsr, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex );
+            pUnoCrsr, Bookmarks, Redlines, SoftPageBreaks, RichFieldmarks, nCurrentIndex );
 
         bool bCursorMoved( false );
         sal_Int32 nNextAttrIndex = -1;
         if (!bAtEnd && !xRef.is() && !bCursorMoved)
         {
             const sal_Int32 nNextPortionIndex =
-                lcl_GetNextIndex(Bookmarks, Redlines, SoftPageBreaks);
+                lcl_GetNextIndex(Bookmarks, Redlines, SoftPageBreaks, RichFieldmarks);
             const sal_Int32 nNextFieldMarkIndex(
                     FieldMarks.size() ? FieldMarks.front() : -1);
 

File sw/source/core/unocore/unoprnms.cxx

 /* 0737 UNO_NAME_DESCRIPTION */         {MAP_CHAR_LEN("Description")},
 /* 0738 UNO_NAME_META */        {MAP_CHAR_LEN("InContentMetadata")},
 /* 0739 UNO_NAME_NESTED_TEXT_CONTENT */ {MAP_CHAR_LEN("NestedTextContent")},
+/* 0740 UNO_NAME_TEXT_FIELDMARK */{MAP_CHAR_LEN("TextFieldmark")},
 };
 
 const SwPropNameLen& SwGetPropName( USHORT nId )

File sw/source/ui/dialog/swdlgfact.cxx

 #include <svx/dialogs.hrc>
 #include <mailmergewizard.hxx>
 #include <mailconfigpage.hxx>
+#include <fieldmarkdialog.hxx>
 
 using namespace ::com::sun::star;
 
 IMPL_ABSTDLG_BASE(AbstarctSwSelGlossaryDlg_Impl);//add for SwSelGlossaryDlg
 IMPL_ABSTDLG_BASE(AbstractSwAutoFormatDlg_Impl); //add for SwAutoFormatDlg
 IMPL_ABSTDLG_BASE(AbstractSwFldDlg_Impl); //add for SwFldDlg
+IMPL_ABSTDLG_BASE(AbstractSwFieldmarkDialog_Impl);
 IMPL_ABSTDLG_BASE(AbstractSwRenameXNamedDlg_Impl); //add for SwRenameXNamedDlg
 IMPL_ABSTDLG_BASE(AbstractSwModalRedlineAcceptDlg_Impl); //add for SwModalRedlineAcceptDlg
 IMPL_ABSTDLG_BASE(AbstractGlossaryDlg_Impl);
 
 //add for SwRenameXNamedDlg begin
 
+const sw::mark::IFieldmarkData& AbstractSwFieldmarkDialog_Impl::GetChangedData() const
+{
+    return pDlg->GetChangedData();
+}    
+
 void AbstractSwRenameXNamedDlg_Impl::SetForbiddenChars( const String& rSet )
 {
 	pDlg->SetForbiddenChars( rSet );
 	return 0;
 }
 //add for SwFldEditDlg
+AbstractSwFieldmarkDialog*   SwAbstractDialogFactory_Impl::CreateFieldmarkDialog( 
+                        SwView& rVw, const sw::mark::IRichFieldmark& rCurFieldmark )
+{
+    SwFieldmarkDialog* pDlg = new SwFieldmarkDialog( rVw, rCurFieldmark );
+    return new AbstractSwFieldmarkDialog_Impl( pDlg );
+}
 
 //add for SwRenameXNamedDlg begin
 AbstractSwRenameXNamedDlg * SwAbstractDialogFactory_Impl::CreateSwRenameXNamedDlg( Window* pParent,

File sw/source/ui/dialog/swdlgfact.hxx

 class SwSelGlossaryDlg;
 class SwAutoFormatDlg;
 class SwFldDlg;
+class SwFieldmarkDialog;
 class SwRenameXNamedDlg;
 class SwModalRedlineAcceptDlg;
 class SwTOXMark;
 };
 //add for SwFldD end
 
+class AbstractSwFieldmarkDialog_Impl : public AbstractSwFieldmarkDialog
+{
+    DECL_ABSTDLG_BASE(AbstractSwFieldmarkDialog_Impl, SwFieldmarkDialog )
+    virtual const sw::mark::IFieldmarkData& GetChangedData() const;
+};    
+
 //add for SwRenameXNamedDlg begin
 class AbstractSwRenameXNamedDlg_Impl : public AbstractSwRenameXNamedDlg
 {
 														const SfxItemSet* pItemSet, SwWrtShell* pSh,int nResId ); //add for SwTableTabDlg
 	virtual AbstractSwFldDlg * CreateSwFldDlg ( SfxBindings* pB, SwChildWinWrapper* pCW, Window *pParent, int nResId ); //add for SwFldDlg
 	virtual SfxAbstractDialog*	 CreateSwFldEditDlg ( SwView& rVw, int nResId ); //add for SwFldEditDlg
+    virtual AbstractSwFieldmarkDialog*  CreateFieldmarkDialog( SwView& rVw, const sw::mark::IRichFieldmark& rCurFieldmark );
 	virtual AbstractSwRenameXNamedDlg * CreateSwRenameXNamedDlg( Window* pParent, //add for SwRenameXNamedDlg
 																STAR_REFERENCE( container::XNamed ) & xNamed,
 																STAR_REFERENCE( container::XNameAccess ) & xNameAccess, int nResId );

File sw/source/ui/docvw/edtwin.cxx

                             }
                             else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos )
                             {
-                                ASSERT( aCntntAtPos.aFnd.pFldmark != NULL, "where is my field ptr???");
-                                if ( aCntntAtPos.aFnd.pFldmark != NULL)
+                                ASSERT( aCntntAtPos.aFnd.pFieldmark != NULL, "where is my field ptr???");
+                                if ( aCntntAtPos.aFnd.pFieldmark != NULL)
                                 {
-                                    IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFldmark );
+                                    IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFieldmark );
                                     //SwDocShell* pDocSh = rView.GetDocShell();
                                     //SwDoc *pDoc=pDocSh->GetDoc();
                                     if (fieldBM->GetFieldname( ).equalsAscii( ODF_FORMCHECKBOX ) )

File sw/source/ui/docvw/edtwin2.cxx

 		SwRect aFldRect;
         USHORT nStyle = 0; // style of quick help
 		SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD |
+                                    SwContentAtPos::SW_FIELDMARK |
 									SwContentAtPos::SW_INETATTR |
 									SwContentAtPos::SW_FTN |
 									SwContentAtPos::SW_REDLINE |

File sw/source/ui/fldui/fldmgr.cxx

 #include <flddropdown.hxx>
 #include <fldui.hrc>
 #include <tox.hxx>
+#include <fieldmarkdata.hxx>
+#include <memory>
 
 using rtl::OUString;
 using namespace com::sun::star::uno;