[Libreoffice-commits] core.git: Branch 'private/kohei/external-ref-refresh' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue May 20 18:02:53 PDT 2014


 sc/inc/document.hxx                      |    3 
 sc/inc/xmlwrap.hxx                       |   14 
 sc/source/core/data/documen2.cxx         |    1 
 sc/source/core/data/documen9.cxx         |    5 
 sc/source/filter/xml/xmlimprt.cxx        |   23 +
 sc/source/filter/xml/xmlimprt.hxx        |    6 
 sc/source/filter/xml/xmlwrap.cxx         |  473 +++++++++++++++----------------
 sc/source/ui/docshell/docsh.cxx          |   10 
 sc/source/ui/docshell/externalrefmgr.cxx |    4 
 9 files changed, 268 insertions(+), 271 deletions(-)

New commits:
commit ce3152ab14937cc37102b0be4264c793d288235a
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue May 20 21:01:46 2014 -0400

    Let's not use ScDocument as a convenient "anything goes" storage place.
    
    Change-Id: I0ae2f44b89b0db915e78a9b07835000e843d016f

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 08f1ca4..e1aabf4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -400,7 +400,6 @@ private:
     bool                bInsertingFromOtherDoc;
     bool                bLoadingMedium;
     bool                bImportingXML;      // special handling of formula text
-    bool                bXMLFromWrapper;    // distinguish ScXMLImportWrapper from external component
     bool                bCalcingAfterLoad;              // in CalcAfterLoad TRUE
     // don't construct/destruct listeners temporarily
     bool                bNoListening;
@@ -1754,8 +1753,6 @@ public:
     void            SetLoadingMedium( bool bVal );
     void            SetImportingXML( bool bVal );
     bool            IsImportingXML() const { return bImportingXML; }
-    void            SetXMLFromWrapper( bool bVal );
-    bool            IsXMLFromWrapper() const { return bXMLFromWrapper; }
     void            SetCalcingAfterLoad( bool bVal ) { bCalcingAfterLoad = bVal; }
     bool            IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
     void            SetNoListening( bool bVal ) { bNoListening = bVal; }
diff --git a/sc/inc/xmlwrap.hxx b/sc/inc/xmlwrap.hxx
index 8bb78af..e74c01a 100644
--- a/sc/inc/xmlwrap.hxx
+++ b/sc/inc/xmlwrap.hxx
@@ -26,10 +26,6 @@
 #include "importfilterdata.hxx"
 #include <sal/types.h>
 
