Kaydet (Commit) 0f58e974 authored tarafından Pranav Kant's avatar Pranav Kant

lokdialog: Better dialog rendering API

After painting the dialog, also write width and height of the rendered
dialog. The dialog is rendered
always on the top left of the given canvas, so client can crop the
canvas accordingly.

Change-Id: If052058a6db8a85d4e28ec88cffcca05564b17f0
üst 1325fabb
......@@ -18,6 +18,8 @@
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <vcl/scheduler.hxx>
#include <comphelper/processfactory.hxx>
#include <rtl/uri.hxx>
#include <sfx2/objsh.hxx>
......
......@@ -591,7 +591,7 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
int* pFontHeight);
static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, int nWidth, int nHeight);
static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
: mxComponent(xComponent)
......@@ -3012,7 +3012,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
return nullptr;
}
static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, int nWidth, int nHeight)
static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
{
SolarMutexGuard aGuard;
......@@ -3021,11 +3021,11 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned char* pBuffe
ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer);
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(*nWidth, *nHeight), Fraction(1.0), Point(), pBuffer);
vcl::DialogID aDialogID(pDialogRenderable->findDialog());
vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
pDialogRenderable->paintDialog(aDialogID, *pDevice.get(), nWidth, nHeight);
pDialogRenderable->paintDialog(aDialogID, *pDevice.get(), *nWidth, *nHeight);
}
static char* lo_getError (LibreOfficeKit *pThis)
......
......@@ -293,6 +293,7 @@ certain functionality.
@li @c lok
@li @c lok.tiledrendering
@li @c lok.dialog
@section l10ntools
......
......@@ -14,26 +14,29 @@
#include <tools/gen.hxx>
#include <vcl/pointr.hxx>
#include <vcl/virdev.hxx>
#include <vcl/window.hxx>
#include "IDialogRenderable.hxx"
#include <map>
namespace vcl
{
typedef sal_Int32 DialogID;
typedef OUString DialogID;
class VCL_DLLPUBLIC IDialogRenderable
{
public:
virtual ~IDialogRenderable();
virtual DialogID findDialog() = 0;
virtual void paintDialog(DialogID rDialogID, VirtualDevice &rDevice,
int nOutputWidth, int nOutputHeight) = 0;
virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice,
int& nOutputWidth, int& nOutputHeight) = 0;
virtual void postDialogMouseEvent(DialogID rDialogID, int nType,
virtual void postDialogMouseEvent(const DialogID& rDialogID, int nType,
int nCharCode, int nKeyCode) = 0;
virtual void postDialogKeyEvent(DialogID rDialogID, int nType, int nX, int nY,
virtual void postDialogKeyEvent(const DialogID& rDialogID, int nType, int nX, int nY,
int nCount, int nButtons, int nModifier) = 0;
};
......
......@@ -114,6 +114,9 @@ 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
......
......@@ -431,12 +431,11 @@ public:
/// @see vcl::ITiledRenderable::getPostIts().
OUString getPostIts() override;
vcl::DialogID findDialog() override;
void paintDialog(vcl::DialogID rDialogID, VirtualDevice &rDevice, int nWidth, int nHeight) override;
void postDialogMouseEvent(vcl::DialogID rDialogID, int nType,
void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) override;
void postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType,
int nCharCode, int nKeyCode) override;
void postDialogKeyEvent(vcl::DialogID rDialogID, int nType, int nX, int nY,
void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY,
int nCount, int nButtons, int nModifier) override;
// css::tiledrendering::XTiledRenderable
......
......@@ -33,6 +33,8 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/sfxbasecontroller.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/msg.hxx>
#include <sfx2/msgpool.hxx>
#include <sfx2/printer.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <toolkit/awt/vclxdevice.hxx>
......@@ -3636,32 +3638,35 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
#endif
}
vcl::DialogID SwXTextDocument::findDialog()
void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight)
{
return vcl::DialogID(0);
}
void SwXTextDocument::paintDialog(vcl::DialogID /*rDialogID*/, VirtualDevice& rDevice, int nWidth, int nHeight)
{
SfxViewShell* pViewShell = pDocShell->GetView();
SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
SfxChildWindow* pSfxChildWindow = SwSpellDialogChildWindow::CreateImpl(&pViewFrame->GetWindow(), SwSpellDialogChildWindow::GetChildWindowId(),
&pViewFrame->GetBindings(), nullptr);
Size aSize(nWidth, nHeight);
vcl::Window* pWindow = pSfxChildWindow->GetWindow();
SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
if (!pChild)
{
pViewFrame->ToggleChildWindow(pSlot->GetSlotId());
pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
if (!pChild)
{
SAL_WARN("lok.dialog", "Dialog " << rDialogID << " is not supported");
return;
}
}
pWindow->SetSizePixel(aSize);
pWindow->Show();
pWindow->Paint(rDevice, tools::Rectangle(Point(), aSize));
Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow());
pDlg->paintDialog(rDevice);
const Size aSize = pDlg->GetOptimalSize();
nWidth = aSize.getWidth();
nHeight = aSize.getHeight();
}
void SwXTextDocument::postDialogMouseEvent(vcl::DialogID /*rDialogID*/, int /*nType*/, int /*nCharCode*/, int /*nKeyCode*/)
void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& /*rDialogID*/, int /*nType*/, int /*nCharCode*/, int /*nKeyCode*/)
{
}
void SwXTextDocument::postDialogKeyEvent(vcl::DialogID /*rDialogID*/, int /*nType*/, int /*nX*/, int /*nY*/,
void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& /*rDialogID*/, int /*nType*/, int /*nX*/, int /*nY*/,
int /*nCount*/, int /*nButtons*/, int /*nModifier*/)
{
}
......
......@@ -51,6 +51,7 @@
#include <vcl/settings.hxx>
#include <vcl/uitest/uiobject.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/virdev.hxx>
#include <salframe.hxx>
#include <iostream>
......@@ -857,6 +858,17 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/)
return true;
}
void Dialog::paintDialog(VirtualDevice& rDevice)
{
setDeferredProperties();
ImplAdjustNWFSizes();
Show();
ToTop();
ensureRepaint();
PaintToDevice(&rDevice, Point(0, 0), Size());
}
void Dialog::ensureRepaint()
{
// ensure repaint
......
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