[Libreoffice-commits] core.git: desktop/source include/vcl sc/inc sc/source sd/qa sd/source sw/inc sw/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 13 12:25:45 UTC 2021
desktop/source/lib/init.cxx | 13 +++--
include/vcl/ITiledRenderable.hxx | 4 +
sc/inc/docuno.hxx | 2
sc/source/ui/unoobj/docuno.cxx | 2
sd/qa/unit/tiledrendering/tiledrendering.cxx | 68 +++++++++++++++++++++++++++
sd/source/ui/inc/DrawViewShell.hxx | 2
sd/source/ui/inc/unomodel.hxx | 2
sd/source/ui/unoidl/unomodel.cxx | 4 -
sd/source/ui/view/drviews1.cxx | 23 ++++++---
sd/source/ui/view/drviews3.cxx | 14 ++++-
sw/inc/unotxdoc.hxx | 2
sw/source/uibase/uno/unotxdoc.cxx | 2
12 files changed, 117 insertions(+), 21 deletions(-)
New commits:
commit bd93f5cec54350b6f07c5b7cd4987ea3762e3f40
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: Tue Apr 13 14:25:04 2021 +0200
impress: don't exit textbox editing when new slide was added
When new slide is added by other user before currently visible slide
then SwitchPage is called and textbox editing is ended.
Avoid any focus change when setPart is called just for rendering
or SwitchPage is used on previously avtive slide (only slide numer changed).
Change-Id: I7fef42b863e0079acc84dadfc3f891548652b48f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113144
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113806
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 087474487b97..e2027ab218ba 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2973,7 +2973,7 @@ static int doc_getPart (LibreOfficeKitDocument* pThis)
return pDoc->getPart();
}
-static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
+static void doc_setPartImpl(LibreOfficeKitDocument* pThis, int nPart, bool bAllowChangeFocus = true)
{
comphelper::ProfileZone aZone("doc_setPart");
@@ -2987,7 +2987,12 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
return;
}
- pDoc->setPart( nPart );
+ pDoc->setPart( nPart, bAllowChangeFocus );
+}
+
+static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
+{
+ doc_setPartImpl(pThis, nPart, true);
}
static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart)
@@ -3301,7 +3306,7 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
nOrigPart = doc_getPart(pThis);
if (nPart != nOrigPart)
{
- doc_setPart(pThis, nPart);
+ doc_setPartImpl(pThis, nPart, false);
}
}
@@ -3309,7 +3314,7 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
if (!isText && nPart != nOrigPart)
{
- doc_setPart(pThis, nOrigPart);
+ doc_setPartImpl(pThis, nOrigPart, false);
}
if (!isText && nViewId != nOrigViewId)
{
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 1fa0d7dcd060..a1107e8a605a 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -72,8 +72,10 @@ public:
/**
* Set the document "part", i.e. slide for a slideshow, and
* tab for a spreadsheet.
+ * bool bAllowChangeFocus - used to not disturb other users while editing when
+ * setPart is used for tile rendering only
*/
- virtual void setPart( int ) {}
+ virtual void setPart( int /*nPart*/, bool /*bAllowChangeFocus*/ = true ) {}
/**
* Get the number of parts -- see setPart for further details.
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 4325a747a3fa..04db162fb95a 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -311,7 +311,7 @@ public:
virtual Size getDocumentSize() override;
/// @see vcl::ITiledRenderable::setPart().
- virtual void setPart(int nPart) override;
+ virtual void setPart(int nPart, bool bAllowChangeFocus = true) override;
/// @see vcl::ITiledRenderable::getPart().
virtual int getPart() override;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 1e531424a92c..5cd51ad148b1 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -565,7 +565,7 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
-void ScModelObj::setPart( int nPart )
+void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
{
ScViewData* pViewData = ScDocShell::GetViewData();
ScTabView* pTabView = pViewData->GetView();
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index cc11e2483991..55d724a6a069 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -114,6 +114,7 @@ public:
void testCommentChangeImpress();
void testCommentChangeDraw();
void testMultiViewInsertDeletePage();
+ void testMultiViewInsertDeletePage2();
void testDisableUndoRepair();
void testDocumentRepair();
void testLanguageStatus();
@@ -167,6 +168,7 @@ public:
CPPUNIT_TEST(testCommentChangeImpress);
CPPUNIT_TEST(testCommentChangeDraw);
CPPUNIT_TEST(testMultiViewInsertDeletePage);
+ CPPUNIT_TEST(testMultiViewInsertDeletePage2);
CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testLanguageStatus);
@@ -1953,6 +1955,72 @@ void SdTiledRenderingTest::testMultiViewInsertDeletePage()
CPPUNIT_ASSERT_EQUAL(4, pXImpressDocument->getPart());
}
+void SdTiledRenderingTest::testMultiViewInsertDeletePage2()
+{
+ // Load the document.
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ ViewCallback aView1;
+ int nView1 = SfxLokHelper::getView();
+ uno::Sequence<beans::PropertyValue> aArgs;
+ SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc();
+
+ // Create second view
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering(aArgs);
+ ViewCallback aView2;
+ int nView2 = SfxLokHelper::getView();
+
+ // the document has 8 slides
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pDoc->GetSdPageCount(PageKind::Standard));
+
+ // Switch to 5th page in 2nd view
+ pXImpressDocument->setPart(4);
+
+ // Begin text edit on the only object on the slide.
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject1 = pActualPage->GetObj(0);
+ CPPUNIT_ASSERT(pObject1 != nullptr);
+ CPPUNIT_ASSERT_EQUAL(OBJ_TITLETEXT, pObject1->GetObjIdentifier());
+ SdrTextObj* pTextObject = static_cast<SdrTextObj*>(pObject1);
+
+ // Double-click outside the text to enter edit mode.
+ const ::tools::Rectangle aRect = pTextObject->GetCurrentBoundRect();
+ const auto cornerX = convertMm100ToTwip(aRect.getX() + (aRect.getWidth() / 4));
+ const auto cornerY = convertMm100ToTwip(aRect.getY() + (aRect.getHeight() / 4));
+ pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ cornerX, cornerY,
+ 2, MOUSE_LEFT, 0);
+ pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ cornerX, cornerY,
+ 2, MOUSE_LEFT, 0);
+ Scheduler::ProcessEventsToIdle();
+
+ // We must be in text editing mode and have cursor visible.
+ CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
+
+ // Insert slide in 1st view
+ SfxLokHelper::setView(nView1);
+ comphelper::dispatchCommand(".uno:InsertPage", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ // See if the current slide number changed in 2nd view too
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT_EQUAL(5, pXImpressDocument->getPart());
+
+ // Delete the page in 1st view now
+ SfxLokHelper::setView(nView1);
+ comphelper::dispatchCommand(".uno:DeletePage", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ // See if current slide number changed in 2nd view too
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT_EQUAL(4, pXImpressDocument->getPart());
+
+ // We must be still in text editing mode and have cursor visible.
+ CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
+}
+
void SdTiledRenderingTest::testDisableUndoRepair()
{
// Load the document.
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 7f8e9b576529..288cf24866de 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -242,7 +242,7 @@ public:
void ResetActualPage();
void ResetActualLayer();
- bool SwitchPage(sal_uInt16 nPage);
+ bool SwitchPage(sal_uInt16 nPage, bool bAllowChangeFocus = true);
bool IsSwitchPageAllowed() const;
/**
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index ab3a723cf672..f5a02cbee597 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -231,7 +231,7 @@ public:
tools::Long nTileWidth,
tools::Long nTileHeight ) override;
virtual Size getDocumentSize() override;
- virtual void setPart( int nPart ) override;
+ virtual void setPart( int nPart, bool bAllowChangeFocus = true ) override;
virtual int getPart() override;
virtual int getParts() override;
virtual OUString getPartName( int nPart ) override;
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 662477a28367..fcdb050d7843 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2282,13 +2282,13 @@ OUString SdXImpressDocument::getPartInfo(int nPart)
return aPartInfo;
}
-void SdXImpressDocument::setPart( int nPart )
+void SdXImpressDocument::setPart( int nPart, bool bAllowChangeFocus )
{
DrawViewShell* pViewSh = GetViewShell();
if (!pViewSh)
return;
- pViewSh->SwitchPage( nPart );
+ pViewSh->SwitchPage( nPart, bAllowChangeFocus );
}
int SdXImpressDocument::getParts()
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index f17f81799bae..db7cd452d860 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -71,6 +71,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
+#include <svl/intitem.hxx>
using namespace com::sun::star;
@@ -652,6 +653,7 @@ void DrawViewShell::ResetActualPage()
return;
sal_uInt16 nCurrentPageId = maTabControl->GetCurPageId();
+ sal_uInt16 nNewPageId = nCurrentPageId;
sal_uInt16 nCurrentPageNum = maTabControl->GetPagePos(nCurrentPageId);
sal_uInt16 nPageCount = (meEditMode == EditMode::Page)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
@@ -678,7 +680,8 @@ void DrawViewShell::ResetActualPage()
GetDoc()->SetSelected(pPage, false);
}
- maTabControl->SetCurPageId(maTabControl->GetPageId(nCurrentPageNum));
+ nNewPageId = maTabControl->GetPageId(nCurrentPageNum);
+ maTabControl->SetCurPageId(nNewPageId);
}
else // EditMode::MasterPage
{
@@ -698,12 +701,16 @@ void DrawViewShell::ResetActualPage()
nCurrentPageNum = i;
}
- maTabControl->SetCurPageId(maTabControl->GetPageId(nCurrentPageNum));
+ nNewPageId = maTabControl->GetPageId(nCurrentPageNum);
+ maTabControl->SetCurPageId(nNewPageId);
SwitchPage(nCurrentPageNum);
}
- GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
- SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
+ bool bAllowChangeFocus = nNewPageId != nCurrentPageId;
+ SfxBoolItem aI(SID_SWITCHPAGE, bAllowChangeFocus);
+ GetViewFrame()->GetDispatcher()->ExecuteList(SID_SWITCHPAGE,
+ SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
+ { &aI });
}
/**
@@ -816,8 +823,11 @@ bool DrawViewShell::IsVisible(sal_uInt16 nPage)
/**
* Switch to desired page.
* nSelectPage refers to the current EditMode
+ * bAllowChangeFocus set to false when slide is inserted before current page
+ * and we need to only update the current page number,
+ * do not disturb editing in that case
*/
-bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
+bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, bool bAllowChangeFocus)
{
/** Under some circumstances there are nested calls to SwitchPage() and
may crash the application (activation of form controls when the
@@ -921,7 +931,8 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
}
}
- mpDrawView->SdrEndTextEdit();
+ if (bAllowChangeFocus)
+ mpDrawView->SdrEndTextEdit();
mpActualPage = nullptr;
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index ed28a4370ebc..545c7befeca4 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);
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 4dbb35b01ec8..b03d59cffd95 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -396,7 +396,7 @@ public:
/// @see vcl::ITiledRenderable::getDocumentSize().
virtual Size getDocumentSize() override;
/// @see vcl::ITiledRenderable::setPart().
- virtual void setPart(int nPart) override;
+ virtual void setPart(int nPart, bool bAllowChangeFocus = true) override;
/// @see vcl::ITiledRenderable::getParts().
virtual int getParts() override;
/// @see vcl::ITiledRenderable::getPart().
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 522cb3aa8645..f7461860a9ba 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3145,7 +3145,7 @@ Size SwXTextDocument::getDocumentSize()
aDocSize.Height() + 2 * DOCUMENTBORDER);
}
-void SwXTextDocument::setPart(int nPart)
+void SwXTextDocument::setPart(int nPart, bool /*bAllowChangeFocus*/)
{
SolarMutexGuard aGuard;
More information about the Libreoffice-commits
mailing list