sc/source/filter/inc/workbookfragment.hxx |    2 
 sc/source/filter/oox/workbookfragment.cxx |   79 +++++++++++++++++++++++++++---
 sc/source/filter/oox/workbookhelper.cxx   |   51 -------------------
 3 files changed, 75 insertions(+), 57 deletions(-)

New commits:
commit d4743045a0b320449d07a957463a76bb8b13f939
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sat Oct 24 09:45:58 2015 +0200

    the cells need to be imported before we handle charts, tdf#81396
    
    Change-Id: Ic0dc47b71e76aa4825a867fc171406d126ae0518
    Reviewed-on: https://gerrit.libreoffice.org/19568
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/filter/inc/workbookfragment.hxx 
b/sc/source/filter/inc/workbookfragment.hxx
index 4a28034..4e22b7b 100644
--- a/sc/source/filter/inc/workbookfragment.hxx
+++ b/sc/source/filter/inc/workbookfragment.hxx
@@ -55,6 +55,8 @@ private:
     void                importExternalLinkFragment( ExternalLink& rExtLink );
     void                importPivotCacheDefFragment( const OUString& rRelId, 
sal_Int32 nCacheId );
 
+    void recalcFormulaCells();
+
 private:
     DefinedNameRef      mxCurrName;
 };
diff --git a/sc/source/filter/oox/workbookfragment.cxx 
b/sc/source/filter/oox/workbookfragment.cxx
index 08ca758..abd63b07 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -52,9 +52,11 @@
 #include "document.hxx"
 #include "docsh.hxx"
 #include "calcconfig.hxx"
+#include "globstr.hrc"
 
 #include <vcl/svapp.hxx>
 #include <vcl/timer.hxx>
+#include <vcl/msgbox.hxx>
 
 #include <oox/core/fastparser.hxx>
 #include <salhelper/thread.hxx>
@@ -68,6 +70,9 @@
 
 #include <oox/ole/vbaproject.hxx>
 
+#include <comphelper/processfactory.hxx>
+#include <officecfg/Office/Calc.hxx>
+
 namespace oox {
 namespace xls {
 
@@ -482,6 +487,19 @@ void WorkbookFragment::finalizeImport()
     // load all worksheets
     importSheetFragments(*this, aSheetFragments);
 
+    sal_Int16 nActiveSheet = getViewSettings().getActiveCalcSheet();
+    getWorksheets().finalizeImport( nActiveSheet );
+
+    // final conversions, e.g. calculation settings and view settings
+    finalizeWorkbookImport();
+    //
+    //stop preventing establishment of listeners as is done in
+    //ScDocShell::AfterXMLLoading() for ods
+    getScDocument().SetInsertingFromOtherDoc(false);
+    getDocImport().finalize();
+
+    recalcFormulaCells();
+
     for( std::vector<WorksheetHelper*>::iterator aIt = maHelpers.begin(), aEnd 
= maHelpers.end(); aIt != aEnd; ++aIt )
     {
         (*aIt)->finalizeDrawingImport();
@@ -494,12 +512,6 @@ void WorkbookFragment::finalizeImport()
         aIt->first.reset();
     }
 
-    sal_Int16 nActiveSheet = getViewSettings().getActiveCalcSheet();
-    getWorksheets().finalizeImport( nActiveSheet );
-
-    // final conversions, e.g. calculation settings and view settings
-    finalizeWorkbookImport();
-
     OUString aRevHeadersPath = 
getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
     if (!aRevHeadersPath.isEmpty())
     {
@@ -509,6 +521,61 @@ void WorkbookFragment::finalizeImport()
     }
 }
 
+namespace {
+
+ScDocShell& getDocShell(ScDocument& rDoc)
+{
+    return static_cast<ScDocShell&>(*rDoc.GetDocumentShell());
+}
+
+}
+
+void WorkbookFragment::recalcFormulaCells()
+{
+    // Recalculate formula cells.
+    ScDocument& rDoc = getScDocument();
+    ScDocShell& rDocSh = getDocShell(rDoc);
+    Reference< XComponentContext > xContext = 
comphelper::getProcessComponentContext();
+    ScRecalcOptions nRecalcMode =
+        
static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
+    bool bHardRecalc = false;
+    if (nRecalcMode == RECALC_ASK)
+    {
+        if (rDoc.IsUserInteractionEnabled())
+        {
+            // Ask the user if full re-calculation is desired.
+            ScopedVclPtrInstance<QueryBox> aBox(
+                ScDocShell::GetActiveDialogParent(), WinBits(WB_YES_NO | 
WB_DEF_YES),
+                ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
+            
aBox->SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED));
+
+            sal_Int32 nRet = aBox->Execute();
+            bHardRecalc = nRet == RET_YES;
+
+            if (aBox->GetCheckBoxState())
+            {
+                // Always perform selected action in the future.
+                std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
+                
officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), 
batch);
+                ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
+                aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : 
RECALC_NEVER);
+                /* XXX  is this really supposed to set the ScModule options?
+                 *      Not the ScDocShell options? */
+                SC_MOD()->SetFormulaOptions(aOpt);
+
+                batch->commit();
+            }
+        }
+    }
+    else if (nRecalcMode == RECALC_ALWAYS)
+        bHardRecalc = true;
+
+    if (bHardRecalc)
+        rDocSh.DoHardRecalc(false);
+    else
+        rDoc.CalcFormulaTree(false, true, false);
+}
+
 // private --------------------------------------------------------------------
 
 void WorkbookFragment::importExternalReference( const AttributeList& rAttribs )
