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

Kohei Yoshida kohei.yoshida at collabora.com
Tue May 20 21:04:43 PDT 2014


 include/sfx2/sfxmodelfactory.hxx         |   12 +++++-------
 sc/inc/unonames.hxx                      |    3 ++-
 sc/source/filter/xml/xmlimprt.cxx        |   16 ++++++++++++++++
 sc/source/filter/xml/xmlimprt.hxx        |    1 +
 sc/source/filter/xml/xmlwrap.cxx         |    5 +++++
 sc/source/ui/docshell/externalrefmgr.cxx |    2 +-
 sfx2/source/doc/objxtor.cxx              |    6 +++++-
 7 files changed, 35 insertions(+), 10 deletions(-)

New commits:
commit 1bd673611ecd795a1caaac676c6c5cef0eba023b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed May 21 00:00:57 2014 -0400

    cp#1000072: Skip styles import for external link cache documents.
    
    This reduces external link update time by 10%.
    
    Change-Id: Ic14d9ea7530818f839330a2004f6aa67ef1e831e

diff --git a/include/sfx2/sfxmodelfactory.hxx b/include/sfx2/sfxmodelfactory.hxx
index 7f7b05f..2067fbf 100644
--- a/include/sfx2/sfxmodelfactory.hxx
+++ b/include/sfx2/sfxmodelfactory.hxx
@@ -25,16 +25,14 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
 
+#define SFXMODEL_STANDARD                   (sal_uInt64)(0x0000)
+#define SFXMODEL_EMBEDDED_OBJECT            (sal_uInt64)(0x0001)
+#define SFXMODEL_EXTERNAL_LINK              (sal_uInt64)(0x0002)
+#define SFXMODEL_DISABLE_EMBEDDED_SCRIPTS   (sal_uInt64)(0x0004)
+#define SFXMODEL_DISABLE_DOCUMENT_RECOVERY  (sal_uInt64)(0x0008)
 
 namespace sfx2
 {
-
-
-    #define SFXMODEL_STANDARD                   (sal_uInt64)(0x0000)
-    #define SFXMODEL_EMBEDDED_OBJECT            (sal_uInt64)(0x0001)
-    #define SFXMODEL_DISABLE_EMBEDDED_SCRIPTS   (sal_uInt64)(0x0002)
-    #define SFXMODEL_DISABLE_DOCUMENT_RECOVERY  (sal_uInt64)(0x0004)
-
     typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ( SAL_CALL * SfxModelFactoryFunc ) (
         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,
         const sal_uInt64 _nCreationFlags
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 689dcea..ca7a28c 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -668,7 +668,8 @@
 
 #define SC_UNO_EMBED_FONTS     "EmbedFonts"
 
-#define SC_UNO_ODS_LOCK_SOLAR_MUTEX "LockSolarMutex"
+#define SC_UNO_ODS_LOCK_SOLAR_MUTEX "ODSLockSolarMutex"
+#define SC_UNO_ODS_IMPORT_STYLES    "ODSImportStyles"
 
 #endif
 
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 813190d..9128026 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -2104,6 +2104,7 @@ ScXMLImport::ScXMLImport(
     bNullDateSetted(false),
     bSelfImportingXMLSet(false),
     mbLockSolarMutex(true),
+    mbImportStyles(true),
     mbHasNewCondFormatData(false)
 {
     pStylesImportHelper = new ScMyStylesImportHelper(*this);
@@ -2256,6 +2257,9 @@ void ScXMLImport::initialize( const css::uno::Sequence<css::uno::Any>& aArgument
 
     if (xInfoSetInfo->hasPropertyByName(SC_UNO_ODS_LOCK_SOLAR_MUTEX))
         xInfoSet->getPropertyValue(SC_UNO_ODS_LOCK_SOLAR_MUTEX) >>= mbLockSolarMutex;
+
+    if (xInfoSetInfo->hasPropertyByName(SC_UNO_ODS_IMPORT_STYLES))
+        xInfoSet->getPropertyValue(SC_UNO_ODS_IMPORT_STYLES) >>= mbImportStyles;
 }
 
 SvXMLImportContext *ScXMLImport::CreateFontDeclsContext(const sal_uInt16 nPrefix, const OUString& rLocalName,
@@ -2765,6 +2769,9 @@ void ScXMLImport::SetType(uno::Reference <beans::XPropertySet>& rProperties,
                           const sal_Int16 nCellType,
                           const OUString& rCurrency)
 {
+    if (!mbImportStyles)
+        return;
+
     if ((nCellType != util::NumberFormat::TEXT) && (nCellType != util::NumberFormat::UNDEFINED))
     {
         if (rNumberFormat == -1)
@@ -2832,6 +2839,9 @@ void ScXMLImport::SetType(uno::Reference <beans::XPropertySet>& rProperties,
 
 void ScXMLImport::AddStyleRange(const table::CellRangeAddress& rCellRange)
 {
+    if (!mbImportStyles)
+        return;
+
     if (!xSheetCellRanges.is() && GetModel().is())
     {
         uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
@@ -2845,6 +2855,9 @@ void ScXMLImport::AddStyleRange(const table::CellRangeAddress& rCellRange)
 
 void ScXMLImport::SetStyleToRanges()
 {
+    if (!mbImportStyles)
+        return;
+
     if (!sPrevStyleName.isEmpty())
     {
         uno::Reference <beans::XPropertySet> xProperties (xSheetCellRanges, uno::UNO_QUERY);
@@ -2901,6 +2914,9 @@ void ScXMLImport::SetStyleToRanges()
 void ScXMLImport::SetStyleToRange(const ScRange& rRange, const OUString* pStyleName,
                                   const sal_Int16 nCellType, const OUString* pCurrency)
 {
+    if (!mbImportStyles)
+        return;
+
     if (sPrevStyleName.isEmpty())
     {
         nPrevCellType = nCellType;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 660f3bd..1f44982 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -965,6 +965,7 @@ class ScXMLImport: public SvXMLImport, boost::noncopyable
     bool                    bNullDateSetted;
     bool                    bSelfImportingXMLSet;
     bool mbLockSolarMutex;
+    bool mbImportStyles;
     bool mbHasNewCondFormatData;
 
 
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index 159c3d8..640890b 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -345,6 +345,7 @@ bool ScXMLImportWrapper::Import( sal_uInt8 nMode, ErrCode& rError )
             ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
         { OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
         { OUString(SC_UNO_ODS_LOCK_SOLAR_MUTEX), 0, getBooleanCppuType(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+        { OUString(SC_UNO_ODS_IMPORT_STYLES), 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 ) ) );
@@ -520,6 +521,10 @@ bool ScXMLImportWrapper::Import( sal_uInt8 nMode, ErrCode& rError )
     sal_uInt32 nDocRetval(0);
     if ((nMode & CONTENT) == CONTENT)
     {
+        if (mrDocShell.GetCreateMode() == SFX_CREATE_MODE_INTERNAL)
+            // We only need to import content for external link cache document.
+            xInfoSet->setPropertyValue(SC_UNO_ODS_IMPORT_STYLES, uno::makeAny(false));
+
         uno::Sequence<uno::Any> aDocArgs(4);
         uno::Any* pDocArgs = aDocArgs.getArray();
         pDocArgs[0] <<= xInfoSet;
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index a2a569e..38f900b 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2372,7 +2372,7 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
     // To load encrypted documents with password, user interaction needs to be enabled.
     pMedium->UseInteractionHandler(mbUserInteractionEnabled);
 
-    ScDocShell* pNewShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
+    ScDocShell* pNewShell = new ScDocShell(SFXMODEL_EXTERNAL_LINK);
     SfxObjectShellRef aRef = pNewShell;
 
     // increment the recursive link count of the source document.
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index c97cb4a..29fe983 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -285,10 +285,14 @@ SfxObjectShell::SfxObjectShell( const sal_uInt64 i_nCreationFlags )
     :   pImp( new SfxObjectShell_Impl( *this ) )
     ,   pMedium(0)
     ,   pStyleSheetPool(0)
-    ,   eCreateMode( ( i_nCreationFlags & SFXMODEL_EMBEDDED_OBJECT ) ? SFX_CREATE_MODE_EMBEDDED : SFX_CREATE_MODE_STANDARD )
+    ,   eCreateMode(SFX_CREATE_MODE_STANDARD)
     ,   bHasName( false )
     ,   bIsInGenerateThumbnail ( false )
 {
+    if (i_nCreationFlags & SFXMODEL_EMBEDDED_OBJECT)
+        eCreateMode = SFX_CREATE_MODE_EMBEDDED;
+    else if (i_nCreationFlags & SFXMODEL_EXTERNAL_LINK)
+        eCreateMode = SFX_CREATE_MODE_INTERNAL;
 
     const bool bScriptSupport = ( i_nCreationFlags & SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ) == 0;
     if ( !bScriptSupport )


More information about the Libreoffice-commits mailing list