[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 9 commits - sc/inc sc/Library_sc.mk sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Oct 1 08:14:46 PDT 2014


 sc/Library_sc.mk                             |    1 
 sc/inc/column.hxx                            |    1 
 sc/inc/document.hxx                          |    2 
 sc/inc/documentimport.hxx                    |   19 +++++
 sc/inc/numformat.hxx                         |   46 ++++++++++++++
 sc/inc/table.hxx                             |    4 -
 sc/source/core/data/column.cxx               |    5 -
 sc/source/core/data/column2.cxx              |    4 +
 sc/source/core/data/document.cxx             |    8 --
 sc/source/core/data/documentimport.cxx       |   82 +++++++++++++++++++++++--
 sc/source/core/data/table2.cxx               |   86 ++++++++++++++-------------
 sc/source/core/tool/numformat.cxx            |   82 +++++++++++++++++++++++++
 sc/source/filter/excel/xistyle.cxx           |   24 ++++---
 sc/source/filter/excel/xlroot.cxx            |   21 ++++++
 sc/source/filter/inc/numberformatsbuffer.hxx |    4 -
 sc/source/filter/inc/stylesbuffer.hxx        |   16 ++++-
 sc/source/filter/inc/xlroot.hxx              |   10 ++-
 sc/source/filter/oox/numberformatsbuffer.cxx |   16 +++--
 sc/source/filter/oox/sheetdatabuffer.cxx     |   28 +++++---
 sc/source/filter/oox/stylesbuffer.cxx        |   34 +++++++---
 sc/source/filter/xml/xmlimprt.cxx            |   29 ---------
 sc/source/ui/view/viewfun2.cxx               |    2 
 22 files changed, 391 insertions(+), 133 deletions(-)

New commits:
commit 2ef1124f78c063a8dccff19ecbbc9eb480584243
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Oct 1 11:12:49 2014 -0400

    Exit early in case the column has no cell notes to copy to destination.
    
    Change-Id: Ifca77ccda7b2065b00ee29f29f377da599929843

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index e038da3b..5a6b50b 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1695,6 +1695,10 @@ public:
 void ScColumn::CopyCellNotesToDocument(
     SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, bool bCloneCaption, SCROW nRowOffsetDest ) const
 {
+    if (IsNotesEmptyBlock(nRow1, nRow2))
+        // The column has no cell notes to copy between specified rows.
+        return;
+
     ScDrawLayer *pDrawLayer = rDestCol.GetDoc().GetDrawLayer();
     bool bWasLocked = bool();
     if (pDrawLayer)
commit 67eb4b77305205e3495d6542e947404d37a190ae
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Sep 30 23:28:41 2014 -0400

    Set latin script to numeric blocks of applicable columns.
    
    Change-Id: Ib81ef144f168fed38100127bd63f43ea5a835a13

diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index e27a38a..29f912f 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -23,6 +23,27 @@
 #include <attarray.hxx>
 
 #include <svl/sharedstringpool.hxx>
+#include <svl/languageoptions.hxx>
+
+#include <vector>
+
+namespace {
+
+struct ColAttr
+{
+    bool mbLatinNumFmtOnly;
+
+    ColAttr() : mbLatinNumFmtOnly(false) {}
+};
+
+struct TabAttr
+{
+    std::vector<ColAttr> maCols;
+};
+
+typedef std::vector<TabAttr> TabAttrsType;
+
+}
 
 struct ScDocumentImportImpl
 {
@@ -31,11 +52,28 @@ struct ScDocumentImportImpl
     sc::ColumnBlockPositionSet maBlockPosSet;
     sal_uInt16 mnDefaultScriptNumeric;
 
+    TabAttrsType maTabAttrs;
+
     ScDocumentImportImpl(ScDocument& rDoc) :
         mrDoc(rDoc),
         maListenCxt(rDoc),
         maBlockPosSet(rDoc),
         mnDefaultScriptNumeric(SC_SCRIPTTYPE_UNKNOWN) {}
+
+    ColAttr* getColAttr( size_t nTab, size_t nCol )
+    {
+        if (nTab > static_cast<size_t>(MAXTAB) || nCol > static_cast<size_t>(MAXCOL))
+            return NULL;
+
+        if (nTab >= maTabAttrs.size())
+            maTabAttrs.resize(nTab+1);
+
+        TabAttr& rTab = maTabAttrs[nTab];
+        if (nCol >= rTab.maCols.size())
+            rTab.maCols.resize(nCol+1);
+
+        return &rTab.maCols[nCol];
+    }
 };
 
 ScDocumentImport::Attrs::Attrs() : mpData(NULL), mnSize(0), mbLatinNumFmtOnly(false) {}
@@ -421,6 +459,10 @@ void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs )
     if (!pCol)
         return;
 
+    ColAttr* pColAttr = mpImpl->getColAttr(nTab, nCol);
+    if (pColAttr)
+        pColAttr->mbLatinNumFmtOnly = rAttrs.mbLatinNumFmtOnly;
+
     pCol->pAttrArray->SetAttrEntries(rAttrs.mpData, rAttrs.mnSize);
 }
 
@@ -450,14 +492,16 @@ class CellStoreInitializer
         {}
     };
 
-    ScDocument& mrDoc;
-    sc::StartListeningContext& mrListenCxt;
+    ScDocumentImportImpl& mrDocImpl;
+    SCTAB mnTab;
+    SCCOL mnCol;
 
 public:
-    CellStoreInitializer(ScDocument& rDoc, sc::StartListeningContext& rCxt, sal_uInt16 nScriptNumeric) :
-        mrDoc(rDoc),
-        mrListenCxt(rCxt),
-        mpImpl(new Impl(MAXROWCOUNT, nScriptNumeric))
+    CellStoreInitializer( ScDocumentImportImpl& rDocImpl, SCTAB nTab, SCCOL nCol ) :
+        mrDocImpl(rDocImpl),
+        mnTab(nTab),
+        mnCol(nCol),
+        mpImpl(new Impl(MAXROWCOUNT, mrDocImpl.mnDefaultScriptNumeric))
     {}
 
     boost::shared_ptr<Impl> mpImpl;
@@ -470,7 +514,13 @@ public:
         // Fill with default values for non-empty cell segments.
         sc::CellTextAttr aDefault;
         if (node.type == sc::element_type_numeric)
+        {
             aDefault.mnScriptType = mpImpl->mnScriptNumeric;
+            const ColAttr* p = mrDocImpl.getColAttr(mnTab, mnCol);
+            if (p && p->mbLatinNumFmtOnly)
+                aDefault.mnScriptType = SCRIPTTYPE_LATIN;
+        }
+
         std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
         mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
 
@@ -482,7 +532,7 @@ public:
             for (; it != itEnd; ++it)
             {
                 ScFormulaCell& rFC = **it;
-                rFC.StartListeningTo(mrListenCxt);
+                rFC.StartListeningTo(mrDocImpl.maListenCxt);
             }
         }
     }
