[Libreoffice-commits] core.git: Branch 'feature/eszka' - 2 commits - sc/source vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 25 12:41:20 UTC 2020


 sc/source/ui/attrdlg/scdlgfact.cxx |    5 
 sc/source/ui/attrdlg/scdlgfact.hxx |    3 
 sc/source/ui/view/cellsh1.cxx      |  231 +++++++++++++++++++------------------
 vcl/source/window/builder.cxx      |    5 
 4 files changed, 135 insertions(+), 109 deletions(-)

New commits:
commit 2f9e09a6efedbdfe811bc1d2aba687d653af4efe
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Nov 25 13:39:28 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Nov 25 13:39:28 2020 +0100

    jsdialog: enable Pivot Table dialogs
    
    Change-Id: Ic467c95f0d56d28e6c6590d488e2a0b10f65e803

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index d141dace9e98..7067a05c5c77 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -166,6 +166,11 @@ weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString
             bUseJSBuilder = true;
     }
 
+    if (comphelper::LibreOfficeKit::isActive() &&
+        (rUIFile == "modules/scalc/ui/pivottablelayoutdialog.ui"
+        || rUIFile == "modules/scalc/ui/selectsource.ui"))
+        bUseJSBuilder = true;
+
     if (bUseJSBuilder)
         return JSInstanceBuilder::CreateDialogBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile);
     else
commit 06aae3931d88705cb34e82654ad6fff8437d28a0
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Nov 23 12:02:07 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon Nov 23 12:02:07 2020 +0100

    Make Pivot table data source dialog async
    
    Change-Id: I573038935e31c5393293197c1a9706110a970837

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index ab717e1ee05e..cb9d07c008ad 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -110,6 +110,11 @@ short AbstractScDataPilotSourceTypeDlg_Impl::Execute()
     return m_xDlg->run();
 }
 
+bool AbstractScDataPilotSourceTypeDlg_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+    return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 short AbstractScDataPilotServiceDlg_Impl::Execute()
 {
     return m_xDlg->run();
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 4f8987bc4e1a..582d189ef4c0 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -181,13 +181,14 @@ public:
 
 class AbstractScDataPilotSourceTypeDlg_Impl  :public AbstractScDataPilotSourceTypeDlg
 {
-    std::unique_ptr<ScDataPilotSourceTypeDlg> m_xDlg;
+    std::shared_ptr<ScDataPilotSourceTypeDlg> m_xDlg;
 public:
     explicit AbstractScDataPilotSourceTypeDlg_Impl(std::unique_ptr<ScDataPilotSourceTypeDlg> p)
         : m_xDlg(std::move(p))
     {
     }
     virtual short Execute() override;
+    virtual bool StartExecuteAsync(AsyncContext &) override;
     virtual bool IsDatabase() const override;
     virtual bool IsExternal() const override;
     virtual bool IsNamedRange() const override;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index e715c721c721..11d9b5aa743a 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2780,6 +2780,23 @@ bool isDPSourceValid(const ScDPObject& rDPObj)
     return true;
 }
 
+void RunPivotLayoutDialog(ScModule* pScMod,
+                          ScTabViewShell* pTabViewShell,
+                          std::unique_ptr<ScDPObject>& pNewDPObject)
+{
+    bool bHadNewDPObject = pNewDPObject != nullptr;
+    pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) );
+    if ( bHadNewDPObject )
+    {
+        //  start layout dialog
+
+        sal_uInt16 nId  = ScPivotLayoutWrapper::GetChildWindowId();
+        SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+        SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+        pScMod->SetRefDialog( nId, pWnd == nullptr );
+    }
+}
+
 }
 
 void ScCellShell::ExecuteDataPilotDialog()
@@ -2789,21 +2806,21 @@ void ScCellShell::ExecuteDataPilotDialog()
     ScViewData* pData = GetViewData();
     ScDocument* pDoc = pData->GetDocument();
 
