[Libreoffice-commits] core.git: 2 commits - framework/source sc/source

Eike Rathke erack at redhat.com
Thu Jul 28 17:04:42 UTC 2016


 framework/source/uielement/menubarmanager.cxx |   10 ++++++++--
 sc/source/ui/inc/viewdata.hxx                 |    3 +++
 sc/source/ui/view/cellsh.cxx                  |   13 ++++++++++++-
 sc/source/ui/view/viewdata.cxx                |   12 ++++++++++++
 sc/source/ui/view/viewfun3.cxx                |    3 +++
 5 files changed, 38 insertions(+), 3 deletions(-)

New commits:
commit fe46041a6b2fd29715389cc5eb2dfbaf65f7f1f9
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 28 19:01:39 2016 +0200

    do not force the Paste command to enabled for Calc, tdf#60021 related
    
    ... so it actually gets disabled in menu or removed from context menu if we say
    so. Used with disallowing Paste for Ctrl+A selection or protected cells.
    
    Change-Id: I7d5f8bdc7b7adee65d08b93ddee015aef953d95d

diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index d47fdbe..fdeda1f 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -401,8 +401,14 @@ throw ( RuntimeException, std::exception )
                 //enable some slots hardly, because UNIX clipboard does not notify all changes
                 // Can be removed if follow up task will be fixed directly within applications.
                 // Note: PasteSpecial is handled specifically by calc
-                if ( pMenuItemHandler->aMenuItemURL == ".uno:Paste"
-                    || pMenuItemHandler->aMenuItemURL == ".uno:PasteClipboard" )      // special for draw/impress
+                // Calc also disables Paste under some circumstances, do not override.
+                /* TODO: is this workaround even needed anymore? Was introduced
+                 * in 2009 with commit 426ab2c0e8f6e3fe2b766f74f6b8da873d860260
+                 * as some "metropatch" and the other places it touched seem to
+                 * be gone. */
+                if ( (pMenuItemHandler->aMenuItemURL == ".uno:Paste" &&
+                            m_aModuleIdentifier != "com.sun.star.sheet.SpreadsheetDocument")
+                        || pMenuItemHandler->aMenuItemURL == ".uno:PasteClipboard" )    // special for draw/impress
                     bEnabledItem = true;
                 #endif
 
commit 984b0d1599ff1672cb0d28019bd652d58d6bdefa
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 28 18:51:01 2016 +0200

    Resolves: tdf#60021 disallow Paste when entire sheet is selected
    
    ... which exhausts memory unless you have 100GB or more of free RAM.
    
    Change-Id: Ie6f02c48457f80acad33d2286194765f8343f2fb

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index a7446e1..7c1c098 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -354,6 +354,9 @@ public:
 
     bool            IsMultiMarked();
 
+                    /// Disallow paste on Ctrl+A all selected. We'd go DOOM.
+    bool            SelectionForbidsPaste();
+
     void            SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
     void            SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
                                     ScFillMode nMode );
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 96b8262..7379cdb 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -205,6 +205,14 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
                 bDisable = (!bSimpleArea);
                 break;
 
+            case SID_PASTE:
+            case SID_PASTE_SPECIAL:
+            case SID_PASTE_ONLY_VALUE:
+            case SID_PASTE_ONLY_TEXT:
+            case SID_PASTE_ONLY_FORMULA:
+                bDisable = GetViewData()->SelectionForbidsPaste();
+                break;
+
             case FID_INS_ROW:
             case FID_INS_ROWS_BEFORE:           // insert rows
             case FID_INS_ROWS_AFTER:
@@ -490,6 +498,9 @@ bool checkDestRanges(ScViewData& rViewData)
             return false;
     }
 
+    if (rViewData.SelectionForbidsPaste())
+        return false;
+
     // Multiple destination ranges.
 
     ScDocument* pDoc = rViewData.GetDocument();
@@ -552,7 +563,7 @@ void ScCellShell::GetClipState( SfxItemSet& rSet )
         if (!rDoc.IsBlockEditable( nTab, nCol,nRow, nCol,nRow ))
             bDisable = true;
 
-        if (!checkDestRanges(*GetViewData()))
+        if (!bDisable && !checkDestRanges(*GetViewData()))
             bDisable = true;
     }
 
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index d188643..d07f711 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -854,6 +854,18 @@ bool ScViewData::IsMultiMarked()
     return (eType & SC_MARK_SIMPLE) != SC_MARK_SIMPLE;
 }
 
+bool ScViewData::SelectionForbidsPaste()
+{
+    SCCOL nCol1, nCol2;
+    SCROW nRow1, nRow2;
+    SCTAB nTab1, nTab2;
+    ScMarkType eMarkType = GetSimpleArea( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
+    /* TODO: it is still possible to select one row less than the entire sheet
+     * and fool around. We could narrow this down to some "sane" value, just
+     * what would be sane? At least this helps against the Ctrl+A cases. */
+    return eMarkType != SC_MARK_MULTI && nCol1 == 0 && nCol2 == MAXCOL && nRow1 == 0 && nRow2 == MAXROW;
+}
+
 void ScViewData::SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
 {
     nFillMode   = ScFillMode::FILL;
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 3facbf1..f798690 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -859,6 +859,9 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc,
         return false;
     }
 
+    if (GetViewData().SelectionForbidsPaste())
+        return false;
+
     //  undo: save all or no content
     InsertDeleteFlags nContFlags = InsertDeleteFlags::NONE;
     if (nFlags & InsertDeleteFlags::CONTENTS)


More information about the Libreoffice-commits mailing list