-class ScDocument;
-class SfxMedium;
-class ScMySharedData;
-
 #include <tools/errcode.hxx>
 
 namespace com { namespace sun { namespace star {
@@ -43,10 +39,16 @@ namespace com { namespace sun { namespace star {
         namespace sax { struct InputSource; class XParser; class XWriter; } }
 } } }
 
+class ScDocument;
+class SfxMedium;
+class ScMySharedData;
+class ScDocShell;
+
 class ScXMLImportWrapper
 {
     sc::ImportPostProcessData maPostProcessData;
 
+    ScDocShell& mrDocShell;
     ScDocument&     rDoc;
     SfxMedium*      pMedium;
     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > xStorage;
@@ -70,7 +72,9 @@ class ScXMLImportWrapper
         ScMySharedData*& pSharedData);
 
 public:
-    ScXMLImportWrapper(ScDocument& rD, SfxMedium* pM, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >&);
+    ScXMLImportWrapper(
+        ScDocShell& rDocSh, SfxMedium* pM, const css::uno::Reference<css::embed::XStorage>& xStor );
+
     bool Import(bool bStylesOnly, ErrCode& );
     bool Export(bool bStylesOnly);
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index e0ed474..d65c42c 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -194,7 +194,6 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
         bInsertingFromOtherDoc( false ),
         bLoadingMedium( false ),
         bImportingXML( false ),
-        bXMLFromWrapper( false ),
         bCalcingAfterLoad( false ),
         bNoListening( false ),
         mbIdleEnabled(true),
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 4d7920e..c9fe85b 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -620,11 +620,6 @@ void ScDocument::SetImportingXML( bool bVal )
     SetLoadingMedium(bVal);
 }
 
-void ScDocument::SetXMLFromWrapper( bool bVal )
-{
-    bXMLFromWrapper = bVal;
-}
-
 rtl::Reference<SvxForbiddenCharactersTable> ScDocument::GetForbiddenCharacters()
 {
     return xForbiddenCharacters;
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index f95b2aa..2aa6c14 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -2102,7 +2102,7 @@ ScXMLImport::ScXMLImport(
     bRemoveLastChar(false),
     bNullDateSetted(false),
     bSelfImportingXMLSet(false),
-    bFromWrapper(false),
+    mbLockSolarMutex(true),
     mbHasNewCondFormatData(false)
 {
     pStylesImportHelper = new ScMyStylesImportHelper(*this);
@@ -2240,6 +2240,23 @@ ScXMLImport::~ScXMLImport() throw()
     delete pDetectiveOpArray;
 }
 
+void ScXMLImport::initialize( const css::uno::Sequence<css::uno::Any>& aArguments )
+        throw (css::uno::Exception, css::uno::RuntimeException, std::exception)
+{
+    SvXMLImport::initialize(aArguments);
+
+    uno::Reference<beans::XPropertySet> xInfoSet = getImportInfo();
+    if (!xInfoSet.is())
+        return;
+
+    uno::Reference<beans::XPropertySetInfo> xInfoSetInfo = xInfoSet->getPropertySetInfo();
+    if (!xInfoSetInfo.is())
+        return;
+
+    if (xInfoSetInfo->hasPropertyByName("LockSolarMutex"))
+        xInfoSet->getPropertyValue("LockSolarMutex") >>= mbLockSolarMutex;
+}
+
 SvXMLImportContext *ScXMLImport::CreateFontDeclsContext(const sal_uInt16 nPrefix, const OUString& rLocalName,
                                                         const uno::Reference<xml::sax::XAttributeList>& xAttrList)
 {
@@ -2964,8 +2981,6 @@ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::R
     mpComp.reset(new ScCompiler(pDoc, ScAddress()));
     mpComp->SetGrammar(formula::FormulaGrammar::GRAM_ODFF);
 
-    bFromWrapper = pDoc->IsXMLFromWrapper();    // UnlockSolarMutex below still works normally
-
     uno::Reference<document::XActionLockable> xActionLockable(xDoc, uno::UNO_QUERY);
     if (xActionLockable.is())
         xActionLockable->addActionLock();
@@ -3284,7 +3299,7 @@ void ScXMLImport::LockSolarMutex()
 {
     // #i62677# When called from DocShell/Wrapper, the SolarMutex is already locked,
     // so there's no need to allocate (and later delete) the SolarMutexGuard.
-    if (bFromWrapper)
+    if (!mbLockSolarMutex)
     {
         DBG_TESTSOLARMUTEX();
         return;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 97c4a5c..660f3bd 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -964,7 +964,7 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable
     bool                    bRemoveLastChar;
     bool                    bNullDateSetted;
     bool                    bSelfImportingXMLSet;
-    bool                    bFromWrapper;           // called from ScDocShell / ScXMLImportWrapper?
+    bool mbLockSolarMutex;
     bool mbHasNewCondFormatData;
 
 
@@ -986,6 +986,10 @@ public:
 
     virtual ~ScXMLImport() throw();
 
+    // XInitialization
+    virtual void SAL_CALL initialize( const css::uno::Sequence<css::uno::Any>& aArguments )
+        throw (css::uno::Exception, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
     // namespace office
     // NB: in contrast to other CreateFooContexts, this particular one handles
     //     the root element (i.e. office:document-meta)
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index e99fcdb..6282b9f 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -70,12 +70,14 @@
 #include "docuno.hxx"
 #include "sheetdata.hxx"
 #include "XMLCodeNameProvider.hxx"
+#include <docsh.hxx>
 
 using namespace com::sun::star;
 
 
-ScXMLImportWrapper::ScXMLImportWrapper(ScDocument& rD, SfxMedium* pM, const uno::Reference < embed::XStorage >& xStor ) :
-    rDoc(rD),
+ScXMLImportWrapper::ScXMLImportWrapper( ScDocShell& rDocSh, SfxMedium* pM, const uno::Reference < embed::XStorage >& xStor ) :
+    mrDocShell(rDocSh),
+    rDoc(*rDocSh.GetDocument()),
     pMedium(pM),
     xStorage(xStor)
 {
@@ -321,303 +323,294 @@ bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
     uno::Reference<xml::sax::XParser> xXMLParser = xml::sax::Parser::create(xContext);
 
     // get filter
-    SfxObjectShell* pObjSh = rDoc.GetDocumentShell();
-    if ( pObjSh )
+    OUString sEmpty;
+    uno::Reference<frame::XModel> xModel = mrDocShell.GetModel();
+
+    /** property map for export info set */
+    comphelper::PropertyMapEntry const aImportInfoMap[] =
     {
-        OUString sEmpty;
-        uno::Reference<frame::XModel> xModel(pObjSh->GetModel());
+        { OUString("ProgressRange"), 0, ::cppu::UnoType<sal_Int32>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
+        { OUString("ProgressMax"), 0, ::cppu::UnoType<sal_Int32>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
+        { OUString("ProgressCurrent"), 0, ::cppu::UnoType<sal_Int32>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
+        { OUString("NumberStyles"), 0, cppu::UnoType<container::XNameAccess>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
+        { OUString("PrivateData"), 0, cppu::UnoType<uno::XInterface>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("BuildId"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("VBACompatibilityMode"), 0, ::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("ScriptConfiguration"), 0, cppu::UnoType<container::XNameAccess>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
+        { OUString("OrganizerMode"), 0, ::getBooleanCppuType(),
+            ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString("LockSolarMutex"), 0, getBooleanCppuType(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString(), 0, css::uno::Type(), 0, 0 }
+    };
+    uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aImportInfoMap ) ) );
 
-        /** property map for export info set */
-        comphelper::PropertyMapEntry const aImportInfoMap[] =
-        {
-            { OUString("ProgressRange"), 0, ::cppu::UnoType<sal_Int32>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
-            { OUString("ProgressMax"), 0, ::cppu::UnoType<sal_Int32>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
-            { OUString("ProgressCurrent"), 0, ::cppu::UnoType<sal_Int32>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
-            { OUString("NumberStyles"), 0, cppu::UnoType<container::XNameAccess>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
-            { OUString("PrivateData"), 0, cppu::UnoType<uno::XInterface>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString("BuildId"), 0, ::cppu::UnoType<OUString>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString("VBACompatibilityMode"), 0, ::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString("ScriptConfiguration"), 0, cppu::UnoType<container::XNameAccess>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
-            { OUString("OrganizerMode"), 0, ::getBooleanCppuType(),
-                ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
-            { OUString(), 0, css::uno::Type(), 0, 0 }
-        };
-        uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aImportInfoMap ) ) );
-
-        // ---- get BuildId from parent container if available
-
-        uno::Reference< container::XChild > xChild( xModel, uno::UNO_QUERY );
-        if( xChild.is() )
+    xInfoSet->setPropertyValue("LockSolarMutex", uno::makeAny(false));
+
+    // ---- get BuildId from parent container if available
+
+    uno::Reference< container::XChild > xChild( xModel, uno::UNO_QUERY );
+    if( xChild.is() )
+    {
+        uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
+        if( xParentSet.is() )
         {
-            uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
-            if( xParentSet.is() )
+            uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
+            OUString sPropName("BuildId" );
+            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
             {
-                uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
-                OUString sPropName("BuildId" );
-                if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
-                {
-                    xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
-                }
+                xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
             }
         }
+    }
 
-        uno::Reference<task::XStatusIndicator> xStatusIndicator(GetStatusIndicator());
-        if (xStatusIndicator.is())
-        {
-            sal_Int32 nProgressRange(1000000);
-            xStatusIndicator->start(ScGlobal::GetRscString(STR_LOAD_DOC), nProgressRange);
-            xInfoSet->setPropertyValue("ProgressRange", uno::makeAny(nProgressRange));
-        }
+    uno::Reference<task::XStatusIndicator> xStatusIndicator = GetStatusIndicator();
+    if (xStatusIndicator.is())
+    {
+        sal_Int32 nProgressRange(1000000);
+        xStatusIndicator->start(ScGlobal::GetRscString(STR_LOAD_DOC), nProgressRange);
+        xInfoSet->setPropertyValue("ProgressRange", uno::makeAny(nProgressRange));
+    }
 
-        // Set base URI
-        OSL_ENSURE( pMedium, "There is no medium to get MediaDescriptor from!\n" );
-        OUString aBaseURL = pMedium ? pMedium->GetBaseURL() : OUString();
-        OUString sPropName("BaseURI");
-        xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
+    // Set base URI
+    OSL_ENSURE( pMedium, "There is no medium to get MediaDescriptor from!\n" );
+    OUString aBaseURL = pMedium ? pMedium->GetBaseURL() : OUString();
+    OUString sPropName("BaseURI");
+    xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
 
-        // TODO/LATER: do not do it for embedded links
-        OUString aName;
-        if( SFX_CREATE_MODE_EMBEDDED == pObjSh->GetCreateMode() )
+    // TODO/LATER: do not do it for embedded links
+    OUString aName;
+    if (SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode())
+    {
+        if ( pMedium && pMedium->GetItemSet() )
         {
-            if ( pMedium && pMedium->GetItemSet() )
-            {
-                const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
-                    pMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
-                if ( pDocHierarchItem )
-                    aName = pDocHierarchItem->GetValue();
-            }
-            else
-                aName = "dummyObjectName";
-
-            if( !aName.isEmpty() )
-            {
-                sPropName = "StreamRelPath";
-                xInfoSet->setPropertyValue( sPropName, uno::makeAny( aName ) );
-            }
+            const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
+                pMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
+            if ( pDocHierarchItem )
+                aName = pDocHierarchItem->GetValue();
         }
+        else
+            aName = "dummyObjectName";
 
-        if (bStylesOnly)
+        if( !aName.isEmpty() )
         {
-            OUString const sOrganizerMode(
-                "OrganizerMode");
-            xInfoSet->setPropertyValue(sOrganizerMode, uno::makeAny(sal_True));
+            sPropName = "StreamRelPath";
+            xInfoSet->setPropertyValue( sPropName, uno::makeAny( aName ) );
         }
+    }
 
-        xInfoSet->setPropertyValue( "SourceStorage", uno::Any( xStorage ) );
+    if (bStylesOnly)
+        xInfoSet->setPropertyValue("OrganizerMode", uno::makeAny(sal_True));
 
-        bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
+    xInfoSet->setPropertyValue( "SourceStorage", uno::Any( xStorage ) );
+
+    bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
 
-        if (!bStylesOnly && bOasis)
+    if (!bStylesOnly && bOasis)
+    {
+        // RDF metadata: ODF >= 1.2
+        try
         {
-            // RDF metadata: ODF >= 1.2
-            try
+            const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
+                xModel, uno::UNO_QUERY_THROW );
+            const uno::Reference< rdf::XURI > xBaseURI(
+                ::sfx2::createBaseURI( xContext, xStorage, aBaseURL, aName ) );
+            uno::Reference<task::XInteractionHandler> xHandler =
+                mrDocShell.GetMedium()->GetInteractionHandler();
+            xDMA->loadMetadataFromStorage( xStorage, xBaseURI, xHandler );
+        }
+        catch ( const lang::WrappedTargetException & e)
+        {
+            ucb::InteractiveAugmentedIOException iaioe;
+            if ( e.TargetException >>= iaioe )
             {
-                const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
-                    xModel, uno::UNO_QUERY_THROW );
-                const uno::Reference< rdf::XURI > xBaseURI(
-                    ::sfx2::createBaseURI( xContext, xStorage, aBaseURL, aName ) );
-                const uno::Reference< task::XInteractionHandler > xHandler(
-                    pObjSh->GetMedium()->GetInteractionHandler() );
-                xDMA->loadMetadataFromStorage( xStorage, xBaseURI, xHandler );
+                nError = SCERR_IMPORT_UNKNOWN;
             }
-            catch ( const lang::WrappedTargetException & e)
-            {
-                ucb::InteractiveAugmentedIOException iaioe;
-                if ( e.TargetException >>= iaioe )
-                {
-                    nError = SCERR_IMPORT_UNKNOWN;
-                }
-                else
-                {
-                    nError = SCWARN_IMPORT_FEATURES_LOST;
-                }
-            }
-            catch ( const uno::Exception &)
+            else
             {
                 nError = SCWARN_IMPORT_FEATURES_LOST;
             }
         }
+        catch ( const uno::Exception &)
+        {
+            nError = SCWARN_IMPORT_FEATURES_LOST;
+        }
+    }
 
-        // #i103539#: always read meta.xml for generator
-        sal_uInt32 nMetaRetval(0);
-        uno::Sequence<uno::Any> aMetaArgs(1);
-        uno::Any* pMetaArgs = aMetaArgs.getArray();
-        pMetaArgs[0] <<= xInfoSet;
-
-        SAL_INFO( "sc.filter", "meta import start" );
-
-        nMetaRetval = ImportFromComponent(
-                                xContext, xModel, xXMLParser, aParserInput,
-                                bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaImporter")
-                                : OUString("com.sun.star.comp.Calc.XMLMetaImporter"),
-                                "meta.xml", "Meta.xml", aMetaArgs, false);
-
-        SAL_INFO( "sc.filter", "meta import end" );
+    // #i103539#: always read meta.xml for generator
+    sal_uInt32 nMetaRetval(0);
+    uno::Sequence<uno::Any> aMetaArgs(1);
+    uno::Any* pMetaArgs = aMetaArgs.getArray();
+    pMetaArgs[0] <<= xInfoSet;
 
-        SvXMLGraphicHelper* pGraphicHelper = NULL;
-        uno::Reference< document::XGraphicObjectResolver > xGrfContainer;
+    SAL_INFO( "sc.filter", "meta import start" );
 
-        uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
-        SvXMLEmbeddedObjectHelper *pObjectHelper = NULL;
+    nMetaRetval = ImportFromComponent(
+                            xContext, xModel, xXMLParser, aParserInput,
+                            bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaImporter")
+                            : OUString("com.sun.star.comp.Calc.XMLMetaImporter"),
+                            "meta.xml", "Meta.xml", aMetaArgs, false);
 
-        if( xStorage.is() )
-        {
-            pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_READ );
-            xGrfContainer = pGraphicHelper;
+    SAL_INFO( "sc.filter", "meta import end" );
 
-            if( pObjSh )
-            {
-                pObjectHelper = SvXMLEmbeddedObjectHelper::Create(xStorage, *pObjSh, EMBEDDEDOBJECTHELPER_MODE_READ, false );
-                xObjectResolver = pObjectHelper;
-            }
-        }
-        uno::Sequence<uno::Any> aStylesArgs(4);
-        uno::Any* pStylesArgs = aStylesArgs.getArray();
-        pStylesArgs[0] <<= xInfoSet;
-        pStylesArgs[1] <<= xGrfContainer;
-        pStylesArgs[2] <<= xStatusIndicator;
-        pStylesArgs[3] <<= xObjectResolver;
-
-        sal_uInt32 nSettingsRetval(0);
-        if (!bStylesOnly)
-        {
-            //  Settings must be loaded first because of the printer setting,
-            //  which is needed in the page styles (paper tray).
+    SvXMLGraphicHelper* pGraphicHelper = NULL;
+    uno::Reference< document::XGraphicObjectResolver > xGrfContainer;
 
-            uno::Sequence<uno::Any> aSettingsArgs(1);
-            uno::Any* pSettingsArgs = aSettingsArgs.getArray();
-            pSettingsArgs[0] <<= xInfoSet;
+    uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
+    SvXMLEmbeddedObjectHelper *pObjectHelper = NULL;
 
-            SAL_INFO( "sc.filter", "settings import start" );
+    if( xStorage.is() )
+    {
+        pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_READ );
+        xGrfContainer = pGraphicHelper;
 
-            nSettingsRetval = ImportFromComponent(
-                                xContext, xModel, xXMLParser, aParserInput,
-                                bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisSettingsImporter")
-                                       : OUString("com.sun.star.comp.Calc.XMLSettingsImporter"),
-                                "settings.xml", sEmpty, aSettingsArgs, false);
+        pObjectHelper = SvXMLEmbeddedObjectHelper::Create(xStorage, mrDocShell, EMBEDDEDOBJECTHELPER_MODE_READ, false);
+        xObjectResolver = pObjectHelper;
+    }
+    uno::Sequence<uno::Any> aStylesArgs(4);
+    uno::Any* pStylesArgs = aStylesArgs.getArray();
+    pStylesArgs[0] <<= xInfoSet;
+    pStylesArgs[1] <<= xGrfContainer;
+    pStylesArgs[2] <<= xStatusIndicator;
+    pStylesArgs[3] <<= xObjectResolver;
+
+    sal_uInt32 nSettingsRetval(0);
+    if (!bStylesOnly)
+    {
+        //  Settings must be loaded first because of the printer setting,
+        //  which is needed in the page styles (paper tray).
 
-            SAL_INFO( "sc.filter", "settings import end" );
-        }
+        uno::Sequence<uno::Any> aSettingsArgs(1);
+        uno::Any* pSettingsArgs = aSettingsArgs.getArray();
+        pSettingsArgs[0] <<= xInfoSet;
 
-        sal_uInt32 nStylesRetval(0);
-        {
-            SAL_INFO( "sc.filter", "styles import start" );
+        SAL_INFO( "sc.filter", "settings import start" );
 
-            nStylesRetval = ImportFromComponent(xContext, xModel, xXMLParser, aParserInput,
-                bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisStylesImporter")
-                       : OUString("com.sun.star.comp.Calc.XMLStylesImporter"),
-                OUString("styles.xml"),
-                sEmpty, aStylesArgs, true);
+        nSettingsRetval = ImportFromComponent(
+                            xContext, xModel, xXMLParser, aParserInput,
+                            bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisSettingsImporter")
+                                   : OUString("com.sun.star.comp.Calc.XMLSettingsImporter"),
+                            "settings.xml", sEmpty, aSettingsArgs, false);
 
-            SAL_INFO( "sc.filter", "styles import end" );
-        }
+        SAL_INFO( "sc.filter", "settings import end" );
+    }
 
-        sal_uInt32 nDocRetval(0);
-        if (!bStylesOnly)
-        {
-            uno::Sequence<uno::Any> aDocArgs(4);
-            uno::Any* pDocArgs = aDocArgs.getArray();
-            pDocArgs[0] <<= xInfoSet;
-            pDocArgs[1] <<= xGrfContainer;
-            pDocArgs[2] <<= xStatusIndicator;
-            pDocArgs[3] <<= xObjectResolver;
+    sal_uInt32 nStylesRetval(0);
+    {
+        SAL_INFO( "sc.filter", "styles import start" );
 
-            SAL_INFO( "sc.filter", "content import start" );
+        nStylesRetval = ImportFromComponent(xContext, xModel, xXMLParser, aParserInput,
+            bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisStylesImporter")
+                   : OUString("com.sun.star.comp.Calc.XMLStylesImporter"),
+            OUString("styles.xml"),
+            sEmpty, aStylesArgs, true);
 
-            nDocRetval = ImportFromComponent(xContext, xModel, xXMLParser, aParserInput,
-                bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisContentImporter")
-                       : OUString("com.sun.star.comp.Calc.XMLContentImporter"),
-                OUString("content.xml"),
-                OUString("Content.xml"), aDocArgs,
-                true);
+        SAL_INFO( "sc.filter", "styles import end" );
+    }
 
-            SAL_INFO( "sc.filter", "content import end" );
-        }
-        if( pGraphicHelper )
-            SvXMLGraphicHelper::Destroy( pGraphicHelper );
+    sal_uInt32 nDocRetval(0);
+    if (!bStylesOnly)
+    {
+        uno::Sequence<uno::Any> aDocArgs(4);
+        uno::Any* pDocArgs = aDocArgs.getArray();
+        pDocArgs[0] <<= xInfoSet;
+        pDocArgs[1] <<= xGrfContainer;
+        pDocArgs[2] <<= xStatusIndicator;
+        pDocArgs[3] <<= xObjectResolver;
+
+        SAL_INFO( "sc.filter", "content import start" );
+
+        nDocRetval = ImportFromComponent(xContext, xModel, xXMLParser, aParserInput,
+            bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisContentImporter")
+                   : OUString("com.sun.star.comp.Calc.XMLContentImporter"),
+            OUString("content.xml"),
+            OUString("Content.xml"), aDocArgs,
+            true);
+
+        SAL_INFO( "sc.filter", "content import end" );
+    }
+    if( pGraphicHelper )
+        SvXMLGraphicHelper::Destroy( pGraphicHelper );
 
-        if( pObjectHelper )
-            SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+    if( pObjectHelper )
+        SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
 
-        if (xStatusIndicator.is())
-            xStatusIndicator->end();
+    if (xStatusIndicator.is())
+        xStatusIndicator->end();
 
-        bool bRet(false);
-        if (bStylesOnly)
+    bool bRet(false);
+    if (bStylesOnly)
+    {
+        if (nStylesRetval)
+            nError = nStylesRetval;
+        else
+            bRet = true;
+    }
+    else
+    {
+        if (nDocRetval)
         {
-            if (nStylesRetval)
-                nError = nStylesRetval;
-            else
+            nError = nDocRetval;
+            if (nDocRetval == SCWARN_IMPORT_RANGE_OVERFLOW ||
+                nDocRetval == SCWARN_IMPORT_ROW_OVERFLOW ||
+                nDocRetval == SCWARN_IMPORT_COLUMN_OVERFLOW ||
+                nDocRetval == SCWARN_IMPORT_SHEET_OVERFLOW)
                 bRet = true;
         }
+        else if (nStylesRetval)
+            nError = nStylesRetval;
+        else if (nMetaRetval)
+            nError = nMetaRetval;
+        else if (nSettingsRetval)
+            nError = nSettingsRetval;
         else
+            bRet = true;
+    }
+
+    // set BuildId on XModel for later OLE object loading
+    if( xInfoSet.is() )
+    {
+        uno::Reference< beans::XPropertySet > xModelSet( xModel, uno::UNO_QUERY );
+        if( xModelSet.is() )
         {
-            if (nDocRetval)
+            uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
+            OUString sBuildPropName("BuildId" );
+            if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sBuildPropName) )
             {
-                nError = nDocRetval;
-                if (nDocRetval == SCWARN_IMPORT_RANGE_OVERFLOW ||
-                    nDocRetval == SCWARN_IMPORT_ROW_OVERFLOW ||
-                    nDocRetval == SCWARN_IMPORT_COLUMN_OVERFLOW ||
-                    nDocRetval == SCWARN_IMPORT_SHEET_OVERFLOW)
-                    bRet = true;
+                xModelSet->setPropertyValue( sBuildPropName, xInfoSet->getPropertyValue(sBuildPropName) );
             }
-            else if (nStylesRetval)
-                nError = nStylesRetval;
-            else if (nMetaRetval)
-                nError = nMetaRetval;
-            else if (nSettingsRetval)
-                nError = nSettingsRetval;
-            else
-                bRet = true;
         }
 
-        // set BuildId on XModel for later OLE object loading
-        if( xInfoSet.is() )
+        // Set Code Names
+        uno::Any aAny = xInfoSet->getPropertyValue("ScriptConfiguration");
+        uno::Reference <container::XNameAccess> xCodeNameAccess;
+        if( aAny >>= xCodeNameAccess )
+            XMLCodeNameProvider::set( xCodeNameAccess, &rDoc );
+
+        // VBA compatibility
+        bool bVBACompat = false;
+        if ( (xInfoSet->getPropertyValue("VBACompatibilityMode") >>= bVBACompat) && bVBACompat )
         {
-            uno::Reference< beans::XPropertySet > xModelSet( xModel, uno::UNO_QUERY );
-            if( xModelSet.is() )
+            /*  Set library container to VBA compatibility mode, this
+                forces loading the Basic project, which in turn creates the
+                VBA Globals object and does all related initialization. */
+            if ( xModelSet.is() ) try
             {
-                uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
-                OUString sBuildPropName("BuildId" );
-                if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sBuildPropName) )
-                {
-                    xModelSet->setPropertyValue( sBuildPropName, xInfoSet->getPropertyValue(sBuildPropName) );
-                }
+                uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModelSet->getPropertyValue(
+                    OUString( "BasicLibraries" ) ), uno::UNO_QUERY_THROW );
+                xVBACompat->setVBACompatibilityMode( sal_True );
             }
-
-            // Set Code Names
-            uno::Any aAny = xInfoSet->getPropertyValue("ScriptConfiguration");
-            uno::Reference <container::XNameAccess> xCodeNameAccess;
-            if( aAny >>= xCodeNameAccess )
-                XMLCodeNameProvider::set( xCodeNameAccess, &rDoc );
-
-            // VBA compatibility
-            bool bVBACompat = false;
-            if ( (xInfoSet->getPropertyValue("VBACompatibilityMode") >>= bVBACompat) && bVBACompat )
+            catch( const uno::Exception& )
             {
-                /*  Set library container to VBA compatibility mode, this
-                    forces loading the Basic project, which in turn creates the
-                    VBA Globals object and does all related initialization. */
-                if ( xModelSet.is() ) try
-                {
-                    uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModelSet->getPropertyValue(
-                        OUString( "BasicLibraries" ) ), uno::UNO_QUERY_THROW );
-                    xVBACompat->setVBACompatibilityMode( sal_True );
-                }
-                catch( const uno::Exception& )
-                {
-                }
             }
         }
-
-        // Don't test bStylesRetval and bMetaRetval, because it could be an older file which not contain such streams
-        return bRet;//!bStylesOnly ? bDocRetval : bStylesRetval;
     }
-    return false;
+
+    // Don't test bStylesRetval and bMetaRetval, because it could be an older file which not contain such streams
+    return bRet;//!bStylesOnly ? bDocRetval : bStylesRetval;
 }
 
 static bool lcl_HasValidStream(ScDocument& rDoc)
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 2cc729e..e85008d 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -439,12 +439,7 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::R
 
     BeforeXMLLoading();
 
-    // #i62677# BeforeXMLLoading is also called from ScXMLImport::startDocument when invoked
-    // from an external component. The XMLFromWrapper flag is only set here, when called
-    // through ScDocShell.
-    aDocument.SetXMLFromWrapper( true );
-
-    ScXMLImportWrapper aImport( aDocument, pLoadMedium, xStor );
+    ScXMLImportWrapper aImport(*this, pLoadMedium, xStor);
 
     bool bRet(false);
     ErrCode nError = ERRCODE_NONE;
@@ -508,7 +503,6 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::R
         aDocument.Broadcast(ScHint(SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS));
     }
 
-    aDocument.SetXMLFromWrapper( false );
     AfterXMLLoading(bRet);
 
     aDocument.EnableAdjustHeight(true);
@@ -519,7 +513,7 @@ bool ScDocShell::SaveXML( SfxMedium* pSaveMedium, const ::com::sun::star::uno::R
 {
     aDocument.EnableIdle(false);
 
-    ScXMLImportWrapper aImport( aDocument, pSaveMedium, xStor );
+    ScXMLImportWrapper aImport(*this, pSaveMedium, xStor);
     bool bRet(false);
     if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
         bRet = aImport.Export(false);
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 9f6b657..a2a569e 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1921,7 +1921,6 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens(
 
         // Put the data into cache.
         putRangeDataIntoCache(maRefCache, pArray, nFileId, rTabName, aCacheData, rRange, aDataRange);
-        fprintf(stdout, "ScExternalRefManager::getDoubleRefTokens:   in memory!\n");
         return pArray;
     }
 
@@ -1929,11 +1928,8 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens(
     ScExternalRefCache::TokenArrayRef pArray =
         maRefCache.getCellRangeData(nFileId, rTabName, rRange);
     if (pArray)
-    {
         // Cache hit !
-        fprintf(stdout, "ScExternalRefManager::getDoubleRefTokens:   cached!\n");
         return pArray;
-    }
 
     pSrcDoc = getSrcDocument(nFileId);
     if (!pSrcDoc)


More information about the Libreoffice-commits mailing list