[Libreoffice-commits] core.git: offapi/com sc/inc sc/qa sc/source

Tamas Bunth tamas.bunth at collabora.co.uk
Mon Aug 7 16:46:19 UTC 2017


 offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl |    4 ++
 sc/inc/document.hxx                                       |    7 ++--
 sc/qa/unit/subsequent_filters-test.cxx                    |    1 
 sc/qa/unit/ucalc.cxx                                      |    2 -
 sc/source/core/data/documen2.cxx                          |    2 -
 sc/source/core/data/document.cxx                          |    7 ++++
 sc/source/core/data/table1.cxx                            |    4 +-
 sc/source/filter/excel/read.cxx                           |    2 -
 sc/source/filter/oox/workbookhelper.cxx                   |    4 +-
 sc/source/ui/docshell/docfunc.cxx                         |    2 -
 sc/source/ui/docshell/docsh.cxx                           |    4 +-
 sc/source/ui/docshell/externalrefmgr.cxx                  |    2 -
 sc/source/ui/unoobj/docuno.cxx                            |   10 +++----
 sc/source/ui/vba/vbaapplication.cxx                       |   20 ++++++++++++++
 sc/source/ui/vba/vbaapplication.hxx                       |    1 
 15 files changed, 52 insertions(+), 20 deletions(-)

New commits:
commit 4aca927040f67c2b68f412234e37ec740346a005
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Wed Jul 26 13:03:03 2017 +0200

    oovbaapi: screenUpdating, do not adjust height
    
    Do not adjust row height if screenUpdating false, because it consumes
    significant time.
    
    Also change IsAdjustHeightEnabled boolean to a counter so it can be used
    several times in an overlapping manner too.
    
    Change-Id: Ie5c894481f3c1b4e07175164aac8303e504779ce
    Reviewed-on: https://gerrit.libreoffice.org/40443
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl b/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
index 7487f6a5bb03..5f8d4fa89858 100644
--- a/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
+++ b/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
@@ -179,6 +179,10 @@ published service SpreadsheetDocumentSettings
     /** specifies whether the automatic adjustment of the row height is
         enabled.
 
+        </p>This boolean is actually a counter internally, of the number of times
+        something has locked the height, so setting it to false will only perform one
+        unlock operation, and might leave it still locked</p>
+
         @since OOo 3.0
      */
     [optional, property] boolean IsAdjustHeightEnabled;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 2cc5f02ed70e..6071fe642c45 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -471,12 +471,12 @@ private:
 
     bool                bInUnoBroadcast;
     bool                bInUnoListenerCall;
+    sal_uInt32          nAdjustHeightLock;
     formula::FormulaGrammar::Grammar  eGrammar;
 
     mutable bool        bStyleSheetUsageInvalid;
 
     bool                mbUndoEnabled:1;
-    bool                mbAdjustHeightEnabled:1;
     bool                mbExecuteLinkEnabled:1;
     bool                mbChangeReadOnlyEnabled:1;    // allow changes in read-only document (for API import filters)
     bool                mbStreamValidLocked:1;
@@ -1377,8 +1377,9 @@ public:
     bool               IsUndoEnabled() const                       { return mbUndoEnabled; }
     SC_DLLPUBLIC void  EnableUndo( bool bVal );
 
-    bool                         IsAdjustHeightEnabled() const               { return mbAdjustHeightEnabled; }
-    void                         EnableAdjustHeight( bool bVal )             { mbAdjustHeightEnabled = bVal; }
+    bool                         IsAdjustHeightLocked() const               { return nAdjustHeightLock != 0; }
+    void                         LockAdjustHeight()                          { ++nAdjustHeightLock; }
+    SC_DLLPUBLIC void            UnlockAdjustHeight();
     bool                         IsExecuteLinkEnabled() const                { return mbExecuteLinkEnabled; }
     void                         EnableExecuteLink( bool bVal )              { mbExecuteLinkEnabled = bVal; }
     bool                         IsChangeReadOnlyEnabled() const             { return mbChangeReadOnlyEnabled; }
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index f8f6548984b5..1e136675b2e5 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -3135,7 +3135,6 @@ void ScFiltersTest::testOptimalHeightReset()
     SCTAB nTab = 0;
     SCROW nRow = 0;
     ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.EnableAdjustHeight( true );
     // open document in read/write mode ( otherwise optimal height stuff won't
     // be triggered ) *and* you can't delete cell contents.
     int nHeight = sc::TwipsToHMM ( rDoc.GetRowHeight(nRow, nTab, false) );
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 89e90d00f8cc..41b6c32038d4 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6539,7 +6539,7 @@ void Test::testEmptyCalcDocDefaults()
     CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsInsertingFromOtherDoc() );
     CPPUNIT_ASSERT_EQUAL( false, m_pDoc->PastingDrawFromOtherDoc() );
 
-    CPPUNIT_ASSERT_EQUAL( true, m_pDoc->IsAdjustHeightEnabled() );
+    CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsAdjustHeightLocked() );
     CPPUNIT_ASSERT_EQUAL( true, m_pDoc->IsExecuteLinkEnabled() );
     CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsChangeReadOnlyEnabled() );
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 973231dc389d..3e2de5cb6d23 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -209,10 +209,10 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
         nInDdeLinkUpdate( 0 ),
         bInUnoBroadcast( false ),
         bInUnoListenerCall( false ),
+        nAdjustHeightLock(0),
         eGrammar( formula::FormulaGrammar::GRAM_NATIVE ),
         bStyleSheetUsageInvalid( true ),
         mbUndoEnabled( true ),
-        mbAdjustHeightEnabled( true ),
         mbExecuteLinkEnabled( true ),
         mbChangeReadOnlyEnabled( false ),
         mbStreamValidLocked( false ),
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 16e8b49b2a4c..3dd1bd5ffc8e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1801,6 +1801,13 @@ formula::VectorRefArray ScDocument::FetchVectorRefArray( const ScAddress& rPos,
     return maTabs[nTab]->FetchVectorRefArray(rPos.Col(), rPos.Row(), rPos.Row()+nLength-1);
 }
 
+void ScDocument::UnlockAdjustHeight()
+{
+    assert(nAdjustHeightLock > 0);
+    if(nAdjustHeightLock > 0)
+        --nAdjustHeightLock;
+}
+
 bool ScDocument::CanFitBlock( const ScRange& rOld, const ScRange& rNew )
 {
     if ( rOld == rNew )
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 1652c97c12b4..c52cb945452f 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -483,7 +483,7 @@ bool ScTable::SetOptimalHeight(
     OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(),
         "automatic OptimalHeight with Extra" );
 
-    if ( !pDocument->IsAdjustHeightEnabled() )
+    if ( pDocument->IsAdjustHeightLocked() )
     {
         return false;
     }
@@ -511,7 +511,7 @@ void ScTable::SetOptimalHeightOnly(
     OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(),
         "automatic OptimalHeight with Extra" );
 
-    if ( !pDocument->IsAdjustHeightEnabled() )
+    if ( pDocument->IsAdjustHeightLocked() )
         return;
 
     SCSIZE  nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index 191700134537..18b89773b9e7 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -1290,7 +1290,7 @@ ErrCode ImportExcel8::Read()
         // Excel documents look much better without this call; better in the
         // sense that the row heights are identical to the original heights in
         // Excel.
-        if (pD->IsAdjustHeightEnabled())
+        if ( !pD->IsAdjustHeightLocked())
             AdjustRowHeight();
 #endif
         PostDocLoad();
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index f8ac80db887b..22b8e471f68a 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -593,7 +593,7 @@ void WorkbookGlobals::initialize()
         // #i76026# disable Undo while loading the document
         mpDoc->EnableUndo(false);
         // #i79826# disable calculating automatic row height while loading the document
-        mpDoc->EnableAdjustHeight(false);
+        mpDoc->LockAdjustHeight();
         // disable automatic update of linked sheets and DDE links
         mpDoc->EnableExecuteLink(false);
 
@@ -620,7 +620,7 @@ void WorkbookGlobals::finalize()
         // enable automatic update of linked sheets and DDE links
         mpDoc->EnableExecuteLink(true);
         // #i79826# enable updating automatic row height after loading the document
-        mpDoc->EnableAdjustHeight(true);
+        mpDoc->UnlockAdjustHeight();
 
         // #i76026# enable Undo after loading the document
         mpDoc->EnableUndo(true);
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 17d8d2dcd049..5c3d77d248f5 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -139,7 +139,7 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint )
         //  for XML import, all row heights are updated together after importing
         return false;
     }