@@ -515,7 +565,7 @@ void ScDocumentImport::finalize()
 
 void ScDocumentImport::initColumn(ScColumn& rCol)
 {
-    CellStoreInitializer aFunc(mpImpl->mrDoc, mpImpl->maListenCxt, mpImpl->mnDefaultScriptNumeric);
+    CellStoreInitializer aFunc(*mpImpl, rCol.nTab, rCol.nCol);
     std::for_each(rCol.maCells.begin(), rCol.maCells.end(), aFunc);
     aFunc.swap(rCol.maCellTextAttrs);
     rCol.RegroupFormulaCells();
commit 714d8261f223c57cd5202c8f2d0e3626ae878661
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Sep 30 23:27:29 2014 -0400

    Forgot to check this in.
    
    Change-Id: I2a45fc31bad6c2ebc9a7c92ad12e54f7da62fea4

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 639946a..b43300b 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -240,6 +240,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/core/tool/listenerquery \
     sc/source/core/tool/lookupcache \
     sc/source/core/tool/navicfg \
+    sc/source/core/tool/numformat \
     sc/source/core/tool/odffmap \
     sc/source/core/tool/optutil \
     sc/source/core/tool/orcusxml \
commit eeaca1291d00a159d2913022884ff4b75aa20024
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Sep 30 22:23:16 2014 -0400

    Check for standard number format rather than just for 'General'.
    
    That's what the ods import filter does.
    
    Change-Id: Ibcd9a80a51785a448594d29a02283cca0ec53e95

diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index 8180f35..7d46216 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -49,7 +49,7 @@ public:
         ScAttrEntry* mpData;
         size_t mnSize;
 
-        bool mbGeneralNumFmtOnly;
+        bool mbLatinNumFmtOnly;
 
         Attrs();
     };
diff --git a/sc/inc/numformat.hxx b/sc/inc/numformat.hxx
index 40d9561..7293818 100644
--- a/sc/inc/numformat.hxx
+++ b/sc/inc/numformat.hxx
@@ -35,6 +35,8 @@ public:
      * latin script output.
      */
     static bool isLatinScript( const ScPatternAttr& rPat, ScDocument& rDoc );
+
+    static bool isLatinScript( sal_uLong nFormat, ScDocument& rDoc );
 };
 
 }
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 09cacec..e27a38a 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -38,7 +38,7 @@ struct ScDocumentImportImpl
         mnDefaultScriptNumeric(SC_SCRIPTTYPE_UNKNOWN) {}
 };
 
-ScDocumentImport::Attrs::Attrs() : mpData(NULL), mnSize(0), mbGeneralNumFmtOnly(true) {}
+ScDocumentImport::Attrs::Attrs() : mpData(NULL), mnSize(0), mbLatinNumFmtOnly(false) {}
 
 ScDocumentImport::ScDocumentImport(ScDocument& rDoc) : mpImpl(new ScDocumentImportImpl(rDoc)) {}
 ScDocumentImport::~ScDocumentImport()
diff --git a/sc/source/core/tool/numformat.cxx b/sc/source/core/tool/numformat.cxx
index 1961125..a889ab8 100644
--- a/sc/source/core/tool/numformat.cxx
+++ b/sc/source/core/tool/numformat.cxx
@@ -49,7 +49,13 @@ bool NumFmtUtil::isLatinScript( const ScPatternAttr& rPat, ScDocument& rDoc )
 {
     SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
     sal_uInt32 nKey = rPat.GetNumberFormat(pFormatter);
-    const SvNumberformat* pFormat = pFormatter->GetEntry(nKey);
+    return isLatinScript(nKey, rDoc);
+}
+
+bool NumFmtUtil::isLatinScript( sal_uLong nFormat, ScDocument& rDoc )
+{
+    SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
+    const SvNumberformat* pFormat = pFormatter->GetEntry(nFormat);
     if (!pFormat || !pFormat->IsStandard())
         return false;
 
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index c4ec6f8..952075b 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -1988,7 +1988,7 @@ void XclImpXFRangeBuffer::Finalize()
             aAttrParam.mnSize = aAttrs.size();
             assert(aAttrParam.mnSize > 0);
             aAttrParam.mpData = new ScAttrEntry[aAttrParam.mnSize];
-            aAttrParam.mbGeneralNumFmtOnly = false; // when unsure, set it to false.
+            aAttrParam.mbLatinNumFmtOnly = false; // when unsure, set it to false.
             list<ScAttrEntry>::const_iterator itr = aAttrs.begin(), itrEnd = aAttrs.end();
             for (size_t i = 0; itr != itrEnd; ++itr, ++i)
                 aAttrParam.mpData[i] = *itr;
diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx
index c34a63d..ab855b3 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -640,7 +640,7 @@ public:
     struct AttrList
     {
         std::list<ScAttrEntry> maAttrs;
-        bool mbGeneralNumFmtOnly;
+        bool mbLatinNumFmtOnly;
 
         AttrList();
     };
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index e5f4e92..7cdf627 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -54,6 +54,7 @@
 #include "paramisc.hxx"
 #include "documentimport.hxx"
 #include "formulabuffer.hxx"
+#include <numformat.hxx>
 
 namespace oox {
 namespace xls {
@@ -477,12 +478,15 @@ void SheetDataBuffer::finalizeImport()
             aEntry.pPattern = rDoc.getDoc().GetPattern(nScCol, 0, getSheetIndex());
             rDoc.getDoc().GetPool()->Put(*aEntry.pPattern);
             aAttrs.maAttrs.push_back(aEntry);
+
+            if (!sc::NumFmtUtil::isLatinScript(*aEntry.pPattern, rDoc.getDoc()))
+                aAttrs.mbLatinNumFmtOnly = false;
         }
 
         ScDocumentImport::Attrs aAttrParam;
         aAttrParam.mnSize = aAttrs.maAttrs.size();
         aAttrParam.mpData = new ScAttrEntry[aAttrParam.mnSize];
-        aAttrParam.mbGeneralNumFmtOnly = aAttrs.mbGeneralNumFmtOnly;
+        aAttrParam.mbLatinNumFmtOnly = aAttrs.mbLatinNumFmtOnly;
         std::list<ScAttrEntry>::const_iterator itr = aAttrs.maAttrs.begin(), itrEnd = aAttrs.maAttrs.end();
         for (size_t i = 0; itr != itrEnd; ++itr, ++i)
             aAttrParam.mpData[i] = *itr;
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 9cb8c46..498241f 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -2054,7 +2054,7 @@ XfModel::XfModel() :
 {
 }
 
-Xf::AttrList::AttrList() : mbGeneralNumFmtOnly(true) {}
+Xf::AttrList::AttrList() : mbLatinNumFmtOnly(true) {}
 
 Xf::Xf( const WorkbookHelper& rHelper ) :
     WorkbookHelper( rHelper ),
@@ -2165,8 +2165,8 @@ void Xf::applyPatternToAttrList( AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal
         rPat.GetItemSet().Put(aNumPat.GetItemSet());
     }
 
-    if (!sc::NumFmtUtil::isGeneral(mnScNumFmt))
-        rAttrs.mbGeneralNumFmtOnly = false;
+    if (!sc::NumFmtUtil::isLatinScript(mnScNumFmt, rDoc))
+        rAttrs.mbLatinNumFmtOnly = false;
 
     if (rPat.GetStyleName())
     {
@@ -2188,8 +2188,8 @@ void Xf::applyPatternToAttrList( AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal
             rAttrs.maAttrs.push_back(aEntry);
 
             // Check if the default pattern is 'General'.
-            if (!sc::NumFmtUtil::isGeneral(*aEntry.pPattern))
-                rAttrs.mbGeneralNumFmtOnly = false;
+            if (!sc::NumFmtUtil::isLatinScript(*aEntry.pPattern, rDoc))
+                rAttrs.mbLatinNumFmtOnly = false;
         }
 
         ScAttrEntry aEntry;
@@ -2197,8 +2197,8 @@ void Xf::applyPatternToAttrList( AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal
         aEntry.pPattern = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(rPat));
         rAttrs.maAttrs.push_back(aEntry);
 
-        if (!sc::NumFmtUtil::isGeneral(*aEntry.pPattern))
-            rAttrs.mbGeneralNumFmtOnly = false;
+        if (!sc::NumFmtUtil::isLatinScript(*aEntry.pPattern, rDoc))
+            rAttrs.mbLatinNumFmtOnly = false;
     }
 }
 
commit a4f6b51faf7a8b2db2a1ab50fea98b073641fdb2
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Sep 30 22:00:05 2014 -0400

    Move this useful function to sc::NumFmtUtil.
    
    Change-Id: I7b42a4418408ee2c988c32e7f1adeee3dfe269c8

diff --git a/sc/inc/numformat.hxx b/sc/inc/numformat.hxx
index 0bf4930..40d9561 100644
--- a/sc/inc/numformat.hxx
+++ b/sc/inc/numformat.hxx
@@ -15,6 +15,7 @@
 #include <tools/solar.h>
 
 class ScPatternAttr;
+class ScDocument;
 
 namespace sc {
 
@@ -28,6 +29,12 @@ public:
     static bool isGeneral( sal_uLong nFormat );
 
     static bool isGeneral( const ScPatternAttr& rPat );
+
+    /**
+     * Check if the attribute pattern has a number format that only produces
+     * latin script output.
+     */
+    static bool isLatinScript( const ScPatternAttr& rPat, ScDocument& rDoc );
 };
 
 }