-    std::unique_ptr<ScDPObject> pNewDPObject;
-
     // ScPivot is no longer used...
     ScDPObject* pDPObj = pDoc->GetDPAtCursor(
                                 pData->GetCurX(), pData->GetCurY(),
                                 pData->GetTabNo() );
     if ( pDPObj )   // on an existing table?
     {
+        std::unique_ptr<ScDPObject> pNewDPObject;
+
         if (isDPSourceValid(*pDPObj))
             pNewDPObject.reset(new ScDPObject(*pDPObj));
+
+        RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
     }
     else            // create new table
     {
-        const char* pSrcErrorId = nullptr;
-
         //  select database range or data
         pTabViewShell->GetDBData( true, SC_DB_OLD );
         ScMarkData& rMark = GetViewData()->GetMarkData();
@@ -2820,7 +2837,7 @@ void ScCellShell::ExecuteDataPilotDialog()
 
         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
 
-        ScopedVclPtr<AbstractScDataPilotSourceTypeDlg> pTypeDlg(
+        VclPtr<AbstractScDataPilotSourceTypeDlg> pTypeDlg(
             pFact->CreateScDataPilotSourceTypeDlg(
                 pTabViewShell->GetFrameWeld(), bEnableExt));
 
@@ -2833,129 +2850,127 @@ void ScCellShell::ExecuteDataPilotDialog()
                 pTypeDlg->AppendNamedRange(itr->second->GetName());
         }
 
-        if ( pTypeDlg->Execute() == RET_OK )
-        {
-            if ( pTypeDlg->IsExternal() )
-            {
-                std::vector<OUString> aSources = ScDPObject::GetRegisteredSources();
-                ScopedVclPtr<AbstractScDataPilotServiceDlg> pServDlg(
-                    pFact->CreateScDataPilotServiceDlg(
-                        pTabViewShell->GetFrameWeld(), aSources));
+        pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell,
+                                    pScMod, pFact, pDoc, &rMark, &aDestPos](int nResult) {
+            const char* pSrcErrorId = nullptr;
+            std::unique_ptr<ScDPObject> pNewDPObject;
 
-                if ( pServDlg->Execute() == RET_OK )
-                {
-                    ScDPServiceDesc aServDesc(
-                            pServDlg->GetServiceName(),
-                            pServDlg->GetParSource(),
-                            pServDlg->GetParName(),
-                            pServDlg->GetParUser(),
-                            pServDlg->GetParPass() );
-                    pNewDPObject.reset(new ScDPObject(pDoc));
-                    pNewDPObject->SetServiceData( aServDesc );
-                }
-            }
-            else if ( pTypeDlg->IsDatabase() )
+            if (nResult == RET_OK )
             {
-                assert(pFact && "ScAbstractFactory create fail!");
-                ScopedVclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg(
-                    pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld()));
-                assert(pDataDlg  && "Dialog create fail!");
-                if ( pDataDlg->Execute() == RET_OK )
+                if ( pTypeDlg->IsExternal() )
                 {
-                    ScImportSourceDesc aImpDesc(pDoc);
-                    pDataDlg->GetValues( aImpDesc );
-                    pNewDPObject.reset(new ScDPObject(pDoc));
-                    pNewDPObject->SetImportDesc( aImpDesc );
+                    std::vector<OUString> aSources = ScDPObject::GetRegisteredSources();
+                    ScopedVclPtr<AbstractScDataPilotServiceDlg> pServDlg(
+                        pFact->CreateScDataPilotServiceDlg(
+                            pTabViewShell->GetFrameWeld(), aSources));
+
+                    if ( pServDlg->Execute() == RET_OK )
+                    {
+                        ScDPServiceDesc aServDesc(
+                                pServDlg->GetServiceName(),
+                                pServDlg->GetParSource(),
+                                pServDlg->GetParName(),
+                                pServDlg->GetParUser(),
+                                pServDlg->GetParPass() );
+                        pNewDPObject.reset(new ScDPObject(pDoc));
+                        pNewDPObject->SetServiceData( aServDesc );
+                    }
                 }
-            }
-            else if (pTypeDlg->IsNamedRange())
-            {
-                OUString aName = pTypeDlg->GetSelectedNamedRange();
-                ScSheetSourceDesc aShtDesc(pDoc);
-                aShtDesc.SetRangeName(aName);
-                pSrcErrorId = aShtDesc.CheckSourceRange();
-                if (!pSrcErrorId)
+                else if ( pTypeDlg->IsDatabase() )
                 {
-                    pNewDPObject.reset(new ScDPObject(pDoc));
-                    pNewDPObject->SetSheetDesc(aShtDesc);
-                }
-            }
-            else        // selection
-            {
-                //! use database ranges (select before type dialog?)
-                ScRange aRange;
-                ScMarkType eType = GetViewData()->GetSimpleArea(aRange);
-                if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
-                {
-                    // Shrink the range to the data area.
-                    SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
-                    SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
-                    if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
+                    assert(pFact && "ScAbstractFactory create fail!");
+                    ScopedVclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg(
+                        pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld()));
+                    assert(pDataDlg  && "Dialog create fail!");
+                    if ( pDataDlg->Execute() == RET_OK )
                     {
-                        aRange.aStart.SetCol(nStartCol);
-                        aRange.aStart.SetRow(nStartRow);
-                        aRange.aEnd.SetCol(nEndCol);
-                        aRange.aEnd.SetRow(nEndRow);
-                        rMark.SetMarkArea(aRange);
-                        pTabViewShell->MarkRange(aRange);
+                        ScImportSourceDesc aImpDesc(pDoc);
+                        pDataDlg->GetValues( aImpDesc );
+                        pNewDPObject.reset(new ScDPObject(pDoc));
+                        pNewDPObject->SetImportDesc( aImpDesc );
                     }
-
-                    bool bOK = true;
-                    if ( pDoc->HasSubTotalCells( aRange ) )
+                }
+                else if (pTypeDlg->IsNamedRange())
+                {
+                    OUString aName = pTypeDlg->GetSelectedNamedRange();
+                    ScSheetSourceDesc aShtDesc(pDoc);
+                    aShtDesc.SetRangeName(aName);
+                    pSrcErrorId = aShtDesc.CheckSourceRange();
+                    if (!pSrcErrorId)
                     {
-                        //  confirm selection if it contains SubTotal cells
-                        std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
-                                                                       VclMessageType::Question, VclButtonsType::YesNo,
-                                                                       ScResId(STR_DATAPILOT_SUBTOTAL)));
-                        xQueryBox->set_default_response(RET_YES);
-                        if (xQueryBox->run() == RET_NO)
-                            bOK = false;
+                        pNewDPObject.reset(new ScDPObject(pDoc));
+                        pNewDPObject->SetSheetDesc(aShtDesc);
                     }
