diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-02-14 18:42:52 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-02-14 19:09:19 +0100 |
commit | 9104d5e8905c2ec2b576b5ca452d3e23d5555e49 (patch) | |
tree | 97d2062437f5c53356602f476a5edbda378f283c | |
parent | b6ff380b9378ecbcceadf717dcf1623bc52d4825 (diff) |
fdo#60738 SwPostItMgr: let the cursor know if we're in annotation mode
This solves the conflicting requirements:
If the annotation has focus ("in annotation mode"), then we want to
be read-only only in case the comment anchor is inside a protected
section, or so. Ignoring the fact that in the main document, the cursor
is right before the annotation anchor, which is a read-only position.
OTOH, if the annotation has no focus and the cursor position is before
the annotation anchor position, then we do want to be read-only.
With this commit, the first case passes around a boolean flag, so the
annotation frame won't be read-only without a reason.
Change-Id: I25781a4501f752f7c4d024795d57b884cb800547
-rw-r--r-- | sw/inc/crsrsh.hxx | 2 | ||||
-rw-r--r-- | sw/inc/pam.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/crsr/pam.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/docvw/PostItMgr.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/inc/view.hxx | 5 | ||||
-rw-r--r-- | sw/source/ui/uiview/view.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/uiview/view2.cxx | 5 |
8 files changed, 21 insertions, 10 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index a7f7d7d3f794..8dff3ca64de3 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -476,7 +476,7 @@ public: // Cursor is placed in something that is protected or selection contains // something that is protected. - sal_Bool HasReadonlySel() const; + sal_Bool HasReadonlySel(bool bAnnotationMode = false) const; // Can the cursor be set to read only ranges? sal_Bool IsReadOnlyAvailable() const { return bSetCrsrInReadOnly; } diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx index 384fbb9e7bca..73a33f725063 100644 --- a/sw/inc/pam.hxx +++ b/sw/inc/pam.hxx @@ -289,7 +289,7 @@ public: /** Is in something protected (readonly) or selection contains something protected. */ - bool HasReadonlySel( bool bFormView ) const; + bool HasReadonlySel( bool bFormView, bool bAnnotationMode = false ) const; sal_Bool ContainsPosition(const SwPosition & rPos) { return *Start() <= rPos && rPos <= *End(); } diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index e417c92db31e..e8048b22ddb2 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -2879,7 +2879,7 @@ void SwCrsrShell::SetReadOnlyAvailable( sal_Bool bFlag ) } } -sal_Bool SwCrsrShell::HasReadonlySel() const +sal_Bool SwCrsrShell::HasReadonlySel(bool bAnnotationMode) const { sal_Bool bRet = sal_False; if( IsReadOnlyAvailable() || GetViewOptions()->IsFormView() ) @@ -2892,7 +2892,7 @@ sal_Bool SwCrsrShell::HasReadonlySel() const const SwPaM* pCrsr = pCurCrsr; do { - if( pCrsr->HasReadonlySel( GetViewOptions()->IsFormView() ) ) + if( pCrsr->HasReadonlySel( GetViewOptions()->IsFormView(), bAnnotationMode ) ) bRet = sal_True; } while( !bRet && pCurCrsr != ( pCrsr = (SwPaM*)pCrsr->GetNext() )); } diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 85aedf079d48..c4bf33c9a132 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -590,7 +590,7 @@ static const SwFrm* lcl_FindEditInReadonlyFrm( const SwFrm& rFrm ) } /// is in protected section or selection surrounds something protected -bool SwPaM::HasReadonlySel( bool bFormView ) const +bool SwPaM::HasReadonlySel( bool bFormView, bool bAnnotationMode ) const { bool bRet = sal_False; Point aTmpPt; @@ -732,8 +732,8 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const } // Don't allow inserting characters between the 'field mark end' and - // the 'comment anchor'. - if (!bRet) + // the 'comment anchor', unless the cursor is inside the annotation. + if (!bRet && !bAnnotationMode) { if (!pA && GetPoint() && GetPoint()->nNode.GetNode().IsTxtNode() && GetPoint()->nContent.GetIndex() > 0) { diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 768827d14b38..b8acb5fcc891 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -1624,7 +1624,9 @@ void SwPostItMgr::SetActiveSidebarWin( SwSidebarWin* p) if (mpActivePostIt) { mpActivePostIt->GotoPos(); + mpView->SetAnnotationMode(true); mpView->AttrChangedNotify(0); + mpView->SetAnnotationMode(false); mpActivePostIt->ActivatePostIt(); } } diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index d0a542bdcc35..70c0f084f4a0 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -267,7 +267,8 @@ class SW_DLLPUBLIC SwView: public SfxViewShell bInDtor : 1, //detect destructor to prevent creating of sub shells while closing bOldShellWasPagePreView : 1, bIsPreviewDoubleClick : 1, // #i114045# - bMakeSelectionVisible : 1; // transport the bookmark selection + bMakeSelectionVisible : 1, // transport the bookmark selection + m_bAnnotationMode; ///< The real cursor position is inside an annotation. // methods for searching // set search context @@ -660,6 +661,8 @@ public: void SelectShellForDrop(); void UpdateDocStats(); + /// Where is the real cursor: in the annotation or in the main document? + void SetAnnotationMode(bool bMode); }; // ----------------- inline Methoden ---------------------- diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 26a135da34bd..4ac403d6fa5d 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -653,7 +653,7 @@ void SwView::_CheckReadonlySelection() sal_uInt32 nDisableFlags = 0; SfxDispatcher &rDis = GetDispatcher(); - if( pWrtShell->HasReadonlySel() && + if( pWrtShell->HasReadonlySel(m_bAnnotationMode) && ( !pWrtShell->GetDrawView() || !pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() )) nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR; @@ -748,7 +748,8 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) bInMailMerge(sal_False), bInDtor(sal_False), bOldShellWasPagePreView(sal_False), - bIsPreviewDoubleClick(sal_False) + bIsPreviewDoubleClick(sal_False), + m_bAnnotationMode(false) { // According to discussion with MBA and further // investigations, no old SfxViewShell will be set as parameter <pOldSh>, diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 0414f685589d..cf690f532821 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -1210,6 +1210,11 @@ void SwView::UpdateDocStats() rBnd.Update( FN_STAT_WORDCOUNT ); } +void SwView::SetAnnotationMode(bool bMode) +{ + m_bAnnotationMode = bMode; +} + /*-------------------------------------------------------------------- Beschreibung: Status der Stauszeile --------------------------------------------------------------------*/ |