diff --git a/sc/source/core/tool/numformat.cxx b/sc/source/core/tool/numformat.cxx
index 505bf6f..1961125 100644
--- a/sc/source/core/tool/numformat.cxx
+++ b/sc/source/core/tool/numformat.cxx
@@ -5,14 +5,27 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
 #include <numformat.hxx>
 #include <patattr.hxx>
 #include <scitems.hxx>
+#include <document.hxx>
 
 #include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
 #include <svl/intitem.hxx>
+#include <svl/languageoptions.hxx>
 
 namespace sc {
 
@@ -32,6 +45,32 @@ bool NumFmtUtil::isGeneral( const ScPatternAttr& rPat )
     return isGeneral(nNumFmt);
 }
 
+bool NumFmtUtil::isLatinScript( const ScPatternAttr& rPat, ScDocument& rDoc )
+{
+    SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
+    sal_uInt32 nKey = rPat.GetNumberFormat(pFormatter);
+    const SvNumberformat* pFormat = pFormatter->GetEntry(nKey);
+    if (!pFormat || !pFormat->IsStandard())
+        return false;
+
+    // The standard format is all-latin if the decimal separator doesn't
+    // have a different script type
+
+    OUString aDecSep;
+    LanguageType nFormatLang = pFormat->GetLanguage();
+    if (nFormatLang == LANGUAGE_SYSTEM)
+        aDecSep = ScGlobal::pLocaleData->getNumDecimalSep();
+    else
+    {
+        LocaleDataWrapper aLocaleData(
+            comphelper::getProcessComponentContext(), LanguageTag(nFormatLang));
+        aDecSep = aLocaleData.getNumDecimalSep();
+    }
+
+    sal_uInt8 nScript = rDoc.GetStringScriptType(aDecSep);
+    return (nScript == 0 || nScript == SCRIPTTYPE_LATIN);
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 1b9d10a..6239d0e 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -70,6 +70,7 @@
 #include "documentimport.hxx"
 #include "pivotsource.hxx"
 #include <unonames.hxx>
+#include <numformat.hxx>
 
 #include <comphelper/extract.hxx>
 
@@ -2437,32 +2438,8 @@ void ScXMLImport::ExamineDefaultStyle()
         // number format (then, value cells can be pre-initialized with western script type)
 
         const ScPatternAttr* pDefPattern = pDoc->GetDefPattern();
-        SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
-        if ( pFormatter && pDefPattern )
-        {
-            sal_uInt32 nKey = pDefPattern->GetNumberFormat(pFormatter);
-            const SvNumberformat* pFormat = pFormatter->GetEntry(nKey);
-            if ( pFormat && pFormat->IsStandard() )
-            {
-                // The standard format is all-latin if the decimal separator doesn't
-                // have a different script type
-
-                OUString aDecSep;
-                LanguageType nFormatLang = pFormat->GetLanguage();
-                if ( nFormatLang == LANGUAGE_SYSTEM )
-                    aDecSep = ScGlobal::pLocaleData->getNumDecimalSep();
-                else
-                {
-                    LocaleDataWrapper aLocaleData( comphelper::getProcessComponentContext(),
-                        LanguageTag( nFormatLang ) );
-                    aDecSep = aLocaleData.getNumDecimalSep();
-                }
-
-                sal_uInt8 nScript = pDoc->GetStringScriptType( aDecSep );
-                if ( nScript == 0 || nScript == SCRIPTTYPE_LATIN )
-                    mpDocImport->setDefaultNumericScript(SCRIPTTYPE_LATIN);
-            }
-        }
+        if (pDefPattern && sc::NumFmtUtil::isLatinScript(*pDefPattern, *pDoc))
+            mpDocImport->setDefaultNumericScript(SCRIPTTYPE_LATIN);
     }
 }
 
commit 7b5ab3e39b791ffbd50aed1dcead94bf277bfa3c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Sep 30 21:30:17 2014 -0400

    Try to determine whether or not a column has all 'General' number format
    
    during import.  We'll then use this information to set script type to latin
    for all numeric cells in those columns rather than leaving the script type
    'unknown'.
    
    Change-Id: I69eae1effc32c57290b0265bc6c87e58f51944b1

diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index 621d222..8180f35 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -43,6 +43,17 @@ class SC_DLLPUBLIC ScDocumentImport : boost::noncopyable
     ScDocumentImport(); // disabled
 
 public:
