editeng: make SfxUndoAction::GetViewShellId() interface available

Extend the existing OutlinerViewCallable interface to be able to obtain
the view shell ID of a view shell, even from editeng.

Change-Id: I13708b0e4f58ee86643b913c7d21de022a685223
Reviewed-on: https://gerrit.libreoffice.org/27788
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna 2016-08-02 11:43:39 +02:00
parent 9162c483bc
commit 0762a119fc
11 changed files with 37 additions and 45 deletions

View File

@ -401,9 +401,9 @@ void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivat
bGotoCursor = false; bGotoCursor = false;
pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor ); pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
if (comphelper::LibreOfficeKit::isActive() && !bActivate) if (pImpEditView->mpViewShell && !bActivate)
{ {
pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr()); pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
} }
} }
} }
@ -412,9 +412,9 @@ void EditView::HideCursor(bool bDeactivate)
{ {
pImpEditView->GetCursor()->Hide(); pImpEditView->GetCursor()->Hide();
if (comphelper::LibreOfficeKit::isActive() && !bDeactivate) if (pImpEditView->mpViewShell && !bDeactivate)
{ {
pImpEditView->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr()); pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
} }
} }
@ -583,9 +583,9 @@ Color EditView::GetBackgroundColor() const
return pImpEditView->GetBackgroundColor(); return pImpEditView->GetBackgroundColor();
} }
void EditView::registerLibreOfficeKitViewCallback(OutlinerViewCallable *pCallable) void EditView::RegisterViewShell(OutlinerViewShell* pViewShell)
{ {
pImpEditView->registerLibreOfficeKitViewCallback(pCallable); pImpEditView->RegisterViewShell(pViewShell);
} }
void EditView::SetControlWord( EVControlBits nWord ) void EditView::SetControlWord( EVControlBits nWord )

View File

@ -79,7 +79,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
pOutWin = pWindow; pOutWin = pWindow;
pPointer = nullptr; pPointer = nullptr;
pBackgroundColor = nullptr; pBackgroundColor = nullptr;
mpLibreOfficeKitViewCallable = nullptr; mpViewShell = nullptr;
nScrollDiffX = 0; nScrollDiffX = 0;
nExtraCursorFlags = 0; nExtraCursorFlags = 0;
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW; nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
@ -117,15 +117,9 @@ void ImpEditView::SetBackgroundColor( const Color& rColor )
pBackgroundColor = new Color( rColor ); pBackgroundColor = new Color( rColor );
} }
void ImpEditView::registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable) void ImpEditView::RegisterViewShell(OutlinerViewShell* pViewShell)
{ {
mpLibreOfficeKitViewCallable = pCallable; mpViewShell = pViewShell;
}
void ImpEditView::libreOfficeKitViewCallback(int nType, const char* pPayload) const
{
if (mpLibreOfficeKitViewCallable)
mpLibreOfficeKitViewCallable->libreOfficeKitViewCallback(nType, pPayload);
} }
void ImpEditView::SetEditSelection( const EditSelection& rEditSelection ) void ImpEditView::SetEditSelection( const EditSelection& rEditSelection )
@ -343,7 +337,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
{ {
*pRegion = vcl::Region( *pPolyPoly ); *pRegion = vcl::Region( *pPolyPoly );
if (comphelper::LibreOfficeKit::isActive() && !pOldRegion) if (comphelper::LibreOfficeKit::isActive() && mpViewShell && !pOldRegion)
{ {
pOutWin->Push(PushFlags::MAPMODE); pOutWin->Push(PushFlags::MAPMODE);
if (pOutWin->GetMapMode().GetMapUnit() == MAP_TWIP) if (pOutWin->GetMapMode().GetMapUnit() == MAP_TWIP)
@ -386,7 +380,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
aStart = OutputDevice::LogicToLogic(aStart, MAP_100TH_MM, MAP_TWIP); aStart = OutputDevice::LogicToLogic(aStart, MAP_100TH_MM, MAP_TWIP);
aStart.Move(aOrigin.getX(), aOrigin.getY()); aStart.Move(aOrigin.getX(), aOrigin.getY());
libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, aStart.toString().getStr()); mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, aStart.toString().getStr());
Rectangle& rEnd = aRectangles.back(); Rectangle& rEnd = aRectangles.back();
Rectangle aEnd = Rectangle(rEnd.Right() - 1, rEnd.Top(), rEnd.Right(), rEnd.Bottom()); Rectangle aEnd = Rectangle(rEnd.Right() - 1, rEnd.Top(), rEnd.Right(), rEnd.Bottom());
@ -394,7 +388,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
aEnd = OutputDevice::LogicToLogic(aEnd, MAP_100TH_MM, MAP_TWIP); aEnd = OutputDevice::LogicToLogic(aEnd, MAP_100TH_MM, MAP_TWIP);
aEnd.Move(aOrigin.getX(), aOrigin.getY()); aEnd.Move(aOrigin.getX(), aOrigin.getY());
libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr()); mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr());
} }
std::vector<OString> v; std::vector<OString> v;
@ -408,7 +402,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
sRectangle = comphelper::string::join("; ", v); sRectangle = comphelper::string::join("; ", v);
} }
libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr()); mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
pOutWin->Pop(); pOutWin->Pop();
} }
@ -986,7 +980,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
GetCursor()->SetSize( aCursorSz ); GetCursor()->SetSize( aCursorSz );
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive() && mpViewShell)
{ {
const Point& rPos = GetCursor()->GetPos(); const Point& rPos = GetCursor()->GetPos();
Rectangle aRect(rPos.getX(), rPos.getY(), rPos.getX() + GetCursor()->GetWidth(), rPos.getY() + GetCursor()->GetHeight()); Rectangle aRect(rPos.getX(), rPos.getY(), rPos.getX() + GetCursor()->GetWidth(), rPos.getY() + GetCursor()->GetHeight());
@ -1005,7 +999,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
aRect.setWidth(0); aRect.setWidth(0);
OString sRect = aRect.toString(); OString sRect = aRect.toString();
libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr()); mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
} }
CursorDirection nCursorDir = CursorDirection::NONE; CursorDirection nCursorDir = CursorDirection::NONE;

