[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 64 commits - basic/source chart2/source connectivity/source cui/source dbaccess/source desktop/source download.lst editeng/source extensions/source extras/source filter/source forms/source formula/source framework/source helpcontent2 include/formula include/oox include/sfx2 include/svtools include/svx include/tools include/unotools include/vcl libvisio/libvisio-0.0.29-remove_whitespace.patch.1 libvisio/UnpackedTarball_libvisio.mk oox/source reportbuilder/Package_reportbuilder-templates.mk reportbuilder/template reportdesign/source sc/inc sc/Library_sc.mk sc/source sfx2/source sot/source starmath/inc starmath/source svgio/source svl/source svtools/source svx/source sw/inc sw/qa sw/source sw/uiconfig sw/UIConfig_swriter.mk tools/source unotools/source unusedcode.easy vcl/inc vcl/source vcl/unx wizards/com xmloff/source xmlsecurity/AllLangResTarget_xsec.mk xmlsecurity/inc xmlsecurity/source

Michael Meeks michael.meeks at suse.com
Tue Jul 2 11:37:48 PDT 2013


Rebased ref, commits from common ancestor:
commit 12a426b0261c44c4625f627ea21bd308266acae5
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Tue Jul 2 18:22:26 2013 +0100

    fix naming snafu.

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 9530276..ca064fe 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -57,7 +57,7 @@ public:
                            const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode);
 };
 
-ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& rMat)
+ScMatrixRef FormulaGroupInterpreterOpenCL::inverseMatrix(const ScMatrix& rMat)
 {
     return ScMatrixRef();
 }
commit 97b026d934cdad9121c980cae87ea50bae9e4aad
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 2 12:26:16 2013 -0400

    Add a way to inverse matrix using openCL. It's an no-op for now.
    
    Change-Id: I4659d57505c3dccf872e124b8b569e680b307b71

diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index e5839e4..1c573c4 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -43,6 +43,7 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
  public:
     static FormulaGroupInterpreter *getStatic();
 
+    virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0;
     virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0;
 };
 
@@ -54,6 +55,7 @@ public:
         FormulaGroupInterpreter() {}
     virtual ~FormulaGroupInterpreterSoftware() {}
 
+    virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat);
     virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode);
 };
 
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 41e439c..9530276 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -51,10 +51,17 @@ public:
     {
         OclCalc::ReleaseOpenclRunEnv();
     }
+
+    virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat);
     virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos,
                            const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode);
 };
 
+ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& rMat)
+{
+    return ScMatrixRef();
+}
+
 bool FormulaGroupInterpreterOpenCL::interpret(ScDocument& rDoc, const ScAddress& rTopPos,
                                               const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode)
 {
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 4a04f79..4754bd0 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -20,6 +20,11 @@
 
 namespace sc {
 
+ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& /*rMat*/)
+{
+    return ScMatrixRef();
+}
+
 bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddress& rTopPos,
                                                 const ScFormulaCellGroupRef& xGroup,
                                                 ScTokenArray& rCode)
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 26c2378..d48cfe7 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -35,6 +35,7 @@
 #include "scmatrix.hxx"
 #include "globstr.hrc"
 #include "cellkeytranslator.hxx"
+#include "formulagroup.hxx"
 
 #include <vector>
 
@@ -850,6 +851,17 @@ void ScInterpreter::ScMatInv()
         }
         SCSIZE nC, nR;
         pMat->GetDimensions(nC, nR);
+
+        if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
+        {
+            ScMatrixRef xResMat = sc::FormulaGroupInterpreter::getStatic()->inverseMatrix(*pMat);
+            if (xResMat)
+            {
+                PushMatrix(xResMat);
+                return;
+            }
+        }
+
         if ( nC != nR || nC == 0 || (sal_uLong) nC * nC > ScMatrix::GetElementsMax() )
             PushIllegalArgument();
         else
commit 946e1cb115a2a46fa10f528f83ca7a214fc31544
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 2 12:00:02 2013 -0400

    Enable group calculation on COUNT and COUNT2.
    
    Change-Id: I7a1cb5aa485bd54e1f6e41262435129b6ac6b98b

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index e25ef60..3ce8fda 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1319,6 +1319,8 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocSum:
             case ocSumProduct:
             case ocMatInv:
+            case ocCount:
+            case ocCount2:
                 // Don't change the state.
             break;
             default:
commit b8904b25d622bcf5c2b1435a993e507d1c7f7555
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 2 09:24:09 2013 -0400

    Try not to iterate beyond the end of the formula block.
    
    Or else a crash would ensue...
    
    Change-Id: Ib08163ba91e4bac023ae778c704a0c052fa48ebb

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index abe2806..4becbb7 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2258,8 +2258,9 @@ const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW n
                 return &rArray[0];
             }
 
+            // Requested length goes beyond a single block.  Fill the array
+            // with the content of this formula block first.
             itEnd = sc::formula_block::end(*aPos.first->data);
-            std::advance(itEnd, nLenRequested);
             for (; it != itEnd; ++it)
             {
                 ScFormulaCell& rCell = **it;
commit cd2594c7504318a88719c710f7e627b9dd72fa16
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 2 01:12:27 2013 -0400

    COUNT should skip formula cells with error.
    
    Change-Id: I829eaf309056403f77949526877888315a2ad720

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index a63025c..52a1474 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -202,6 +202,7 @@ public:
                     // display as empty string if formula::svEmptyCell result
     bool            IsEmptyDisplayedAsString();
     bool            IsValue();      // also true if formula::svEmptyCell
+    bool IsValueNoError();
     bool            IsHybridValueCell(); // for cells after import to deal with inherited number formats
     double          GetValue();
     double          GetValueAlways();   // ignore errors
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index 6736a10..f1f7b5d 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -128,6 +128,8 @@ public:
         details instead. */
     bool IsValue() const;
 
+    bool IsValueNoError() const;
+
     /** Determines whether or not the result is a string containing more than
         one paragraph */
     bool IsMultiline() const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 64aae03..61f57ab 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -511,7 +511,7 @@ public:
                 for (; it != itEnd; ++it)
                 {
                     ScFormulaCell& rCell = const_cast<ScFormulaCell&>(**it);
-                    if (rCell.IsValue())
+                    if (rCell.IsValueNoError())
                         ++mnCount;
                 }
             }
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 1e86cfc..a129726 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1711,6 +1711,15 @@ bool ScFormulaCell::IsValue()
     return aResult.IsValue();
 }
 
+bool ScFormulaCell::IsValueNoError()
+{
+    MaybeInterpret();
+    if (pCode->GetCodeError())
+        return false;
+
+    return aResult.IsValueNoError();
+}
+
 bool ScFormulaCell::IsHybridValueCell()
 {
     return aResult.GetType() == formula::svHybridValueCell;
diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx
index a20963b..72944a0 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -265,6 +265,18 @@ bool ScFormulaResult::IsValue() const
     return isValue(GetCellResultType());
 }
 
+bool ScFormulaResult::IsValueNoError() const
+{
+    switch (GetCellResultType())
+    {
+        case formula::svDouble:
+        case formula::svEmptyCell:
+        case formula::svHybridValueCell:
+            return true;
+    }
+    return false;
+}
+
 bool ScFormulaResult::IsMultiline() const
 {
     if (meMultiline == MULTILINE_UNKNOWN)
commit 9d207f6fc479bf96db9fcde214f15f2ffb045001
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 2 00:51:10 2013 -0400

    Re-implement SUM function to make use of new cell storage.
    
    And fix a bug in my new COUNT function, where I forgot to tally numeric
    formula cells.
    
    Change-Id: I52d26be3e48f646f656821066e23594d52f78c6d

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 7ce53ad..359b8ac 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -409,6 +409,7 @@ public:
     void        ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
     void        ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
 
+    double SumNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const;
     size_t CountNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const;
 
     long GetNeededSize(
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 8d3f625..64aae03 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -468,18 +468,57 @@ void ScColumn::ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark )
 
 namespace {
 
+class NumericCellAccumulator
+{
+    double mfSum;
+public:
+    NumericCellAccumulator() : mfSum(0.0) {}
+
+    void operator() (size_t, double fVal)
+    {
+        mfSum += fVal;
+    }
+
+    void operator() (size_t, const ScFormulaCell* pCell)
+    {
+        ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*pCell);
+        if (rCell.IsValue())
+            mfSum += rCell.GetValue();
+    }
+
+    double getSum() const { return mfSum; }
+};
+
 class NumericCellCounter
 {
     size_t mnCount;
 public:
     NumericCellCounter() : mnCount(0) {}
 
-    void operator() (const sc::CellStoreType::value_type& rNode, size_t /*nOffset*/, size_t nDataSize)
+    void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize)
     {
-        if (rNode.type != sc::element_type_numeric)
-            return;
-
-        mnCount += nDataSize;
+        switch (rNode.type)
+        {
+            case sc::element_type_numeric:
+                mnCount += nDataSize;
+            break;
+            case sc::element_type_formula:
+            {
+                sc::formula_block::const_iterator it = sc::formula_block::begin(*rNode.data);
+                std::advance(it, nOffset);
+                sc::formula_block::const_iterator itEnd = it;
+                std::advance(itEnd, nDataSize);
+                for (; it != itEnd; ++it)
+                {
+                    ScFormulaCell& rCell = const_cast<ScFormulaCell&>(**it);
+                    if (rCell.IsValue())
+                        ++mnCount;
+                }
+            }
+            break;
+            default:
+                ;
+        }
     }
 
     size_t getCount() const { return mnCount; }
@@ -487,6 +526,13 @@ public:
 
 }
 
+double ScColumn::SumNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const
+{
+    NumericCellAccumulator aFunc;
+    rPos.miCellPos = sc::ParseFormulaNumeric(rPos.miCellPos, maCells, nRow1, nRow2, aFunc);
+    return aFunc.getSum();
+}
+
 size_t ScColumn::CountNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const
 {
     NumericCellCounter aFunc;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 643a0aa..93bcfef 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3854,6 +3854,64 @@ void ScInterpreter::ScMax( bool bTextAsZero )
 
 namespace {
 
+class FuncCount : public sc::ColumnSpanSet::ColumnAction
+{
+    sc::ColumnBlockConstPosition maPos;
+    ScColumn* mpCol;
+    size_t mnCount;
+    sal_uInt32 mnNumFmt;
+
+public:
+    FuncCount() : mnCount(0), mnNumFmt(0) {}
+
+    virtual void startColumn(ScColumn* pCol)
+    {
+        mpCol = pCol;
+        mpCol->InitBlockPosition(maPos);
+    }
+
+    virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal)
+    {
+        if (!bVal)
+            return;
+
+        mnCount += mpCol->CountNumericCells(maPos, nRow1, nRow2);
+        mnNumFmt = mpCol->GetNumberFormat(nRow2);
+    };
+
+    size_t getCount() const { return mnCount; }
+    sal_uInt32 getNumberFormat() const { return mnNumFmt; }
+};
+
+class FuncSum : public sc::ColumnSpanSet::ColumnAction
+{
+    sc::ColumnBlockConstPosition maPos;
+    ScColumn* mpCol;
+    double mfSum;
+    sal_uInt32 mnNumFmt;
+
+public:
+    FuncSum() : mfSum(0.0), mnNumFmt(0) {}
+
+    virtual void startColumn(ScColumn* pCol)
+    {
+        mpCol = pCol;
+        mpCol->InitBlockPosition(maPos);
+    }
+
+    virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal)
+    {
+        if (!bVal)
+            return;
+
+        mfSum += mpCol->SumNumericCells(maPos, nRow1, nRow2);
+        mnNumFmt = mpCol->GetNumberFormat(nRow2);
+    };
+
+    double getSum() const { return mfSum; }
+    sal_uInt32 getNumberFormat() const { return mnNumFmt; }
+};
+
 void IterateMatrix(
     const ScMatrixRef& pMat, ScIterFunc eFunc, bool bTextAsZero,
     sal_uLong& rCount, short& rFuncFmtType, double& fRes, double& fMem, bool& bNull)