+
+    struct Attrs
+    {
+        ScAttrEntry* mpData;
+        size_t mnSize;
+
+        bool mbGeneralNumFmtOnly;
+
+        Attrs();
+    };
+
     ScDocumentImport(ScDocument& rDoc);
     ~ScDocumentImport();
 
@@ -87,7 +98,7 @@ public:
      * transfers the ownership of the ScAttrEntry array from the caller to the
      * column.
      */
-    void setAttrEntries( SCTAB nTab, SCCOL nCol, ScAttrEntry* pData, size_t nSize );
+    void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs );
 
     void finalize();
 
diff --git a/sc/inc/numformat.hxx b/sc/inc/numformat.hxx
new file mode 100644
index 0000000..0bf4930
--- /dev/null
+++ b/sc/inc/numformat.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SC_NUMFORMAT_HXX
+#define INCLUDED_SC_NUMFORMAT_HXX
+
+#include <scdllapi.h>
+
+#include <tools/solar.h>
+
+class ScPatternAttr;
+
+namespace sc {
+
+class SC_DLLPUBLIC NumFmtUtil
+{
+public:
+
+    /**
+     * Return whether or not given number format is a 'General' number format.
+     */
+    static bool isGeneral( sal_uLong nFormat );
+
+    static bool isGeneral( const ScPatternAttr& rPat );
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 17c8e4d..09cacec 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -38,6 +38,8 @@ struct ScDocumentImportImpl
         mnDefaultScriptNumeric(SC_SCRIPTTYPE_UNKNOWN) {}
 };
 
+ScDocumentImport::Attrs::Attrs() : mpData(NULL), mnSize(0), mbGeneralNumFmtOnly(true) {}
+
 ScDocumentImport::ScDocumentImport(ScDocument& rDoc) : mpImpl(new ScDocumentImportImpl(rDoc)) {}
 ScDocumentImport::~ScDocumentImport()
 {
@@ -409,7 +411,7 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam
     }
 }
 
-void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, ScAttrEntry* pData, size_t nSize )
+void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs )
 {
     ScTable* pTab = mpImpl->mrDoc.FetchTable(nTab);
     if (!pTab)
@@ -419,7 +421,7 @@ void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, ScAttrEntry* pDat
     if (!pCol)
         return;
 
-    pCol->pAttrArray->SetAttrEntries(pData, nSize);
+    pCol->pAttrArray->SetAttrEntries(rAttrs.mpData, rAttrs.mnSize);
 }
 
 namespace {
diff --git a/sc/source/core/tool/numformat.cxx b/sc/source/core/tool/numformat.cxx
new file mode 100644
index 0000000..505bf6f
--- /dev/null
+++ b/sc/source/core/tool/numformat.cxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <numformat.hxx>
+#include <patattr.hxx>
+#include <scitems.hxx>
+
+#include <svl/zforlist.hxx>
+#include <svl/intitem.hxx>
+
+namespace sc {
+
+bool NumFmtUtil::isGeneral( sal_uLong nFormat )
+{
+    return (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0;
+}
+
+bool NumFmtUtil::isGeneral( const ScPatternAttr& rPat )
+{
+    const SfxPoolItem* pItem = NULL;
+    if (!rPat.GetItemSet().HasItem(ATTR_VALUE_FORMAT, &pItem))
+        // Assume it's 'General' when the number format is not explicitly set.
+        return true;
+
+    sal_uInt32 nNumFmt = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
+    return isGeneral(nNumFmt);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index e6a13a7..c4ec6f8 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -1984,14 +1984,16 @@ void XclImpXFRangeBuffer::Finalize()
                 aAttrs.push_back(aEntry);
             }
 
-            size_t nAttrSize = aAttrs.size();
-            assert(nAttrSize > 0);
-            ScAttrEntry* pData = new ScAttrEntry[nAttrSize];
+            ScDocumentImport::Attrs aAttrParam;
+            aAttrParam.mnSize = aAttrs.size();
+            assert(aAttrParam.mnSize > 0);
+            aAttrParam.mpData = new ScAttrEntry[aAttrParam.mnSize];
+            aAttrParam.mbGeneralNumFmtOnly = false; // when unsure, set it to false.
             list<ScAttrEntry>::const_iterator itr = aAttrs.begin(), itrEnd = aAttrs.end();
             for (size_t i = 0; itr != itrEnd; ++itr, ++i)
-                pData[i] = *itr;
+                aAttrParam.mpData[i] = *itr;
 
-            rDoc.setAttrEntries(nScTab, nScCol, pData, static_cast<SCSIZE>(nAttrSize));
+            rDoc.setAttrEntries(nScTab, nScCol, aAttrParam);
         }
     }
 
diff --git a/sc/source/filter/inc/numberformatsbuffer.hxx b/sc/source/filter/inc/numberformatsbuffer.hxx
index e75caa6..3a79075 100644
--- a/sc/source/filter/inc/numberformatsbuffer.hxx
+++ b/sc/source/filter/inc/numberformatsbuffer.hxx
@@ -71,7 +71,7 @@ public:
     sal_Int32           finalizeImport(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& rxNumFmts,
                             const ::com::sun::star::lang::Locale& rFromLocale );
-    void fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs = false ) const;
+    sal_uLong fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs = false ) const;
     /** Writes the number format to the passed property map. */
     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
 
@@ -98,7 +98,7 @@ public:
     /** Final processing after import of all style settings. */
     void                finalizeImport();
 
-    void                fillToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs = false ) const;
+    sal_uLong           fillToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs = false ) const;
 
     /** Writes the specified number format to the passed property map. */
     void                writeToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const;
diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx
index c2f364e..c34a63d 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -637,6 +637,14 @@ class Xf : public WorkbookHelper
 {
     friend bool operator==( const Xf& rXf1,  const Xf& rXf2 );
 public:
+    struct AttrList
+    {
+        std::list<ScAttrEntry> maAttrs;
+        bool mbGeneralNumFmtOnly;
+
+        AttrList();
+    };
+
     explicit            Xf( const WorkbookHelper& rHelper );
 
     /** Sets all attributes from the xf element. */
@@ -662,8 +670,9 @@ public:
     /** Returns the cell protection data of this style. */
     inline const Protection& getProtection() const { return maProtection; }
 
-    void  applyPatternToAttrList( ::std::list<ScAttrEntry>& rAttrs, SCROW nRow1, SCROW nRow2,
-                                  sal_Int32 nForceScNumFmt );
+    void applyPatternToAttrList(
+        AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nForceScNumFmt );
+
     /** Writes all formatting attributes to the passed property map. */
     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
     /** Writes all formatting attributes to the passed property set. */
@@ -677,6 +686,7 @@ private:
     typedef ::std::auto_ptr< ::ScPatternAttr > ScPatternAttrPtr;
 
     ScPatternAttrPtr    mpPattern;          /// Calc item set.
+    sal_uLong           mnScNumFmt;         /// Calc number format.
 
     XfModel             maModel;            /// Cell XF or style XF model data.
     Alignment           maAlignment;        /// Cell alignment data.
@@ -902,7 +912,7 @@ public:
     void                writeFontToItemSet( SfxItemSet& rItemSet, sal_Int32 nFontId, bool bSkipPoolDefs = false ) const;
     /** Writes the font attributes of the specified font data to the passed property map. */
     void                writeFontToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFontId ) const;
-    void                writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs = false ) const;
+    sal_uLong           writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs = false ) const;
     /** Writes the specified number format to the passed property map. */
     void                writeNumFmtToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const;
     void                writeBorderToItemSet( SfxItemSet& rItemSet, sal_Int32 nBorderId, bool bSkipPoolDefs = false ) const;
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx
index 04202cc..d0d3c37 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -1911,16 +1911,21 @@ sal_Int32 NumberFormat::finalizeImport( const Reference< XNumberFormats >& rxNum
     return maApiData.mnIndex;
 }
 
-void NumberFormat::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
+sal_uLong NumberFormat::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
 {
     const ScDocument& rDoc = getScDocument();
     static sal_uLong  nDflt = rDoc.GetFormatTable()->GetStandardFormat( ScGlobal::eLnge );
     sal_uLong nScNumFmt = nDflt;
     if ( maApiData.mnIndex )
         nScNumFmt = maApiData.mnIndex;
+
     ScfTools::PutItem( rItemSet, SfxUInt32Item( ATTR_VALUE_FORMAT, nScNumFmt ), bSkipPoolDefs );
     if( rItemSet.GetItemState( ATTR_VALUE_FORMAT, false ) == SfxItemState::SET )
         ScGlobal::AddLanguage( rItemSet, *(rDoc.GetFormatTable()) );
+    else
+        nScNumFmt = 0;
+
+    return nScNumFmt;
 }
 
 void NumberFormat::writeToPropertyMap( PropertyMap& rPropMap ) const
@@ -1976,10 +1981,13 @@ void NumberFormatsBuffer::finalizeImport()
     maNumFmts.forEach( NumberFormatFinalizer( *this ) );
 }
 
-void NumberFormatsBuffer::fillToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs ) const
+sal_uLong NumberFormatsBuffer::fillToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs ) const
 {
-    if( const NumberFormat* pNumFmt = maNumFmts.get( nNumFmtId ).get() )
-        pNumFmt->fillToItemSet( rItemSet, bSkipPoolDefs);
+    const NumberFormat* pNumFmt = maNumFmts.get(nNumFmtId).get();
+    if (!pNumFmt)
+        return 0;
+
+    return pNumFmt->fillToItemSet( rItemSet, bSkipPoolDefs);
 }
 
 void NumberFormatsBuffer::writeToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index adaaf5e..e5f4e92 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -461,7 +461,7 @@ void SheetDataBuffer::finalizeImport()
     for ( ColStyles::iterator col = maStylesPerColumn.begin(), col_end = maStylesPerColumn.end(); col != col_end; ++col )
     {
         RowStyles& rRowStyles = col->second;
-        std::list<ScAttrEntry> aAttrs;
+        Xf::AttrList aAttrs;
         SCCOL nScCol = static_cast< SCCOL >( col->first );
         for ( RowStyles::iterator rRows = rRowStyles.begin(), rRows_end = rRowStyles.end(); rRows != rRows_end; ++rRows )
         {
@@ -470,22 +470,24 @@ void SheetDataBuffer::finalizeImport()
              if ( pXf )
                  pXf->applyPatternToAttrList( aAttrs,  rRows->mnStartRow,  rRows->mnEndRow,  rRows->mnNumFmt.second );
         }
-        if (aAttrs.empty() || aAttrs.back().nRow != MAXROW)
+        if (aAttrs.maAttrs.empty() || aAttrs.maAttrs.back().nRow != MAXROW)
         {
             ScAttrEntry aEntry;
             aEntry.nRow = MAXROW;
             aEntry.pPattern = rDoc.getDoc().GetPattern(nScCol, 0, getSheetIndex());
             rDoc.getDoc().GetPool()->Put(*aEntry.pPattern);
-            aAttrs.push_back(aEntry);
+            aAttrs.maAttrs.push_back(aEntry);
         }
 
-        size_t nAttrSize = aAttrs.size();
-        ScAttrEntry* pData = new ScAttrEntry[nAttrSize];
-        std::list<ScAttrEntry>::const_iterator itr = aAttrs.begin(), itrEnd = aAttrs.end();
+        ScDocumentImport::Attrs aAttrParam;
+        aAttrParam.mnSize = aAttrs.maAttrs.size();
+        aAttrParam.mpData = new ScAttrEntry[aAttrParam.mnSize];
+        aAttrParam.mbGeneralNumFmtOnly = aAttrs.mbGeneralNumFmtOnly;
+        std::list<ScAttrEntry>::const_iterator itr = aAttrs.maAttrs.begin(), itrEnd = aAttrs.maAttrs.end();
         for (size_t i = 0; itr != itrEnd; ++itr, ++i)
-            pData[i] = *itr;
+            aAttrParam.mpData[i] = *itr;
 
-        rDoc.setAttrEntries(getSheetIndex(), nScCol, pData, static_cast<SCSIZE>(nAttrSize));
+        rDoc.setAttrEntries(getSheetIndex(), nScCol, aAttrParam);
     }
 
     // merge all cached merged ranges and update right/bottom cell borders
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 210dec2..9cb8c46 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -78,6 +78,7 @@
 #include "globstr.hrc"
 #include "xlconst.hxx"
 #include <documentimport.hxx>
+#include <numformat.hxx>
 
 using ::com::sun::star::table::BorderLine2;
 namespace oox {
@@ -2053,8 +2054,11 @@ XfModel::XfModel() :
 {
 }
 
+Xf::AttrList::AttrList() : mbGeneralNumFmtOnly(true) {}
+
 Xf::Xf( const WorkbookHelper& rHelper ) :
     WorkbookHelper( rHelper ),
+    mnScNumFmt(0),
     maAlignment( rHelper ),
     maProtection( rHelper ),
     meRotationRef( ::com::sun::star::table::CellVertJustify2::STANDARD ),
@@ -2124,8 +2128,7 @@ FontRef Xf::getFont() const
     return getStyles().getFont( maModel.mnFontId );
 }
 