diff --git a/sc/source/filter/oox/workbookhelper.cxx 
b/sc/source/filter/oox/workbookhelper.cxx
index a4cb2f6..ce4f54b 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -660,60 +660,9 @@ void WorkbookGlobals::finalize()
         if (pModel)
             pModel->SetOpenInDesignMode(false);
 
-        //stop preventing establishment of listeners as is done in
-        //ScDocShell::AfterXMLLoading() for ods
-        mpDoc->SetInsertingFromOtherDoc(false);
-        getDocImport().finalize();
-
-        recalcFormulaCells();
     }
 }
 
-void WorkbookGlobals::recalcFormulaCells()
-{
-    // Recalculate formula cells.
-    ScDocument& rDoc = getScDocument();
-    ScDocShell& rDocSh = getDocShell();
-    Reference< XComponentContext > xContext = 
comphelper::getProcessComponentContext();
-    ScRecalcOptions nRecalcMode =
-        
static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
-    bool bHardRecalc = false;
-    if (nRecalcMode == RECALC_ASK)
-    {
-        if (rDoc.IsUserInteractionEnabled())
-        {
-            // Ask the user if full re-calculation is desired.
-            ScopedVclPtrInstance<QueryBox> aBox(
-                ScDocShell::GetActiveDialogParent(), WinBits(WB_YES_NO | 
WB_DEF_YES),
-                ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
-            
aBox->SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED));
-
-            sal_Int32 nRet = aBox->Execute();
-            bHardRecalc = nRet == RET_YES;
-
-            if (aBox->GetCheckBoxState())
-            {
-                // Always perform selected action in the future.
-                std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
-                
officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), 
batch);
-                ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
-                aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : 
RECALC_NEVER);
-                /* XXX  is this really supposed to set the ScModule options?
-                 *      Not the ScDocShell options? */
-                SC_MOD()->SetFormulaOptions(aOpt);
-
-                batch->commit();
-            }
-        }
-    }
-    else if (nRecalcMode == RECALC_ALWAYS)
-        bHardRecalc = true;
-
-    if (bHardRecalc)
-        rDocSh.DoHardRecalc(false);
-    else
-        rDoc.CalcFormulaTree(false, true, false);
-}
 
 WorkbookHelper::~WorkbookHelper()
 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to