@@ -4258,8 +4316,132 @@ void ScInterpreter::ScSumSQ()
 
 void ScInterpreter::ScSum()
 {
-    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSum" );
-    PushDouble( IterateParameters( ifSUM ) );
+    short nParamCount = GetByte();
+    double fRes = 0.0;
+    double fVal = 0.0;
+    ScAddress aAdr;
+    ScRange aRange;
+    size_t nRefInList = 0;
+    while (nParamCount-- > 0)
+    {
+        switch (GetStackType())
+        {
+            case svString:
+            {
+                while (nParamCount-- > 0)
+                    Pop();
+                SetError( errNoValue );
+            }
+            break;
+            case svDouble    :
+                fVal = GetDouble();
+                fRes += fVal;
+                nFuncFmtType = NUMBERFORMAT_NUMBER;
+                break;
+            case svExternalSingleRef:
+            {
+                ScExternalRefCache::TokenRef pToken;
+                ScExternalRefCache::CellFormat aFmt;
+                PopExternalSingleRef(pToken, &aFmt);
+
+                if (!pToken)
+                    break;
+
+                StackVar eType = pToken->GetType();
+                if (eType == formula::svDouble)
+                {
+                    fVal = pToken->GetDouble();
+                    if (aFmt.mbIsSet)
+                    {
+                        nFuncFmtType = aFmt.mnType;
+                        nFuncFmtIndex = aFmt.mnIndex;
+                    }
+
+                    fRes += fVal;
+                }
+            }
+            break;
+            case svSingleRef :
+            {
+                PopSingleRef( aAdr );
+
+                if (glSubTotal && pDok->RowFiltered( aAdr.Row(), aAdr.Tab()))
+                {
+                    break;
+                }
+                ScRefCellValue aCell;
+                aCell.assign(*pDok, aAdr);
+                if (!aCell.isEmpty())
+                {
+                    if (aCell.hasNumeric())
+                    {
+                        fVal = GetCellValue(aAdr, aCell);
+                        CurFmtToFuncFmt();
+                        fRes += fVal;
+                    }
+                }
+            }
+            break;
+            case svDoubleRef :
+            case svRefList :
+            {
+                PopDoubleRef( aRange, nParamCount, nRefInList);
+
+                sc::ColumnSpanSet aSet(false);
+                aSet.set(aRange, true);
+                if (glSubTotal)
+                    // Skip all filtered rows and subtotal formula cells.
+                    pDok->MarkSubTotalCells(aSet, aRange, false);
+
+                FuncSum aAction;
+                aSet.executeColumnAction(*pDok, aAction);
+                fRes = aAction.getSum();
+
+                // Get the number format of the last iterated cell.
+                nFuncFmtIndex = aAction.getNumberFormat();
+                nFuncFmtType = pDok->GetFormatTable()->GetType(nFuncFmtIndex);
+            }
+            break;
+            case svExternalDoubleRef:
+            {
+                ScMatrixRef pMat;
+                PopExternalDoubleRef(pMat);
+                if (nGlobalError)
+                    break;
+
+                sal_uLong nCount = 0;
+                double fMem = 0.0;
+                bool bNull = true;
+                IterateMatrix(pMat, ifSUM, false, nCount, nFuncFmtType, fRes, fMem, bNull);
+                fRes += fMem;
+            }
+            break;
+            case svMatrix :
+            {
+                ScMatrixRef pMat = PopMatrix();
+                sal_uLong nCount = 0;
+                double fMem = 0.0;
+                bool bNull = true;
+                IterateMatrix(pMat, ifSUM, false, nCount, nFuncFmtType, fRes, fMem, bNull);
+                fRes += fMem;
+            }
+            break;
+            case svError:
+            {
+                PopError();
+            }
+            break;
+            default :
+                while (nParamCount-- > 0)
+                    PopError();
+                SetError(errIllegalParameter);
+        }
+    }
+
+    if (nFuncFmtType == NUMBERFORMAT_LOGICAL)
+        nFuncFmtType = NUMBERFORMAT_NUMBER;
+
+    PushDouble(fRes);
 }
 
 
@@ -4276,39 +4458,6 @@ void ScInterpreter::ScAverage( bool bTextAsZero )
     PushDouble( IterateParameters( ifAVERAGE, bTextAsZero ) );
 }
 
-namespace {
-
-class FuncCount : public sc::ColumnSpanSet::ColumnAction
-{
-    sc::ColumnBlockConstPosition maPos;
-    ScColumn* mpCol;
-    size_t mnCount;
-    sal_uInt32 mnNumFmt;
-
-public:
-    FuncCount() : mnCount(0), mnNumFmt(0) {}
-
-    virtual void startColumn(ScColumn* pCol)
-    {
-        mpCol = pCol;
-        mpCol->InitBlockPosition(maPos);
-    }
-
-    virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal)
-    {
-        if (!bVal)
-            return;
-
-        mnCount += mpCol->CountNumericCells(maPos, nRow1, nRow2);
-        mnNumFmt = mpCol->GetNumberFormat(nRow2);
-    };
-
-    size_t getCount() const { return mnCount; }
-    sal_uInt32 getNumberFormat() const { return mnNumFmt; }
-};
-
-}
-
 void ScInterpreter::ScCount()
 {
     short nParamCount = GetByte();
commit 3b10c65d9e9a3ffd1bbe176c39d45bbb76b1fc05
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 1 23:30:00 2013 -0400

    Unused variable.
    
    Change-Id: I1df58281896687e61d40675206d0fc3854d93866

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 2a59e7e..8d3f625 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -474,7 +474,7 @@ class NumericCellCounter
 public:
     NumericCellCounter() : mnCount(0) {}
 
-    void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize)
+    void operator() (const sc::CellStoreType::value_type& rNode, size_t /*nOffset*/, size_t nDataSize)
     {
         if (rNode.type != sc::element_type_numeric)
             return;
commit cfb2ce587b097b407eb15699cff7ce9fb6844123
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 1 23:08:14 2013 -0400

    Re-implement the COUNT function for efficiency.
    
    By taking advantage of the block structure of the new cell storage.
    
    Change-Id: Ib953c14d364ccdff7df5caf70d57cec86189e3be

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6cc3c4b..7ce53ad 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -44,6 +44,7 @@ namespace sc {
     class CopyToClipContext;
     class CopyToDocContext;
     class MixDocContext;
+    class ColumnSpanSet;
     struct ColumnBlockPosition;
     class SingleColumnSpanSet;
 }
@@ -116,7 +117,6 @@ class ScColumn
 
 friend class ScDocument;                    // for FillInfo
 friend class ScTable;
-friend class ScDocumentIterator;
 friend class ScValueIterator;
 friend class ScHorizontalValueIterator;
 friend class ScDBQueryDataIterator;
@@ -127,6 +127,7 @@ friend class ScHorizontalAttrIterator;
 friend class ScColumnTextWidthIterator;
 friend class ScDocumentImport;
 friend class sc::SingleColumnSpanSet;
+friend class sc::ColumnSpanSet;
 
     ScColumn(const ScColumn&); // disabled
     ScColumn& operator= (const ScColumn&); // disabled
@@ -242,6 +243,7 @@ public:
     void        SwapCol(ScColumn& rCol);
     void        MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
 
+    void MarkSubTotalCells( sc::ColumnSpanSet& rSet, SCROW nRow1, SCROW nRow2, bool bVal ) const;
 
     bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst);
 
@@ -407,6 +409,8 @@ public:
     void        ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
     void        ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
 
+    size_t CountNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const;
+
     long GetNeededSize(
         SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
         const Fraction& rZoomX, const Fraction& rZoomY,
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 55c3f57..98533e2 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -16,8 +16,10 @@
 #include <mdds/flat_segment_tree.hpp>
 #include <boost/noncopyable.hpp>
 
+class ScDocument;
 class ScColumn;
 class ScMarkData;
+class ScRange;
 
 namespace sc {
 
@@ -30,12 +32,22 @@ struct ColumnBlockConstPosition;
 class ColumnSpanSet : boost::noncopyable
 {
     typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
-    typedef std::vector<ColumnSpansType*> TableType;
+
+    struct ColumnType
+    {
+        ColumnSpansType maSpans;
+        ColumnSpansType::const_iterator miPos;
+
+        ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
+    };
+
+    typedef std::vector<ColumnType*> TableType;
     typedef std::vector<TableType*> DocType;
 
     DocType maDoc;
+    bool mbInit;
 
-    ColumnSpansType& getColumnSpans(SCTAB nTab, SCCOL nCol);
+    ColumnType& getColumn(SCTAB nTab, SCCOL nCol);
 
 public:
     class Action
@@ -46,12 +58,23 @@ public:
         virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
     };
 
+    class ColumnAction
+    {
+    public:
+        virtual ~ColumnAction() = 0;
+        virtual void startColumn(ScColumn* pCol) = 0;
+        virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
+    };
+
+    ColumnSpanSet(bool bInit);
     ~ColumnSpanSet();
 
     void set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
     void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
+    void set(const ScRange& rRange, bool bVal);
 
-    void executeFromTop(Action& ac) const;
+    void executeAction(Action& ac) const;
+    void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
 };
 
 /**
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 806fb77..4d41565 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -53,6 +53,7 @@ namespace sc {
     class StartListeningContext;
     class EndListeningContext;
     class CopyFromClipContext;
+    class ColumnSpanSet;
     struct ColumnBlockPosition;
 }
 class SvxFontItem;
@@ -228,6 +229,7 @@ friend class ScFormulaCell;
 friend class ScTable;
 friend struct ScRefCellValue;
 friend class ScDocumentImport;
+friend class sc::ColumnSpanSet;
 
     typedef ::std::vector<ScTable*> TableContainer;
 private:
@@ -1960,6 +1962,7 @@ public:
     void AddSubTotalCell(ScFormulaCell* pCell);
     void RemoveSubTotalCell(ScFormulaCell* pCell);
     void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
+    void MarkSubTotalCells( sc::ColumnSpanSet& rSet, const ScRange& rRange, bool bVal ) const;
 
     sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 03060bb..a8d5128 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -57,6 +57,7 @@ namespace sc {
     class CopyToClipContext;
     class CopyToDocContext;
     class MixDocContext;
+    class ColumnSpanSet;
     struct ColumnBlockPosition;
 }
 
@@ -203,6 +204,7 @@ friend class ScDocAttrIterator;
 friend class ScAttrRectIterator;
 friend class ScColumnTextWidthIterator;
 friend class ScDocumentImport;
+friend class sc::ColumnSpanSet;
 
 public:
                 ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
@@ -231,6 +233,8 @@ public:
     void        RemoveSubTotals( ScSubTotalParam& rParam );
     bool        DoSubTotals( ScSubTotalParam& rParam );
 
+    void MarkSubTotalCells( sc::ColumnSpanSet& rSet, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal ) const;
+
     const ScSheetEvents* GetSheetEvents() const              { return pSheetEvents; }
     void        SetSheetEvents( const ScSheetEvents* pNew );
 
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index aa82f4d1..2a59e7e 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -466,6 +466,33 @@ void ScColumn::ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark )
     }
 }
 
+namespace {
+
+class NumericCellCounter
+{
+    size_t mnCount;
+public:
+    NumericCellCounter() : mnCount(0) {}
+
+    void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize)
+    {
+        if (rNode.type != sc::element_type_numeric)
+            return;
+
+        mnCount += nDataSize;
+    }
+
+    size_t getCount() const { return mnCount; }
+};
+
+}
+
+size_t ScColumn::CountNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const
+{
+    NumericCellCounter aFunc;
+    rPos.miCellPos = sc::ParseBlock(rPos.miCellPos, maCells, aFunc, nRow1, nRow2);
+    return aFunc.getCount();
+}
 
 void ScColumn::ClearSelectionItems( const sal_uInt16* pWhich,const ScMarkData& rMark )
 {
@@ -2155,6 +2182,33 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
 
 namespace {
 
+class SubTotalCellPicker
+{
+    sc::ColumnSpanSet& mrSet;
+    SCTAB mnTab;
+    SCCOL mnCol;
+    bool mbVal;
+public:
+    SubTotalCellPicker(sc::ColumnSpanSet& rSet, SCTAB nTab, SCCOL nCol, bool bVal) :
+        mrSet(rSet), mnTab(nTab), mnCol(nCol), mbVal(bVal) {}
+
+    void operator() (size_t nRow, const ScFormulaCell* pCell)
+    {
+        if (pCell->IsSubTotal())
+            mrSet.set(mnTab, mnCol, nRow, mbVal);
+    }
+};
+
+}
+
+void ScColumn::MarkSubTotalCells( sc::ColumnSpanSet& rSet, SCROW nRow1, SCROW nRow2, bool bVal ) const
+{
+    SubTotalCellPicker aFunc(rSet, nTab, nCol, bVal);
+    sc::ParseFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
+}
+
+namespace {
+
 class UpdateRefOnCopy
 {
 protected:
diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx
index 8bfb7fc..f8c7813 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -10,6 +10,8 @@
 #include "columnspanset.hxx"
 #include "stlalgorithm.hxx"
 #include "column.hxx"
+#include "table.hxx"
+#include "document.hxx"
 #include "mtvfunctions.hxx"
 #include "markdata.hxx"
 #include "rangelst.hxx"
@@ -18,9 +20,16 @@
 
 namespace sc {
 
+ColumnSpanSet::ColumnType::ColumnType(SCROW nStart, SCROW nEnd, bool bInit) :
+    maSpans(nStart, nEnd+1, bInit), miPos(maSpans.begin()) {}
+
 ColumnSpanSet::Action::~Action() {}
 void ColumnSpanSet::Action::startColumn(SCTAB /*nTab*/, SCCOL /*nCol*/) {}
 
+ColumnSpanSet::ColumnAction::~ColumnAction() {}
+
+ColumnSpanSet::ColumnSpanSet(bool bInit) : mbInit(bInit) {}
+
 ColumnSpanSet::~ColumnSpanSet()
 {
     DocType::iterator itTab = maDoc.begin(), itTabEnd = maDoc.end();
@@ -30,12 +39,12 @@ ColumnSpanSet::~ColumnSpanSet()
         if (!pTab)
             continue;
 
-        std::for_each(pTab->begin(), pTab->end(), ScDeleteObjectByPtr<ColumnSpansType>());
+        std::for_each(pTab->begin(), pTab->end(), ScDeleteObjectByPtr<ColumnType>());
         delete pTab;
     }
 }
 
-ColumnSpanSet::ColumnSpansType& ColumnSpanSet::getColumnSpans(SCTAB nTab, SCCOL nCol)
+ColumnSpanSet::ColumnType& ColumnSpanSet::getColumn(SCTAB nTab, SCCOL nCol)
 {
     if (static_cast<size_t>(nTab) >= maDoc.size())
         maDoc.resize(nTab+1, NULL);
@@ -48,7 +57,7 @@ ColumnSpanSet::ColumnSpansType& ColumnSpanSet::getColumnSpans(SCTAB nTab, SCCOL
         rTab.resize(nCol+1, NULL);
 
     if (!rTab[nCol])
-        rTab[nCol] = new ColumnSpansType(0, MAXROW+1, false);
+        rTab[nCol] = new ColumnType(0, MAXROW, mbInit);
 
     return *rTab[nCol];
 }
@@ -58,8 +67,8 @@ void ColumnSpanSet::set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal)
     if (!ValidTab(nTab) || !ValidCol(nCol) || !ValidRow(nRow))
         return;
 
-    ColumnSpansType& rCol = getColumnSpans(nTab, nCol);
-    rCol.insert_back(nRow, nRow+1, bVal);
+    ColumnType& rCol = getColumn(nTab, nCol);
+    rCol.miPos = rCol.maSpans.insert(rCol.miPos, nRow, nRow+1, bVal).first;
 }
 
 void ColumnSpanSet::set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal)
@@ -67,11 +76,23 @@ void ColumnSpanSet::set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool b
     if (!ValidTab(nTab) || !ValidCol(nCol) || !ValidRow(nRow1) || !ValidRow(nRow2))
         return;
 
-    ColumnSpansType& rCol = getColumnSpans(nTab, nCol);
-    rCol.insert_back(nRow1, nRow2+1, bVal);
+    ColumnType& rCol = getColumn(nTab, nCol);
+    rCol.miPos = rCol.maSpans.insert(rCol.miPos, nRow1, nRow2+1, bVal).first;
 }
 
-void ColumnSpanSet::executeFromTop(Action& ac) const
+void ColumnSpanSet::set(const ScRange& rRange, bool bVal)
+{
+    for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
+    {
+        for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
+        {
+            ColumnType& rCol = getColumn(nTab, nCol);
+            rCol.miPos = rCol.maSpans.insert(rCol.miPos, rRange.aStart.Row(), rRange.aEnd.Row()+1, bVal).first;
+        }
+    }
+}
+
+void ColumnSpanSet::executeAction(Action& ac) const
 {
     for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
     {
@@ -85,8 +106,8 @@ void ColumnSpanSet::executeFromTop(Action& ac) const
                 continue;
 
             ac.startColumn(nTab, nCol);
-            ColumnSpansType& rCol = *rTab[nCol];
-            ColumnSpansType::const_iterator it = rCol.begin(), itEnd = rCol.end();
+            ColumnType& rCol = *rTab[nCol];
+            ColumnSpansType::const_iterator it = rCol.maSpans.begin(), itEnd = rCol.maSpans.end();
             SCROW nRow1, nRow2;
             nRow1 = it->first;
             bool bVal = it->second;
@@ -102,6 +123,49 @@ void ColumnSpanSet::executeFromTop(Action& ac) const
     }
 }
 
+void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const
+{
+    for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
+    {
+        if (!maDoc[nTab])
+            continue;
+
+        const TableType& rTab = *maDoc[nTab];
+        for (size_t nCol = 0; nCol < rTab.size(); ++nCol)
+        {
+            if (!rTab[nCol])
+                continue;
+
+            ScTable* pTab = rDoc.FetchTable(nTab);
+            if (!pTab)
+                continue;
+
+            if (!ValidCol(nCol))
+            {
+                // End the loop.
+                nCol = rTab.size();
+                continue;
+            }
+
+            ScColumn& rColumn = pTab->aCol[nCol];
+            ac.startColumn(&rColumn);
+            ColumnType& rCol = *rTab[nCol];
+            ColumnSpansType::const_iterator it = rCol.maSpans.begin(), itEnd = rCol.maSpans.end();
+            SCROW nRow1, nRow2;
+            nRow1 = it->first;
+            bool bVal = it->second;
+            for (++it; it != itEnd; ++it)
+            {
+                nRow2 = it->first-1;
+                ac.execute(nRow1, nRow2, bVal);
+
+                nRow1 = nRow2+1; // for the next iteration.
+                bVal = it->second;
+            }
+        }
+    }
+}
+
 namespace {
 
 class Scanner
diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx
index a165f97..b9b8d5f 100644
--- a/sc/source/core/data/documen6.cxx
+++ b/sc/source/core/data/documen6.cxx
@@ -194,7 +194,7 @@ sal_uInt8 ScDocument::GetRangeScriptType(
 
 sal_uInt8 ScDocument::GetRangeScriptType( const ScRangeList& rRanges )
 {
-    sc::ColumnSpanSet aSet;
+    sc::ColumnSpanSet aSet(false);
     for (size_t i = 0, n = rRanges.size(); i < n; ++i)
     {
         const ScRange& rRange = *rRanges[i];
@@ -206,7 +206,7 @@ sal_uInt8 ScDocument::GetRangeScriptType( const ScRangeList& rRanges )
     }
 
     ScriptTypeAggregator aAction(*this);
-    aSet.executeFromTop(aAction);
+    aSet.executeAction(aAction);
     return aAction.getScriptType();
 }
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9d3c72f..2920d99 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3538,8 +3538,7 @@ void ScDocument::AddTableOpFormulaCell( ScFormulaCell* pCell )
 void ScDocument::CalcAll()
 {
     ClearLookupCaches();    // Ensure we don't deliver zombie data.
-    bool bOldAutoCalc = GetAutoCalc();
-    SetAutoCalc( true );
+    sc::AutoCalcSwitch aSwitch(*this, true);
     TableContainer::iterator it = maTabs.begin();
     for (; it != maTabs.end(); ++it)
         if (*it)
@@ -3548,7 +3547,6 @@ void ScDocument::CalcAll()
         if (*it)
             (*it)->CalcAll();
     ClearFormulaTree();
-    SetAutoCalc( bOldAutoCalc );
 }
 
 
@@ -5925,6 +5923,19 @@ void ScDocument::SetSubTotalCellsDirty(const ScRange& rDirtyRange)
     maSubTotalCells.swap(aNewSet); // update the list.
 }
 
+void ScDocument::MarkSubTotalCells( sc::ColumnSpanSet& rSet, const ScRange& rRange, bool bVal ) const
+{
+    for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
+    {
+        const ScTable* pTab = FetchTable(nTab);
+        if (!pTab)
+            continue;
+
+        pTab->MarkSubTotalCells(
+            rSet, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), bVal);
+    }
+}
+
 sal_uInt16 ScDocument::GetTextWidth( const ScAddress& rPos ) const
 {
     SCTAB nTab = rPos.Tab();
diff --git a/sc/source/core/data/listenercontext.cxx b/sc/source/core/data/listenercontext.cxx
index 6f67920..dc92346 100644
--- a/sc/source/core/data/listenercontext.cxx
+++ b/sc/source/core/data/listenercontext.cxx
@@ -53,7 +53,7 @@ ColumnBlockPosition* StartListeningContext::getBlockPosition(SCTAB nTab, SCCOL n
 }
 
 EndListeningContext::EndListeningContext(ScDocument& rDoc) :
-    mrDoc(rDoc), mpPosSet(new ColumnBlockPositionSet(rDoc)) {}
+    mrDoc(rDoc), maSet(false), mpPosSet(new ColumnBlockPositionSet(rDoc)) {}
 
 ScDocument& EndListeningContext::getDoc()
 {
@@ -73,7 +73,7 @@ void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SC
 void EndListeningContext::purgeEmptyBroadcasters()
 {
     PurgeAction aAction(mrDoc);
-    maSet.executeFromTop(aAction);
+    maSet.executeAction(aAction);
 }
 
 }
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index eff2cd6..9971816 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -55,6 +55,7 @@
 #include "cellvalue.hxx"
 #include "tokenarray.hxx"
 #include "mtvcellfunc.hxx"
+#include "columnspanset.hxx"
 
 #include <vector>
 #include <boost/unordered_set.hpp>
@@ -1159,6 +1160,36 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam )
     return bSpaceLeft;
 }
 
+void ScTable::MarkSubTotalCells(
+    sc::ColumnSpanSet& rSet, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal ) const
+{
+    if (!ValidCol(nCol1) || !ValidCol(nCol2))
+        return;
+
+    // Pick up all subtotal formula cells.
+    for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+        aCol[nCol].MarkSubTotalCells(rSet, nRow1, nRow2, bVal);
+
+    // Pick up all filtered rows.
+    ScFlatBoolRowSegments::RangeData aFilteredSpan;
+    SCROW nRow = nRow1;
+    while (nRow <= nRow2)
+    {
+        if (!mpFilteredRows->getRangeData(nRow, aFilteredSpan))
+            // Failed for whatever reason.
+            return;
+
+        if (aFilteredSpan.mbValue)
+        {
+            // Filtered span found.
+            for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+                rSet.set(nTab, nCol, nRow, aFilteredSpan.mnRow2, bVal);
+        }
+
+        nRow = aFilteredSpan.mnRow2 + 1;
+    }
+}
+
 namespace {
 
 class QueryEvaluator
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index a88b542..643a0aa 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -58,6 +58,8 @@
 #include "queryparam.hxx"
 #include "queryentry.hxx"
 #include "tokenarray.hxx"
+#include "columnspanset.hxx"
+#include "column.hxx"
 
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
@@ -4274,11 +4276,188 @@ void ScInterpreter::ScAverage( bool bTextAsZero )
     PushDouble( IterateParameters( ifAVERAGE, bTextAsZero ) );
 }
 
+namespace {
+
+class FuncCount : public sc::ColumnSpanSet::ColumnAction
+{
+    sc::ColumnBlockConstPosition maPos;
+    ScColumn* mpCol;
+    size_t mnCount;
+    sal_uInt32 mnNumFmt;
+
+public:
+    FuncCount() : mnCount(0), mnNumFmt(0) {}
+
+    virtual void startColumn(ScColumn* pCol)
+    {
+        mpCol = pCol;
+        mpCol->InitBlockPosition(maPos);
+    }
+
+    virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal)
+    {
+        if (!bVal)
+            return;
+
+        mnCount += mpCol->CountNumericCells(maPos, nRow1, nRow2);
+        mnNumFmt = mpCol->GetNumberFormat(nRow2);
+    };
+
+    size_t getCount() const { return mnCount; }
+    sal_uInt32 getNumberFormat() const { return mnNumFmt; }
+};
+
+}
 
 void ScInterpreter::ScCount()
 {
-    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScCount" );
-    PushDouble( IterateParameters( ifCOUNT ) );
+    short nParamCount = GetByte();
+    double fVal = 0.0;
+    sal_uLong nCount = 0;
+    ScAddress aAdr;
+    ScRange aRange;
+    size_t nRefInList = 0;
+    if (nGlobalError)
+        nGlobalError = 0;
+
+    while (nParamCount-- > 0)
+    {
+        switch (GetStackType())
+        {
+            case svString:
+            {
+                String aStr( PopString() );
+                sal_uInt32 nFIndex = 0;                 // damit default Land/Spr.
+                if (pFormatter->IsNumberFormat(aStr, nFIndex, fVal))
+                    nCount++;
+            }
+            break;
+            case svDouble    :
+                nCount++;
+                nFuncFmtType = NUMBERFORMAT_NUMBER;
+                break;
+            case svExternalSingleRef:
+            {
+                ScExternalRefCache::TokenRef pToken;
+                ScExternalRefCache::CellFormat aFmt;
+                PopExternalSingleRef(pToken, &aFmt);
+                if (nGlobalError)
+                {
+                    nGlobalError = 0;
+                    break;
+                }
+
+                if (!pToken)
+                    break;
+
+                StackVar eType = pToken->GetType();
+                if (eType == formula::svDouble)
+                {
+                    nCount++;
+                    if (aFmt.mbIsSet)
+                    {
+                        nFuncFmtType = aFmt.mnType;
+                        nFuncFmtIndex = aFmt.mnIndex;
+                    }
+
+                    if (nGlobalError)
+                    {
+                        nGlobalError = 0;
+                        nCount--;
+                    }
+                }
+            }
+            break;
+            case svSingleRef :
+            {
+                PopSingleRef( aAdr );
+                if (nGlobalError)
+                {
+                    nGlobalError = 0;
+                    break;
+                }
+                if (glSubTotal && pDok->RowFiltered( aAdr.Row(), aAdr.Tab()))
+                {
+                    break;
+                }
+                ScRefCellValue aCell;
+                aCell.assign(*pDok, aAdr);
+                if (!aCell.isEmpty())
+                {
+                    if (aCell.hasNumeric())
+                    {
+                        nCount++;
+                        CurFmtToFuncFmt();
+                        if (nGlobalError)
+                        {
+                            nGlobalError = 0;
+                            nCount--;
+                        }
+                    }
+                }
+            }
+            break;
+            case svDoubleRef :
+            case svRefList :
+            {
+                PopDoubleRef( aRange, nParamCount, nRefInList);
+                if (nGlobalError)
+                {
+                    nGlobalError = 0;
+                    break;
+                }
+
+                sc::ColumnSpanSet aSet(false);
+                aSet.set(aRange, true);
+                if (glSubTotal)
+                    // Skip all filtered rows and subtotal formula cells.
+                    pDok->MarkSubTotalCells(aSet, aRange, false);
+
+                FuncCount aAction;
+                aSet.executeColumnAction(*pDok, aAction);
+                nCount = aAction.getCount();
+
+                // Get the number format of the last iterated cell.
+                nFuncFmtIndex = aAction.getNumberFormat();
+                nFuncFmtType = pDok->GetFormatTable()->GetType(nFuncFmtIndex);
+            }
+            break;
+            case svExternalDoubleRef:
+            {
+                ScMatrixRef pMat;
+                PopExternalDoubleRef(pMat);
+                if (nGlobalError)
+                    break;
+
+                double fMem = 0.0, fRes = 0.0;
+                bool bNull = true;
+                IterateMatrix(pMat, ifCOUNT, false, nCount, nFuncFmtType, fRes, fMem, bNull);
+            }
+            break;
+            case svMatrix :
+            {
+                ScMatrixRef pMat = PopMatrix();
+                double fMem = 0.0, fRes = 0.0;
+                bool bNull = true;
+                IterateMatrix(pMat, ifCOUNT, false, nCount, nFuncFmtType, fRes, fMem, bNull);
+            }
+            break;
+            case svError:
+            {
+                PopError();
+                nGlobalError = 0;
+            }
+            break;
+            default :
+                while (nParamCount-- > 0)
+                    PopError();
+                SetError(errIllegalParameter);
+        }
+    }
+
+    nFuncFmtType = NUMBERFORMAT_NUMBER;
+
+    PushDouble(nCount);
 }
 
 
commit db377e02c309c20419aef1360409be09fe50fc42
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Tue Jul 2 12:23:38 2013 +0400

    gtk3: Clearlooks theme paints scrollbar buttons depending on the style class
    
    Change-Id: I8e464e4b71671eccb2c0467d74542e6ddda0f5a6

diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index fd4282f..98da944 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -266,6 +266,8 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
     gdouble          arrow1Angle;                                        // backward
     gdouble          arrow2Angle;                                        // forward
     Rectangle        arrowRect;
+    const gchar*     button1StyleClass = NULL;
+    const gchar*     button2StyleClass = NULL;
     gint            slider_width = 0;
     gint            stepper_size = 0;
     gint            stepper_spacing = 0;
@@ -319,6 +321,8 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
         scrollbarOrientation = GTK_ORIENTATION_HORIZONTAL;
         arrow1Angle = G_PI * 3 / 2;
         arrow2Angle = G_PI / 2;
+        button1StyleClass = GTK_STYLE_CLASS_LEFT;
+        button2StyleClass = GTK_STYLE_CLASS_RIGHT;
 
         if ( has_backward )
         {
@@ -359,6 +363,8 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
         scrollbarOrientation = GTK_ORIENTATION_VERTICAL;
         arrow1Angle = 0;
         arrow2Angle = G_PI;
+        button1StyleClass = GTK_STYLE_CLASS_TOP;
+        button2StyleClass = GTK_STYLE_CLASS_BOTTOM;
 
         if ( has_backward )
         {
@@ -434,6 +440,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
         gtk_style_context_save(context);
         gtk_style_context_set_state(context, stateFlags);
         gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+        gtk_style_context_add_class(context, button1StyleClass);
 
         gtk_render_background(context, cr,
                               button11BoundRect.Left(), button11BoundRect.Top(),
@@ -460,6 +467,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
         gtk_style_context_save(context);
         gtk_style_context_set_state(context, stateFlags);
         gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+        gtk_style_context_add_class(context, button1StyleClass);
 
         gtk_render_background(context, cr,
                               button12BoundRect.Left(), button12BoundRect.Top(),
@@ -487,6 +495,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
         gtk_style_context_save(context);
         gtk_style_context_set_state(context, stateFlags);
         gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+        gtk_style_context_add_class(context, button2StyleClass);
 
         gtk_render_background(context, cr,
                               button21BoundRect.Left(), button21BoundRect.Top(),
@@ -513,6 +522,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
         gtk_style_context_save(context);
         gtk_style_context_set_state(context, stateFlags);
         gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+        gtk_style_context_add_class(context, button2StyleClass);
 
         gtk_render_background(context, cr,
                        button22BoundRect.Left(), button22BoundRect.Top(),
commit 010391b647f15efbeeba4e1a8158ab6dd550aa6b
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Tue Jul 2 12:06:13 2013 +0400

    gtk3: gtk_vscrollbar_new is deprecated, use gtk_scrollbar_new
    
    Change-Id: Iea6b6cd0147e42eab9889ea9a45aaf98c77cfaab

diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 912e27e..d75e9dc 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -61,7 +61,8 @@ private:
     GtkWidget       *mpWindow;
     static GtkStyleContext *mpButtonStyle;
     static GtkStyleContext *mpEntryStyle;
-    static GtkStyleContext *mpScrollbarStyle;
+    static GtkStyleContext *mpVScrollbarStyle;
+    static GtkStyleContext *mpHScrollbarStyle;
     static GtkStyleContext *mpToolbarStyle;
     static GtkStyleContext *mpToolButtonStyle;
     static GtkStyleContext *mpCheckButtonStyle;
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 350d1e9..fd4282f 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -18,7 +18,8 @@
 
 GtkStyleContext* GtkSalGraphics::mpButtonStyle = NULL;
 GtkStyleContext* GtkSalGraphics::mpEntryStyle = NULL;
-GtkStyleContext* GtkSalGraphics::mpScrollbarStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpVScrollbarStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpHScrollbarStyle = NULL;
 GtkStyleContext* GtkSalGraphics::mpToolbarStyle = NULL;
 GtkStyleContext* GtkSalGraphics::mpToolButtonStyle = NULL;
 GtkStyleContext* GtkSalGraphics::mpCheckButtonStyle = NULL;
@@ -160,13 +161,19 @@ Rectangle GtkSalGraphics::NWGetSpinButtonRect( ControlPart nPart, Rectangle aAre
 
 Rectangle GtkSalGraphics::NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect )
 {
+    GtkStyleContext* pScrollbarStyle = NULL;
+    if ((nPart == PART_BUTTON_LEFT) || (nPart == PART_BUTTON_RIGHT))
+        pScrollbarStyle = mpHScrollbarStyle;
+    else // (nPart == PART_BUTTON_UP) || (nPart == PART_BUTTON_DOWN)
+        pScrollbarStyle = mpVScrollbarStyle;
+
     gint slider_width;
     gint stepper_size;
     gint stepper_spacing;
     gint trough_border;
 
     // Grab some button style attributes
-    gtk_style_context_get_style( mpScrollbarStyle,
+    gtk_style_context_get_style( pScrollbarStyle,
                                  "slider-width", &slider_width,
                                  "stepper-size", &stepper_size,
                                  "trough-border", &trough_border,
@@ -177,7 +184,7 @@ Rectangle GtkSalGraphics::NWGetScrollButtonRect( ControlPart nPart, Rectangle aA
     gboolean has_backward;
     gboolean has_backward2;
 
-    gtk_style_context_get_style( mpScrollbarStyle,
+    gtk_style_context_get_style( pScrollbarStyle,
                                  "has-forward-stepper", &has_forward,
                                  "has-secondary-forward-stepper", &has_forward2,
                                  "has-backward-stepper", &has_backward,
@@ -281,7 +288,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
         return;
 
     // Grab some button style attributes
-    gtk_style_context_get_style( mpScrollbarStyle,
+    gtk_style_context_get_style( context,
                                  "slider_width", &slider_width,
                                  "stepper_size", &stepper_size,
                                  "trough_border", &trough_border,
@@ -292,7 +299,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
     gboolean has_backward;
     gboolean has_backward2;
 
-    gtk_style_context_get_style( mpScrollbarStyle,
+    gtk_style_context_get_style( context,
                                  "has-forward-stepper", &has_forward,
                                  "has-secondary-forward-stepper", &has_forward2,
                                  "has-backward-stepper", &has_backward,
@@ -875,7 +882,8 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
         {
         case PART_DRAW_BACKGROUND_VERT:
         case PART_DRAW_BACKGROUND_HORZ:
-            context = mpScrollbarStyle;
+            context = (nPart == PART_DRAW_BACKGROUND_VERT)
+                ? mpVScrollbarStyle : mpHScrollbarStyle;
             renderType = RENDER_SCROLLBAR;
             break;
         }
@@ -1388,7 +1396,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     gint min_slider_length = 21;
 
     // Grab some button style attributes
-    gtk_style_context_get_style( mpScrollbarStyle,
+    gtk_style_context_get_style( mpVScrollbarStyle,
                                  "slider-width", &slider_width,
                                  "trough-border", &trough_border,
                                  "min-slider-length", &min_slider_length,
@@ -1499,8 +1507,10 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
     gtk_style_context_set_path(mpToolButtonStyle, path);
     gtk_widget_path_free (path);
 
-    getStyleContext(&mpScrollbarStyle, gtk_vscrollbar_new(NULL));
-    gtk_style_context_add_class(mpScrollbarStyle, GTK_STYLE_CLASS_SCROLLBAR);
+    getStyleContext(&mpVScrollbarStyle, gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL));
+    gtk_style_context_add_class(mpVScrollbarStyle, GTK_STYLE_CLASS_SCROLLBAR);
+    getStyleContext(&mpHScrollbarStyle, gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL));
+    gtk_style_context_add_class(mpHScrollbarStyle, GTK_STYLE_CLASS_SCROLLBAR);
 
     getStyleContext(&mpCheckButtonStyle, gtk_check_button_new());
 
commit eb39f90f071c03f8f9e61a0f129a060ffcfb96eb
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jul 2 17:24:49 2013 +0100

    Related: fdo#66252 RID_SVXPAGE_NUMBERFORMAT needs a layout parent
    
    Change-Id: I25f87916e5b8480e50cafb30b78da4d575a7df24

diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx
index 7a595ca..348f667 100644
--- a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx
+++ b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx
@@ -40,15 +40,15 @@ namespace chart
 using namespace ::com::sun::star;
 
 NumberFormatDialog::NumberFormatDialog(Window* pParent, SfxItemSet& rSet)
-    : SfxNoLayoutSingleTabDialog( pParent, rSet, 0 )
+    : SfxSingleTabDialog(pParent, rSet)
 {
     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
     ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT );
     if ( fnCreatePage )
     {
-        SfxTabPage* pTabPage = (*fnCreatePage)( this, rSet );
+        SfxTabPage* pTabPage = (*fnCreatePage)( get_content_area(), rSet );
         pTabPage->PageCreated(rSet);
-        SetTabPage(pTabPage);
+        setTabPage(pTabPage);
     }
 }
 
diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.hxx b/chart2/source/controller/dialogs/dlg_NumberFormat.hxx
index 31535dd..c574608 100644
--- a/chart2/source/controller/dialogs/dlg_NumberFormat.hxx
+++ b/chart2/source/controller/dialogs/dlg_NumberFormat.hxx
@@ -29,7 +29,7 @@ namespace chart
 {
 //.............................................................................
 
-class NumberFormatDialog : public SfxNoLayoutSingleTabDialog
+class NumberFormatDialog : public SfxSingleTabDialog
 {
 public:
      NumberFormatDialog(Window* pParent, SfxItemSet& rSet);
commit 092281f1e7022ee26e3659cc1c54ac0dd73a4382
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jul 2 17:11:40 2013 +0100

    Resolves: fdo#66252 format->number for controls is busted
    
    Change-Id: I7c88f3acd9a6c5faa40a8fedc7c9f6e7817cefb7

diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index e35dfd7..e29b892 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -2716,20 +2716,20 @@ namespace pcr
             aCoreSet.Put( aFormatter );
 
             // a tab dialog with a single page
-            ::std::auto_ptr< SfxNoLayoutSingleTabDialog > pDialog( new SfxNoLayoutSingleTabDialog( impl_getDefaultDialogParent_nothrow(), aCoreSet, 0 ) );
+            boost::scoped_ptr< SfxSingleTabDialog > xDialog(new SfxSingleTabDialog(impl_getDefaultDialogParent_nothrow(), aCoreSet));
             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
             DBG_ASSERT( pFact, "CreateFactory fail!" );
             ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT );
             if ( !fnCreatePage )
                 throw RuntimeException();   // caught below
 
-            SfxTabPage* pPage = (*fnCreatePage)( pDialog.get(), aCoreSet );
-            pDialog->SetTabPage( pPage );
+            SfxTabPage* pPage = (*fnCreatePage)( xDialog->get_content_area(), aCoreSet );
+            xDialog->setTabPage( pPage );
 
             _rClearBeforeDialog.clear();
-            if ( RET_OK == pDialog->Execute() )
+            if ( RET_OK == xDialog->Execute() )
             {
-                const SfxItemSet* pResult = pDialog->GetOutputItemSet();
+                const SfxItemSet* pResult = xDialog->GetOutputItemSet();
 
                 const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
                 const SvxNumberInfoItem* pInfoItem = dynamic_cast< const SvxNumberInfoItem* >( pItem );
commit 7b3839e0c3d9339b4469a808e2818cd3f3119cc4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jul 2 16:03:55 2013 +0100

    vertically align center widgets
    
    Change-Id: Iedd7fc4e05aa59e59725f2087ded704aae0b6115

diff --git a/sw/uiconfig/swriter/ui/insertfootnote.ui b/sw/uiconfig/swriter/ui/insertfootnote.ui
index e23e9af..5a836a9 100644
--- a/sw/uiconfig/swriter/ui/insertfootnote.ui
+++ b/sw/uiconfig/swriter/ui/insertfootnote.ui
@@ -138,6 +138,7 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
+                            <property name="valign">center</property>
                             <property name="xalign">0</property>
                             <property name="active">True</property>
                             <property name="draw_indicator">True</property>
@@ -156,6 +157,7 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
+                            <property name="valign">center</property>
                             <property name="xalign">0</property>
                             <property name="draw_indicator">True</property>
                             <property name="group">automatic</property>
@@ -175,6 +177,7 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="halign">start</property>
+                            <property name="valign">center</property>
                             <property name="invisible_char">•</property>
                             <property name="width_chars">2</property>
                             <property name="progress_fraction">0.0099999997764825821</property>
@@ -202,6 +205,7 @@
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="halign">start</property>
+                            <property name="valign">center</property>
                           </object>
                           <packing>
                             <property name="left_attach">2</property>
@@ -261,6 +265,7 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
+                            <property name="valign">center</property>
                             <property name="xalign">0</property>
                             <property name="active">True</property>
                             <property name="draw_indicator">True</property>
@@ -278,6 +283,7 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
+                            <property name="valign">center</property>
                             <property name="xalign">0</property>
                             <property name="draw_indicator">True</property>
                             <property name="group">footnote</property>
commit d37723a2496907bf60829306c6509fe24a9c4dbe
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Tue Jul 2 17:00:57 2013 +0200

    Allow build with older boost
    
    Change-Id: I49902109eb2a1b9561a9ccfa70d89c160a4965a9

diff --git a/libvisio/UnpackedTarball_libvisio.mk b/libvisio/UnpackedTarball_libvisio.mk
index f71161a..7e9ce61 100644
--- a/libvisio/UnpackedTarball_libvisio.mk
+++ b/libvisio/UnpackedTarball_libvisio.mk
@@ -11,5 +11,8 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,libvisio))
 
 $(eval $(call gb_UnpackedTarball_set_tarball,libvisio,$(VISIO_TARBALL)))
 
+$(eval $(call gb_UnpackedTarball_add_patches,libvisio,\
+	libvisio/libvisio-0.0.29-remove_whitespace.patch.1 \
+))
 
 # vim: set noet sw=4 ts=4:
diff --git a/libvisio/libvisio-0.0.29-remove_whitespace.patch.1 b/libvisio/libvisio-0.0.29-remove_whitespace.patch.1
new file mode 100644
index 0000000..b8f1eb4
--- /dev/null
+++ b/libvisio/libvisio-0.0.29-remove_whitespace.patch.1
@@ -0,0 +1,20 @@
+--- a/src/lib/libvisio_utils.cpp
++++ b/src/lib/libvisio_utils.cpp
+@@ -33,7 +33,6 @@
+ #include "libvisio_utils.h"
+ 
+ #include <boost/archive/iterators/binary_from_base64.hpp>
+-#include <boost/archive/iterators/remove_whitespace.hpp>
+ #include <boost/archive/iterators/transform_width.hpp>
+ 
+ uint8_t libvisio::readU8(WPXInputStream *input)
+@@ -126,8 +125,7 @@ double libvisio::readDouble(WPXInputStream *input)
+ void libvisio::appendFromBase64(WPXBinaryData &data, const unsigned char *base64String, size_t base64StringLength)
+ {
+   typedef boost::archive::iterators::transform_width<
+-  boost::archive::iterators::binary_from_base64<
+-  boost::archive::iterators::remove_whitespace< const char * > >, 8, 6 > base64_decoder;
++  boost::archive::iterators::binary_from_base64< const char * >, 8, 6 > base64_decoder;
+ 
+   std::vector<unsigned char> buffer;
+   std::copy(base64_decoder(base64String), base64_decoder(base64String + base64StringLength), std::back_inserter(buffer));
commit 3835dee3c777bf10693903cb0866d22fab3794ea
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Jun 30 21:18:45 2013 +0200

    SvStream: remove the error prone operator<</>>(sal_Int64)
    
    As the recent regression after merging AOO patch adding code serializing
    "long" variables has shown, this overload (which was added in
    7b2a0e541567be9750dfc7d98374555967da3470) is a bad idea.
    
    In a unxlngx build, nm finds uses of the symbols _ZN8SvStreamrsERl
    and _ZN8SvStreamlsEl in these files:
    
    - sbxvalue.cxx: this appears to be a legitimate use with sal_Int64
    
    - dateitem.cxx: this was accidentally changed by commit
      9830fd36dbdb72c79703b0c61efc027fba793c5a
    
    - atrfrm.cxx: this was added for Table Autoformat enhancement in
      7e8c0bd73ee59ff3041e55268c77203373962e51, which is after the
      sal_Int64 operators were added, so the file format is now
      platform dependent
    
    Change-Id: I78352b5429b53612c4831cdb81b587b5de5180a9

diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index f0ea5d1..3efbdab 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -1449,9 +1449,8 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
             break;
         }
         //#fdo39428 SvStream no longer supports operator>>(long&)
-        //SvStream now has operator>>(sal_Int64&)
         case SbxSALINT64:
-            r >> aData.nInt64;
+            r.ReadInt64(aData.nInt64);
             break;
         case SbxSALUINT64:
             r >> aData.uInt64;
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 3d9f363..8aed53c 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -304,7 +304,8 @@ public:
     SvStream&       operator>>( sal_uInt64& rUInt64 );
     SvStream&       operator>>( sal_Int16& rInt16 );
     SvStream&       operator>>( sal_Int32& rInt32 );
-    SvStream&       operator>>( sal_Int64& rInt64 );
+    SvStream&       operator>>( sal_Int64& rInt64 ) SAL_DELETED_FUNCTION;
+    SvStream&       ReadInt64(sal_Int64 & rInt64);
 
     SvStream&       operator>>( signed char& rChar );
     SvStream&       operator>>( char& rChar );
@@ -318,7 +319,8 @@ public:
     SvStream&       operator<<( sal_uInt64 nuInt64 );
     SvStream&       operator<<( sal_Int16 nInt16 );
     SvStream&       operator<<( sal_Int32 nInt32 );
-    SvStream&       operator<<( sal_Int64 nInt64 );
+    SvStream&       operator<<( sal_Int64 nInt64 ) SAL_DELETED_FUNCTION;
+    SvStream&       WriteInt64(sal_Int64 nInt64);
 
     SvStream&       operator<<( bool b )
                         { return operator<<(static_cast< sal_Bool >(b)); }
diff --git a/svl/source/items/dateitem.cxx b/svl/source/items/dateitem.cxx
index 54e942e..67ebba6 100644
--- a/svl/source/items/dateitem.cxx
+++ b/svl/source/items/dateitem.cxx
@@ -102,7 +102,7 @@ SvStream& SfxDateTimeItem::Store( SvStream& rStream, sal_uInt16 ) const
 {
     DBG_CHKTHIS(SfxDateTimeItem, 0);
     rStream << aDateTime.GetDate();
-    rStream << aDateTime.GetTime();
+    rStream << static_cast<sal_Int32>(aDateTime.GetTime());
     return rStream;
 }
 
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 63ae22e..7677acc 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -1170,16 +1170,30 @@ bool SwFmtSurround::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
 
 SvStream& SwFmtVertOrient::Store(SvStream &rStream, sal_uInt16 /*version*/) const
 {
-    rStream << nYPos << eOrient << eRelation;
+#if SAL_TYPES_SIZEOFLONG == 8
+    rStream.WriteInt64(nYPos);
+#else
+    rStream << static_cast<sal_Int32>(nYPos);
+#endif
+    rStream << eOrient << eRelation;
     return rStream;
 }
 
 SfxPoolItem* SwFmtVertOrient::Create(SvStream &rStream, sal_uInt16 /*itemVersion*/) const
 {
-    SwTwips yPos;
-    sal_Int16 orient;
-    sal_Int16 relation;
-    rStream >> yPos >> orient >> relation;
+    SwTwips yPos(0);
+    sal_Int16 orient(0);
+    sal_Int16 relation(0);
+    // compatibility hack for Table Auto Format: SwTwips is "long" :(
+    // (this means that the file format is platform dependent)
+#if SAL_TYPES_SIZEOFLONG == 8
+    rStream.ReadInt64(yPos);
+#else
+    sal_Int32 n;
+    rStream >> n;
+    yPos = n;
+#endif
+    rStream >> orient >> relation;
 
     return new SwFmtVertOrient(yPos, orient, relation);
 }
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index ede47ed..a3053a9 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -954,7 +954,7 @@ SvStream& SvStream::operator>>(sal_Int32& r)
     return *this;
 }
 
-SvStream& SvStream::operator>>(sal_Int64& r)
+SvStream& SvStream::ReadInt64(sal_Int64& r)
 {
     sal_Int64 n = 0;
     READNUMBER_WITHOUT_SWAP(sal_Int64, n)
@@ -1099,7 +1099,7 @@ SvStream& SvStream::operator<<  ( sal_Int32 v )
     return *this;
 }
 
-SvStream& SvStream::operator<<  ( sal_Int64 v )
+SvStream& SvStream::WriteInt64  (sal_Int64 v)
 {
     if( bSwap )
         SwapInt64(v);
commit ee5ed806e2cf5780f90d52a2fc83055f497139b7
Author: Philipp Weissenbacher <p.weissenbacher at gmail.com>
Date:   Mon Jul 1 19:57:01 2013 +0200

    Translate German comments, fix some WS
    
    Change-Id: Ib017480e45cf76a95297e6563229d49c13ea6a51
    Reviewed-on: https://gerrit.libreoffice.org/4660
    Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat at free.fr>
    Tested-by: Bosdonnat Cedric <cedric.bosdonnat at free.fr>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 765b0f3..67267bb 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -97,7 +97,7 @@
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <com/sun/star/document/XViewDataSupplier.hpp>
 #include <com/sun/star/document/IndexedPropertyValues.hpp>
-#include <svl/itemiter.hxx>  //SfxItemIter
+#include <svl/itemiter.hxx>     //SfxItemIter
 
 #include <comphelper/processfactory.hxx>
 #include <basic/basmgr.hxx>
@@ -465,16 +465,16 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
         {
             SfxItemSet aSet( pSdrModel->GetItemPool() );
 
-            //Originally anything that as a mso_sptTextBox was created as a
-            //textbox, this was changed to be created as a simple
-            //rect to keep impress happy. For the rest of us we'd like to turn
-            //it back into a textbox again.
+            // Originally anything that as a mso_sptTextBox was created as a
+            // textbox, this was changed to be created as a simple
+            // rect to keep impress happy. For the rest of us we'd like to turn
+            // it back into a textbox again.
             bool bIsSimpleDrawingTextBox = (pImpRec->eShapeType == mso_sptTextBox);
             if (!bIsSimpleDrawingTextBox)
             {
-                //Either
-                //a) its a simple text object or
-                //b) its a rectangle with text and square wrapping.
+                // Either
+                // a) its a simple text object or
+                // b) its a rectangle with text and square wrapping.
                 bIsSimpleDrawingTextBox =
                 (
                     (pImpRec->eShapeType == mso_sptTextSimple) ||
@@ -638,7 +638,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
             pImpRec->nDxTextRight   = nTextRight;
             pImpRec->nDyTextBottom  = nTextBottom;
 
-            // taking the correct default (which is mso_anchorTop)
+            // Taking the correct default (which is mso_anchorTop)
             MSO_Anchor eTextAnchor =
                 (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
 
@@ -771,7 +771,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
             pObj->SetMergedItemSet(aSet);
         }
 
-        //Means that fBehindDocument is set
+        // Means that fBehindDocument is set
         if (GetPropertyValue(DFF_Prop_fPrint) & 0x20)
             pImpRec->bDrawHell = sal_True;
         else
@@ -921,9 +921,9 @@ SwFltStackEntry* SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt1
     sal_Bool bTstEnde, long nHand, sal_Bool )
 {
     SwFltStackEntry *pRet = NULL;
-    //Doing a textbox, and using the control stack only as a temporary
-    //collection point for properties which will are not to be set into
-    //the real document
+    // Doing a textbox, and using the control stack only as a temporary
+    // collection point for properties which will are not to be set into
+    // the real document
     if (rReader.pPlcxMan && rReader.pPlcxMan->GetDoingDrawTextBox())
     {
         size_t nCnt = size();
@@ -937,7 +937,7 @@ SwFltStackEntry* SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt1
             }
         }
     }
-    else //Normal case, set the attribute into the document
+    else // Normal case, set the attribute into the document
         pRet = SwFltControlStack::SetAttr(rPos, nAttrId, bTstEnde, nHand);
     return pRet;
 }
@@ -1043,7 +1043,10 @@ bool SwWW8FltControlStack::IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool b
     return rReader.IsParaEndInCPs(nStart,nEnd,bSdOD);
 }
 
-//Clear the para end position recorded in reader intermittently for the least impact on loading performance
+/**
+ * Clear the para end position recorded in reader intermittently
+ * for the least impact on loading performance.
+ */
 void SwWW8FltControlStack::ClearParaEndPosition()
 {
     if ( !empty() )
@@ -1065,11 +1068,11 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
         case RES_LR_SPACE:
             {
                 /*
-                 Loop over the affect nodes and
+                 Loop over the affected nodes and
                  a) convert the word style absolute indent to indent relative
-                  to any numbering indent active on the nodes
+                    to any numbering indent active on the nodes
                  b) adjust the writer style tabstops relative to the old
-                  paragraph indent to be relative to the new paragraph indent
+                    paragraph indent to be relative to the new paragraph indent
                 */
                 using namespace sw::util;
                 SwPaM aRegion(rTmpPos);
@@ -1130,9 +1133,9 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
                 if (rEntry.MakeRegion(pDoc, aRegion, false))
                 {
                     SwFrmFmt *pFrm;
-                    //If we have just one single inline graphic then
-                    //don't insert a field for the single frame, set
-                    //the frames hyperlink field attribute directly.
+                    // If we have just one single inline graphic then
+                    // don't insert a field for the single frame, set
+                    // the frames hyperlink field attribute directly.
                     if (0 != (pFrm = rReader.ContainsSingleInlineGraphic(aRegion)))
                     {
                         const SwFmtINetFmt *pAttr = (const SwFmtINetFmt *)
@@ -1339,30 +1342,30 @@ void SwWW8ImplReader::Read_Tab(sal_uInt16 , const sal_uInt8* pData, short nLen)
     short nRequiredLength = 2 + 2*nDel + 2*nIns + 1*nIns;
     if (nRequiredLength > nLen)
     {
-        //would require more data than available to describe!, discard invalid
-        //record
+        // would require more data than available to describe!
+        // discard invalid record
         nIns = 0;
         nDel = 0;
     }
 
-    WW8_TBD* pTyp = (WW8_TBD*)(pData + 2*nDel + 2*nIns + 2);// Typ - Array
+    WW8_TBD* pTyp = (WW8_TBD*)(pData + 2*nDel + 2*nIns + 2); // Type Array
 
     SvxTabStopItem aAttr(0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP);
 
     const SwTxtFmtColl* pSty = 0;
     sal_uInt16 nTabBase;
-    if (pAktColl && nAktColl < vColl.size())               // StyleDef
+    if (pAktColl && nAktColl < vColl.size()) // StyleDef
     {
         nTabBase = vColl[nAktColl].nBase;
-        if (nTabBase < vColl.size())              // Based On
+        if (nTabBase < vColl.size())  // Based On
             pSty = (const SwTxtFmtColl*)vColl[nTabBase].pFmt;
     }
     else
-    {                                       // Text
+    { // Text
         nTabBase = nAktColl;
         if (nAktColl < vColl.size())
             pSty = (const SwTxtFmtColl*)vColl[nAktColl].pFmt;
-        //TODO figure else here
+        //TODO: figure out else here
     }
 
     bool bFound = false;
@@ -1460,14 +1463,14 @@ void SwWW8ImplReader::Read_Tab(sal_uInt16 , const sal_uInt8* pData, short nLen)
         NewAttr(aAttr);
     else
     {
-        //Here we have a tab definition which inserts no extra tabs, or deletes
-        //no existing tabs. An older version of writer is probably the creater
-        //of the document  :-( . So if we are importing a style we can just
-        //ignore it. But if we are importing into text we cannot as during
-        //text SwWW8ImplReader::Read_Tab is called at the begin and end of
-        //the range the attrib affects, and ignoring it would upset the
-        //balance
-        if (!pAktColl)  //not importing into a style
+        // Here we have a tab definition which inserts no extra tabs, or deletes
+        // no existing tabs. An older version of writer is probably the creater
+        // of the document  :-( . So if we are importing a style we can just
+        // ignore it. But if we are importing into text we cannot as during
+        // text SwWW8ImplReader::Read_Tab is called at the begin and end of
+        // the range the attrib affects, and ignoring it would upset the
+        // balance
+        if (!pAktColl) // not importing into a style
         {
             using namespace sw::util;
             SvxTabStopItem aOrig = pSty ?
@@ -1587,7 +1590,7 @@ void SwWW8ImplReader::ImportDop()
     // COMPATIBILITY FLAGS END
     //
 
-    //import magic doptypography information, if its there
+    // Import magic doptypography information, if its there
     if (pWwFib->nFib > 105)
         ImportDopTypography(pWDop->doptypography);
 
@@ -1627,14 +1630,14 @@ void SwWW8ImplReader::ImportDopTypography(const WW8DopTypography &rTypo)
     using namespace com::sun::star;
     switch (rTypo.iLevelOfKinsoku)
     {
-        case 2: //custom
+        case 2: // custom
             {
                 i18n::ForbiddenCharacters aForbidden(rTypo.rgxchFPunct,
                     rTypo.rgxchLPunct);
                 rDoc.setForbiddenCharacters(rTypo.GetConvertedLang(),
                         aForbidden);
-                //Obviously cannot set the standard level 1 for japanese, so
-                //bail out now while we can.
+                // Obviously cannot set the standard level 1 for japanese, so
+                // bail out now while we can.
                 if (rTypo.GetConvertedLang() == LANGUAGE_JAPANESE)
                     return;
             }
@@ -1784,7 +1787,9 @@ void SwWW8ImplReader::Read_HdFtFtnText( const SwNodeIndex* pSttIdx,
     aSave.Restore( this );
 }
 
-//Use authornames, if not available fall back to initials.
+/**
+ * Use authornames, if not available fall back to initials.
+ */
 long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
 {
     WW8PLCFx_SubDoc* pSD = pPlcxMan->GetAtn();
@@ -1844,7 +1849,7 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
 
     if (sal_uInt8 * pExtended = pPlcxMan->GetExtendedAtrds()) // Word < 2002 has no date data for comments
     {
-        sal_uLong nIndex = pSD->GetIdx() & 0xFFFF; //Index is (stupidly) multiplexed for WW8PLCFx_SubDocs
+        sal_uLong nIndex = pSD->GetIdx() & 0xFFFF; // Index is (stupidly) multiplexed for WW8PLCFx_SubDocs
         if (pWwFib->lcbAtrdExtra/18 > nIndex)
             nDateTime = SVBT32ToUInt32(*(SVBT32*)(pExtended+(nIndex*18)));
     }
@@ -1927,7 +1932,7 @@ void SwWW8ImplReader::Read_HdFtText(long nStart, long nLen, SwFrmFmt* pHdFtFmt)
     if (!pSttIdx)
         return;
 
-    SwPosition aTmpPos( *pPaM->GetPoint() );    // merke alte Cursorposition
+    SwPosition aTmpPos( *pPaM->GetPoint() ); // Remember old cursor position
 
     Read_HdFtFtnText(pSttIdx, nStart, nLen - 1, MAN_HDFT);
 
@@ -1937,7 +1942,7 @@ void SwWW8ImplReader::Read_HdFtText(long nStart, long nLen, SwFrmFmt* pHdFtFmt)
 
 bool SwWW8ImplReader::isValid_HdFt_CP(WW8_CP nHeaderCP) const
 {
-    //each CP of Plcfhdd MUST be less than FibRgLw97.ccpHdd
+    // Each CP of Plcfhdd MUST be less than FibRgLw97.ccpHdd
     return (nHeaderCP < pWwFib->ccpHdr) ? true : false;
 }
 
@@ -2066,7 +2071,7 @@ bool wwSectionManager::SectionIsProtected(const wwSection &rSection) const
 void wwSectionManager::SetHdFt(wwSection &rSection, int nSect,
     const wwSection *pPrevious)
 {
-    // Header / Footer nicht da
+    // Header/Footer not present
     if (!rSection.maSep.grpfIhdt)
         return;
 
@@ -2077,8 +2082,8 @@ void wwSectionManager::SetHdFt(wwSection &rSection, int nSect,
                 rSection);
     }
 
-    // Kopf / Fuss - Index Updaten
-    // Damit der Index auch spaeter noch stimmt
+    // Header/Footer - Update Index
+    // So that the index is still valid later on
     if (mrReader.pHdFt)
         mrReader.pHdFt->UpdateIndex(rSection.maSep.grpfIhdt);
 
@@ -2157,7 +2162,7 @@ void SwWW8ImplReader::AppendTxtNode(SwPosition& rPos)
 
     rDoc.AppendTxtNode(rPos);
 
-    //We can flush all anchored graphics at the end of a paragraph.
+    // We can flush all anchored graphics at the end of a paragraph.
     pAnchorStck->Flush();
 }
 
@@ -2206,9 +2211,9 @@ sal_uInt16 SwWW8ImplReader::TabRowSprm(int nLevel) const
 
 void SwWW8ImplReader::EndSpecial()
 {
-    // Frame / Table / Anl
+    // Frame/Table/Anl
     if (bAnl)
-        StopAllAnl();                  // -> bAnl = false
+        StopAllAnl(); // -> bAnl = false
 
     while(maApos.size() > 1)
     {
@@ -2227,7 +2232,7 @@ void SwWW8ImplReader::EndSpecial()
 
 bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
 {
-    // Frame / Table / Anl
+    // Frame/Table/Anl
     if (bInHyperlink)
         return false;
 
@@ -2291,7 +2296,7 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
 
             bool bHasRowEnd = SearchRowEnd(pPap, nMyStartCp, (nInTable<nCellLevel?nInTable:nCellLevel-1));
 
-            //Bad Table, remain unchanged in level, e.g. #i19667#
+            // Bad Table, remain unchanged in level, e.g. #i19667#
             if (!bHasRowEnd)
                 nCellLevel = static_cast< sal_uInt8 >(nInTable);
 
@@ -2301,11 +2306,11 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
             pPlcxMan->GetPap()->Restore( aSave );
         }
 
-    //  then look if we are in an Apo
+        // Then look if we are in an Apo
 
         ApoTestResults aApo = TestApo(nCellLevel, bTableRowEnd, pTabPos);
 
-        //look to see if we are in a Table, but Table in foot/end note not allowed
+        // Look to see if we are in a Table, but Table in foot/end note not allowed
         bool bStartTab = (nInTable < nCellLevel) && !bFtnEdn;
 
         bool bStopTab = bWasTabRowEnd && (nInTable > nCellLevel) && !bFtnEdn;
@@ -2314,31 +2319,29 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
                                 // WW8TabDesc::TableCellEnd() from making nonsense
 
         if (nInTable && !bTableRowEnd && !bStopTab && (nInTable == nCellLevel && aApo.HasStartStop()))
-            bStopTab = bStartTab = true;    // Required to stop and start table
-
-    //  Dann auf Anl (Nummerierung) testen
-    //  und dann alle Ereignisse in der richtigen Reihenfolge bearbeiten
+            bStopTab = bStartTab = true; // Required to stop and start table
 
+        //  Test for Anl (Numbering) and process all events in the right order
         if( bAnl && !bTableRowEnd )
         {
             const sal_uInt8* pSprm13 = pPlcxMan->HasParaSprm( 13 );
             if( pSprm13 )
-            {                                   // Noch Anl ?
+            {   // Still Anl left?
                 sal_uInt8 nT = static_cast< sal_uInt8 >(GetNumType( *pSprm13 ));
-                if( ( nT != WW8_Pause && nT != nWwNumType ) // Anl-Wechsel
-                    || aApo.HasStartStop()                  // erzwungenes Anl-Ende
+                if( ( nT != WW8_Pause && nT != nWwNumType ) // Anl change
+                    || aApo.HasStartStop()                  // Forced Anl end
                     || bStopTab || bStartTab )
                 {
-                    StopAnlToRestart(nT);  // Anl-Restart ( = Wechsel ) ueber sprms
+                    StopAnlToRestart(nT);  // Anl-Restart (= change) over sprms
                 }
                 else
                 {
-                    NextAnlLine( pSprm13 );                 // naechste Anl-Zeile
+                    NextAnlLine( pSprm13 ); // Next Anl Line
                 }
             }
             else
-            {                                           // Anl normal zuende
-                StopAllAnl();                                  // Wirkliches Ende
+            {   // Regular Anl end
+                StopAllAnl(); // Actual end
             }
         }
         if (bStopTab)
@@ -2356,8 +2359,8 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
         if (aApo.mbStartApo)
         {
             maApos[nInTable] = StartApo(aApo, pTabPos);
-            // nach StartApo ist ein ReSync noetig ( eigentlich nur, falls die Apo
-            // ueber eine FKP-Grenze geht
+            // We need an ReSync after StartApo
+            // (actually only if the Apo extends past a FKP border)
             rbReSync = true;
         }
         if (bStartTab)
@@ -2365,9 +2368,10 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
             WW8PLCFxSave1 aSave;
             pPlcxMan->GetPap()->Save( aSave );
 
-            if (bAnl)                           // Nummerierung ueber Zellengrenzen
-                StopAllAnl();                   // fuehrt zu Absturz -> keine Anls
-                                                // in Tabellen
+           // Numbering for cell borders causes a crash -> no Anls in Tables
+           if (bAnl)
+               StopAllAnl();
+
             if(nInTable < nCellLevel)
             {
                 if (StartTable(nStartCp))
@@ -2376,10 +2380,11 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
                     break;
                 maApos.push_back(false);
             }
+
             if(nInTable >= nCellLevel)
             {
-                // nach StartTable ist ein ReSync noetig ( eigentlich nur, falls die
-                // Tabelle ueber eine FKP-Grenze geht
+                // We need an ReSync after StartTable
+                // (actually only if the Apo extends past a FKP border)
                 rbReSync = true;
                 pPlcxMan->GetPap()->Restore( aSave );
             }
@@ -2620,7 +2625,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
     OSL_ENSURE(bValidPos, "Document claimed to have more text than available");
     if (!bValidPos)
     {
-        //Swallow missing range, e.g. #i95550#
+        // Swallow missing range, e.g. #i95550#
         rPos+=nRequestedStrLen;
         return true;
     }
@@ -2629,16 +2634,16 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
     OSL_ENSURE(nAvailableStrLen, "Document claimed to have more text than available");
     if (!nAvailableStrLen)
     {
-        //Swallow missing range, e.g. #i95550#
+        // Swallow missing range, e.g. #i95550#
         rPos+=nRequestedStrLen;
         return true;
     }
 
     sal_Size nValidStrLen = std::min(nRequestedStrLen, nAvailableStrLen);
 
-    // Unicode-Flag neu setzen und notfalls File-Pos korrigieren
-    // merke: Seek kostet nicht viel, da inline geprueft wird,
-    //        ob die korrekte FilePos nicht schon erreicht ist.
+    // Reset Unicode flag and correct FilePos if needed.
+    // Note: Seek is not expensive, as we're checking inline whether or not
+    // the correct FilePos has already been reached.
     xub_StrLen nStrLen;
     if (nValidStrLen <= (STRING_MAXLEN-1))
         nStrLen = writer_cast<xub_StrLen>(nValidStrLen);
@@ -2677,16 +2682,16 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
     for( nL2 = 0; nL2 < nStrLen; ++nL2, ++pWork )
     {
         if (bIsUnicode)
-            *pStrm >> nUCode;   // unicode  --> read 2 bytes
+            *pStrm >> nUCode; // unicode  --> read 2 bytes
         else
         {
-            *pStrm >> nBCode;   // old code --> read 1 byte
+            *pStrm >> nBCode; // old code --> read 1 byte
             nUCode = nBCode;
         }
 
         if (pStrm->GetError())
         {
-            rPos = WW8_CP_MAX-10;     // -> eof or other error
+            rPos = WW8_CP_MAX-10; // -> eof or other error
             rtl_freeMemory(pStr);
             delete [] p8Bits;
             return true;
@@ -2695,7 +2700,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
         if ((32 > nUCode) || (0xa0 == nUCode))
         {
             pStrm->SeekRel( bIsUnicode ? -2 : -1 );
-            break;              // Sonderzeichen < 32, == 0xa0 gefunden
+            break; // Special character < 32, == 0xa0 found
         }
 
         if (bIsUnicode)
@@ -2704,7 +2709,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
                 *pWork = nUCode;
             else
             {
-                if (nUCode >= 0x3000)       //0x8000 ?
+                if (nUCode >= 0x3000) //0x8000 ?
                 {
                     sal_Char aTest[2];
                     aTest[0] = static_cast< sal_Char >((nUCode & 0xFF00) >> 8);
@@ -2741,8 +2746,8 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
         emulateMSWordAddTextToParagraph(OUString(pStr, SAL_NO_ACQUIRE));
         pStr = NULL;
         rPos += nL2;
-        if (!maApos.back()) //a para end in apo doesn't count
-            bWasParaEnd = false;            //kein CR
+        if (!maApos.back()) // a para end in apo doesn't count
+            bWasParaEnd = false; // No CR
     }
 
     if (hConverter)
@@ -2757,7 +2762,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
 
 namespace
 {
-    //We want to force weak chars inside 0x0020 to 0x007F to LATIN
+    // We want to force weak chars inside 0x0020 to 0x007F to LATIN
     sal_Int16 lcl_getScriptType(
         const uno::Reference<i18n::XBreakIterator>& rBI,
         const OUString &rString, sal_Int32 nPos)
@@ -2768,8 +2773,8 @@ namespace
         return nScript;
     }
 
-    //We want to know about WEAK segments, so endOfScript isn't
-    //useful, and see lcl_getScriptType anyway
+    // We want to know about WEAK segments, so endOfScript isn't
+    // useful, and see lcl_getScriptType anyway
     sal_Int32 lcl_endOfScript(
         const uno::Reference<i18n::XBreakIterator>& rBI,
         const OUString &rString, sal_Int32 nPos, sal_Int16 nScript)
@@ -2811,7 +2816,7 @@ namespace
 
     bool sameFontIgnoringIrrelevantFields(const SvxFontItem &rA, const SvxFontItem &rB)
     {
-        //Ignoring CharSet, and ignoring unknown pitch
+        // Ignoring CharSet, and ignoring unknown pitch
         return rA.GetFamilyName() == rB.GetFamilyName() &&
             rA.GetStyleName() == rB.GetStyleName() &&
             rA.GetFamily() == rB.GetFamily() &&
@@ -2819,29 +2824,29 @@ namespace
     }
 }
 
-//In writer we categorize text into CJK, CTL and "Western" for everything else.
-//Microsoft Word basically categorizes text into East Asian, Complex, ASCII,
-//NonEastAsian/HighAnsi, with some shared characters and some properties to to
-//hint as to which way to bias those shared characters.
+// In writer we categorize text into CJK, CTL and "Western" for everything else.
+// Microsoft Word basically categorizes text into East Asian, Complex, ASCII,
+// NonEastAsian/HighAnsi, with some shared characters and some properties to
+// hint as to which way to bias those shared characters.
 //
-//That's four categories, we however have three categories. Given that problem
-//here we would ideally find out "what would word do" to see what font/language
-//word would assign to characters based on the unicode range they fall into and
-//hack the word one onto the range we use. However it's unclear what word's
-//categorization is. So we don't do that here yet.
+// That's four categories, we however have three categories. Given that problem
+// here we would ideally find out "what would word do" to see what font/language
+// word would assign to characters based on the unicode range they fall into and
+// hack the word one onto the range we use. However it's unclear what word's
+// categorization is. So we don't do that here yet.
 //
-//Additional to the categorization, when word encounters weak text for ambigious
-//chars it uses idcthint to indicate which way to bias. We don't have a idcthint
-//feature in writer.
+// Additional to the categorization, when word encounters weak text for ambigious
+// chars it uses idcthint to indicate which way to bias. We don't have a idcthint
+// feature in writer.
 //
-//So what we currently do here then is to split our text into non-weak/weak
-//sections and uses word's idcthint to determine what font it would use and
-//force that on for the segment. Following what we *do* know about word's
-//categorization, we know that the range 0x0020 and 0x007F is sprmCRgFtc0 in
-//word, something we map to LATIN, so we consider all weaks chars in that range
-//to auto-bias to LATIN.
+// So what we currently do here then is to split our text into non-weak/weak
+// sections and uses word's idcthint to determine what font it would use and
+// force that on for the segment. Following what we *do* know about word's
+// categorization, we know that the range 0x0020 and 0x007F is sprmCRgFtc0 in
+// word, something we map to LATIN, so we consider all weaks chars in that range
+// to auto-bias to LATIN.
 //
-//See https://bugs.freedesktop.org/show_bug.cgi?id=34319 for an example
+// See https://bugs.freedesktop.org/show_bug.cgi?id=34319 for an example
 void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString)
 {
     if (rAddString.isEmpty())
@@ -2880,7 +2885,7 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
         int nLclIdctHint = 0xFF;
         if (nScript == i18n::ScriptType::WEAK)
             nLclIdctHint = nIdctHint;
-        else if (nScript == MSASCII) //Force weak chars in ascii range to use LATIN font
+        else if (nScript == MSASCII) // Force weak chars in ascii range to use LATIN font
             nLclIdctHint = 0;
 
         sal_uInt16 nForceFromFontId = 0;
@@ -2904,8 +2909,8 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
 
         if (nForceFromFontId != 0)
         {
-            //Now we know that word would use the nForceFromFontId font for this range
-            //Try and determine what script writer would assign this range to
+            // Now we know that word would use the nForceFromFontId font for this range
+            // Try and determine what script writer would assign this range to
 
             sal_Int32 nWriterScript = lcl_getWriterScriptType(xBI, sParagraphText,
                 nPos + nParaOffset);
@@ -2931,7 +2936,7 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
                 }
             }
 
-            //Writer won't use the same font as word, so force the issue
+            // Writer won't use the same font as word, so force the issue
             if (!bWriterWillUseSameFontAsWordAutomatically)
             {
                 const SvxFontItem *pSourceFont = (const SvxFontItem*)GetFmtAttr(nForceFromFontId);
@@ -3018,7 +3023,9 @@ void SwWW8ImplReader::simpleAddTextToParagraph(const String& rAddString)
     bReadTable = false;
 }
 
-// Return value: true for para end
+/**
+ * Return value: true for para end
+ */
 bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd,
     long nCpOfs)
 {
@@ -3056,11 +3063,10 @@ bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd,
 bool SwWW8ImplReader::HandlePageBreakChar()
 {
     bool bParaEndAdded = false;
-    //#i1909# section/page breaks should not occur in tables, word
-    //itself ignores them in this case.
+    // #i1909# section/page breaks should not occur in tables, word
+    // itself ignores them in this case.
     if (!nInTable)
     {
-        //xushanchuan add for issue106569
         bool IsTemp=true;
         SwTxtNode* pTemp = pPaM->GetNode()->GetTxtNode();
         if (pTemp && pTemp->GetTxt().isEmpty()
@@ -3070,7 +3076,7 @@ bool SwWW8ImplReader::HandlePageBreakChar()
             AppendTxtNode(*pPaM->GetPoint());
             pTemp->SetAttr(*GetDfltAttr(RES_PARATR_NUMRULE));
         }
-        //xushanchuan end
+
         bPgSecBreak = true;
         pCtrlStck->KillUnlockedAttrs(*pPaM->GetPoint());
         /*
@@ -3078,9 +3084,7 @@ bool SwWW8ImplReader::HandlePageBreakChar()
         paragraph end, but nevertheless, numbering (and perhaps other
         similar constructs) do not exist on the para.
         */
-        //xushanchuan add for issue106569
         if (!bWasParaEnd && IsTemp)
-            //xushanchuan end
         {
             bParaEndAdded = true;
             if (0 >= pPaM->GetPoint()->nContent.GetIndex())
@@ -3099,9 +3103,9 @@ bool SwWW8ImplReader::HandlePageBreakChar()
 bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
 {
     bool bNewParaEnd = false;
-    // Unicode-Flag neu setzen und notfalls File-Pos korrigieren
-    // merke: Seek kostet nicht viel, da inline geprueft wird,
-    //        ob die korrekte FilePos nicht schon erreicht ist.
+    // Reset Unicode flag and correct FilePos if needed.
+    // Note: Seek is not expensive, as we're checking inline whether or not
+    // the correct FilePos has already been reached.
     sal_Size nRequestedPos = pSBase->WW8Cp2Fc(nCpOfs+nPosCp, &bIsUnicode);
     if (!checkSeek(*pStrm, nRequestedPos))
         return false;
@@ -3109,24 +3113,24 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
     sal_uInt8 nBCode(0);
     sal_uInt16 nWCharVal(0);
     if( bIsUnicode )
-        *pStrm >> nWCharVal;    // unicode  --> read 2 bytes
+        *pStrm >> nWCharVal; // unicode  --> read 2 bytes
     else
     {
-        *pStrm  >>  nBCode;     // old code --> read 1 byte
+        *pStrm  >>  nBCode; // old code --> read 1 byte
         nWCharVal = nBCode;
     }
 
     sal_Unicode cInsert = '\x0';
     bool bRet = false;
-    //xushanchuan add for issue106569
+
     if ( 0xc != nWCharVal )
         bFirstParaOfPage = false;
-    //xushanchuan end
+
     switch (nWCharVal)
     {
         case 0:
             {
-                // Seitennummer
+                // Page number
                 SwPageNumberField aFld(
                     (SwPageNumberFieldType*)rDoc.GetSysFldType(
                     RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC);
@@ -3148,18 +3152,18 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
             break;
         case 0x7:
             bNewParaEnd = true;
-            TabCellEnd();       // table cell end (Flags abfragen!)
+            TabCellEnd();       // Table cell end (query flags!)
             break;
         case 0xf:
-            if( !bSpec )        // "Satellit"
+            if( !bSpec )        // "Satellite"
                 cInsert = '\xa4';
             break;
         case 0x14:
-            if( !bSpec )        // "Para-Ende"-Zeichen
+            if( !bSpec )        // "Para End" char
                 cInsert = '\xb5';
             break;
         case 0x15:
-            if( !bSpec )        // Juristenparagraph
+            if( !bSpec )        // Section sign
                 cInsert = '\xa7';
             break;
         case 0x9:
@@ -3171,13 +3175,13 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
         case 0xc:
             bRet = HandlePageBreakChar();
             break;
-        case 0x1e:   // Non-breaking hyphen
+        case 0x1e:              // Non-breaking hyphen
             rDoc.InsertString( *pPaM, OUString(CHAR_HARDHYPHEN) );
             break;
-        case 0x1f:   // Non-required hyphens
+        case 0x1f:              // Non-required hyphens
             rDoc.InsertString( *pPaM, OUString(CHAR_SOFTHYPHEN) );
             break;
-        case 0xa0:   // Non-breaking spaces
+        case 0xa0:              // Non-breaking spaces
             rDoc.InsertString( *pPaM, OUString(CHAR_HARDBLANK)  );
             break;
         case 0x1:
@@ -3186,9 +3190,10 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
             straightforward "traditional" ole object, otherwise we have a
             graphic preview of an associated ole2 object (or a simple
             graphic of course)
+
+            normally in the canvas field, the code is 0x8 0x1.
+            in a special case, the code is 0x1 0x1, which yields a simple picture
             */
-            //normally in the canvas field, the code is 0x8 0x1.
-            //in a special case, the code is 0x1 0x1, which yields a simple picture
             {
                 bool bReadObj = IsInlineEscherHack();
                 if( bReadObj )
@@ -3257,7 +3262,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
                     void *pData;
                     pTest->Get(nPos, pData);
                     sal_uInt32 nData = SVBT32ToUInt32(*(SVBT32*)pData);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list