-                    if (bOK)
+                }
+                else        // selection
+                {
+                    //! use database ranges (select before type dialog?)
+                    ScRange aRange;
+                    ScMarkType eType = GetViewData()->GetSimpleArea(aRange);
+                    if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
                     {
-                        ScSheetSourceDesc aShtDesc(pDoc);
-                        aShtDesc.SetSourceRange(aRange);
-                        pSrcErrorId = aShtDesc.CheckSourceRange();
-                        if (!pSrcErrorId)
+                        // Shrink the range to the data area.
+                        SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
+                        SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
+                        if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
                         {
-                            pNewDPObject.reset(new ScDPObject(pDoc));
-                            pNewDPObject->SetSheetDesc( aShtDesc );
+                            aRange.aStart.SetCol(nStartCol);
+                            aRange.aStart.SetRow(nStartRow);
+                            aRange.aEnd.SetCol(nEndCol);
+                            aRange.aEnd.SetRow(nEndRow);
+                            rMark.SetMarkArea(aRange);
+                            pTabViewShell->MarkRange(aRange);
                         }
 
-                        //  output below source data
-                        if ( aRange.aEnd.Row()+2 <= pDoc->MaxRow() - 4 )
-                            aDestPos = ScAddress( aRange.aStart.Col(),
-                                                    aRange.aEnd.Row()+2,
-                                                    aRange.aStart.Tab() );
+                        bool bOK = true;
+                        if ( pDoc->HasSubTotalCells( aRange ) )
+                        {
+                            //  confirm selection if it contains SubTotal cells
+                            std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
+                                                                        VclMessageType::Question, VclButtonsType::YesNo,
+                                                                        ScResId(STR_DATAPILOT_SUBTOTAL)));
+                            xQueryBox->set_default_response(RET_YES);
+                            if (xQueryBox->run() == RET_NO)
+                                bOK = false;
+                        }
+                        if (bOK)
+                        {
+                            ScSheetSourceDesc aShtDesc(pDoc);
+                            aShtDesc.SetSourceRange(aRange);
+                            pSrcErrorId = aShtDesc.CheckSourceRange();
+                            if (!pSrcErrorId)
+                            {
+                                pNewDPObject.reset(new ScDPObject(pDoc));
+                                pNewDPObject->SetSheetDesc( aShtDesc );
+                            }
+
+                            //  output below source data
+                            if ( aRange.aEnd.Row()+2 <= pDoc->MaxRow() - 4 )
+                                aDestPos = ScAddress( aRange.aStart.Col(),
+                                                        aRange.aEnd.Row()+2,
+                                                        aRange.aStart.Tab() );
+                        }
                     }
                 }
             }
-        }
 
-        if (pSrcErrorId)
-        {
-            // Error occurred during data creation.  Launch an error and bail out.
-            std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
-                                                          VclMessageType::Info, VclButtonsType::Ok,
-                                                          ScResId(pSrcErrorId)));
-            xInfoBox->run();
-            return;
-        }
+            if (pSrcErrorId)
+            {
+                // Error occurred during data creation.  Launch an error and bail out.
+                std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
+                                                            VclMessageType::Info, VclButtonsType::Ok,
+                                                            ScResId(pSrcErrorId)));
+                xInfoBox->run();
+                return;
+            }
 
-        if ( pNewDPObject )
-            pNewDPObject->SetOutRange( aDestPos );
-    }
+            if ( pNewDPObject )
+                pNewDPObject->SetOutRange( aDestPos );
 
-    bool bHadNewDPObject = pNewDPObject != nullptr;
-    pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) );
-    if ( bHadNewDPObject )
-    {
-        //  start layout dialog
+            pTypeDlg->disposeOnce();
 
-        sal_uInt16 nId  = ScPivotLayoutWrapper::GetChildWindowId();
-        SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
-        SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
-        pScMod->SetRefDialog( nId, pWnd == nullptr );
+            RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
+        });
     }
 }
 


More information about the Libreoffice-commits mailing list