-    if ( !rDoc.IsAdjustHeightEnabled() )
+    if ( rDoc.IsAdjustHeightLocked() )
     {
         return false;
     }
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 40b24695eff4..8d6352c7b112 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -442,7 +442,7 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css
 
     bool bRet = false;
     ErrCode nError = ERRCODE_NONE;
-    aDocument.EnableAdjustHeight(false);
+    aDocument.LockAdjustHeight();
     if (GetCreateMode() == SfxObjectCreateMode::ORGANIZER)
         bRet = aImport.Import(ImportFlags::Styles, nError);
     else
@@ -506,7 +506,7 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css
 
     AfterXMLLoading(bRet);
 
-    aDocument.EnableAdjustHeight(true);
+    aDocument.UnlockAdjustHeight();
     return bRet;
 }
 
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 2a5087d3dfe9..3baad956e02d 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2532,7 +2532,7 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
     ScDocument& rSrcDoc = pNewShell->GetDocument();
     rSrcDoc.EnableExecuteLink(false); // to prevent circular access of external references.
     rSrcDoc.EnableUndo(false);
-    rSrcDoc.EnableAdjustHeight(false);
+    rSrcDoc.LockAdjustHeight();
     rSrcDoc.EnableUserInteraction(false);
 
     ScExtDocOptions* pExtOptNew = rSrcDoc.GetExtDocOptions();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 8b70fa9f44e9..b331d7d66300 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2351,10 +2351,10 @@ void SAL_CALL ScModelObj::setPropertyValue(
         }
         else if ( aPropertyName == SC_UNO_ISADJUSTHEIGHTENABLED )
         {
-            bool bOldAdjustHeightEnabled = rDoc.IsAdjustHeightEnabled();
-            bool bAdjustHeightEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue );
-            if( bOldAdjustHeightEnabled != bAdjustHeightEnabled )
-                rDoc.EnableAdjustHeight( bAdjustHeightEnabled );
+            if( ScUnoHelpFunctions::GetBoolFromAny( aValue ) )
+                rDoc.UnlockAdjustHeight();
+            else
+                rDoc.LockAdjustHeight();
         }
         else if ( aPropertyName == SC_UNO_ISEXECUTELINKENABLED )
         {
@@ -2539,7 +2539,7 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName )
         }
         else if ( aPropertyName == SC_UNO_ISADJUSTHEIGHTENABLED )
         {
-            aRet <<= rDoc.IsAdjustHeightEnabled();
+            aRet <<= !( rDoc.IsAdjustHeightLocked() );
         }
         else if ( aPropertyName == SC_UNO_ISEXECUTELINKENABLED )
         {
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 1805a3f950b1..bab488c48b5d 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -1338,6 +1338,26 @@ void SAL_CALL ScVbaApplication::OnKey( const OUString& Key, const uno::Any& Proc
     }
 }
 
+void SAL_CALL ScVbaApplication::setScreenUpdating(sal_Bool bUpdate)
+{
+    VbaApplicationBase::setScreenUpdating( bUpdate );
+
+    uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );
+    ScDocShell* pDocShell = excel::getDocShell( xModel );
+    ScDocument& rDoc = pDocShell->GetDocument();
+
+    if( bUpdate )
+    {
+        rDoc.UnlockAdjustHeight();
+        if( !rDoc.IsAdjustHeightLocked() )
+            pDocShell->UpdateAllRowHeights();
+    }
+    else
+    {
+        rDoc.LockAdjustHeight();
+    }
+}
+
 void SAL_CALL ScVbaApplication::Undo()
 {
     uno::Reference< frame::XModel > xModel( getThisExcelDoc( mxContext ), uno::UNO_SET_THROW );
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 34d62b7b1f87..9a0d3137febb 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -103,6 +103,7 @@ public:
     virtual ::sal_Int32 SAL_CALL getCursor() override;
     virtual void SAL_CALL setCursor( ::sal_Int32 _cursor ) override;
     virtual void SAL_CALL OnKey( const OUString& Key, const css::uno::Any& Procedure ) override;
+    virtual void SAL_CALL setScreenUpdating( sal_Bool bUpdate ) override;
     virtual sal_Bool SAL_CALL getEnableEvents() override;
     virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) override;
     virtual sal_Bool SAL_CALL getEnableCancelKey() override;


More information about the Libreoffice-commits mailing list