Index: inc/IDocumentBookmarkAccess.hxx =================================================================== RCS file: /cvs/sw/sw/inc/IDocumentBookmarkAccess.hxx,v --- inc/IDocumentBookmarkAccess.hxx 11 Oct 2006 08:41:22 -0000 1.3 +++ inc/IDocumentBookmarkAccess.hxx 5 Apr 2007 12:08:45 -0000 @@ -45,22 +45,24 @@ class SwPaM; class KeyCode; class String; +class SwFieldBookmark; /** Provides access to the bookmarks of a document. */ class IDocumentBookmarkAccess { public: - enum BookmarkType - { - BOOKMARK, - MARK, - DDE_BOOKMARK, + enum BookmarkType + { + BOOKMARK, + MARK, + DDE_BOOKMARK, UNO_BOOKMARK, - HIDDEN_BOOKMARK + HIDDEN_BOOKMARK, + FIELD_BOOKMARK }; - - public: + + public: /** Returns all bookmarks set at the document. @returns @@ -92,6 +94,15 @@ /*[in]*/const String& rName, /*[in]*/const String& rShortName, /*[in]*/BookmarkType eMark ) = 0; + /** insert bookmark based field + @param pBookmarkField + [in] the to-be-inserted bookmark, SwPositions are already set, this takes ownership + @returns + result of the insert operation, if false pBookmarkField is invalid + */ + virtual bool insertField(/*[in]*/ SwFieldBookmark* pBookmarkField) = 0; + + /** Deletes a bookmark. @param nPos @@ -147,7 +158,7 @@ the bookmark. */ virtual SwBookmark& getBookmark( /*[in]*/sal_uInt16 nPos, /*[in]*/bool bBkmrk) = 0; - + protected: virtual ~IDocumentBookmarkAccess() {}; }; Index: inc/bookmrk.hxx =================================================================== RCS file: /cvs/sw/sw/inc/bookmrk.hxx,v --- inc/bookmrk.hxx 8 Nov 2006 13:20:14 -0000 1.8 +++ inc/bookmrk.hxx 5 Apr 2007 12:08:45 -0000 @@ -61,14 +61,18 @@ #define SW_DECL_SWSERVEROBJECT_DEFINED SV_DECL_REF( SwServerObject ) #endif - - -struct SwPosition; // fwd Decl. wg. UI +#ifndef _FLDBAS_HXX +#include +#endif + +namespace com{ namespace sun{ namespace star{ namespace uno{ + class Any; +}}}} +struct SwPosition; // fwd Decl. wg. UI class SwBookmark : public SwModify { friend class SwDoc; // fuers Loeschen -// friend class Sw3IoImp; // fuers Setzen der Position(en) SwPosition *pPos1, *pPos2; // wird im CTOR gesetzt, im DTOR geloescht // pPos1 is always != 0, pPos2 may be 0 @@ -82,10 +86,13 @@ KeyCode aCode; IDocumentBookmarkAccess::BookmarkType eMarkType; + void setNewPositions( const SwPaM& rNew ); + public: TYPEINFO(); SwBookmark(const SwPosition& aPos); + SwBookmark(const SwPosition& rPos, const SwPosition& rSecondPos); SwBookmark(const SwPosition& aPos, const KeyCode& rCode, const String& rName, const String& rShortName); @@ -113,6 +120,7 @@ BOOL IsDDEMark() const { return IDocumentBookmarkAccess::DDE_BOOKMARK == eMarkType; } BOOL IsUNOMark() const { return IDocumentBookmarkAccess::UNO_BOOKMARK == eMarkType; } BOOL IsHiddenBookMark() const { return IDocumentBookmarkAccess::HIDDEN_BOOKMARK == eMarkType; } + BOOL IsFieldBookMark() const { return IDocumentBookmarkAccess::FIELD_BOOKMARK == eMarkType; } void SetType( IDocumentBookmarkAccess::BookmarkType eNewType ) { eMarkType = eNewType; } IDocumentBookmarkAccess::BookmarkType GetType() const { return eMarkType; } @@ -159,6 +167,48 @@ const KeyCode& rCode, const String& rName, const String& rShortName); }; +/*-----------------02.04.2007 08:37-----------------*/ +/** Base class of bookmark-like field implementation + */ +class SwFieldBookmark : public SwBookmark +{ + RES_FIELDS m_eFieldType; +public: + SwFieldBookmark(const SwPosition& rPos, const SwPosition& rOtherPos, RES_FIELDS eFieldType ); + virtual ~SwFieldBookmark(); + + void setPresentation( const ::rtl::OUString rPresentation ); + RES_FIELDS GetFieldResId() const { return m_eFieldType;} + + virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, BYTE nMId ) const; + virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, BYTE nMId ); +}; + +/*-----------------02.04.2007 08:37-----------------*/ +/** Successor of SwInputField + @param rHint + [in] the hint will be displayed as fly over help + @param rUserFieldname + [in] contains the name of the related SwUserFieldType if the field should be connected to it + */ +class SwInputFieldBookmark : public SwFieldBookmark +{ + ::rtl::OUString m_sHint; + ::rtl::OUString m_sUserFieldName; + +public: + SwInputFieldBookmark( + const SwPaM& rPaM, + const ::rtl::OUString& rHint, + const ::rtl::OUString& rUserFieldName ); + virtual ~SwInputFieldBookmark(); + + const ::rtl::OUString& GetHint() const { return m_sHint; } + const ::rtl::OUString& GetUserFieldName() const { return m_sUserFieldName; } + + virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, BYTE nMId ) const; + virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, BYTE nMId ); +}; #endif Index: inc/ddefld.hxx =================================================================== RCS file: /cvs/sw/sw/inc/ddefld.hxx,v --- inc/ddefld.hxx 14 Aug 2006 15:19:42 -0000 1.8 +++ inc/ddefld.hxx 5 Apr 2007 12:08:45 -0000 @@ -73,8 +73,8 @@ ~SwDDEFieldType(); const String& GetExpansion() const { return aExpansion; } - void SetExpansion( const String& rStr ) { aExpansion = rStr, - bCRLFFlag = FALSE; } + void SetExpansion( const String& rStr ) { aExpansion = rStr, + bCRLFFlag = FALSE; } virtual SwFieldType* Copy() const; virtual const String& GetName() const; Index: inc/doc.hxx =================================================================== RCS file: /cvs/sw/sw/inc/doc.hxx,v --- inc/doc.hxx 28 Feb 2007 15:36:45 -0000 1.133 +++ inc/doc.hxx 5 Apr 2007 12:08:45 -0000 @@ -594,7 +594,7 @@ // sal_Bool bWinEncryption ; // imported document password encrypted? - + sal_Bool mbStartIdleTimer ; // idle timer mode start/stop static SwAutoCompleteWord *pACmpltWords; // Liste aller Worte fuers AutoComplete @@ -748,6 +748,7 @@ virtual SwBookmark* makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCode& rKC, /*[in]*/ const String& rName, /*[in]*/const String& rShortName, /*[in]*/BookmarkType eMark ); + virtual bool insertField(/*[in]*/ SwFieldBookmark* pBookmarkField); virtual void deleteBookmark( /*[in]*/sal_uInt16 nPos ); virtual void deleteBookmark( /*[in]*/const String& rName ); virtual sal_uInt16 findBookmark( /*[in]*/const String& rName ); Index: inc/expfld.hxx =================================================================== RCS file: /cvs/sw/sw/inc/expfld.hxx,v --- inc/expfld.hxx 14 Aug 2006 15:21:38 -0000 1.8 +++ inc/expfld.hxx 5 Apr 2007 12:08:45 -0000 @@ -307,54 +307,6 @@ { return 0 != (GSE_SEQ & ((SwSetExpFieldType*)GetTyp())->GetType()); } /*-------------------------------------------------------------------- - Beschreibung: Eingabe im Text/Variable setzen - --------------------------------------------------------------------*/ - -class SwInputFieldType : public SwFieldType -{ - SwDoc* pDoc; -public: - SwInputFieldType( SwDoc* pDoc ); - - virtual SwFieldType* Copy() const; - - SwDoc* GetDoc() const { return pDoc; } -}; - -/*-------------------------------------------------------------------- - Beschreibung: Eingabefeld - --------------------------------------------------------------------*/ - -class SwInputField : public SwField -{ - String aContent; - String aPText; - USHORT nSubType; -public: - // Direkte Eingabe ueber Dialog alten Wert loeschen - SwInputField(SwInputFieldType*, const String& rContent , - const String& rPrompt, USHORT nSubType = 0, - ULONG nFmt = 0); - - virtual String GetCntnt(BOOL bName = FALSE) const; - virtual String Expand() const; - virtual SwField* Copy() const; - - // Content - virtual const String& GetPar1() const; - virtual void SetPar1(const String& rStr); - - // aPromptText - virtual String GetPar2() const; - virtual void SetPar2(const String& rStr); - - virtual USHORT GetSubType() const; - virtual void SetSubType(USHORT nSub); - virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, BYTE nMId ) const; - virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, BYTE nMId ); -}; - -/*-------------------------------------------------------------------- Description: Sorted list of input fields and DropDown fields --------------------------------------------------------------------*/ Index: inc/swtypes.hxx =================================================================== RCS file: /cvs/sw/sw/inc/swtypes.hxx,v --- inc/swtypes.hxx 14 Aug 2006 15:34:52 -0000 1.22 +++ inc/swtypes.hxx 5 Apr 2007 12:08:45 -0000 @@ -173,7 +173,8 @@ // <- #i30312# // Anzahl der SystemField-Types vom SwDoc -#define INIT_FLDTYPES 32 +// SwInputField removed - now 31 fields +#define INIT_FLDTYPES 31 // Anzahl der vordefinierten Seq-Feldtypen. Es handelt sich dabei // immer um die letzen Felder vor INIT_FLDTYPES #define INIT_SEQ_FLDTYPES 4 Index: inc/unofield.hxx =================================================================== RCS file: /cvs/sw/sw/inc/unofield.hxx,v --- inc/unofield.hxx 9 Sep 2005 02:25:51 -0000 1.16 +++ inc/unofield.hxx 5 Apr 2007 12:08:45 -0000 @@ -63,6 +63,7 @@ class SwField; class SwSetExpField; class String; +class SwFieldBookmark; /* -----------------04.12.98 12:49------------------- * * --------------------------------------------------*/ @@ -97,7 +98,7 @@ SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId); SwXFieldMaster(SwFieldType& rType, SwDoc* pDoc); - + TYPEINFO(); @@ -170,7 +171,8 @@ public: SwXTextField(sal_uInt16 nServiceId); SwXTextField(const SwFmtFld& rFmt, SwDoc* pDoc); - + SwXTextField( SwFieldBookmark& rFieldBookmark ); + TYPEINFO(); @@ -219,6 +221,7 @@ const SwField* GetField() const; const SwFmtFld* GetFldFmt(){return GetField() ? pFmtFld : 0; }; + SwFieldBookmark* GetBookmarkField() const; // #111840# /** @@ -246,7 +249,7 @@ virtual ~SwXTextFieldMasters(); public: SwXTextFieldMasters(SwDoc* pDoc); - + //XNameAccess virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); @@ -285,7 +288,7 @@ virtual ~SwXTextFieldTypes(); public: SwXTextFieldTypes(SwDoc* pDoc); - + //XEnumerationAccess virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); @@ -306,6 +309,9 @@ // SwUnoCollection virtual void Invalidate(); + + static SwXTextField* GetObject( SwFieldBookmark& rBkm ); + }; /* -----------------21.12.98 14:49------------------- Index: inc/unoport.hxx =================================================================== RCS file: /cvs/sw/sw/inc/unoport.hxx,v --- inc/unoport.hxx 14 Aug 2006 15:37:21 -0000 1.17 +++ inc/unoport.hxx 5 Apr 2007 12:08:46 -0000 @@ -133,6 +133,7 @@ ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xTOXMark; ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xBookmark; ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xFootnote; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xBookmarkField; ::com::sun::star::uno::Any* pRubyText; ::com::sun::star::uno::Any* pRubyStyle; ::com::sun::star::uno::Any* pRubyAdjust; @@ -248,6 +249,8 @@ void SetFootnote( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) {xFootnote = xMark;} + void SetBookmarkField( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xField ) + {xBookmarkField = xField; } void SetControlChar(sal_Int16 nSet) {nControlChar = nSet;} BOOL IsCollapsed() const { return bIsCollapsed;} Index: inc/viewsh.hxx =================================================================== RCS file: /cvs/sw/sw/inc/viewsh.hxx,v --- inc/viewsh.hxx 22 Jan 2007 15:10:09 -0000 1.52 +++ inc/viewsh.hxx 5 Apr 2007 12:08:46 -0000 @@ -218,9 +218,9 @@ void InitPrt( SfxPrinter * , OutputDevice *pPDFOut = NULL ); //Klammerung von zusammengehoerenden Aktionen. - inline void StartAction(); + void StartAction(); void ImplStartAction(); - inline void EndAction( const sal_Bool bIdleEnd = sal_False ); + void EndAction( const sal_Bool bIdleEnd = sal_False ); void ImplEndAction( const sal_Bool bIdleEnd = sal_False ); sal_uInt16 ActionCount() const { return nStartAction; } sal_Bool ActionPend() const { return nStartAction != 0; } @@ -245,7 +245,7 @@ void SetNoNextScroll(); void InvalidateWindows( const SwRect &rRect ); - + ////////////////////////////////////////////////////////////////////////////// // #i72754# set of Pre/PostPaints with lock counter and initial target OutDev protected: @@ -581,17 +581,7 @@ aInvalidRect.Clear(); } -inline void ViewShell::StartAction() -{ - if ( !nStartAction++ ) - ImplStartAction(); -} -inline void ViewShell::EndAction( const sal_Bool bIdleEnd ) -{ - if( 0 == (nStartAction - 1) ) - ImplEndAction( bIdleEnd ); - --nStartAction; -} + inline void ViewShell::LockPaint() { Index: source/core/crsr/bookmrk.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/crsr/bookmrk.cxx,v --- source/core/crsr/bookmrk.cxx 16 Sep 2006 20:44:16 -0000 1.9 +++ source/core/crsr/bookmrk.cxx 5 Apr 2007 12:08:46 -0000 @@ -46,6 +46,24 @@ #ifndef _PAM_HXX #include #endif +#ifndef _SWCRSR_HXX +#include +#endif +#ifndef _DOC_HXX +#include +#endif +#ifndef _UNOCRSRHELPER_HXX +#include +#endif +#ifndef _NDTXT_HXX +#include +#endif +#ifndef _CRSSKIP_HXX +#include +#endif +#ifndef _UNOFLDMID_H +#include +#endif #ifndef _SWSERV_HXX #include #endif @@ -54,6 +72,8 @@ #endif #include +using namespace ::com::sun::star; + SV_IMPL_REF( SwServerObject ) TYPEINIT1( SwBookmark, SwModify ); //rtti @@ -84,6 +104,19 @@ pPos1 = new SwPosition(aPos); } +/*-- 02.04.2007 09:28:45--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwBookmark::SwBookmark(const SwPosition& rPos, const SwPosition& rSecondPos) + : SwModify( 0 ), + aStartMacro( aEmptyStr, aEmptyStr ), + aEndMacro ( aEmptyStr, aEmptyStr ), + eMarkType( IDocumentBookmarkAccess::BOOKMARK ) +{ + pPos1 = new SwPosition(rPos); + pPos2 = new SwPosition(rSecondPos); +} + // Beim Loeschen von Text werden Bookmarks mitgeloescht! @@ -137,6 +170,18 @@ refObj = pObj; } +/*-- 04.04.2007 09:10:15--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwBookmark::setNewPositions( const SwPaM& rNew ) +{ + *pPos1 = *rNew.Start(); + if( pPos2 ) + delete pPos2, pPos2 = 0; + if( rNew.HasMark() ) + pPos2 = new SwPosition( *rNew.End() ); +} + SwMark::SwMark( const SwPosition& aPos, const KeyCode& rCode, @@ -155,4 +200,134 @@ { eMarkType = IDocumentBookmarkAccess::UNO_BOOKMARK; } +/*-- 02.04.2007 09:27:54--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwFieldBookmark::SwFieldBookmark( + const SwPosition& rPos, const SwPosition& rOtherPos, RES_FIELDS eFieldType ) : + SwBookmark( rPos, rOtherPos ), + m_eFieldType( eFieldType ) +{ + eMarkType = IDocumentBookmarkAccess::FIELD_BOOKMARK; +} +/*-- 02.04.2007 09:27:54--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwFieldBookmark::~SwFieldBookmark() +{ +} +/*-- 05.04.2007 09:37:40--------------------------------------------------- + -----------------------------------------------------------------------*/ +BOOL SwFieldBookmark::QueryValue( uno::Any&, BYTE ) const +{ + return sal_True; +} +/*-- 05.04.2007 09:37:41--------------------------------------------------- + + -----------------------------------------------------------------------*/ +BOOL SwFieldBookmark::PutValue( const uno::Any& , BYTE ) +{ + return sal_True; +} +/*-- 02.04.2007 10:15:20--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwFieldBookmark::setPresentation( const ::rtl::OUString rPresentation ) +{ + //TODO: should be a method at SwDoc/IDocumentContentOperations + //to support correct Undo! + SwCursor aNewCrsr( GetPos() ); + SwDoc* pDoc = aNewCrsr.GetDoc(); + if(GetOtherPos()) + { + aNewCrsr.SetMark(); + *aNewCrsr.GetMark() = *GetOtherPos(); + } + + if(aNewCrsr.HasMark()) + pDoc->DeleteAndJoin(aNewCrsr); + + if(rPresentation.getLength()) + { + xub_StrLen nIndex = aNewCrsr.Start()->nContent.GetIndex(); + SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, aNewCrsr, rPresentation ); + aNewCrsr.SetMark(); + aNewCrsr.GetMark()->nContent = nIndex; + } + //TODO: currently no Undo!! + setNewPositions( aNewCrsr ); +} +/*-- 02.04.2007 09:27:54--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwInputFieldBookmark::SwInputFieldBookmark( + const SwPaM& rPaM, + const ::rtl::OUString& rHint, + const ::rtl::OUString& rUserFieldName ) : + SwFieldBookmark( *rPaM.Start(), *rPaM.End(), RES_INPUTFLD ), + m_sHint( rHint ), + m_sUserFieldName(rUserFieldName) +{ +} +/*-- 02.04.2007 09:27:54--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwInputFieldBookmark::~SwInputFieldBookmark() +{ +} +/*-- 05.04.2007 09:38:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +BOOL SwInputFieldBookmark::QueryValue( uno::Any& rVal, BYTE nMId ) const +{ + nMId &= ~CONVERT_TWIPS; + switch( nMId ) + { + case FIELD_PROP_PAR1: + { + ::rtl::OUString sText; + const SwTxtNode* pTxtNd = Start()->nNode.GetNode().GetTxtNode(); + if( pTxtNd ) + { + xub_StrLen nStt = Start()->nContent.GetIndex(); + sText = pTxtNd->GetExpandTxt( nStt, + End()->nContent.GetIndex() - nStt ); + } + rVal <<= sText; + } + break; + case FIELD_PROP_PAR2: + rVal <<= m_sHint; + break; + default: + DBG_ERROR("illegal property"); + } + return sal_True; +} +/*-- 05.04.2007 09:38:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +BOOL SwInputFieldBookmark::PutValue( const uno::Any& rVal, BYTE nMId ) +{ + nMId &= ~CONVERT_TWIPS; + switch( nMId ) + { + case FIELD_PROP_PAR1: + { + ::rtl::OUString sPresentation; + rVal >>= sPresentation; + setPresentation(sPresentation); + } + break; + case FIELD_PROP_PAR2: + { + ::rtl::OUString sPresentation; + rVal >>= m_sHint; + } + break; + default: + DBG_ERROR("illegal property"); + } + return sal_True; +} Index: source/core/doc/docbm.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/doc/docbm.cxx,v --- source/core/doc/docbm.cxx 16 Sep 2006 20:50:01 -0000 1.20 +++ source/core/doc/docbm.cxx 5 Apr 2007 12:08:47 -0000 @@ -196,6 +196,25 @@ } return pBM; } +bool SwDoc::insertField(/*[in]*/ SwFieldBookmark* pBookmarkField) +{ + // fix bookmark positions if they are invalid + lcl_FixPosition( *pBookmarkField->pPos1 ); + if( pBookmarkField->pPos2 != NULL ) + lcl_FixPosition( *pBookmarkField->pPos2 ); + + if( !pBookmarkTbl->Insert( pBookmarkField ) ) + delete pBookmarkField, pBookmarkField = 0; + if( DoesUndo() ) + { + ClearRedo(); + //TODO: create appropriate undo code + AppendUndo( new SwUndoInsBookmark( *pBookmarkField )); + } + + SetModified(); + return pBookmarkField != 0; +} void SwDoc::deleteBookmark( /*[in]*/sal_uInt16 nPos ) { @@ -678,7 +697,7 @@ nReturn = BEHIND_SAME_NODE; } else if( nIndex > nNode ) - nReturn = BEHIND_NODE; + nReturn = BEHIND_NODE; return nReturn; } Index: source/core/doc/docfld.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/doc/docfld.cxx,v --- source/core/doc/docfld.cxx 27 Sep 2006 10:51:50 -0000 1.28 +++ source/core/doc/docfld.cxx 5 Apr 2007 12:08:47 -0000 @@ -347,9 +347,9 @@ } } -const SwFldTypes* SwDoc::GetFldTypes() const -{ - return pFldTypes; +const SwFldTypes* SwDoc::GetFldTypes() const +{ + return pFldTypes; } /*-------------------------------------------------------------------- @@ -357,7 +357,7 @@ --------------------------------------------------------------------*/ SwFieldType* SwDoc::GetFldType( USHORT nResId, const String& rName, - bool bDbFieldMatching // used in some UNO calls for RES_DBFLD + bool bDbFieldMatching // used in some UNO calls for RES_DBFLD // to use different string matching code // #i51815# ) const @@ -796,33 +796,33 @@ } void SwDoc::LockExpFlds() -{ - ++nLockExpFld; +{ + ++nLockExpFld; } void SwDoc::UnlockExpFlds() -{ - if( nLockExpFld ) - --nLockExpFld; +{ + if( nLockExpFld ) + --nLockExpFld; } -bool SwDoc::IsExpFldsLocked() const -{ - return 0 != nLockExpFld; +bool SwDoc::IsExpFldsLocked() const +{ + return 0 != nLockExpFld; } SwDocUpdtFld& SwDoc::GetUpdtFlds() const -{ +{ return *pUpdtFlds; } -bool SwDoc::IsNewFldLst() const -{ - return mbNewFldLst; +bool SwDoc::IsNewFldLst() const +{ + return mbNewFldLst; } -void SwDoc::SetNewFldLst(bool bFlag) -{ +void SwDoc::SetNewFldLst(bool bFlag) +{ mbNewFldLst = bFlag; } @@ -1416,7 +1416,7 @@ // if( pGFld->IsInBodyTxt() ) SwSbxValue aValue = aCalc.Calculate( pSect->GetCondition() ); - if(!aValue.IsVoidValue()) + if(!aValue.IsVoidValue()) pSect->SetCondHidden( aValue.GetBool() ); continue; } @@ -1439,7 +1439,7 @@ SwSbxValue aValue = aCalc.Calculate( pHFld->GetPar1() ); sal_Bool bValue = !aValue.GetBool(); if(!aValue.IsVoidValue()) - { + { pHFld->SetValue( bValue ); // Feld Evaluieren pHFld->Evaluate(this); @@ -1687,7 +1687,8 @@ pFldTypes->Insert( new SwPostItFieldType, nFldType++ ); pFldTypes->Insert( new SwDocStatFieldType(this), nFldType++); pFldTypes->Insert( new SwDocInfoFieldType(this), nFldType++); - pFldTypes->Insert( new SwInputFieldType( this ), nFldType++ ); +// removed - SwInputField replace by SwInputFieldBookmark +// pFldTypes->Insert( new SwInputFieldType( this ), nFldType++ ); pFldTypes->Insert( new SwTblFieldType( this ), nFldType++); pFldTypes->Insert( new SwMacroFieldType(this), nFldType++ ); pFldTypes->Insert( new SwHiddenParaFieldType, nFldType++ ); @@ -2767,7 +2768,7 @@ } // #111840# -bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld, +bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld, SwMsgPoolItem * pMsgHnt, bool bUpdateFlds) { @@ -2780,17 +2781,17 @@ USHORT nFldWhich = rSrcFld.GetTyp()->Which(); SwNodeIndex aTblNdIdx(pDstTxtFld->GetTxtNode()); - if (pDstFld->GetTyp()->Which() == + if (pDstFld->GetTyp()->Which() == rSrcFld.GetTyp()->Which()) { if (DoesUndo()) { - SwPosition * pPos = + SwPosition * pPos = pDstTxtFld->GetPosition(); ASSERT(pPos, "SwTxtFld not in its SwTxtNode?"); - - AppendUndo(new SwUndoFieldFromDoc(*pPos, *pDstFld, rSrcFld, + + AppendUndo(new SwUndoFieldFromDoc(*pPos, *pDstFld, rSrcFld, pMsgHnt, bUpdateFlds)); delete pPos; } @@ -2798,7 +2799,7 @@ // Das gefundene Feld wird angepasst ... //pDstFld->ChangeFormat( rSrcFld.GetFormat() ); //pDstFld->SetLanguage( rSrcFld.GetLanguage() ); - + SwField * pNewFld = rSrcFld.Copy(); pDstFmtFld->SetFld(pNewFld); @@ -2813,7 +2814,7 @@ case RES_TABLEFLD: { - const SwTableNode* pTblNd = + const SwTableNode* pTblNd = IsIdxInTbl(aTblNdIdx); if( pTblNd ) { @@ -2825,7 +2826,7 @@ pNewFld->GetTyp()->Modify(0, &aTblUpdate); if (! bUpdateFlds) - bTblSelBreak = TRUE; + bTblSelBreak = TRUE; } } break; @@ -2878,7 +2879,7 @@ Any aOldVal; SwField * pField = GetField(rPos); - + if (DoesUndo() && pField->QueryValue(aOldVal, nMId)) AppendUndo(new SwUndoFieldFromAPI(rPos, aOldVal, rVal, nMId)); Index: source/core/fields/expfld.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/fields/expfld.cxx,v --- source/core/fields/expfld.cxx 16 Sep 2006 21:11:24 -0000 1.25 +++ source/core/fields/expfld.cxx 5 Apr 2007 12:08:47 -0000 @@ -1056,147 +1056,6 @@ } } -/*-------------------------------------------------------------------- - Beschreibung: Eingabefeld Type - ---------------------------------------------------------------------*/ - -SwInputFieldType::SwInputFieldType( SwDoc* pD ) - : SwFieldType( RES_INPUTFLD ), pDoc( pD ) -{ -} - -SwFieldType* SwInputFieldType::Copy() const -{ - SwInputFieldType* pType = new SwInputFieldType( pDoc ); - return pType; -} - -/*-------------------------------------------------------------------- - Beschreibung: Eingabefeld - --------------------------------------------------------------------*/ - -SwInputField::SwInputField(SwInputFieldType* pType, const String& rContent, - const String& rPrompt, USHORT nSub, ULONG nFmt) : - SwField(pType, nFmt), nSubType(nSub), aContent(rContent), aPText(rPrompt) -{ -} - -String SwInputField::GetCntnt(BOOL bName) const -{ - if ( bName ) - { - String aStr(SwField::GetCntnt(bName)); - if ((nSubType & 0x00ff) == INP_USR) - { - aStr += GetTyp()->GetName(); - aStr += ' '; - aStr += aContent; - } - return aStr; - } - return Expand(); -} - -SwField* SwInputField::Copy() const -{ - SwInputField* pFld = new SwInputField((SwInputFieldType*)GetTyp(), aContent, - aPText, GetSubType(), GetFormat()); - pFld->SetAutomaticLanguage(IsAutomaticLanguage()); - return pFld; -} - -String SwInputField::Expand() const -{ - String sRet; - if((nSubType & 0x00ff) == INP_TXT) - sRet = aContent; - - else if( (nSubType & 0x00ff) == INP_USR ) - { - SwUserFieldType* pUserTyp = (SwUserFieldType*) - ((SwInputFieldType*)GetTyp())->GetDoc()-> - GetFldType( RES_USERFLD, aContent, false ); - if( pUserTyp ) - sRet = pUserTyp->GetContent(); - } - return sRet; -} - -/*-----------------06.03.98 11:12------------------- - ---------------------------------------------------*/ -BOOL SwInputField::QueryValue( uno::Any& rAny, BYTE nMId ) const -{ - nMId &= ~CONVERT_TWIPS; - switch( nMId ) - { - case FIELD_PROP_PAR1: - rAny <<= OUString( aContent ); - break; - case FIELD_PROP_PAR2: - rAny <<= OUString( aPText ); - break; - default: - DBG_ERROR("illegal property"); - } - return TRUE; -} -/*-----------------06.03.98 11:12------------------- - ---------------------------------------------------*/ -BOOL SwInputField::PutValue( const uno::Any& rAny, BYTE nMId ) -{ - nMId &= ~CONVERT_TWIPS; - switch( nMId ) - { - case FIELD_PROP_PAR1: - ::GetString( rAny, aContent ); - break; - case FIELD_PROP_PAR2: - ::GetString( rAny, aPText ); - break; - default: - DBG_ERROR("illegal property"); - } - return TRUE; -} -/*-------------------------------------------------------------------- - Beschreibung: Bedingung setzen - --------------------------------------------------------------------*/ - -void SwInputField::SetPar1(const String& rStr) -{ - aContent = rStr; -} - -const String& SwInputField::GetPar1() const -{ - return aContent; -} - -/*-------------------------------------------------------------------- - Beschreibung: True/False Text - --------------------------------------------------------------------*/ - -void SwInputField::SetPar2(const String& rStr) -{ - aPText = rStr; -} - -String SwInputField::GetPar2() const -{ - return aPText; -} - -USHORT SwInputField::GetSubType() const -{ - return nSubType; -} - -void SwInputField::SetSubType(USHORT nSub) -{ - nSubType = nSub; -} /*-----------------05.03.98 17:22------------------- --------------------------------------------------*/ Index: source/core/undo/undobj.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/undo/undobj.cxx,v --- source/core/undo/undobj.cxx 25 Sep 2006 09:28:31 -0000 1.22 +++ source/core/undo/undobj.cxx 5 Apr 2007 12:08:47 -0000 @@ -750,10 +750,11 @@ for( USHORT n = 0; n < rBkmkTbl.Count(); ++n ) { BYTE nTyp = 0; + pBkmk = rBkmkTbl[ n ]; if( ( DELCNT_CHKNOCNTNT & nDelCntntType ) - ? (pStt->nNode <= ( pBkmk = rBkmkTbl[ n ])->GetPos().nNode && + ? (pStt->nNode <= pBkmk->GetPos().nNode && pBkmk->GetPos().nNode < pEnd->nNode ) - : (*pStt <= ( pBkmk = rBkmkTbl[ n ])->GetPos() && + : (*pStt <= pBkmk->GetPos() && pBkmk->GetPos() < *pEnd ) ) nTyp = SwHstryBookmark::BKMK_POS; Index: source/core/unocore/unobkm.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/unocore/unobkm.cxx,v --- source/core/unocore/unobkm.cxx 16 Sep 2006 21:55:18 -0000 1.12 +++ source/core/unocore/unobkm.cxx 5 Apr 2007 12:08:47 -0000 @@ -61,7 +61,7 @@ #ifndef _DOCARY_HXX #include #endif -#ifndef _SWUNDO_HXX //autogen +#ifndef _SWUNDO_HXX #include #endif #ifndef _COMCORE_HRC Index: source/core/unocore/unofield.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/unocore/unofield.cxx,v --- source/core/unocore/unofield.cxx 30 Jan 2007 15:22:46 -0000 1.94 +++ source/core/unocore/unofield.cxx 5 Apr 2007 12:08:48 -0000 @@ -52,6 +52,9 @@ #ifndef _TXTFLD_HXX //autogen #include #endif +#ifndef _BOOKMRK_HXX +#include +#endif #ifndef _NDTXT_HXX //autogen #include #endif @@ -79,6 +82,9 @@ #ifndef _VIEWSH_HXX #include #endif +#ifndef _SWUNDO_HXX //autogen +#include +#endif #ifndef _COMPHELPER_TYPES_HXX_ #include #endif @@ -394,6 +400,25 @@ return nSrvId; } +sal_uInt16 lcl_GetServiceForField( const SwFieldBookmark& rFieldBookmark ) +{ + sal_uInt16 nRet = USHRT_MAX; + switch( rFieldBookmark.GetFieldResId() ) + { + case RES_INPUTFLD: + { + const SwInputFieldBookmark* pInputField = dynamic_cast< const SwInputFieldBookmark* >( &rFieldBookmark ); + DBG_ASSERT( pInputField, "field which id and type don't match") + nRet = pInputField->GetUserFieldName().getLength() ? + SW_SERVICE_FIELDTYPE_INPUT_USER : + SW_SERVICE_FIELDTYPE_INPUT; + } + break; + default: DBG_ERROR("unsupported type"); + }; + return nRet; +} + sal_uInt16 lcl_GetPropMapIdForFieldType( USHORT nWhich ) { sal_uInt16 nId; @@ -1304,6 +1329,20 @@ { pDc->GetUnoCallBack()->Add(this); } +/*-- 04.04.2007 12:24:36--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextField::SwXTextField( SwFieldBookmark& rFieldBookmark) : + pFmtFld(0), + aLstnrCntnr( (XTextContent*)this), + m_pDoc( rFieldBookmark.GetPos().GetDoc() ), + m_nServiceId( lcl_GetServiceForField( rFieldBookmark )), + m_bIsDescriptor(sal_False), + m_pProps(0), + m_bCallUpdate(sal_False) +{ + rFieldBookmark.Add( this ); +} /*-- 14.12.98 11:37:15--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -1359,8 +1398,19 @@ vos::OGuard aGuard(Application::GetSolarMutex()); OUString sRet; const SwField* pField = GetField(); + const SwFieldBookmark* pFieldBookmark = 0; if(pField) sRet = pField->GetCntnt(bShowCommand); + else if( 0 != (pFieldBookmark = GetBookmarkField() )) + { + const SwTxtNode* pTxtNd = pFieldBookmark->Start()->nNode.GetNode().GetTxtNode(); + if( pTxtNd ) + { + xub_StrLen nStt = pFieldBookmark->Start()->nContent.GetIndex(); + sRet = pTxtNd->GetExpandTxt( nStt, + pFieldBookmark->End()->nContent.GetIndex() - nStt ); + } + } else throw uno::RuntimeException(); return sRet; @@ -1765,12 +1815,20 @@ case SW_SERVICE_FIELDTYPE_INPUT_USER: case SW_SERVICE_FIELDTYPE_INPUT: { - SwFieldType* pFldType = pDoc->GetFldType(RES_INPUTFLD, m_sTypeName, sal_True); - if(!pFldType) - throw uno::RuntimeException(); - USHORT nInpSubType = SW_SERVICE_FIELDTYPE_INPUT_USER == m_nServiceId ? INP_USR : INP_TXT; - pFld = new SwInputField((SwInputFieldType*)pFldType, - m_pProps->sPar1, m_pProps->sPar2, nInpSubType); + pDoc->StartUndo( UNDO_INSERT, 0 ); + bool bInputUser = SW_SERVICE_FIELDTYPE_INPUT_USER == m_nServiceId; + + SwFieldBookmark* pBookmarkField = + new SwInputFieldBookmark( *aPam.Start(), + m_pProps->sPar2, + bInputUser ? m_pProps->sPar2 : ::rtl::OUString()); + if( pDoc->insertField( pBookmarkField )) + { + pBookmarkField->Add(this); + if( !bInputUser ) + pBookmarkField->setPresentation(m_pProps->sPar1 ); + } + pDoc->EndUndo( UNDO_INSERT, 0 ); } break; case SW_SERVICE_FIELDTYPE_MACRO: @@ -1881,8 +1939,8 @@ const SwFmtFld& rFld = pTxtAttr->GetFld(); pFmtFld = &rFld; } + delete pFld; } - delete pFld; m_pDoc = pDoc; m_pDoc->GetUnoCallBack()->Add(this); @@ -1911,6 +1969,7 @@ vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< XTextRange > aRef; SwField* pField = (SwField*)GetField(); + const SwFieldBookmark* pFieldBookmark = 0; if(pField) { const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld(); @@ -1923,6 +1982,12 @@ aRef = SwXTextRange::CreateTextRangeFromPosition(m_pDoc, *aPam.GetPoint(), aPam.GetMark()); } + else if( 0 != (pFieldBookmark = GetBookmarkField() )) + { + SwPaM aPam( *pFieldBookmark->Start(), *pFieldBookmark->End(), 0 ); + aRef = SwXTextRange::CreateTextRangeFromPosition(m_pDoc, + *aPam.GetPoint(), aPam.GetMark()); + } return aRef; } @@ -1994,6 +2059,7 @@ { vos::OGuard aGuard(Application::GetSolarMutex()); SwField* pField = (SwField*)GetField(); + SwFieldBookmark* pFieldBookmark = 0; const SfxItemPropertyMap* _pMap = aSwMapProvider.GetPropertyMap( lcl_GetPropertyMapOfService( m_nServiceId)); const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(_pMap, rPropertyName); @@ -2041,6 +2107,11 @@ pFmtFld->GetTxtFld()->Expand(); } } + else if( 0 != (pFieldBookmark = GetBookmarkField() )) + { + //TODO: create equivalent to PutValueToField() + pFieldBookmark->PutValue(rValue, pMap->nWID); + } else if(m_pProps) { String* pStr = 0; @@ -2144,6 +2215,7 @@ vos::OGuard aGuard(Application::GetSolarMutex()); uno::Any aRet; const SwField* pField = GetField(); + const SwFieldBookmark* pFieldBookmark = 0; const SfxItemPropertyMap* _pMap = aSwMapProvider.GetPropertyMap( lcl_GetPropertyMapOfService( m_nServiceId)); const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(_pMap, rPropertyName); @@ -2211,13 +2283,13 @@ { xub_StrLen nHiddenStart; xub_StrLen nHiddenEnd; - + SwPosition *pPos = pTxtFld->GetPosition(); if (!pPos) throw RuntimeException(); - bHidden = SwScriptInfo::GetBoundsOfHiddenRange( rTxtNode, - pPos->nContent.GetIndex(), + bHidden = SwScriptInfo::GetBoundsOfHiddenRange( rTxtNode, + pPos->nContent.GetIndex(), nHiddenStart, nHiddenEnd ); } @@ -2238,6 +2310,11 @@ else pField->QueryValue( aRet, pMap->nWID ); } + else if( 0 != (pFieldBookmark = GetBookmarkField() )) + { + //TODO: Handling of special properties as above + pFieldBookmark->QueryValue(aRet, pMap->nWID); + } else if( m_pProps ) // currently just a descriptor... { switch(pMap->nWID) @@ -2502,6 +2579,13 @@ return pFmtFld->GetFld(); return 0; } +/*-- 05.04.2007 09:15:55--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwFieldBookmark* SwXTextField::GetBookmarkField() const +{ + return dynamic_cast(const_cast(GetRegisteredIn())); +} // #111840# SwPosition * SwXTextField::GetPosition() @@ -2580,7 +2664,7 @@ sal_uInt16 lcl_GetIdByName( String& rName, String& rTypeName ) { - if( rName.EqualsAscii( COM_TEXT_FLDMASTER, 0, RTL_CONSTASCII_LENGTH(COM_TEXT_FLDMASTER )) + if( rName.EqualsAscii( COM_TEXT_FLDMASTER, 0, RTL_CONSTASCII_LENGTH(COM_TEXT_FLDMASTER )) || rName.EqualsAscii( COM_TEXT_FLDMASTER_CC, 0, RTL_CONSTASCII_LENGTH(COM_TEXT_FLDMASTER_CC ))) rName.Erase(0, 30); @@ -2821,6 +2905,18 @@ { SwUnoCollection::Invalidate(); aRefreshCont.Disposing(); +} +/*-- 04.04.2007 12:21:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextField* SwXTextFieldTypes::GetObject( SwFieldBookmark& rBkm ) +{ + SwXTextField* pField = (SwXTextField*)SwClientIter( rBkm ). + First( TYPE( SwXTextField )); + if( !pField ) + pField = new SwXTextField( rBkm ); + return pField; + } /*-- 21.12.98 10:35:17--------------------------------------------------- Index: source/core/unocore/unoport.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/unocore/unoport.cxx,v --- source/core/unocore/unoport.cxx 30 Jan 2007 15:23:24 -0000 1.37 +++ source/core/unocore/unoport.cxx 5 Apr 2007 12:08:48 -0000 @@ -444,6 +444,14 @@ rVal = *pToSet; } break; + //TODO: bookmark text fields should be available as cursor property + case FN_UNO_TEXT_FIELD: + if(xBookmarkField.is()) + { + rVal <<= xBookmarkField; + break; + } + //no break default: PropertyState eTemp; BOOL bDone = SwUnoCursorHelper::getCrsrPropertyValue( Index: source/core/unocore/unoportenum.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/unocore/unoportenum.cxx,v --- source/core/unocore/unoportenum.cxx 30 Jan 2007 15:23:35 -0000 1.35 +++ source/core/unocore/unoportenum.cxx 5 Apr 2007 12:08:48 -0000 @@ -70,6 +70,9 @@ #ifndef _UNOOBJ_HXX #include #endif +#ifndef _UNOFIELD_HXX +#include +#endif #ifndef _UNOREDLINE_HXX #include #endif @@ -294,7 +297,7 @@ BYTE nBkmType; const SwPosition aPosition; - SwXBookmarkPortion_Impl( SwXBookmark* pXMark, BYTE nType, const SwPosition &rPosition ) + SwXBookmarkPortion_Impl( SwXBookmark* pXMark, BYTE nType, const SwPosition &rPosition ) : xBookmark ( pXMark ) , nBkmType ( nType ) , aPosition ( rPosition ) @@ -315,7 +318,7 @@ // #i16896# for bookmark portions at the same position, the start should // always precede the end. Hence compare positions, and use bookmark type // as tie-breaker for same position. - // return ( r1->nIndex == r2->nIndex ) + // return ( r1->nIndex == r2->nIndex ) // ? ( r1->nBkmType < r2->nBkmType ) // : ( r1->nIndex < r2->nIndex ); @@ -329,7 +332,39 @@ } }; typedef std::multiset < SwXBookmarkPortion_ImplSharedPtr, BookmarkCompareStruct > SwXBookmarkPortion_ImplList; +//----------------------------------------------------------------------------- +struct SwXFieldBookmarkPortion_Impl +{ + Reference m_xField; + BYTE m_nBkmType; + const SwPosition m_aPosition; + xub_StrLen m_nLength; + + SwXFieldBookmarkPortion_Impl( SwXTextField* pXField, BYTE nType, + const SwPosition &rPosition, xub_StrLen nLength ) + : m_xField ( pXField ) + , m_nBkmType ( nType ) + , m_aPosition ( rPosition ) + , m_nLength( nLength ) + { + } + ULONG getIndex () + { + return m_aPosition.nContent.GetIndex(); + } +}; +typedef boost::shared_ptr < SwXFieldBookmarkPortion_Impl > SwXFieldBookmarkPortion_ImplSharedPtr; +struct FieldBookmarkCompareStruct +{ + bool operator () ( const SwXFieldBookmarkPortion_ImplSharedPtr &r1, + const SwXFieldBookmarkPortion_ImplSharedPtr &r2 ) + { + return r1->m_aPosition < r2->m_aPosition; + } +}; +typedef std::multiset < SwXFieldBookmarkPortion_ImplSharedPtr, FieldBookmarkCompareStruct > + SwXFieldBookmarkPortion_ImplList; //----------------------------------------------------------------------------- void lcl_ExportBookmark( SwXBookmarkPortion_ImplList& rBkmArr, ULONG nIndex, @@ -346,7 +381,7 @@ } if ( nIndex < pPtr->getIndex() ) break; - + SwXTextPortion* pPortion; if(BKM_TYPE_START == pPtr->nBkmType || BKM_TYPE_START_END == pPtr->nBkmType) { @@ -367,6 +402,47 @@ rBkmArr.erase( aIter++ ); } } +//----------------------------------------------------------------------------- +void lcl_ExportFieldBookmark( + SwXFieldBookmarkPortion_ImplList& rFieldBkmArr, ULONG nIndex, + SwUnoCrsr* pUnoCrsr, Reference & rParent, XTextRangeArr& rPortionArr) +{ + for ( SwXFieldBookmarkPortion_ImplList::iterator aIter = rFieldBkmArr.begin(), aEnd = rFieldBkmArr.end(); + aIter != aEnd; ) + { + SwXFieldBookmarkPortion_ImplSharedPtr pPtr = (*aIter); + if ( nIndex > pPtr->getIndex() ) + { + rFieldBkmArr.erase( aIter++ ); + continue; + } + if ( nIndex < pPtr->getIndex() ) + break; + + SwXTextPortion* pPortion; + if(BKM_TYPE_START == pPtr->m_nBkmType || BKM_TYPE_START_END == pPtr->m_nBkmType) + { + pUnoCrsr->Right( pPtr->m_nLength,CRSR_SKIP_CHARS,FALSE,FALSE ); + rPortionArr.Insert( + new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_FIELD)), + rPortionArr.Count()); + pPortion->SetBookmarkField( pPtr->m_xField ); + pPortion->SetCollapsed(BKM_TYPE_START_END == pPtr->m_nBkmType ? TRUE : FALSE); + if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) + pUnoCrsr->Exchange(); + *pUnoCrsr->GetMark() = *pUnoCrsr->GetPoint(); + + } +/* if(BKM_TYPE_END == pPtr->m_nBkmType) + { + rPortionArr.Insert( + new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_END)), + rPortionArr.Count()); + pPortion->SetBookmark(pPtr->xBookmark); + }*/ + rFieldBkmArr.erase( aIter++ ); + } +} /* -----------------------------18.12.00 14:51-------------------------------- ---------------------------------------------------------------------------*/ @@ -404,7 +480,7 @@ bool operator () ( const SwXRedlinePortion_ImplSharedPtr &r1, const SwXRedlinePortion_ImplSharedPtr &r2 ) { - return getPosition ( r1 ) < getPosition ( r2 ); + return getPosition ( r1 ) < getPosition ( r2 ); } }; typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > SwXRedlinePortion_ImplList; @@ -419,6 +495,7 @@ const xub_StrLen& nFirstFrameIndex, SwXBookmarkPortion_ImplList& aBkmArr, SwXRedlinePortion_ImplList& aRedArr, + SwXFieldBookmarkPortion_ImplList& rFieldBkmArr, sal_Int32 nEndPos ) { Reference xRef; @@ -622,6 +699,9 @@ { nMovePos = (sal_uInt16)(*aRedArr.begin())->getRealIndex(); } + //break up portions for field bookmarks + if( rFieldBkmArr.size() && (*rFieldBkmArr.begin())->getIndex() < nMovePos ) + nMovePos = (sal_uInt16)(*rFieldBkmArr.begin())->getIndex(); // break up if the destination is behind a frame if(nFirstFrameIndex != STRING_MAXLEN && nMovePos > nFirstFrameIndex) nMovePos = nFirstFrameIndex; @@ -644,6 +724,45 @@ return xRef; } //----------------------------------------------------------------------------- +void lcl_FillFieldBookmarkArray(SwDoc& rDoc, SwUnoCrsr& rUnoCrsr, + SwXFieldBookmarkPortion_ImplList& rFieldBkmArr ) +{ + const SwBookmarks& rMarks = rDoc.getBookmarks(); + sal_uInt16 nArrLen = rMarks.Count(); + if ( nArrLen > 0 ) + { + const SwNodeIndex nOwnNode = rUnoCrsr.GetPoint()->nNode; + //search for fields as bookmark - currently InputFields only + for( sal_uInt16 n = 0; n < nArrLen; ++n ) + { + SwBookmark* pMark = rMarks.GetObject( n ); + if( !pMark->IsFieldBookMark() ) + continue; + SwFieldBookmark* pFieldMark = dynamic_cast< SwFieldBookmark* >( pMark ); + + const SwPosition& rPos1 = *pMark->Start(); + const SwPosition* pPos2 = pMark->End(); + if(rPos1.nNode == nOwnNode) + { + BYTE nType = BKM_TYPE_START; + DBG_ASSERT(!pPos2 || pPos2->nNode == nOwnNode, + "field bookmarks are currently limited to be inside of a paragraph") + + rFieldBkmArr.insert( SwXFieldBookmarkPortion_ImplSharedPtr ( + new SwXFieldBookmarkPortion_Impl( + SwXTextFieldTypes::GetObject(*pFieldMark), nType, rPos1, + pPos2->nContent.GetIndex() - rPos1.nContent.GetIndex() ))); + } +// currently field bookmarks must not spread over different paragraphs +// if(pPos2 && pPos2->nNode == nOwnNode) +// { +// BYTE nType = bBackward ? BKM_TYPE_START : BKM_TYPE_END; +// new SwXFieldBookmarkPortion_Impl( SwXTextFieldTypes::GetObject(*pFieldMark), nType, *pPos2 ) ) ); +// } + } + } +} +//----------------------------------------------------------------------------- void lcl_FillBookmarkArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXBookmarkPortion_ImplList& rBkmArr ) { const SwBookmarks& rMarks = rDoc.getBookmarks(); @@ -669,14 +788,14 @@ nType = BKM_TYPE_START_END; } - rBkmArr.insert ( SwXBookmarkPortion_ImplSharedPtr ( + rBkmArr.insert ( SwXBookmarkPortion_ImplSharedPtr ( new SwXBookmarkPortion_Impl ( SwXBookmarks::GetObject( *pMark, &rDoc ), nType, rPos1 ))); } if(pPos2 && pPos2->nNode == nOwnNode) { BYTE nType = bBackward ? BKM_TYPE_START : BKM_TYPE_END; - rBkmArr.insert( SwXBookmarkPortion_ImplSharedPtr ( + rBkmArr.insert( SwXBookmarkPortion_ImplSharedPtr ( new SwXBookmarkPortion_Impl( SwXBookmarks::GetObject( *pMark, &rDoc ), nType, *pPos2 ) ) ); } } @@ -701,10 +820,10 @@ const SwNodeIndex nRedNode = pRedStart->nNode; IDocumentRedlineAccess::RedlineType_t nType = pRedline->GetType(); if ( nOwnNode == nRedNode ) - rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( + rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( new SwXRedlinePortion_Impl ( pRedline, TRUE) ) ); if( pRedline->HasMark() && pRedline->End()->nNode == nOwnNode ) - rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( + rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( new SwXRedlinePortion_Impl ( pRedline, FALSE) ) ); } } @@ -737,7 +856,7 @@ rPortionArr.Count()); rRedlineArr.erase ( aIter++ ); } - // MTG: 23/11/05: If we've iterated past nIndex, exit the loop + // MTG: 23/11/05: If we've iterated past nIndex, exit the loop else break; } @@ -756,8 +875,22 @@ if (rRedlineArr.size()) lcl_ExportRedline(rRedlineArr, nIndex, pUnoCrsr, rParent, rPortionArr); } + +/*-- 04.04.2007 13:38:34--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void lcl_ExportFieldBookmarks( SwXFieldBookmarkPortion_ImplList& rFieldBkmArr, + ULONG nIndex, SwUnoCrsr* pUnoCrsr, + Reference & rParent, XTextRangeArr& rPortionArr ) +{ + if (rFieldBkmArr.size()) + lcl_ExportFieldBookmark(rFieldBkmArr, nIndex, pUnoCrsr, rParent, rPortionArr); +} //----------------------------------------------------------------------------- -sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr, SwXRedlinePortion_ImplList& rRedlineArr) +sal_Int32 lcl_GetNextIndex( + SwXBookmarkPortion_ImplList& rBkmArr, + SwXRedlinePortion_ImplList& rRedlineArr, + SwXFieldBookmarkPortion_ImplList& rFieldBkmArr ) { sal_Int32 nRet = -1; if(rBkmArr.size()) @@ -772,6 +905,13 @@ if(nRet < 0 || nTmp < nRet) nRet = nTmp; } + if(rFieldBkmArr.size()) + { + const SwXFieldBookmarkPortion_ImplSharedPtr pPtr = (*rFieldBkmArr.begin()); + sal_Int32 nTmp = pPtr->getIndex(); + if(nRet < 0 || nTmp < nRet) + nRet = nTmp; + } return nRet; }; //----------------------------------------------------------------------------- @@ -792,10 +932,12 @@ { SwXBookmarkPortion_ImplList aBkmArr; SwXRedlinePortion_ImplList aRedArr; + SwXFieldBookmarkPortion_ImplList aFieldBkmArr; SwDoc* pDoc = pUnoCrsr->GetDoc(); lcl_FillRedlineArray(*pDoc, *pUnoCrsr, aRedArr); lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, aBkmArr ); + lcl_FillFieldBookmarkArray(*pDoc, *pUnoCrsr, aFieldBkmArr ); #if OSL_DEBUG_LEVEL > 1 for (SwXBookmarkPortion_ImplList::const_iterator aIter = aBkmArr.begin(), aEnd = aBkmArr.end(); aIter != aEnd; @@ -834,6 +976,7 @@ if(!pCNd->Len()) { lcl_ExportBkmAndRedline(aBkmArr, aRedArr, 0, pUnoCrsr, xParent, aPortionArr); + lcl_ExportFieldBookmarks( aFieldBkmArr, 0, pUnoCrsr, xParent, aPortionArr ); // the paragraph is empty xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType); // are there any frames? @@ -894,6 +1037,7 @@ if(!xRef.is()) { lcl_ExportBkmAndRedline(aBkmArr, aRedArr, nCurrentIndex, pUnoCrsr, xParent, aPortionArr); + lcl_ExportFieldBookmarks( aFieldBkmArr, nCurrentIndex, pUnoCrsr, xParent, aPortionArr ); if(pHints) { xRef = lcl_ExportHints(pHints, @@ -905,6 +1049,7 @@ nFirstFrameIndex, aBkmArr, aRedArr, + aFieldBkmArr, nEndPos); } @@ -914,7 +1059,7 @@ } else { - sal_Int32 nNextIndex = lcl_GetNextIndex(aBkmArr, aRedArr); + sal_Int32 nNextIndex = lcl_GetNextIndex(aBkmArr, aRedArr, aFieldBkmArr); DBG_ASSERT( nNextIndex <= pCNd->Len(), "illegal next index" ); if( nNextIndex > pCNd->Len() ) { @@ -963,7 +1108,10 @@ bAtEnd = sal_True; lcl_ExportBkmAndRedline(aBkmArr, aRedArr, nLocalEnd, pUnoCrsr, xParent, aPortionArr); - if(ND_TEXTNODE == pNode->GetNodeType()) + lcl_ExportFieldBookmarks( aFieldBkmArr, nLocalEnd, + pUnoCrsr, xParent, aPortionArr ); + + if(ND_TEXTNODE == pNode->GetNodeType()) { SwTxtNode* pTxtNode = (SwTxtNode*)pNode; SwpHints* pHints = pTxtNode->GetpSwpHints(); @@ -979,6 +1127,7 @@ STRING_MAXLEN, aBkmArr, aRedArr, + aFieldBkmArr, nEndPos); if(xRef.is()) aPortionArr.Insert(new Reference(xRef), aPortionArr.Count()); Index: source/core/view/viewsh.cxx =================================================================== RCS file: /cvs/sw/sw/source/core/view/viewsh.cxx,v --- source/core/view/viewsh.cxx 22 Jan 2007 15:11:13 -0000 1.68 +++ source/core/view/viewsh.cxx 5 Apr 2007 12:08:48 -0000 @@ -362,7 +362,7 @@ aOrigin.X() = -aOrigin.X(); aOrigin.Y() = -aOrigin.Y(); aMapMode.SetOrigin( aOrigin ); pVout->SetMapMode( aMapMode ); - + // #i72754# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev const Region aRepaintRegion(aRect.SVRect()); DLPrePaint2(aRepaintRegion); @@ -494,7 +494,7 @@ // #i72754# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev const Region aRepaintRegion(VisArea().SVRect()); DLPrePaint2(aRepaintRegion); - + OutputDevice *pOld = pOut; pOut = pVout; Paint( VisArea().SVRect() ); @@ -1558,7 +1558,7 @@ for ( USHORT i = 0; i < rRegion.Count(); ++i ) { const Rectangle aRectangle(rRegion[i].SVRect()); - + // #i68597# inform Drawinglayer about display change DLPrePaint2(Region(aRectangle)); GetOut()->DrawRect(aRectangle); @@ -1828,7 +1828,7 @@ pOut->SetLineColor(); pOut->DrawRect( rRect ); pOut->Pop(); - + // #i68597# DLPostPaint2(); } @@ -2442,6 +2442,17 @@ return nRet; } // <-- +void ViewShell::StartAction() +{ + if ( !nStartAction++ ) + ImplStartAction(); +} +void ViewShell::EndAction( const sal_Bool bIdleEnd ) +{ + if( 0 == (nStartAction - 1) ) + ImplEndAction( bIdleEnd ); + --nStartAction; +} /* * Document Interface Access Index: source/filter/ww1/w1filter.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww1/w1filter.cxx,v --- source/filter/ww1/w1filter.cxx 14 Nov 2006 15:13:57 -0000 1.13 +++ source/filter/ww1/w1filter.cxx 5 Apr 2007 12:08:48 -0000 @@ -972,11 +972,13 @@ // das Ignorieren des Bookmarks ist nicht implementiert } case 39: // fillin command - pField = new SwInputField( - (SwInputFieldType*)rOut.GetSysFldType( RES_INPUTFLD ), - aEmptyStr, sFormel, - INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders ) - break; + //TODO insert via API +// TODO - SwInputField needs to be replaced by SwInputFieldBookmark +// pField = new SwInputField( +// (SwInputFieldType*)rOut.GetSysFldType( RES_INPUTFLD ), +// aEmptyStr, sFormel, +// INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders ) + break; case 51: // macro button { pos = aStr.Search(' '); Index: source/filter/ww8/ww8par3.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/ww8par3.cxx,v --- source/filter/ww8/ww8par3.cxx 6 Nov 2006 14:54:26 -0000 1.81 +++ source/filter/ww8/ww8par3.cxx 5 Apr 2007 12:08:48 -0000 @@ -255,10 +255,10 @@ String(static_cast< sal_Unicode >(0x2002)), CREATE_CONST_ASC(" ")); - SwInputField aFld((SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), - aFormula.sDefault , aFormula.sTitle , INP_TXT, 0 ); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); - +//TODO: create inputfield via API +// SwInputField aFld((SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), +// aFormula.sDefault , aFormula.sTitle , INP_TXT, 0 ); +// rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } Index: source/filter/ww8/ww8par5.cxx =================================================================== RCS file: /cvs/sw/sw/source/filter/ww8/ww8par5.cxx,v --- source/filter/ww8/ww8par5.cxx 9 Jan 2007 15:20:36 -0000 1.98 +++ source/filter/ww8/ww8par5.cxx 5 Apr 2007 12:08:49 -0000 @@ -1211,10 +1211,10 @@ if( !aDef.Len() ) aDef = GetFieldResult( pF ); - SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), - aDef, aQ, INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders ) - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); - +//TODO: create inputfield via API +// SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), +// aDef, aQ, INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders ) +// rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } Index: source/ui/fldui/fldmgr.cxx =================================================================== RCS file: /cvs/sw/sw/source/ui/fldui/fldmgr.cxx,v --- source/ui/fldui/fldmgr.cxx 16 Sep 2006 22:58:21 -0000 1.46 +++ source/ui/fldui/fldmgr.cxx 5 Apr 2007 12:08:49 -0000 @@ -71,6 +71,9 @@ #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ #include #endif +#ifndef _COM_SUN_STAR_TEXT_XTEXTVIEWCURSORSUPPLIER_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_URI_XURIREFERENCEFACTORY_HPP_ #include #endif @@ -86,6 +89,9 @@ #ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX #include #endif +#ifndef _UNOPRNMS_HXX +#include +#endif #ifndef _SFXDISPATCH_HXX //autogen #include @@ -206,6 +212,7 @@ #endif using namespace rtl; +using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::container; using namespace com::sun::star::lang; @@ -825,7 +832,7 @@ if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N) { if(nValidEntry == ((sal_Int32)nFormatId) - nOffset) - { + { aRet = xNumberingInfo->getNumberingIdentifier( pTypes[nType] ); break; } @@ -895,7 +902,7 @@ if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N) { if(nValidEntry == ((sal_Int32)nFormatId) - nOffset) - { + { nId = pTypes[nType]; break; } @@ -1361,17 +1368,36 @@ } else { - SwInputFieldType* pTyp = - (SwInputFieldType*)pCurShell->GetFldType(0, RES_INPUTFLD); - - SwInputField* pInpFld = - new SwInputField(pTyp, rData.sPar1, rData.sPar2, nSubType|SUB_INVISIBLE, nFormatId); - pFld = pInpFld; - } + try + { + uno::Reference< frame::XModel > xModel = pCurShell->GetView().GetDocShell()->GetModel(); + uno::Reference< lang::XMultiServiceFactory > xFactory( xModel, uno::UNO_QUERY ); + uno::Reference< text::XTextContent > xTextField ( + xFactory->createInstance( + (nSubType & 0xff) == INP_TXT ? + C2U( "com.sun.star.text.TextField.Input" ) : + C2U( "com.sun.star.text.TextField.InputUser" )), + uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xTextFieldProps( xTextField, uno::UNO_QUERY ); + xTextFieldProps->setPropertyValue( + ::rtl::OUString(SW_PROP_NAME( UNO_NAME_CONTENT), RTL_TEXTENCODING_ASCII_US ), + uno::makeAny( ::rtl::OUString( rData.sPar1 ) ) ); + xTextFieldProps->setPropertyValue( + ::rtl::OUString(SW_PROP_NAME( UNO_NAME_HINT ), RTL_TEXTENCODING_ASCII_US ), + uno::makeAny( ::rtl::OUString( rData.sPar2 ))); + uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( + pCurShell->GetView().GetController(), uno::UNO_QUERY ); + uno::Reference< text::XTextRange > xTextViewCursor( + xViewCursorSupplier->getViewCursor(), uno::UNO_QUERY_THROW ); + xTextViewCursor->getText()->insertTextContent(xTextViewCursor, xTextField, false); - // Dialog starten - // - pCurShell->StartInputFldDlg(pFld, FALSE, rData.pParent); + } + catch( const uno::Exception& ) + { + } + } + //todo make input field dialog work again - for insertion only +// pCurShell->StartInputFldDlg(pFld, FALSE, rData.pParent); break; } case TYP_SETFLD: @@ -1501,19 +1527,21 @@ return FALSE; } } - ASSERT(pFld, "Feld nicht vorhanden"); - + // Einfuegen + pCurShell->StartAllAction(); + if( pFld ) + { + ASSERT(pFld, "Feld nicht vorhanden"); - //the auto language flag has to be set prior to the language! - pFld->SetAutomaticLanguage(rData.bIsAutomaticLanguage); - USHORT nLang = GetCurrLanguage(); - pFld->SetLanguage(nLang); - // Einfuegen - pCurShell->StartAllAction(); + //the auto language flag has to be set prior to the language! + pFld->SetAutomaticLanguage(rData.bIsAutomaticLanguage); + USHORT nLang = GetCurrLanguage(); + pFld->SetLanguage(nLang); - pCurShell->Insert(*pFld); + pCurShell->Insert(*pFld); + } if(bExp && bEvalExp) pCurShell->UpdateExpFlds(TRUE); Index: source/ui/fldui/inpdlg.cxx =================================================================== RCS file: /cvs/sw/sw/source/ui/fldui/inpdlg.cxx,v --- source/ui/fldui/inpdlg.cxx 6 Nov 2006 14:52:47 -0000 1.9 +++ source/ui/fldui/inpdlg.cxx 5 Apr 2007 12:08:49 -0000 @@ -125,23 +125,24 @@ if( RES_INPUTFLD == pField->GetTyp()->Which() ) { // Es ist eine Eingabefeld // - pInpFld = (SwInputField*)pField; - aLabelED.SetText( pInpFld->GetPar2() ); - USHORT nSubType = pInpFld->GetSubType(); - - switch(nSubType & 0xff) - { - case INP_TXT: - aStr = pInpFld->GetPar1(); - break; - - case INP_USR: - // Benutzerfeld - if( 0 != ( pUsrType = (SwUserFieldType*)rSh.GetFldType( - RES_USERFLD, pInpFld->GetPar1() ) ) ) - aStr = pUsrType->GetContent(); - break; - } + //TODO: Handling of bookmark base inputfields +// pInpFld = (SwInputField*)pField; +// aLabelED.SetText( pInpFld->GetPar2() ); +// USHORT nSubType = pInpFld->GetSubType(); + +// switch(nSubType & 0xff) +// { +// case INP_TXT: +// aStr = pInpFld->GetPar1(); +// break; + +// case INP_USR: +// // Benutzerfeld +// if( 0 != ( pUsrType = (SwUserFieldType*)rSh.GetFldType( +// RES_USERFLD, pInpFld->GetPar1() ) ) ) +// aStr = pUsrType->GetContent(); +// break; +// } } else { @@ -202,12 +203,13 @@ bModified = TRUE; } } - else if( aTmp != pInpFld->GetPar1() ) - { - pInpFld->SetPar1(aTmp); - rSh.SwEditShell::UpdateFlds(*pInpFld); - bModified = TRUE; - } +// TODO - SwInputField replaced by SwInputFieldBookmark +// else if( aTmp != pInpFld->GetPar1() ) +// { +// pInpFld->SetPar1(aTmp); +// rSh.SwEditShell::UpdateFlds(*pInpFld); +// bModified = TRUE; +// } } else if( aTmp != pSetFld->GetPar2() ) { Index: source/ui/fldui/makefile.mk =================================================================== RCS file: /cvs/sw/sw/source/ui/fldui/makefile.mk,v --- source/ui/fldui/makefile.mk 9 Sep 2005 07:46:14 -0000 1.8 +++ source/ui/fldui/makefile.mk 5 Apr 2007 12:08:49 -0000 @@ -81,6 +81,7 @@ EXCEPTIONSFILES = \ + $(SLO)$/fldmgr.obj \ $(SLO)$/xfldui.obj LIB1TARGET = $(SLB)$/$(TARGET).lib Index: source/ui/shells/textfld.cxx =================================================================== RCS file: /cvs/sw/sw/source/ui/shells/textfld.cxx,v --- source/ui/shells/textfld.cxx 16 Sep 2006 23:17:06 -0000 1.31 +++ source/ui/shells/textfld.cxx 5 Apr 2007 12:08:49 -0000 @@ -247,6 +247,10 @@ } } } + else + { + //find bookmark field + } break; } case FN_EXECUTE_MACROFIELD: