[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Apr 15 11:50:56 PDT 2014


 sc/inc/scopetools.hxx              |    9 ++++++++
 sc/source/core/tool/scopetools.cxx |   11 +++++++++
 sc/source/ui/view/output2.cxx      |   41 +++++++++++++++++++------------------
 3 files changed, 42 insertions(+), 19 deletions(-)

New commits:
commit 6fa4d31d6a7e363285f22d4c0012521d10073652
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Apr 15 14:47:53 2014 -0400

    Use scope switch rather than manual on and off.
    
    Change-Id: Ia4072339b6f1fd4b929d891dcc8f3bb3e2403d5e

diff --git a/sc/inc/scopetools.hxx b/sc/inc/scopetools.hxx
index 5a16c2c..f1a1174 100644
--- a/sc/inc/scopetools.hxx
+++ b/sc/inc/scopetools.hxx
@@ -46,6 +46,15 @@ public:
     ~UndoSwitch();
 };
 
+class SC_DLLPUBLIC IdleSwitch
+{
+    ScDocument& mrDoc;
+    bool mbOldValue;
+public:
+    IdleSwitch(ScDocument& rDoc, bool bEnableIdle);
+    ~IdleSwitch();
+};
+
 }
 
 #endif
diff --git a/sc/source/core/tool/scopetools.cxx b/sc/source/core/tool/scopetools.cxx
index a1a52a1..96f4458 100644
--- a/sc/source/core/tool/scopetools.cxx
+++ b/sc/source/core/tool/scopetools.cxx
@@ -45,6 +45,17 @@ UndoSwitch::~UndoSwitch()
     mrDoc.EnableUndo(mbOldValue);
 }
 
+IdleSwitch::IdleSwitch(ScDocument& rDoc, bool bEnableIdle) :
+    mrDoc(rDoc), mbOldValue(rDoc.IsIdleEnabled())
+{
+    mrDoc.EnableIdle(bEnableIdle);
+}
+
+IdleSwitch::~IdleSwitch()
+{
+    mrDoc.EnableIdle(mbOldValue);
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 1a625e5..321cf04 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -61,6 +61,7 @@
 #include "markdata.hxx"
 #include "stlsheet.hxx"
 #include "spellcheckcontext.hxx"
+#include <scopetools.hxx>
 
 #include <com/sun/star/i18n/DirectionProperty.hpp>
 #include <comphelper/string.hxx>
@@ -1443,9 +1444,7 @@ void ScOutputData::DrawStrings( bool bPixelToLogic )
 
     vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, mpDev->GetExtOutDevData() );
 
-    bool bWasIdleEnabled = mpDoc->IsIdleEnabled();
-    mpDoc->EnableIdle(false);
-
+    sc::IdleSwitch aIdleSwitch(*mpDoc, false);
     ScDrawStringsVars aVars( this, bPixelToLogic );
 
     bool bProgress = false;
@@ -2071,7 +2070,6 @@ void ScOutputData::DrawStrings( bool bPixelToLogic )
     }
     if ( bProgress )
         ScProgress::DeleteInterpretProgress();
-    mpDoc->EnableIdle(bWasIdleEnabled);
 }
 
 ScFieldEditEngine* ScOutputData::CreateOutputEditEngine()
commit 8e50a6c7b1cb9481cce42c71ff07e921fb4292d0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Apr 15 14:37:47 2014 -0400

    Use single std::vector instance in lieu of heap arrays.
    
    Change-Id: I36820b5c3790998eab922a0fa603ac063972c445

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 4b99bcb..1a625e5 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1477,6 +1477,7 @@ void ScOutputData::DrawStrings( bool bPixelToLogic )
     // before processing the cell value.
     ::boost::ptr_vector<ScPatternAttr> aAltPatterns;
 
+    std::vector<sal_Int32> aDX;
     long nPosY = nScrY;
     for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
     {
@@ -2022,25 +2023,29 @@ void ScOutputData::DrawStrings( bool bPixelToLogic )
                         //  aufgezeichnet werden (fuer nicht-proportionales Resize):
 
                         OUString aString = aVars.GetString();
-                        if (bMetaFile || pFmtDevice != mpDev || aZoomX != aZoomY)
+                        if (!aString.isEmpty())
                         {
-                            sal_Int32* pDX = new sal_Int32[aString.getLength()];
-                            pFmtDevice->GetTextArray( aString, pDX );
-
-                            if ( !mpRefDevice->GetConnectMetaFile() ||
-                                    mpRefDevice->GetOutDevType() == OUTDEV_PRINTER )
+                            if (bMetaFile || pFmtDevice != mpDev || aZoomX != aZoomY)
                             {
-                                double fMul = GetStretch();
-                                sal_Int32 nLen = aString.getLength();
-                                for( sal_Int32 i = 0; i<nLen; i++ )
-                                    pDX[i] = (long)(pDX[i] / fMul + 0.5);
-                            }
+                                size_t nLen = aString.getLength();
+                                if (aDX.size() < nLen)
+                                    aDX.resize(nLen, 0);
+
+                                pFmtDevice->GetTextArray(aString, &aDX[0]);
 
-                            mpDev->DrawTextArray( aDrawTextPos, aString, pDX );
-                            delete[] pDX;
+                                if ( !mpRefDevice->GetConnectMetaFile() ||
+                                        mpRefDevice->GetOutDevType() == OUTDEV_PRINTER )
+                                {
+                                    double fMul = GetStretch();
+                                    for (size_t i = 0; i < nLen; ++i)
+                                        aDX[i] = static_cast<sal_Int32>(aDX[i] / fMul + 0.5);
+                                }
+
+                                mpDev->DrawTextArray(aDrawTextPos, aString, &aDX[0]);
+                            }
+                            else
+                                mpDev->DrawText( aDrawTextPos, aString );
                         }
-                        else
-                            mpDev->DrawText( aDrawTextPos, aString );
 
                         if ( bHClip || bVClip )
                         {


More information about the Libreoffice-commits mailing list