[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/qa sd/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 15 13:19:58 UTC 2021


 sd/qa/unit/uiimpress.cxx       |   58 +++++++++++++++++++++++++++++++++++++++--
 sd/source/ui/view/drviews1.cxx |   11 ++++---
 sd/source/ui/view/drviews3.cxx |   14 ++++++++-
 3 files changed, 74 insertions(+), 9 deletions(-)

New commits:
commit 2c35c5ce65774db624d2b030c276cfe644dd0568
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Mar 25 17:21:35 2021 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Apr 15 15:19:22 2021 +0200

    impress: don't exit textbox editing when new slide was added followup
    
    ec90261c6568476c0eb039d7f2e4af75a535baf2 followup
    this synces code with master
    
    Change-Id: I7a0b33e2821396a2d02e2d9fdc2a7e6f851acb84
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114048
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 738b09a3fd7d..81ec6e4bf321 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -13,6 +13,7 @@
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/XDrawView.hpp>
 #include <com/sun/star/frame/DispatchHelper.hpp>
 
 #include <comphelper/processfactory.hxx>
@@ -38,6 +39,7 @@
 #include <comphelper/propertysequence.hxx>
 #include <com/sun/star/frame/DispatchHelper.hpp>
 #include <svx/xflclit.hxx>
+#include <vcl/scheduler.hxx>
 
 using namespace ::com::sun::star;
 
@@ -51,6 +53,8 @@ protected:
 public:
     virtual void setUp() override;
     virtual void tearDown() override;
+
+    void checkCurrentPageNumber(sal_uInt16 nNum);
 };
 
 void SdUiImpressTest::setUp()
@@ -69,6 +73,18 @@ void SdUiImpressTest::tearDown()
     test::BootstrapFixture::tearDown();
 }
 
+void SdUiImpressTest::checkCurrentPageNumber(sal_uInt16 nNum)
+{
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawView> xDrawView(xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xPage(xDrawView->getCurrentPage(), uno::UNO_SET_THROW);
+    uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
+
+    sal_uInt16 nPageNumber;
+    xPropertySet->getPropertyValue("Number") >>= nPageNumber;
+    CPPUNIT_ASSERT_EQUAL(nNum, nPageNumber);
+}
+
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf111522)
 {
     // Load the document and create two new windows.
@@ -200,6 +216,43 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf128651)
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Redo changes width", nUndoWidth, nRedoWidth);
 }
 
+CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf127481)
+{
+    mxComponent = loadFromDesktop("private:factory/simpress",
+                                  "com.sun.star.presentation.PresentationDocument");
+
+    CPPUNIT_ASSERT(mxComponent.is());
+
+    auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+    sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+    SdPage* pActualPage = pViewShell->GetActualPage();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pActualPage->GetObjCount());
+
+    uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+        { { "Rows", uno::makeAny(sal_Int32(1)) }, { "Columns", uno::makeAny(sal_Int32(1)) } }));
+
+    dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pActualPage->GetObjCount());
+
+    dispatchCommand(mxComponent, ".uno:DuplicatePage", aArgs);
+    Scheduler::ProcessEventsToIdle();
+
+    checkCurrentPageNumber(2);
+
+    pActualPage = pViewShell->GetActualPage();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pActualPage->GetObjCount());
+
+    auto pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(pActualPage->GetObj(2));
+    CPPUNIT_ASSERT(pTableObject);
+
+    //without the fix, it would crash here
+    pViewShell->GetView()->SdrBeginTextEdit(pTableObject);
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pActualPage->GetObjCount());
+}
+
 namespace
 {
 void dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand,
@@ -282,12 +335,13 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSpellOnlineParameter)
     auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     bool bSet = pImpressDocument->GetDoc()->GetOnlineSpell();
 
-    uno::Sequence<beans::PropertyValue> params(comphelper::InitPropertySequence({{"Enable", uno::makeAny(!bSet)}}));
+    uno::Sequence<beans::PropertyValue> params(
+        comphelper::InitPropertySequence({ { "Enable", uno::makeAny(!bSet) } }));
     dispatchCommand(mxComponent, ".uno:SpellOnline", params);
     CPPUNIT_ASSERT_EQUAL(!bSet, pImpressDocument->GetDoc()->GetOnlineSpell());
 
     // set the same state as now and we don't expect any change (no-toggle)
-    params = comphelper::InitPropertySequence({{"Enable", uno::makeAny(!bSet)}});
+    params = comphelper::InitPropertySequence({ { "Enable", uno::makeAny(!bSet) } });
     dispatchCommand(mxComponent, ".uno:SpellOnline", params);
     CPPUNIT_ASSERT_EQUAL(!bSet, pImpressDocument->GetDoc()->GetOnlineSpell());
 }
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index 4a055184fb08..bdbf06b72361 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -70,6 +70,7 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <vcl/uitest/logger.hxx>
 #include <vcl/uitest/eventdescription.hxx>
+#include <svl/intitem.hxx>
 
 using namespace com::sun::star;
 
@@ -704,11 +705,11 @@ void DrawViewShell::ResetActualPage()
         SwitchPage(nCurrentPageNum);
     }
 
-    if (nNewPageId != nCurrentPageId)
-        GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
-                    SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
-    else
-        SwitchPage(nCurrentPageNum, false);
+    bool bAllowChangeFocus = nNewPageId != nCurrentPageId;
+    SfxBoolItem aI(SID_SWITCHPAGE, bAllowChangeFocus);
+    GetViewFrame()->GetDispatcher()->ExecuteList(SID_SWITCHPAGE,
+                SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
+                { &aI });
 }
 
 /**
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index c5e1450f70e2..b243e9db4919 100644
--- a/sd/source/ui/view/drviews3.cxx
+++ b/sd/source/ui/view/drviews3.cxx
@@ -106,6 +106,7 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
 
     // End text edit mode for some requests.
     sal_uInt16 nSlot = rReq.GetSlot();
+    bool bAllowFocusChange = true;
     switch (nSlot)
     {
         case SID_OUTPUT_QUALITY_COLOR:
@@ -114,6 +115,15 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
         case SID_OUTPUT_QUALITY_CONTRAST:
             // Do nothing.
             break;
+        case SID_SWITCHPAGE:
+            if (rReq.GetArgs() && rReq.GetArgs()->Count () == 1)
+            {
+                const SfxBoolItem* pAllowFocusChange = rReq.GetArg<SfxBoolItem>(SID_SWITCHPAGE);
+                bAllowFocusChange = pAllowFocusChange->GetValue();
+                if (!bAllowFocusChange)
+                    break;
+            }
+            BOOST_FALLTHROUGH;
         default:
             if ( mpDrawView->IsTextEdit() )
             {
@@ -137,7 +147,7 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
                 const SfxItemSet *pArgs = rReq.GetArgs ();
                 sal_uInt16 nSelectedPage = 0;
 
-                if (! pArgs)
+                if (! pArgs || pArgs->Count () == 1)
                 {
                     nSelectedPage = maTabControl->GetCurPagePos();
                 }
@@ -183,7 +193,7 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
                 if( GetDocSh() && (GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED))
                     GetDocSh()->SetModified();
 
-                SwitchPage(nSelectedPage);
+                SwitchPage(nSelectedPage, bAllowFocusChange);
 
                 if(HasCurrentFunction(SID_BEZIER_EDIT))
                     GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);


More information about the Libreoffice-commits mailing list