[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - sc/source sw/inc sw/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Wed May 20 12:32:42 UTC 2020
sc/source/core/data/validat.cxx | 2
sw/inc/swabstdlg.hxx | 8 +
sw/source/ui/dialog/swdlgfact.cxx | 13 +-
sw/source/ui/dialog/swdlgfact.hxx | 11 +-
sw/source/uibase/shells/basesh.cxx | 176 ++++++++++++++++++++++---------------
5 files changed, 122 insertions(+), 88 deletions(-)
New commits:
commit 10549444abc85e248ad3bff1b51b7c00ae345e98
Author: Szymon Kłos <eszkadev at gmail.com>
AuthorDate: Wed May 20 14:26:35 2020 +0200
Commit: Szymon Kłos <eszkadev at gmail.com>
CommitDate: Wed May 20 14:26:35 2020 +0200
fix build
Change-Id: I9a370f2ad877d6c7deca44b01adfe09f94e9a496
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 409ecbe6c70d..4471db3bab26 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -408,7 +408,7 @@ bool ScValidationData::DoError(weld::Window* pParent, const OUString& rInput,
}
bool bIsMobile = comphelper::LibreOfficeKit::isActive()
- && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone();
+ && comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView());
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, eType,
eStyle, aMessage, bIsMobile));
commit f8a9dda0c161bf2ef5fb698d8f3f53e5c4d1c403
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue May 19 16:55:39 2020 +0200
Commit: Szymon Kłos <eszkadev at gmail.com>
CommitDate: Wed May 20 14:26:23 2020 +0200
Make Insert Table dialog async
Change-Id: Id2458c16f259a58e2376f42104a9a6c9056cab11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94536
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 3d4dd0d7ff29..3f1066d36315 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -57,6 +57,7 @@ struct SfxChildWinInfo;
class SwTOXMark;
struct SwDocStat;
struct SwInsertTableOptions;
+class SwInsTableDlg;
enum class SwBorderModes;
enum class SwCharDlgMode;
enum class SfxStyleFamily;
@@ -117,14 +118,15 @@ public:
virtual void SetText( const OUString& rStr ) = 0;
};
-class AbstractInsTableDlg : public VclAbstractDialog
+class AbstractInsTableDlg
{
protected:
- virtual ~AbstractInsTableDlg() override = default;
+ virtual ~AbstractInsTableDlg() = default;
public:
virtual void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
std::unique_ptr<SwTableAutoFormat>& prTAFormat ) = 0;
+ virtual std::shared_ptr<weld::DialogController> getDialogController() = 0;
};
class AbstractJavaEditDialog : public VclAbstractDialog
@@ -457,7 +459,7 @@ public:
SwWrtShell &rSh, bool bEd = false) = 0;
virtual VclPtr<VclAbstractDialog> CreateTitlePageDlg(weld::Window* pParent) = 0;
virtual VclPtr<VclAbstractDialog> CreateVclSwViewDialog(SwView& rView) = 0;
- virtual VclPtr<AbstractInsTableDlg> CreateInsTableDlg(SwView& rView) = 0;
+ virtual std::shared_ptr<AbstractInsTableDlg> CreateInsTableDlg(SwView& rView) = 0;
virtual VclPtr<AbstractJavaEditDialog> CreateJavaEditDialog(weld::Window* pParent,
SwWrtShell* pWrtSh) = 0;
virtual VclPtr<AbstractMailMergeDlg> CreateMailMergeDlg(
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 05dccd0da12a..515b26f00853 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -233,11 +233,6 @@ short AbstractInsFootNoteDlg_Impl::Execute()
return m_xDlg->run();
}
-short AbstractInsTableDlg_Impl::Execute()
-{
- return m_xDlg->run();
-}
-
short AbstractJavaEditDialog_Impl::Execute()
{
return m_xDlg->run();
@@ -601,7 +596,9 @@ void AbstractInsTableDlg_Impl::GetValues( OUString& rName, sal_uInt16& rRow, sal
SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
std::unique_ptr<SwTableAutoFormat>& prTAFormat )
{
- m_xDlg->GetValues(rName, rRow, rCol, rInsTableFlags, rTableAutoFormatName, prTAFormat);
+ SwInsTableDlg* pDlg = dynamic_cast<SwInsTableDlg*>(m_xDlg.get());
+ if (pDlg)
+ pDlg->GetValues(rName, rRow, rCol, rInsTableFlags, rTableAutoFormatName, prTAFormat);
}
OUString AbstractJavaEditDialog_Impl::GetScriptText() const
@@ -1041,9 +1038,9 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateVclSwViewDialog(Sw
return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_unique<SwLineNumberingDlg>(rView));
}
-VclPtr<AbstractInsTableDlg> SwAbstractDialogFactory_Impl::CreateInsTableDlg(SwView& rView)
+std::shared_ptr<AbstractInsTableDlg> SwAbstractDialogFactory_Impl::CreateInsTableDlg(SwView& rView)
{
- return VclPtr<AbstractInsTableDlg_Impl>::Create(std::make_unique<SwInsTableDlg>(rView));
+ return std::make_shared<AbstractInsTableDlg_Impl>(std::make_shared<SwInsTableDlg>(rView));
}
VclPtr<AbstractJavaEditDialog> SwAbstractDialogFactory_Impl::CreateJavaEditDialog(
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 579fe94562c2..5da08110c8c8 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -471,16 +471,17 @@ public:
class SwInsTableDlg;
class AbstractInsTableDlg_Impl : public AbstractInsTableDlg
{
- std::unique_ptr<SwInsTableDlg> m_xDlg;
+protected:
+ std::shared_ptr<weld::DialogController> m_xDlg;
public:
- explicit AbstractInsTableDlg_Impl(std::unique_ptr<SwInsTableDlg> p)
- : m_xDlg(std::move(p))
+ explicit AbstractInsTableDlg_Impl(std::shared_ptr<weld::DialogController> p)
+ : m_xDlg(p)
{
}
- virtual short Execute() override;
virtual void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
std::unique_ptr<SwTableAutoFormat>& prTAFormat ) override;
+ virtual std::shared_ptr<weld::DialogController> getDialogController() override { return m_xDlg; }
};
class SwJavaEditDialog;
@@ -728,7 +729,7 @@ public:
weld::Window * pParent, SwWrtShell &rSh, bool bEd = false) override;
virtual VclPtr<VclAbstractDialog> CreateTitlePageDlg(weld::Window* pParent) override;
virtual VclPtr<VclAbstractDialog> CreateVclSwViewDialog(SwView& rView) override;
- virtual VclPtr<AbstractInsTableDlg> CreateInsTableDlg(SwView& rView) override;
+ virtual std::shared_ptr<AbstractInsTableDlg> CreateInsTableDlg(SwView& rView) override;
virtual VclPtr<AbstractJavaEditDialog> CreateJavaEditDialog(weld::Window* pParent,
SwWrtShell* pWrtSh) override;
virtual VclPtr<AbstractMailMergeDlg> CreateMailMergeDlg(
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 629424523126..f34c8a802d50 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -2691,6 +2691,58 @@ SwWrtShell* SwBaseShell::GetShellPtr()
return rView.GetWrtShellPtr();
}
+static void EndUndo(SwWrtShell& rSh)
+{
+ SwRewriter aRewriter;
+
+ if (rSh.GetTableFormat())
+ {
+ aRewriter.AddRule(UndoArg1, SwResId(STR_START_QUOTE));
+ aRewriter.AddRule(UndoArg2, rSh.GetTableFormat()->GetName());
+ aRewriter.AddRule(UndoArg3, SwResId(STR_END_QUOTE));
+
+ }
+ rSh.EndUndo(SwUndoId::INSTABLE, &aRewriter); // If possible change the Shell
+}
+
+static void InsertTableImpl(SwWrtShell& rSh,
+ SwView &rTempView,
+ const OUString& aTableName,
+ sal_uInt16 nRows,
+ sal_uInt16 nCols,
+ SwInsertTableOptions aInsTableOpts,
+ const OUString& aAutoName,
+ std::unique_ptr<SwTableAutoFormat> pTAFormat)
+{
+ rSh.StartUndo(SwUndoId::INSTABLE);
+
+ rSh.StartAllAction();
+ if( rSh.HasSelection() )
+ rSh.DelRight();
+
+ rSh.InsertTable( aInsTableOpts, nRows, nCols, pTAFormat.get() );
+ rSh.MoveTable( GotoPrevTable, fnTableStart );
+
+ if( !aTableName.isEmpty() && !rSh.GetTableStyle( aTableName ) )
+ rSh.GetTableFormat()->SetName( aTableName );
+
+ if( pTAFormat != nullptr && !aAutoName.isEmpty()
+ && aAutoName != SwViewShell::GetShellRes()->aStrNone )
+ {
+ SwTableNode* pTableNode = const_cast<SwTableNode*>( rSh.IsCursorInTable() );
+ if ( pTableNode )
+ {
+ pTableNode->GetTable().SetTableStyleName( aAutoName );
+ SwUndoTableAutoFormat* pUndo = new SwUndoTableAutoFormat( *pTableNode, *pTAFormat );
+ if ( pUndo )
+ rSh.GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
+ }
+ }
+
+ rSh.EndAllAction();
+ rTempView.AutoCaption(TABLE_CAP);
+}
+
void SwBaseShell::InsertTable( SfxRequest& _rRequest )
{
const SfxItemSet* pArgs = _rRequest.GetArgs();
@@ -2703,7 +2755,6 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
bool bCallEndUndo = false;
if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() &&
- !rSh.IsTableMode() )
{
const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
SwInsertTableOptions aInsTableOpts = pModOpt->GetInsTableFlags(bHTMLMode);
@@ -2719,12 +2770,12 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
}
else
{
- sal_uInt16 nCols = 0;
- sal_uInt16 nRows = 0;
- SwInsertTableOptions aInsTableOpts( SwInsertTableFlags::All, 1 );
- OUString aTableName;
- OUString aAutoName;
- std::unique_ptr<SwTableAutoFormat> pTAFormat;
+ sal_uInt16 nColsIn = 0;
+ sal_uInt16 nRowsIn = 0;
+ SwInsertTableOptions aInsTableOptsIn( SwInsertTableFlags::All, 1 );
+ OUString aTableNameIn;
+ OUString aAutoNameIn;
+ std::unique_ptr<SwTableAutoFormat> pTAFormatIn = nullptr;
if( pArgs && pArgs->Count() >= 2 )
{
@@ -2735,23 +2786,23 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
const SfxStringItem* pAuto = _rRequest.GetArg<SfxStringItem>(FN_PARAM_2);
if ( pName )
- aTableName = pName->GetValue();
+ aTableNameIn = pName->GetValue();
if ( pCols )
- nCols = pCols->GetValue();
+ nColsIn = pCols->GetValue();
if ( pRows )
- nRows = pRows->GetValue();
+ nRowsIn = pRows->GetValue();
if ( pAuto )
{
- aAutoName = pAuto->GetValue();
- if ( !aAutoName.isEmpty() )
+ aAutoNameIn = pAuto->GetValue();
+ if ( !aAutoNameIn.isEmpty() )
{
SwTableAutoFormatTable aTableTable;
aTableTable.Load();
for ( size_t n=0; n<aTableTable.size(); n++ )
{
- if ( aTableTable[n].GetName() == aAutoName )
+ if ( aTableTable[n].GetName() == aAutoNameIn )
{
- pTAFormat.reset(new SwTableAutoFormat( aTableTable[n] ));
+ pTAFormatIn.reset(new SwTableAutoFormat( aTableTable[n] ));
break;
}
}
@@ -2759,81 +2810,64 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
}
if ( pFlags )
- aInsTableOpts.mnInsMode = static_cast<SwInsertTableFlags>(pFlags->GetValue());
+ aInsTableOptsIn.mnInsMode = static_cast<SwInsertTableFlags>(pFlags->GetValue());
else
{
const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
- aInsTableOpts = pModOpt->GetInsTableFlags(bHTMLMode);
+ aInsTableOptsIn = pModOpt->GetInsTableFlags(bHTMLMode);
}
}
- if( !nCols || !nRows )
+ if( !nColsIn || !nRowsIn )
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
- ScopedVclPtr<AbstractInsTableDlg> pDlg(pFact->CreateInsTableDlg(rTempView));
- if( RET_OK == pDlg->Execute() )
- {
- pDlg->GetValues( aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat );
- }
- else
- _rRequest.Ignore();
- }
-
- if( nCols && nRows )
- {
- // record before shell change
- _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableName ) );
- if ( !aAutoName.isEmpty() )
- _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoName ) );
- _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nCols ) );
- _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRows ) );
- _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, static_cast<sal_Int32>(aInsTableOpts.mnInsMode) ) );
- _rRequest.Done();
+ std::shared_ptr<AbstractInsTableDlg> pAbstractDialog(pFact->CreateInsTableDlg(rTempView));
+ std::shared_ptr<weld::DialogController> pDialogController(pAbstractDialog->getDialogController());
- rSh.StartUndo(SwUndoId::INSTABLE);
- bCallEndUndo = true;
-
- rSh.StartAllAction();
- if( rSh.HasSelection() )
- rSh.DelRight();
+ weld::DialogController::runAsync(pDialogController,
+ [pAbstractDialog, &rSh, &rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn, pTAFormatIn] (sal_Int32 nResult) {
+ if( RET_OK == nResult )
+ {
+ sal_uInt16 nCols = nColsIn;
+ sal_uInt16 nRows = nRowsIn;
+ SwInsertTableOptions aInsTableOpts = aInsTableOptsIn;
+ OUString aTableName = aTableNameIn;
+ OUString aAutoName = aAutoNameIn;
+ SwTableAutoFormat* pTAFormat = pTAFormatIn;
- rSh.InsertTable( aInsTableOpts, nRows, nCols, pTAFormat.get() );
- rSh.MoveTable( GotoPrevTable, fnTableStart );
+ pAbstractDialog->GetValues( aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat );
- if( !aTableName.isEmpty() && !rSh.GetTableStyle( aTableName ) )
- rSh.GetTableFormat()->SetName( aTableName );
+ if( nCols && nRows )
+ {
+ InsertTableImpl( rSh, rTempView, aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat );
+ EndUndo(rSh);
+ }
- if( pTAFormat != nullptr && !aAutoName.isEmpty()
- && aAutoName != SwViewShell::GetShellRes()->aStrNone )
- {
- SwTableNode* pTableNode = const_cast<SwTableNode*>( rSh.IsCursorInTable() );
- if ( pTableNode )
- {
- pTableNode->GetTable().SetTableStyleName( aAutoName );
- SwUndoTableAutoFormat* pUndo = new SwUndoTableAutoFormat( *pTableNode, *pTAFormat );
- if ( pUndo )
- rSh.GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
+ delete pTAFormat;
+ }
}
- }
-
- rSh.EndAllAction();
- rTempView.AutoCaption(TABLE_CAP);
+ );
}
- }
-
- if( bCallEndUndo )
- {
- SwRewriter aRewriter;
-
- if (rSh.GetTableFormat())
+ else
{
- aRewriter.AddRule(UndoArg1, SwResId(STR_START_QUOTE));
- aRewriter.AddRule(UndoArg2, rSh.GetTableFormat()->GetName());
- aRewriter.AddRule(UndoArg3, SwResId(STR_END_QUOTE));
+ // record before shell change
+ _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableNameIn ) );
+ if ( !aAutoNameIn.isEmpty() )
+ _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoNameIn ) );
+ _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nColsIn ) );
+ _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRowsIn ) );
+ _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, static_cast<sal_Int32>(aInsTableOptsIn.mnInsMode) ) );
+ _rRequest.Done();
+
+ InsertTableImpl( rSh, rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn, pTAFormatIn );
+ bCallEndUndo = true;
+ delete pTAFormatIn;
}
- rSh.EndUndo(SwUndoId::INSTABLE, &aRewriter); // If possible change the Shell
}
+
+ if( bCallEndUndo )
+ EndUndo(rSh);
}
}
More information about the Libreoffice-commits
mailing list