sw lok: move filtering of callbacks during paint to desktop

This will be important when in the per-view case
SwViewShell::libreOfficeKitCallback() won't be called anymore; as
pointed out by online.git's TileCacheTests::testSimpleCombine() test.

Change-Id: Ie68f8c51facdba127763df660e9220f820805ecc
Reviewed-on: https://gerrit.libreoffice.org/26372
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna
2016-06-16 15:55:43 +02:00
parent 90fa0d8f1a
commit a93217908d
4 changed files with 11 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ namespace desktop {
class DESKTOP_DLLPUBLIC CallbackFlushHandler : public Idle
{
public:
explicit CallbackFlushHandler(LibreOfficeKitCallback pCallback, void* pData);
explicit CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData);
virtual ~CallbackFlushHandler();
virtual void Invoke() override;
static void callback(const int type, const char* payload, void* data);
@@ -44,6 +44,7 @@ namespace desktop {
std::vector<std::pair<int, std::string>> m_queue;
std::map<int, std::string> m_states;
LibreOfficeKitDocument* m_pDocument;
LibreOfficeKitCallback m_pCallback;
void *m_pData;
bool m_bPartTilePainting;

View File

@@ -1277,8 +1277,9 @@ static void callbackCompressionTest(const int type, const char* payload, void* d
void DesktopLOKTest::testNotificationCompression()
{
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
std::vector<std::tuple<int, std::string>> notifs;
std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(callbackCompressionTest, &notifs));
std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0
handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseeded.

View File

@@ -430,8 +430,9 @@ LibLODocument_Impl::~LibLODocument_Impl()
mxComponent->dispose();
}
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitCallback pCallback, void* pData)
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData)
: Idle( "lokit timer callback" ),
m_pDocument(pDocument),
m_pCallback(pCallback),
m_pData(pData),
m_bPartTilePainting(false)
@@ -498,6 +499,10 @@ void CallbackFlushHandler::queue(const int type, const char* data)
//SAL_WARN("lokevt", "Skipping while painting [" + std::to_string(type) + "]: [" + payload + "].");
return;
}
// In Writer we drop all notifications during painting.
if (doc_getDocumentType(m_pDocument) == LOK_DOCTYPE_TEXT)
return;
}
// Supress invalid payloads.
@@ -1338,7 +1343,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0;
pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pCallback, pData));
pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pThis, pCallback, pData));
if (comphelper::LibreOfficeKit::isViewCallback())
{

View File

@@ -124,9 +124,6 @@ void SwViewShell::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallbac
void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload) const
{
if (mbInLibreOfficeKitCallback)
return;
getIDocumentDrawModelAccess().GetDrawModel()->libreOfficeKitCallback(nType, pPayload);
}