[PATCH libreoffice-4-0] fdo#60738 SwPostItMgr: let the cursor know if we're in annot...

Miklos Vajna (via Code Review) gerrit at gerrit.libreoffice.org
Fri Feb 15 01:11:04 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2163

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/63/2163/1

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.

(cherry picked from commit 9104d5e8905c2ec2b576b5ca452d3e23d5555e49)

Conflicts:
	sw/inc/pam.hxx
	sw/source/core/crsr/pam.cxx

Change-Id: I25781a4501f752f7c4d024795d57b884cb800547
---
M sw/inc/crsrsh.hxx
M sw/inc/pam.hxx
M sw/source/core/crsr/crsrsh.cxx
M sw/source/core/crsr/pam.cxx
M sw/source/ui/docvw/PostItMgr.cxx
M sw/source/ui/inc/view.hxx
M sw/source/ui/uiview/view.cxx
M sw/source/ui/uiview/view2.cxx
8 files changed, 21 insertions(+), 10 deletions(-)



diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 6d47927..5a061db 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -476,7 +476,7 @@
 
     // 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 bfe7214..b74f990 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -287,7 +287,7 @@
 
     /** Is in something protected (readonly) or selection contains
        something protected. */
-    sal_Bool HasReadonlySel( bool bFormView ) const;
+    sal_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 3486a74..379af07 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2888,7 +2888,7 @@
     }
 }
 
-sal_Bool SwCrsrShell::HasReadonlySel() const
+sal_Bool SwCrsrShell::HasReadonlySel(bool bAnnotationMode) const
 {
     sal_Bool bRet = sal_False;
     if( IsReadOnlyAvailable() || GetViewOptions()->IsFormView() )
@@ -2901,7 +2901,7 @@
             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 e745e80..c36b582 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -589,7 +589,7 @@
 }
 
 /// is in protected section or selection surrounds something protected
-sal_Bool SwPaM::HasReadonlySel( bool bFormView ) const
+sal_Bool SwPaM::HasReadonlySel( bool bFormView, bool bAnnotationMode ) const
 {
     sal_Bool bRet = sal_False;
     Point aTmpPt;
@@ -731,8 +731,8 @@
     }
 
     // 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 83b1cc9..3a24565 100644
--- a/sw/source/ui/docvw/PostItMgr.cxx
+++ b/sw/source/ui/docvw/PostItMgr.cxx
@@ -1626,7 +1626,9 @@
         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 c1be2bb..4df29ac 100644
--- a/sw/source/ui/inc/view.hxx
+++ b/sw/source/ui/inc/view.hxx
@@ -265,7 +265,8 @@
                     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
@@ -658,6 +659,8 @@
     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 df77bd1..d192dd9 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -653,7 +653,7 @@
     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;
@@ -747,7 +747,8 @@
     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 61b9440..b6a7d10 100644
--- a/sw/source/ui/uiview/view2.cxx
+++ b/sw/source/ui/uiview/view2.cxx
@@ -1210,6 +1210,11 @@
     rBnd.Update( FN_STAT_WORDCOUNT );
 }
 
+void SwView::SetAnnotationMode(bool bMode)
+{
+    m_bAnnotationMode = bMode;
+}
+
 /*--------------------------------------------------------------------
     Beschreibung:   Status der Stauszeile
  --------------------------------------------------------------------*/

-- 
To view, visit https://gerrit.libreoffice.org/2163
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25781a4501f752f7c4d024795d57b884cb800547
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Miklos Vajna <vmiklos at suse.cz>


More information about the LibreOffice mailing list