View File

@ -221,8 +221,8 @@ private:
EditView* pEditView; EditView* pEditView;
vcl::Cursor* pCursor; vcl::Cursor* pCursor;
Color* pBackgroundColor; Color* pBackgroundColor;
/// Per-view callback. /// Containing view shell, if any.
OutlinerViewCallable* mpLibreOfficeKitViewCallable; OutlinerViewShell* mpViewShell;
EditEngine* pEditEngine; EditEngine* pEditEngine;
VclPtr<vcl::Window> pOutWin; VclPtr<vcl::Window> pOutWin;
Pointer* pPointer; Pointer* pPointer;
@ -367,10 +367,8 @@ public:
const Color& GetBackgroundColor() const { const Color& GetBackgroundColor() const {
return ( pBackgroundColor ? *pBackgroundColor : pOutWin->GetBackground().GetColor() ); } return ( pBackgroundColor ? *pBackgroundColor : pOutWin->GetBackground().GetColor() ); }
/// @see SfxViewShell::registerLibreOfficeKitViewCallback(). /// Informs this edit view about which view shell contains it.
void registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable); void RegisterViewShell(OutlinerViewShell* pViewShell);
/// Invokes the registered view callback, if there are any.
void libreOfficeKitViewCallback(int nType, const char* pPayload) const;
bool IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong ); bool IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong );
OUString SpellIgnoreWord(); OUString SpellIgnoreWord();

View File

@ -1421,9 +1421,9 @@ void OutlinerView::SetBackgroundColor( const Color& rColor )
pEditView->SetBackgroundColor( rColor ); pEditView->SetBackgroundColor( rColor );
} }
void OutlinerView::registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable) void OutlinerView::RegisterViewShell(OutlinerViewShell* pViewShell)
{ {
pEditView->registerLibreOfficeKitViewCallback(pCallable); pEditView->RegisterViewShell(pViewShell);
} }
Color OutlinerView::GetBackgroundColor() Color OutlinerView::GetBackgroundColor()

View File

@ -35,8 +35,7 @@
class EditEngine; class EditEngine;
class ImpEditEngine; class ImpEditEngine;
class ImpEditView; class ImpEditView;
class OutlinerSearchable; class OutlinerViewShell;
class OutlinerViewCallable;
class SvxSearchItem; class SvxSearchItem;
class SvxFieldItem; class SvxFieldItem;
namespace vcl { class Window; } namespace vcl { class Window; }
@ -183,8 +182,8 @@ public:
void SetBackgroundColor( const Color& rColor ); void SetBackgroundColor( const Color& rColor );
Color GetBackgroundColor() const; Color GetBackgroundColor() const;
/// Register a LOK view callback. /// Informs this edit view about which view shell contains it.
void registerLibreOfficeKitViewCallback(OutlinerViewCallable *pCallable); void RegisterViewShell(OutlinerViewShell* pViewShell);
void SetControlWord( EVControlBits nWord ); void SetControlWord( EVControlBits nWord );
EVControlBits GetControlWord() const; EVControlBits GetControlWord() const;

