chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx | 57 +++-- chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx | 18 + sc/source/ui/drawfunc/fuins2.cxx | 132 ++++++------ sc/source/ui/inc/fuinsert.hxx | 14 + sc/source/ui/inc/tabvwsh.hxx | 3 sc/source/ui/view/tabvwsh4.cxx | 1 sc/source/ui/view/tabvwshb.cxx | 2 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 3 sw/source/uibase/inc/chartins.hxx | 8 sw/source/uibase/inc/textsh.hxx | 3 sw/source/uibase/shells/textsh.cxx | 23 ++ sw/source/uibase/table/chartins.cxx | 32 +- vcl/source/control/wizardmachine.cxx | 3 writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 31 ++ writerfilter/source/dmapper/PropertyIds.cxx | 2 15 files changed, 220 insertions(+), 112 deletions(-)
New commits: commit 7f805108a4ccc5751d7cbcb722ded5247e398578 Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Feb 21 15:44:26 2020 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Mar 2 10:31:05 2020 +0100 tdf#131062 DOCX import: fix table-style paragraph background color by comparing fill attributes to ParaBackColor to avoid losing them. Regression from commit a9ba8e57a41c5ddf3597272bddab30e51fb3fd38 (Revert "tdf#118947 sw tablestyle: manually scan parents for ::SET"). See also commit 24077b2d52ab3d0fd0db5afb25d8b94b62386e3e (writerfilter: import paragraph color as fill attributes) Change-Id: Id42ea3adaddf883435dd61e5dea0e6c5fb89f927 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89215 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 9c1f362b8a70..a37c603732ad 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -338,6 +338,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle, "tdf118947_tableStyle.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("Table has 10pt space above paragraph", sal_Int32(353), getProperty<sal_Int32>(xPara, "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table style sets 0 right margin", sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaRightMargin")); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("TextBody has 1.07 line-spacing", sal_Int16(107), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height, 1); + // table-style based paragraph background color + CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing paragraph background color in cell A1", sal_Int32(0xCCFFCC), getProperty<sal_Int32>(xPara, "ParaBackColor")); xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY); xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); @@ -351,6 +353,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle, "tdf118947_tableStyle.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("Table sets 10pt space above paragraph", sal_Int32(353), getProperty<sal_Int32>(xPara, "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table style sets 0 right margin", sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaRightMargin")); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table sets 2.5 line-spacing", sal_Int16(250), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height, 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Paragraph background color in cell A2", sal_Int32(-1), getProperty<sal_Int32>(xPara, "ParaBackColor")); } DECLARE_OOXMLEXPORT_TEST(tdf123912_protectedForm, "tdf123912_protectedForm.odt") diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 7dcbae415ff2..3cc394b8a50d 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> #include "TablePositionHandler.hxx" #include "TagLogger.hxx" #include "util.hxx" @@ -1094,6 +1095,23 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag if (pCellProp != rCellProperties.end()) { bool bDocDefault; + // handle paragraph background color defined in CellColorHandler + if (eId == PROP_FILL_COLOR) + { + // table style defines paragraph background color, use the correct property name + auto pFillStyleProp = std::find_if(rCellProperties.begin(), rCellProperties.end(), + [&](const beans::PropertyValue& rProp) { return rProp.Name == "FillStyle"; }); + if ( pFillStyleProp != rCellProperties.end() && + pFillStyleProp->Value == uno::makeAny(drawing::FillStyle_SOLID) ) + { + sPropertyName = "ParaBackColor"; + } + else + { + // FillStyle_NONE, skip table style usage for paragraph background color + continue; + } + } OUString sParaStyleName; rParaProp.m_rPropertySet->getPropertyValue("ParaStyleName") >>= sParaStyleName; StyleSheetEntryPtr pEntry = m_rDMapper_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(sParaStyleName); @@ -1112,8 +1130,17 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag uno::Reference< beans::XPropertyState > xParaProperties( xParagraph, uno::UNO_QUERY_THROW ); if ( xParaProperties->getPropertyState(sPropertyName) == css::beans::PropertyState_DEFAULT_VALUE ) { - // apply style setting when the paragraph doesn't modify it - rParaProp.m_rPropertySet->setPropertyValue( sPropertyName, pCellProp->Value ); + if ( eId != PROP_FILL_COLOR ) + { + // apply style setting when the paragraph doesn't modify it + rParaProp.m_rPropertySet->setPropertyValue( sPropertyName, pCellProp->Value ); + } + else + { + // we need this for complete import of table-style based paragraph background color + rParaProp.m_rPropertySet->setPropertyValue( "FillColor", pCellProp->Value ); + rParaProp.m_rPropertySet->setPropertyValue( "FillStyle", uno::makeAny(drawing::FillStyle_SOLID) ); + } } else { diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index bb133dff2f7a..64a9ee063f77 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -366,7 +366,7 @@ bool isCharacterProperty( const PropertyIds eId ) bool isParagraphProperty( const PropertyIds eId ) { - return eId >= PROP_PARA_ADJUST && eId <= PROP_PARA_WIDOWS; + return (eId >= PROP_PARA_ADJUST && eId <= PROP_PARA_WIDOWS) || eId == PROP_FILL_COLOR; } } //namespace writerfilter commit ed86b6250cd00ed6b7bdb81307bc66adba129cae Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Apr 17 17:33:10 2019 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Mar 2 10:30:52 2020 +0100 Make Chart Creation Wizard async * FuInsertChart as a memeber in ScTabViewShell stores instance is needed to react on the dialog's result * CreationWizardUnoDlg converted to XAsynchronousExecutableDialog added dialog close handler which notifies listeners In the Online dialog become dead after closing, additional PostUserEvent was needed to kill the dialog after real close (without it user needed to select any cell to close dialog) * Reuse in Writer Change-Id: I9fe123d5c189d568f0edb4d36173a224a820a8a3 Reviewed-on: https://gerrit.libreoffice.org/79654 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/79571 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx index 7735c1757e1f..4d959b335252 100644 --- a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx +++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx @@ -29,6 +29,8 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <tools/diagnose_ex.h> +#include <comphelper/lok.hxx> +#include <sfx2/viewsh.hxx> namespace chart { @@ -47,6 +49,7 @@ CreationWizardUnoDlg::CreationWizardUnoDlg(const uno::Reference<uno::XComponentC CreationWizardUnoDlg::~CreationWizardUnoDlg() { SolarMutexGuard aSolarGuard; + m_xDlgClosedListener.clear(); m_xDialog.reset(); } @@ -81,9 +84,9 @@ void SAL_CALL CreationWizardUnoDlg::release() throw () } uno::Any SAL_CALL CreationWizardUnoDlg::queryAggregation( uno::Type const & rType ) { - if (rType == cppu::UnoType<ui::dialogs::XExecutableDialog>::get()) + if (rType == cppu::UnoType<ui::dialogs::XAsynchronousExecutableDialog>::get()) { - void * p = static_cast< ui::dialogs::XExecutableDialog * >( this ); + void * p = static_cast< ui::dialogs::XAsynchronousExecutableDialog * >( this ); return uno::Any( &p, rType ); } else if (rType == cppu::UnoType<lang::XServiceInfo>::get()) @@ -118,9 +121,8 @@ uno::Sequence< uno::Type > CreationWizardUnoDlg::getTypes() cppu::UnoType<lang::XServiceInfo>::get(), cppu::UnoType<lang::XInitialization>::get(), cppu::UnoType<frame::XTerminateListener>::get(), - cppu::UnoType<ui::dialogs::XExecutableDialog>::get(), + cppu::UnoType<ui::dialogs::XAsynchronousExecutableDialog>::get(), cppu::UnoType<beans::XPropertySet>::get() }; - return aTypeList; } @@ -145,7 +147,7 @@ void SAL_CALL CreationWizardUnoDlg::disposing( const lang::EventObject& /*Source //Listener should deregister himself and release all references to the closing object. } -void SAL_CALL CreationWizardUnoDlg::setTitle( const OUString& /*rTitle*/ ) +void SAL_CALL CreationWizardUnoDlg::setDialogTitle( const OUString& /*rTitle*/ ) { } void CreationWizardUnoDlg::createDialogOnDemand() @@ -168,25 +170,42 @@ void CreationWizardUnoDlg::createDialogOnDemand() uno::Reference< XComponent > xKeepAlive( this ); if( m_xChartModel.is() ) { - m_xDialog = std::make_unique<CreationWizard>(Application::GetFrameWeld(m_xParentWindow), m_xChartModel, m_xCC); + m_xDialog = std::make_shared<CreationWizard>(Application::GetFrameWeld(m_xParentWindow), m_xChartModel, m_xCC); } } } -sal_Int16 SAL_CALL CreationWizardUnoDlg::execute( ) +IMPL_STATIC_LINK_NOARG(CreationWizardUnoDlg, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*) { - sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL; - { - SolarMutexGuard aSolarGuard; - createDialogOnDemand(); - if (!m_xDialog) - return nRet; - TimerTriggeredControllerLock aTimerTriggeredControllerLock( m_xChartModel ); - if( m_bUnlockControllersOnExecute && m_xChartModel.is() ) - m_xChartModel->unlockControllers(); - nRet = m_xDialog->run(); - } - return nRet; + return SfxViewShell::Current(); +} + +void SAL_CALL CreationWizardUnoDlg::startExecuteModal( const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& xListener ) +{ + SolarMutexGuard aSolarGuard; + m_xDlgClosedListener = xListener; + createDialogOnDemand(); + + if( !m_xDialog ) + return; + + m_xDialog->getDialog()->SetInstallLOKNotifierHdl( + LINK(this, CreationWizardUnoDlg, InstallLOKNotifierHdl)); + + TimerTriggeredControllerLock aTimerTriggeredControllerLock( m_xChartModel ); + if( m_bUnlockControllersOnExecute && m_xChartModel.is() ) + m_xChartModel->unlockControllers(); + + rtl::Reference<CreationWizardUnoDlg> xThat(this); + weld::DialogController::runAsync(m_xDialog, [xThat](sal_Int32 nResult){ + if( xThat->m_xDlgClosedListener.is() ) + { + // Notify UNO listener to perform correct action depending on the result + css::ui::dialogs::DialogClosedEvent aEvent( *xThat, nResult ); + xThat->m_xDlgClosedListener->dialogClosed( aEvent ); + xThat->m_xDlgClosedListener.clear(); + } + }); } void SAL_CALL CreationWizardUnoDlg::initialize( const uno::Sequence< uno::Any >& aArguments ) diff --git a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx index c3ebb615db32..a7e67519d678 100644 --- a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx +++ b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx @@ -26,9 +26,13 @@ #include <com/sun/star/frame/XTerminateListener.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include "dlg_CreationWizard.hxx" +#include <tools/link.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/vclevent.hxx> namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } } namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } } @@ -41,7 +45,7 @@ namespace chart class CreationWizardUnoDlg : public MutexContainer , public ::cppu::OComponentHelper - , public css::ui::dialogs::XExecutableDialog + , public css::ui::dialogs::XAsynchronousExecutableDialog , public css::lang::XServiceInfo , public css::lang::XInitialization , public css::frame::XTerminateListener @@ -68,9 +72,9 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - // XExecutableDialog - virtual void SAL_CALL setTitle( const OUString& aTitle ) override; - virtual sal_Int16 SAL_CALL execute( ) override; + // XAsynchronousExecutableDialog + virtual void SAL_CALL setDialogTitle( const OUString& aTitle ) override; + virtual void SAL_CALL startExecuteModal( const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& xListener ) override; // XInitialization virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; @@ -97,13 +101,15 @@ protected: private: void createDialogOnDemand(); + DECL_STATIC_LINK(CreationWizardUnoDlg, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); private: css::uno::Reference< css::frame::XModel > m_xChartModel; css::uno::Reference< css::uno::XComponentContext> m_xCC; css::uno::Reference< css::awt::XWindow > m_xParentWindow; + css::uno::Reference< css::ui::dialogs::XDialogClosedListener > m_xDlgClosedListener; - std::unique_ptr<CreationWizard> m_xDialog; + std::shared_ptr<CreationWizard> m_xDialog; bool m_bUnlockControllersOnExecute; }; diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx index 80753e59c3cd..d926a1eb7258 100644 --- a/sc/source/ui/drawfunc/fuins2.cxx +++ b/sc/source/ui/drawfunc/fuins2.cxx @@ -53,10 +53,12 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <cppuhelper/bootstrap.hxx> +#include <svtools/dialogclosedlistener.hxx> #include <PivotTableDataProvider.hxx> #include <chart2uno.hxx> @@ -398,8 +400,58 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* rReq.Ignore(); } +IMPL_LINK( FuInsertChart, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvent, void ) +{ + bool bAddUndo = true; + + if( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::CANCEL ) + { + // leave OLE inplace mode and unmark + OSL_ASSERT( pView ); + rViewShell.DeactivateOle(); + pView->UnMarkAll(); + + // old page view pointer is invalid after switching sheets + SdrPageView* pPV = pView->GetSdrPageView(); + + // remove the chart + OSL_ASSERT( pPV ); + SdrPage * pPage( pPV->GetPage()); + OSL_ASSERT( pPage ); + OSL_ASSERT( m_pInsertedObject ); + if( pPage ) + { + // Remove the OLE2 object from the sdr page. + SdrObject* pRemoved = pPage->RemoveObject( m_pInsertedObject->GetOrdNum() ); + OSL_ASSERT( pRemoved == m_pInsertedObject ); + SdrObject::Free( pRemoved ); + } + + bAddUndo = false; + + // leave the draw shell + rViewShell.SetDrawShell( false ); + + // reset marked cell area + ScMarkData aMark = rViewShell.GetViewData().GetMarkData(); + rViewShell.GetViewData().GetViewShell()->SetMarkData(aMark); + } + else + { + OSL_ASSERT( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::OK ); + //@todo maybe move chart to different table + } + + if ( bAddUndo ) + { + // add undo action the same way as in SdrEditView::InsertObjectAtView + // (using UndoActionHdl etc.) + pView->AddUndo(std::make_unique<SdrUndoNewObj>(*m_pInsertedObject)); + } +} + FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP, - SdrModel* pDoc, SfxRequest& rReq) + SdrModel* pDoc, SfxRequest& rReq) : FuPoor(rViewSh, pWin, pViewP, pDoc, rReq) { const SfxItemSet* pReqArgs = rReq.GetArgs(); @@ -583,7 +635,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV Point aStart = rViewSh.GetChartInsertPos( aSize, aPositionRange ); tools::Rectangle aRect (aStart, aSize); - SdrOle2Obj* pObj = new SdrOle2Obj( + m_pInsertedObject = new SdrOle2Obj( *pDoc, // TTTT should be reference svt::EmbeddedObjectRef(xObj, nAspect), aName, @@ -597,11 +649,10 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV // pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immediate redraw and asks the chart for a visual representation // use the page instead of the view to insert, so no undo action is created yet - SdrPage* pInsPage = pPV->GetPage(); - pInsPage->InsertObject( pObj ); + SdrPage* m_pPage = pPV->GetPage(); + m_pPage->InsertObject( m_pInsertedObject ); pView->UnmarkAllObj(); - pView->MarkObj( pObj, pPV ); - bool bAddUndo = true; // add undo action later, unless the dialog is canceled + pView->MarkObj( m_pInsertedObject, pPV ); if (rReq.IsAPI()) { @@ -614,7 +665,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV // only activate object if not called via API (e.g. macro) if (!comphelper::LibreOfficeKit::isActive()) - rViewShell.ActivateObject(pObj, embed::EmbedVerbs::MS_OLEVERB_SHOW); + rViewShell.ActivateObject(m_pInsertedObject, embed::EmbedVerbs::MS_OLEVERB_SHOW); //open wizard //@todo get context from calc if that has one @@ -625,11 +676,11 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); if(xMCF.is()) { - uno::Reference< ui::dialogs::XExecutableDialog > xDialog( + m_xDialog = uno::Reference< ui::dialogs::XAsynchronousExecutableDialog >( xMCF->createInstanceWithContext( "com.sun.star.comp.chart2.WizardDialog" , xContext), uno::UNO_QUERY); - uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY ); + uno::Reference< lang::XInitialization > xInit( m_xDialog, uno::UNO_QUERY ); if( xChartModel.is() && xInit.is() ) { uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence( @@ -640,7 +691,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV xInit->initialize( aSeq ); // try to set the dialog's position so it doesn't hide the chart - uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY ); + uno::Reference < beans::XPropertySet > xDialogProps( m_xDialog, uno::UNO_QUERY ); if ( xDialogProps.is() ) { try @@ -670,62 +721,21 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV } } - sal_Int16 nDialogRet = xDialog->execute(); - if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) - { - // leave OLE inplace mode and unmark - OSL_ASSERT( pView ); - rViewShell.DeactivateOle(); - pView->UnmarkAll(); - - // old page view pointer is invalid after switching sheets - pPV = pView->GetSdrPageView(); - - // remove the chart - OSL_ASSERT( pPV ); - SdrPage * pPage( pPV->GetPage()); - OSL_ASSERT( pPage ); - OSL_ASSERT( pObj ); - if( pPage ) - { - // Remove the OLE2 object from the sdr page. - SdrObject* pRemoved = pPage->RemoveObject(pObj->GetOrdNum()); - OSL_ASSERT(pRemoved == pObj); - SdrObject::Free(pRemoved); // Don't forget to free it. - } - - bAddUndo = false; // don't create the undo action for inserting - - // leave the draw shell - rViewShell.SetDrawShell( false ); + ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener(); + pListener->SetDialogClosedLink( LINK( this, FuInsertChart, DialogClosedHdl ) ); + css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener ); - // reset marked cell area - - rViewSh.GetViewData().GetViewShell()->SetMarkData(aMark); - } - else - { - OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK ); - //@todo maybe move chart to different table - } + m_xDialog->startExecuteModal( xListener ); + } + else + { + uno::Reference< lang::XComponent > xComponent( m_xDialog, uno::UNO_QUERY ); + if( xComponent.is()) + xComponent->dispose(); } - uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); - if( xComponent.is()) - xComponent->dispose(); } } } - else if( xChartModel.is() ) - xChartModel->unlockControllers(); - - if ( bAddUndo ) - { - // add undo action the same way as in SdrEditView::InsertObjectAtView - // (using UndoActionHdl etc.) - pView->AddUndo(std::make_unique<SdrUndoNewObj>(*pObj)); - } - - // BM/IHA -- } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/fuinsert.hxx b/sc/source/ui/inc/fuinsert.hxx index 863aa6d88cb1..cfad23933836 100644 --- a/sc/source/ui/inc/fuinsert.hxx +++ b/sc/source/ui/inc/fuinsert.hxx @@ -22,6 +22,9 @@ #include "fupoor.hxx" #include <scdllapi.h> +#include <svx/svdoole2.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> +#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> class FuInsertGraphic : public FuPoor { @@ -40,9 +43,14 @@ public: class FuInsertChart : public FuPoor { -public: - FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pView, - SdrModel* pDoc, SfxRequest& rReq); + css::uno::Reference<css::ui::dialogs::XAsynchronousExecutableDialog> m_xDialog; + SdrOle2Obj* m_pInsertedObject; + + DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); + + public: + FuInsertChart( ScTabViewShell& pViewSh, vcl::Window* pWin, ScDrawView* pView, + SdrModel* pDoc, SfxRequest& rReq); }; class FuInsertMedia : public FuPoor diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 210cf689d2c1..df33dac2c00e 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -59,6 +59,7 @@ class ScPageBreakShell; class ScDPObject; class ScNavigatorSettings; class ScRangeName; +class FuInsertChart; struct ScHeaderFieldData; @@ -97,6 +98,7 @@ private: sal_uInt16 nDrawSfxId; sal_uInt16 nFormSfxId; OUString sDrawCustom; // current custom shape type + std::unique_ptr<ScDrawShell> pDrawShell; std::unique_ptr<ScDrawTextObjectBar> pDrawTextShell; std::unique_ptr<ScEditShell> pEditShell; @@ -111,6 +113,7 @@ private: std::unique_ptr<ScPageBreakShell> pPageBreakShell; std::unique_ptr<svx::ExtrusionBar> pExtrusionBarShell; std::unique_ptr<svx::FontworkBar> pFontworkBarShell; + std::unique_ptr<FuInsertChart> pFuInsertChart; std::unique_ptr<FmFormShell> pFormShell; diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index f4f61330b4fb..e190b3fdb684 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -56,6 +56,7 @@ #include <inputwin.hxx> #include <dbdata.hxx> #include <reffact.hxx> +#include <fuinsert.hxx> #include <viewuno.hxx> #include <dispuno.hxx> #include <chgtrack.hxx> diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index 545fce092934..6b4f3b4a8045 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -333,7 +333,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq) break; case SID_INSERT_DIAGRAM: - FuInsertChart(*this, pWin, pView, pDrModel, rReq); + pFuInsertChart.reset(new FuInsertChart(*this, pWin, pView, pDrModel, rReq)); break; case SID_INSERT_OBJECT: diff --git a/sw/source/uibase/inc/chartins.hxx b/sw/source/uibase/inc/chartins.hxx index 383e0fda1a58..d258053ae985 100644 --- a/sw/source/uibase/inc/chartins.hxx +++ b/sw/source/uibase/inc/chartins.hxx @@ -20,11 +20,17 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_CHARTINS_HXX #include <tools/gen.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> namespace vcl { class Window; } Point SwGetChartDialogPos( const vcl::Window *pParentWin, const Size& rDialogSize, const tools::Rectangle& rLogicChart ); -void SwInsertChart(); + +class SwInsertChart +{ +public: + SwInsertChart( const Link<css::ui::dialogs::DialogClosedEvent*,void>& rLink ); +}; #endif // INCLUDED_SW_SOURCE_UIBASE_INC_CHARTINS_HXX diff --git a/sw/source/uibase/inc/textsh.hxx b/sw/source/uibase/inc/textsh.hxx index 9ec521afe647..849bffcf4f2b 100644 --- a/sw/source/uibase/inc/textsh.hxx +++ b/sw/source/uibase/inc/textsh.hxx @@ -22,11 +22,13 @@ #include "basesh.hxx" #include <unotools/caserotate.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> class AbstractSvxPostItDialog; class SwFieldMgr; class SwFlyFrameAttrMgr; class SvxHyperlinkItem; +class SwInsertChart; class SW_DLLPUBLIC SwTextShell: public SwBaseShell { @@ -46,6 +48,7 @@ private: public: DECL_LINK( RedlineNextHdl, AbstractSvxPostItDialog&, void ); DECL_LINK( RedlinePrevHdl, AbstractSvxPostItDialog&, void ); + DECL_STATIC_LINK( SwTextShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); void Execute(SfxRequest &); void GetState(SfxItemSet &); diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index ef1341d078bc..c16dcf1a7cfc 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -87,9 +87,30 @@ using namespace ::com::sun::star; #include <drawdoc.hxx> #include <svtools/embedhlp.hxx> #include <sfx2/event.hxx> +#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <IDocumentUndoRedo.hxx> SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell) +IMPL_STATIC_LINK( SwTextShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvent, void ) +{ + SwView* pView = ::GetActiveView(); + SwWrtShell& rWrtShell = pView->GetWrtShell(); + + sal_Int16 nDialogRet = pEvent->DialogResult; + if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) + { + rWrtShell.Undo(); + rWrtShell.GetIDocumentUndoRedo().ClearRedo(); + } + else + { + OSL_ENSURE( nDialogRet == ui::dialogs::ExecutableDialogResults::OK, + "dialog execution failed" ); + } +} + void SwTextShell::InitInterface_Impl() { GetStaticInterface()->RegisterPopupMenu("text"); @@ -303,7 +324,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) break; if(!rReq.IsAPI()) { - SwInsertChart(); + SwInsertChart( LINK( this, SwTextShell, DialogClosedHdl ) ); } else { diff --git a/sw/source/uibase/table/chartins.cxx b/sw/source/uibase/table/chartins.cxx index b9e5f1e5103b..51289c19e983 100644 --- a/sw/source/uibase/table/chartins.cxx +++ b/sw/source/uibase/table/chartins.cxx @@ -41,11 +41,12 @@ #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/XWindow.hpp> +#include <svtools/dialogclosedlistener.hxx> #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> using namespace ::com::sun::star; @@ -122,7 +123,7 @@ Point SwGetChartDialogPos( const vcl::Window *pParentWin, const Size& rDialogSiz return aRet; } -void SwInsertChart() +SwInsertChart::SwInsertChart( const Link<css::ui::dialogs::DialogClosedEvent*, void>& rLink ) { SwView *pView = ::GetActiveView(); @@ -162,7 +163,7 @@ void SwInsertChart() uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); if(xMCF.is()) { - uno::Reference< ui::dialogs::XExecutableDialog > xDialog( + uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > xDialog( xMCF->createInstanceWithContext( "com.sun.star.comp.chart2.WizardDialog", xContext), uno::UNO_QUERY); @@ -208,21 +209,18 @@ void SwInsertChart() } } - sal_Int16 nDialogRet = xDialog->execute(); - if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) - { - rWrtShell.Undo(); - rWrtShell.GetIDocumentUndoRedo().ClearRedo(); - } - else - { - OSL_ENSURE( nDialogRet == ui::dialogs::ExecutableDialogResults::OK, - "dialog execution failed" ); - } + ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener(); + pListener->SetDialogClosedLink( rLink ); + css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener ); + + xDialog->startExecuteModal( xListener ); + } + else + { + uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); + if( xComponent.is()) + xComponent->dispose(); } - uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); - if( xComponent.is()) - xComponent->dispose(); } } } diff --git a/vcl/source/control/wizardmachine.cxx b/vcl/source/control/wizardmachine.cxx index c9e323620332..2e5d48458d1c 100644 --- a/vcl/source/control/wizardmachine.cxx +++ b/vcl/source/control/wizardmachine.cxx @@ -1387,6 +1387,9 @@ namespace vcl void WizardMachine::resumeTraveling( AccessGuard ) { + if (!m_pImpl) + return; + DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "WizardMachine::resumeTraveling: nothing to resume!" ); m_pImpl->m_bTravelingSuspended = false; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits