[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - editeng/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 18 15:52:46 UTC 2019


 editeng/source/editeng/impedit.cxx |   21 +++++++++++++++------
 editeng/source/editeng/impedit.hxx |    2 ++
 2 files changed, 17 insertions(+), 6 deletions(-)

New commits:
commit ce9795954d3957e98d24bf711869efd846df6f15
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jun 18 14:04:27 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jun 18 17:51:52 2019 +0200

    fix crash in header/footer calc dialog
    
    cut and paste can happen when the EditView isn't in a vcl::Window
    
    Change-Id: I9fdbfe28c5ca5dd680b821ff8ce4e0133ab203aa
    Reviewed-on: https://gerrit.libreoffice.org/74280
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 0fa84e2d90a2..9618c1fb604d 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
 #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
+#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
 #include <editeng/flditem.hxx>
@@ -38,8 +39,9 @@
 #include <sot/exchange.hxx>
 #include <sot/formats.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
-#include <comphelper/string.hxx>
 #include <comphelper/lok.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
 #include <sfx2/lokhelper.hxx>
 
 using namespace ::com::sun::star;
@@ -1268,6 +1270,13 @@ Pair ImpEditView::Scroll( long ndX, long ndY, ScrollRangeCheck nRangeCheck )
     return Pair( nRealDiffX, nRealDiffY );
 }
 
+Reference<css::datatransfer::clipboard::XClipboard> ImpEditView::GetClipboard()
+{
+    if (vcl::Window* pWindow = GetWindow())
+        return pWindow->GetClipboard();
+    return css::datatransfer::clipboard::SystemClipboard::create(comphelper::getProcessComponentContext());
+}
+
 bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * pFrameWin )
 {
     bool bDone = false;
@@ -1281,7 +1290,7 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p
             {
                 if ( !bReadOnly )
                 {
-                    Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
+                    Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard());
                     CutCopy( aClipBoard, true );
                     bDone = true;
                 }
@@ -1289,7 +1298,7 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p
             break;
             case KeyFuncType::COPY:
             {
-                Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
+                Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard());
                 CutCopy( aClipBoard, false );
                 bDone = true;
             }
@@ -1299,7 +1308,7 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p
                 if ( !bReadOnly && IsPasteEnabled() )
                 {
                     pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_PASTE );
-                    Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
+                    Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard());
                     Paste( aClipBoard, pEditEngine->pImpEditEngine->GetStatus().AllowPasteSpecial() );
                     pEditEngine->pImpEditEngine->UndoActionEnd();
                     bDone = true;
@@ -1329,12 +1338,12 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent )
         if ( rMouseEvent.IsMiddle() && !bReadOnly &&
              ( pWindow->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
         {
-            Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(pWindow->GetPrimarySelection());
+            Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard());
             Paste( aClipBoard );
         }
         else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() )
         {
-            Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(pWindow->GetPrimarySelection());
+            Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard());
             CutCopy( aClipBoard, false );
         }
     }
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 8f09ca8f13d0..b7f7d5db0323 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -282,6 +282,8 @@ private:
 
     void InvalidateAtWindow(const tools::Rectangle& rRect);
 
+    css::uno::Reference<css::datatransfer::clipboard::XClipboard> GetClipboard();
+
 protected:
 
     // DragAndDropClient


More information about the Libreoffice-commits mailing list