View File

@ -72,8 +72,7 @@ class SvKeyValueIterator;
class SvxForbiddenCharactersTable; class SvxForbiddenCharactersTable;
class OverflowingText; class OverflowingText;
class NonOverflowingText; class NonOverflowingText;
class OutlinerSearchable; class OutlinerViewShell;
class OutlinerViewCallable;
namespace svl namespace svl
{ {
@ -270,8 +269,8 @@ public:
void SetBackgroundColor( const Color& rColor ); void SetBackgroundColor( const Color& rColor );
Color GetBackgroundColor(); Color GetBackgroundColor();
/// Registers a LOK view callback. /// Informs this edit view about which view shell contains it.
void registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable); void RegisterViewShell(OutlinerViewShell* pViewShell);
SfxItemSet GetAttribs(); SfxItemSet GetAttribs();
@ -374,13 +373,14 @@ public:
}; };
/// Interface class to not depend on SfxViewShell in editeng. /// Interface class to not depend on SfxViewShell in editeng.
class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewCallable class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
{ {
public: public:
virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0; virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
virtual sal_uInt32 GetViewShellId() const = 0;
protected: protected:
~OutlinerViewCallable() throw () {} ~OutlinerViewShell() throw () {}
}; };
// some thesaurus functionality to avoid code duplication in different projects... // some thesaurus functionality to avoid code duplication in different projects...

View File

@ -141,7 +141,7 @@ template<class T> bool checkSfxViewShell(const SfxViewShell* pShell)
return dynamic_cast<const T*>(pShell) != nullptr; return dynamic_cast<const T*>(pShell) != nullptr;
} }
class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewCallable class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell
{ {
#ifdef INCLUDED_SFX2_VIEWSH_HXX #ifdef INCLUDED_SFX2_VIEWSH_HXX
friend class SfxViewFrame; friend class SfxViewFrame;
@ -334,7 +334,8 @@ public:
/// See lok::Document::getPart(). /// See lok::Document::getPart().
virtual int getPart() const; virtual int getPart() const;
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const; virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
sal_uInt32 GetViewShellId() const; /// See OutlinerViewShell::GetViewShellId().
sal_uInt32 GetViewShellId() const override;
}; };

View File

@ -1882,7 +1882,7 @@ void ScInputHandler::UpdateActiveView()
{ {
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive())
{ {
pTableView->registerLibreOfficeKitViewCallback(pActiveViewSh); pTableView->RegisterViewShell(pActiveViewSh);
} }
} }

View File

@ -974,7 +974,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive())
{ {
pEditView[eWhich]->registerLibreOfficeKitViewCallback(pViewShell); pEditView[eWhich]->RegisterViewShell(pViewShell);
} }
} }

View File

@ -542,7 +542,7 @@ OutlinerView* SdrObjEditView::ImpMakeOutlinerView(vcl::Window* pWin, bool /*bNoP
// depend on the application owning this draw view to provide the view // depend on the application owning this draw view to provide the view
// shell. // shell.
SfxViewShell* pSfxViewShell = pViewShell ? pViewShell : GetSfxViewShell(); SfxViewShell* pSfxViewShell = pViewShell ? pViewShell : GetSfxViewShell();
pOutlView->registerLibreOfficeKitViewCallback(pSfxViewShell ? pSfxViewShell : SfxViewShell::Current()); pOutlView->RegisterViewShell(pSfxViewShell ? pSfxViewShell : SfxViewShell::Current());
if (pText!=nullptr) if (pText!=nullptr)
{ {

View File

@ -614,7 +614,7 @@ void SwSidebarWin::InitControls()
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive())
{ {
// If there is a callback already registered, inform the new outliner view about it. // If there is a callback already registered, inform the new outliner view about it.
mpOutlinerView->registerLibreOfficeKitViewCallback(&mrView); mpOutlinerView->RegisterViewShell(&mrView);
} }
//create Scrollbars //create Scrollbars