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;
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();
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();
}
void EditView::registerLibreOfficeKitViewCallback(OutlinerViewCallable *pCallable)
void EditView::RegisterViewShell(OutlinerViewShell* pViewShell)
{
pImpEditView->registerLibreOfficeKitViewCallback(pCallable);
pImpEditView->RegisterViewShell(pViewShell);
}
void EditView::SetControlWord( EVControlBits nWord )

View File

@ -79,7 +79,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
pOutWin = pWindow;
pPointer = nullptr;
pBackgroundColor = nullptr;
mpLibreOfficeKitViewCallable = nullptr;
mpViewShell = nullptr;
nScrollDiffX = 0;
nExtraCursorFlags = 0;
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
@ -117,15 +117,9 @@ void ImpEditView::SetBackgroundColor( const Color& rColor )
pBackgroundColor = new Color( rColor );
}
void ImpEditView::registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable)
void ImpEditView::RegisterViewShell(OutlinerViewShell* pViewShell)
{
mpLibreOfficeKitViewCallable = pCallable;
}
void ImpEditView::libreOfficeKitViewCallback(int nType, const char* pPayload) const
{
if (mpLibreOfficeKitViewCallable)
mpLibreOfficeKitViewCallable->libreOfficeKitViewCallback(nType, pPayload);
mpViewShell = pViewShell;
}
void ImpEditView::SetEditSelection( const EditSelection& rEditSelection )
@ -343,7 +337,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
{
*pRegion = vcl::Region( *pPolyPoly );
if (comphelper::LibreOfficeKit::isActive() && !pOldRegion)
if (comphelper::LibreOfficeKit::isActive() && mpViewShell && !pOldRegion)
{
pOutWin->Push(PushFlags::MAPMODE);
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.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 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.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;
@ -408,7 +402,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
sRectangle = comphelper::string::join("; ", v);
}
libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
pOutWin->Pop();
}
@ -986,7 +980,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
GetCursor()->SetSize( aCursorSz );
if (comphelper::LibreOfficeKit::isActive())
if (comphelper::LibreOfficeKit::isActive() && mpViewShell)
{
const Point& rPos = GetCursor()->GetPos();
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);
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;

View File

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

View File

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

View File

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

View File

@ -72,8 +72,7 @@ class SvKeyValueIterator;
class SvxForbiddenCharactersTable;
class OverflowingText;
class NonOverflowingText;
class OutlinerSearchable;
class OutlinerViewCallable;
class OutlinerViewShell;
namespace svl
{
@ -270,8 +269,8 @@ public:
void SetBackgroundColor( const Color& rColor );
Color GetBackgroundColor();
/// Registers a LOK view callback.
void registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable);
/// Informs this edit view about which view shell contains it.
void RegisterViewShell(OutlinerViewShell* pViewShell);
SfxItemSet GetAttribs();
@ -374,13 +373,14 @@ public:
};
/// 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:
virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
virtual sal_uInt32 GetViewShellId() const = 0;
protected:
~OutlinerViewCallable() throw () {}
~OutlinerViewShell() throw () {}
};
// 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;
}
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
friend class SfxViewFrame;
@ -334,7 +334,8 @@ public:
/// See lok::Document::getPart().
virtual int getPart() 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())
{
pTableView->registerLibreOfficeKitViewCallback(pActiveViewSh);
pTableView->RegisterViewShell(pActiveViewSh);
}
}

View File

@ -974,7 +974,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
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
// shell.
SfxViewShell* pSfxViewShell = pViewShell ? pViewShell : GetSfxViewShell();
pOutlView->registerLibreOfficeKitViewCallback(pSfxViewShell ? pSfxViewShell : SfxViewShell::Current());
pOutlView->RegisterViewShell(pSfxViewShell ? pSfxViewShell : SfxViewShell::Current());
if (pText!=nullptr)
{

View File

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