summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-19 10:02:08 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-21 10:43:11 +0200
commitfc4bb1254ef77d29368535c9a810875c8db15b77 (patch)
treeb1ebc10536f79914dd18466292b7c285d57f6572
parentff11e4ff92036006851458cc5d935ff946618ae8 (diff)
sfx2 lok: expose part number in SfxLokHelper::notifyOtherViews()
This way a client can decide if the view cursor it gets is relevant (the views show the same part) or not. Change-Id: I7b274b28f0c4f0509df5071831acf50512eff640 Reviewed-on: https://gerrit.libreoffice.org/27311 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 299b9377469473abd8f58ba7f1054794491bdc56)
-rw-r--r--include/sfx2/viewsh.hxx2
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx2
-rw-r--r--sc/source/ui/unoobj/docuno.cxx2
-rw-r--r--sc/source/ui/view/tabvwshc.cxx5
-rw-r--r--sd/qa/unit/tiledrendering/data/shape.odpbin10159 -> 10446 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx57
-rw-r--r--sd/source/ui/inc/ViewShellBase.hxx2
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx3
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx13
-rw-r--r--sfx2/source/view/lokhelper.cxx2
-rw-r--r--sfx2/source/view/viewsh.cxx5
-rw-r--r--sw/inc/view.hxx2
-rw-r--r--sw/source/uibase/uiview/viewprt.cxx12
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx10
14 files changed, 104 insertions, 13 deletions
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index d489d55bfa64..afee9701dd17 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -331,6 +331,8 @@ public:
void setTiledSearching(bool bTiledSearching);
/// Are we doing tiled searching?
bool isTiledSearching() const;
+ /// See lok::Document::getPart().
+ virtual int getPart() const;
};
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index ec6f22622b5e..6a2ae9b82ab1 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -385,6 +385,8 @@ public:
// #i123629#
bool GetForceFocusOnCurCell() const { return bForceFocusOnCurCell; }
void SetForceFocusOnCurCell(bool bFlag) { bForceFocusOnCurCell=bFlag; }
+ /// See SfxViewShell::getPart().
+ int getPart() const override;
};
#endif
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b38031f7fe58..47c21c6ee514 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -512,7 +512,7 @@ int ScModelObj::getParts()
int ScModelObj::getPart()
{
ScViewData* pViewData = ScDocShell::GetViewData();
- return pViewData->GetTabNo();
+ return pViewData->GetViewShell()->getPart();
}
OUString ScModelObj::getPartName( int nPart )
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index bfe6d8e72164..9cdc11ebaf82 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -536,4 +536,9 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog(
return pResult;
}
+int ScTabViewShell::getPart() const
+{
+ return GetViewData().GetTabNo();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/tiledrendering/data/shape.odp b/sd/qa/unit/tiledrendering/data/shape.odp
index f73476140d73..b1ffa54e367f 100644
--- a/sd/qa/unit/tiledrendering/data/shape.odp
+++ b/sd/qa/unit/tiledrendering/data/shape.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 316936f44d47..acff325c6498 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -64,6 +64,7 @@ public:
void testResizeTable();
void testResizeTableColumn();
void testViewCursors();
+ void testViewCursorParts();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -84,6 +85,7 @@ public:
CPPUNIT_TEST(testResizeTable);
CPPUNIT_TEST(testResizeTableColumn);
CPPUNIT_TEST(testViewCursors);
+ CPPUNIT_TEST(testViewCursorParts);
CPPUNIT_TEST_SUITE_END();
private:
@@ -814,10 +816,13 @@ class ViewCallback
public:
bool m_bGraphicSelectionInvalidated;
bool m_bGraphicViewSelectionInvalidated;
+ /// Our current part, to be able to decide if a view cursor/selection is relevant for us.
+ int m_nPart;
ViewCallback()
: m_bGraphicSelectionInvalidated(false),
- m_bGraphicViewSelectionInvalidated(false)
+ m_bGraphicViewSelectionInvalidated(false),
+ m_nPart(0)
{
}
@@ -826,7 +831,7 @@ public:
static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
}
- void callbackImpl(int nType, const char* /*pPayload*/)
+ void callbackImpl(int nType, const char* pPayload)
{
switch (nType)
{
@@ -837,7 +842,12 @@ public:
break;
case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
{
- m_bGraphicViewSelectionInvalidated = true;
+ std::stringstream aStream(pPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ if (aTree.get_child("part").get_value<int>() == m_nPart)
+ // Ignore callbacks which are for a different part.
+ m_bGraphicViewSelectionInvalidated = true;
}
break;
}
@@ -874,6 +884,47 @@ void SdTiledRenderingTest::testViewCursors()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testViewCursorParts()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views.
+ SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ ViewCallback aView2;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+
+ // Select the shape in the second view.
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ Scheduler::ProcessEventsToIdle();
+ // First view notices that there was a selection change in the other view.
+ CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated);
+ pView->UnmarkAllObj(pView->GetSdrPageView());
+
+ // Now switch to the second part in the second view.
+ pXImpressDocument->setPart(1);
+ aView2.m_nPart = 1;
+ aView1.m_bGraphicViewSelectionInvalidated = false;
+ pActualPage = pViewShell->GetActualPage();
+ pObject = pActualPage->GetObj(0);
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ Scheduler::ProcessEventsToIdle();
+ // First view ignores view selection, as it would be for part 1, and it's in part 0.
+ // This failed when the "part" was always 0 in the callback.
+ CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelectionInvalidated);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx
index 5e4aec31e6a9..22489f114a46 100644
--- a/sd/source/ui/inc/ViewShellBase.hxx
+++ b/sd/source/ui/inc/ViewShellBase.hxx
@@ -220,6 +220,8 @@ public:
/** returns the ui descriptive name for the given uno slot. The result is taken from the configuration
and not cached, so do not use it excessive (f.e. in status updates) */
OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) const;
+ /// See SfxViewShell::getPart().
+ int getPart() const override;
protected:
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 8cf59832c103..4d006062db70 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2312,8 +2312,7 @@ int SdXImpressDocument::getPart()
if (!pViewSh)
return 0;
- // curPageId seems to start at 1
- return pViewSh->GetCurPageId() - 1;
+ return pViewSh->GetViewShellBase().getPart();
}
OUString SdXImpressDocument::getPartName( int nPart )
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index b90fa2af0665..5f4ba544c104 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -1032,6 +1032,19 @@ OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) cons
return ImplRetrieveLabelFromCommand( xFrame, aCmdURL );
}
+int ViewShellBase::getPart() const
+{
+ ViewShell* pViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
+
+ if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell))
+ {
+ // curPageId seems to start at 1
+ return pDrawViewShell->GetCurPageId() - 1;
+ }
+
+ return 0;
+}
+
//===== ViewShellBase::Implementation =========================================
ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index d027bad47f15..09d78cf8601d 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -108,6 +108,8 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
boost::property_tree::ptree aTree;
aTree.put("viewId", SfxLokHelper::getView(pThisView));
aTree.put(rKey.getStr(), rPayload.getStr());
+ aTree.put("part", pThisView->getPart());
+ aTree.put(rKey.getStr(), rPayload.getStr());
std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree);
OString aPayload = aStream.str().c_str();
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index a68e8c0ef330..92d3f1a5a7f8 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1643,6 +1643,11 @@ bool SfxViewShell::isTiledSearching() const
return pImp->m_bTiledSearching;
}
+int SfxViewShell::getPart() const
+{
+ return 0;
+}
+
bool SfxViewShell::KeyInput( const KeyEvent &rKeyEvent )
/* [Description]
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 328460fe65c8..f422ced3efd4 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -649,6 +649,8 @@ public:
SAL_DLLPRIVATE virtual VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window* pParent,
const SfxItemSet& rSet) override;
static SvxSearchItem* GetSearchItem() { return m_pSrchItem; }
+ /// See SfxViewShell::getPart().
+ int getPart() const override;
};
inline long SwView::GetXScroll() const
diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx
index 6a915277d92f..8d122145f0ac 100644
--- a/sw/source/uibase/uiview/viewprt.cxx
+++ b/sw/source/uibase/uiview/viewprt.cxx
@@ -246,6 +246,18 @@ void SwView::ExecutePrint(SfxRequest& rReq)
}
}
+int SwView::getPart() const
+{
+ if (!m_pWrtShell)
+ return 0;
+
+ sal_uInt16 nPage, nLogPage;
+ OUString sDisplay;
+ m_pWrtShell->GetPageNumber(-1, m_pWrtShell->IsCursorVisible(), nPage, nLogPage, sDisplay);
+
+ return nPage - 1;
+}
+
// Create page printer/additions for SwView and SwPagePreview
VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent,
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 396e79ddaacb..a37764ad8451 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3203,15 +3203,11 @@ int SwXTextDocument::getPart()
{
SolarMutexGuard aGuard;
- SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
- if (!pWrtShell)
+ SwView* pView = pDocShell->GetView();
+ if (!pView)
return 0;
- sal_uInt16 nPage, nLogPage;
- OUString sDisplay;
- pWrtShell->GetPageNumber(-1, pWrtShell->IsCursorVisible(), nPage, nLogPage, sDisplay);
-
- return nPage - 1;
+ return pView->getPart();
}
OUString SwXTextDocument::getPartName(int nPart)