[Libreoffice-commits] core.git: 2 commits - desktop/qa desktop/source include/LibreOfficeKit sfx2/source vcl/source
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 25 17:25:52 UTC 2019
desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 +
desktop/source/lib/init.cxx | 21 ++++++++++++
include/LibreOfficeKit/LibreOfficeKit.h | 5 ++
include/LibreOfficeKit/LibreOfficeKit.hxx | 14 ++++++++
sfx2/source/sidebar/SidebarController.cxx | 48 ++++++++++++++++++++++------
vcl/source/window/dockwin.cxx | 5 ++
6 files changed, 85 insertions(+), 11 deletions(-)
New commits:
commit 4790923b8c7de719b6c4cb84aff5997a040df2c8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Oct 7 08:33:41 2018 -0400
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 25 19:25:14 2019 +0200
sfx2: collapse the sidebar instead of closing on toggle
When toggling a sidebar deck that is open, the default
behavior when floating is to close the sidebar altogether.
This is both inconsistent with the behaviour when docked
and unexpected.
Now we simply collapse the sidebar into the TabBar (toolbar)
as is done when docked. This is also the behavior desired
from LoKit since the sidebar is rendered floating (to allow
arbitrary resizing).
The collapsed sidebar into toolbar is shown in same-position.
Change-Id: I0519c5ad012cc9df31758927a4dbcd774d47fcd3
Reviewed-on: https://gerrit.libreoffice.org/73505
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 8f09d3f38af6..aa328608ffe3 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -32,6 +32,7 @@
#include <sfx2/sidebar/ContextList.hxx>
+#include <sfx2/lokhelper.hxx>
#include <sfx2/sfxresid.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/titledockwin.hxx>
@@ -524,16 +525,16 @@ void SidebarController::OpenThenToggleDeck (
pSplitWindow->FadeIn();
else if ( IsDeckVisible( rsDeckId ) )
{
- if ( pSplitWindow )
+ if( !WasFloatingDeckClosed() )
{
- // tdf#67627 Clicking a second time on a Deck icon will close the Deck
- RequestCloseDeck();
+ // tdf#88241 Summoning an undocked sidebar a second time should close sidebar
+ mpParentWindow->Close();
return;
}
- else if( !WasFloatingDeckClosed() )
+ else
{
- // tdf#88241 Summoning an undocked sidebar a second time should close sidebar
- mpParentWindow->Close();
+ // tdf#67627 Clicking a second time on a Deck icon will close the Deck
+ RequestCloseDeck();
return;
}
}
@@ -1134,7 +1135,7 @@ void SidebarController::UpdateDeckOpenState()
// No state requested.
return;
- sal_Int32 nTabBarDefaultWidth = TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor();
+ const sal_Int32 nTabBarDefaultWidth = TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor();
// Update (change) the open state when it either has not yet been initialized
// or when its value differs from the requested state.
@@ -1143,15 +1144,42 @@ void SidebarController::UpdateDeckOpenState()
if (mbIsDeckRequestedOpen.get())
{
- if (mnSavedSidebarWidth <= nTabBarDefaultWidth)
- SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow));
+ if (!mpParentWindow->IsFloatingMode())
+ {
+ if (mnSavedSidebarWidth <= nTabBarDefaultWidth)
+ SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow));
+ else
+ SetChildWindowWidth(mnSavedSidebarWidth);
+ }
else
- SetChildWindowWidth(mnSavedSidebarWidth);
+ {
+ // Show the Deck by resizing back to the original size (before hiding).
+ Size aNewSize(mpParentWindow->GetFloatingWindow()->GetSizePixel());
+ Point aNewPos(mpParentWindow->GetFloatingWindow()->GetPosPixel());
+
+ aNewPos.setX(aNewPos.X() - mnSavedSidebarWidth + nTabBarDefaultWidth);
+ aNewSize.setWidth(mnSavedSidebarWidth);
+
+ mpParentWindow->GetFloatingWindow()->SetPosSizePixel(aNewPos, aNewSize);
+ }
}
else
{
if ( ! mpParentWindow->IsFloatingMode())
mnSavedSidebarWidth = SetChildWindowWidth(nTabBarDefaultWidth);
+ else
+ {
+ // Hide the Deck by resizing to the width of the TabBar.
+ Size aNewSize(mpParentWindow->GetFloatingWindow()->GetSizePixel());
+ Point aNewPos(mpParentWindow->GetFloatingWindow()->GetPosPixel());
+ mnSavedSidebarWidth = aNewSize.Width(); // Save the current width to restore.
+
+ aNewPos.setX(aNewPos.X() + mnSavedSidebarWidth - nTabBarDefaultWidth);
+ aNewSize.setWidth(nTabBarDefaultWidth);
+
+ mpParentWindow->GetFloatingWindow()->SetPosSizePixel(aNewPos, aNewSize);
+ }
+
if (mnWidthOnSplitterButtonDown > nTabBarDefaultWidth)
mnSavedSidebarWidth = mnWidthOnSplitterButtonDown;
mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE);
commit ca8f1ff34e291b74068dace619e58c37ef169f88
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Oct 21 19:29:38 2018 -0400
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 25 19:25:01 2019 +0200
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 at collabora.co.uk>
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))
More information about the Libreoffice-commits
mailing list