[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - cui/source include/svx include/vcl sd/source vcl/jsdialog
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 21 07:47:54 UTC 2020
cui/source/dialogs/newtabledlg.cxx | 10 -
cui/source/factory/dlgfact.cxx | 4
cui/source/factory/dlgfact.hxx | 2
cui/source/inc/newtabledlg.hxx | 41 +++++-
include/svx/svxdlg.hxx | 7 -
include/vcl/jsdialog/jsdialogbuilder.hxx | 11 +
sd/source/ui/table/tablefunction.cxx | 196 ++++++++++++++++---------------
vcl/jsdialog/jsdialogbuilder.cxx | 11 +
8 files changed, 172 insertions(+), 110 deletions(-)
New commits:
commit ec17eb370b427f8ffa8078f6860ab4dd4b2968ca
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu May 21 09:24:31 2020 +0200
Commit: Szymon Kłos <eszkadev at gmail.com>
CommitDate: Thu May 21 09:46:54 2020 +0200
Add license header to jsdialogbuilder
Change-Id: Ia62f225bd95e8c1e40c306fc334cd5700d64f91e
diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
index 32b279dea66d..6921384c9386 100644
--- a/include/vcl/jsdialog/jsdialogbuilder.hxx
+++ b/include/vcl/jsdialog/jsdialogbuilder.hxx
@@ -1,3 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
#ifndef INCLUDED_VCL_INC_JSDIALOG_JSDIALOG_HXX
#define INCLUDED_VCL_INC_JSDIALOG_JSDIALOG_HXX
@@ -184,3 +193,5 @@ public:
};
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 9246bda13b86..0ce65d586362 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1,3 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
#include <vcl/jsdialog/jsdialogbuilder.hxx>
#include <sal/log.hxx>
#include <boost/property_tree/json_parser.hpp>
@@ -421,3 +430,5 @@ void JSCheckButton::set_active(bool active)
SalInstanceCheckButton::set_active(active);
notifyDialogState();
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
commit 8eadedd70a5cef10126abd061a02e57501aa0bc0
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed May 20 18:53:39 2020 +0200
Commit: Szymon Kłos <eszkadev at gmail.com>
CommitDate: Thu May 21 09:16:47 2020 +0200
Make Impress Insert Table dialog async
Change-Id: If8b48cfe983819387c066d3bd81a42dad8947489
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94591
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/cui/source/dialogs/newtabledlg.cxx b/cui/source/dialogs/newtabledlg.cxx
index af4d91f1b1c5..16e81f8d90ea 100644
--- a/cui/source/dialogs/newtabledlg.cxx
+++ b/cui/source/dialogs/newtabledlg.cxx
@@ -26,16 +26,6 @@ SvxNewTableDialog::SvxNewTableDialog(weld::Window* pWindow)
{
}
-SvxNewTableDialog::~SvxNewTableDialog()
-{
- disposeOnce();
-}
-
-short SvxNewTableDialog::Execute()
-{
- return m_xDialog->run();
-}
-
sal_Int32 SvxNewTableDialog::getRows() const
{
return sal::static_int_cast< sal_Int32 >( mxNumRows->get_value() );
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 80e28b271b63..5c1979943ac3 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1607,9 +1607,9 @@ VclPtr<SvxAbstractSplitTableDialog> AbstractDialogFactory_Impl::CreateSvxSplitTa
return VclPtr<SvxSplitTableDlg>::Create( pParent, bIsTableVertical, nMaxVertical, 99 );
}
-VclPtr<SvxAbstractNewTableDialog> AbstractDialogFactory_Impl::CreateSvxNewTableDialog(weld::Window* pParent)
+std::shared_ptr<SvxAbstractNewTableDialog> AbstractDialogFactory_Impl::CreateSvxNewTableDialog(weld::Window* pParent)
{
- return VclPtr<SvxNewTableDialog>::Create(pParent);
+ return std::make_shared<SvxNewTableDialogWrapper>(pParent);
}
VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateOptionsDialog(weld::Window* pParent, const OUString& rExtensionId)
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 174417214907..c7e66c44556d 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -926,7 +926,7 @@ public:
virtual VclPtr<SvxAbstractSplitTableDialog> CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) override;
- virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog(weld::Window* pParent) override ;
+ virtual std::shared_ptr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog(weld::Window* pParent) override ;
virtual VclPtr<VclAbstractDialog> CreateOptionsDialog(
weld::Window* pParent, const OUString& rExtensionId ) override;
diff --git a/cui/source/inc/newtabledlg.hxx b/cui/source/inc/newtabledlg.hxx
index cad953779b12..9a05f8aa3afe 100644
--- a/cui/source/inc/newtabledlg.hxx
+++ b/cui/source/inc/newtabledlg.hxx
@@ -22,7 +22,7 @@
#include <svx/svxdlg.hxx>
#include <vcl/weld.hxx>
-class SvxNewTableDialog : public SvxAbstractNewTableDialog, public weld::GenericDialogController
+class SvxNewTableDialog : public weld::GenericDialogController
{
private:
std::unique_ptr<weld::SpinButton> mxNumColumns;
@@ -30,12 +30,43 @@ private:
public:
SvxNewTableDialog(weld::Window* pParent);
- virtual ~SvxNewTableDialog() override;
- virtual short Execute() override;
+ virtual sal_Int32 getRows() const;
+ virtual sal_Int32 getColumns() const;
+};
+
+class SvxNewTableDialogWrapper : public SvxAbstractNewTableDialog
+{
+private:
+ std::shared_ptr<weld::DialogController> m_xDlg;
+
+public:
+ SvxNewTableDialogWrapper(weld::Window* pParent)
+ : m_xDlg(std::make_shared<SvxNewTableDialog>(pParent))
+ {}
+
+ virtual std::shared_ptr<weld::DialogController> getDialogController() override
+ {
+ return m_xDlg;
+ }
+
+ virtual sal_Int32 getRows() const override
+ {
+ SvxNewTableDialog* pDlg = dynamic_cast<SvxNewTableDialog*>(m_xDlg.get());
+ if (pDlg)
+ return pDlg->getRows();
+
+ return 0;
+ }
+
+ virtual sal_Int32 getColumns() const override
+ {
+ SvxNewTableDialog* pDlg = dynamic_cast<SvxNewTableDialog*>(m_xDlg.get());
+ if (pDlg)
+ return pDlg->getColumns();
- virtual sal_Int32 getRows() const override;
- virtual sal_Int32 getColumns() const override;
+ return 0;
+ }
};
#endif // INCLUDED_CUI_SOURCE_INC_NEWTABLEDLG_HXX
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index 52282e6bb6e5..b0be803adbd7 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -312,13 +312,14 @@ public:
virtual void SetSplitVerticalByDefault() = 0;
};
-class SvxAbstractNewTableDialog : public VclAbstractDialog
+class SvxAbstractNewTableDialog
{
protected:
- virtual ~SvxAbstractNewTableDialog() override = default;
+ virtual ~SvxAbstractNewTableDialog() = default;
public:
virtual sal_Int32 getRows() const = 0;
virtual sal_Int32 getColumns() const = 0;
+ virtual std::shared_ptr<weld::DialogController> getDialogController() = 0;
};
class SvxAbstractInsRowColDlg : public VclAbstractDialog
@@ -464,7 +465,7 @@ public:
virtual VclPtr<SvxAbstractSplitTableDialog> CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) = 0;
- virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog(weld::Window* pParent) = 0;
+ virtual std::shared_ptr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog(weld::Window* pParent) = 0;
virtual VclPtr<SvxAbstractInsRowColDlg> CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OString& rHelpId) = 0;
};
diff --git a/sd/source/ui/table/tablefunction.cxx b/sd/source/ui/table/tablefunction.cxx
index 6fb9be6973a3..16e26c353c24 100644
--- a/sd/source/ui/table/tablefunction.cxx
+++ b/sd/source/ui/table/tablefunction.cxx
@@ -84,6 +84,98 @@ static void apply_table_style( SdrTableObj* pObj, SdrModel const * pModel, const
}
}
+static void InsertTableImpl(DrawViewShell* pShell,
+ ::sd::View* pView,
+ sal_Int32 nColumns,
+ sal_Int32 nRows,
+ const OUString& sTableStyle)
+{
+ ::tools::Rectangle aRect;
+
+ SdrObject* pPickObj = pView->GetEmptyPresentationObject( PRESOBJ_TABLE );
+ if( pPickObj )
+ {
+ aRect = pPickObj->GetLogicRect();
+ aRect.setHeight( 200 );
+ }
+ else
+ {
+ Size aSize( 14100, 2000 );
+
+ Point aPos;
+ ::tools::Rectangle aWinRect(aPos, pShell->GetActiveWindow()->GetOutputSizePixel());
+ aWinRect = pShell->GetActiveWindow()->PixelToLogic(aWinRect);
+
+ // make sure that the default size of the table fits on the paper and is inside the viewing area.
+ // if zoomed in close, don't make the table bigger than the viewing window.
+ Size aMaxSize = pShell->getCurrentPage()->GetSize();
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ // aWinRect is nonsensical in the LOK case
+ aWinRect = ::tools::Rectangle(aPos, aMaxSize);
+ }
+ else
+ {
+ if( aMaxSize.Height() > aWinRect.getHeight() )
+ aMaxSize.setHeight( aWinRect.getHeight() );
+ if( aMaxSize.Width() > aWinRect.getWidth() )
+ aMaxSize.setWidth( aWinRect.getWidth() );
+ }
+
+ if( aSize.Width() > aMaxSize.getWidth() )
+ aSize.setWidth( aMaxSize.getWidth() );
+
+ // adjust height based on # of rows.
+ if( nRows > 0 )
+ {
+ aSize.setHeight( aSize.Height() * nRows );
+ if( aSize.Height() > aMaxSize.getHeight() )
+ aSize.setHeight( aMaxSize.getHeight() );
+ }
+
+ aPos = aWinRect.Center();
+ aPos.AdjustX( -(aSize.Width() / 2) );
+ aPos.AdjustY( -(aSize.Height() / 2) );
+ aRect = ::tools::Rectangle(aPos, aSize);
+ }
+
+ sdr::table::SdrTableObj* pObj = new sdr::table::SdrTableObj(
+ *pShell->GetDoc(), // TTTT should be reference
+ aRect,
+ nColumns,
+ nRows);
+ pObj->NbcSetStyleSheet( pShell->GetDoc()->GetDefaultStyleSheet(), true );
+ apply_table_style( pObj, pShell->GetDoc(), sTableStyle );
+ SdrPageView* pPV = pView->GetSdrPageView();
+
+ // #i123359# if an object is to be replaced/manipulated it may be that it is in text edit mode,
+ // so to be on the safe side call SdrEndTextEdit here
+ SdrTextObj* pCheckForTextEdit = dynamic_cast< SdrTextObj* >(pPickObj);
+
+ if(pCheckForTextEdit && pCheckForTextEdit->IsInEditMode())
+ {
+ pView->SdrEndTextEdit();
+ }
+
+ // if we have a pick obj we need to make this new ole a pres obj replacing the current pick obj
+ if( pPickObj )
+ {
+ SdPage* pPage = static_cast< SdPage* >(pPickObj->getSdrPageFromSdrObject());
+ if(pPage && pPage->IsPresObj(pPickObj))
+ {
+ pObj->SetUserCall( pPickObj->GetUserCall() );
+ pPage->InsertPresObj( pObj, PRESOBJ_TABLE );
+ }
+ }
+
+ pShell->GetParentWindow()->GrabFocus();
+ if( pPickObj )
+ pView->ReplaceObjectAtView(pPickObj, *pPV, pObj );
+ else
+ pView->InsertObjectAtView(pObj, *pPV, SdrInsertFlags::SETDEFLAYER);
+}
+
void DrawViewShell::FuTable(SfxRequest& rReq)
{
switch( rReq.GetSlot() )
@@ -93,6 +185,8 @@ void DrawViewShell::FuTable(SfxRequest& rReq)
sal_Int32 nColumns = 0;
sal_Int32 nRows = 0;
OUString sTableStyle;
+ DrawViewShell* pShell = this;
+ ::sd::View* pView = mpView;
const SfxUInt16Item* pCols = rReq.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_COLUMN);
const SfxUInt16Item* pRows = rReq.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_ROW);
@@ -110,100 +204,24 @@ void DrawViewShell::FuTable(SfxRequest& rReq)
if( (nColumns == 0) || (nRows == 0) )
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr<SvxAbstractNewTableDialog> pDlg( pFact->CreateSvxNewTableDialog(rReq.GetFrameWeld()) );
-
- if( pDlg->Execute() != RET_OK )
- break;
-
- nColumns = pDlg->getColumns();
- nRows = pDlg->getRows();
- }
-
- ::tools::Rectangle aRect;
-
- SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_TABLE );
- if( pPickObj )
- {
- aRect = pPickObj->GetLogicRect();
- aRect.setHeight( 200 );
+ std::shared_ptr<SvxAbstractNewTableDialog> pDlg( pFact->CreateSvxNewTableDialog(rReq.GetFrameWeld()) );
+
+ weld::DialogController::runAsync(pDlg->getDialogController(),
+ [pDlg, pShell, pView, sTableStyle] (sal_Int32 nResult) {
+ if (nResult == RET_OK)
+ {
+ sal_Int32 nColumnsIn = pDlg->getColumns();
+ sal_Int32 nRowsIn = pDlg->getRows();
+
+ InsertTableImpl(pShell, pView, nColumnsIn, nRowsIn, sTableStyle);
+ }
+ });
}
else
{
- Size aSize( 14100, 2000 );
-
- Point aPos;
- ::tools::Rectangle aWinRect(aPos, GetActiveWindow()->GetOutputSizePixel());
- aWinRect = GetActiveWindow()->PixelToLogic(aWinRect);
-
- // make sure that the default size of the table fits on the paper and is inside the viewing area.
- // if zoomed in close, don't make the table bigger than the viewing window.
- Size aMaxSize = getCurrentPage()->GetSize();
-
- if (comphelper::LibreOfficeKit::isActive())
- {
- // aWinRect is nonsensical in the LOK case
- aWinRect = ::tools::Rectangle(aPos, aMaxSize);
- }
- else
- {
- if( aMaxSize.Height() > aWinRect.getHeight() )
- aMaxSize.setHeight( aWinRect.getHeight() );
- if( aMaxSize.Width() > aWinRect.getWidth() )
- aMaxSize.setWidth( aWinRect.getWidth() );
- }
-
- if( aSize.Width() > aMaxSize.getWidth() )
- aSize.setWidth( aMaxSize.getWidth() );
-
- // adjust height based on # of rows.
- if( nRows > 0 )
- {
- aSize.setHeight( aSize.Height() * nRows );
- if( aSize.Height() > aMaxSize.getHeight() )
- aSize.setHeight( aMaxSize.getHeight() );
- }
-
- aPos = aWinRect.Center();
- aPos.AdjustX( -(aSize.Width() / 2) );
- aPos.AdjustY( -(aSize.Height() / 2) );
- aRect = ::tools::Rectangle(aPos, aSize);
- }
-
- sdr::table::SdrTableObj* pObj = new sdr::table::SdrTableObj(
- *GetDoc(), // TTTT should be reference
- aRect,
- nColumns,
- nRows);
- pObj->NbcSetStyleSheet( GetDoc()->GetDefaultStyleSheet(), true );
- apply_table_style( pObj, GetDoc(), sTableStyle );
- SdrPageView* pPV = mpView->GetSdrPageView();
-
- // #i123359# if an object is to be replaced/manipulated it may be that it is in text edit mode,
- // so to be on the safe side call SdrEndTextEdit here
- SdrTextObj* pCheckForTextEdit = dynamic_cast< SdrTextObj* >(pPickObj);
-
- if(pCheckForTextEdit && pCheckForTextEdit->IsInEditMode())
- {
- mpView->SdrEndTextEdit();
- }
-
- // if we have a pick obj we need to make this new ole a pres obj replacing the current pick obj
- if( pPickObj )
- {
- SdPage* pPage = static_cast< SdPage* >(pPickObj->getSdrPageFromSdrObject());
- if(pPage && pPage->IsPresObj(pPickObj))
- {
- pObj->SetUserCall( pPickObj->GetUserCall() );
- pPage->InsertPresObj( pObj, PRESOBJ_TABLE );
- }
+ InsertTableImpl(pShell, pView, nColumns, nRows, sTableStyle);
}
- GetParentWindow()->GrabFocus();
- if( pPickObj )
- mpView->ReplaceObjectAtView(pPickObj, *pPV, pObj );
- else
- mpView->InsertObjectAtView(pObj, *pPV, SdrInsertFlags::SETDEFLAYER);
-
rReq.Ignore();
SfxViewShell* pViewShell = GetViewShell();
OSL_ASSERT (pViewShell!=nullptr);
More information about the Libreoffice-commits
mailing list