Kaydet (Commit) 9874cd5e authored tarafından Pranav Kant's avatar Pranav Kant

lokdialog: Dialog invalidation support

For now, just invalidate the whole dialog whenever any of the controls
in the dialog get invalidated.

Since during dialog painting, many such invalidations are triggered,
don't listen to them when we are painting.

Change-Id: Ia8fc12cf9469691d60e91ef770d687e5ff01a7ef
üst 706e4d19
......@@ -21,6 +21,8 @@ static bool g_bPartInInvalidation(false);
static bool g_bTiledPainting(false);
static bool g_bDialogPainting(false);
static bool g_bTiledAnnotations(true);
void setActive(bool bActive)
......@@ -53,6 +55,16 @@ bool isTiledPainting()
return g_bTiledPainting;
}
void setDialogPainting(bool bDialogPainting)
{
g_bDialogPainting = bDialogPainting;
}
bool isDialogPainting()
{
return g_bDialogPainting;
}
void setTiledAnnotations(bool bTiledAnnotations)
{
g_bTiledAnnotations = bTiledAnnotations;
......
......@@ -521,7 +521,11 @@ typedef enum
*
* Here all aproperties are same as described in svxruler.
*/
LOK_CALLBACK_RULER_UPDATE = 35
LOK_CALLBACK_RULER_UPDATE = 35,
/**
* Dialog invalidation
*/
LOK_CALLBACK_DIALOG_INVALIDATE = 36
}
LibreOfficeKitCallbackType;
......
......@@ -52,6 +52,10 @@ COMPHELPER_DLLPUBLIC void setPartInInvalidation(bool bPartInInvalidation);
COMPHELPER_DLLPUBLIC bool isTiledPainting();
/// Set if we are doing tiled painting.
COMPHELPER_DLLPUBLIC void setTiledPainting(bool bTiledPainting);
/// Check if we are painting the dialog.
COMPHELPER_DLLPUBLIC bool isDialogPainting();
/// Set if we are painting the dialog.
COMPHELPER_DLLPUBLIC void setDialogPainting(bool bDialogPainting);
/// Set if we want no annotations rendering
COMPHELPER_DLLPUBLIC void setTiledAnnotations(bool bTiledAnnotations);
/// Check if annotations rendering is turned off
......
......@@ -105,6 +105,8 @@ public:
SfxBindings& GetBindings()
{ return *pBindings; }
virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override;
DECL_LINK(TimerHdl, Timer *, void);
};
......
......@@ -40,6 +40,8 @@ public:
static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload);
/// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
/// Emits a LOK_CALLBACK_DIALOG_INVALIDATE with 'invalidate' action
static void notifyDialogInvalidation(const OUString& rPayload);
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
/// A special value to signify 'infinity'.
......
......@@ -44,6 +44,8 @@ private:
SAL_DLLPRIVATE void ImplInitControlData();
virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override;
Control (const Control &) = delete;
Control & operator= (const Control &) = delete;
......
......@@ -72,10 +72,14 @@ private:
protected:
using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
OUString maID; // identifier for this dialog
public:
SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
virtual void doDeferredInit(WinBits nBits) override;
virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override { (void)pRectangle; }
// Paints the current dialog to the given virtual device
void paintDialog(VirtualDevice& rDevice);
protected:
explicit Dialog( WindowType nType );
......@@ -114,9 +118,6 @@ public:
virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
// Paints the current dialog to the given virtual device
void paintDialog(VirtualDevice& rDevice);
// ensureRepaint - triggers Application::Yield until the dialog is
// completely repainted. Sometimes needed for dialogs showing progress
// during actions
......
......@@ -436,6 +436,8 @@ callbackTypeToString (int nType)
return "LOK_CALLBACK_COMMENT";
case LOK_CALLBACK_RULER_UPDATE:
return "LOK_CALLBACK_RULER_UPDATE";
case LOK_CALLBACK_DIALOG_INVALIDATE:
return "LOK_CALLBACK_DIALOG_INVALIDATE";
}
g_assert(false);
return nullptr;
......@@ -1427,6 +1429,8 @@ callback (gpointer pData)
break;
case LOK_CALLBACK_RULER_UPDATE:
g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, pCallback->m_aPayload.c_str());
case LOK_CALLBACK_DIALOG_INVALIDATE:
// TODO: Register the signal with lokdocview and emit it
break;
default:
g_assert(false);
......
......@@ -18,7 +18,10 @@
*/
#include <stdlib.h>
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <osl/file.hxx>
#include <vcl/fixed.hxx>
#include <vcl/help.hxx>
......@@ -29,6 +32,7 @@
#include <vcl/idle.hxx>
#include <sfx2/basedlgs.hxx>
#include <sfx2/lokhelper.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/tabdlg.hxx>
#include <sfx2/app.hxx>
......@@ -390,6 +394,13 @@ void SfxModelessDialog::FillInfo(SfxChildWinInfo& rInfo) const
}
void SfxModelessDialog::LogicInvalidate(const tools::Rectangle* /*pRectangle*/)
{
if (!comphelper::LibreOfficeKit::isDialogPainting())
SfxLokHelper::notifyDialogInvalidation(maID);
}
bool SfxFloatingWindow::EventNotify( NotifyEvent& rEvt )
/* [Description]
......
......@@ -144,6 +144,19 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
}
}
void SfxLokHelper::notifyDialogInvalidation(const OUString& rDialogID)
{
if (SfxLokHelper::getViewsCount() <= 0)
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG_INVALIDATE, OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr());
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
{
OStringBuffer aBuf;
......
......@@ -18,11 +18,13 @@
*/
#include <comphelper/processfactory.hxx>
#include <comphelper/lok.hxx>
#include <vcl/svapp.hxx>
#include <vcl/event.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/decoview.hxx>
#include <vcl/dialog.hxx>
#include <vcl/salnativewidgets.hxx>
#include <vcl/settings.hxx>
#include <vcl/uitest/logger.hxx>
......@@ -412,6 +414,19 @@ void Control::ImplInitSettings()
ApplySettings(*this);
}
void Control::LogicInvalidate(const tools::Rectangle* /*pRectangle*/)
{
// Several repaint, resize invalidations are emitted when we are painting,
// ignore all of those
if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isDialogPainting())
{
// For now just invalidate the whole dialog
Dialog* pParentDlg = GetParentDialog();
if (pParentDlg)
pParentDlg->LogicInvalidate(nullptr);
}
}
tools::Rectangle Control::DrawControlText( OutputDevice& _rTargetDevice, const tools::Rectangle& rRect, const OUString& _rStr,
DrawTextFlags _nStyle, MetricVector* _pVector, OUString* _pDisplayText, const Size* i_pDeviceSize ) const
{
......
......@@ -514,6 +514,7 @@ void Dialog::doDeferredInit(WinBits nBits)
Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription)
: SystemWindow(WindowType::DIALOG)
, mnInitFlag(InitFlag::Default)
, maID(rID)
{
ImplInitDialogData();
loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);
......@@ -522,6 +523,7 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML
Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag)
: SystemWindow(nType)
, mnInitFlag(eFlag)
, maID(rID)
{
ImplInitDialogData();
loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);
......
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