diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-02 15:51:45 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-02 15:51:45 +0000 |
commit | 19f251c29311c23f071cc02fdaa6efd6917922a0 (patch) | |
tree | dcdd660d7eab7c6622efd45ac1baef869fd71c0f | |
parent | 16160041500efcc4cc8ad9b77e7c6aa90c0d1acc (diff) |
CWS-TOOLING: integrate CWS notes7
2008-12-29 19:45:08 +0100 mod r265824 : CWS-TOOLING: rebase CWS notes7 to trunk@265758 (milestone: DEV300:m38)
2008-12-16 14:54:42 +0100 mod r265544 : #i97239#
2008-12-16 14:53:18 +0100 mod r265543 : #i97239#
2008-12-16 13:36:43 +0100 mod r265537 : 96602
2008-12-13 13:02:54 +0100 mba r265452 : warning fixed
2008-12-13 08:20:21 +0100 mod r265448 : search inside notes
2008-12-13 00:11:47 +0100 mod r265447 : search inside notes
2008-12-13 00:11:09 +0100 mod r265446 : search inside notes
2008-12-13 00:10:52 +0100 mod r265445 : search inside notes
2008-12-12 19:39:14 +0100 mod r265439 : search inside notes
2008-12-12 19:02:44 +0100 mod r265438 : search inside notes
2008-12-12 16:42:07 +0100 mba r265431 : #i80135#: search in notes
2008-12-12 16:11:54 +0100 mba r265429 : #i80135#: search in notes
2008-12-12 16:11:02 +0100 mba r265428 : #i80135#: search in notes
2008-12-11 20:24:20 +0100 pb r265358 : fix: #i80135# fixes for aNotesBtn
2008-12-11 20:23:19 +0100 pb r265357 : fix: #i80135# fixes for aNotesBtn
2008-12-11 07:42:17 +0100 pb r265241 : fix: #i80135# CB_NOTES added
2008-12-11 07:40:36 +0100 pb r265240 : fix: #i80135# CB_NOTES added
2008-12-11 07:32:03 +0100 pb r265239 : fix: #i80135# CheckBox aNotesBtn added
2008-12-11 07:24:45 +0100 pb r265238 : fix: #i80135# CheckBox aNotesBtn added
2008-12-10 15:41:31 +0100 mod r265198 : crash using replies
2008-12-10 15:21:23 +0100 mod r265195 : crash using replies
2008-12-10 13:45:14 +0100 mba r265181 : warning fixed
2008-12-10 13:26:45 +0100 mba r265178 : warning fixed
2008-12-10 11:48:23 +0100 mba r265162 : fixed compilation error on Linux
2008-12-03 18:39:07 +0100 mod r264806 : we don't get the Ctrl-Alt-N on mac inside a note, let's do the whole reply thing using the shell, cleaner anyway
2008-12-03 17:13:59 +0100 mod r264802 : search dialog can be started and closed when focus is inside a note
2008-12-03 00:07:08 +0100 mod r264733 : search inside notes
2008-12-02 18:06:08 +0100 mod r264729 : WaE
2008-12-02 15:01:26 +0100 mod r264703 : WaE
2008-12-02 00:20:14 +0100 mod r264644 : WaE
2008-12-01 10:06:14 +0100 mod r264587 : WaE
2008-12-01 01:28:34 +0100 mod r264585 : WaE
2008-11-30 22:51:19 +0100 mod r264584 : search inside notes
2008-11-30 17:03:04 +0100 mod r264583 : search inside notes
2008-11-28 16:30:05 +0100 mod r264560 : #i96602#
2008-11-28 16:14:50 +0100 mod r264559 : test
2008-11-28 16:11:37 +0100 mod r264558 : test
2008-11-17 17:46:10 +0100 mod r263735 : WaE
2008-11-17 17:45:56 +0100 mod r263734 : WaE
2008-11-17 17:37:35 +0100 mod r263733 : revert manual fix for icu
2008-11-17 15:03:55 +0100 mod r263726 : manual fix for icu
2008-11-17 11:17:49 +0100 mod r263707 : manual fix for icu
2008-11-14 15:51:19 +0100 mod r263679 : fix
2008-11-14 14:48:02 +0100 mod r263676 : some more cleanup, redline comments not in the margin for 3.1
2008-11-14 08:37:07 +0100 mod r263664 : end of line missing
2008-11-13 18:36:53 +0100 mod r263660 : WaE
2008-11-13 18:20:04 +0100 mod r263659 : #i94374#
2008-11-13 15:51:28 +0100 mod r263648 : CWS-TOOLING: rebase CWS notes7 to trunk@263288 (milestone: DEV300:m35)
2008-11-13 08:33:19 +0100 mod r263622 : typos
2008-11-02 23:18:19 +0100 mod r263278 : changes notes, replies
2008-11-01 11:48:35 +0100 mod r262873 : replies, comments
2008-11-01 11:44:57 +0100 mod r262872 : notes search button
2008-10-10 14:34:34 +0200 mod r262150 : migration from cvs to svn
2008-10-10 14:33:39 +0200 mod r262149 : migration from cvs to svn
59 files changed, 2857 insertions, 1084 deletions
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 731902105434..ce3b1866007d 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: PostItMgr.hxx,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.84.5 $ * * This file is part of OpenOffice.org. * @@ -35,10 +35,13 @@ #include <list> #include <vector> - +#include <svx/outlobj.hxx> +#include <tools/string.hxx> #include <tools/link.hxx> #include <swrect.hxx> +#include <com/sun/star/util/SearchOptions.hpp> + class SwWrtShell; class SwDoc; class SwView; @@ -47,11 +50,13 @@ class SwFmtFld; class SwField; class SfxBroadcaster; class SfxHint; -class SwPostIt; class SwEditWin; class Color; class SvxSearchItem; class SvxLanguageItem; +class SwPostIt; +class SwMarginWin; +class SwMarginItem; #define SORT_POS 1 #define SORT_AUTHOR 2 @@ -60,9 +65,7 @@ class SvxLanguageItem; #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0) #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153) -struct SwPostItItem; - -typedef std::list<SwPostItItem*> SwPostItItem_list; +typedef std::list<SwMarginItem*> SwMarginItem_list; struct SwPostItPageItem { @@ -70,10 +73,10 @@ struct SwPostItPageItem bool bMarginSide; long lOffset; SwRect mPageRect; - SwPostItItem_list* mList; + SwMarginItem_list* mList; SwPostItPageItem(): bScrollbar(false),lOffset(0) { - mList = new SwPostItItem_list; + mList = new SwMarginItem_list; } ~SwPostItPageItem() { @@ -93,44 +96,42 @@ struct FieldShadowState } }; +typedef std::list<SwMarginItem*>::iterator SwMarginItem_iterator; + class SwPostItMgr: public SfxListener { private: SwView* mpView; SwWrtShell* mpWrtShell; SwEditWin* mpEditWin; - std::list< SwPostItItem*> mvPostItFlds; + std::list< SwMarginItem*> mvPostItFlds; std::vector<SwPostItPageItem*> mPages; ULONG mnEventId; bool mbWaitingForCalcRects; - SwPostIt* mpActivePostIt; + SwMarginWin* mpActivePostIt; bool mbLayout; long mbLayoutHeight; long mbLayouting; bool mbReadOnly; bool mbDeleteNote; FieldShadowState mShadowState; + OutlinerParaObject* mpAnswer; - typedef std::list<SwPostItItem*>::iterator SwPostItItem_iterator; - typedef std::list<SwPostIt*>::iterator SwPostIt_iterator; + typedef std::list<SwMarginWin*>::iterator SwMarginWin_iterator; void AddPostIts(bool bCheckExistance = true,bool bFocus = true); - void RemovePostIts(); + //void AddRedlineComments(bool bCheckExistance, bool bFocus); + void RemoveMarginWin(); void PreparePageContainer(); void Scroll(const long lScroll,const unsigned long aPage ); - void AutoScroll(const SwPostIt* pPostIt,const unsigned long aPage ); + void AutoScroll(const SwMarginWin* pPostIt,const unsigned long aPage ); bool ScrollbarHit(const unsigned long aPage,const Point &aPoint); - bool LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Rectangle aBorder,long lNeededHeight); + bool LayoutByPage(std::list<SwMarginWin*> &aVisiblePostItList,const Rectangle aBorder,long lNeededHeight); void CheckForRemovedPostIts(); bool ArrowEnabled(USHORT aDirection,unsigned long aPage) const; bool BorderOverPageBorder(unsigned long aPage) const; bool HasScrollbars() const; - - void SetColors(SwPostIt* pPostIt, SwPostItField* pFld); - - Color GetColorDark(sal_uInt16 aAuthorIndex); - Color GetColorLight(sal_uInt16 aAuthorIndex); - Color GetColorAnkor(sal_uInt16 aAuthorIndex); + void Focus(SfxBroadcaster& rBC); sal_Int32 GetInitialAnchorDistance() const; sal_Int32 GetScrollSize() const; @@ -144,18 +145,18 @@ class SwPostItMgr: public SfxListener SwPostItMgr(SwView* aDoc); ~SwPostItMgr(); - typedef std::list< SwPostItItem* >::const_iterator const_iterator; + typedef std::list< SwMarginItem* >::const_iterator const_iterator; const_iterator begin() const { return mvPostItFlds.begin(); } const_iterator end() const { return mvPostItFlds.end(); } - void InsertFld( SwFmtFld* aField, bool bCheckExistance, bool bFocus); - void RemoveFld( SfxBroadcaster* pFld ); + void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus); + void RemoveItem( SfxBroadcaster* pBroadcast ); void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); void LayoutPostIts(); bool CalcRects(); - void MakeVisible(const SwPostIt* pPostIt,long aPage = -1); + void MakeVisible(const SwMarginWin* pPostIt,long aPage = -1); bool ShowScrollbar(const unsigned long aPage) const; bool HasNotes() const ; @@ -187,24 +188,35 @@ class SwPostItMgr: public SfxListener bool IsHit(const Point &aPointPixel); Color GetArrowColor(USHORT aDirection,unsigned long aPage) const; - SwPostIt* GetNextPostIt(USHORT aDirection, SwPostIt* aPostIt); + SwMarginWin* GetNextPostIt(USHORT aDirection, SwMarginWin* aPostIt); long GetNextBorder(); - SwPostIt* GetActivePostIt() { return mpActivePostIt; } - void SetActivePostIt( SwPostIt* p); + SwMarginWin* GetActivePostIt() { return mpActivePostIt; } + void SetActivePostIt( SwMarginWin* p); sal_Int32 GetMinimumSizeWithMeta() const; sal_Int32 GetSidebarScrollerHeight() const; - SwFmtFld* GetFmtFld(SwPostIt* mpPostIt) const; - SwPostIt* GetPostIt(const SwFmtFld* pFld) const; + SwMarginWin* GetPostIt(const SfxBroadcaster* pBroadcaster) const; + SwMarginWin* GetPostIt(SfxBroadcaster* pBroadcaster) const; SwPostIt* GetPostIt(const SwPostItField* pFld) const; - SwPostIt* GetPostIt(SwFmtFld* pFld) const; SwPostIt* GetPostIt(SwPostItField* pFld) const; void SetShadowState(const SwPostItField* pFld,bool bCursor = true); void SetSpellChecking(); - bool ShowPreview(const SwField* pFld,SwFmtFld*& pFmtFld) const; + Color GetColorDark(sal_uInt16 aAuthorIndex); + Color GetColorLight(sal_uInt16 aAuthorIndex); + Color GetColorAnkor(sal_uInt16 aAuthorIndex); + + bool ShowPreview(const SwField* pFld,SwFmtFld*& pFmtFld) const; + + void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;} + OutlinerParaObject* IsAnswer() {return mpAnswer;} + + sal_uInt16 Replace(SvxSearchItem* pItem); + void StartSearchAndReplace(const SvxSearchItem& rSearchItem); + sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); + sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); }; #endif diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index f78c0ce55f62..f5de3d518082 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: cmdid.h,v $ - * $Revision: 1.84 $ + * $Revision: 1.84.34.1 $ * * This file is part of OpenOffice.org. * @@ -1069,6 +1069,10 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr #define FN_HIDE_NOTE_AUTHOR (FN_NOTES+4) #define FN_HIDE_ALL_NOTES (FN_NOTES+5) +#define FN_DELETE_COMMENT (FN_NOTES+6) +#define FN_REPLY (FN_NOTES+7) + + /*-------------------------------------------------------------------- Bereich: Parameter --------------------------------------------------------------------*/ diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index f997a4e6e97a..1f945cf6fdff 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -392,6 +392,7 @@ public: // die Suchfunktionen ULONG Find( const com::sun::star::util::SearchOptions& rSearchOpt, + BOOL bSearchInNotes, SwDocPositions eStart, SwDocPositions eEnde, BOOL& bCancel, FindRanges eRng, int bReplace = FALSE ); diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index 5dd199b11a81..3cd0f1bb034f 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docufld.hxx,v $ - * $Revision: 1.17 $ + * $Revision: 1.17.82.1 $ * * This file is part of OpenOffice.org. * @@ -30,10 +30,8 @@ #ifndef _DOCUFLD_HXX #define _DOCUFLD_HXX -#ifndef _DATE_HXX //autogen - #include <tools/date.hxx> -#endif +#include <tools/date.hxx> #include <tools/datetime.hxx> diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index 20c585dcfc9f..496df5c56a1c 100644 --- a/sw/inc/fmtfld.hxx +++ b/sw/inc/fmtfld.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: fmtfld.hxx,v $ - * $Revision: 1.9 $ + * $Revision: 1.9.118.1 $ * * This file is part of OpenOffice.org. * @@ -31,17 +31,16 @@ #define _FMTFLD_HXX #include <svtools/poolitem.hxx> - +#include <svtools/brdcst.hxx> #include <svtools/smplhint.hxx> + #include "swdllapi.h" #include <calbck.hxx> -#include <svtools/brdcst.hxx> - class SwField; class SwTxtFld; -// ATT_FLD *********************************** +// ATT_FLD *********************************** class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBroadcaster { friend class SwTxtFld; @@ -117,4 +116,3 @@ public: }; #endif - diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx index 09f2931c2176..f4237c6b964b 100644 --- a/sw/inc/pam.hxx +++ b/sw/inc/pam.hxx @@ -162,6 +162,7 @@ public: // Suchen BYTE Find( const com::sun::star::util::SearchOptions& rSearchOpt, + BOOL bSearchInNotes, utl::TextSearch& rSTxt, SwMoveFn fnMove = fnMoveForward, const SwPaM *pPam =0, BOOL bInReadOnly = FALSE); @@ -175,6 +176,9 @@ public: SwMoveFn fnMove, const SwPaM *pPam, BOOL bInReadOnly, BOOL bMoveFirst ); + bool DoSearch( const com::sun::star::util::SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, + SwMoveFn fnMove, BOOL bSrchForward, BOOL bRegSearch, BOOL bChkEmptyPara, BOOL bChkParaEnd, + xub_StrLen &nStart, xub_StrLen &nEnde,xub_StrLen nTxtLen,SwNode* pNode, SwPaM* pPam); inline BOOL IsInFrontOfLabel() const { return bIsInFrontOfLabel; } inline void _SetInFrontOfLabel( BOOL bNew ) { bIsInFrontOfLabel = bNew; } @@ -195,7 +199,7 @@ public: void Exchange(); #endif /* - * Undokumented Feature: Liefert zurueck, ob das Pam ueber + * Undocumented Feature: Liefert zurueck, ob das Pam ueber * eine Selektion verfuegt oder nicht. Definition einer * Selektion: Point und Mark zeigen auf unterschiedliche * Puffer. diff --git a/sw/inc/postit.hxx b/sw/inc/postit.hxx index 62c419eb2dac..e1683477b334 100644 --- a/sw/inc/postit.hxx +++ b/sw/inc/postit.hxx @@ -8,7 +8,7 @@ * * $RCSfile: postit.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.8.84.7 $ * * This file is part of OpenOffice.org. * @@ -38,6 +38,9 @@ #include <swrect.hxx> #include <svx/sdr/overlay/overlayobject.hxx> +#include <tools/datetime.hxx> +#include <tools/date.hxx> + #include <vcl/lineinfo.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <svx/editstat.hxx> @@ -55,6 +58,12 @@ class Edit; class MultiLineEdit; class PopupMenu; class SvxLanguageItem; +class SwRedline; +class OutlinerParaObject; + +#define ANKORLINE_WIDTH 1 + +enum AnkorState {AS_ALL, AS_START, AS_END}; class SwPostItAnkor: public sdr::overlay::OverlayObjectWithBasePosition { @@ -91,6 +100,7 @@ class SwPostItAnkor: public sdr::overlay::OverlayObjectWithBasePosition LineInfo mLineInfo; unsigned long mHeight; bool mbShadowedEffect; + AnkorState mAnkorState; public: SwPostItAnkor(const basegfx::B2DPoint& rBasePos, @@ -125,6 +135,8 @@ class SwPostItAnkor: public sdr::overlay::OverlayObjectWithBasePosition bool getShadowedEffect() const { return mbShadowedEffect; } + void SetAnkorState(AnkorState aState); + AnkorState GetAnkorState() const {return mAnkorState;} virtual void Trigger(sal_uInt32 nTime); //sal_Bool isHit(const basegfx::B2DPoint& rPos, double fTol) const; @@ -164,7 +176,7 @@ class PostItTxt : public Window { private: OutlinerView* mpOutlinerView; - SwPostIt* mpPostIt; + SwMarginWin* mpMarginWin; bool mMouseOver; BOOL mbShowPopup; @@ -179,6 +191,11 @@ class PostItTxt : public Window virtual void DataChanged( const DataChangedEvent& aData); virtual void LoseFocus(); virtual void RequestHelp(const HelpEvent &rEvt); + + // reconversion /*i94374*/ + virtual XubString GetSurroundingText() const; + virtual Selection GetSurroundingTextSelection() const; + DECL_LINK( Select, Menu* ); public: @@ -196,9 +213,11 @@ typedef sal_Int64 SwPostItBits; #define PB_Preview ((SwPostItBits)0x00000001) -class SwPostIt : public Window + +class SwMarginWin : public Window { private: + ULONG mnEventId; SwView* mpView; sdr::overlay::OverlayManager* pOverlayManager; OutlinerView* mpOutlinerView; @@ -206,33 +225,30 @@ class SwPostIt : public Window PostItTxt* mpPostItTxt; MultiLineEdit* mpMeta; ScrollBar* mpVScrollbar; - SwFmtFld* mpFmtFld; - SwPostItField* mpFld; SwPostItAnkor* mpAnkor; SwPostItShadow* mpShadow; SwPostItMgr* mpMgr; bool mbMeta; - bool mbReadonly; Color mColorAnkor; Color mColorDark; Color mColorLight; basegfx::B2DPolygon aPopupTriangle; - Rectangle mRectMetaButton; - PopupMenu* mpButtonPopup; - sal_Int32 mnEventId; bool mbMarginSide; Rectangle mPosSize; SwRect mAnkorRect; long mPageBorder; SwPostItBits nFlags; - Color mChangeColor; - SwPostItHelper::SwLayoutStatus mStatus; - + bool mbMouseOverButton; protected: - + bool mbReadonly; + PopupMenu* mpButtonPopup; + bool mbIsFollow; + Rectangle mRectMetaButton; + virtual void CheckMetaText(); virtual void DataChanged( const DataChangedEvent& aEvent); virtual void LoseFocus(); virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); virtual void Paint( const Rectangle& rRect); virtual void GetFocus(); void SetPosAndSize(); @@ -240,20 +256,17 @@ class SwPostIt : public Window DECL_LINK(ModifyHdl, void*); DECL_LINK(ScrollHdl, ScrollBar*); - - void InitControls(); - void CheckMetaText(); + DECL_LINK(DeleteHdl, void*); public: - SwPostIt( Window* pParent, WinBits nBits,SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits); - ~SwPostIt(); + TYPEINFO(); + SwMarginWin( Window* pParent, WinBits nBits, SwPostItMgr* aMgr,SwPostItBits aBits); + virtual ~SwMarginWin(); void SetSize( const Size& rNewSize ); void SetPosSizePixelRect( long nX, long nY,long nWidth, long nHeight,const SwRect &aRect,const long PageBorder); void TranslateTopPosition(const long aAmount); - void SetPostItText(); - PostItTxt* PostItText() { return mpPostItTxt;} ScrollBar* Scrollbar() { return mpVScrollbar;} SwPostItAnkor* Ankor() { return mpAnkor;} @@ -262,20 +275,29 @@ class SwPostIt : public Window SwView* DocView() { return mpView;} Outliner* Engine() { return mpOutliner;} SwPostItMgr* Mgr() { return mpMgr; } - SwFmtFld* Field() { return mpFmtFld; } + SwRect GetAnkorRect() { return mAnkorRect; } - String GetAuthor() const; SwEditWin* EditWin(); long GetPostItTextHeight(); - void UpdateData(); void SwitchToPostIt(USHORT aDirection); //void SwitchToPostIt(bool aDirection); - void SwitchToFieldPos(bool bAfter = true); + virtual void SwitchToFieldPos(); + virtual sal_uInt32 MoveCaret() { return 0;}; + + virtual void UpdateData() = 0; + virtual void SetPostItText() = 0; + virtual void Delete(); + virtual void GotoPos() = 0; + virtual void SetPopup() = 0; - void ExecuteCommand(USHORT aSlot); - void Delete(); + virtual String GetAuthor(); + virtual Date GetDate(); + virtual Time GetTime(); + + void ExecuteCommand(USHORT nSlot); + void InitControls(); void HidePostIt(); void DoResize(); void ResizeIfNeccessary(long aOldHeight, long aNewHeight); @@ -291,18 +313,27 @@ class SwPostIt : public Window void ResetAttributes(); - void SetLanguage(const SvxLanguageItem aNewItem); void SetMarginSide(bool aMarginSide); void SetReadonly(BOOL bSet); BOOL IsReadOnly() { return mbReadonly;} bool IsPreview() { return nFlags & PB_Preview;} + void SetLanguage(const SvxLanguageItem aNewItem); + virtual SvxLanguageItem GetLanguage(void); + void SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor); Color ColorDark() { return mColorDark; } Color ColorLight() { return mColorLight; } void Rescale(); - void SetShadowState(ShadowState bState); + void SetViewState(ShadowState bState); + + bool IsFollow() { return mbIsFollow; } + void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow;}; + virtual bool CalcFollow(); + + SwMarginWin* GetTopReplyNote(); + bool IsAnyStackParentVisible(); sal_Int32 GetMetaHeight(); sal_Int32 GetMinimumSizeWithMeta(); @@ -314,15 +345,82 @@ class SwPostIt : public Window void ToggleInsMode(); + virtual void ActivatePostIt(); + virtual void DeactivatePostIt(); + + virtual SwPostItHelper::SwLayoutStatus GetStatus() { return SwPostItHelper::NONE; } + + virtual bool IsProtected() {return mbReadonly;}; +}; + +// implementation for change tracking comments, fully functional, but not yet used +/* +class SwRedComment : public SwMarginWin +{ + private: + SwRedline* pRedline; + + protected: + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + public: + TYPEINFO(); + SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed); + virtual ~SwRedComment() {}; + + virtual void UpdateData(); + virtual void SetPostItText(); + virtual void Delete(); + virtual void GotoPos(); + virtual void SetPopup(); + virtual void ActivatePostIt(); + virtual void DeactivatePostIt(); + + virtual String GetAuthor(); + virtual Date GetDate(); + virtual Time GetTime(); + + virtual bool IsProtected(); +}; +*/ +class SwPostIt : public SwMarginWin +{ + private: + SwFmtFld* mpFmtFld; + SwPostItField* mpFld; + SwPostItHelper::SwLayoutStatus mStatus; + Color mChangeColor; + + protected: + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + + public: + TYPEINFO(); + SwPostIt( Window* pParent, WinBits nBits,SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits); + virtual ~SwPostIt() {}; + + virtual void UpdateData(); + virtual void SetPostItText(); + virtual void Delete(); + virtual void GotoPos(); + virtual void SetPopup(); + + virtual String GetAuthor(); + virtual Date GetDate(); + virtual Time GetTime(); + + virtual sal_uInt32 MoveCaret(); + void SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor); - SwPostItHelper::SwLayoutStatus GetStatus() { return mStatus; } + virtual SwPostItHelper::SwLayoutStatus GetStatus() { return mStatus; } Color GetChangeColor() { return mChangeColor; } + sal_uInt32 CountFollowing(); + virtual bool CalcFollow(); + void InitAnswer(OutlinerParaObject* pText); + virtual SvxLanguageItem GetLanguage(void); - void ActivatePostIt(); - void DeactivatePostIt(); + virtual bool IsProtected(); }; - #endif diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx index ef0637684818..3f36c6015f6c 100644 --- a/sw/inc/postithelper.hxx +++ b/sw/inc/postithelper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: postithelper.hxx,v $ - * $Revision: 1.2 $ + * $Revision: 1.2.118.3 $ * * This file is part of OpenOffice.org. * @@ -31,15 +31,23 @@ #define _POSTITHELPER_HXX #include <swrect.hxx> +#include <fmtfld.hxx> +#include <redline.hxx> #include <vector> +#include <vcl/window.hxx> +#include <svtools/brdcst.hxx> class SwTxtFld; class SwRootFrm; -class SwFmtFld; class SwPostIt; +class String; +class SwMarginWin; +class SwPostItMgr; struct SwPosition; +typedef sal_Int64 SwPostItBits; + struct SwLayoutInfo { SwRect mPosition; @@ -54,7 +62,7 @@ namespace SwPostItHelper { enum SwLayoutStatus { - INVISIBLE, VISIBLE, INSERTED, DELETED + INVISIBLE, VISIBLE, INSERTED, DELETED, NONE, HIDDEN }; SwLayoutStatus getLayoutInfos( std::vector< SwLayoutInfo >&, SwPosition& ); @@ -64,30 +72,71 @@ namespace SwPostItHelper unsigned long getPageInfo( SwRect& rPageFrm, const SwRootFrm* , const Point& ); } -struct SwPostItItem +class SwMarginItem { +public: + SwMarginWin* pPostIt; bool bShow; bool bFocus; bool bMarginSide; - SwFmtFld* pFmtFld; - SwPostIt* pPostIt; SwRect mPos; SwRect mFramePos; SwRect mPagePos; unsigned long mnPageNumber; SwPostItHelper::SwLayoutStatus mLayoutStatus; USHORT mRedlineAuthor; - SwPostItItem( SwFmtFld* p, bool aShow, bool aFocus) - : bShow(aShow), + SwMarginItem(bool aShow, bool aFocus) + : pPostIt(0), + bShow(aShow), bFocus(aFocus), bMarginSide(false), - pFmtFld(p), - pPostIt(0), mnPageNumber(1), mLayoutStatus( SwPostItHelper::INVISIBLE ), mRedlineAuthor(0) + {} + virtual ~SwMarginItem(){} + virtual SwPosition GetPosition() = 0; + virtual bool UseElement() = 0; + virtual SwFmtFld* GetFmtFld() = 0; + virtual SfxBroadcaster* GetBroadCaster() const = 0; + virtual SwMarginWin* GetMarginWindow(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits) = 0; +}; +/* +class SwRedCommentItem: public SwMarginItem +{ +private: + SwRedline* pRedline; +public: + + SwRedCommentItem( SwRedline* pRed, bool aShow, bool aFocus) + : SwMarginItem(aShow,aFocus), + pRedline(pRed) {} + virtual ~SwRedCommentItem() {} + virtual SwPosition GetPosition(); + virtual bool UseElement(); + virtual SwFmtFld* GetFmtFld() {return 0; } + virtual SfxBroadcaster* GetBroadCaster() const { return dynamic_cast<SfxBroadcaster *> (pRedline); } + virtual SwMarginWin* GetMarginWindow(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits); +}; +*/ + +class SwPostItItem: public SwMarginItem +{ + private: + SwFmtFld* pFmtFld; + + public: + SwPostItItem( SwFmtFld* p, bool aShow, bool aFocus) + : SwMarginItem(aShow,aFocus) , + pFmtFld(p) { } + virtual ~SwPostItItem() {} + virtual SwPosition GetPosition(); + virtual bool UseElement(); + virtual SwFmtFld* GetFmtFld() {return pFmtFld;} + virtual SfxBroadcaster* GetBroadCaster() const { return dynamic_cast<SfxBroadcaster *> (pFmtFld); } + virtual SwMarginWin* GetMarginWindow(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits); }; #endif // _POSTITHELPER_HXX diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx index e9230c4228a7..b05f132b5e23 100644 --- a/sw/inc/redline.hxx +++ b/sw/inc/redline.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: redline.hxx,v $ - * $Revision: 1.14 $ + * $Revision: 1.14.180.1 $ * * This file is part of OpenOffice.org. * @@ -37,9 +37,9 @@ #include <svtools/svstdarr.hxx> #include <pam.hxx> -#ifndef IDOCUMENTREDLINEACCESS_HXX_INCLUDED #include <IDocumentRedlineAccess.hxx> -#endif + +#include <svtools/smplhint.hxx> class SfxItemSet; @@ -287,4 +287,27 @@ public: int operator<( const SwRedline& ) const; }; +class SW_DLLPUBLIC SwRedlineHint : public SfxHint +{ +#define SWREDLINE_INSERTED 1 +#define SWREDLINE_REMOVED 2 +#define SWREDLINE_FOCUS 3 +#define SWREDLINE_CHANGED 4 +#define SWREDLINE_LANGUAGE 5 + + const SwRedline* pRedline; + sal_Int16 nWhich; + +public: + SwRedlineHint( const SwRedline* p, sal_Int16 n ) + : pRedline(p) + , nWhich(n) + {} + + TYPEINFO(); + const SwRedline* GetRedline() const { return pRedline; } + sal_Int16 Which() const { return nWhich; } +}; + + #endif diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx index d9a159554808..8dd654c4034a 100644 --- a/sw/inc/swcrsr.hxx +++ b/sw/inc/swcrsr.hxx @@ -126,6 +126,7 @@ public: ULONG Find( const com::sun::star::util::SearchOptions& rSearchOpt, + BOOL bSearchInNotes, SwDocPositions nStart, SwDocPositions nEnde, BOOL& bCancel, FindRanges = FND_IN_BODY, diff --git a/sw/sdi/_annotsh.sdi b/sw/sdi/_annotsh.sdi index 1f4e205ebe82..cbba9249acaa 100755 --- a/sw/sdi/_annotsh.sdi +++ b/sw/sdi/_annotsh.sdi @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: _annotsh.sdi,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.82.3 $ * * This file is part of OpenOffice.org. * @@ -31,6 +31,12 @@ interface _Annotation [ Automation = FALSE; ] { + FN_DELETE_COMMENT + [ + ExecMethod = NoteExec ; + StateMethod = GetNoteState ; + ] + FN_DELETE_NOTE [ ExecMethod = NoteExec ; @@ -67,6 +73,17 @@ interface _Annotation StateMethod = GetNoteState ; ] + FN_POSTIT + [ + ExecMethod = NoteExec ; + StateMethod = GetNoteState ; + ] + + FN_REPLY + [ + ExecMethod = NoteExec ; + StateMethod = GetNoteState ; + ] FN_ESCAPE // api: [ ExecMethod = NoteExec ; @@ -151,12 +168,39 @@ interface _Annotation DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + FN_FORMAT_FOOTNOTE_DLG // status() + [ + ExecMethod = Exec ; + ] + + SID_OPEN_XML_FILTERSETTINGS // ole : no, status : ? + [ + ExecMethod = Exec ; + ] + + FN_WORDCOUNT_DIALOG + [ + ExecMethod = Exec; + ] + + FN_NUMBERING_OUTLINE_DLG // status(final|play) + [ + ExecMethod = Exec ; + ] + FN_INSERT_SYMBOL // api: [ ExecMethod = Exec ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + FN_INSERT_STRING + [ + ExecMethod = Exec ; + StateMethod = NoState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + SID_ATTR_CHAR_FONT // status() [ ExecMethod = Exec; @@ -303,4 +347,43 @@ interface _Annotation StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + + SID_SEARCH_ITEM // status() + [ + ExecMethod = ExecSearch ; + StateMethod = StateSearch ; + Export = FALSE; + ] + FN_REPEAT_SEARCH // status(final|play) + [ + ExecMethod = ExecSearch ; + ] + FID_SEARCH_NOW // status() + [ + ExecMethod = ExecSearch ; + ] + SID_SEARCH_OPTIONS // status() + [ + StateMethod = StateSearch ; + ] + FID_SEARCH_SEARCHSET // status() + [ + ExecMethod = ExecSearch ; + ] + FID_SEARCH_REPLACESET // status() + [ + ExecMethod = ExecSearch ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + // ab hier Export = FALSE; + FID_SEARCH_ON // status() + [ + ExecMethod = ExecSearch ; + Export = FALSE; + ] + FID_SEARCH_OFF // status() + [ + ExecMethod = ExecSearch ; + Export = FALSE; + ] } diff --git a/sw/sdi/_frmsh.sdi b/sw/sdi/_frmsh.sdi index d2d81bf39feb..a355bdb76b55 100644 --- a/sw/sdi/_frmsh.sdi +++ b/sw/sdi/_frmsh.sdi @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: _frmsh.sdi,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.190.2 $ * * This file is part of OpenOffice.org. * @@ -232,6 +232,27 @@ interface BaseTextFrame DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + FN_FORMAT_FOOTNOTE_DLG // status() + [ + ExecMethod = Execute; + ] + + SID_OPEN_XML_FILTERSETTINGS // ole : no, status : ? + [ + ExecMethod = Execute ; + ] + + FN_WORDCOUNT_DIALOG + [ + ExecMethod = Execute; + ] + + FN_NUMBERING_OUTLINE_DLG // status(final|play) + [ + ExecMethod = Execute ; + ] + + /***************************************************** Abfragefunktionen fuer ImageMaps diff --git a/sw/sdi/_grfsh.sdi b/sw/sdi/_grfsh.sdi index bfb8711b5a23..9d431b8b8291 100644 --- a/sw/sdi/_grfsh.sdi +++ b/sw/sdi/_grfsh.sdi @@ -64,7 +64,14 @@ interface BaseTextGraphic SID_INSERT_GRAPHIC // zeigt auf FN_FORMAT_GRAFIC_DLG [ ExecMethod = Execute ; - StateMethod = NoState ; + StateMethod = GetAttrState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + + SID_TWAIN_TRANSFER + [ + ExecMethod = Execute ; + StateMethod = GetAttrState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] diff --git a/sw/sdi/annotsh.sdi b/sw/sdi/annotsh.sdi index a29ed5dbd55d..c3693daf6c19 100755 --- a/sw/sdi/annotsh.sdi +++ b/sw/sdi/annotsh.sdi @@ -271,11 +271,6 @@ interface Annotation : _Annotation DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - SID_SEARCH_DLG - [ - StateMethod = StateDisableItems - ] - SID_STYLE_FAMILY1 [ StateMethod = StateDisableItems ; diff --git a/sw/sdi/drawsh.sdi b/sw/sdi/drawsh.sdi index 62a3086f9e95..dd8441aefa98 100644 --- a/sw/sdi/drawsh.sdi +++ b/sw/sdi/drawsh.sdi @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: drawsh.sdi,v $ - * $Revision: 1.9 $ + * $Revision: 1.9.190.2 $ * * This file is part of OpenOffice.org. * @@ -443,6 +443,25 @@ shell SwDrawShell : SwDrawBaseShell DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + FN_FORMAT_FOOTNOTE_DLG // status() + [ + ExecMethod = Execute; + ] + + SID_OPEN_XML_FILTERSETTINGS // ole : no, status : ? + [ + ExecMethod = Execute ; + ] + + FN_WORDCOUNT_DIALOG + [ + ExecMethod = Execute; + ] + + FN_NUMBERING_OUTLINE_DLG // status(final|play) + [ + ExecMethod = Execute ; + ] } diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi index 41ec7a88f857..c18d47ec2bc0 100644 --- a/sw/sdi/drwtxtsh.sdi +++ b/sw/sdi/drwtxtsh.sdi @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: drwtxtsh.sdi,v $ - * $Revision: 1.20 $ + * $Revision: 1.20.82.2 $ * * This file is part of OpenOffice.org. * @@ -119,6 +119,14 @@ interface TextDrawText ExecMethod = ExecDraw ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + + FN_INSERT_STRING + [ + ExecMethod = ExecDraw ; + StateMethod = NoState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + FN_INSERT_SOFT_HYPHEN // status(final|play) [ ExecMethod = ExecDraw ; @@ -145,25 +153,23 @@ interface TextDrawText ] SID_INSERT_LRM [ - ExecMethod = ExecDraw ; + ExecMethod = ExecDraw ; StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] SID_INSERT_ZWSP [ - ExecMethod = ExecDraw ; + ExecMethod = ExecDraw ; StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] SID_INSERT_ZWNBSP [ - ExecMethod = ExecDraw ; + ExecMethod = ExecDraw ; StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - - SID_ATTR_CHAR_WEIGHT // api: [ ExecMethod = Execute ; @@ -512,6 +518,27 @@ interface TextDrawText StateMethod = GetState; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; // e.g. disable for read-only documents ] + + FN_FORMAT_FOOTNOTE_DLG // status() + [ + ExecMethod = Execute ; + ] + + SID_OPEN_XML_FILTERSETTINGS // ole : no, status : ? + [ + ExecMethod = Execute ; + ] + + FN_WORDCOUNT_DIALOG + [ + ExecMethod = Execute; + ] + + FN_NUMBERING_OUTLINE_DLG // status(final|play) + [ + ExecMethod = Execute ; + ] + } interface TextDrawFont diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 6d4b9e29bf35..9bba9039eb3d 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -10013,6 +10013,55 @@ SfxVoidItem DeleteNote FN_DELETE_NOTE GroupId = GID_EDIT; ] +SfxVoidItem ReplyNote FN_REPLY +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_EDIT; +] + +//-------------------------------------------------------------------------- +SfxVoidItem DeleteComment FN_DELETE_COMMENT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_EDIT; +] + //-------------------------------------------------------------------------- SfxVoidItem DeleteAuthor FN_DELETE_NOTE_AUTHOR ( SfxStringItem Author FN_DELETE_NOTE_AUTHOR ) [ diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index bb6a870bc252..72056be6a3ef 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -3112,7 +3112,7 @@ bool SwCrsrShell::SelectHiddenRange() /* */ // die Suchfunktionen -ULONG SwCrsrShell::Find( const SearchOptions& rSearchOpt, +ULONG SwCrsrShell::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes, SwDocPositions eStart, SwDocPositions eEnde, BOOL& bCancel, FindRanges eRng, int bReplace ) @@ -3121,7 +3121,7 @@ ULONG SwCrsrShell::Find( const SearchOptions& rSearchOpt, GetCrsr(); delete pTblCrsr, pTblCrsr = 0; SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen - ULONG nRet = pCurCrsr->Find( rSearchOpt, eStart, eEnde, bCancel, eRng, bReplace ); + ULONG nRet = pCurCrsr->Find( rSearchOpt, bSearchInNotes, eStart, eEnde, bCancel, eRng, bReplace ); if( nRet || bCancel ) UpdateCrsr(); return nRet; diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 54a5fe9cc4c8..61aa9f95ffd7 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -1138,8 +1138,12 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, pSTxt = new utl::TextSearch( aTmp ); } + + // todo/mba: searching for attributes in Outliner text?! + BOOL bSearchInNotes = FALSE; + // Bug 24665: suche im richtigen Bereich weiter (pTextRegion!) - if( aSrchPam.Find( *pSearchOpt, *pSTxt, fnMove, pTextRegion, bInReadOnly ) && + if( aSrchPam.Find( *pSearchOpt, bSearchInNotes, *pSTxt, fnMove, pTextRegion, bInReadOnly ) && *aSrchPam.GetMark() != *aSrchPam.GetPoint() ) // gefunden ? break; // also raus else if( !pSet->Count() ) diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 5a577a35fbe4..e21d744b705a 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -51,6 +51,14 @@ #include <swundo.hxx> #include <breakit.hxx> +/*testarea*/ +#include <docsh.hxx> +#include <PostItMgr.hxx> +#include <viewsh.hxx> +#include <vcl/window.hxx> + +#define POSTITMGR ((ViewShell*)pNode->GetDoc()->GetDocShell()->GetWrtShell())->GetPostItMgr() + using namespace ::com::sun::star; using namespace util; @@ -188,9 +196,39 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, return rRet; } +// skip all non SwPostIts inside the array +xub_StrLen GetPostIt(xub_StrLen aCount,const SwpHints *pHts) +{ + xub_StrLen aIndex = 0; + while (aCount) + { + for (xub_StrLen i = 0; i <pHts->Count();i++) + { + aIndex++; + const SwTxtAttr* pTxtAttr = (*pHts)[i]; + if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) && + (pTxtAttr->GetFld().GetFld()->Which()==RES_POSTITFLD)) + { + aCount--; + if (!aCount) + break; + } + } + } + // throw away all following non postits + for (xub_StrLen i = aIndex; i <pHts->Count();i++) + { + const SwTxtAttr* pTxtAttr = (*pHts)[i]; + if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) && + (pTxtAttr->GetFld().GetFld()->Which()==RES_POSTITFLD)) + break; + else + aIndex++; + } + return aIndex; +} - -BYTE SwPaM::Find( const SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, +BYTE SwPaM::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes , utl::TextSearch& rSTxt, SwMoveFn fnMove, const SwPaM * pRegion, BOOL bInReadOnly ) { @@ -229,11 +267,12 @@ BYTE SwPaM::Find( const SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, */ BOOL bFirst = TRUE; SwCntntNode * pNode; - String sCleanStr; - SvULongs aFltArr; + //testarea + //String sCleanStr; + //SvULongs aFltArr; + //const SwNode* pSttNd = &rNdIdx.GetNode(); xub_StrLen nStart, nEnde, nTxtLen; - const SwNode* pSttNd = &rNdIdx.GetNode(); BOOL bRegSearch = SearchAlgorithms_REGEXP == rSearchOpt.algorithmType; BOOL bChkEmptyPara = bRegSearch && 2 == rSearchOpt.searchString.getLength() && @@ -242,7 +281,7 @@ BYTE SwPaM::Find( const SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, BOOL bChkParaEnd = bRegSearch && 1 == rSearchOpt.searchString.getLength() && !rSearchOpt.searchString.compareToAscii( "$" ); - LanguageType eLastLang = 0; +// LanguageType eLastLang = 0; while( 0 != ( pNode = ::GetNode( *pPam, bFirst, fnMove, bInReadOnly ) )) { if( pNode->IsTxtNode() ) @@ -254,136 +293,269 @@ BYTE SwPaM::Find( const SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, nEnde = bSrchForward ? nTxtLen : 0; nStart = rCntntIdx.GetIndex(); - // if the search string contains a soft hypen, we don't strip them from the text: - bool bRemoveSoftHyphens = true; - if ( bRegSearch ) - { - const rtl::OUString a00AD( rtl::OUString::createFromAscii( "\\x00AD" ) ); - if ( -1 != rSearchOpt.searchString.indexOf( a00AD ) ) - bRemoveSoftHyphens = false; - } - else - { - if ( 1 == rSearchOpt.searchString.getLength() && - CHAR_SOFTHYPHEN == rSearchOpt.searchString.toChar() ) - bRemoveSoftHyphens = false; - } - - if( bSrchForward ) - lcl_CleanStr( *(SwTxtNode*)pNode, nStart, nEnde, - aFltArr, sCleanStr, bRemoveSoftHyphens ); - else - lcl_CleanStr( *(SwTxtNode*)pNode, nEnde, nStart, - aFltArr, sCleanStr, bRemoveSoftHyphens ); - - SwScriptIterator* pScriptIter = 0; - USHORT nSearchScript = 0; - USHORT nCurrScript = 0; + /* #i80135# */ + // if there are SwPostItFields inside our current node text, we split the text into seperate pieces + // and search for text inside the pieces as well as inside the fields + const SwpHints *pHts = ((SwTxtNode*)pNode)->GetpSwpHints(); - if ( SearchAlgorithms_APPROXIMATE == rSearchOpt.algorithmType && - pBreakIt->xBreak.is() ) + // count postitfields by looping over all fields + xub_StrLen aNumberPostits = 0; + xub_StrLen aIgnore = 0; + if (pHts && bSearchInNotes) { - pScriptIter = new SwScriptIterator( sCleanStr, nStart, bSrchForward ); - nSearchScript = pBreakIt->GetRealScriptOfText( rSearchOpt.searchString, 0 ); - } + if (!bSrchForward) + { + xub_StrLen swap = nEnde; + nEnde = nStart; + nStart = swap; + } - xub_StrLen nStringEnd = nEnde; - while ( bSrchForward && nStart < nStringEnd || - ! bSrchForward && nStart > nStringEnd ) - { - // SearchAlgorithms_APPROXIMATE works on a per word base - // so we have to provide the text searcher with the correct - // locale, because it uses the breakiterator - if ( pScriptIter ) + for (xub_StrLen i = 0; i <pHts->Count();i++) { - nEnde = pScriptIter->GetScriptChgPos(); - nCurrScript = pScriptIter->GetCurrScript(); - if ( nSearchScript == nCurrScript ) + xub_StrLen aPos = *(*pHts)[i]->GetStart(); + const SwTxtAttr* pTxtAttr = (*pHts)[i]; + if ( (pTxtAttr->Which()==RES_TXTATR_FIELD) && + (pTxtAttr->GetFld().GetFld()->Which()==RES_POSTITFLD)) { - const LanguageType eCurrLang = - ((SwTxtNode*)pNode)->GetLang( bSrchForward ? - nStart : - nEnde ); - - if ( eCurrLang != eLastLang ) + if ( (aPos >= nStart) && (aPos <= nEnde) ) + aNumberPostits++; + else { - const lang::Locale aLocale( - pBreakIt->GetLocale( eCurrLang ) ); - rSTxt.SetLocale( rSearchOpt, aLocale ); - eLastLang = eCurrLang; + if (bSrchForward) + aIgnore++; } } - pScriptIter->Next(); } - if( nSearchScript == nCurrScript && - (rSTxt.*fnMove->fnSearch)( sCleanStr, &nStart, &nEnde, 0 )) + if (!bSrchForward) { - // setze den Bereich richtig - *GetPoint() = *pPam->GetPoint(); - SetMark(); + xub_StrLen swap = nEnde; + nEnde = nStart; + nStart = swap; + } + + } - // Start und Ende wieder korrigieren !! - if( aFltArr.Count() ) + xub_StrLen aStart = 0; + // do we need to finish a note? + if (POSTITMGR->GetActivePostIt()) + { + if (bSearchInNotes) + { + if (bSrchForward) + aStart++; + else { - xub_StrLen n, nNew; - // bei Rueckwaertssuche die Positionen temp. vertauschen - if( !bSrchForward ) { n = nStart; nStart = nEnde; nEnde = n; } - - for( n = 0, nNew = nStart; - n < aFltArr.Count() && aFltArr[ n ] <= nStart; - ++n, ++nNew ) - ; - nStart = nNew; - for( n = 0, nNew = nEnde; - n < aFltArr.Count() && aFltArr[ n ] < nEnde; - ++n, ++nNew ) - ; - nEnde = nNew; - - // bei Rueckwaertssuche die Positionen temp. vertauschen - if( !bSrchForward ) { n = nStart; nStart = nEnde; nEnde = n; } + if (aNumberPostits) + --aNumberPostits; } - GetMark()->nContent = nStart; // Startposition setzen - GetPoint()->nContent = nEnde; + //search inside and finsih and put focus back into the doc + if (POSTITMGR->FinishSearchReplace(rSearchOpt,bSrchForward)) + { + bFound = true ; + break; + } + } + else + { + POSTITMGR->SetActivePostIt(0); + } + } - if( !bSrchForward ) // rueckwaerts Suche? - Exchange(); // Point und Mark tauschen - bFound = TRUE; - break; + if (aNumberPostits) + { + // now we have to split + xub_StrLen nStartInside = 0; + xub_StrLen nEndeInside = 0; + sal_Int16 aLoop= bSrchForward ? aStart : aNumberPostits; + + while ( (aLoop>=0) && (aLoop<=aNumberPostits)) + { + if (bSrchForward) + { + nStartInside = aLoop==0 ? nStart : *(*pHts)[GetPostIt(aLoop+aIgnore-1,pHts)]->GetStart()+1; + nEndeInside = aLoop==aNumberPostits? nEnde : *(*pHts)[GetPostIt(aLoop+aIgnore,pHts)]->GetStart(); + nTxtLen = nEndeInside-nStartInside; + } + else + { + nStartInside = aLoop==aNumberPostits ? nStart : *(*pHts)[GetPostIt(aLoop+aIgnore,pHts)]->GetStart(); + nEndeInside = aLoop==0 ? nEnde : *(*pHts)[GetPostIt(aLoop+aIgnore-1,pHts)]->GetStart()+1; + nTxtLen = nStartInside-nEndeInside; + } + // search inside the text between a note + bFound = DoSearch(rSearchOpt,rSTxt,fnMove,bSrchForward,bRegSearch,bChkEmptyPara,bChkParaEnd, + nStartInside,nEndeInside,nTxtLen, pNode,pPam); + if (bFound) + break; + else + { + // we should now be right in front of a note, search inside + if ( (bSrchForward && (GetPostIt(aLoop + aIgnore,pHts) < pHts->Count()) ) || ( !bSrchForward && (aLoop!=0) )) + { + const SwTxtAttr* pTxtAttr = bSrchForward ? (*pHts)[GetPostIt(aLoop+aIgnore,pHts)] : (*pHts)[GetPostIt(aLoop+aIgnore-1,pHts)]; + if ( POSTITMGR->SearchReplace(((SwTxtFld*)pTxtAttr)->GetFld(),rSearchOpt,bSrchForward) ) + { + bFound = true ; + break; + } + } + } + aLoop = bSrchForward ? aLoop+1 : aLoop-1; } + } + else + { + // if there is no SwPostItField inside or searching inside notes is disabled, we search the whole length just like before + bFound = DoSearch(rSearchOpt,rSTxt,fnMove,bSrchForward,bRegSearch,bChkEmptyPara,bChkParaEnd, + nStart,nEnde,nTxtLen, pNode,pPam); + } + if (bFound) + break; + } + } + delete pPam; + return bFound; +} - nStart = nEnde; - } // end of script while +bool SwPaM::DoSearch( const SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, + SwMoveFn fnMove, + BOOL bSrchForward, BOOL bRegSearch, BOOL bChkEmptyPara, BOOL bChkParaEnd, + xub_StrLen &nStart, xub_StrLen &nEnde, xub_StrLen nTxtLen,SwNode* pNode, SwPaM* pPam) +{ + bool bFound = false; + SwNodeIndex& rNdIdx = pPam->GetPoint()->nNode; + const SwNode* pSttNd = &rNdIdx.GetNode(); + String sCleanStr; + SvULongs aFltArr; + LanguageType eLastLang = 0; + // if the search string contains a soft hypen, we don't strip them from the text: + bool bRemoveSoftHyphens = true; + if ( bRegSearch ) + { + const rtl::OUString a00AD( rtl::OUString::createFromAscii( "\\x00AD" ) ); + if ( -1 != rSearchOpt.searchString.indexOf( a00AD ) ) + bRemoveSoftHyphens = false; + } + else + { + if ( 1 == rSearchOpt.searchString.getLength() && + CHAR_SOFTHYPHEN == rSearchOpt.searchString.toChar() ) + bRemoveSoftHyphens = false; + } - delete pScriptIter; + if( bSrchForward ) + lcl_CleanStr( *(SwTxtNode*)pNode, nStart, nEnde, + aFltArr, sCleanStr, bRemoveSoftHyphens ); + else + lcl_CleanStr( *(SwTxtNode*)pNode, nEnde, nStart, + aFltArr, sCleanStr, bRemoveSoftHyphens ); - if ( bFound ) - break; - else if( ( bChkEmptyPara && !nStart && !nTxtLen ) || bChkParaEnd ) + SwScriptIterator* pScriptIter = 0; + USHORT nSearchScript = 0; + USHORT nCurrScript = 0; + + if ( SearchAlgorithms_APPROXIMATE == rSearchOpt.algorithmType && + pBreakIt->xBreak.is() ) + { + pScriptIter = new SwScriptIterator( sCleanStr, nStart, bSrchForward ); + nSearchScript = pBreakIt->GetRealScriptOfText( rSearchOpt.searchString, 0 ); + } + + xub_StrLen nStringEnd = nEnde; + while ( bSrchForward && nStart < nStringEnd || + ! bSrchForward && nStart > nStringEnd ) + { + // SearchAlgorithms_APPROXIMATE works on a per word base + // so we have to provide the text searcher with the correct + // locale, because it uses the breakiterator + if ( pScriptIter ) + { + nEnde = pScriptIter->GetScriptChgPos(); + nCurrScript = pScriptIter->GetCurrScript(); + if ( nSearchScript == nCurrScript ) { - *GetPoint() = *pPam->GetPoint(); - GetPoint()->nContent = bChkParaEnd ? nTxtLen : 0; - SetMark(); - if( (bSrchForward || pSttNd != &rNdIdx.GetNode()) && - Move( fnMoveForward, fnGoCntnt ) && - (!bSrchForward || pSttNd != &GetPoint()->nNode.GetNode()) && - 1 == Abs( (int)( GetPoint()->nNode.GetIndex() - - GetMark()->nNode.GetIndex()) ) ) + const LanguageType eCurrLang = + ((SwTxtNode*)pNode)->GetLang( bSrchForward ? + nStart : + nEnde ); + + if ( eCurrLang != eLastLang ) { - if( !bSrchForward ) // rueckwaerts Suche? - Exchange(); // Point und Mark tauschen - bFound = TRUE; - break; + const lang::Locale aLocale( + pBreakIt->GetLocale( eCurrLang ) ); + rSTxt.SetLocale( rSearchOpt, aLocale ); + eLastLang = eCurrLang; } } + pScriptIter->Next(); + } + + if( nSearchScript == nCurrScript && + (rSTxt.*fnMove->fnSearch)( sCleanStr, &nStart, &nEnde, 0 )) + { + // setze den Bereich richtig + *GetPoint() = *pPam->GetPoint(); + SetMark(); + + // Start und Ende wieder korrigieren !! + if( aFltArr.Count() ) + { + xub_StrLen n, nNew; + // bei Rueckwaertssuche die Positionen temp. vertauschen + if( !bSrchForward ) { n = nStart; nStart = nEnde; nEnde = n; } + + for( n = 0, nNew = nStart; + n < aFltArr.Count() && aFltArr[ n ] <= nStart; + ++n, ++nNew ) + ; + nStart = nNew; + for( n = 0, nNew = nEnde; + n < aFltArr.Count() && aFltArr[ n ] < nEnde; + ++n, ++nNew ) + ; + nEnde = nNew; + + // bei Rueckwaertssuche die Positionen temp. vertauschen + if( !bSrchForward ) { n = nStart; nStart = nEnde; nEnde = n; } + } + GetMark()->nContent = nStart; // Startposition setzen + GetPoint()->nContent = nEnde; + + if( !bSrchForward ) // rueckwaerts Suche? + Exchange(); // Point und Mark tauschen + bFound = TRUE; + break; + } + + nStart = nEnde; + } // end of script while + + delete pScriptIter; + + if ( bFound ) + return true; + else if( ( bChkEmptyPara && !nStart && !nTxtLen ) || bChkParaEnd ) + { + *GetPoint() = *pPam->GetPoint(); + GetPoint()->nContent = bChkParaEnd ? nTxtLen : 0; + SetMark(); + if( (bSrchForward || pSttNd != &rNdIdx.GetNode()) && + Move( fnMoveForward, fnGoCntnt ) && + (!bSrchForward || pSttNd != &GetPoint()->nNode.GetNode()) && + 1 == Abs( (int)( GetPoint()->nNode.GetIndex() - + GetMark()->nNode.GetIndex()) ) ) + { + if( !bSrchForward ) // rueckwaerts Suche? + Exchange(); // Point und Mark tauschen + //bFound = TRUE; + //break; + return true; } } - delete pPam; return bFound; } - // Parameter fuers Suchen und Ersetzen von Text struct SwFindParaText : public SwFindParas { @@ -391,9 +563,10 @@ struct SwFindParaText : public SwFindParas SwCursor& rCursor; utl::TextSearch aSTxt; BOOL bReplace; + BOOL bSearchInNotes; - SwFindParaText( const SearchOptions& rOpt, int bRepl, SwCursor& rCrsr ) - : rSearchOpt( rOpt ), rCursor( rCrsr ), aSTxt( rOpt ), bReplace( 0 != bRepl ) + SwFindParaText( const SearchOptions& rOpt, BOOL bSearchNotes, int bRepl, SwCursor& rCrsr ) + : rSearchOpt( rOpt ), rCursor( rCrsr ), aSTxt( rOpt ), bReplace( 0 != bRepl ), bSearchInNotes( bSearchNotes ) {} virtual int Find( SwPaM* , SwMoveFn , const SwPaM*, BOOL bInReadOnly ); virtual int IsReplaceMode() const; @@ -410,10 +583,12 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, if( bInReadOnly && bReplace ) bInReadOnly = FALSE; - BOOL bFnd = (BOOL)pCrsr->Find( rSearchOpt, aSTxt, fnMove, pRegion, bInReadOnly ); - // kein Bereich ?? + BOOL bFnd = (BOOL)pCrsr->Find( rSearchOpt, bSearchInNotes, aSTxt, fnMove, pRegion, bInReadOnly ); + + /* #i80135# if we found something in a note, Mark and Point is the same if( bFnd && *pCrsr->GetMark() == *pCrsr->GetPoint() ) return FIND_NOT_FOUND; + */ if( bFnd && bReplace ) // String ersetzen ?? { @@ -461,7 +636,7 @@ int SwFindParaText::IsReplaceMode() const } -ULONG SwCursor::Find( const SearchOptions& rSearchOpt, +ULONG SwCursor::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes, SwDocPositions nStart, SwDocPositions nEnde, BOOL& bCancel, FindRanges eFndRngs, int bReplace ) @@ -478,7 +653,7 @@ ULONG SwCursor::Find( const SearchOptions& rSearchOpt, BOOL bSearchSel = 0 != (rSearchOpt.searchFlag & SearchFlags::REG_NOT_BEGINOFLINE); if( bSearchSel ) eFndRngs = (FindRanges)(eFndRngs | FND_IN_SEL); - SwFindParaText aSwFindParaText( rSearchOpt, bReplace, *this ); + SwFindParaText aSwFindParaText( rSearchOpt, bSearchInNotes, bReplace, *this ); ULONG nRet = FindAll( aSwFindParaText, nStart, nEnde, eFndRngs, bCancel ); pDoc->SetOle2Link( aLnk ); if( nRet && bReplace ) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 4daadd9bea38..c13389034149 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -296,6 +296,7 @@ SwDoc::SwDoc() : mbClipBoard( false ), mbColumnSelection( false ), // i#78591# + mbProtectForm(false), n32DummyCompatabilityOptions1(0), n32DummyCompatabilityOptions2(0), mbStartIdleTimer(sal_False) diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 2a3914e4d28a..cfe83500bed1 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -57,6 +57,8 @@ using namespace com::sun::star; +TYPEINIT1(SwRedlineHint, SfxHint); + #ifdef PRODUCT #define _CHECK_REDLINE( pDoc ) diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 8b18f5c941ab..01c9b6f6cb76 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -444,7 +444,10 @@ void SwEditShell::ApplyAutoMark() KillPams(); BOOL bCancel; - ULONG nRet = Find( aSearchOpt, DOCPOS_START, DOCPOS_END, bCancel, + + // todo/mba: assuming that notes shouldn't be searched + BOOL bSearchInNotes = FALSE; + ULONG nRet = Find( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END, bCancel, (FindRanges)(FND_IN_SELALL|FND_IN_BODYONLY), FALSE ); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index fcaea66cde39..ff7e6e2eb84b 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -1861,7 +1861,7 @@ void SwPostItField::SetPar2(const String& rStr) ---------------------------------------------------------------------------*/ String SwPostItField::GetPar2() const { - return sTxt; + return sTxt; } const OutlinerParaObject* SwPostItField::GetTextObject() const diff --git a/sw/source/core/fields/postithelper.cxx b/sw/source/core/fields/postithelper.cxx index eed2f1bdf876..dda7cec0e439 100644 --- a/sw/source/core/fields/postithelper.cxx +++ b/sw/source/core/fields/postithelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: postithelper.cxx,v $ - * $Revision: 1.2 $ + * $Revision: 1.2.118.3 $ * * This file is part of OpenOffice.org. * @@ -32,10 +32,13 @@ #include "precompiled_sw.hxx" #include <tools/gen.hxx> + #include <postithelper.hxx> #include <PostItMgr.hxx> +#include <postit.hxx> #include <fmtfld.hxx> #include <txtfld.hxx> +#include <docufld.hxx> #include <ndtxt.hxx> #include <cntfrm.hxx> #include <pagefrm.hxx> @@ -43,12 +46,15 @@ #include <txtfrm.hxx> #include <IDocumentRedlineAccess.hxx> #include <redline.hxx> +#include <scriptinfo.hxx> +#include <svx/charhiddenitem.hxx> SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLayoutInfo >& rInfo, SwPosition& rPos ) { SwLayoutStatus aRet = INVISIBLE; - SwCntntNode* pNode = rPos.nNode.GetNode().GetCntntNode(); + const SwTxtNode* pTxtNode = rPos.nNode.GetNode().GetTxtNode(); + SwCntntNode* pNode = rPos.nNode.GetNode().GetCntntNode(); // getfirstcontentnode // getnext... if( !pNode ) return aRet; SwClientIter aIter( *pNode ); @@ -68,6 +74,7 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa aInfo.mPagePrtArea.Pos() += aInfo.mPageFrame.Pos(); aInfo.mnPageNumber = pPage->GetPhyPageNum(); aInfo.mbMarginSide = pPage->MarginSide(); + aInfo.mRedlineAuthor = 0; if( aRet == INVISIBLE ) { @@ -86,12 +93,11 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa } } } - rInfo.push_back( aInfo ); } } } - return aRet; + return ((aRet==VISIBLE) && SwScriptInfo::IsInHiddenRange( *pTxtNode , rPos.nContent.GetIndex()) ) ? HIDDEN : aRet; } long SwPostItHelper::getLayoutHeight( const SwRootFrm* pRoot ) @@ -138,4 +144,44 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa return aRet; } +SwPosition SwPostItItem::GetPosition() +{ + SwTxtFld* pFld = pFmtFld->GetTxtFld(); + //if( pFld ) + //{ + SwTxtNode* pTNd = pFld->GetpTxtNode(); + // if( pTNd ) + // { + SwPosition aPos( *pTNd ); + aPos.nContent.Assign( pTNd, *pFld->GetStart() ); + return aPos; + // } + //} +} + +bool SwPostItItem::UseElement() +{ + return pFmtFld->IsFldInDoc(); +} + +SwMarginWin* SwPostItItem::GetMarginWindow(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits) +{ + return new SwPostIt(pParent,nBits,pFmtFld,aMgr,aBits); +} + +/* +SwPosition SwRedCommentItem::GetPosition() +{ + return *pRedline->Start(); +} +SwMarginWin* SwRedCommentItem::GetMarginWindow(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits) +{ + return new SwRedComment(pParent,nBits,aMgr,aBits,pRedline); +} + +bool SwRedCommentItem::UseElement() +{ + return true; +} +*/ diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 443c83b9d231..14ac562f64d9 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: atrfld.cxx,v $ - * $Revision: 1.16 $ + * $Revision: 1.16.190.1 $ * * This file is part of OpenOffice.org. * @@ -48,7 +48,7 @@ #include <svtools/smplhint.hxx> -TYPEINIT2( SwFmtFld, SfxPoolItem, SwClient ) +TYPEINIT3( SwFmtFld, SfxPoolItem, SwClient,SfxBroadcaster) TYPEINIT1(SwFmtFldHint, SfxHint); /**************************************************************************** diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index b7220db53f9e..a49e37ba706e 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: undobj.cxx,v $ - * $Revision: 1.29 $ + * $Revision: 1.29.52.1 $ * * This file is part of OpenOffice.org. * @@ -53,6 +53,7 @@ #ifndef _COMCORE_HRC #include <comcore.hrc> #endif +#include <docsh.hxx> class SwRedlineSaveData : public SwUndRng, public SwRedlineData, private SwUndoSaveSection @@ -1099,6 +1100,10 @@ void SwRedlineSaveData::RedlineToDoc( SwPaM& rPam ) RedlineMode_t eOld = rDoc.GetRedlineMode(); rDoc.SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_DONTCOMBINE_REDLINES)); + //#i92154# let UI know about a new redline with comment + if (rDoc.GetDocShell() && (pRedl->GetComment() != String(::rtl::OUString::createFromAscii(""))) ) + rDoc.GetDocShell()->Broadcast(SwRedlineHint(pRedl,SWREDLINE_INSERTED)); + // rDoc.AppendRedline( pRedl, true ); rDoc.SetRedlineMode_intern( eOld ); } diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 8d8efd2df452..057684f49b9c 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ww8graf.cxx,v $ - * $Revision: 1.154 $ + * $Revision: 1.154.30.1 $ * * This file is part of OpenOffice.org. * @@ -952,6 +952,7 @@ OutlinerParaObject* SwWW8ImplReader::ImportAsOutliner(String &rString, WW8_CP nS } pRet = new OutlinerParaObject(*mpDrawEditEngine->CreateTextObject()); + pRet->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT ); mpDrawEditEngine->SetText( aEmptyStr ); mpDrawEditEngine->SetParaAttribs(0, mpDrawEditEngine->GetEmptyItemSet()); diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index ef32005bb175..659ef01562d1 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docsh.cxx,v $ - * $Revision: 1.79 $ + * $Revision: 1.79.188.1 $ * * This file is part of OpenOffice.org. * @@ -85,6 +85,8 @@ #include <view.hxx> // fuer die aktuelle Sicht #endif #include <edtwin.hxx> +#include <PostItMgr.hxx> +#include <postit.hxx> #include <wrtsh.hxx> // Verbindung zur Core #ifndef _DOCSH_HXX #include <docsh.hxx> // Dokumenterzeugung @@ -465,6 +467,10 @@ sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) if(pView) pView->GetEditWin().StopQuickHelp(); + //#i91811# mod if we have an active margin window, write back the text + if (pView && pView->GetPostItMgr() && pView->GetPostItMgr()->GetActivePostIt()) + pView->GetPostItMgr()->GetActivePostIt()->UpdateData(); + if( pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) && !pDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS) ) RemoveOLEObjects(); @@ -618,6 +624,11 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) //#i3370# remove quick help to prevent saving of autocorrection suggestions if(pView) pView->GetEditWin().StopQuickHelp(); + + //#i91811# mod if we have an active margin window, write back the text + if (pView && pView->GetPostItMgr() && pView->GetPostItMgr()->GetActivePostIt()) + pView->GetPostItMgr()->GetActivePostIt()->UpdateData(); + ULONG nVBWarning = 0; if( pDoc->ContainsMSVBasic() ) diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index 7ec9815d8356..e13d2418cc58 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: mn.src,v $ - * $Revision: 1.53 $ + * $Revision: 1.53.118.1 $ * * This file is part of OpenOffice.org. * @@ -432,6 +432,13 @@ #define MN_ANNOTATIONS \ MenuItem\ {\ + Identifier = FN_REPLY ;\ + HelpID = FN_DELETE_NOTE ;\ + Text [ en-US ] = "Reply" ;\ + };\ + SEPARATOR ; \ + MenuItem\ + {\ Identifier = FN_DELETE_NOTE ;\ HelpID = FN_DELETE_NOTE ;\ Text [ en-US ] = "Delete ~Note" ;\ @@ -805,6 +812,14 @@ Menu MN_DRWTXT_POPUPMENU }; }; +#define MN_REDCOMMENT \ + MenuItem\ + {\ + Identifier = FN_DELETE_COMMENT ;\ + HelpID = FN_DELETE_COMMENT ;\ + Text [ en-US ] = "Delete ~Changes Note" ;\ + };\ + Menu MN_ANNOTATION_POPUPMENU { ItemList = @@ -835,6 +850,7 @@ Menu MN_ANNOTATION_POPUPMENU //MN_FRM_CAPTION_ITEM SEPARATOR ; MN_ANNOTATIONS + //MN_REDCOMMENT }; }; @@ -846,6 +862,13 @@ Menu MN_ANNOTATION_BUTTON }; }; +Menu MN_REDCOMMENT_BUTTON +{ + ItemList = + { + MN_REDCOMMENT + }; +}; String MN_GRF_POPUPMENU { diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 617d5519ad99..edabcf30f1f1 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -8,7 +8,7 @@ * * $RCSfile: PostItMgr.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.12.34.10 $ * * This file is part of OpenOffice.org. * @@ -35,12 +35,10 @@ #include "PostItMgr.hxx" #include <postithelper.hxx> -#include <svtools/smplhint.hxx> - #include <vcl/svapp.hxx> #include <vcl/scrbar.hxx> +#include <vcl/outdev.hxx> -#include <swmodule.hxx> #include <viewopt.hxx> #include <view.hxx> @@ -54,6 +52,8 @@ #include <postit.hxx> #include <txtfld.hxx> #include <ndtxt.hxx> +#include <redline.hxx> +#include <docary.hxx> #include <SwRewriter.hxx> #include <undobj.hxx> #include <tools/color.hxx> @@ -65,24 +65,22 @@ #include <undobj.hxx> #include <sfx2/request.hxx> - #include <sfx2/event.hxx> +#include <sfx2/srchitem.hxx> + #include <svtools/languageoptions.hxx> #include <svtools/langtab.hxx> +#include <svtools/smplhint.hxx> #include <svx/eeitem.hxx> #include <svx/langitem.hxx> -#include <svx/srchitem.hxx> #include <svx/outliner.hxx> -#include <vcl/outdev.hxx> - #include <i18npool/mslangid.hxx> #include <i18npool/lang.h> #include "swevent.hxx" -#include <sfx2/event.hxx> // distance between ankor Y and initial note position #define POSTIT_INITIAL_ANKOR_DISTANCE 20 @@ -94,6 +92,7 @@ // if we layout more often we stop, this should never happen #define MAX_LOOP_COUNT 50 +/* bool comp_author( const SwPostItItem* a, const SwPostItItem* b) { return a->pFmtFld->GetFld()->GetPar1() < b->pFmtFld->GetFld()->GetPar1(); @@ -103,25 +102,19 @@ bool comp_date( const SwPostItItem* a, const SwPostItItem* b) { return static_cast<SwPostItField*>(a->pFmtFld->GetFld())->GetDate() < static_cast<SwPostItField*>(b->pFmtFld->GetFld())->GetDate(); } +*/ -bool comp_pos(const SwPostItItem *a, const SwPostItItem *b) -{ - // if notes are on the same line, sort by x position, otherwise by y position - return (a->mPos.Bottom() == b->mPos.Bottom()) ? a->mPos.Left() < b->mPos.Left() : a->mPos.Bottom() < b->mPos.Bottom(); -} - -/* -bool comp_id(const SwPostItItem *a, const SwPostItItem *b) +// if position is on the same line, sort by x (Left) position, otherwise by y(Bottom) position +// if two notes are at the same position, sort by logical node position +bool comp_pos(const SwMarginItem *a, const SwMarginItem *b) { - #define TXTFLD pFmtFld->GetTxtFld() - if (a->TXTFLD->GetTxtNode().FindFlyStartNode() || b->TXTFLD->GetTxtNode().FindFlyStartNode() || - a->TXTFLD->GetTxtNode().FindHeaderStartNode() || a->TXTFLD->GetTxtNode().FindFooterStartNode() || - b->TXTFLD->GetTxtNode().FindHeaderStartNode() || b->TXTFLD->GetTxtNode().FindFooterStartNode()) - return (a->mPos.Bottom() == b->mPos.Bottom()) ? a->mPos.Left() < b->mPos.Left() : a->mPos.Bottom() < b->mPos.Bottom(); - else - return ((*a->TXTFLD->GetPosition()) < (*b->TXTFLD->GetPosition())); + return (a->mPos.Bottom() == b->mPos.Bottom()) ? + ( ((a->mPos.Left() == b->mPos.Left()) && (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) ? + *(static_cast<SwFmtFld*>(a->GetBroadCaster())->GetTxtFld()->GetStart()) < + *(static_cast<SwFmtFld*>(b->GetBroadCaster())->GetTxtFld()->GetStart()) + : a->mPos.Left() < b->mPos.Left() ) + : a->mPos.Bottom() < b->mPos.Bottom(); } -*/ SwPostItMgr::SwPostItMgr(SwView* pView) : mpView(pView) @@ -135,12 +128,18 @@ SwPostItMgr::SwPostItMgr(SwView* pView) , mbLayouting(false) , mbReadOnly(mpView->GetDocShell()->IsReadOnly()) , mbDeleteNote(true) + , mpAnswer(0) { if(!mpView->GetDrawView() ) mpView->GetWrtShell().MakeDrawView(); - // collect all PostIts that exist after loading the document + + // collect all PostIts and redline comments that exist after loading the document // don't check for existance for any of them, don't focus them AddPostIts(false,false); + /* this code can be used once we want redline comments in the margin + AddRedlineComments(false,false); + */ + // we want to receive stuff like SFX_HINT_DOCCHANGED StartListening(*mpView->GetDocShell()); if (!mvPostItFlds.empty() && ShowNotes()) { @@ -153,8 +152,8 @@ SwPostItMgr::~SwPostItMgr() { if ( mnEventId ) Application::RemoveUserEvent( mnEventId ); - // forget about all PostItFields - RemovePostIts(); + // forget about all our margin windows + RemoveMarginWin(); EndListening( *mpView->GetDocShell() ); for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i!= mPages.end() ; i++) @@ -165,12 +164,12 @@ SwPostItMgr::~SwPostItMgr() void SwPostItMgr::CheckForRemovedPostIts() { bool bRemoved = false; - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); ) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); ) { - std::list<SwPostItItem*>::iterator it = i++; - if ( !(*it)->pFmtFld->IsFldInDoc() ) + std::list<SwMarginItem*>::iterator it = i++; + if ( !(*it)->UseElement() ) { - SwPostItItem* p = (*it); + SwMarginItem* p = (*it); mvPostItFlds.remove(*it); if (p->pPostIt) delete p->pPostIt; @@ -195,38 +194,46 @@ void SwPostItMgr::CheckForRemovedPostIts() } } -void SwPostItMgr::InsertFld(SwFmtFld* aField, bool bCheckExistance, bool bFocus) +void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus) { if (bCheckExistance) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld == aField ) + if ( (*i)->GetBroadCaster() == pItem ) return; } } mbLayout = bFocus; - mvPostItFlds.push_back(new SwPostItItem(aField, true, bFocus) ); - // listen for removal of field - StartListening( *aField ); + if (pItem->ISA(SwFmtFld)) + mvPostItFlds.push_back(new SwPostItItem(static_cast<SwFmtFld*>(pItem), true, bFocus) ); + /* + else + if (pItem->ISA(SwRedline)) + mvPostItFlds.push_back(new SwRedCommentItem( static_cast<SwRedline*>(pItem), true, bFocus)) ; + */ + DBG_ASSERT(pItem->ISA(SwFmtFld) /*|| pItem->ISA(SwRedline)*/,"Mgr::InsertItem: seems like new stuff was added"); + StartListening(*pItem); } -void SwPostItMgr::RemoveFld( SfxBroadcaster* pFld ) +void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + EndListening(*pBroadcast); + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld == pFld ) + if ( (*i)->GetBroadCaster() == pBroadcast ) { - SwPostItItem* p = (*i); - mvPostItFlds.remove(*i); + SwMarginItem* p = (*i); if (GetActivePostIt() == p->pPostIt) SetActivePostIt(0); + mvPostItFlds.remove(*i); delete p->pPostIt; delete p; break; } } mbLayout = true; + PrepareView(); } void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) @@ -282,13 +289,39 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { // field to be removed is the broadcaster DBG_ERROR("Notification for removed SwFmtFld was not sent!"); - RemoveFld(&rBC); - PrepareView(); + RemoveItem(&rBC); } break; } } } + /* + else if ( rHint.IsA(TYPE(SwRedlineHint) ) ) + { + SwRedline* pRedline = const_cast<SwRedline*>(((SwRedlineHint&)rHint).GetRedline()); + switch ( ((SwRedlineHint&)rHint).Which() ) + { + case SWREDLINE_INSERTED : + { + bool bEmpty = !HasNotes(); + InsertItem( pRedline, true, false ); + if (bEmpty && !mvPostItFlds.empty()) + PrepareView(true); + break; + } + case SWREDLINE_REMOVED: + { + RemoveItem(pRedline); + break; + } + case SWREDLINE_FOCUS: + { + Focus(rBC); + break; + } + } + } + */ else if ( rHint.IsA(TYPE(SwFmtFldHint) ) ) { SwFmtFld* pFld = const_cast <SwFmtFld*>( ((SwFmtFldHint&)rHint).GetField() ); @@ -301,12 +334,11 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) AddPostIts(true); break; } - // get field to be inserted from hint if ( pFld->IsFldInDoc() ) { - bool bEmpty = mvPostItFlds.empty(); - InsertFld( pFld, true, false ); + bool bEmpty = !HasNotes(); + InsertItem( pFld, true, false ); if (bEmpty && !mvPostItFlds.empty()) PrepareView(true); } @@ -324,47 +356,21 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) CheckForRemovedPostIts(); break; } - - // get field to be removed from hint - EndListening( *pFld ); - RemoveFld(pFld); - PrepareView(); + RemoveItem(pFld); } break; } case SWFMTFLD_FOCUS: { - if (!mpWrtShell->GetViewOptions()->IsPostIts()) - { - SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES); - mpView->ExecViewOptions(aRequest); - } - // field to get the focus is the broadcaster, SwFmtFld in Hint may be NULL - SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - { - if ( pFmtFld == (*i)->pFmtFld ) - { - if ((*i)->pPostIt) - { - (*i)->pPostIt->GrabFocus(); - MakeVisible((*i)->pPostIt); - } - else - { - // when the layout algorithm starts, this postit is created and receives focus - (*i)->bFocus = true; - } - } - } + Focus(rBC); break; } case SWFMTFLD_CHANGED: { SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->pFmtFld ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) (*i)->pPostIt->SetPostItText(); @@ -376,13 +382,13 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) case SWFMTFLD_LANGUAGE: { SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->pFmtFld ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) { - USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( (*i)->pFmtFld->GetFld()->GetLanguage() ); + USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( (*i)->GetFmtFld()->GetFld()->GetLanguage() ); USHORT nLangWhichId = 0; switch (nScriptType) { @@ -390,7 +396,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; } - (*i)->pPostIt->SetLanguage(SvxLanguageItem((*i)->pFmtFld->GetFld()->GetLanguage(),nLangWhichId)); + (*i)->pPostIt->SetLanguage(SvxLanguageItem((*i)->GetFmtFld()->GetFld()->GetLanguage(),nLangWhichId)); } break; } @@ -401,6 +407,33 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } } +void SwPostItMgr::Focus(SfxBroadcaster& rBC) +{ + if (!mpWrtShell->GetViewOptions()->IsPostIts()) + { + SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES); + mpView->ExecViewOptions(aRequest); + } + + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + { + // field to get the focus is the broadcaster + if ( &rBC == (*i)->GetBroadCaster() ) + { + if ((*i)->pPostIt) + { + (*i)->pPostIt->GrabFocus(); + MakeVisible((*i)->pPostIt); + } + else + { + // when the layout algorithm starts, this postit is created and receives focus + (*i)->bFocus = true; + } + } + } +} + bool SwPostItMgr::CalcRects() { if (!ShowNotes()) @@ -419,12 +452,12 @@ bool SwPostItMgr::CalcRects() PreparePageContainer(); if ( !mvPostItFlds.empty() ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItItem* pItem = (*i); - if ( !pItem->pFmtFld->IsFldInDoc() ) + SwMarginItem* pItem = (*i); + if ( !pItem->UseElement() ) { - DBG_ERROR("PostIt is not in doc!"); + DBG_ERROR("PostIt is not in doc or other wrong use"); bRepair = true; continue; } @@ -432,12 +465,12 @@ bool SwPostItMgr::CalcRects() //save old rect and visible state SwRect aOldRect(pItem->mPos); SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus; - if( pItem->pFmtFld ) + std::vector< SwLayoutInfo > aInfo; + //pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, pItem->pFmtFld->GetTxtFld() ); + SwPosition aPosition = pItem->GetPosition(); + pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); + if( aInfo.size() ) { - std::vector< SwLayoutInfo > aInfo; - pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, pItem->pFmtFld->GetTxtFld() ); - if( aInfo.size() ) - { SwLayoutInfo& rInfo = aInfo[0]; pItem->mPos = rInfo.mPosition; pItem->mPagePos = rInfo.mPageFrame; @@ -445,7 +478,6 @@ bool SwPostItMgr::CalcRects() pItem->bMarginSide = rInfo.mbMarginSide; pItem->mnPageNumber = rInfo.mnPageNumber; pItem->mRedlineAuthor = rInfo.mRedlineAuthor; - } } bChange = bChange || (pItem->mPos != aOldRect) || (eOldStatus != pItem->mLayoutStatus); } @@ -455,11 +487,25 @@ bool SwPostItMgr::CalcRects() Sort(SORT_POS); // sort the items into the right page vector, so layout can be done by page - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItItem* pItem = (*i); + SwMarginItem* pItem = (*i); if( SwPostItHelper::INVISIBLE == pItem->mLayoutStatus ) + { + if (pItem->pPostIt) + pItem->pPostIt->HideNote(); continue; + } + + if( SwPostItHelper::HIDDEN == pItem->mLayoutStatus ) + { + if (!mpWrtShell->GetViewOptions()->IsShowHiddenChar()) + { + if (pItem->pPostIt) + pItem->pPostIt->HideNote(); + continue; + } + } const unsigned long aPageNum = pItem->mnPageNumber; if (aPageNum > mPages.size()) @@ -499,7 +545,7 @@ bool SwPostItMgr::CalcRects() bool SwPostItMgr::HasScrollbars() const { - for(std::list<SwPostItItem*>::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ((*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->Scrollbar()) return true; @@ -554,16 +600,15 @@ void SwPostItMgr::LayoutPostIts() // only layout if there are notes on this page if (mPages[n]->mList->size()>0) { - std::list<SwPostIt*> aVisiblePostItList; + std::list<SwMarginWin*> aVisiblePostItList; unsigned long lNeededHeight = 0; long mlPageBorder = 0; long mlPageEnd = 0; - for(SwPostItItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { - SwPostItItem* pItem = (*i); - SwFmtFld* pFmtFld = pItem->pFmtFld; - SwPostIt* pPostIt = pItem->pPostIt; + SwMarginItem* pItem = (*i); + SwMarginWin* pPostIt = pItem->pPostIt; if (mPages[n]->bMarginSide) { @@ -586,13 +631,25 @@ void SwPostItMgr::LayoutPostIts() long aPostItHeight = 0; if (!pPostIt) { - pPostIt = new SwPostIt(static_cast<Window*>(&mpView->GetEditWin()),WINDOW_CONTROL,pFmtFld,this,0); + pPostIt = (*i)->GetMarginWindow(static_cast<Window*>(&mpView->GetEditWin()),WINDOW_CONTROL,this,0); + pPostIt->InitControls(); pPostIt->SetReadonly(mbReadOnly); - SetColors(pPostIt,static_cast<SwPostItField*>(pFmtFld->GetFld())); pItem->pPostIt = pPostIt; + if (mpAnswer) + { + if (pPostIt->CalcFollow()) //do we really have another note in front of this one + static_cast<SwPostIt*>(pPostIt)->InitAnswer(mpAnswer); + delete mpAnswer; + mpAnswer = 0; + } + } + + if (pItem->pPostIt->ISA(SwPostIt)) + { + static_cast<SwPostIt*>(pPostIt)->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); } - pPostIt->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); pPostIt->SetMarginSide(mPages[n]->bMarginSide); + pPostIt->SetFollow(pPostIt->CalcFollow()); aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() ? pPostIt->GetMinimumSizeWithoutMeta() : pPostIt->GetPostItTextHeight() ) + pPostIt->GetMetaHeight(); pPostIt->SetPosSizePixelRect( mlPageBorder ,Y-GetInitialAnchorDistance(), GetNoteWidth() ,aPostItHeight,pItem->mPos, mlPageEnd); @@ -604,7 +661,7 @@ void SwPostItMgr::LayoutPostIts() } // only the visible postits are used for the final layout aVisiblePostItList.push_back(pPostIt); - lNeededHeight += aPostItHeight+GetSpaceBetween(); + lNeededHeight += pPostIt->IsFollow() ? aPostItHeight : aPostItHeight+GetSpaceBetween(); } else // we don't want to see it { @@ -636,7 +693,7 @@ void SwPostItMgr::LayoutPostIts() - enlarge all notes till GetNextBorder(), as we resized to average value before */ //lets hide the ones which overlap the page - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { if (mPages[n]->lOffset != 0) (*i)->TranslateTopPosition(mPages[n]->lOffset); @@ -651,7 +708,6 @@ void SwPostItMgr::LayoutPostIts() { if (mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() < (mPages[n]->mPageRect.Top()+aSidebarheight)) { - if (mPages[n]->bMarginSide) (*i)->ShowAnkorOnly(Point(mPages[n]->mPageRect.Left(),mPages[n]->mPageRect.Top())); else @@ -668,7 +724,7 @@ void SwPostItMgr::LayoutPostIts() } } // do some magic so we really see the focused note - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { if ((*i)->HasChildPathFocus()) { @@ -694,10 +750,10 @@ void SwPostItMgr::LayoutPostIts() else { // we do not want to see the notes anymore -> Options-Writer-View-Notes bool bRepair = false; - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItItem* pItem = (*i); - if ( !pItem->pFmtFld->IsFldInDoc() ) + SwMarginItem* pItem = (*i); + if ( !pItem->UseElement() ) { DBG_ERROR("PostIt is not in doc!"); bRepair = true; @@ -730,7 +786,7 @@ bool SwPostItMgr::BorderOverPageBorder(unsigned long aPage) const return false; } - SwPostItItem_iterator aItem = mPages[aPage-1]->mList->end(); + SwMarginItem_iterator aItem = mPages[aPage-1]->mList->end(); --aItem; DBG_ASSERT ((*aItem)->pPostIt,"BorderOverPageBorder: NULL postIt, should never happen"); if ((*aItem)->pPostIt) @@ -753,9 +809,10 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) const bool bOldUp = ArrowEnabled(KEY_PAGEUP,aPage); const bool bOldDown = ArrowEnabled(KEY_PAGEDOWN,aPage); const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height(); - for(SwPostItItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++) { - SwPostIt* pPostIt = (*i)->pPostIt; + SwMarginWin* pPostIt = (*i)->pPostIt; + // if this is an answer, we should take the normal position and not the real, slightly moved position pPostIt->SetVirtualPosSize(pPostIt->GetPosPixel(),pPostIt->GetSizePixel()); pPostIt->TranslateTopPosition(lScroll); @@ -794,7 +851,7 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) } } -void SwPostItMgr::AutoScroll(const SwPostIt* pPostIt,const unsigned long aPage ) +void SwPostItMgr::AutoScroll(const SwMarginWin* pPostIt,const unsigned long aPage ) { // otherwise all notes are visible if (mPages[aPage-1]->bScrollbar) @@ -814,7 +871,7 @@ void SwPostItMgr::AutoScroll(const SwPostIt* pPostIt,const unsigned long aPage ) } } -void SwPostItMgr::MakeVisible(const SwPostIt* pPostIt,long aPage ) +void SwPostItMgr::MakeVisible(const SwMarginWin* pPostIt,long aPage ) { if (aPage == -1) { @@ -823,7 +880,7 @@ void SwPostItMgr::MakeVisible(const SwPostIt* pPostIt,long aPage ) { if (mPages[n]->mList->size()>0) { - for(SwPostItItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->pPostIt==pPostIt) { @@ -872,7 +929,7 @@ Color SwPostItMgr::GetArrowColor(USHORT aDirection,unsigned long aPage) const } } -bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight) +bool SwPostItMgr::LayoutByPage(std::list<SwMarginWin*> &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight) { /*** General layout idea:***/ // - if we have space left, we always move the current one up, @@ -893,44 +950,27 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re bool bScrollbars = false; // do all neccessary resizings - /* if (lVisibleHeight < lNeededHeight) { - // resize the one we showed bigger on purpose and recalculate lNeededHeight - lNeededHeight = 0; - unsigned long aPostItHeight = 0; - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + // ok, now we have to really resize and adding scrollbars + const long lAverageHeight = (lVisibleHeight - aVisiblePostItList.size()*GetSpaceBetween()) / aVisiblePostItList.size(); + if (lAverageHeight<GetMinimumSizeWithMeta()) { - aPostItHeight = ( (*i)->GetTextHeight()==0 ? 30 : (*i)->GetTextHeight() ) + (*i)->GetMetaHeight(); - if ((*i)->GetTextHeight() < (*i)->GetMinimumSizeWithoutMeta()) - (*i)->SetSizePixel(Size((*i)->GetSizePixel().getWidth(), aPostItHeight)); - lNeededHeight += aPostItHeight+POSTIT_SPACE_BETWEEN; + bScrollbars = true; + lTopBorder += GetSidebarScrollerHeight() + 10; + lBottomBorder -= (GetSidebarScrollerHeight() + 10); + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta())); } - // do we still need to resize now? - */ - if (lVisibleHeight < lNeededHeight) + else { - // ok, now we have to really resize and adding scrollbars - const long lAverageHeight = (lVisibleHeight - aVisiblePostItList.size()*GetSpaceBetween()) / aVisiblePostItList.size(); - if (lAverageHeight<GetMinimumSizeWithMeta()) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { - bScrollbars = true; - lTopBorder += GetSidebarScrollerHeight() + 10; - lBottomBorder -= (GetSidebarScrollerHeight() + 10); - - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) - (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta())); - } - else - { - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) - { - if ( (*i)->VirtualSize().getHeight() > lAverageHeight) - (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight)); - } + if ( (*i)->VirtualSize().getHeight() > lAverageHeight) + (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight)); } } - //} + } //start the real layout so nothing overlaps anymore if (aVisiblePostItList.size()>1) @@ -941,9 +981,9 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re loop++; bDone = true; lSpaceUsed = lTopBorder + GetSpaceBetween(); - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { - SwPostIt_iterator aNextPostIt = i; + SwMarginWin_iterator aNextPostIt = i; ++aNextPostIt; if (aNextPostIt !=aVisiblePostItList.end()) @@ -961,19 +1001,28 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re // we have space left, so let's move the current one up if ( ((*i)->VirtualPos().Y()- lTranslatePos - GetSpaceBetween()) > lTopBorder) { - (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween())); + if ((*aNextPostIt)->IsFollow()) + (*i)->TranslateTopPosition(-1*(lTranslatePos+ANKORLINE_WIDTH)); + else + (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween())); } else { long lMoveUp = (*i)->VirtualPos().Y() - lTopBorder; (*i)->TranslateTopPosition(-1* lMoveUp); - (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp); + if ((*aNextPostIt)->IsFollow()) + (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+ANKORLINE_WIDTH) - lMoveUp); + else + (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp); } } else { // no space left, left move the next one down - (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); + if ((*aNextPostIt)->IsFollow()) + (*aNextPostIt)->TranslateTopPosition(lTranslatePos+ANKORLINE_WIDTH); + else + (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); } } else @@ -989,20 +1038,27 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re } } } - lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween(); + if (aNextPostIt !=aVisiblePostItList.end() && (*aNextPostIt)->IsFollow()) + lSpaceUsed += (*i)->VirtualSize().Height() + ANKORLINE_WIDTH; + else + lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween(); } else { //(*i) is the last visible item - SwPostIt_iterator aPrevPostIt = i; + SwMarginWin_iterator aPrevPostIt = i; --aPrevPostIt; - lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() + GetSpaceBetween() ) - (*i)->VirtualPos().Y(); + //lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() + GetSpaceBetween() ) - (*i)->VirtualPos().Y(); + lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() ) - (*i)->VirtualPos().Y(); if (lTranslatePos > 0) { bDone = false; if ( ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()+lTranslatePos) < lBottomBorder) { - (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); + if ( (*i)->IsFollow() ) + (*i)->TranslateTopPosition(lTranslatePos+ANKORLINE_WIDTH); + else + (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); } else { @@ -1032,7 +1088,7 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re else { // only one left, make sure it is not hidden at the top or bottom - SwPostIt_iterator i = aVisiblePostItList.begin(); + SwMarginWin_iterator i = aVisiblePostItList.begin(); lTranslatePos = lTopBorder - (*i)->VirtualPos().Y(); if (lTranslatePos>0) { @@ -1047,6 +1103,22 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re return bScrollbars; } +/* +void SwPostItMgr::AddRedlineComments(bool bCheckExistance, bool bFocus) +{ + bool bEmpty = mvPostItFlds.empty(); + const SwRedlineTbl& aTable = mpView->GetDocShell()->GetDoc()->GetRedlineTbl(); + for( USHORT i = 0; i < aTable.Count(); ++i ) + { + SwRedline* pRedline = const_cast<SwRedline*>((aTable)[i]); + if ( pRedline->GetComment() != String(rtl::OUString::createFromAscii("")) ) + InsertItem(pRedline, bCheckExistance, bFocus); + } + if (bEmpty && !mvPostItFlds.empty()) + PrepareView(true); + } + */ + void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus) { bool bEmpty = mvPostItFlds.empty(); @@ -1059,7 +1131,7 @@ void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus) if ( pSwFmtFld->GetTxtFld()) { if ( pSwFmtFld->IsFldInDoc() ) - InsertFld(pSwFmtFld,bCheckExistance,bFocus); + InsertItem(pSwFmtFld,bCheckExistance,bFocus); } pFirst = aIter++; } @@ -1069,15 +1141,14 @@ void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus) PrepareView(true); } -void SwPostItMgr::RemovePostIts() +void SwPostItMgr::RemoveMarginWin() { if (!mvPostItFlds.empty()) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - EndListening( *((*i)->pFmtFld) ); - SwPostIt* pPostIt = (*i)->pPostIt; - delete pPostIt; + EndListening( *((*i)->GetBroadCaster()) ); + delete (*i)->pPostIt; delete (*i); } mvPostItFlds.clear(); @@ -1087,12 +1158,14 @@ void SwPostItMgr::RemovePostIts() PreparePageContainer(); } -// copy to new vector, otherwise RemoveFld would operate and delete stuff on mvPostItFlds as well -// RemoveFld will clean up the core field and visible postit if neccessary +// copy to new vector, otherwise RemoveItem would operate and delete stuff on mvPostItFlds as well +// RemoveItem will clean up the core field and visible postit if neccessary // we cannot just delete everything as before, as postits could move into change tracking void SwPostItMgr::Delete(String aAuthor) { mpWrtShell->StartAllAction(); + if ( GetActivePostIt() && (GetActivePostIt()->GetAuthor()==aAuthor) ) + SetActivePostIt(0); SwRewriter aRewriter; String aUndoString = SW_RES(STR_DELETE_AUTHOR_NOTES); aUndoString += aAuthor; @@ -1101,11 +1174,10 @@ void SwPostItMgr::Delete(String aAuthor) std::vector<SwFmtFld*> aTmp; aTmp.reserve( mvPostItFlds.size() ); - for(std::list<SwPostItItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) + for(std::list<SwMarginItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) { - SwPostItField* pPostItField = static_cast<SwPostItField*>((*pPostIt)->pFmtFld->GetFld()); - if (pPostItField->GetPar1() == aAuthor) - aTmp.push_back( (*pPostIt)->pFmtFld ); + if ((*pPostIt)->GetFmtFld() && ((*pPostIt)->pPostIt->GetAuthor() == aAuthor) ) + aTmp.push_back( (*pPostIt)->GetFmtFld() ); } for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; i++) { @@ -1160,8 +1232,11 @@ void SwPostItMgr::Delete() std::vector<SwFmtFld*> aTmp; aTmp.reserve( mvPostItFlds.size() ); - for(std::list<SwPostItItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) - aTmp.push_back( (*pPostIt)->pFmtFld ); + for(std::list<SwMarginItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) + { + if ((*pPostIt)->GetFmtFld()) + aTmp.push_back( (*pPostIt)->GetFmtFld() ); + } for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; i++) { mpWrtShell->GotoField( *(*i) ); @@ -1195,14 +1270,17 @@ void SwPostItMgr::Delete() void SwPostItMgr::Hide(SwPostItField* pPostItField ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItField* pField = static_cast<SwPostItField*>((*i)->pFmtFld->GetFld()); - if (pPostItField==pField) + if ((*i)->GetFmtFld()) { - (*i)->bShow = false; - (*i)->pPostIt->HideNote(); - break; + SwPostItField* pField = static_cast<SwPostItField*>((*i)->GetFmtFld()->GetFld()); + if (pPostItField==pField) + { + (*i)->bShow = false; + (*i)->pPostIt->HideNote(); + break; + } } } @@ -1211,10 +1289,9 @@ void SwPostItMgr::Hide(SwPostItField* pPostItField ) void SwPostItMgr::Hide( const String& rAuthor ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItField* pPostItField = static_cast<SwPostItField*>((*i)->pFmtFld->GetFld()); - if ( rAuthor == pPostItField->GetPar1() ) + if ( (*i)->pPostIt && ((*i)->pPostIt->GetAuthor() == rAuthor) ) { (*i)->bShow = false; (*i)->pPostIt->HideNote(); @@ -1226,7 +1303,7 @@ void SwPostItMgr::Hide( const String& rAuthor ) void SwPostItMgr::Hide() { - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { (*i)->bShow = false; (*i)->pPostIt->HideNote(); @@ -1236,7 +1313,7 @@ void SwPostItMgr::Hide() void SwPostItMgr::Show() { - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { (*i)->bShow = true; } @@ -1251,23 +1328,24 @@ void SwPostItMgr::Sort(const short aType) { case SORT_POS: mvPostItFlds.sort(comp_pos); - //mvPostItFlds.sort(comp_id); break; + /* case SORT_AUTHOR: mvPostItFlds.sort(comp_author); break; case SORT_DATE: mvPostItFlds.sort(comp_date); break; + */ } } } -SwPostIt* SwPostItMgr::GetPostIt(SwFmtFld* pFld) const +SwMarginWin* SwPostItMgr::GetPostIt(SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld ==pFld) + if ( (*i)->GetBroadCaster() == pBroadcaster) return (*i)->pPostIt; } return NULL; @@ -1277,17 +1355,17 @@ SwPostIt* SwPostItMgr::GetPostIt(SwPostItField* pFld) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld->GetFld() == pFld) - return (*i)->pPostIt; + if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld) ) + return static_cast<SwPostIt*>((*i)->pPostIt); } return NULL; } -SwPostIt* SwPostItMgr::GetPostIt( const SwFmtFld* pFld) const +SwMarginWin* SwPostItMgr::GetPostIt( const SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld ==pFld) + if ( (*i)->GetBroadCaster() == pBroadcaster) return (*i)->pPostIt; } return NULL; @@ -1297,8 +1375,8 @@ SwPostIt* SwPostItMgr::GetPostIt(const SwPostItField* pFld) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld->GetFld() == pFld) - return (*i)->pPostIt; + if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld)) + return static_cast<SwPostIt*>((*i)->pPostIt); } return NULL; } @@ -1311,9 +1389,9 @@ bool SwPostItMgr::ShowPreview(const SwField* pFld, SwFmtFld*& pFmtFld) const { for(const_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { - if ((*i)->pFmtFld->GetFld()==pFld) + if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld()==pFld) ) { - pFmtFld = (*i)->pFmtFld; + pFmtFld = (*i)->GetFmtFld(); const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0; bool bTopPage = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y())).Y() >= (mPages[n]->mPageRect.Top()+aSidebarheight); bool bBottomPage = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y()+(*i)->pPostIt->GetSizePixel().Height())).Y() <= (mPages[n]->mPageRect.Bottom()-aSidebarheight); @@ -1327,57 +1405,34 @@ bool SwPostItMgr::ShowPreview(const SwField* pFld, SwFmtFld*& pFmtFld) const return false; } -SwPostIt* SwPostItMgr::GetNextPostIt(USHORT aDirection, SwPostIt* aPostIt) +SwMarginWin* SwPostItMgr::GetNextPostIt(USHORT aDirection, SwMarginWin* aPostIt) { if (mvPostItFlds.size()>1) { - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->pPostIt ==aPostIt) { - SwPostItItem_iterator iNextPostIt = i; - /* - const Rectangle &aVisRect = mpView->GetVisArea(); - bool bVisible = false; - bool bDone = false; - - while (!bDone) + SwMarginItem_iterator iNextPostIt = i; + if (aDirection==KEY_PAGEUP) { - */ - if (aDirection==KEY_PAGEUP) + if ( iNextPostIt==mvPostItFlds.begin() ) { - if ( iNextPostIt==mvPostItFlds.begin() ) - { - //iNextPostIt = mvPostItFlds.end(); - return NULL; - } - --iNextPostIt; + return NULL; } - else + --iNextPostIt; + } + else + { + iNextPostIt++; + if ( iNextPostIt==mvPostItFlds.end() ) { - iNextPostIt++; - if ( iNextPostIt==mvPostItFlds.end() ) - { - return NULL; - //iNextPostIt = mvPostItFlds.begin(); - } - } - // lets quit, we are back at the beginng - if ( (*iNextPostIt)->pPostIt==aPostIt) return NULL; - - //bVisible = (*iNextPostIt)->pFmtFld->GetTxtFld()->GetTxtNode().IsInVisibleArea(); - //bVisible = bVisible && ((*iNextPostIt)->mPos.Bottom() < aVisRect.Bottom()) && ((*iNextPostIt)->mPos.Bottom() > aVisRect.Top()); - - /* - const bool bBottom = mpEditWin->PixelToLogic(Point(0,(*iNextPostIt)->pPostIt->GetPosPixel().Y()+(*iNextPostIt)->pPostIt->GetSizePixel().Height())).Y() <= aVisRect.Bottom(); - const bool bTop = mpEditWin->PixelToLogic(Point(0,(*iNextPostIt)->pPostIt->GetPosPixel().Y())).Y() >= aVisRect.Top(); - bVisible = bBottom && bTop; - - bDone = bVisible && (*iNextPostIt)->bShow; - + } } - */ + // lets quit, we are back at the beginng + if ( (*iNextPostIt)->pPostIt==aPostIt) + return NULL; return (*iNextPostIt)->pPostIt; } } @@ -1391,27 +1446,24 @@ long SwPostItMgr::GetNextBorder() { for (unsigned long n=0;n<mPages.size();n++) { - for(SwPostItItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); b++) + for(SwMarginItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); b++) { if ((*b)->pPostIt == mpActivePostIt) { - if (mPages[n]->bScrollbar) + SwMarginItem_iterator aNext = b; + aNext++; + bool bFollow = (aNext == mPages[n]->mList->end()) ? false : (*aNext)->pPostIt->IsFollow(); + if ( mPages[n]->bScrollbar || bFollow ) { return -1; } else { //if this is the last item, return the bottom border otherwise the next item - SwPostItItem_iterator aNext = b; - aNext++; if (aNext == mPages[n]->mList->end()) - { return mpEditWin->LogicToPixel(Point(0,mPages[n]->mPageRect.Bottom())).Y() - GetSpaceBetween(); - } else - { return (*aNext)->pPostIt->GetPosPixel().Y() - GetSpaceBetween(); - } } } } @@ -1421,17 +1473,6 @@ long SwPostItMgr::GetNextBorder() return -1; } -SwFmtFld* SwPostItMgr::GetFmtFld(SwPostIt* mpPostIt) const -{ - for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - { - if ( (*i)->pPostIt == mpPostIt) - return (*i)->pFmtFld; - } - DBG_WARNING("SwPostItMgr::GetFmtFld(): PostIt not found, something major must have gone wrong here"); - return NULL; -} - void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) { if (pFld) @@ -1444,13 +1485,13 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) // TODO: does not work properly if mouse and cursor was set SwPostIt* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) - pOldPostIt->SetShadowState(SS_NORMAL); + pOldPostIt->SetViewState(SS_NORMAL); } //set new one, if it is not currently edited SwPostIt* pNewPostIt = GetPostIt(pFld); if (pNewPostIt && pNewPostIt->Shadow() && (pNewPostIt->Shadow()->GetShadowState() != SS_EDIT)) { - pNewPostIt->SetShadowState(SS_VIEW); + pNewPostIt->SetViewState(SS_VIEW); //remember our new field mShadowState.mpShadowFld = pFld; mShadowState.bCursor = false; @@ -1476,7 +1517,7 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) SwPostIt* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) { - pOldPostIt->SetShadowState(SS_NORMAL); + pOldPostIt->SetViewState(SS_NORMAL); mShadowState.mpShadowFld = 0; } } @@ -1486,13 +1527,15 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) void SwPostItMgr::PrepareView(bool bIgnoreCount) { - if (mvPostItFlds.empty() || bIgnoreCount) + if (!HasNotes() || bIgnoreCount) { - mpEditWin->Invalidate(); + mpWrtShell->StartAllAction(); + //mpEditWin->Invalidate(); // really not needed anymore?? SwRootFrm* pLayout = mpWrtShell->GetLayout(); if ( pLayout ) SwPostItHelper::setSidebarChanged( pLayout, mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE ) ); + mpWrtShell->EndAllAction(); } } @@ -1586,12 +1629,12 @@ bool SwPostItMgr::ScrollbarHit(const unsigned long aPage,const Point &aPoint) void SwPostItMgr::CorrectPositions() { - if ( mbWaitingForCalcRects || mbLayouting || mvPostItFlds.empty()) + if ( mbWaitingForCalcRects || mbLayouting || mvPostItFlds.empty() ) return; // find first valid note - SwPostIt *pFirstPostIt = 0; - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + SwMarginWin *pFirstPostIt = 0; + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { pFirstPostIt = (*i)->pPostIt; if (pFirstPostIt) @@ -1611,7 +1654,7 @@ void SwPostItMgr::CorrectPositions() long aAnkorPosY = 0; for (unsigned long n=0;n<mPages.size();n++) { - for(SwPostItItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->bShow && (*i)->pPostIt) { @@ -1635,7 +1678,6 @@ bool SwPostItMgr::ShowNotes() const bool SwPostItMgr::HasNotes() const { - //we just want to know if there are notes, no matter if visible or not return !mvPostItFlds.empty(); } @@ -1706,20 +1748,14 @@ Color SwPostItMgr::GetColorAnkor(sal_uInt16 aAuthorIndex) return Color(COL_WHITE); } -void SwPostItMgr::SetColors(SwPostIt* pPostIt,SwPostItField* pFld) -{ - sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(pFld->GetPar1()); - pPostIt->SetColor(GetColorDark(aIndex),GetColorLight(aIndex),GetColorAnkor(aIndex)); -} - -void SwPostItMgr::SetActivePostIt( SwPostIt* p) +void SwPostItMgr::SetActivePostIt( SwMarginWin* p) { if ( p != mpActivePostIt ) { // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt // therefore we get a new layout in DOCCHANGED when switching from postit to document, // otherwise, GetActivePostIt() would still hold our old postit - SwPostIt* pActive = mpActivePostIt; + SwMarginWin* pActive = mpActivePostIt; mpActivePostIt = p; if (pActive) { @@ -1728,7 +1764,7 @@ void SwPostItMgr::SetActivePostIt( SwPostIt* p) } if (mpActivePostIt) { - mpWrtShell->GotoField( *mpActivePostIt->Field() ); + mpActivePostIt->GotoPos(); mpView->AttrChangedNotify(0); mpActivePostIt->ActivatePostIt(); } @@ -1741,6 +1777,7 @@ IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ ) if ( mbLayouting ) { DBG_ERROR("Reentrance problem in Layout Manager!"); + mbWaitingForCalcRects = false; return 0; } @@ -1755,7 +1792,7 @@ IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ ) void SwPostItMgr::Rescale() { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->Rescale(); } @@ -1792,14 +1829,159 @@ sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const void SwPostItMgr::SetSpellChecking() { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->SetSpellChecking(); } void SwPostItMgr::SetReadOnlyState() { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->SetReadonly( mbReadOnly ); } + +void SwPostItMgr::StartSearchAndReplace(const SvxSearchItem& rSearchItem) +{ + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + if ( (*i)->pPostIt ) + { + ESelection aOldSelection = (*i)->pPostIt->View()->GetSelection(); + (*i)->pPostIt->View()->SetSelection(ESelection(0,0,0,0)); + if (!(*i)->pPostIt->View()->StartSearchAndReplace( rSearchItem )) + (*i)->pPostIt->View()->SetSelection(aOldSelection); + /* if ((*i)->pPostIt->View()->StartSearchAndReplace( rSearchItem )) + (*i)->pPostIt->GrabFocus(); + return; + */ + } + + /* + 673 BOOL bFromStart, + 674 BOOL bApi, + 675 BOOL bRecursive) + 676 { + 677 ExtTextView* pTextView = aEditWin.GetTextView(); + 678 TextSelection aSel; + 679 TextPaM aPaM; + 680 + 681 BOOL bForward = !rSearchItem.GetBackward(); + 682 BOOL bAtStart = pTextView->GetSelection() == TextSelection( aPaM, aPaM ); + 683 + 684 if( !bForward ) + 685 aPaM = TextPaM( (ULONG)-1, (USHORT)-1 ); + 686 + 687 if( bFromStart ) + 688 { + 689 aSel = pTextView->GetSelection(); + 690 pTextView->SetSelection( TextSelection( aPaM, aPaM )); + 691 } + 692 + 693 SearchOptions aSearchOpt( rSearchItem.GetSearchOptions() ); + 694 aSearchOpt.Locale = SvxCreateLocale( + 695 static_cast< LanguageType >( GetAppLanguage() ) ); + 696 + 697 USHORT nFound; + 698 BOOL bAll = FALSE; + 699 switch( rSearchItem.GetCommand() ) + 700 { + 701 case SVX_SEARCHCMD_FIND: + 702 case SVX_SEARCHCMD_FIND_ALL: + 703 nFound = pTextView->Search( aSearchOpt, bForward ); + 704 break; + 705 + 706 case SVX_SEARCHCMD_REPLACE_ALL: bAll = TRUE; + 707 case SVX_SEARCHCMD_REPLACE: + 708 nFound = pTextView->Replace( aSearchOpt, bAll, bForward ); + 709 break; + 710 + 711 default: + 712 nFound = 0; + 713 } + 714 + 715 if( !nFound ) + 716 { + 717 BOOL bNotFoundMessage = FALSE; + 718 if(!bRecursive) + 719 { + 720 if(!bFromStart) + 721 { + 722 bNotFoundMessage = bAtStart; + 723 } + 724 else + 725 { + 726 bNotFoundMessage = TRUE; + 727 pTextView->SetSelection( aSel ); + 728 } + 729 } + 730 else if(bAtStart) + 731 { + 732 bNotFoundMessage = TRUE; + 733 } + 734 + 735 + 736 if(!bApi) + 737 if(bNotFoundMessage) + 738 { + 739 InfoBox( 0, SW_RES(MSG_NOT_FOUND)).Execute(); + 740 } + 741 else if(!bRecursive && RET_YES == + 742 QueryBox(0, SW_RES( bForward ? MSG_SEARCH_END + 743 : MSG_SEARCH_START)).Execute()) + 744 { + 745 pTextView->SetSelection( TextSelection( aPaM, aPaM ) ); + 746 StartSearchAndReplace( rSearchItem, FALSE, FALSE, TRUE ); + 747 } + 748 } + 749 return nFound; + + */ +} + +sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem) +{ + SwMarginWin* pWin = GetActivePostIt(); + sal_uInt16 aResult = pWin->View()->StartSearchAndReplace( *pItem ); + if (!aResult) + SetActivePostIt(0); + return aResult; +} + + +sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward) +{ + SwMarginWin* pWin = GetActivePostIt(); + SvxSearchItem aItem(SID_SEARCH_ITEM ); + aItem.SetSearchOptions(rSearchOptions); + aItem.SetBackward(!bSrchForward); + sal_uInt16 aResult = pWin->View()->StartSearchAndReplace( aItem ); + if (!aResult) + SetActivePostIt(0); + return aResult; +} + +sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward) +{ + sal_uInt16 aResult = 0; + SwMarginWin* pWin = GetPostIt(&pFld); + if (pWin) + { + ESelection aOldSelection = pWin->View()->GetSelection(); + if (bSrchForward) + pWin->View()->SetSelection(ESelection(0,0,0,0)); + else + pWin->View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); + SvxSearchItem aItem(SID_SEARCH_ITEM ); + aItem.SetSearchOptions(rSearchOptions); + aItem.SetBackward(!bSrchForward); + aResult = pWin->View()->StartSearchAndReplace( aItem ); + if (!aResult) + pWin->View()->SetSelection(aOldSelection); + else + { + SetActivePostIt(pWin); + MakeVisible(pWin); + } + } + return aResult; +} diff --git a/sw/source/ui/docvw/docvw.hrc b/sw/source/ui/docvw/docvw.hrc index 38d562f100e2..afb599e64c6c 100644 --- a/sw/source/ui/docvw/docvw.hrc +++ b/sw/source/ui/docvw/docvw.hrc @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docvw.hrc,v $ - * $Revision: 1.11 $ + * $Revision: 1.11.190.1 $ * * This file is part of OpenOffice.org. * @@ -90,6 +90,11 @@ #define STR_DELETE_ALL_NOTES (RC_DOCVW_BEGIN + 24) #define STR_DELETE_AUTHOR_NOTES (RC_DOCVW_BEGIN + 25) +#define STR_NODATE (RC_DOCVW_BEGIN + 26) +#define STR_NOAUTHOR (RC_DOCVW_BEGIN + 27) + +#define STR_REPLY (RC_DOCVW_BEGIN + 28) + #define MSG_READONLY_CONTENT (RC_DOCVW_BEGIN + 1) #define DOCVW_ACT_END STR_SMARTTAG_CLICK diff --git a/sw/source/ui/docvw/docvw.src b/sw/source/ui/docvw/docvw.src index 963bfe29160f..de4305bc730e 100644 --- a/sw/source/ui/docvw/docvw.src +++ b/sw/source/ui/docvw/docvw.src @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docvw.src,v $ - * $Revision: 1.52 $ + * $Revision: 1.52.140.1 $ * * This file is part of OpenOffice.org. * @@ -323,3 +323,18 @@ String STR_DELETE_AUTHOR_NOTES Text [ en-US ] = "Notes by " ; }; +String STR_NODATE +{ + Text [ en-US ] = "(no date)" ; +}; + +String STR_NOAUTHOR +{ + Text [ en-US ] = "(no author)" ; +}; + +String STR_REPLY +{ + Text [ en-US ] = "Reply to $1" ; +}; + diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index d600a7e21ea0..c53253ee7115 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -3779,6 +3779,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt) break; } //#i6193#, change ui if mouse is over SwPostItField + // TODO: do the same thing for redlines SW_REDLINE SwRect aFldRect; SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD); if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, FALSE, &aFldRect ) ) diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx index 4a654ff6aabb..6f397520be2c 100644 --- a/sw/source/ui/docvw/edtwin2.cxx +++ b/sw/source/ui/docvw/edtwin2.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: edtwin2.cxx,v $ - * $Revision: 1.32 $ + * $Revision: 1.31.130.3 $ * * This file is part of OpenOffice.org. * @@ -97,7 +97,7 @@ /*-------------------------------------------------------------------- Beschreibung: KeyEvents --------------------------------------------------------------------*/ -static void lcl_GetRedlineHelp( const SwRedline& rRedl, String& rTxt, BOOL bBalloon ) +static void lcl_GetRedlineHelp( const SwRedline& rRedl, String& rTxt, BOOL /*bBalloon*/ ) { USHORT nResId = 0; switch( rRedl.GetType() ) @@ -301,6 +301,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) if (pMgr->ShowPreview(pFld,pSwFmtFld)) { SwPostIt* pPostIt = new SwPostIt(static_cast<Window*>(this),0,pSwFmtFld,pMgr,PB_Preview); + pPostIt->InitControls(); pPostIt->SetReadonly(true); pMgr->SetColors(pPostIt,static_cast<SwPostItField*>(pSwFmtFld->GetFld())); pPostIt->SetVirtualPosSize(rEvt.GetMousePosPixel(),Size(180,70)); diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 08cba6066892..fbcf8cfe4977 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: postit.cxx,v $ - * $Revision: 1.10 $ + * $Revision: 1.8.42.11 $ * * This file is part of OpenOffice.org. * @@ -35,19 +35,15 @@ #include <popup.hrc> #include <docvw.hrc> +#include <app.hrc> #include <hintids.hxx> #include "viewopt.hxx" #include "cmdid.h" -#include <vcl/help.hxx> -#include <vcl/scrbar.hxx> -#include <vcl/button.hxx> -#include <vcl/svapp.hxx> -#include <vcl/gradient.hxx> #include <tools/poly.hxx> // Polygon -#include <vcl/salbtype.hxx> // FRound +#include <svx/postitem.hxx> #include <svx/fontitem.hxx> #include <svx/eeitem.hxx> #include <svx/fhgtitem.hxx> @@ -68,17 +64,20 @@ #include <svx/editstat.hxx> //EditEngine flags #include <svx/outliner.hxx> #include <svx/editeng.hxx> +#include <svx/editobj.hxx> #include <svx/unolingu.hxx> -#include <svtools/languageoptions.hxx> #include <svtools/langtab.hxx> #include <svtools/slstitm.hxx> #include <svtools/securityoptions.hxx> +#include <svtools/useroptions.hxx> +#include <svtools/languageoptions.hxx> #include <svtools/zforlist.hxx> #include <svtools/svmedit.hxx> #include <linguistic/lngprops.hxx> +#include <sfx2/request.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> @@ -86,6 +85,12 @@ #include <vcl/vclenum.hxx> #include <vcl/edit.hxx> +#include <vcl/help.hxx> +#include <vcl/scrbar.hxx> +#include <vcl/button.hxx> +#include <vcl/svapp.hxx> +#include <vcl/gradient.hxx> +#include <vcl/salbtype.hxx> // FRound #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/tuple/b2dtuple.hxx> @@ -100,16 +105,20 @@ #include <shellres.hxx> #include <fmtfld.hxx> #include <wrtsh.hxx> +#include <textsh.hxx> #include <doc.hxx> #include <txtfld.hxx> #include <redline.hxx> #include <uitool.hxx> #include <SwUndoField.hxx> #include <editsh.hxx> +#include <swmodule.hxx> +#include <node.hxx> +#include <ndtxt.hxx> +#include <langhelper.hxx> using namespace ::com::sun::star; -#define ANKORLINE_WIDTH 1 #define METABUTTON_WIDTH 16 #define METABUTTON_HEIGHT 18 #define METABUTTON_AREA_WIDTH 30 @@ -119,6 +128,13 @@ using namespace ::com::sun::star; #define POSTIT_SHADOW_BRIGHT Color(180,180,180) #define POSTIT_SHADOW_DARK Color(83,83,83) +#define LINEBREAK rtl::OUString::createFromAscii("\n") +#define EMPTYSTRING rtl::OUString::createFromAscii("") + +TYPEINIT0(SwMarginWin); +TYPEINIT1(SwPostIt,SwMarginWin); +//TYPEINIT1(SwRedComment,SwMarginWin); + Color ColorFromAlphaColor(UINT8 aTransparency, Color &aFront, Color &aBack ) { return Color((UINT8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)), @@ -131,7 +147,7 @@ PostItTxt::PostItTxt(Window* pParent, WinBits nBits) : Window(pParent, nBits), m { SetHelpId(26276); AddEventListener( LINK( this, PostItTxt, WindowEventListener ) ); - mpPostIt = static_cast<SwPostIt*>(GetParent()); + mpMarginWin = static_cast<SwMarginWin*>(GetParent()); } PostItTxt::~PostItTxt() @@ -141,24 +157,24 @@ PostItTxt::~PostItTxt() void PostItTxt::GetFocus() { - BOOL bLockView = mpPostIt->DocView()->GetWrtShell().IsViewLocked(); - mpPostIt->DocView()->GetWrtShell().LockView( TRUE ); + BOOL bLockView = mpMarginWin->DocView()->GetWrtShell().IsViewLocked(); + mpMarginWin->DocView()->GetWrtShell().LockView( TRUE ); - if(mpPostIt && !mpPostIt->IsPreview()) - mpPostIt->Mgr()->SetActivePostIt(mpPostIt); + if(mpMarginWin && !mpMarginWin->IsPreview()) + mpMarginWin->Mgr()->SetActivePostIt(mpMarginWin); Window::GetFocus(); if (!mMouseOver) Invalidate(); - mpPostIt->DocView()->GetWrtShell().LockView( bLockView ); - mpPostIt->Mgr()->MakeVisible(mpPostIt); + mpMarginWin->DocView()->GetWrtShell().LockView( bLockView ); + mpMarginWin->Mgr()->MakeVisible(mpMarginWin); } void PostItTxt::LoseFocus() { // write the visible text back into the SwField - if ( mpPostIt ) - mpPostIt->UpdateData(); + if ( mpMarginWin ) + mpMarginWin->UpdateData(); Window::LoseFocus(); if (!mMouseOver) @@ -168,7 +184,7 @@ void PostItTxt::LoseFocus() void PostItTxt::RequestHelp(const HelpEvent &rEvt) { USHORT nResId = 0; - switch( mpPostIt->GetStatus() ) + switch( mpMarginWin->GetStatus() ) { case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break; case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break; @@ -176,7 +192,7 @@ void PostItTxt::RequestHelp(const HelpEvent &rEvt) } SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); - if ( nResId && mpPostIt->DocView()->GetWrtShell().GetContentAtPos( mpPostIt->GetAnkorRect().Pos(), aCntntAtPos ) ) + if ( nResId && mpMarginWin->DocView()->GetWrtShell().GetContentAtPos( mpMarginWin->GetAnkorRect().Pos(), aCntntAtPos ) ) { String sTxt; sTxt = SW_RESSTR( nResId ); @@ -194,17 +210,17 @@ void PostItTxt::Paint( const Rectangle& rRect) { if (mMouseOver || HasFocus()) DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())), - Gradient(GRADIENT_LINEAR,mpPostIt->ColorDark(),mpPostIt->ColorDark())); + Gradient(GRADIENT_LINEAR,mpMarginWin->ColorDark(),mpMarginWin->ColorDark())); else DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())), - Gradient(GRADIENT_LINEAR,mpPostIt->ColorLight(),mpPostIt->ColorDark())); + Gradient(GRADIENT_LINEAR,mpMarginWin->ColorLight(),mpMarginWin->ColorDark())); } mpOutlinerView->Paint( rRect ); - if (mpPostIt->GetStatus()==SwPostItHelper::DELETED) + if (mpMarginWin->GetStatus()==SwPostItHelper::DELETED) { - SetLineColor(mpPostIt->GetChangeColor()); + SetLineColor(static_cast<SwPostIt*>(mpMarginWin)->GetChangeColor()); DrawLine(PixelToLogic(GetPosPixel()),PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),GetSizePixel().Height()))); DrawLine(PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),0)),PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()))); } @@ -214,60 +230,45 @@ void PostItTxt::KeyInput( const KeyEvent& rKeyEvt ) { const KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); USHORT nKey = rKeyCode.GetCode(); - SwView* pView = mpPostIt->DocView(); - - if ( (nKey== KEY_N) && rKeyCode.IsMod1() && rKeyCode.IsMod2()) - { - if ( mpPostIt->Mgr()->GetActivePostIt() == mpPostIt ) - mpPostIt->Mgr()->SetActivePostIt(0); - mpPostIt->SwitchToFieldPos(); - } - else + SwView* pView = mpMarginWin->DocView(); if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN))) - { - mpPostIt->SwitchToPostIt(nKey); - } + mpMarginWin->SwitchToPostIt(nKey); else if ((nKey == KEY_ESCAPE) || (rKeyCode.IsMod1() && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN)))) - { - if ( mpPostIt->Mgr()->GetActivePostIt() == mpPostIt ) - mpPostIt->Mgr()->SetActivePostIt(0); - if (!mpPostIt->IsReadOnly() && (mpPostIt->GetStatus()!=SwPostItHelper::DELETED) && - mpPostIt->Engine()->GetEditEngine().GetText()==String(::rtl::OUString::createFromAscii(""))) - mpPostIt->Delete(); - else - mpPostIt->SwitchToFieldPos(); - } + mpMarginWin->SwitchToFieldPos(); else if (nKey == KEY_INSERT) { if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2()) - mpPostIt->ToggleInsMode(); + mpMarginWin->ToggleInsMode(); } else { //let's make sure we see our note - mpPostIt->Mgr()->MakeVisible(mpPostIt); + mpMarginWin->Mgr()->MakeVisible(mpMarginWin); - long aOldHeight = mpPostIt->GetPostItTextHeight(); + long aOldHeight = mpMarginWin->GetPostItTextHeight(); bool bDone = false; /// HACK: need to switch off processing of Undo/Redo in Outliner if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) ) { - SwPostItHelper::SwLayoutStatus aStatus = mpPostIt->GetStatus(); + /* + SwPostItHelper::SwLayoutStatus aStatus = mpMarginWin->GetStatus(); if ( (aStatus!=SwPostItHelper::DELETED) || - ( (aStatus==SwPostItHelper::DELETED) && (!mpPostIt->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt))) ) + ( (aStatus==SwPostItHelper::DELETED) && (!mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt))) ) + */ + bool bIsProtected = mpMarginWin->IsProtected(); + if (!bIsProtected || (bIsProtected && !mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); } if (bDone) - mpPostIt->ResizeIfNeccessary(aOldHeight,mpPostIt->GetPostItTextHeight()); + mpMarginWin->ResizeIfNeccessary(aOldHeight,mpMarginWin->GetPostItTextHeight()); else { - // write back data first when saving or showing navigator - //otherwise new content could be lost - if ( (rKeyCode.IsMod1() && nKey== KEY_S) || (nKey==KEY_F5) ) - mpPostIt->UpdateData(); + // write back data first when showing navigator + if ( nKey==KEY_F5 ) + mpMarginWin->UpdateData(); if (!pView->KeyInput(rKeyEvt)) Window::KeyInput(rKeyEvt); } @@ -324,7 +325,7 @@ void PostItTxt::MouseButtonDown( const MouseEvent& rMEvt ) if ( pURL ) { mpOutlinerView->MouseButtonDown( rMEvt ); - SwWrtShell &rSh = mpPostIt->DocView()->GetWrtShell(); + SwWrtShell &rSh = mpMarginWin->DocView()->GetWrtShell(); String sURL( pURL->GetURL() ); String sTarget( pURL->GetTargetFrame() ); ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget); @@ -337,7 +338,7 @@ void PostItTxt::MouseButtonDown( const MouseEvent& rMEvt ) GrabFocus(); if ( mpOutlinerView ) mpOutlinerView->MouseButtonDown( rMEvt ); - mpPostIt->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE); + mpMarginWin->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE); } void PostItTxt::MouseButtonUp( const MouseEvent& rMEvt ) @@ -348,14 +349,14 @@ void PostItTxt::MouseButtonUp( const MouseEvent& rMEvt ) IMPL_LINK(PostItTxt, OnlineSpellCallback, SpellCallbackInfo*, pInfo) { - if (mpPostIt && pInfo->nCommand == SPELLCMD_STARTSPELLDLG) - mpPostIt->DocView()->GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON); + if ( mpMarginWin && (pInfo->nCommand == SPELLCMD_STARTSPELLDLG) ) + mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON); return 0; } IMPL_LINK( PostItTxt, Select, Menu*, pSelMenu ) { - mpPostIt->ExecuteCommand( pSelMenu->GetCurItemId() ); + mpMarginWin->ExecuteCommand( pSelMenu->GetCurItemId() ); return 0; } @@ -363,7 +364,8 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) { if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) { - if (!mpPostIt->IsReadOnly() && (mpPostIt->GetStatus()!=SwPostItHelper::DELETED) && + if (!mpMarginWin->IsProtected() && + //if (!mpMarginWin->IsReadOnly() && (mpMarginWin->GetStatus()!=SwPostItHelper::DELETED) && mpOutlinerView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE )) { Link aLink = LINK(this, PostItTxt, OnlineSpellCallback); @@ -371,10 +373,10 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) } else { - SfxPopupMenuManager* aMgr = mpPostIt->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); + SfxPopupMenuManager* aMgr = mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR ); SwRewriter aRewriter; - aRewriter.AddRule(UNDO_ARG1, mpPostIt->GetAuthor()); + aRewriter.AddRule(UNDO_ARG1, mpMarginWin->GetAuthor()); aText = aRewriter.Apply(aText); ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); // SwPostItLinkForwarder_Impl aFwd( ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->GetSelectHdl(), mpPostIt ); @@ -396,34 +398,63 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) else if (rCEvt.GetCommand() == COMMAND_WHEEL) { - if (mpPostIt->Scrollbar()->IsVisible()) + if (mpMarginWin->Scrollbar()->IsVisible()) { const CommandWheelData* pData = rCEvt.GetWheelData(); if (pData->IsShift() || pData->IsMod1() || pData->IsMod2()) { - mpPostIt->DocView()->HandleWheelCommands(rCEvt); + mpMarginWin->DocView()->HandleWheelCommands(rCEvt); } else { - HandleScrollCommand( rCEvt, 0 , mpPostIt->Scrollbar()); + HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar()); /* long nLines = pData->GetNotchDelta() * (long)pData->GetScrollLines(); - if ( ((mpPostIt->Scrollbar()->GetRange().Min() == mpPostIt->Scrollbar()->GetThumbPos()) && (nLines > 0)) || - ( (mpPostIt->Scrollbar()->GetRange().Max() == mpPostIt->Scrollbar()->GetThumbPos()+mpPostIt->Scrollbar()->GetVisibleSize()) && (nLines < 0)) ) + if ( ((mpMarginWin->Scrollbar()->GetRange().Min() == mpMarginWin->Scrollbar()->GetThumbPos()) && (nLines > 0)) || + ( (mpMarginWin->Scrollbar()->GetRange().Max() == mpMarginWin->Scrollbar()->GetThumbPos()+mpMarginWin->Scrollbar()->GetVisibleSize()) && (nLines < 0)) ) { - mpPostIt->DocView()->HandleWheelCommands(rCEvt); + mpMarginWin->DocView()->HandleWheelCommands(rCEvt); } else { - HandleScrollCommand( rCEvt, 0 , mpPostIt->Scrollbar()); + HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar()); } */ } } else { - mpPostIt->DocView()->HandleWheelCommands(rCEvt); + mpMarginWin->DocView()->HandleWheelCommands(rCEvt); + } + } + else + if (rCEvt.GetCommand() == COMMAND_SELECTIONCHANGE) + { + if ( mpOutlinerView ) + { + const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData(); + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + aSelection.nStartPos = pData->GetStart(); + aSelection.nEndPos = pData->GetEnd(); + mpOutlinerView->GetEditView().SetSelection(aSelection); + } + } + else + if (rCEvt.GetCommand() == COMMAND_PREPARERECONVERSION) + { + if ( mpOutlinerView && mpOutlinerView->HasSelection() ) + { + EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + aSelection.Adjust(); + if( aSelection.nStartPara != aSelection.nEndPara ) + { + xub_StrLen aParaLen = aEditEngine->GetTextLen( aSelection.nStartPara ); + aSelection.nEndPara = aSelection.nStartPara; + aSelection.nEndPos = aParaLen; + mpOutlinerView->GetEditView().SetSelection( aSelection ); + } } } else @@ -440,6 +471,40 @@ void PostItTxt::DataChanged( const DataChangedEvent& aData) Window::DataChanged( aData ); } +XubString PostItTxt::GetSurroundingText() const +{ + if( mpOutlinerView ) + { + EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); + if( mpOutlinerView->HasSelection() ) + return mpOutlinerView->GetSelected(); + else + { + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + XubString aStr = aEditEngine->GetText(aSelection.nStartPara); + return aStr; + } + } + else + return XubString::EmptyString(); +} + +Selection PostItTxt::GetSurroundingTextSelection() const +{ + if( mpOutlinerView ) + { + if( mpOutlinerView->HasSelection() ) + return Selection( 0, mpOutlinerView->GetSelected().Len() ); + else + { + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + return Selection( aSelection.nStartPos, aSelection.nEndPos ); + } + } + else + return Selection( 0, 0 ); +} + IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) { if ( pWinEvent && pWinEvent->ISA( VclWindowEvent ) ) @@ -453,22 +518,22 @@ IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) mMouseOver = true; if (!mbShowPopup && !HasFocus()) { - mpPostIt->SetShadowState(SS_VIEW); + mpMarginWin->SetViewState(SS_VIEW); Invalidate(); } } else if ( pMouseEvt->IsLeaveWindow()) { - if (mpPostIt->IsPreview()) + if (mpMarginWin->IsPreview()) { - //mpPostIt->doLazyDelete(); + //mpMarginWin->doLazyDelete(); } else { mMouseOver = false; if (!mbShowPopup && !HasFocus()) { - mpPostIt->SetShadowState(SS_NORMAL); + mpMarginWin->SetViewState(SS_NORMAL); Invalidate(); } } @@ -477,23 +542,23 @@ IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) } return sal_True; } - - -/******* SwPostIt **************************************/ -SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits) : Window(pParent, nBits), +/************** SwMarginWin***********************************++*/ +SwMarginWin::SwMarginWin(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits) +: Window(pParent, nBits), + mnEventId(0), mpOutlinerView(0), mpOutliner(0), mpPostItTxt(0), mpMeta(0), mpVScrollbar(0), - mpFmtFld(aField), - mpFld( static_cast<SwPostItField*>(aField->GetFld())), mpAnkor(0), mpShadow(0), mpMgr(aMgr), mbMeta(true), - mpButtonPopup(new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON))), - nFlags(aBits) + nFlags(aBits), + mbMouseOverButton(false), + mpButtonPopup(0), + mbIsFollow(false) { SwEditWin* aWin = static_cast<SwEditWin*>(GetParent()); mpView = &aWin->GetView(); @@ -507,38 +572,9 @@ SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr mpShadow->setVisible(false); pOverlayManager->add(*mpShadow); } - - InitControls(); - SetPostItText(); } -void SwPostIt::SetPostItText() -{ - // get text from SwPostItField and insert into our textview - mpOutliner->SetModifyHdl( Link() ); - mpOutliner->EnableUndo( FALSE ); - mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld()); - if( mpFld->GetTextObject() ) - mpOutliner->SetText( *mpFld->GetTextObject() ); - else - { - mpOutliner->Clear(); - SfxItemSet item( mpView->GetDocShell()->GetPool() ); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - rtl::OUString::createFromAscii(""),PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - mpOutlinerView->SetAttribs(item); - mpOutlinerView->InsertText(mpFld->GetPar2(),false); - } - - mpOutliner->ClearModifyFlag(); - mpOutliner->GetUndoManager().Clear(); - mpOutliner->EnableUndo( TRUE ); - mpOutliner->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); - Invalidate(); -} - -SwPostIt::~SwPostIt() +SwMarginWin::~SwMarginWin() { if (mpOutlinerView) { @@ -589,9 +625,12 @@ SwPostIt::~SwPostIt() { delete mpButtonPopup; } + + if (mnEventId) + Application::RemoveUserEvent( mnEventId ); } -void SwPostIt::Paint( const Rectangle& rRect) +void SwMarginWin::Paint( const Rectangle& rRect) { Window::Paint(rRect); @@ -614,7 +653,11 @@ void SwPostIt::Paint( const Rectangle& rRect) else { //draw button - Gradient aGradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,mColorAnkor,mColorDark),ColorFromAlphaColor(80,mColorAnkor,mColorDark)); + Gradient aGradient; + if (mbMouseOverButton) + aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(80,mColorAnkor,mColorDark),ColorFromAlphaColor(15,mColorAnkor,mColorDark)); + else + aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,mColorAnkor,mColorDark),ColorFromAlphaColor(80,mColorAnkor,mColorDark)); DrawGradient(mRectMetaButton,aGradient); //draw rect around button SetFillColor(); @@ -647,7 +690,7 @@ void SwPostIt::Paint( const Rectangle& rRect) } } -void SwPostIt::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,const SwRect &aRect, const long aPageBorder) +void SwMarginWin::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,const SwRect &aRect, const long aPageBorder) { mbMeta = true; mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight)); @@ -655,22 +698,22 @@ void SwPostIt::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,co mPageBorder = aPageBorder; } -void SwPostIt::SetSize( const Size& rNewSize ) +void SwMarginWin::SetSize( const Size& rNewSize ) { mPosSize.SetSize(rNewSize); } -void SwPostIt::SetVirtualPosSize( const Point& aPoint, const Size& aSize) +void SwMarginWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize) { mPosSize = Rectangle(aPoint,aSize); } -void SwPostIt::TranslateTopPosition(const long aAmount) +void SwMarginWin::TranslateTopPosition(const long aAmount) { mPosSize.Move(0,aAmount); } -void SwPostIt::ShowAnkorOnly(const Point &aPoint) +void SwMarginWin::ShowAnkorOnly(const Point &aPoint) { HideNote(); SetPosAndSize(); @@ -680,12 +723,13 @@ void SwPostIt::ShowAnkorOnly(const Point &aPoint) mpAnkor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); mpAnkor->setVisible(true); } + if (mpShadow) + mpShadow->setVisible(false); } -void SwPostIt::InitControls() +void SwMarginWin::InitControls() { // actual window which holds the user text - //mpPostItTxt = new PostItTxt(this, 0x00000100); mpPostItTxt = new PostItTxt(this, 0); mpPostItTxt->SetPointer(Pointer(POINTER_TEXT)); @@ -708,8 +752,6 @@ void SwPostIt::InitControls() aSettings.SetStyleSettings(aStyleSettings); mpMeta->SetSettings(aSettings); - CheckMetaText(); - SwDocShell* aShell = mpView->GetDocShell(); mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT); aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner ); @@ -732,7 +774,7 @@ void SwPostIt::InitControls() SfxItemSet item(aShell->GetPool()); item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - rtl::OUString::createFromAscii(""),PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); mpOutlinerView->SetAttribs(item); // TODO: ?? @@ -743,12 +785,10 @@ void SwPostIt::InitControls() mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG); mpVScrollbar->EnableNativeWidget(false); mpVScrollbar->EnableRTL( false ); - mpVScrollbar->SetScrollHdl(LINK(this, SwPostIt, ScrollHdl)); + mpVScrollbar->SetScrollHdl(LINK(this, SwMarginWin, ScrollHdl)); mpVScrollbar->EnableDrag(); mpVScrollbar->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) ); - mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES); - const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions(); ULONG nCntrl = mpOutliner->GetControlWord(); // TODO: crash when AUTOCOMPLETE enabled @@ -763,64 +803,49 @@ void SwPostIt::InitControls() nCntrl &= ~EE_CNTRL_ONLINESPELLING; mpOutliner->SetControlWord(nCntrl); - XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR ); - SwRewriter aRewriter; - aRewriter.AddRule(UNDO_ARG1,GetAuthor()); - aText = aRewriter.Apply(aText); - mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); - - // TODO: why does this not work? - //mpOutliner->SetDefaultLanguage(mpFld->GetLanguage()); + sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor()); + SetColor(mpMgr->GetColorDark(aIndex),mpMgr->GetColorLight(aIndex),mpMgr->GetColorAnkor(aIndex)); - // set initial language for outliner - USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() ); - USHORT nLangWhichId = 0; - switch (nScriptType) - { - case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break; - case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; - case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; - } - SetLanguage(SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId)); - mpOutlinerView->StartSpeller(); + CheckMetaText(); + SetPopup(); + SetPostItText(); + SetLanguage(GetLanguage()); + View()->StartSpeller(); mpMeta->Show(); mpVScrollbar->Show(); mpPostItTxt->Show(); } -void SwPostIt::CheckMetaText() +void SwMarginWin::CheckMetaText() { - /* - String sDateTime; - SvNumberFormatter* pNumFormatter = mpView->GetDocShell()->GetDoc()->GetNumberFormatter(); - const ULONG nFormatDate = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATETIME , Application::GetSettings().GetLanguage()); - const DateTime aDateTime( mpFld->GetDate(), mpFld->GetTime()); - pNumFormatter->GetOutputString( aDateTime - DateTime( *pNumFormatter->GetNullDate()), nFormatDate, sDateTime, &pColor ); - */ const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData(); - String sMeta = mpFld->GetPar1(); + String sMeta = GetAuthor(); + if (sMeta==String(EMPTYSTRING)) + sMeta = String(SW_RES(STR_NOAUTHOR)); if (sMeta.Len() > 22) { sMeta.Erase(20); sMeta = sMeta + rtl::OUString::createFromAscii("..."); } - bool bValidTimeStamp = true; - if (mpFld->GetDate()==Date()) - sMeta = sMeta + rtl::OUString::createFromAscii("\n") + String(SW_RES(STR_POSTIT_TODAY)); - else if (mpFld->GetDate()==Date(Date()-1)) - sMeta = sMeta + rtl::OUString::createFromAscii("\n") + String(SW_RES(STR_POSTIT_YESTERDAY)); - else if (mpFld->GetDate().IsValid()) - sMeta = sMeta + rtl::OUString::createFromAscii("\n") + rLocalData.getDate(mpFld->GetDate()); + Date aDate = GetDate(); + if (aDate==Date()) + sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_TODAY)); else - bValidTimeStamp = false; - if (bValidTimeStamp) - sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime(mpFld->GetTime(), false); + if (aDate == Date(Date()-1)) + sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_YESTERDAY)); + else + if (aDate.IsValid() ) + sMeta = sMeta + LINEBREAK + rLocalData.getDate(aDate); + else + sMeta = sMeta + LINEBREAK + String(SW_RES(STR_NODATE)); + if (GetTime()!=0) + sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( GetTime(),false ); if (mpMeta->GetText() != sMeta) mpMeta->SetText(sMeta); } -void SwPostIt::Rescale() +void SwMarginWin::Rescale() { MapMode aMode = GetParent()->GetMapMode(); aMode.SetOrigin( Point() ); @@ -839,7 +864,7 @@ void SwPostIt::Rescale() } } -void SwPostIt::SetPosAndSize() +void SwMarginWin::SetPosAndSize() { bool bChange = false; @@ -914,9 +939,20 @@ void SwPostIt::SetPosAndSize() Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height())); mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y())); } + if (IsFollow() && !HasChildPathFocus()) + { + mpAnkor->SetAnkorState(AS_END); + } + else + { + mpAnkor->SetAnkorState(AS_ALL); + SwMarginWin* pWin = GetTopReplyNote(); + if (IsFollow() && pWin ) + pWin->Ankor()->SetAnkorState(AS_END); + } } -void SwPostIt::DoResize() +void SwMarginWin::DoResize() { long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); unsigned long aWidth = GetSizePixel().Width(); @@ -926,7 +962,7 @@ void SwPostIt::DoResize() { aHeight -= GetMetaHeight(); mpMeta->Show(); - mpPostItTxt->SetQuickHelpText(rtl::OUString::createFromAscii("")); + mpPostItTxt->SetQuickHelpText(EMPTYSTRING); } else { @@ -991,7 +1027,7 @@ void SwPostIt::DoResize() Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) ); } -void SwPostIt::SetSizePixel( const Size& rNewSize ) +void SwMarginWin::SetSizePixel( const Size& rNewSize ) { Window::SetSizePixel(rNewSize); @@ -1003,12 +1039,12 @@ void SwPostIt::SetSizePixel( const Size& rNewSize ) } } -void SwPostIt::SetScrollbar() +void SwMarginWin::SetScrollbar() { mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY()); } -void SwPostIt::ResizeIfNeccessary(long aOldHeight, long aNewHeight) +void SwMarginWin::ResizeIfNeccessary(long aOldHeight, long aNewHeight) { if (aOldHeight != aNewHeight) { @@ -1029,16 +1065,15 @@ void SwPostIt::ResizeIfNeccessary(long aOldHeight, long aNewHeight) else { if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight()) - { SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight())); - DoResize(); - Invalidate(); - } + DoResize(); + Invalidate(); } } else { - SetScrollbar(); + DoResize(); + Invalidate(); } } else @@ -1047,7 +1082,7 @@ void SwPostIt::ResizeIfNeccessary(long aOldHeight, long aNewHeight) } } -void SwPostIt::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor) +void SwMarginWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor) { mColorDark = aColorDark; mColorLight = aColorLight; @@ -1078,104 +1113,94 @@ void SwPostIt::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor) } } -void SwPostIt::SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor) -{ - if ( (mStatus != aStatus) || (mChangeColor != aColor) ) - { - mStatus = aStatus; - mChangeColor = aColor; - Invalidate(); - } -} - -void SwPostIt::SetMarginSide(bool aMarginSide) +void SwMarginWin::SetMarginSide(bool aMarginSide) { mbMarginSide = aMarginSide; } -void SwPostIt::SetReadonly(BOOL bSet) +void SwMarginWin::SetReadonly(BOOL bSet) { mbReadonly = bSet; View()->SetReadOnly(bSet); } -void SwPostIt::SetLanguage(const SvxLanguageItem aNewItem) +void SwMarginWin::SetLanguage(const SvxLanguageItem aNewItem) { - mpOutliner->SetModifyHdl( Link() ); - ESelection aOld = mpOutlinerView->GetSelection(); + Engine()->SetModifyHdl( Link() ); + ESelection aOld = View()->GetSelection(); - ESelection aNewSelection( 0, 0, (USHORT)mpOutliner->GetParagraphCount()-1, USHRT_MAX ); - mpOutlinerView->SetSelection( aNewSelection ); - SfxItemSet aEditAttr(mpOutlinerView->GetAttribs()); + ESelection aNewSelection( 0, 0, (USHORT)Engine()->GetParagraphCount()-1, USHRT_MAX ); + View()->SetSelection( aNewSelection ); + SfxItemSet aEditAttr(View()->GetAttribs()); aEditAttr.Put(aNewItem); - mpOutlinerView->SetAttribs( aEditAttr ); + View()->SetAttribs( aEditAttr ); - mpOutlinerView->SetSelection(aOld); - mpOutliner->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); + View()->SetSelection(aOld); + Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); - const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions(); - ULONG nCntrl = mpOutliner->GetControlWord(); + const SwViewOption* pVOpt = DocView()->GetWrtShellPtr()->GetViewOptions(); + ULONG nCntrl = Engine()->GetControlWord(); // turn off if (!pVOpt->IsOnlineSpell()) nCntrl &= ~EE_CNTRL_ONLINESPELLING; else nCntrl &= ~EE_CNTRL_ONLINESPELLING; - mpOutliner->SetControlWord(nCntrl); + Engine()->SetControlWord(nCntrl); //turn back on if (pVOpt->IsOnlineSpell()) nCntrl |= EE_CNTRL_ONLINESPELLING; else nCntrl &= ~EE_CNTRL_ONLINESPELLING; - mpOutliner->SetControlWord(nCntrl); + Engine()->SetControlWord(nCntrl); - mpOutliner->CompleteOnlineSpelling(); + Engine()->CompleteOnlineSpelling(); Invalidate(); } -void SwPostIt::DataChanged( const DataChangedEvent& aEvent) +void SwMarginWin::DataChanged( const DataChangedEvent& aEvent) { Window::DataChanged( aEvent ); } -void SwPostIt::GetFocus() +void SwMarginWin::GetFocus() { if (mpPostItTxt) mpPostItTxt->GrabFocus(); } -void SwPostIt::LoseFocus() +void SwMarginWin::LoseFocus() { } -void SwPostIt::ShowNote() +void SwMarginWin::ShowNote() { SetPosAndSize(); if (!IsVisible()) Window::Show(); - if (mpAnkor) - mpAnkor->setVisible(true); - if (mpShadow) + if (mpAnkor && !mpShadow->isVisible()) mpShadow->setVisible(true); + if (mpAnkor && !mpAnkor->isVisible()) + mpAnkor->setVisible(true); } -void SwPostIt::HideNote() +void SwMarginWin::HideNote() { if (IsVisible()) Window::Hide(); - if (mpAnkor) + if (mpAnkor && mpAnkor->isVisible()) mpAnkor->setVisible(false); - if (mpShadow) + if (mpShadow && mpShadow->isVisible()) mpShadow->setVisible(false); } -void SwPostIt::ActivatePostIt() +void SwMarginWin::ActivatePostIt() { mpOutliner->ClearModifyFlag(); mpOutliner->GetUndoManager().Clear(); CheckMetaText(); - SetShadowState(SS_EDIT); + SetViewState(SS_EDIT); View()->ShowCursor(); mpOutlinerView->GetEditView().SetInsertMode(mpView->GetWrtShellPtr()->IsInsMode()); @@ -1186,7 +1211,7 @@ void SwPostIt::ActivatePostIt() // mpPostItTxt->SetBackground(Wallpaper(mColorDark)); } -void SwPostIt::DeactivatePostIt() +void SwMarginWin::DeactivatePostIt() { // remove selection, #i87073# if (View()->GetEditView().HasSelection()) @@ -1199,7 +1224,7 @@ void SwPostIt::DeactivatePostIt() mpOutliner->CompleteOnlineSpelling(); - SetShadowState(SS_NORMAL); + SetViewState(SS_NORMAL); // write the visible text back into the SwField UpdateData(); @@ -1207,187 +1232,191 @@ void SwPostIt::DeactivatePostIt() View()->SetBackgroundColor(COL_TRANSPARENT); //mpPostItTxt->SetBackground(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark)); + + if ( !IsProtected() && + //if (!IsReadOnly() && (GetStatus()!=SwPostItHelper::DELETED) && + Engine()->GetEditEngine().GetText()==String(EMPTYSTRING) ) + mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 ); } -void SwPostIt::UpdateData() +void SwMarginWin::ToggleInsMode() { - if ( mpOutliner->IsModified() ) + if (!mpView->GetWrtShell().IsRedlineOn()) { - SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); - if ( pPos ) - { - SwField* pOldField = mpFld->Copy(); - mpFld->SetPar2(mpOutliner->GetEditEngine().GetText()); - mpFld->SetTextObject(mpOutliner->CreateParaObject()); - mpView->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); - delete pOldField; - delete pPos; - // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) - mpMgr->SetLayout(); - mpView->GetDocShell()->SetModified(); - } + //change outliner + mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode()); + //change documnet + mpView->GetWrtShell().ToggleInsMode(); + //update statusbar + SfxBindings &rBnd = mpView->GetViewFrame()->GetBindings(); + rBnd.Invalidate(SID_ATTR_INSERT); + rBnd.Update(SID_ATTR_INSERT); } - mpOutliner->ClearModifyFlag(); - mpOutliner->GetUndoManager().Clear(); } -void SwPostIt::ToggleInsMode() +void SwMarginWin::ExecuteCommand(USHORT nSlot) { - //change outliner - mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode()); - //change documnet - mpView->GetWrtShell().ToggleInsMode(); - //update statusbar - SfxBindings &rBnd = mpView->GetViewFrame()->GetBindings(); - rBnd.Invalidate(SID_ATTR_INSERT); - rBnd.Update(SID_ATTR_INSERT); + switch (nSlot) + { + case FN_POSTIT: + case FN_REPLY: + { + // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note + // will be created + SwView* pView = DocView(); + if (Engine()->GetEditEngine().GetText() != String(EMPTYSTRING)) + { + OutlinerParaObject* pPara = new OutlinerParaObject(*View()->GetEditView().CreateTextObject()); + Mgr()->RegisterAnswer(pPara); + } + if (Mgr()->GetActivePostIt()) + Mgr()->SetActivePostIt(0); + SwitchToFieldPos(); + pView->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT); + break; + } + case FN_DELETE_COMMENT: + case FN_DELETE_NOTE: + + //Delete(); // do not kill the parent of our open popup menu + mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 ); + break; + /* + case FN_HIDE_NOTE: + if ( Mgr()->GetActivePostIt() == this ) + { + Mgr()->SetActivePostIt(0); + // put the cursor back into the document + SwitchToFieldPos(); + } + Mgr()->Hide(mpFld); + break; + */ + case FN_DELETE_ALL_NOTES: + case FN_HIDE_ALL_NOTES: + // not possible as slot as this would require that "this" is the active postit + DocView()->GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON ); + break; + case FN_DELETE_NOTE_AUTHOR: + case FN_HIDE_NOTE_AUTHOR: + { + // not possible as slot as this would require that "this" is the active postit + SfxStringItem aItem( nSlot, GetAuthor() ); + const SfxPoolItem* aItems[2]; + aItems[0] = &aItem; + aItems[1] = 0; + DocView()->GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON ); + } + default: + mpView->GetViewFrame()->GetBindings().Execute( nSlot ); + break; + } } -void SwPostIt::Delete() +bool SwMarginWin::CalcFollow() { - if ( Mgr()->GetActivePostIt() == this) - Mgr()->SetActivePostIt(0); - // we delete the field directly, the Mgr cleans up the PostIt by listening - mpView->GetWrtShellPtr()->GotoField(*mpFmtFld); - mpView->GetWrtShellPtr()->DelRight(); + return false; } -SwEditWin* SwPostIt::EditWin() +SwEditWin* SwMarginWin::EditWin() { return &mpView->GetEditWin(); } -String SwPostIt::GetAuthor() const +String SwPostIt::GetAuthor() { return mpFld->GetPar1(); } -long SwPostIt::GetPostItTextHeight() +Date SwPostIt::GetDate() { - return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; + return mpFld->GetDate(); } -/* -void SwPostIt::SwitchToPostIt(bool aDirection) +Time SwPostIt::GetTime() { - if (aDirection) - SwitchToPostIt(KEY_PAGEDOWN); - else - SwitchToPostIt(KEY_PAGEUP); + return mpFld->GetTime(); } -*/ -void SwPostIt::SwitchToPostIt(USHORT aDirection) + +long SwMarginWin::GetPostItTextHeight() +{ + return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; +} + +void SwMarginWin::SwitchToPostIt(USHORT aDirection) { if (mpMgr) { - SwPostIt* pPostIt = mpMgr->GetNextPostIt(aDirection, this); + SwMarginWin* pPostIt = mpMgr->GetNextPostIt(aDirection, this); if (pPostIt) pPostIt->GrabFocus(); } } -void SwPostIt::MouseButtonDown( const MouseEvent& rMEvt ) +void SwMarginWin::MouseButtonDown( const MouseEvent& /*rMEvt */) { - if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) +} + +void SwMarginWin::MouseMove( const MouseEvent& rMEvt ) +{ + if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel()))) { - if (IsPreview()) + if (!mbMouseOverButton) { - doLazyDelete(); - if (mpMgr) - { - SwPostIt* pPostIt = mpMgr->GetPostIt(mpFmtFld); - if (pPostIt) - { - pPostIt->GrabFocus(); - mpMgr->MakeVisible(pPostIt); - } - } - + Invalidate(mRectMetaButton); + mbMouseOverButton = true; } - else + } + else + { + if (mbMouseOverButton) { - if ( mbReadonly ) - { - mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); - mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,false); - mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,false); - } - else - { - if (mStatus==SwPostItHelper::DELETED) - mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); - else - mpButtonPopup->EnableItem(FN_DELETE_NOTE,true); - mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,true); - mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,true); - } - - ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) ); + Invalidate(mRectMetaButton); + mbMouseOverButton = false; } } } -void SwPostIt::ExecuteCommand(USHORT nSlot) +void SwMarginWin::Delete() { - switch (nSlot) + if ( Mgr()->GetActivePostIt() == this) { - case FN_DELETE_NOTE: - Delete(); - break; - case FN_HIDE_NOTE: - if ( mpMgr->GetActivePostIt() == this ) - { - mpMgr->SetActivePostIt(0); - // put the cursor back into the document - SwitchToFieldPos(); - } - mpMgr->Hide(mpFld); - break; - case FN_DELETE_ALL_NOTES: - case FN_HIDE_ALL_NOTES: - // not possible as slot as this would require that "this" is the active postit - mpView->GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON ); - break; - case FN_DELETE_NOTE_AUTHOR: - case FN_HIDE_NOTE_AUTHOR: + Mgr()->SetActivePostIt(0); + // if the note is empty, the previous line will send a delete event, but we are already there + if (mnEventId) { - // not possible as slot as this would require that "this" is the active postit - SfxStringItem aItem( nSlot, mpFld->GetPar1() ); - const SfxPoolItem* aItems[2]; - aItems[0] = &aItem; - aItems[1] = 0; - mpView->GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON ); + Application::RemoveUserEvent( mnEventId ); + mnEventId = 0; } - default: - mpView->GetViewFrame()->GetBindings().Execute( nSlot ); - break; } } -void SwPostIt::SwitchToFieldPos(bool bAfter) +IMPL_LINK(SwMarginWin, ScrollHdl, ScrollBar*, pScroll) { - mpView->GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld); - if (bAfter) - mpView->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(1, 0, FALSE); - GrabFocusToDocument(); + long nDiff = View()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); + View()->Scroll( 0, nDiff ); + return 0; } -IMPL_LINK(SwPostIt, ScrollHdl, ScrollBar*, pScroll) +IMPL_LINK(SwMarginWin, ModifyHdl, void*, pVoid) { - long nDiff = View()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); - View()->Scroll( 0, nDiff ); + // no warnings, please + pVoid=0; + DocView()->GetDocShell()->SetModified(sal_True); return 0; } -IMPL_LINK(SwPostIt, ModifyHdl, void*, pVoid) +IMPL_LINK(SwMarginWin, DeleteHdl, void*, pVoid) { // no warnings, please pVoid=0; - mpView->GetDocShell()->SetModified(sal_True); + mnEventId = 0; + Delete(); return 0; } -void SwPostIt::ResetAttributes() + +void SwMarginWin::ResetAttributes() { mpOutlinerView->RemoveAttribsKeepLanguages(TRUE); mpOutliner->RemoveFields(TRUE); @@ -1396,12 +1425,12 @@ void SwPostIt::ResetAttributes() mpOutlinerView->SetAttribs(aSet); } -sal_Int32 SwPostIt::GetScrollbarWidth() +sal_Int32 SwMarginWin::GetScrollbarWidth() { return mpView->GetWrtShell().GetViewOptions()->GetZoom() / 10; } -sal_Int32 SwPostIt::GetMetaButtonAreaWidth() +sal_Int32 SwMarginWin::GetMetaButtonAreaWidth() { const Fraction& f( GetMapMode().GetScaleX() ); if (IsPreview()) @@ -1410,24 +1439,24 @@ sal_Int32 SwPostIt::GetMetaButtonAreaWidth() return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator(); } -sal_Int32 SwPostIt::GetMetaHeight() +sal_Int32 SwMarginWin::GetMetaHeight() { const Fraction& f( GetMapMode().GetScaleY() ); return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator(); } -sal_Int32 SwPostIt::GetMinimumSizeWithMeta() +sal_Int32 SwMarginWin::GetMinimumSizeWithMeta() { return mpMgr->GetMinimumSizeWithMeta(); } -sal_Int32 SwPostIt::GetMinimumSizeWithoutMeta() +sal_Int32 SwMarginWin::GetMinimumSizeWithoutMeta() { const Fraction& f( GetMapMode().GetScaleY() ); return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator(); } -void SwPostIt::SetSpellChecking() +void SwMarginWin::SetSpellChecking() { const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions(); ULONG nCntrl = mpOutliner->GetControlWord(); @@ -1441,16 +1470,22 @@ void SwPostIt::SetSpellChecking() Invalidate(); } -void SwPostIt::SetShadowState(ShadowState bState) +void SwMarginWin::SetViewState(ShadowState bState) { switch (bState) { case SS_EDIT: { - if ( Ankor() ) - Ankor()->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); - if ( Shadow() ) - Shadow()->SetShadowState(SS_EDIT); + if (mpAnkor) + { + mpAnkor->SetAnkorState(AS_ALL); + SwMarginWin* pWin = GetTopReplyNote(); + if (IsFollow() && pWin) + pWin->Ankor()->SetAnkorState(AS_END); + mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + } + if (mpShadow) + mpShadow->SetShadowState(bState); break; } case SS_VIEW: @@ -1458,24 +1493,466 @@ void SwPostIt::SetShadowState(ShadowState bState) if (mpAnkor) mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); if (mpShadow) - mpShadow->SetShadowState(SS_VIEW); + mpShadow->SetShadowState(bState); break; } case SS_NORMAL: { if (mpAnkor) + { + if (IsFollow()) + { + // if there is no visible parent note, we want to see the complete anchor ?? + //if (IsAnyStackParentVisible()) + mpAnkor->SetAnkorState(AS_END); + SwMarginWin* pWin = GetTopReplyNote(); + if (pWin) + pWin->Ankor()->SetAnkorState(AS_ALL); + } mpAnkor->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15)); + } if (mpShadow) - mpShadow->SetShadowState(SS_NORMAL); + mpShadow->SetShadowState(bState); break; } } } -/****** SwPostItShadow ***********************************************************/ +bool SwMarginWin::IsAnyStackParentVisible() +{ + SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this); + while (pMarginWin) + { + if (pMarginWin->IsFollow()) + { + pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin); + if (pMarginWin && pMarginWin->IsVisible()) + return true; + } + else + return pMarginWin && pMarginWin->IsVisible() ? true : false; + } + return false; +} + +SwMarginWin* SwMarginWin::GetTopReplyNote() +{ + SwMarginWin* pTopNote = 0; + SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this); + while (pMarginWin) + { + pTopNote = pMarginWin; + pMarginWin = pMarginWin->IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin) : 0; + } + return pTopNote; +} + +void SwMarginWin::SetPostItText() +{ +} + +void SwMarginWin::SwitchToFieldPos() +{ + if ( Mgr()->GetActivePostIt() == this ) + Mgr()->SetActivePostIt(0); + GotoPos(); + sal_uInt32 aCount = MoveCaret(); + if (aCount) + DocView()->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, FALSE); + GrabFocusToDocument(); +} + +String SwMarginWin::GetAuthor() +{ + return String(EMPTYSTRING); +} + +Date SwMarginWin::GetDate() +{ + return Date(0); +} + +Time SwMarginWin::GetTime() +{ + return Time(0); +} + +SvxLanguageItem SwMarginWin::GetLanguage(void) +{ + return SvxLanguageItem(SwLangHelper::GetLanguage(DocView()->GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE); +} + +/***** SwPostIt *********************************************/ +SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits) + : SwMarginWin(pParent,nBits,aMgr,aBits), + mpFmtFld(aField), + mpFld( static_cast<SwPostItField*>(aField->GetFld())), + mStatus(SwPostItHelper::INVISIBLE) +{ +} + +void SwPostIt::SetPostItText() +{ + // get text from SwPostItField and insert into our textview + Engine()->SetModifyHdl( Link() ); + Engine()->EnableUndo( FALSE ); + mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld()); + if( mpFld->GetTextObject() ) + Engine()->SetText( *mpFld->GetTextObject() ); + else + { + Engine()->Clear(); + SfxItemSet item( DocView()->GetDocShell()->GetPool() ); + item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + View()->SetAttribs(item); + View()->InsertText(mpFld->GetPar2(),false); + } + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); + Engine()->EnableUndo( TRUE ); + Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); + Invalidate(); +} + +void SwPostIt::UpdateData() +{ + if ( Engine()->IsModified() ) + { + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + if ( pPos ) + { + SwField* pOldField = mpFld->Copy(); + mpFld->SetPar2(Engine()->GetEditEngine().GetText()); + mpFld->SetTextObject(Engine()->CreateParaObject()); + DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); + delete pOldField; + delete pPos; + // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) + Mgr()->SetLayout(); + DocView()->GetDocShell()->SetModified(); + } + } + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); +} + +void SwPostIt::SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor) +{ + if ( (mStatus != aStatus) || (mChangeColor != aColor) ) + { + mStatus = aStatus; + mChangeColor = aColor; + Invalidate(); + } +} + +void SwPostIt::Delete() +{ + SwMarginWin::Delete(); + // we delete the field directly, the Mgr cleans up the PostIt by listening + DocView()->GetWrtShellPtr()->GotoField(*mpFmtFld); + GrabFocusToDocument(); + DocView()->GetWrtShellPtr()->DelRight(); +} + +void SwPostIt::GotoPos() +{ + DocView()->GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld); +} + +sal_uInt32 SwPostIt::MoveCaret() +{ + // if this is an answer, do not skip over all following ones, but insert directly behind the current one + // but when just leaving a note, skip all following ones as well to continue typing + return Mgr()->IsAnswer() ? 1 : 1 + CountFollowing(); +} + +//returns true, if there is another note right before this note +bool SwPostIt::CalcFollow() +{ + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); + SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()-1,RES_TXTATR_FIELD ) : 0; + const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; + delete pPos; + return pFld && (pFld->Which()== RES_POSTITFLD); +} + +// counts how many SwPostItField we have right after the current one +sal_uInt32 SwPostIt::CountFollowing() +{ + sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); + + SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()+1,RES_TXTATR_FIELD ) : 0; + SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; + while (pFld && (pFld->Which()== RES_POSTITFLD)) + { + aCount++; + pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex() + aCount,RES_TXTATR_FIELD ) : 0; + pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; + } + delete pPos; + return aCount - 1; +} + +void SwPostIt::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) + { + if (IsPreview()) + { + doLazyDelete(); + if (Mgr()) + { + SwPostIt* pPostIt = dynamic_cast<SwPostIt*>(Mgr()->GetPostIt(mpFmtFld)); + if (pPostIt) + { + pPostIt->GrabFocus(); + Mgr()->MakeVisible(pPostIt); + } + } + + } + else + { + if ( mbReadonly ) + { + mpButtonPopup->EnableItem(FN_REPLY,false); + mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); + mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,false); + mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,false); + } + else + { + if (IsProtected()) + mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); + else + mpButtonPopup->EnableItem(FN_DELETE_NOTE,true); + mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,true); + mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,true); + } + SvtUserOptions aUserOpt; + String sAuthor; + if( !(sAuthor = aUserOpt.GetFullName()).Len()) + if( !(sAuthor = aUserOpt.GetID()).Len() ) + sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); + // do not allow to reply to ourself and no answer possible if this note is in a protected section + if ((sAuthor == GetAuthor()) || (IsProtected())) + mpButtonPopup->EnableItem(FN_REPLY,false); + else + mpButtonPopup->EnableItem(FN_REPLY,true); + + // show the popup menu and execute the selected command + ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) ); + } + } +} + +void SwPostIt::SetPopup() +{ + mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON)); + //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES); + XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR ); + SwRewriter aRewriter; + aRewriter.AddRule(UNDO_ARG1,GetAuthor()); + aText = aRewriter.Apply(aText); + mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); +} + +void SwPostIt::InitAnswer(OutlinerParaObject* pText) +{ + //collect our old meta data + SwMarginWin* pWin = Mgr()->GetNextPostIt(KEY_PAGEUP, this); + const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData(); + String aText = String((SW_RES(STR_REPLY))); + aText.Append(String(pWin->GetAuthor() + rtl::OUString::createFromAscii(" (") + + String(rLocalData.getDate( pWin->GetDate())) + rtl::OUString::createFromAscii(", ") + + String(rLocalData.getTime( pWin->GetTime(),false)) + rtl::OUString::createFromAscii("): \""))); + View()->InsertText(aText,false); + + // insert old, selected text or "..." + // TOOD: iterate over all paragraphs, not only first one to find out if it is empty + if (pText->GetTextObject().GetText(0) != String(EMPTYSTRING)) + View()->GetEditView().InsertText(pText->GetTextObject()); + else + View()->InsertText(rtl::OUString::createFromAscii("..."),false); + View()->InsertText(rtl::OUString::createFromAscii("\"\n"),false); + + View()->SetSelection(ESelection(0x0,0x0,0xFFFF,0xFFFF)); + SfxItemSet aAnswerSet( DocView()->GetDocShell()->GetPool() ); + aAnswerSet.Put(SvxFontHeightItem(200,80,EE_CHAR_FONTHEIGHT)); + aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC)); + View()->SetAttribs(aAnswerSet); + View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); + + //remove all attributes and reset our standard ones + View()->GetEditView().RemoveAttribsKeepLanguages(true); + SfxItemSet aNormalSet( DocView()->GetDocShell()->GetPool() ); + aNormalSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + aNormalSet.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + View()->SetAttribs(aNormalSet); + // lets insert an undo step so the initial text can be easily deleted + // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr + Engine()->SetModifyHdl( Link() ); + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + if ( pPos ) + { + SwField* pOldField = mpFld->Copy(); + mpFld->SetPar2(Engine()->GetEditEngine().GetText()); + mpFld->SetTextObject(Engine()->CreateParaObject()); + DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); + delete pOldField; + delete pPos; + } + Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); +} + +SvxLanguageItem SwPostIt::GetLanguage(void) +{ + // set initial language for outliner + USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() ); + USHORT nLangWhichId = 0; + switch (nScriptType) + { + case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break; + case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; + case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; + default: DBG_ERROR("GetLanguage: wrong script tye"); + } + return SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId); +} + +bool SwPostIt::IsProtected() +{ + bool aReturn; + aReturn = mpFmtFld ? (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED) || + mpFmtFld->IsProtect()) : (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED)); + return aReturn; +} + +/********** SwRedComment**************/ +/* +SwRedComment::SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed) + : SwMarginWin(pParent,nBits,aMgr,aBits), + pRedline(pRed) +{ +} + +void SwRedComment::SetPopup() +{ + mpButtonPopup = new PopupMenu(SW_RES(MN_REDCOMMENT_BUTTON)); + //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES); +} + +void SwRedComment::UpdateData() +{ + if ( Engine()->IsModified() ) + { + // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) + Mgr()->SetLayout(); + // SetRedline is calling SetModified already + DocView()->GetWrtShell().SetRedlineComment(Engine()->GetEditEngine().GetText()); + } + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); +} + +void SwRedComment::SetPostItText() +{ + Engine()->SetModifyHdl( Link() ); + Engine()->EnableUndo( FALSE ); + + Engine()->Clear(); + SfxItemSet item( DocView()->GetDocShell()->GetPool() ); + item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + View()->SetAttribs(item); + View()->InsertText(pRedline->GetComment(),false); + + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); + Engine()->EnableUndo( TRUE ); + Engine()->SetModifyHdl( LINK( this, SwMarginWin, ModifyHdl ) ); + Invalidate(); +} + +void SwRedComment::DeactivatePostIt() +{ + SwMarginWin::DeactivatePostIt(); + // current Redline is still selected + DocView()->GetWrtShellPtr()->ClearMark(); +} + +void SwRedComment::ActivatePostIt() +{ + SwMarginWin::ActivatePostIt(); + + // do we want the redline selected? + // otherwise, SwRedComment::ActivatePostIt() as well as SwRedComment::DeactivatePostIt() + // can be thrown out completly + DocView()->GetDocShell()->GetWrtShell()->GotoRedline( + DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()),true); +} + +void SwRedComment::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) + { + ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) ); + } +} + +void SwRedComment::Delete() +{ + SwMarginWin::Delete(); + // we are not neccessarily on our redline, so let's move there + GotoPos(); + DocView()->GetWrtShell().SetRedlineComment(EMPTYSTRING); + DocView()->GetWrtShell().ClearMark(); + // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) + Mgr()->SetLayout(); + Mgr()->RemoveItem(pRedline); +} + +void SwRedComment::GotoPos() +{ + DocView()->GetDocShell()->GetWrtShell()->GotoRedline( + DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData())); +} + +String SwRedComment::GetAuthor() +{ + return pRedline->GetAuthorString(); +} + +Date SwRedComment::GetDate() +{ + return pRedline->GetTimeStamp().GetDate(); +} + +Time SwRedComment::GetTime() +{ + return pRedline->GetTimeStamp().GetTime(); +} + +bool SwRedComment::IsProtected() +{ + return SwMarginWin::IsProtected() || pRedline->Start()->nNode.GetNode().GetTxtNode()->IsInProtectSect(); +} +*/ + +/****** SwPostItShadow ***********************************************************/ SwPostItShadow::SwPostItShadow(const basegfx::B2DPoint& rBasePos,const basegfx::B2DPoint& rSecondPosition, - Color aBaseColor,ShadowState aState) + Color aBaseColor,ShadowState aState) : OverlayObjectWithBasePosition(rBasePos, aBaseColor), maSecondPosition(rSecondPosition), mShadowState(aState) @@ -1627,26 +2104,42 @@ void SwPostItAnkor::implDrawGeometry(OutputDevice& rOutputDevice, Color aColor, aLin.transform(aTranslate); } - // draw triangle - rOutputDevice.SetLineColor(); - rOutputDevice.SetFillColor(aColor); - rOutputDevice.DrawPolygon(Polygon(aTri)); - - /* - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate(-aTri.getB2DPoint(0).getX(),-aTri.getB2DPoint(0).getY()); - aMatrix.scale(1.0, -1.0); - aMatrix.translate(aTri.getB2DPoint(0).getX(),aTri.getB2DPoint(0).getY()); - aMatrix.translate(0,(mHeight*-1) + 13 * 15 ); - aTri.transform(aMatrix); - rOutputDevice.DrawPolygon(Polygon(aTri)); - */ - - // draw line - rOutputDevice.SetLineColor(aColor); - rOutputDevice.SetFillColor(); - rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); - rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + switch (mAnkorState) + { + case AS_ALL: + { + rOutputDevice.SetLineColor(); + rOutputDevice.SetFillColor(aColor); + //rOutputDevice.DrawTransparent(Polygon(aTri), 50); + rOutputDevice.DrawPolygon(Polygon(aTri)); + + // draw line + rOutputDevice.SetLineColor(aColor); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); + rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + break; + } + case AS_START: + { + rOutputDevice.SetLineColor(); + rOutputDevice.SetFillColor(aColor); + rOutputDevice.DrawPolygon(Polygon(aTri)); + // draw line + rOutputDevice.SetLineColor(aColor); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); + break; + } + case AS_END: + { + // draw line + rOutputDevice.SetLineColor(aColor); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + break; + } + } } Color SwPostItAnkor::implBlendColor(const Color aOriginal, sal_Int16 nChange) @@ -1703,7 +2196,8 @@ SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos, maLineTop(), mLineInfo(aLineInfo), mHeight(0), - mbShadowedEffect(bShadowedEffect) + mbShadowedEffect(bShadowedEffect), + mAnkorState(AS_ALL) { if (mLineInfo.GetStyle()==LINE_DASH) { @@ -1881,3 +2375,12 @@ void SwPostItAnkor::SetLineInfo(const LineInfo &aLineInfo) objectChange(); } } + +void SwPostItAnkor::SetAnkorState(AnkorState aState) +{ + if (mAnkorState != aState) + { + mAnkorState = aState; + objectChange(); + } +} diff --git a/sw/source/ui/inc/annotsh.hxx b/sw/source/ui/inc/annotsh.hxx index 710fbc59c83b..e6498ec24ce6 100755 --- a/sw/source/ui/inc/annotsh.hxx +++ b/sw/source/ui/inc/annotsh.hxx @@ -70,6 +70,10 @@ public: void InsertSymbol(SfxRequest& rReq); + void ExecSearch(SfxRequest&, BOOL bNoMessage = FALSE); + void StateSearch(SfxItemSet &); + + virtual SfxUndoManager* GetUndoManager(); }; diff --git a/sw/source/ui/inc/content.hxx b/sw/source/ui/inc/content.hxx index 239e1c780c84..7990214d0616 100644 --- a/sw/source/ui/inc/content.hxx +++ b/sw/source/ui/inc/content.hxx @@ -42,6 +42,7 @@ class SwContentType; class SwFmtFld; class SwTxtINetFmt; class SwTOXBase; +class SwRedline; //---------------------------------------------------------------------------- // Hilfsklassen @@ -120,20 +121,29 @@ public: }; //---------------------------------------------------------------------------- - class SwPostItContent : public SwContent { const SwFmtFld* pFld; + SwRedline* pRedline; + bool mbPostIt; public: SwPostItContent( const SwContentType* pCnt, const String& rName, const SwFmtFld* pField, long nYPos ) - : SwContent( pCnt, rName, nYPos ), pFld( pField ) + : SwContent( pCnt, rName, nYPos ), pFld( pField ),mbPostIt(true) + {} + SwPostItContent( const SwContentType* pCnt, + const String& rName, + SwRedline* pRed, + long nYPos ) + : SwContent( pCnt, rName, nYPos ), pRedline( pRed ),mbPostIt(false) {} const SwFmtFld* GetPostIt() { return pFld; } - virtual BOOL IsProtect() const; + SwRedline* GetRedline() { return pRedline; } + virtual BOOL IsProtect() const; + bool IsPostIt() {return mbPostIt; } }; //---------------------------------------------------------------------------- diff --git a/sw/source/ui/inc/popup.hrc b/sw/source/ui/inc/popup.hrc index 40961f35ee24..ea891a982273 100644 --- a/sw/source/ui/inc/popup.hrc +++ b/sw/source/ui/inc/popup.hrc @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: popup.hrc,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.190.1 $ * * This file is part of OpenOffice.org. * @@ -49,6 +49,8 @@ #define MN_LANGUAGE_FOR_DOCUMENT (RC_POPUPS_BEGIN + 13) #define MN_ANNOTATION_POPUPMENU (RC_POPUPS_BEGIN + 14) #define MN_ANNOTATION_BUTTON (RC_POPUPS_BEGIN + 15) +#define MN_REDCOMMENT_POPUPMENU (RC_POPUPS_BEGIN + 16) +#define MN_REDCOMMENT_BUTTON (RC_POPUPS_BEGIN + 17) #if MN_MEDIA_POPUPMENU > RC_POPUPS_END diff --git a/sw/source/ui/inc/textsh.hxx b/sw/source/ui/inc/textsh.hxx index fd79ac2c51ed..73a173e9aad1 100644 --- a/sw/source/ui/inc/textsh.hxx +++ b/sw/source/ui/inc/textsh.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: textsh.hxx,v $ - * $Revision: 1.16 $ + * $Revision: 1.16.188.1 $ * * This file is part of OpenOffice.org. * diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 6365620ba097..81f1173d6814 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -659,6 +659,8 @@ public: Graphic* pPreviewGrf = 0, BOOL bRule = FALSE ); + void ExecuteScan( SfxRequest& rReq ); + SwPostItMgr* GetPostItMgr() { return mpPostItMgr;} const SwPostItMgr* GetPostItMgr() const { return mpPostItMgr;} }; diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index 0cef2075de20..fcccff415eb2 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -377,6 +377,7 @@ typedef BOOL (SwWrtShell:: *FNSimpleMove)(); //Suchen oder Ersetzen ULONG SearchPattern(const com::sun::star::util::SearchOptions& rSearchOpt, + BOOL bSearchInNotes, SwDocPositions eStart, SwDocPositions eEnde, FindRanges eFlags = FND_IN_BODY, int bReplace = FALSE ); diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index ab6e219d8a25..bbe0ed10bbaf 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -536,7 +536,10 @@ static void lcl_SelectSameStrings(SwWrtShell& rSh, BOOL bWordOnly, BOOL bCaseSen rSh.ClearMark(); BOOL bCancel; - rSh.Find( aSearchOpt, DOCPOS_START, DOCPOS_END, bCancel, + + //todo/mba: assuming that notes should not be searched + BOOL bSearchInNotes = FALSE; + rSh.Find( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END, bCancel, (FindRanges)(FND_IN_SELALL|FND_IN_BODYONLY), FALSE ); } diff --git a/sw/source/ui/misc/redlndlg.cxx b/sw/source/ui/misc/redlndlg.cxx index 0376bdd7f870..a0da69f942e5 100644 --- a/sw/source/ui/misc/redlndlg.cxx +++ b/sw/source/ui/misc/redlndlg.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: redlndlg.cxx,v $ - * $Revision: 1.29 $ + * $Revision: 1.29.190.1 $ * * This file is part of OpenOffice.org. * @@ -90,6 +90,7 @@ #include <unomid.h> +#include <docsh.hxx> #include <IDocumentRedlineAccess.hxx> @@ -1247,18 +1248,25 @@ IMPL_LINK( SwRedlineAcceptDlg, CommandHdl, void*, EMPTYARG ) switch( nRet ) { - case MN_EDIT_COMMENT: + case MN_EDIT_COMMENT: { String sComment; - if (pEntry) { if (pTable->GetParent(pEntry)) pEntry = pTable->GetParent(pEntry); USHORT nPos = GetRedlinePos(*pEntry); - const SwRedline &rRedline = pSh->GetRedline(nPos); + + + /* enable again once we have redline comments in the margin + sComment = rRedline.GetComment(); + if ( sComment == String(::rtl::OUString::createFromAscii("")) ) + GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED)); + const_cast<SwRedline&>(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS)); + */ + sComment = rRedline.GetComment(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); DBG_ASSERT(pFact, "Dialogdiet fail!"); @@ -1316,6 +1324,7 @@ IMPL_LINK( SwRedlineAcceptDlg, CommandHdl, void*, EMPTYARG ) delete pDlg; pSh->SetCareWin(NULL); } + } break; @@ -1410,5 +1419,3 @@ void SwRedlineAcceptDlg::FillInfo(String &rExtraData) const } rExtraData += ')'; } - - diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index aa63e682c06d..cdb4c04f6e65 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: annotsh.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.7.82.3 $ * * This file is part of OpenOffice.org. * @@ -67,6 +67,8 @@ #include <svx/svdoutl.hxx> #include <svtools/whiter.hxx> #include <svtools/cjkoptions.hxx> +#include <svtools/ctloptions.hxx> +#include <svtools/useroptions.hxx> #include <vcl/msgbox.hxx> #include <svx/flditem.hxx> #include <svx/editstat.hxx> @@ -88,6 +90,8 @@ #include <swmodule.hxx> #include <initui.hxx> #include <edtwin.hxx> +#include <swwait.hxx> +#include <docstat.hxx> #include <cmdid.h> #include <globals.hrc> @@ -118,6 +122,10 @@ #include <svtools/undo.hxx> #include "swabstdlg.hxx" //CHINA001 #include "chrdlg.hrc" //CHINA001 +#include "misc.hrc" +#include <app.hrc> + +#include <comphelper/processfactory.hxx> #include <cppuhelper/bootstrap.hxx> @@ -133,10 +141,8 @@ using namespace ::com::sun::star::i18n; #include <itemdef.hxx> #include <swslots.hxx> - SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT)) { - //SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TEXT_TOOLBOX)); SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX)); SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU)); } @@ -316,12 +322,106 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) } break; } + case FN_INSERT_SOFT_HYPHEN: + case FN_INSERT_HARDHYPHEN: + case FN_INSERT_HARD_SPACE: + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + sal_Unicode cIns = 0; + switch(rReq.GetSlot()) + { + case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; + case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break; + case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break; + case SID_INSERT_RLM : cIns = CHAR_RLM ; break; + case SID_INSERT_LRM : cIns = CHAR_LRM ; break; + case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; + case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; + } + pOLV->InsertText( String(cIns), TRUE ); + rReq.Done(); + break; + } case FN_INSERT_SYMBOL: { if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) InsertSymbol(rReq); break; } + case FN_INSERT_STRING: + { + const SfxPoolItem* pItem = 0; + if(pNewAttrs) + pNewAttrs->GetItemState(nSlot, FALSE, &pItem ); + if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) + pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue()); + break; + } + + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( rView.GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + rView.GetWindow(), &aTmp, rView.GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwWrtShell &rSh = rView.GetWrtShell(); + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *rView.GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( rView.GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; case SID_CHAR_DLG: { const SfxItemSet* pArgs = rReq.GetArgs(); @@ -640,6 +740,18 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet) } } break; + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + SvtCTLOptions aCTLOptions; + sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); + rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); + if(!bEnabled) + rSet.DisableItem(nWhich); + } + break; default: rSet.InvalidateItem( nWhich ); break; @@ -655,6 +767,16 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet) } } +void SwAnnotationShell::ExecSearch(SfxRequest& rReq, BOOL bNoMessage) +{ + rView.ExecSearch(rReq,bNoMessage); +} + +void SwAnnotationShell::StateSearch(SfxItemSet &rSet) +{ + rView.StateSearch(rSet); +} + void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq) { SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); @@ -874,9 +996,12 @@ void SwAnnotationShell::NoteExec(SfxRequest &rReq) sal_uInt16 nSlot = rReq.GetSlot(); switch (nSlot) { + case FN_REPLY: + case FN_POSTIT: + case FN_DELETE_COMMENT: case FN_DELETE_NOTE: if ( pPostItMgr->GetActivePostIt() ) - pPostItMgr->GetActivePostIt()->Delete(); + pPostItMgr->GetActivePostIt()->ExecuteCommand(nSlot); break; case FN_DELETE_ALL_NOTES: pPostItMgr->Delete(); @@ -889,8 +1014,15 @@ void SwAnnotationShell::NoteExec(SfxRequest &rReq) break; } case FN_HIDE_NOTE: - if ( pPostItMgr->GetActivePostIt() ) - pPostItMgr->GetActivePostIt()->Hide(); + /* + if ( Mgr()->GetActivePostIt() == this ) + { + Mgr()->SetActivePostIt(0); + // put the cursor back into the document + SwitchToFieldPos(); + } + Mgr()->Hide(mpFld); + */ break; case FN_HIDE_ALL_NOTES: pPostItMgr->Hide(); @@ -914,24 +1046,49 @@ void SwAnnotationShell::GetNoteState(SfxItemSet &rSet) USHORT nSlotId = GetPool().GetSlotId( nWhich ); switch( nSlotId ) { + case FN_POSTIT: case FN_DELETE_NOTE: case FN_DELETE_NOTE_AUTHOR: case FN_DELETE_ALL_NOTES: case FN_HIDE_NOTE: case FN_HIDE_NOTE_AUTHOR: case FN_HIDE_ALL_NOTES: + { + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() || !pPostItMgr->GetActivePostIt()->ISA(SwPostIt)) + rSet.DisableItem(nWhich); + break; + } + case FN_DELETE_COMMENT: + { + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) //|| !pPostItMgr->GetActivePostIt()->ISA(SwRedComment)) + rSet.DisableItem(nWhich); + break; + } + case FN_REPLY: + { + if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() || !pPostItMgr->GetActivePostIt()->ISA(SwPostIt)) + rSet.DisableItem(nWhich); + else { - if ( !pPostItMgr || !pPostItMgr->GetActivePostIt() ) - rSet.InvalidateItem( nWhich ); + SvtUserOptions aUserOpt; + String sAuthor; + if( !(sAuthor = aUserOpt.GetFullName()).Len()) + if( !(sAuthor = aUserOpt.GetID()).Len() ) + sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); + if (sAuthor == pPostItMgr->GetActivePostIt()->GetAuthor()) + rSet.DisableItem(nWhich); } break; + } default: rSet.InvalidateItem( nWhich ); break; } - if ( (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) && (nSlotId==FN_DELETE_NOTE) ) - rSet.DisableItem( nWhich ); + if ( (pPostItMgr->GetActivePostIt()->IsProtected()) && + //if ( (pPostItMgr->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED) && + ( (nSlotId==FN_DELETE_NOTE) || (nSlotId==FN_REPLY) ) ) + rSet.DisableItem( nWhich ); nWhich = aIter.NextWhich(); } diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx index 46c442fe9d27..e616126f8b1c 100644 --- a/sw/source/ui/shells/drawsh.cxx +++ b/sw/source/ui/shells/drawsh.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: drawsh.cxx,v $ - * $Revision: 1.20 $ + * $Revision: 1.20.190.1 $ * * This file is part of OpenOffice.org. * @@ -47,10 +47,14 @@ #include <svx/fontworkbar.hxx> #include <svx/tbxcustomshapes.hxx> #include <uitool.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <swmodule.hxx> +#include <swwait.hxx> +#include <docstat.hxx> +#include <IDocumentStatistics.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <svx/xtable.hxx> @@ -67,7 +71,11 @@ #define SwDrawShell #include "itemdef.hxx" #include "swslots.hxx" +#include "swabstdlg.hxx" //CHINA001 +#include "misc.hrc" +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW)) { @@ -189,7 +197,66 @@ void SwDrawShell::Execute(SfxRequest &rReq) pVFrame->GetBindings().Invalidate(SID_FONTWORK); } break; + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *GetView().GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; case SID_EXTRUSION_TOOGLE: case SID_EXTRUSION_TILT_DOWN: case SID_EXTRUSION_TILT_UP: diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index f09a3d6a7dad..016f27dca10e 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: drwtxtex.cxx,v $ - * $Revision: 1.46 $ + * $Revision: 1.46.82.1 $ * * This file is part of OpenOffice.org. * @@ -61,6 +61,7 @@ #include <sfx2/viewfrm.hxx> #include <svtools/whiter.hxx> #include <svtools/cjkoptions.hxx> +#include <svtools/ctloptions.hxx> #include <sfx2/bindings.hxx> #include <vcl/msgbox.hxx> #include <sfx2/dispatch.hxx> @@ -84,19 +85,18 @@ #include <swmodule.hxx> #include <initui.hxx> // fuer SpellPointer #include <edtwin.hxx> +#include <swwait.hxx> +#include <docstat.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif - #include "swabstdlg.hxx" #include "chrdlg.hrc" +#include "misc.hrc" //modified on Jul. 30th #include <svtools/languageoptions.hxx> @@ -124,9 +124,8 @@ using namespace ::com::sun::star; void SwDrawTextShell::Execute( SfxRequest &rReq ) { SwWrtShell &rSh = GetShell(); - - OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); - SfxItemSet aEditAttr(pOLV->GetAttribs()); + OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + SfxItemSet aEditAttr(pOLV->GetAttribs()); SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); sal_uInt16 nSlot = rReq.GetSlot(); @@ -298,7 +297,66 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) aNewAttr.Put(*pArgs); } break; + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + } + break; + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *GetView().GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; case SID_PARA_DLG: { const SfxItemSet* pArgs = rReq.GetArgs(); @@ -663,6 +721,18 @@ ASK_ESCAPE: GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); } break; + case SID_INSERT_RLM : + case SID_INSERT_LRM : + case SID_INSERT_ZWNBSP : + case SID_INSERT_ZWSP: + { + SvtCTLOptions aCTLOptions; + sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); + GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); + if(!bEnabled) + rSet.DisableItem(nWhich); + } + break; default: nSlotId = 0; // don't know this slot break; diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index f2381dbc8ff3..e033f7c7c3f7 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: drwtxtsh.cxx,v $ - * $Revision: 1.42 $ + * $Revision: 1.42.190.1 $ * * This file is part of OpenOffice.org. * @@ -110,7 +110,8 @@ #include <cppuhelper/bootstrap.hxx> - +#include "swabstdlg.hxx" //CHINA001 +#include "misc.hrc" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -494,9 +495,6 @@ void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq) /*-------------------------------------------------------------------- Beschreibung: --------------------------------------------------------------------*/ - - - void SwDrawTextShell::ExecDraw(SfxRequest &rReq) { SwWrtShell &rSh = GetShell(); @@ -528,9 +526,23 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq) rReq.Done(); } break; - case FN_INSERT_SYMBOL: // Sonderzeichen einfuegen + case FN_INSERT_SYMBOL: + { // Sonderzeichen einfuegen InsertSymbol(rReq); break; + } + case FN_INSERT_STRING: + { + const SfxItemSet *pNewAttrs = rReq.GetArgs(); + sal_uInt16 nSlot = rReq.GetSlot(); + const SfxPoolItem* pItem = 0; + if(pNewAttrs) + { + pNewAttrs->GetItemState(nSlot, FALSE, &pItem ); + pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue()); + } + break; + } case SID_SELECTALL: { @@ -544,7 +556,7 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq) } break; - case FN_FORMAT_RESET: // Harte Textattributierung l�schen + case FN_FORMAT_RESET: // delete hard text attributes { pOLV->RemoveAttribsKeepLanguages( true ); pOLV->GetEditView().GetEditEngine()->RemoveFields(TRUE); @@ -564,7 +576,6 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq) return; } break; - case FN_DRAWTEXT_ATTR_DLG: { SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() ); diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx index 550a4524ed96..4df31175e1aa 100644 --- a/sw/source/ui/shells/frmsh.cxx +++ b/sw/source/ui/shells/frmsh.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: frmsh.cxx,v $ - * $Revision: 1.22 $ + * $Revision: 1.22.190.1 $ * * This file is part of OpenOffice.org. * @@ -70,24 +70,23 @@ #include <usrpref.hxx> #include <edtwin.hxx> #include <swdtflvr.hxx> +#include <swwait.hxx> +#include <docstat.hxx> +#include <IDocumentStatistics.hxx> + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif -#ifndef _POPUP_HRC #include <popup.hrc> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif #include "swabstdlg.hxx" +#include "misc.hrc" + using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; // Prototypen ------------------------------------------------------------ @@ -236,7 +235,66 @@ void SwFrameShell::Execute(SfxRequest &rReq) rSh.Unchain( (SwFrmFmt&)*rSh.GetFlyFrmFmt() ); GetView().GetViewFrame()->GetBindings().Invalidate(FN_FRAME_CHAIN); break; + case FN_FORMAT_FOOTNOTE_DLG: + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + break; + } + case FN_NUMBERING_OUTLINE_DLG: + { + SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + pDlg->Execute(); + delete pDlg; + rReq.Done(); + break; + } + case SID_OPEN_XML_FILTERSETTINGS: + { + try + { + uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); + if( xDialog.is() ) + { + xDialog->execute(); + } + } + catch( uno::Exception& ) + { + } + rReq.Ignore (); + } + break; + case FN_WORDCOUNT_DIALOG: + { + SwDocStat aCurr; + SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); + { + SwWait aWait( *GetView().GetDocShell(), TRUE ); + rSh.StartAction(); + rSh.CountWords( aCurr ); + rSh.UpdateDocStat( aDocStat ); + rSh.EndAction(); + } + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); + pDialog->SetValues(aCurr, aDocStat ); + pDialog->Execute(); + delete pDialog; + } + break; default: bMore = TRUE; } diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index 10858ab1e68f..026e22a228c4 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -86,12 +86,8 @@ #include <usrpref.hxx> #include <edtwin.hxx> #include <swwait.hxx> -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif -#ifndef _POPUP_HRC #include <popup.hrc> -#endif #define SwGrfShell #include "itemdef.hxx" @@ -114,6 +110,11 @@ void SwGrfShell::Execute(SfxRequest &rReq) USHORT nSlot = rReq.GetSlot(); switch(nSlot) { + case SID_TWAIN_TRANSFER: + { + GetView().ExecuteScan( rReq ); + break; + } case FN_SAVE_GRAPHIC: { const Graphic *pGraphic; @@ -383,8 +384,8 @@ void SwGrfShell::ExecAttr( SfxRequest &rReq ) switch( nSlot ) { - case FN_FLIP_VERT_GRAFIC: - case FN_FLIP_HORZ_GRAFIC: + case FN_FLIP_VERT_GRAFIC: + case FN_FLIP_HORZ_GRAFIC: { GetShell().GetCurAttr( aGrfSet ); SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get( @@ -475,7 +476,6 @@ void SwGrfShell::ExecAttr( SfxRequest &rReq ) aToolboxAccess.toggleToolbox(); break; } - case SID_GRFFILTER: case SID_GRFFILTER_INVERT: case SID_GRFFILTER_SMOOTH: @@ -534,7 +534,11 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet) BOOL bDisable = bParentCntProt; switch( nWhich ) { + case SID_INSERT_GRAPHIC: case FN_FORMAT_GRAFIC_DLG: + case SID_TWAIN_TRANSFER: + if( bParentCntProt || !bIsGrfCntnt ) + bDisable = TRUE; break; case FN_SAVE_GRAPHIC: if( rSh.GetGraphicType() == GRAPHIC_NONE ) diff --git a/sw/source/ui/shells/makefile.mk b/sw/source/ui/shells/makefile.mk index 9dfec26cddfc..2e4a96c990bf 100644 --- a/sw/source/ui/shells/makefile.mk +++ b/sw/source/ui/shells/makefile.mk @@ -81,7 +81,11 @@ EXCEPTIONSFILES = \ $(SLO)$/drwtxtsh.obj \ $(SLO)$/textsh.obj \ $(SLO)$/textsh2.obj \ - $(SLO)$/grfshex.obj \ + $(SLO)$/grfshex.obj \ + $(SLO)$/drawsh.obj \ + $(SLO)$/drwtxtsh.obj \ + $(SLO)$/frmsh.obj \ + $(SLO)$/drwtxtex.obj \ $(SLO)$/textsh1.obj # --- Tagets ------------------------------------------------------- diff --git a/sw/source/ui/shells/textfld.cxx b/sw/source/ui/shells/textfld.cxx index 97a331201751..d4556b89d14f 100644 --- a/sw/source/ui/shells/textfld.cxx +++ b/sw/source/ui/shells/textfld.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: textfld.cxx,v $ - * $Revision: 1.38 $ + * $Revision: 1.38.190.2 $ * * This file is part of OpenOffice.org. * @@ -37,9 +37,7 @@ #include <sfx2/lnkbase.hxx> #include <fmtfld.hxx> #include <tools/urlobj.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/itempool.hxx> #include <svtools/useroptions.hxx> #include <svtools/whiter.hxx> @@ -57,19 +55,14 @@ #include <fmtinfmt.hxx> #include <fldwrap.hxx> #include <redline.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <wrtsh.hxx> #include <flddat.hxx> #include <numrule.hxx> -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif +#include <docsh.hxx> #include <docufld.hxx> #include <usrfld.hxx> #include <ddefld.hxx> @@ -77,12 +70,8 @@ #include <fldmgr.hxx> #include <uitool.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif #include <sfx2/app.hxx> #include <svx/svxdlg.hxx> @@ -92,9 +81,7 @@ #include <fldui.hrc> #include <doc.hxx> -#ifndef _APP_HRC #include <app.hrc> -#endif #include "PostItMgr.hxx" #include "postit.hxx" @@ -334,7 +321,6 @@ void SwTextShell::ExecField(SfxRequest &rReq) rReq.Ignore(); } break; - case FN_DELETE_NOTE: if ( GetView().GetPostItMgr() && GetView().GetPostItMgr()->GetActivePostIt() ) GetView().GetPostItMgr()->GetActivePostIt()->Delete(); @@ -369,7 +355,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) { SwPostItField* pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); BOOL bNew = !(pPostIt && pPostIt->GetTyp()->Which() == RES_POSTITFLD); - if (bNew) + if (bNew || GetView().GetPostItMgr()->IsAnswer()) { SvtUserOptions aUserOpt; String sAuthor; @@ -388,10 +374,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, FALSE); pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); rSh.Pop(FALSE); // Cursorpos restaurieren - } - else - { - } + } if (pPostIt) { @@ -413,6 +396,20 @@ void SwTextShell::ExecField(SfxRequest &rReq) break; case FN_REDLINE_COMMENT: { + /* this code can be used once we want redline comments in the margin, all other stuff can + then be deleted + String sComment; + const SwRedline *pRedline = rSh.GetCurrRedline(); + + if (pRedline) + { + sComment = pRedline->GetComment(); + if ( sComment == String(rtl::OUString::createFromAscii("")) ) + GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); + const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS)); + } + */ + String sComment; const SwRedline *pRedline = rSh.GetCurrRedline(); @@ -792,10 +789,6 @@ void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem) } } -/*-------------------------------------------------------------------- - Beschreibung: Traveling zwischen Redlines - --------------------------------------------------------------------*/ - IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog *, pBtn ) { SwWrtShell* pSh = GetShellPtr(); @@ -851,10 +844,6 @@ IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog *, pBtn ) return 0; } -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog *, pBtn ) { SwWrtShell* pSh = GetShellPtr(); @@ -905,4 +894,3 @@ IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog *, pBtn ) } - diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 123247c8a164..92fee69b7bb6 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: textsh1.cxx,v $ - * $Revision: 1.70 $ + * $Revision: 1.70.84.1 $ * * This file is part of OpenOffice.org. * @@ -32,16 +32,10 @@ #include "precompiled_sw.hxx" #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <comphelper/processfactory.hxx> -#ifndef _SVX_DIALOGS_HRC #include <svx/dialogs.hrc> -#endif #include <hintids.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif #include <i18npool/mslangid.hxx> #include <svtools/languageoptions.hxx> @@ -63,9 +57,7 @@ #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> #include <svx/colritem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/brshitem.hxx> #include <svx/svxacorr.hxx> #include <svtools/cjkoptions.hxx> @@ -78,18 +70,14 @@ #include <fmtinfmt.hxx> #include <swwait.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <swmodule.hxx> #include <viewopt.hxx> #include <uitool.hxx> #include <swevent.hxx> #include <fmthdft.hxx> #include <pagedesc.hxx> -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif #include <bookmrk.hxx> #include <swdtflvr.hxx> #include <docstat.hxx> @@ -97,41 +85,24 @@ #include <tablemgr.hxx> #include <swundo.hxx> // fuer Undo-IDs #include <reffld.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <mdiexp.hxx> -#ifndef _INPUTWIN_HXX #include <inputwin.hxx> -#endif -#ifndef _PARDLG_HXX #include <pardlg.hxx> -#endif #include <frmatr.hxx> #include <fmtcol.hxx> #include <cellatr.hxx> #include <edtwin.hxx> -#ifndef _REDLNDLG_HXX #include <redlndlg.hxx> -#endif #include "fldmgr.hxx" -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif -#ifndef _APP_HRC #include <app.hrc> -#endif -#ifndef _WEB_HRC #include <web.hrc> -#endif #include "paratr.hxx" #include <crsskip.hxx> #include <docstat.hxx> -#include <swwait.hxx> #include <vcl/svapp.hxx> #include <sfx2/app.hxx> #include <breakit.hxx> diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 11d0ee0f0f36..be87729e2296 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -101,30 +101,20 @@ #include <svx/svdview.hxx> #include <swtypes.hxx> #include <swwait.hxx> -#ifndef _REDLNDLG_HXX #include <redlndlg.hxx> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <uivwimp.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <doc.hxx> #include <wrtsh.hxx> #include <viewopt.hxx> -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <swmodule.hxx> #include <uitool.hxx> #include <shellio.hxx> #include <fmtinfmt.hxx> #include <mdiexp.hxx> -#ifndef _DRAWBASE_HXX #include <drawbase.hxx> -#endif #include <frmmgr.hxx> #include <pagedesc.hxx> #include <section.hxx> @@ -135,53 +125,25 @@ #include <workctrl.hxx> #include <scroll.hxx> #include <edtwin.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif -#ifndef _TABSH_HXX #include <tabsh.hxx> -#endif -#ifndef _LISTSH_HXX #include <listsh.hxx> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> -#endif -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif #include <swerror.h> -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif -#ifndef _WEB_HRC #include <web.hrc> -#endif -#ifndef _VIEW_HRC #include <view.hrc> -#endif -#ifndef _APP_HRC #include <app.hrc> -#endif #include <fmtclds.hxx> #include <helpid.h> #include <svtools/templdlg.hxx> #include <dbconfig.hxx> -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <PostItMgr.hxx> #include <postit.hxx> @@ -190,7 +152,6 @@ // #include <frmmgr.hxx> // #endif - #include <comphelper/processfactory.hxx> #include <svx/svxdlg.hxx> @@ -1895,7 +1856,9 @@ BOOL SwView::JumpToSwMark( const String& rMark ) 0,0,0, TransliterationModules_IGNORE_CASE ); - if( pWrtShell->SearchPattern( aSearchOpt, DOCPOS_START, DOCPOS_END )) + //todo/mba: assuming that notes shouldn't be searched + BOOL bSearchInNotes = FALSE; + if( pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END )) { pWrtShell->EnterStdMode(); // Selektion wieder aufheben bRet = TRUE; @@ -2440,3 +2403,9 @@ IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) return 0; } +void SwView::ExecuteScan( SfxRequest& rReq ) +{ + if (pViewImpl) + pViewImpl->ExecuteScan(rReq) ; +} + diff --git a/sw/source/ui/uiview/viewmdi.cxx b/sw/source/ui/uiview/viewmdi.cxx index bc044d651959..75484a21713d 100644 --- a/sw/source/ui/uiview/viewmdi.cxx +++ b/sw/source/ui/uiview/viewmdi.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: viewmdi.cxx,v $ - * $Revision: 1.24 $ + * $Revision: 1.24.140.1 $ * * This file is part of OpenOffice.org. * @@ -491,7 +491,7 @@ IMPL_STATIC_LINK( SwView, MoveNavigationHdl, bool *, pbNext ) break; case NID_POSTIT: { - SwPostIt* pPostIt = pThis->GetPostItMgr()->GetActivePostIt(); + SwMarginWin* pPostIt = pThis->GetPostItMgr()->GetActivePostIt(); if (pPostIt) pThis->GetPostItMgr()->SetActivePostIt(0); SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD); diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx index 928069ee0a82..a6369123f5d0 100644 --- a/sw/source/ui/uiview/viewsrch.cxx +++ b/sw/source/ui/uiview/viewsrch.cxx @@ -225,7 +225,6 @@ void SwView::ExecSearch(SfxRequest& rReq, BOOL bNoMessage) pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone(); } } - switch (pSrchItem->GetCommand()) { case SVX_SEARCHCMD_FIND: @@ -606,6 +605,8 @@ void SwView::Replace() } else { + if (GetPostItMgr()->GetActivePostIt()) + GetPostItMgr()->Replace(pSrchItem); pWrtShell->SwEditShell::Replace( pSrchItem->GetReplaceString(), pSrchItem->GetRegExp()); @@ -717,7 +718,7 @@ ULONG SwView::FUNC_Search( const SwSearchOptions& rOptions ) else { // Normale Suche - nFound = pWrtShell->SearchPattern(aSearchOpt, + nFound = pWrtShell->SearchPattern(aSearchOpt, pSrchItem->GetNotes(), rOptions.eStart, rOptions.eEnd, FindRanges(eRanges), diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 8f1f015936f1..43ee928fd08e 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -802,8 +802,10 @@ sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > } else { + //todo/mba: assuming that notes should be omitted + BOOL bSearchInNotes = FALSE; BOOL bCancel; - nResult = pUnoCrsr->Find( aSearchOpt, + nResult = pUnoCrsr->Find( aSearchOpt, bSearchInNotes, eStart, eEnd, bCancel, (FindRanges)eRanges, sal_True ); @@ -931,8 +933,10 @@ SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > } else { + //todo/mba: assuming that notes should be omitted + BOOL bSearchInNotes = FALSE; BOOL bCancel; - nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, + nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, bSearchInNotes, eStart, eEnd, bCancel, (FindRanges)eRanges, /*int bReplace =*/sal_False ); diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx index 226de19d3fc0..7c2ed2e1d938 100644 --- a/sw/source/ui/utlui/content.cxx +++ b/sw/source/ui/utlui/content.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: content.cxx,v $ - * $Revision: 1.55 $ + * $Revision: 1.55.34.1 $ * * This file is part of OpenOffice.org. * @@ -104,15 +104,15 @@ #include <svx/svdpage.hxx> #include <svx/svdview.hxx> #include <vcl/scrbar.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <undobj.hxx> #include <swundo.hxx> #include <ndtxt.hxx> #include <PostItMgr.hxx> +#include <postit.hxx> #include <postithelper.hxx> - +#include <redline.hxx> +#include <docary.hxx> #include "swabstdlg.hxx" #include "globals.hrc" @@ -130,7 +130,6 @@ using namespace ::com::sun::star::container; #define NAVI_BOOKMARK_DELIM (sal_Unicode)1 - /*************************************************************************** ***************************************************************************/ @@ -206,7 +205,10 @@ sal_Bool SwContent::IsProtect() const sal_Bool SwPostItContent::IsProtect() const { - return pFld->IsProtect(); + if (mbPostIt) + return pFld->IsProtect(); + else + return false; } sal_Bool SwURLFieldContent::IsProtect() const @@ -423,22 +425,45 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow) { for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) { - if ( (*i)->pFmtFld->GetTxtFld() && - (*i)->pFmtFld->IsFldInDoc() && - (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit { - String sEntry = (*i)->pFmtFld->GetFld()->GetPar2(); - RemoveNewline(sEntry); - SwPostItContent* pCnt = new SwPostItContent( - this, - sEntry, // hier steht der Text - (const SwFmtFld*)(*i)->pFmtFld, - nMemberCount); - pMember->Insert(pCnt); - nMemberCount++; + SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster()); + if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && + (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + { + String sEntry = aFmtFld->GetFld()->GetPar2(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + (const SwFmtFld*)aFmtFld, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } + } + /* + // this code can be used once we want redline comments in the margin + else // redcomment + { + SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster()); + if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) ) + { + String sEntry = pRedline->GetComment(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, // hier steht der Text + pRedline, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } } + */ } } + // sTypeToken = aEmptyStr; bEdit = sal_True; nOldMemberCount = nMemberCount; @@ -763,18 +788,44 @@ void SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibiblityChanged) { for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) { - if ( (*i)->pFmtFld->GetTxtFld() && - (*i)->pFmtFld->IsFldInDoc() && - (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit { - String sEntry = (*i)->pFmtFld->GetFld()->GetPar2(); - RemoveNewline(sEntry); - SwPostItContent* pCnt = new SwPostItContent(this,sEntry, (*i)->pFmtFld,nMemberCount); - pMember->Insert(pCnt); - nMemberCount++; + SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster()); + if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && + (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + { + String sEntry = aFmtFld->GetFld()->GetPar2(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + (const SwFmtFld*)aFmtFld, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } } + /* this code can be used once we want redline comments in the margin + else // redcomment + { + SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster()); + if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) ) + { + String sEntry = pRedline->GetComment(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + pRedline, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } + } + */ } } + // } break; case CONTENT_TYPE_DRAWOBJECT: @@ -2865,11 +2916,28 @@ void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode) case CONTENT_TYPE_POSTIT: if(nMode == EDIT_MODE_DELETE) { - pActiveShell->GetView().GetPostItMgr()->SetActivePostIt(0); - pActiveShell->DelRight(); + if (((SwPostItContent*)pCnt)->IsPostIt()) + { + pActiveShell->GetView().GetPostItMgr()->SetActivePostIt(0); + pActiveShell->DelRight(); + } + /* + // this code can be used once we want redline comments in the margin + else + { + SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline()); + if (pComment) + pComment->Delete(); + } + */ } else - nSlot = FN_POSTIT; + { + if (((SwPostItContent*)pCnt)->IsPostIt()) + nSlot = FN_POSTIT; + else + nSlot = FN_REDLINE_COMMENT; + } break; case CONTENT_TYPE_INDEX: { @@ -3014,7 +3082,12 @@ void SwContentTree::GotoContent(SwContent* pCnt) } break; case CONTENT_TYPE_POSTIT: - pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt()); + if (((SwPostItContent*)pCnt)->IsPostIt()) + pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt()); + else + pActiveShell->GetView().GetDocShell()->GetWrtShell()->GotoRedline( + pActiveShell->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent*)pCnt)->GetRedline()->GetRedlineData())); + break; case CONTENT_TYPE_DRAWOBJECT: { diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index 6bb51000ac7c..d9c51b60073f 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -175,7 +175,7 @@ long SwWrtShell::SelAll() ------------------------------------------------------------------------*/ -ULONG SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, +ULONG SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, BOOL bSearchInNotes, SwDocPositions eStt, SwDocPositions eEnd, FindRanges eFlags, int bReplace ) { @@ -183,7 +183,7 @@ ULONG SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, if(!(eFlags & FND_IN_SEL)) ClearMark(); BOOL bCancel = FALSE; - ULONG nRet = Find( rSearchOpt, eStt, eEnd, bCancel, eFlags, bReplace ); + ULONG nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace ); if(bCancel) { Undo(UNDO_EMPTY, 1); |