editeng: implement per-view LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR
Given that the per-view callback is in SfxViewShell, and editeng doesn't depend on sfx2, add an interface class in editeng to invert the dependency. With this, gtktiledviewer no longer crashes when starting editeng text edit with per-view callbacks. Change-Id: I783cdc646b890a6b597000f1d88428c8042417cf Reviewed-on: https://gerrit.libreoffice.org/26169 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
parent
30104ff4c7
commit
89bbd0ecbf
@ -583,6 +583,11 @@ void EditView::registerLibreOfficeKitCallback(OutlinerSearchable *pSearchable)
|
|||||||
pImpEditView->registerLibreOfficeKitCallback(pSearchable);
|
pImpEditView->registerLibreOfficeKitCallback(pSearchable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditView::registerLibreOfficeKitViewCallback(OutlinerViewCallable *pCallable)
|
||||||
|
{
|
||||||
|
pImpEditView->registerLibreOfficeKitViewCallback(pCallable);
|
||||||
|
}
|
||||||
|
|
||||||
void EditView::SetControlWord( EVControlBits nWord )
|
void EditView::SetControlWord( EVControlBits nWord )
|
||||||
{
|
{
|
||||||
pImpEditView->nControl = nWord;
|
pImpEditView->nControl = nWord;
|
||||||
|
@ -80,6 +80,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
|
|||||||
pPointer = nullptr;
|
pPointer = nullptr;
|
||||||
pBackgroundColor = nullptr;
|
pBackgroundColor = nullptr;
|
||||||
mpLibreOfficeKitSearchable = nullptr;
|
mpLibreOfficeKitSearchable = nullptr;
|
||||||
|
mpLibreOfficeKitViewCallable = nullptr;
|
||||||
nScrollDiffX = 0;
|
nScrollDiffX = 0;
|
||||||
nExtraCursorFlags = 0;
|
nExtraCursorFlags = 0;
|
||||||
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
|
nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
|
||||||
@ -119,6 +120,8 @@ void ImpEditView::SetBackgroundColor( const Color& rColor )
|
|||||||
|
|
||||||
void ImpEditView::registerLibreOfficeKitCallback(OutlinerSearchable* pSearchable)
|
void ImpEditView::registerLibreOfficeKitCallback(OutlinerSearchable* pSearchable)
|
||||||
{
|
{
|
||||||
|
// Per-view callbacks should always invoke ImpEditView::registerLibreOfficeKitViewCallback().
|
||||||
|
assert(!comphelper::LibreOfficeKit::isViewCallback());
|
||||||
mpLibreOfficeKitSearchable = pSearchable;
|
mpLibreOfficeKitSearchable = pSearchable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +131,17 @@ void ImpEditView::libreOfficeKitCallback(int nType, const char* pPayload) const
|
|||||||
mpLibreOfficeKitSearchable->libreOfficeKitCallback(nType, pPayload);
|
mpLibreOfficeKitSearchable->libreOfficeKitCallback(nType, pPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImpEditView::registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable)
|
||||||
|
{
|
||||||
|
mpLibreOfficeKitViewCallable = pCallable;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 )
|
||||||
{
|
{
|
||||||
// set state before notification
|
// set state before notification
|
||||||
@ -1002,6 +1016,9 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
|
|||||||
aRect.setWidth(0);
|
aRect.setWidth(0);
|
||||||
|
|
||||||
OString sRect = aRect.toString();
|
OString sRect = aRect.toString();
|
||||||
|
if (comphelper::LibreOfficeKit::isViewCallback())
|
||||||
|
libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
|
||||||
|
else
|
||||||
libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
|
libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,10 @@ private:
|
|||||||
EditView* pEditView;
|
EditView* pEditView;
|
||||||
vcl::Cursor* pCursor;
|
vcl::Cursor* pCursor;
|
||||||
Color* pBackgroundColor;
|
Color* pBackgroundColor;
|
||||||
|
/// Model callback.
|
||||||
OutlinerSearchable* mpLibreOfficeKitSearchable;
|
OutlinerSearchable* mpLibreOfficeKitSearchable;
|
||||||
|
/// Per-view callback.
|
||||||
|
OutlinerViewCallable* mpLibreOfficeKitViewCallable;
|
||||||
EditEngine* pEditEngine;
|
EditEngine* pEditEngine;
|
||||||
VclPtr<vcl::Window> pOutWin;
|
VclPtr<vcl::Window> pOutWin;
|
||||||
Pointer* pPointer;
|
Pointer* pPointer;
|
||||||
@ -368,8 +371,12 @@ public:
|
|||||||
|
|
||||||
/// @see vcl::ITiledRenderable::registerCallback().
|
/// @see vcl::ITiledRenderable::registerCallback().
|
||||||
void registerLibreOfficeKitCallback(OutlinerSearchable* pSearchable);
|
void registerLibreOfficeKitCallback(OutlinerSearchable* pSearchable);
|
||||||
/// Invokes the registered callback, if there are any.
|
/// Invokes the registered model callback, if there are any.
|
||||||
void libreOfficeKitCallback(int nType, const char* pPayload) const;
|
void libreOfficeKitCallback(int nType, const char* pPayload) const;
|
||||||
|
/// @see vcl::ITiledRenderable::registerCallback().
|
||||||
|
void registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable);
|
||||||
|
/// 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();
|
||||||
|
@ -1426,6 +1426,11 @@ void OutlinerView::registerLibreOfficeKitCallback(OutlinerSearchable* pSearchabl
|
|||||||
pEditView->registerLibreOfficeKitCallback(pSearchable);
|
pEditView->registerLibreOfficeKitCallback(pSearchable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OutlinerView::registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable)
|
||||||
|
{
|
||||||
|
pEditView->registerLibreOfficeKitViewCallback(pCallable);
|
||||||
|
}
|
||||||
|
|
||||||
Color OutlinerView::GetBackgroundColor()
|
Color OutlinerView::GetBackgroundColor()
|
||||||
{
|
{
|
||||||
return pEditView->GetBackgroundColor();
|
return pEditView->GetBackgroundColor();
|
||||||
|
@ -36,6 +36,7 @@ class EditEngine;
|
|||||||
class ImpEditEngine;
|
class ImpEditEngine;
|
||||||
class ImpEditView;
|
class ImpEditView;
|
||||||
class OutlinerSearchable;
|
class OutlinerSearchable;
|
||||||
|
class OutlinerViewCallable;
|
||||||
class SvxSearchItem;
|
class SvxSearchItem;
|
||||||
class SvxFieldItem;
|
class SvxFieldItem;
|
||||||
namespace vcl { class Window; }
|
namespace vcl { class Window; }
|
||||||
@ -182,8 +183,10 @@ public:
|
|||||||
void SetBackgroundColor( const Color& rColor );
|
void SetBackgroundColor( const Color& rColor );
|
||||||
Color GetBackgroundColor() const;
|
Color GetBackgroundColor() const;
|
||||||
|
|
||||||
/// @see vcl::ITiledRenderable::registerCallback().
|
/// Register a LOK model callback.
|
||||||
void registerLibreOfficeKitCallback(OutlinerSearchable *pSearchable);
|
void registerLibreOfficeKitCallback(OutlinerSearchable *pSearchable);
|
||||||
|
/// Register a LOK view callback.
|
||||||
|
void registerLibreOfficeKitViewCallback(OutlinerViewCallable *pCallable);
|
||||||
|
|
||||||
void SetControlWord( EVControlBits nWord );
|
void SetControlWord( EVControlBits nWord );
|
||||||
EVControlBits GetControlWord() const;
|
EVControlBits GetControlWord() const;
|
||||||
|
@ -73,6 +73,7 @@ class SvxForbiddenCharactersTable;
|
|||||||
class OverflowingText;
|
class OverflowingText;
|
||||||
class NonOverflowingText;
|
class NonOverflowingText;
|
||||||
class OutlinerSearchable;
|
class OutlinerSearchable;
|
||||||
|
class OutlinerViewCallable;
|
||||||
|
|
||||||
namespace svl
|
namespace svl
|
||||||
{
|
{
|
||||||
@ -269,8 +270,10 @@ public:
|
|||||||
void SetBackgroundColor( const Color& rColor );
|
void SetBackgroundColor( const Color& rColor );
|
||||||
Color GetBackgroundColor();
|
Color GetBackgroundColor();
|
||||||
|
|
||||||
/// @see vcl::ITiledRenderable::registerCallback().
|
/// Registers a LOK model callback.
|
||||||
void registerLibreOfficeKitCallback(OutlinerSearchable* pSearchable);
|
void registerLibreOfficeKitCallback(OutlinerSearchable* pSearchable);
|
||||||
|
/// Registers a LOK view callback.
|
||||||
|
void registerLibreOfficeKitViewCallback(OutlinerViewCallable* pCallable);
|
||||||
|
|
||||||
SfxItemSet GetAttribs();
|
SfxItemSet GetAttribs();
|
||||||
|
|
||||||
@ -381,6 +384,16 @@ public:
|
|||||||
virtual void libreOfficeKitCallback(int nType, const char* pPayload) const = 0;
|
virtual void libreOfficeKitCallback(int nType, const char* pPayload) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Interface class to not depend on SfxViewShell in editeng, meant to replace OutlinerSearchable at the end.
|
||||||
|
class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewCallable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~OutlinerViewCallable() throw () {}
|
||||||
|
};
|
||||||
|
|
||||||
// some thesaurus functionality to avoid code duplication in different projects...
|
// some thesaurus functionality to avoid code duplication in different projects...
|
||||||
bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView );
|
bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView );
|
||||||
void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText );
|
void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText );
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <vcl/vclptr.hxx>
|
#include <vcl/vclptr.hxx>
|
||||||
#include <sfx2/tabdlg.hxx>
|
#include <sfx2/tabdlg.hxx>
|
||||||
#include <LibreOfficeKit/LibreOfficeKitTypes.h>
|
#include <LibreOfficeKit/LibreOfficeKitTypes.h>
|
||||||
|
#include <editeng/outliner.hxx>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class SfxBaseController;
|
class SfxBaseController;
|
||||||
@ -140,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
|
class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewCallable
|
||||||
{
|
{
|
||||||
#ifdef INCLUDED_SFX2_VIEWSH_HXX
|
#ifdef INCLUDED_SFX2_VIEWSH_HXX
|
||||||
friend class SfxViewFrame;
|
friend class SfxViewFrame;
|
||||||
@ -325,7 +326,7 @@ public:
|
|||||||
/// The actual per-view implementation of lok::Document::registerCallback().
|
/// The actual per-view implementation of lok::Document::registerCallback().
|
||||||
void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
|
void registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
|
||||||
/// Invokes the registered callback, if there are any.
|
/// Invokes the registered callback, if there are any.
|
||||||
void libreOfficeKitViewCallback(int nType, const char* pPayload) const;
|
void libreOfficeKitViewCallback(int nType, const char* pPayload) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
#include <svx/sdr/table/tablecontroller.hxx>
|
#include <svx/sdr/table/tablecontroller.hxx>
|
||||||
#include <drawinglayer/processor2d/processor2dtools.hxx>
|
#include <drawinglayer/processor2d/processor2dtools.hxx>
|
||||||
#include <comphelper/lok.hxx>
|
#include <comphelper/lok.hxx>
|
||||||
|
#include <sfx2/viewsh.hxx>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -460,6 +461,9 @@ OutlinerView* SdrObjEditView::ImpMakeOutlinerView(vcl::Window* pWin, bool /*bNoP
|
|||||||
}
|
}
|
||||||
pOutlView->SetControlWord(nStat);
|
pOutlView->SetControlWord(nStat);
|
||||||
pOutlView->SetBackgroundColor( aBackground );
|
pOutlView->SetBackgroundColor( aBackground );
|
||||||
|
if (comphelper::LibreOfficeKit::isViewCallback())
|
||||||
|
pOutlView->registerLibreOfficeKitViewCallback(SfxViewShell::Current());
|
||||||
|
else
|
||||||
pOutlView->registerLibreOfficeKitCallback(GetModel());
|
pOutlView->registerLibreOfficeKitCallback(GetModel());
|
||||||
if (pText!=nullptr)
|
if (pText!=nullptr)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user