Kaydet (Commit) 1e1eb87f authored tarafından Miklos Vajna's avatar Miklos Vajna

sd lok: implement SfxViewShell::NotifyCursor() API

The same API is already implemented in sw and sc already, the sd
implementation allows selecting a shape in one view, then creating a
second view, and seeing the selection of the first view in the second
view, without de-selecting and re-selecting the shape in question in the
first view.

Change-Id: Ia36e4772584d132f1ff6a7eb07ca4cadaa384ee9
Reviewed-on: https://gerrit.libreoffice.org/28623Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 6228d6c5
......@@ -164,12 +164,12 @@ SdrPageView* DrawViewWrapper::GetPageView() const
return pSdrPageView;
};
void DrawViewWrapper::SetMarkHandles()
void DrawViewWrapper::SetMarkHandles(SfxViewShell* pOtherShell)
{
if( m_pMarkHandleProvider && m_pMarkHandleProvider->getMarkHandles( maHdlList ) )
return;
else
SdrView::SetMarkHandles();
SdrView::SetMarkHandles(pOtherShell);
}
SdrObject* DrawViewWrapper::getHitObject( const Point& rPnt ) const
......
......@@ -56,7 +56,7 @@ public:
const css::uno::Reference< css::frame::XModel > & xChartModel );
//fill list of selection handles 'aHdl'
virtual void SetMarkHandles() override;
virtual void SetMarkHandles(SfxViewShell* pOtherShell) override;
SdrPageView* GetPageView() const;
......
......@@ -61,7 +61,7 @@ private:
SVX_DLLPRIVATE void ImpClearVars();
protected:
virtual void SetMarkHandles() override;
virtual void SetMarkHandles(SfxViewShell* pOtherShell) override;
void ShowDragObj();
void HideDragObj();
bool ImpBegInsObjPoint(bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, bool bNewObj, OutputDevice* pOut);
......
......@@ -142,7 +142,7 @@ private:
protected:
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
virtual void ModelHasChanged() override; // Is called by the PaintView
virtual void SetMarkHandles(); // maHdlList - fill (List of handles)
virtual void SetMarkHandles(SfxViewShell* pOtherShell); // maHdlList - fill (List of handles)
void SetMarkRects(); // Rects at the PageViews
void CheckMarked(); // Scan MarkList after Del and Lock Layer ...
void AddDragModeHdl(SdrDragMode eMode);
......@@ -406,7 +406,7 @@ public:
// AdjustMarkHdl is just called in case of changes; usually this causes an Invalidate
// At the end of a redraw the handles are drawn automatically.
// The purpose is to avoid unnecessary flickering. -> This does not yet work, that's why sal_True!
void AdjustMarkHdl(); //HMHBOOL bRestraintPaint=sal_True);
void AdjustMarkHdl(SfxViewShell* pOtherShell = nullptr); //HMHBOOL bRestraintPaint=sal_True);
const Rectangle& GetMarkedObjRect() const; // SnapRects of Objects, without line width
Rectangle GetMarkedObjBoundRect() const; // incl. line width, overlapping rags, ...
......
......@@ -1118,7 +1118,6 @@ void SdTiledRenderingTest::testCreateViewGraphicSelection()
// Load a document and register a callback.
SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
pXImpressDocument->initializeForTiledRendering({});
ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
......@@ -1134,10 +1133,20 @@ void SdTiledRenderingTest::testCreateViewGraphicSelection()
// Now create a new view.
aView1.m_bGraphicSelectionInvalidated = false;
SfxLokHelper::createView();
pXImpressDocument->initializeForTiledRendering({});
// This failed, creating a new view affected the graphic selection of an
// existing view.
CPPUNIT_ASSERT(!aView1.m_bGraphicSelectionInvalidated);
// Check that when the first view has a shape selected and we register a
// callback on the second view, then it gets a "graphic view selection".
ViewCallback aView2;
aView2.m_bGraphicViewSelectionInvalidated = false;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
// This failed, the created new view had no "view selection" of the first
// view's selected shape.
CPPUNIT_ASSERT(aView2.m_bGraphicViewSelectionInvalidated);
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
......
......@@ -219,6 +219,8 @@ public:
OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) const;
/// See SfxViewShell::getPart().
int getPart() const override;
/// See SfxViewShell::NotifyCursor().
void NotifyCursor(SfxViewShell* pViewShell) const override;
protected:
......
......@@ -90,6 +90,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include "fubullet.hxx"
#include "drawview.hxx"
using namespace sd;
#define ViewShellBase
......@@ -1033,6 +1034,24 @@ int ViewShellBase::getPart() const
return 0;
}
void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const
{
ViewShell* pThisShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pThisShell);
if (!pDrawViewShell)
return;
if (this == pOtherShell)
return;
DrawView* pDrawView = pDrawViewShell->GetDrawView();
if (!pDrawView)
return;
pDrawView->AdjustMarkHdl(pOtherShell);
}
//===== ViewShellBase::Implementation =========================================
ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
......
......@@ -1409,7 +1409,7 @@ void E3dView::Start3DCreation()
maRef2.Y() = nY2;
// Turn on marks
SetMarkHandles();
SetMarkHandles(nullptr);
//HMHif (bVis) ShowMarkHdl();
if (AreObjectsMarked()) MarkListHasChanged();
......
......@@ -558,7 +558,7 @@ bool SdrDragView::EndDragObj(bool bCopy)
if (mbInsPolyPoint)
{
SetMarkHandles();
SetMarkHandles(nullptr);
mbInsPolyPoint=false;
if( bUndo )
{
......@@ -605,7 +605,7 @@ void SdrDragView::BrkDragObj()
mpInsPointUndo->Undo(); // delete inserted point again
delete mpInsPointUndo;
mpInsPointUndo=nullptr;
SetMarkHandles();
SetMarkHandles(nullptr);
mbInsPolyPoint=false;
}
......@@ -874,12 +874,12 @@ bool SdrDragView::IsOrthoDesired() const
return false;
}
void SdrDragView::SetMarkHandles()
void SdrDragView::SetMarkHandles(SfxViewShell* pOtherShell)
{
if( mpDragHdl )
mpDragHdl = nullptr;
SdrExchangeView::SetMarkHandles();
SdrExchangeView::SetMarkHandles(pOtherShell);
}
void SdrDragView::SetSolidDragging(bool bOn)
......
......@@ -616,7 +616,7 @@ bool SdrMarkView::ImpIsFrameHandles() const
return bFrmHdl;
}
void SdrMarkView::SetMarkHandles()
void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
{
// remember old focus handle values to search for it again
const SdrHdl* pSaveOldFocusHdl = maHdlList.GetFocusHdl();
......@@ -767,8 +767,17 @@ void SdrMarkView::SetMarkHandles()
}
if(SfxViewShell* pViewShell = GetSfxViewShell())
{
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelection.getStr());
SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
if (pOtherShell)
// An other shell wants to know about our existing
// selection.
SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
else
{
// We have a new selection, so both pViewShell and the
// other views want to know about it.
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelection.getStr());
SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
}
}
}
......@@ -951,7 +960,7 @@ void SdrMarkView::SetDragMode(SdrDragMode eMode)
if (meDragMode==SdrDragMode::Resize) meDragMode=SdrDragMode::Move;
if (meDragMode!=eMode0) {
ForceRefToMarked();
SetMarkHandles();
SetMarkHandles(nullptr);
{
if (AreObjectsMarked()) MarkListHasChanged();
}
......@@ -1993,11 +2002,11 @@ void SdrMarkView::MarkAllObj(SdrPageView* _pPV)
}
}
void SdrMarkView::AdjustMarkHdl()
void SdrMarkView::AdjustMarkHdl(SfxViewShell* pOtherShell)
{
CheckMarked();
SetMarkRects();
SetMarkHandles();
SetMarkHandles(pOtherShell);
}
Rectangle SdrMarkView::GetMarkedObjBoundRect() const
......
......@@ -271,7 +271,7 @@ void SdrMarkView::SetPlusHandlesAlwaysVisible(bool bOn)
ForceUndirtyMrkPnt();
if (bOn!=mbPlusHdlAlways) {
mbPlusHdlAlways=bOn;
SetMarkHandles();
SetMarkHandles(nullptr);
MarkListHasChanged();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment