summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-10-21 19:29:38 -0400
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-25 19:25:01 +0200
commitca8f1ff34e291b74068dace619e58c37ef169f88 (patch)
tree3746aeb309ebc75f38d017d5f01a2d21e7b88368
parent987c03d5c237c6a86ac886991435220e7381ced1 (diff)
LOK: support resizing windows
And delegate resizing of floating windows. Currently used for resizing sidebars in LOK. Change-Id: Iadc1b71c15a7d16a8c9dd7246490ae6bd645644c Reviewed-on: https://gerrit.libreoffice.org/73509 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx3
-rw-r--r--desktop/source/lib/init.cxx21
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h5
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx14
-rw-r--r--vcl/source/window/dockwin.cxx5
5 files changed, 47 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e590b0a7f974..f10e1fb0f035 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2717,9 +2717,10 @@ void DesktopLOKTest::testABI()
CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct _LibreOfficeKitDocumentClass, createViewWithOptions));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), offsetof(struct _LibreOfficeKitDocumentClass, selectPart));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), offsetof(struct _LibreOfficeKitDocumentClass, moveSelectedParts));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(51), offsetof(struct _LibreOfficeKitDocumentClass, resizeWindow));
// Extending is fine, update this, and add new assert for the offsetof the
// new method
- CPPUNIT_ASSERT_EQUAL(documentClassOffset(51), sizeof(struct _LibreOfficeKitDocumentClass));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(52), sizeof(struct _LibreOfficeKitDocumentClass));
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 42972ce713b5..3f00cd57020f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -846,6 +846,9 @@ static int doc_getSignatureState(LibreOfficeKitDocument* pThis);
static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOutput);
+static void doc_resizeWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
+ const int nWidth, const int nHeight);
+
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
: mxComponent(xComponent)
{
@@ -904,6 +907,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->paintWindow = doc_paintWindow;
m_pDocumentClass->paintWindowDPI = doc_paintWindowDPI;
m_pDocumentClass->postWindow = doc_postWindow;
+ m_pDocumentClass->resizeWindow = doc_resizeWindow;
m_pDocumentClass->setViewLanguage = doc_setViewLanguage;
@@ -4604,6 +4608,23 @@ static int doc_getSignatureState(LibreOfficeKitDocument* pThis)
return int(pObjectShell->GetDocumentSignatureState());
}
+static void doc_resizeWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
+ const int nWidth, const int nHeight)
+{
+ SolarMutexGuard aGuard;
+ if (gImpl)
+ gImpl->maLastExceptionMsg.clear();
+
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+ if (!pWindow)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support dialog resizing, or window not found.";
+ return;
+ }
+
+ pWindow->SetSizePixel(Size(nWidth, nHeight));
+}
+
static char* lo_getError (LibreOfficeKit *pThis)
{
comphelper::ProfileZone aZone("lo_getError");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 896b441ff715..dedb75995930 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -384,6 +384,11 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::moveSelectedParts().
void (*moveSelectedParts) (LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate);
+ /// Resize window with given id.
+ /// @see lok::Document::resizeWindow().
+ void (*resizeWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
+ const int width, const int height);
+
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 3bd1c50bb0be..c6f90dc1ae24 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -664,6 +664,20 @@ public:
mpDoc->pClass->moveSelectedParts(mpDoc, nPosition, bDuplicate);
}
+ /**
+ * Resize a window (dialog, popup, etc.) with give id.
+ *
+ * @param nWindowId
+ * @param width The width of the window.
+ * @param height The height of the window.
+ */
+ void resizeWindow(unsigned nWindowId,
+ const int width,
+ const int height)
+ {
+ return mpDoc->pClass->resizeWindow(mpDoc, nWindowId, width, height);
+ }
+
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index 47f050d1af99..baa7da9c7a34 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -833,6 +833,11 @@ void DockingWindow::setPosSizePixel( long nX, long nY,
{
if (!mpFloatWin)
Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
+ else
+ {
+ mpFloatWin->SetOutputSizePixel(Size(nWidth, nHeight));
+ mpFloatWin->SetPosPixel(Point(nX, nY));
+ }
}
if (::isLayoutEnabled(this))