summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-10-21 19:29:38 -0400
committerJan Holesovsky <kendy@collabora.com>2019-04-30 18:06:25 +0200
commit36cc2eab944aae6338234f31ac9bd54d4048729e (patch)
tree74301d9f8ae7069fa88640ac24cf1a1923cd7deb
parent49fe72fe93d6b292da275fd0508a01b49a86fa3b (diff)
LOK: support resizing windows
And delegate resizing of floating windows. Currently used for resizing sidebars in LOK. Change-Id: Iadc1b71c15a7d16a8c9dd7246490ae6bd645644c
-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 a952dcd0a0a0..3df2a5645471 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2670,9 +2670,10 @@ void DesktopLOKTest::testABI()
CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct _LibreOfficeKitDocumentClass, postWindowGestureEvent));
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 853b0a7882dd..4a5bdc20fb9b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -821,6 +821,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)
{
@@ -876,6 +879,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;
@@ -4425,6 +4429,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 f163660b0f68..1975a8d6ebf6 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -372,6 +372,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 8c0d0df145f9..61c2e44b5024 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -636,6 +636,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 26a43bbde581..a3f3f6797810 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -834,6 +834,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))