-void Xf::applyPatternToAttrList( ::std::list<ScAttrEntry>& rAttrs, SCROW nRow1, SCROW nRow2,
-                                  sal_Int32 nNumFmtId )
+void Xf::applyPatternToAttrList( AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nNumFmtId )
 {
     createPattern();
     ScPatternAttr& rPat = *mpPattern;
@@ -2158,18 +2161,22 @@ void Xf::applyPatternToAttrList( ::std::list<ScAttrEntry>& rAttrs, SCROW nRow1,
     if ( nNumFmtId >= 0 )
     {
         ScPatternAttr aNumPat(rDoc.GetPool());
-        getStyles().writeNumFmtToItemSet( aNumPat.GetItemSet(), nNumFmtId );
+        mnScNumFmt = getStyles().writeNumFmtToItemSet( aNumPat.GetItemSet(), nNumFmtId );
         rPat.GetItemSet().Put(aNumPat.GetItemSet());
     }
+
+    if (!sc::NumFmtUtil::isGeneral(mnScNumFmt))
+        rAttrs.mbGeneralNumFmtOnly = false;
+
     if (rPat.GetStyleName())
     {
         // Check for a gap between the last entry and this one.
         bool bHasGap = false;
-        if (rAttrs.empty() && nRow1 > 0)
+        if (rAttrs.maAttrs.empty() && nRow1 > 0)
             // First attribute range doesn't start at row 0.
             bHasGap = true;
 
-        if (!rAttrs.empty() && rAttrs.back().nRow + 1 < nRow1)
+        if (!rAttrs.maAttrs.empty() && rAttrs.maAttrs.back().nRow + 1 < nRow1)
             bHasGap = true;
 
         if (bHasGap)
@@ -2178,13 +2185,20 @@ void Xf::applyPatternToAttrList( ::std::list<ScAttrEntry>& rAttrs, SCROW nRow1,
             ScAttrEntry aEntry;
             aEntry.nRow = nRow1 - 1;
             aEntry.pPattern = rDoc.GetDefPattern();
-            rAttrs.push_back(aEntry);
+            rAttrs.maAttrs.push_back(aEntry);
+
+            // Check if the default pattern is 'General'.
+            if (!sc::NumFmtUtil::isGeneral(*aEntry.pPattern))
+                rAttrs.mbGeneralNumFmtOnly = false;
         }
 
         ScAttrEntry aEntry;
         aEntry.nRow = nRow2;
         aEntry.pPattern = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(rPat));
-        rAttrs.push_back(aEntry);
+        rAttrs.maAttrs.push_back(aEntry);
+
+        if (!sc::NumFmtUtil::isGeneral(*aEntry.pPattern))
+            rAttrs.mbGeneralNumFmtOnly = false;
     }
 }
 
@@ -2307,7 +2321,7 @@ Xf::createPattern( bool bSkipPoolDefs )
     // value format
     if( maModel.mbNumFmtUsed )
     {
-        rStyles.writeNumFmtToItemSet( rItemSet, maModel.mnNumFmtId, bSkipPoolDefs );
+        mnScNumFmt = rStyles.writeNumFmtToItemSet( rItemSet, maModel.mnNumFmtId, bSkipPoolDefs );
     }
     // alignment
     if( maModel.mbAlignUsed )
@@ -3107,9 +3121,9 @@ void StylesBuffer::writeFontToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFon
         pFont->writeToPropertyMap( rPropMap, FONT_PROPTYPE_CELL );
 }
 
-void StylesBuffer::writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs ) const
+sal_uLong StylesBuffer::writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs ) const
 {
-    maNumFmts.fillToItemSet( rItemSet, nNumFmtId, bSkipPoolDefs );
+    return maNumFmts.fillToItemSet( rItemSet, nNumFmtId, bSkipPoolDefs );
 }
 
 void StylesBuffer::writeNumFmtToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const
commit 6029d8ca070b8b58019a97e93df3dd5359098a2d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Sep 30 14:52:52 2014 -0400

    Move SetAttrEntries from ScDocument to ScDocumentImport.
    
    Since that method was really an optimization for xls(x) import code.
    
    Change-Id: Ie2530f5dc27411bd45d72440681689c6c7a8b10a

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 7b189e0..b147654 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -407,7 +407,6 @@ public:
     void        ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
     void        ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
                                   ScEditDataArray* pDataArray = NULL );
-    bool        SetAttrEntries(ScAttrEntry* pData, SCSIZE nSize);
     void        SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, bool bPutToPool = false );
     void        SetPatternArea( SCROW nStartRow, SCROW nEndRow,
                                 const ScPatternAttr& rPatAttr, bool bPutToPool = false );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9c462d7..7c0e52e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1422,8 +1422,6 @@ public:
                                             SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
                                             const ScPatternAttr& rAttr );
 
-    SC_DLLPUBLIC bool SetAttrEntries(SCCOL nCol, SCTAB nTab, ScAttrEntry* pData, SCSIZE nSize);
-
     SC_DLLPUBLIC void           ApplyPatternIfNumberformatIncompatible(
                             const ScRange& rRange, const ScMarkData& rMark,
                             const ScPatternAttr& rPattern, short nNewType );
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index 4b84f0d..621d222 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -21,6 +21,7 @@ class EditTextObject;
 class ScDocument;
 class ScColumn;
 class ScAddress;
+struct ScAttrEntry;
 class ScTokenArray;
 class ScFormulaCell;
 class ScStyleSheet;
@@ -81,6 +82,13 @@ public:
 
     void setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam);
 
+    /**
+     * Set an array of cell attributes to specified column.  This call
+     * transfers the ownership of the ScAttrEntry array from the caller to the
+     * column.
+     */
+    void setAttrEntries( SCTAB nTab, SCCOL nCol, ScAttrEntry* pData, size_t nSize );
+
     void finalize();
 
 private:
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index fb5d6f9..4caee54 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -607,7 +607,6 @@ public:
     void        ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
     void        ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
                                   const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = NULL );
-    bool        SetAttrEntries(SCCOL nCol, ScAttrEntry* pData, SCSIZE nSize);
 
     void        SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr, bool bPutToPool = false )
                     {
@@ -1088,6 +1087,9 @@ private:
     // Clipboard transpose for notes
     void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2);
 
+    ScColumn* FetchColumn( SCCOL nCol );
+    const ScColumn* FetchColumn( SCCOL nCol ) const;
+
     /**
      * Use this to iterate through non-empty visible cells in a single column.
      */
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index e49d765..939069b 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -509,11 +509,6 @@ void ScColumn::ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPattern
     pAttrArray->ApplyCacheArea( nStartRow, nEndRow, &aCache, pDataArray );
 }
 
-bool ScColumn::SetAttrEntries(ScAttrEntry* pData, SCSIZE nSize)
-{
-    return pAttrArray->SetAttrEntries(pData, nSize);
-}
-
 void ScColumn::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
         const ScPatternAttr& rPattern, short nNewType )
 {
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index a582db4..3a9dade 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4437,14 +4437,6 @@ void ScDocument::ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
             maTabs[nTab]->ApplyPatternArea( nStartCol, nStartRow, nEndCol, nEndRow, rAttr );
 }
 
-bool ScDocument::SetAttrEntries(SCCOL nCol, SCTAB nTab, ScAttrEntry* pData, SCSIZE nSize)
-{
-    if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
-        return false;
-
-    return maTabs[nTab]->SetAttrEntries(nCol, pData, nSize);
-}
-
 void ScDocument::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
         const ScMarkData& rMark, const ScPatternAttr& rPattern, short nNewType )
 {
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 32ff6fb..17c8e4d 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -20,6 +20,7 @@
 #include "compiler.hxx"
 #include "paramisc.hxx"
 #include "listenercontext.hxx"
+#include <attarray.hxx>
 
 #include <svl/sharedstringpool.hxx>
 
@@ -408,6 +409,19 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam
     }
 }
 
+void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, ScAttrEntry* pData, size_t nSize )
+{
+    ScTable* pTab = mpImpl->mrDoc.FetchTable(nTab);
+    if (!pTab)
+        return;
+
+    ScColumn* pCol = pTab->FetchColumn(nCol);
+    if (!pCol)
+        return;
+
+    pCol->pAttrArray->SetAttrEntries(pData, nSize);
+}
+
 namespace {
 
 class CellStoreInitializer
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 882c481..ffc3c4e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1007,6 +1007,22 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC
     }
 }
 
+ScColumn* ScTable::FetchColumn( SCCOL nCol )
+{
+    if (!ValidCol(nCol))
+        return NULL;
+
+    return &aCol[nCol];
+}
+
+const ScColumn* ScTable::FetchColumn( SCCOL nCol ) const
+{
+    if (!ValidCol(nCol))
+        return NULL;
+
+    return &aCol[nCol];
+}
+
 void ScTable::StartAllListeners()
 {
     for (SCCOL i=0; i<=MAXCOL; i++)
@@ -2362,14 +2378,6 @@ void ScTable::ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol,
     }
 }
 
-bool ScTable::SetAttrEntries(SCCOL nCol, ScAttrEntry* pData, SCSIZE nSize)
-{
-    if (!ValidCol(nCol))
-        return false;
-
-    return aCol[nCol].SetAttrEntries(pData, nSize);
-}
-
 void ScTable::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
         const ScPatternAttr& rPattern, short nNewType )
 {
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 69b2b35..e6a13a7 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -1947,7 +1947,7 @@ void XclImpXFRangeBuffer::SetMerge( SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2,
 
 void XclImpXFRangeBuffer::Finalize()
 {
-    ScDocument& rDoc = GetDoc();
+    ScDocumentImport& rDoc = GetDocImport();
     SCTAB nScTab = GetCurrScTab();
 
     // apply patterns
@@ -1980,7 +1980,7 @@ void XclImpXFRangeBuffer::Finalize()
             {
                 ScAttrEntry aEntry;
                 aEntry.nRow = MAXROW;
-                aEntry.pPattern = rDoc.GetDefPattern();
+                aEntry.pPattern = rDoc.getDoc().GetDefPattern();
                 aAttrs.push_back(aEntry);
             }
 
@@ -1991,7 +1991,7 @@ void XclImpXFRangeBuffer::Finalize()
             for (size_t i = 0; itr != itrEnd; ++itr, ++i)
                 pData[i] = *itr;
 
-            rDoc.SetAttrEntries(nScCol, nScTab, pData, static_cast<SCSIZE>(nAttrSize));
+            rDoc.setAttrEntries(nScTab, nScCol, pData, static_cast<SCSIZE>(nAttrSize));
         }
     }
 
@@ -2015,13 +2015,13 @@ void XclImpXFRangeBuffer::Finalize()
             SetBorderLine( *pRange, nScTab, BOX_LINE_BOTTOM );
         // do merge
         if( bMultiCol || bMultiRow )
-            rDoc.DoMerge( nScTab, rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() );
+            rDoc.getDoc().DoMerge( nScTab, rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() );
         // #i93609# merged range in a single row: test if manual row height is needed
         if( !bMultiRow )
         {
-            bool bTextWrap = static_cast< const SfxBoolItem* >( rDoc.GetAttr( rStart.Col(), rStart.Row(), rStart.Tab(), ATTR_LINEBREAK ) )->GetValue();
-            if( !bTextWrap && (rDoc.GetCellType( rStart ) == CELLTYPE_EDIT) )
-                if (const EditTextObject* pEditObj = rDoc.GetEditText(rStart))
+            bool bTextWrap = static_cast<const SfxBoolItem*>( rDoc.getDoc().GetAttr( rStart.Col(), rStart.Row(), rStart.Tab(), ATTR_LINEBREAK ) )->GetValue();
+            if( !bTextWrap && (rDoc.getDoc().GetCellType( rStart ) == CELLTYPE_EDIT) )
+                if (const EditTextObject* pEditObj = rDoc.getDoc().GetEditText(rStart))
                     bTextWrap = pEditObj->GetParagraphCount() > 1;
             if( bTextWrap )
                 GetOldRoot().pColRowBuff->SetManualRowHeight( rStart.Row() );
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index e43800b..5690316 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -82,6 +82,7 @@ XclRootData::XclRootData( XclBiff eBiff, SfxMedium& rMedium,
     mrMedium( rMedium ),
     mxRootStrg( xRootStrg ),
     mrDoc( rDoc ),
+    maDocImport(mrDoc),
     maDefPassword( "VelvetSweatshop" ),
     meTextEnc( eTextEnc ),
     meSysLang( Application::GetSettings().GetLanguageTag().getLanguageType() ),
@@ -265,6 +266,26 @@ SotStorageStreamRef XclRoot::OpenStream( const OUString& rStrmName ) const
     return OpenStream( GetRootStorage(), rStrmName );
 }
 
+ScDocument& XclRoot::GetDoc() const
+{
+    return mrData.mrDoc;
+}
+
+ScDocument* XclRoot::GetDocPtr() const
+{
+    return &mrData.mrDoc;
+}
+
+ScDocumentImport& XclRoot::GetDocImport()
+{
+    return mrData.maDocImport;
+}
+
+const ScDocumentImport& XclRoot::GetDocImport() const
+{
+    return mrData.maDocImport;
+}
+
 SfxObjectShell* XclRoot::GetDocShell() const
 {
     return GetDoc().GetDocumentShell();
diff --git a/sc/source/filter/inc/xlroot.hxx b/sc/source/filter/inc/xlroot.hxx
index 0dc5e1d..a132eda 100644
--- a/sc/source/filter/inc/xlroot.hxx
+++ b/sc/source/filter/inc/xlroot.hxx
@@ -26,6 +26,7 @@
 #include <sot/storage.hxx>
 #include "xlconst.hxx"
 #include "xltools.hxx"
+#include <documentimport.hxx>
 #include <boost/shared_ptr.hpp>
 
 namespace comphelper { class IDocPasswordVerifier; }
@@ -80,6 +81,7 @@ struct XclRootData
     SfxMedium&          mrMedium;           /// The medium to import from.
     SotStorageRef       mxRootStrg;         /// The root OLE storage of imported/exported file.
     ScDocument&         mrDoc;              /// The source or destination document.
+    ScDocumentImport    maDocImport;
     OUString            maDocUrl;           /// Document URL of imported/exported file.
     OUString            maBasePath;         /// Base path of imported/exported file (path of maDocUrl).
     OUString            maUserName;         /// Current user name.
@@ -202,9 +204,13 @@ public:
     SotStorageStreamRef OpenStream( const OUString& rStrmName ) const;
 
     /** Returns the destination document (import) or source document (export). */
-    inline ScDocument&  GetDoc() const { return mrData.mrDoc; }
+    ScDocument& GetDoc() const;
     /** Returns pointer to the destination document (import) or source document (export). */
-    inline ScDocument*  GetDocPtr() const { return &mrData.mrDoc; }
+    ScDocument* GetDocPtr() const;
+
+    ScDocumentImport& GetDocImport();
+    const ScDocumentImport& GetDocImport() const;
+
     /** Returns the object shell of the Calc document. May be 0 (i.e. import from clipboard). */
     SfxObjectShell*     GetDocShell() const;
     /** Returns the object model of the Calc document. */
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 6fc4922..adaaf5e 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -456,7 +456,7 @@ void SheetDataBuffer::finalizeImport()
         }
     }
 
-    ScDocument& rDoc = getScDocument();
+    ScDocumentImport& rDoc = getDocImport();
     StylesBuffer& rStyles = getStyles();
     for ( ColStyles::iterator col = maStylesPerColumn.begin(), col_end = maStylesPerColumn.end(); col != col_end; ++col )
     {
@@ -474,8 +474,8 @@ void SheetDataBuffer::finalizeImport()
         {
             ScAttrEntry aEntry;
             aEntry.nRow = MAXROW;
-            aEntry.pPattern = rDoc.GetPattern(nScCol, 0, getSheetIndex());
-            rDoc.GetPool()->Put(*aEntry.pPattern);
+            aEntry.pPattern = rDoc.getDoc().GetPattern(nScCol, 0, getSheetIndex());
+            rDoc.getDoc().GetPool()->Put(*aEntry.pPattern);
             aAttrs.push_back(aEntry);
         }
 
@@ -485,7 +485,7 @@ void SheetDataBuffer::finalizeImport()
         for (size_t i = 0; itr != itrEnd; ++itr, ++i)
             pData[i] = *itr;
 
-        rDoc.SetAttrEntries(nScCol, getSheetIndex(), pData, static_cast<SCSIZE>(nAttrSize));
+        rDoc.setAttrEntries(getSheetIndex(), nScCol, pData, static_cast<SCSIZE>(nAttrSize));
     }
 
     // merge all cached merged ranges and update right/bottom cell borders
commit 969a4f08db59678684712d57fb562a57c482bbba
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Sep 29 19:08:02 2014 -0400

    Scope reduction by early bail-out.
    
    Change-Id: Iacbf9f46a1b5683b6de5dd93002a69078af46951

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 401a148..882c481 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -484,47 +484,47 @@ void ScTable::CopyToClip(
     sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     ScTable* pTable )
 {
-    if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
-    {
-        //  copy content
-        //local range names need to be copied first for formula cells
-        if (!pTable->mpRangeName && mpRangeName)
-            pTable->mpRangeName = new ScRangeName(*mpRangeName);
+    if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2))
+        return;
 
-        SCCOL i;
+    //  copy content
+    //local range names need to be copied first for formula cells
+    if (!pTable->mpRangeName && mpRangeName)
+        pTable->mpRangeName = new ScRangeName(*mpRangeName);
 
-        for ( i = nCol1; i <= nCol2; i++)
-            aCol[i].CopyToClip(rCxt, nRow1, nRow2, pTable->aCol[i]);  // notes are handled at column level
+    SCCOL i;
 
-        //  copy widths/heights, and only "hidden", "filtered" and "manual" flags
-        //  also for all preceding columns/rows, to have valid positions for drawing objects
+    for ( i = nCol1; i <= nCol2; i++)
+        aCol[i].CopyToClip(rCxt, nRow1, nRow2, pTable->aCol[i]);  // notes are handled at column level
 
-        if (pColWidth && pTable->pColWidth)
-            for (i=0; i<=nCol2; i++)
-                pTable->pColWidth[i] = pColWidth[i];
+    //  copy widths/heights, and only "hidden", "filtered" and "manual" flags
+    //  also for all preceding columns/rows, to have valid positions for drawing objects
 
-        pTable->CopyColHidden(*this, 0, nCol2);
-        pTable->CopyColFiltered(*this, 0, nCol2);
-        if (pDBDataNoName)
-            pTable->SetAnonymousDBData(new ScDBData(*pDBDataNoName));
+    if (pColWidth && pTable->pColWidth)
+        for (i=0; i<=nCol2; i++)
+            pTable->pColWidth[i] = pColWidth[i];
 
-        if (pRowFlags && pTable->pRowFlags && mpRowHeights && pTable->mpRowHeights)
-        {
-            pTable->pRowFlags->CopyFromAnded( *pRowFlags, 0, nRow2, CR_MANUALSIZE);
-            pTable->CopyRowHeight(*this, 0, nRow2, 0);
-        }
+    pTable->CopyColHidden(*this, 0, nCol2);
+    pTable->CopyColFiltered(*this, 0, nCol2);
+    if (pDBDataNoName)
+        pTable->SetAnonymousDBData(new ScDBData(*pDBDataNoName));
+
+    if (pRowFlags && pTable->pRowFlags && mpRowHeights && pTable->mpRowHeights)
+    {
+        pTable->pRowFlags->CopyFromAnded( *pRowFlags, 0, nRow2, CR_MANUALSIZE);
+        pTable->CopyRowHeight(*this, 0, nRow2, 0);
+    }
 
-        pTable->CopyRowHidden(*this, 0, nRow2);
-        pTable->CopyRowFiltered(*this, 0, nRow2);
+    pTable->CopyRowHidden(*this, 0, nRow2);
+    pTable->CopyRowFiltered(*this, 0, nRow2);
 
-        //  ggf. Formeln durch Werte ersetzen
+    //  ggf. Formeln durch Werte ersetzen
 
-        if ( IsProtected() )
-            for (i = nCol1; i <= nCol2; i++)
-                pTable->aCol[i].RemoveProtected(nRow1, nRow2);
+    if ( IsProtected() )
+        for (i = nCol1; i <= nCol2; i++)
+            pTable->aCol[i].RemoveProtected(nRow1, nRow2);
 
-        pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->pDocument, *mpCondFormatList));
-    }
+    pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->pDocument, *mpCondFormatList));
 }
 
 void ScTable::CopyToClip(
commit 101979eb34c9f67baba74b489206dafa5d951070
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Sep 29 14:24:27 2014 -0400

    Update all script types in the marked ranges up-front.
    
    This is slightly faster than doing it on a as-needed basis.
    
    Change-Id: I7618f003f3c98ee894c3f1cf597681e4281cc6ab

diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 2e60bfa..0e9d8ba 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -138,6 +138,8 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData )
         {
             SCROW nStartNo = itRows->mnStart;
             SCROW nEndNo = itRows->mnEnd;
+            ScAddress aTopLeft(0, nStartNo, nTab);
+            rDoc.UpdateScriptTypes(aTopLeft, MAXCOLCOUNT, nEndNo-nStartNo+1);
             if (rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab))
             {
                 if (!bChanged)


More information about the Libreoffice-commits mailing list