[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 99 commits - apache-commons/ExternalProject_apache_commons_httpclient.mk apache-commons/Package_apache_commons_codec.mk apache-commons/Package_apache_commons_lang.mk apache-commons/patches apache-commons/UnpackedTarball_apache_commons_httpclient.mk basebmp/source bin/module-deps.pl config_host/config_global.h.in config_host/config_graphite.h.in config_host/config_kde4.h.in config_host/config_mingw.h.in config_host/config_telepathy.h.in config_host/config_vclplug.h.in config_host.mk.in config_host/README configure.ac connectivity/inc connectivity/Library_postgresql-sdbc-impl.mk connectivity/source cui/source cui/uiconfig cui/UI_cui.mk dbaccess/source desktop/source download.lst filter/Configuration_filter.mk filter/source forms/Module_forms.mk framework/inc framework/source i18npool/source ios/CustomTarget_Viewer_app.mk ios/experimental l10ntools/source logerrit lotuswordpro/source Makefile.in postgresql/ExternalPackage _postgresql.mk postgresql/ExternalProject_postgresql.mk RepositoryModule_host.mk sal/inc sal/osl sc/inc sc/qa sc/source sd/source sfx2/inc sfx2/Library_sfx.mk sfx2/Package_inc.mk sfx2/source solenv/bin solenv/gbuild sot/source starmath/source svl/inc svl/Library_svl.mk svtools/inc svtools/source svx/inc svx/source swext/Extension_wiki-publisher.mk sw/qa sw/source tools/inc ucb/source unotools/inc unotools/source vcl/aqua vcl/coretext vcl/generic vcl/headless vcl/inc vcl/ios vcl/source writerfilter/source writerperfect/source

Kohei Yoshida kohei.yoshida at gmail.com
Tue Mar 26 12:58:31 PDT 2013


Rebased ref, commits from common ancestor:
commit 5f5d2cb6d1363bd133053a7c035b6e0163ee4edc
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 26 15:04:25 2013 -0400

    Make the conditional formatting code free of ScBaseCell.
    
    Change-Id: I93f83a840874c973cdc0821ddeb1913be7f09767

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 7998898..84127cd 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -80,9 +80,10 @@ struct SC_DLLPUBLIC ScCellValue
 };
 
 /**
- * This is very similar to ScCellValue, except that it points to the
+ * This is very similar to ScCellValue, except that it references the
  * original value instead of copying it.  As such, don't hold an instance of
- * this class any longer than necessary.
+ * this class any longer than necessary, and absolutely not after the
+ * original cell has been destroyed.
  */
 struct SC_DLLPUBLIC ScRefCellValue
 {
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index d5a55e3..8592bcb 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -35,10 +35,9 @@
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/scoped_ptr.hpp>
 
-class ScBaseCell;
 class ScFormulaCell;
 class ScTokenArray;
-
+class ScRefCellValue;
 
 //  nOptions Flags
 #define SC_COND_NOBLANKS    1
@@ -196,7 +195,7 @@ public:
 
     virtual void SetParent( ScConditionalFormat* pNew )  { pCondFormat = pNew; }
 
-    bool            IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) const;
+    bool IsCellValid( ScRefCellValue& rCell, const ScAddress& rPos ) const;
 
     ScConditionMode GetOperation() const        { return eOp; }
     bool            IsIgnoreBlank() const       { return ( nOptions & SC_COND_NOBLANKS ) == 0; }
@@ -406,9 +405,9 @@ public:
 
     const ScFormatEntry* GetEntry( sal_uInt16 nPos ) const;
 
-    const rtl::OUString&   GetCellStyle( ScBaseCell* pCell, const ScAddress& rPos ) const;
+    const OUString& GetCellStyle( ScRefCellValue& rCell, const ScAddress& rPos ) const;
 
-    ScCondFormatData GetData( ScBaseCell* pCell, const ScAddress& rPos ) const;
+    ScCondFormatData GetData( ScRefCellValue& rCell, const ScAddress& rPos ) const;
 
     bool            EqualEntries( const ScConditionalFormat& r ) const;
 
diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx
index 8c73b7d..85737a3 100644
--- a/sc/inc/validat.hxx
+++ b/sc/inc/validat.hxx
@@ -125,12 +125,11 @@ public:
         @return  true = rStrings has been filled with at least one entry. */
     bool FillSelectionList(std::vector<ScTypedStrData>& rStrings, const ScAddress& rPos) const;
 
-                    //  with string: during input, with cell: for detective / RC_FORCED
-    sal_Bool            IsDataValid( const String& rTest, const ScPatternAttr& rPattern,
-                                    const ScAddress& rPos ) const;
-    sal_Bool            IsDataValid( ScBaseCell* pCell, const ScAddress& rPos ) const;
+    //  with string: during input, with cell: for detective / RC_FORCED
+    bool IsDataValid(
+        const OUString& rTest, const ScPatternAttr& rPattern, const ScAddress& rPos ) const;
 
-    bool IsDataValid( ScCellIterator& rIter ) const;
+    bool IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos ) const;
 
                     // TRUE -> break
     sal_Bool            DoError( Window* pParent, const String& rInput, const ScAddress& rPos ) const;
@@ -160,14 +159,14 @@ private:
         @param rMatch    (out-param) the index of the first item that matched, -1 if nothing matched.
         @return  true = Cell range found, rRange is valid, or an error entry stuffed into the list if pCell==NULL. */
     bool GetSelectionFromFormula(
-        std::vector<ScTypedStrData>* pStrings, ScBaseCell* pCell, const ScAddress& rPos,
+        std::vector<ScTypedStrData>* pStrings, ScRefCellValue& rCell, const ScAddress& rPos,
         const ScTokenArray& rTokArr, int& rMatch) const;
 
     /** Tests, if pCell is equal to what the passed token array represents. */
-    bool            IsEqualToTokenArray( ScBaseCell* pCell, const ScAddress& rPos, const ScTokenArray& rTokArr ) const;
+    bool IsEqualToTokenArray( ScRefCellValue& rCell, const ScAddress& rPos, const ScTokenArray& rTokArr ) const;
 
     /** Tests, if contents of pCell occur in cell range referenced by own formula, or in a string list. */
-    bool            IsListValid( ScBaseCell* pCell, const ScAddress& rPos ) const;
+    bool IsListValid( ScRefCellValue& rCell, const ScAddress& rPos ) const;
 };
 
 //
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index aa777e5..c34e55c 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1688,7 +1688,8 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
             if ( nValidation )
             {
                 const ScValidationData* pData = pDocument->GetValidationEntry( nValidation );
-                if ( pData && !pData->IsDataValid( this, aPos ) )
+                ScRefCellValue aTmpCell(this);
+                if ( pData && !pData->IsDataValid(aTmpCell, aPos))
                     pData->DoCalcError( this );
             }
         }
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index ae4a7e2..0ce3088 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -36,6 +36,8 @@
 #include "stlpool.hxx"
 #include "rangenam.hxx"
 #include "colorscale.hxx"
+#include "cellvalue.hxx"
+#include "editutil.hxx"
 
 using namespace formula;
 //------------------------------------------------------------------------
@@ -731,47 +733,40 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
     bFirstRun = false;
 }
 
-static bool lcl_GetCellContent( ScBaseCell* pCell, bool bIsStr1, double& rArg, rtl::OUString& rArgStr )
+static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rArg, OUString& rArgStr )
 {
+
+    if (rCell.isEmpty())
+        return !bIsStr1;
+
     bool bVal = true;
 
-    if ( pCell )
+    switch (rCell.meType)
     {
-        CellType eType = pCell->GetCellType();
-        switch( eType )
+        case CELLTYPE_VALUE:
+            rArg = rCell.mfValue;
+        break;
+        case CELLTYPE_FORMULA:
         {
-            case CELLTYPE_VALUE:
-                rArg = ((ScValueCell*)pCell)->GetValue();
-                break;
-            case CELLTYPE_FORMULA:
-                {
-                    ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
-                    bVal = pFCell->IsValue();
-                    if (bVal)
-                        rArg = pFCell->GetValue();
-                    else
-                        rArgStr = pFCell->GetString();
-                }
-                break;
-            case CELLTYPE_STRING:
-            case CELLTYPE_EDIT:
-                bVal = false;
-                if ( eType == CELLTYPE_STRING )
-                    rArgStr = ((ScStringCell*)pCell)->GetString();
-                else
-                    rArgStr = ((ScEditCell*)pCell)->GetString();
-                break;
-
-            default:
-                pCell = NULL;           // Note-Zellen wie leere
-                break;
+            bVal = rCell.mpFormula->IsValue();
+            if (bVal)
+                rArg = rCell.mpFormula->GetValue();
+            else
+                rArgStr = rCell.mpFormula->GetString();
         }
+        break;
+        case CELLTYPE_STRING:
+        case CELLTYPE_EDIT:
+            bVal = false;
+            if (rCell.meType == CELLTYPE_STRING)
+                rArgStr = *rCell.mpString;
+            else if (rCell.mpEditText)
+                rArgStr = ScEditUtil::GetString(*rCell.mpEditText);
+        break;
+        default:
+            ;
     }
 
-    if( !pCell )
-        if( bIsStr1 )
-            bVal = false;               // leere Zellen je nach Bedingung
-
     return bVal;
 }
 
@@ -803,23 +798,28 @@ void ScConditionEntry::FillCache() const
             for( SCROW r = nRowStart; r <= nRow; r++ )
                 for( SCCOL c = nColStart; c <= nCol; c++ )
                 {
-                    double nVal = 0.0;
-                    ScBaseCell *pCell = NULL;
-
-                    mpDoc->GetCell( c, r, nTab, pCell );
-                    if( !pCell )
+                    ScRefCellValue aCell;
+                    aCell.assign(*mpDoc, ScAddress(c, r, nTab));
+                    if (aCell.isEmpty())
                         continue;
 
-                    rtl::OUString aStr;
-                    if( !lcl_GetCellContent( pCell, false, nVal, aStr ) )
+                    double nVal = 0.0;
+                    OUString aStr;
+                    if (!lcl_GetCellContent(aCell, false, nVal, aStr))
                     {
-                        std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult = mpCache->maStrings.insert(std::pair<rtl::OUString, sal_Int32>(aStr, static_cast<sal_Int32>(1)));
+                        std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult =
+                            mpCache->maStrings.insert(
+                                ScConditionEntryCache::StringCacheType::value_type(aStr, 1));
+
                         if(!aResult.second)
                             aResult.first->second++;
                     }
                     else
                     {
-                        std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult = mpCache->maValues.insert(std::pair<double, sal_Int32>(nVal, (sal_Int32)1));
+                        std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult =
+                            mpCache->maValues.insert(
+                                ScConditionEntryCache::ValueCacheType::value_type(nVal, 1));
+
                         if(!aResult.second)
                             aResult.first->second++;
 
@@ -978,17 +978,13 @@ bool ScConditionEntry::IsAboveAverage( double nArg, bool bEqual ) const
 
 bool ScConditionEntry::IsError( const ScAddress& rPos ) const
 {
-    ScBaseCell* pCell = mpDoc->GetCell(rPos);
-    if(!pCell)
-        return false;
-
-    switch(pCell->GetCellType())
+    switch (mpDoc->GetCellType(rPos))
     {
         case CELLTYPE_VALUE:
             return false;
         case CELLTYPE_FORMULA:
         {
-            ScFormulaCell* pFormulaCell = static_cast<ScFormulaCell*>(pCell);
+            ScFormulaCell* pFormulaCell = const_cast<ScFormulaCell*>(mpDoc->GetFormulaCell(rPos));
             if(pFormulaCell->GetErrCode())
                 return true;
         }
@@ -1267,13 +1263,13 @@ bool ScConditionEntry::IsValidStr( const rtl::OUString& rArg, const ScAddress& r
     return bValid;
 }
 
-bool ScConditionEntry::IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) const
+bool ScConditionEntry::IsCellValid( ScRefCellValue& rCell, const ScAddress& rPos ) const
 {
     ((ScConditionEntry*)this)->Interpret(rPos);         // Formeln auswerten
 
     double nArg = 0.0;
     rtl::OUString aArgStr;
-    bool bVal = lcl_GetCellContent( pCell, bIsStr1, nArg, aArgStr );
+    bool bVal = lcl_GetCellContent( rCell, bIsStr1, nArg, aArgStr );
     if (bVal)
         return IsValid( nArg, rPos );
     else
@@ -1651,12 +1647,14 @@ ScCondDateFormatEntry::ScCondDateFormatEntry( ScDocument* pDoc, const ScCondDate
 
 bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const
 {
-    ScBaseCell* pBaseCell = mpDoc->GetCell( rPos );
+    CellType eCellType = mpDoc->GetCellType(rPos);
 
-    if(!pBaseCell)
+    if (eCellType == CELLTYPE_NONE || eCellType == CELLTYPE_NOTE)
+        // empty cell.
         return false;
 
-    if(pBaseCell->GetCellType() != CELLTYPE_VALUE && pBaseCell->GetCellType() != CELLTYPE_FORMULA)
+    if (eCellType != CELLTYPE_VALUE && eCellType != CELLTYPE_FORMULA)
+        // non-numerical cell.
         return false;
 
     if( !mpCache )
@@ -1903,14 +1901,14 @@ const ScFormatEntry* ScConditionalFormat::GetEntry( sal_uInt16 nPos ) const
         return NULL;
 }
 
-const rtl::OUString& ScConditionalFormat::GetCellStyle( ScBaseCell* pCell, const ScAddress& rPos ) const
+const OUString& ScConditionalFormat::GetCellStyle( ScRefCellValue& rCell, const ScAddress& rPos ) const
 {
     for (CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
     {
         if(itr->GetType() == condformat::CONDITION)
         {
             const ScCondFormatEntry& rEntry = static_cast<const ScCondFormatEntry&>(*itr);
-            if ( rEntry.IsCellValid( pCell, rPos ) )
+            if (rEntry.IsCellValid(rCell, rPos))
                 return rEntry.GetStyle();
         }
         else if(itr->GetType() == condformat::DATE)
@@ -1924,7 +1922,7 @@ const rtl::OUString& ScConditionalFormat::GetCellStyle( ScBaseCell* pCell, const
     return EMPTY_OUSTRING;
 }
 
-ScCondFormatData ScConditionalFormat::GetData( ScBaseCell* pCell, const ScAddress& rPos ) const
+ScCondFormatData ScConditionalFormat::GetData( ScRefCellValue& rCell, const ScAddress& rPos ) const
 {
     ScCondFormatData aData;
     for(CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
@@ -1932,7 +1930,7 @@ ScCondFormatData ScConditionalFormat::GetData( ScBaseCell* pCell, const ScAddres
         if(itr->GetType() == condformat::CONDITION && aData.aStyleName.isEmpty())
         {
             const ScCondFormatEntry& rEntry = static_cast<const ScCondFormatEntry&>(*itr);
-            if ( rEntry.IsCellValid( pCell, rPos ) )
+            if (rEntry.IsCellValid(rCell, rPos))
                 aData.aStyleName = rEntry.GetStyle();
         }
         else if(itr->GetType() == condformat::COLORSCALE && !aData.pColorScale)
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index aad3f4f..3df2fbc 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -631,8 +631,10 @@ const SfxPoolItem* ScDocument::GetEffItem(
                     const ScConditionalFormat* pForm = pCondFormList->GetFormat( *itr );
                     if ( pForm )
                     {
-                        ScBaseCell* pCell = ((ScDocument*)this)->GetCell(ScAddress(nCol,nRow,nTab));
-                        rtl::OUString aStyle = pForm->GetCellStyle( pCell, ScAddress(nCol, nRow, nTab) );
+                        ScAddress aPos(nCol, nRow, nTab);
+                        ScRefCellValue aCell;
+                        aCell.assign(const_cast<ScDocument&>(*this), aPos);
+                        rtl::OUString aStyle = pForm->GetCellStyle(aCell, aPos);
                         if (!aStyle.isEmpty())
                         {
                             SfxStyleSheetBase* pStyleSheet = xPoolHelper->GetStylePool()->Find(
@@ -663,8 +665,10 @@ const SfxItemSet* ScDocument::GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab
         if(!pForm)
             continue;
 
-        ScBaseCell* pCell = ((ScDocument*)this)->GetCell(ScAddress(nCol,nRow,nTab));
-        rtl::OUString aStyle = pForm->GetCellStyle( pCell, ScAddress(nCol, nRow, nTab) );
+        ScAddress aPos(nCol, nRow, nTab);
+        ScRefCellValue aCell;
+        aCell.assign(const_cast<ScDocument&>(*this), aPos);
+        const OUString& aStyle = pForm->GetCellStyle(aCell, aPos);
         if (!aStyle.isEmpty())
         {
             SfxStyleSheetBase* pStyleSheet = xPoolHelper->GetStylePool()->Find( aStyle, SFX_STYLE_FAMILY_PARA );
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index f0d4cb4..f7366cd 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -39,6 +39,7 @@
 #include "conditio.hxx"
 #include "colorscale.hxx"
 #include "stlpool.hxx"
+#include "cellvalue.hxx"
 
 #include <iostream>
 
@@ -520,8 +521,11 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
                                         if(!pCondForm)
                                             continue;
 
-                                        ScCondFormatData aData = pCondForm->GetData( pInfo->pCell,
-                                                ScAddress( nX, nCurRow, nTab ) );
+                                        ScRefCellValue aTmpCell;
+                                        if (pInfo->pCell)
+                                            aTmpCell.assign(*pInfo->pCell);
+                                        ScCondFormatData aData = pCondForm->GetData(
+                                            aTmpCell, ScAddress(nX, nCurRow, nTab));
                                         if (!aData.aStyleName.isEmpty())
                                         {
                                             SfxStyleSheetBase* pStyleSheet =
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index a2d4b4a..cff7da7 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -41,6 +41,7 @@
 #include "dbdata.hxx"
 #include "typedstrdata.hxx"
 #include "dociter.hxx"
+#include "editutil.hxx"
 
 #include <math.h>
 #include <memory>
@@ -414,18 +415,19 @@ sal_Bool ScValidationData::DoError( Window* pParent, const String& rInput,
 }
 
 
-sal_Bool ScValidationData::IsDataValid( const String& rTest, const ScPatternAttr& rPattern,
-                                    const ScAddress& rPos ) const
+bool ScValidationData::IsDataValid(
+    const OUString& rTest, const ScPatternAttr& rPattern, const ScAddress& rPos ) const
 {
     if ( eDataMode == SC_VALID_ANY ) // check if any cell content is allowed
         return sal_True;
 
-    if ( rTest.GetChar(0) == '=' )   // formulas do not pass the validity test
-        return sal_False;
-
-    if ( !rTest.Len() )              // check whether empty cells are allowed
+    if (rTest.isEmpty())              // check whether empty cells are allowed
         return IsIgnoreBlank();
 
+    if (rTest[0] == '=')   // formulas do not pass the validity test
+        return false;
+
+
     SvNumberFormatter* pFormatter = GetDocument()->GetFormatTable();
 
     // get the value if any
@@ -438,7 +440,7 @@ sal_Bool ScValidationData::IsDataValid( const String& rTest, const ScPatternAttr
     {
         double nLenVal;
         if (!bIsVal)
-            nLenVal = static_cast<double>( rTest.Len() );
+            nLenVal = static_cast<double>(rTest.getLength());
         else
         {
             // For numeric values use the resulting input line string to
@@ -449,133 +451,55 @@ sal_Bool ScValidationData::IsDataValid( const String& rTest, const ScPatternAttr
             pFormatter->GetInputLineString( nVal, nFormat, aStr);
             nLenVal = static_cast<double>( aStr.Len() );
         }
-        ScValueCell aTmpCell( nLenVal );
-        bRet = IsCellValid( &aTmpCell, rPos );
+        ScRefCellValue aTmpCell(nLenVal);
+        bRet = IsCellValid(aTmpCell, rPos);
     }
     else
     {
         if (bIsVal)
         {
-            ScValueCell aTmpCell( nVal );
-            bRet = IsDataValid( &aTmpCell, rPos );
+            ScRefCellValue aTmpCell(nVal);
+            bRet = IsDataValid(aTmpCell, rPos);
         }
         else
         {
-            ScStringCell aTmpCell( rTest );
-            bRet = IsDataValid( &aTmpCell, rPos );
+            ScRefCellValue aTmpCell(&rTest);
+            bRet = IsDataValid(aTmpCell, rPos);
         }
     }
 
     return bRet;
 }
 
-sal_Bool ScValidationData::IsDataValid( ScBaseCell* pCell, const ScAddress& rPos ) const
+bool ScValidationData::IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos ) const
 {
     if( eDataMode == SC_VALID_LIST )
-        return IsListValid( pCell, rPos );
+        return IsListValid(rCell, rPos);
 
     double nVal = 0.0;
-    String aString;
-    sal_Bool bIsVal = sal_True;
-
-    switch (pCell->GetCellType())
-    {
-        case CELLTYPE_VALUE:
-            nVal = ((ScValueCell*)pCell)->GetValue();
-            break;
-        case CELLTYPE_STRING:
-            aString = ((ScStringCell*)pCell)->GetString();
-            bIsVal = false;
-            break;
-        case CELLTYPE_EDIT:
-            aString = ((ScEditCell*)pCell)->GetString();
-            bIsVal = false;
-            break;
-        case CELLTYPE_FORMULA:
-            {
-                ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
-                bIsVal = pFCell->IsValue();
-                if ( bIsVal )
-                    nVal  = pFCell->GetValue();
-                else
-                    aString = pFCell->GetString();
-            }
-            break;
-        default:                        // Notizen, Broadcaster
-            return IsIgnoreBlank();     // wie eingestellt
-    }
-
-    sal_Bool bOk = sal_True;
-    switch (eDataMode)
-    {
-        // SC_VALID_ANY schon oben
-
-        case SC_VALID_WHOLE:
-        case SC_VALID_DECIMAL:
-        case SC_VALID_DATE:         // Date/Time ist nur Formatierung
-        case SC_VALID_TIME:
-            bOk = bIsVal;
-            if ( bOk && eDataMode == SC_VALID_WHOLE )
-                bOk = ::rtl::math::approxEqual( nVal, floor(nVal+0.5) );        // ganze Zahlen
-            if ( bOk )
-                bOk = IsCellValid( pCell, rPos );
-            break;
-
-        case SC_VALID_CUSTOM:
-            //  fuer Custom muss eOp == SC_COND_DIRECT sein
-            //! der Wert muss im Dokument stehen !!!!!!!!!!!!!!!!!!!!
-            bOk = IsCellValid( pCell, rPos );
-            break;
-
-        case SC_VALID_TEXTLEN:
-            bOk = !bIsVal;          // nur Text
-            if ( bOk )
-            {
-                double nLenVal = (double) aString.Len();
-                ScValueCell* pTmpCell = new ScValueCell( nLenVal );
-                bOk = IsCellValid( pTmpCell, rPos );
-                pTmpCell->Delete();
-            }
-            break;
-
-        default:
-            OSL_FAIL("not yet done");
-            break;
-    }
-
-    return bOk;
-}
-
-bool ScValidationData::IsDataValid( ScCellIterator& rIter ) const
-{
-    const ScAddress& rPos = rIter.GetPos();
-
-    if( eDataMode == SC_VALID_LIST )
-    {
-        ScBaseCell* pBC = rIter.getHackedBaseCell();
-        return IsListValid(pBC, rPos);
-    }
-
-    double fVal = 0.0;
     OUString aString;
     bool bIsVal = true;
 
-    switch (rIter.getType())
+    switch (rCell.meType)
     {
         case CELLTYPE_VALUE:
-            fVal = rIter.getValue();
-            break;
+            nVal = rCell.mfValue;
+        break;
         case CELLTYPE_STRING:
+            aString = *rCell.mpString;
+            bIsVal = false;
+        break;
         case CELLTYPE_EDIT:
-            aString = rIter.getString();
+            if (rCell.mpEditText)
+                aString = ScEditUtil::GetString(*rCell.mpEditText);
             bIsVal = false;
-            break;
+        break;
         case CELLTYPE_FORMULA:
         {
-            ScFormulaCell* pFCell = rIter.getFormulaCell();
+            ScFormulaCell* pFCell = rCell.mpFormula;
             bIsVal = pFCell->IsValue();
             if ( bIsVal )
-                fVal  = pFCell->GetValue();
+                nVal  = pFCell->GetValue();
             else
                 aString = pFCell->GetString();
         }
@@ -595,30 +519,24 @@ bool ScValidationData::IsDataValid( ScCellIterator& rIter ) const
         case SC_VALID_TIME:
             bOk = bIsVal;
             if ( bOk && eDataMode == SC_VALID_WHOLE )
-                bOk = ::rtl::math::approxEqual( fVal, floor(fVal+0.5) );        // ganze Zahlen
+                bOk = ::rtl::math::approxEqual( nVal, floor(nVal+0.5) );        // ganze Zahlen
             if ( bOk )
-            {
-                ScBaseCell* pBC = rIter.getHackedBaseCell();
-                bOk = IsCellValid(pBC, rPos);
-            }
+                bOk = IsCellValid(rCell, rPos);
             break;
 
         case SC_VALID_CUSTOM:
-        {
             //  fuer Custom muss eOp == SC_COND_DIRECT sein
             //! der Wert muss im Dokument stehen !!!!!!!!!!!!!!!!!!!!
-            ScBaseCell* pBC = rIter.getHackedBaseCell();
-            bOk = IsCellValid(pBC, rPos);
-        }
-        break;
+            bOk = IsCellValid(rCell, rPos);
+            break;
+
         case SC_VALID_TEXTLEN:
             bOk = !bIsVal;          // nur Text
             if ( bOk )
             {
                 double nLenVal = (double) aString.getLength();
-                ScValueCell* pTmpCell = new ScValueCell( nLenVal );
-                bOk = IsCellValid( pTmpCell, rPos );
-                pTmpCell->Delete();
+                ScRefCellValue aTmpCell(nLenVal);
+                bOk = IsCellValid(aTmpCell, rPos);
             }
             break;
 
@@ -630,8 +548,6 @@ bool ScValidationData::IsDataValid( ScCellIterator& rIter ) const
     return bOk;
 }
 
-// ----------------------------------------------------------------------------
-
 namespace {
 
 /** Token array helper. Iterates over all string tokens.
@@ -701,7 +617,7 @@ bool ScValidationData::HasSelectionList() const
 }
 
 bool ScValidationData::GetSelectionFromFormula(
-    std::vector<ScTypedStrData>* pStrings, ScBaseCell* pCell, const ScAddress& rPos,
+    std::vector<ScTypedStrData>* pStrings, ScRefCellValue& rCell, const ScAddress& rPos,
     const ScTokenArray& rTokArr, int& rMatch) const
 {
     bool bOk = true;
@@ -816,7 +732,7 @@ bool ScValidationData::GetSelectionFromFormula(
                 if( NULL != pStrings )
                     pEntry = new ScTypedStrData( aValStr, 0.0, ScTypedStrData::Standard);
 
-                if( pCell && rMatch < 0 )
+                if (!rCell.isEmpty() && rMatch < 0)
                     aCondTokArr.AddString( aValStr );
             }
             else
@@ -842,7 +758,7 @@ bool ScValidationData::GetSelectionFromFormula(
                         pFormatter->GetInputLineString( nMatVal.fVal, 0, aValStr );
                 }
 
-                if( pCell && rMatch < 0 )
+                if (!rCell.isEmpty() && rMatch < 0)
                 {
                     // I am not sure errors will work here, but a user can no
                     // manually enter an error yet so the point is somewhat moot.
@@ -852,7 +768,7 @@ bool ScValidationData::GetSelectionFromFormula(
                     pEntry = new ScTypedStrData( aValStr, nMatVal.fVal, ScTypedStrData::Value);
             }
 
-            if( rMatch < 0 && NULL != pCell && IsEqualToTokenArray( pCell, rPos, aCondTokArr ) )
+            if (rMatch < 0 && !rCell.isEmpty() && IsEqualToTokenArray(rCell, rPos, aCondTokArr))
             {
                 rMatch = n;
                 // short circuit on the first match if not filling the list
@@ -871,7 +787,7 @@ bool ScValidationData::GetSelectionFromFormula(
 
     // In case of no match needed and an error occurred, return that error
     // entry as valid instead of silently failing.
-    return bOk || NULL == pCell;
+    return bOk || rCell.isEmpty();
 }
 
 bool ScValidationData::FillSelectionList(std::vector<ScTypedStrData>& rStrColl, const ScAddress& rPos) const
@@ -902,7 +818,8 @@ bool ScValidationData::FillSelectionList(std::vector<ScTypedStrData>& rStrColl,
         if (!bOk)
         {
             int nMatch;
-            bOk = GetSelectionFromFormula( &rStrColl, NULL, rPos, *pTokArr, nMatch );
+            ScRefCellValue aEmptyCell;
+            bOk = GetSelectionFromFormula(&rStrColl, aEmptyCell, rPos, *pTokArr, nMatch);
         }
     }
 
@@ -911,14 +828,14 @@ bool ScValidationData::FillSelectionList(std::vector<ScTypedStrData>& rStrColl,
 
 // ----------------------------------------------------------------------------
 
-bool ScValidationData::IsEqualToTokenArray( ScBaseCell* pCell, const ScAddress& rPos, const ScTokenArray& rTokArr ) const
+bool ScValidationData::IsEqualToTokenArray( ScRefCellValue& rCell, const ScAddress& rPos, const ScTokenArray& rTokArr ) const
 {
     // create a condition entry that tests on equality and set the passed token array
     ScConditionEntry aCondEntry( SC_COND_EQUAL, &rTokArr, NULL, GetDocument(), rPos );
-    return aCondEntry.IsCellValid( pCell, rPos );
+    return aCondEntry.IsCellValid(rCell, rPos);
 }
 
-bool ScValidationData::IsListValid( ScBaseCell* pCell, const ScAddress& rPos ) const
+bool ScValidationData::IsListValid( ScRefCellValue& rCell, const ScAddress& rPos ) const
 {
     bool bIsValid = false;
 
@@ -955,7 +872,7 @@ bool ScValidationData::IsListValid( ScBaseCell* pCell, const ScAddress& rPos ) c
             else
                 aCondTokArr.AddString( *pString );
 
-            bIsValid = IsEqualToTokenArray( pCell, rPos, aCondTokArr );
+            bIsValid = IsEqualToTokenArray(rCell, rPos, aCondTokArr);
         }
     }
 
@@ -968,7 +885,7 @@ bool ScValidationData::IsListValid( ScBaseCell* pCell, const ScAddress& rPos ) c
     if (!bIsValid)
     {
         int nMatch;
-        bIsValid = GetSelectionFromFormula( NULL, pCell, rPos, *pTokArr, nMatch );
+        bIsValid = GetSelectionFromFormula(NULL, rCell, rPos, *pTokArr, nMatch);
         bIsValid = bIsValid && nMatch >= 0;
     }
 
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 7aad0cc..958162f 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1366,7 +1366,8 @@ sal_Bool ScDetectiveFunc::MarkInvalid(sal_Bool& rOverflow)
                             DrawCircle( nCol, nRow, aData );
                             ++nInsCount;
                         }
-                    if (!pData->IsDataValid(aCellIter))
+                    ScRefCellValue aCell = aCellIter.getRefCellValue();
+                    if (!pData->IsDataValid(aCell, aCellIter.GetPos()))
                     {
                         DrawCircle( nCol, nCellRow, aData );
                         ++nInsCount;
commit 7c2dd80cbee59aadee20b59aacdf0ba437c765db
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 26 12:35:36 2013 -0400

    By using ScRefCellValue we can remove some duplicated code.
    
    Change-Id: I75652172033e4ce00ac239e85d835c7cc9256fe2

diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index b30cf1b..6b06c22 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -37,7 +37,6 @@
 
 class ScDocument;
 class ScFormulaCell;
-class ScCellIterator;
 
 enum ScChangeActionType
 {
@@ -800,7 +799,7 @@ public:
         rtl::OUString& rStr, ScDocument* pDoc, bool bFlag3D = false ) const;
 
     static ScChangeActionContentCellType GetContentCellType( const ScCellValue& rCell );
-    static ScChangeActionContentCellType GetContentCellType( const ScCellIterator& rIter );
+    static ScChangeActionContentCellType GetContentCellType( const ScRefCellValue& rIter );
 
     // NewCell
     bool IsMatrixOrigin() const;
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 58d1215..4f3ab26 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -24,6 +24,7 @@
 #include <tools/solar.h>
 #include "global.hxx"
 #include "scdllapi.h"
+#include "cellvalue.hxx"
 
 #include <memory>
 
@@ -45,7 +46,6 @@ struct ScQueryParam;
 struct ScDBQueryParamInternal;
 struct ScDBQueryParamMatrix;
 class ScFormulaCell;
-struct ScCellValue;
 
 class ScDocumentIterator                // walk through all non-empty cells
 {
@@ -222,13 +222,7 @@ private:
     SCSIZE mnIndex;
     bool mbSubTotal;
 
-    CellType meCurType;
-    OUString maCurString;
-    union {
-        double mfCurValue;
-        const EditTextObject* mpCurEditText; // points to the original.
-        ScFormulaCell* mpCurFormula; // points to the original.
-    };
+    ScRefCellValue maCurCell;
 
     void init();
     bool getCurrent();
@@ -245,9 +239,11 @@ public:
     const ScFormulaCell* getFormulaCell() const;
     double getValue() const;
     ScCellValue getCellValue() const;
+    ScRefCellValue getRefCellValue() const;
 
     bool hasString() const;
     bool hasNumeric() const;
+    bool hasEmptyData() const;
     bool isEmpty() const;
     bool equalsWithoutFormat( const ScAddress& rPos ) const;
 
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 9f7dd02..adb7787 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -943,9 +943,7 @@ ScCellIterator::ScCellIterator( ScDocument* pDoc, const ScRange& rRange, bool bS
     maStartPos(rRange.aStart),
     maEndPos(rRange.aEnd),
     mnIndex(0),
-    mbSubTotal(bSTotal),
-    meCurType(CELLTYPE_NONE),
-    mfCurValue(0.0)
+    mbSubTotal(bSTotal)
 {
     init();
 }
@@ -996,7 +994,7 @@ bool ScCellIterator::getCurrent()
                     maCurPos.IncTab();
                     if (maCurPos.Tab() > maEndPos.Tab())
                     {
-                        meCurType = CELLTYPE_NONE;
+                        maCurCell.clear();
                         return false; // Over and out
                     }
                 }
@@ -1021,26 +1019,26 @@ bool ScCellIterator::getCurrent()
                 else
                 {
                     // Found it!
-                    meCurType = pCell->GetCellType();
-                    switch (meCurType)
+                    maCurCell.meType = pCell->GetCellType();
+                    switch (maCurCell.meType)
                     {
                         case CELLTYPE_VALUE:
-                            mfCurValue = static_cast<const ScValueCell*>(pCell)->GetValue();
+                            maCurCell.mfValue = static_cast<const ScValueCell*>(pCell)->GetValue();
                         break;
                         case CELLTYPE_STRING:
-                            maCurString = static_cast<const ScStringCell*>(pCell)->GetString();
+                            maCurCell.mpString = static_cast<const ScStringCell*>(pCell)->GetStringPtr();
                         break;
                         case CELLTYPE_EDIT:
-                            mpCurEditText = static_cast<const ScEditCell*>(pCell)->GetData();
+                            maCurCell.mpEditText = static_cast<const ScEditCell*>(pCell)->GetData();
                         break;
                         case CELLTYPE_FORMULA:
-                            mpCurFormula = static_cast<ScFormulaCell*>(pCell);
+                            maCurCell.mpFormula = static_cast<ScFormulaCell*>(pCell);
                         break;
                         default:
-                            meCurType = CELLTYPE_NONE;
+                            maCurCell.meType = CELLTYPE_NONE;
                     }
 
-                    if (meCurType != CELLTYPE_NONE)
+                    if (maCurCell.meType != CELLTYPE_NONE)
                         return true;
 
                     maCurPos.IncRow();
@@ -1057,21 +1055,21 @@ bool ScCellIterator::getCurrent()
 
 CellType ScCellIterator::getType() const
 {
-    return meCurType;
+    return maCurCell.meType;
 }
 
 OUString ScCellIterator::getString()
 {
-    switch (meCurType)
+    switch (maCurCell.meType)
     {
         case CELLTYPE_STRING:
-            return maCurString;
+            return *maCurCell.mpString;
         case CELLTYPE_EDIT:
-            if (mpCurEditText)
-                return ScEditUtil::GetString(*mpCurEditText);
+            if (maCurCell.mpEditText)
+                return ScEditUtil::GetString(*maCurCell.mpEditText);
         break;
         case CELLTYPE_FORMULA:
-            return mpCurFormula->GetString();
+            return maCurCell.mpFormula->GetString();
         default:
             ;
     }
@@ -1080,27 +1078,27 @@ OUString ScCellIterator::getString()
 
 const EditTextObject* ScCellIterator::getEditText() const
 {
-    return mpCurEditText;
+    return maCurCell.mpEditText;
 }
 
 ScFormulaCell* ScCellIterator::getFormulaCell()
 {
-    return mpCurFormula;
+    return maCurCell.mpFormula;
 }
 
 const ScFormulaCell* ScCellIterator::getFormulaCell() const
 {
-    return mpCurFormula;
+    return maCurCell.mpFormula;
 }
 
 double ScCellIterator::getValue() const
 {
-    switch (meCurType)
+    switch (maCurCell.meType)
     {
         case CELLTYPE_VALUE:
-            return mfCurValue;
+            return maCurCell.mfValue;
         case CELLTYPE_FORMULA:
-            return mpCurFormula->GetValue();
+            return maCurCell.mpFormula->GetValue();
         default:
             ;
     }
@@ -1110,21 +1108,21 @@ double ScCellIterator::getValue() const
 ScCellValue ScCellIterator::getCellValue() const
 {
     ScCellValue aRet;
-    aRet.meType = meCurType;
+    aRet.meType = maCurCell.meType;
 
-    switch (meCurType)
+    switch (maCurCell.meType)
     {
         case CELLTYPE_STRING:
-            aRet.mpString = new OUString(maCurString);
+            aRet.mpString = new OUString(*maCurCell.mpString);
         break;
         case CELLTYPE_EDIT:
-            aRet.mpEditText = mpCurEditText->Clone();
+            aRet.mpEditText = maCurCell.mpEditText->Clone();
         break;
         case CELLTYPE_VALUE:
-            aRet.mfValue = mfCurValue;
+            aRet.mfValue = maCurCell.mfValue;
         break;
         case CELLTYPE_FORMULA:
-            aRet.mpFormula = mpCurFormula->Clone();
+            aRet.mpFormula = maCurCell.mpFormula->Clone();
         break;
         default:
             ;
@@ -1133,133 +1131,42 @@ ScCellValue ScCellIterator::getCellValue() const
     return aRet;
 }
 
-bool ScCellIterator::hasString() const
+ScRefCellValue ScCellIterator::getRefCellValue() const
 {
-    switch (meCurType)
-    {
-        case CELLTYPE_STRING:
-        case CELLTYPE_EDIT:
-            return true;
-        case CELLTYPE_FORMULA:
-            return !mpCurFormula->IsValue();
-        default:
-            ;
-    }
+    return maCurCell;
+}
 
-    return false;
+bool ScCellIterator::hasString() const
+{
+    return maCurCell.hasString();
 }
 
 bool ScCellIterator::hasNumeric() const
 {
-    switch (meCurType)
-    {
-        case CELLTYPE_VALUE:
-            return true;
-        case CELLTYPE_FORMULA:
-            return mpCurFormula->IsValue();
-        default:
-            ;
-    }
-
-    return false;
+    return maCurCell.hasNumeric();
 }
 
-bool ScCellIterator::isEmpty() const
+bool ScCellIterator::hasEmptyData() const
 {
-    switch (meCurType)
-    {
-        case CELLTYPE_NOTE:
-        case CELLTYPE_NONE:
-            return true;
-        case CELLTYPE_FORMULA:
-            return mpCurFormula->IsEmpty();
-        default:
-            ;
-    }
-    return false;
-}
+    if (maCurCell.isEmpty())
+        return true;
 
-namespace {
+    if (maCurCell.meType == CELLTYPE_FORMULA)
+        return maCurCell.mpFormula->IsEmpty();
 
-CellType adjustCellType( CellType eOrig )
-{
-    switch (eOrig)
-    {
-        case CELLTYPE_NOTE:
-            return CELLTYPE_NONE;
-        case CELLTYPE_EDIT:
-            return CELLTYPE_STRING;
-        default:
-            ;
-    }
-    return eOrig;
+    return false;
 }
 
+bool ScCellIterator::isEmpty() const
+{
+    return maCurCell.isEmpty();
 }
 
 bool ScCellIterator::equalsWithoutFormat( const ScAddress& rPos ) const
 {
-    // Fetch the other cell first.
-    if (!mpDoc->TableExists(rPos.Tab()))
-        return false;
-
-    ScTable& rTab = *mpDoc->maTabs[rPos.Tab()];
-    if (!ValidColRow(rPos.Col(), rPos.Row()))
-        return false;
-
-    ScColumn& rCol = rTab.aCol[rPos.Col()];
-    SCSIZE nIndex;
-    if (!rCol.Search(rPos.Row(), nIndex))
-        return false;
-
-    ScBaseCell* pCell2 = rCol.maItems[nIndex].pCell;
-
-    CellType eType1 = adjustCellType(meCurType);
-    CellType eType2 = adjustCellType(pCell2->GetCellType());
-    if (eType1 != eType2)
-        return false;
-
-    switch (eType1)
-    {
-        case CELLTYPE_NONE:
-            // Both are empty.
-            return true;
-        case CELLTYPE_VALUE:
-            return mfCurValue == static_cast<ScValueCell*>(pCell2)->GetValue();
-        case CELLTYPE_STRING:
-        {
-            OUString aStr1;
-            if (meCurType == CELLTYPE_STRING)
-                aStr1 = maCurString;
-            else if (meCurType == CELLTYPE_EDIT)
-                aStr1 = ScEditUtil::GetString(*mpCurEditText);
-
-            OUString aStr2 = pCell2->GetStringData();
-            return aStr1 == aStr2;
-        }
-        case CELLTYPE_FORMULA:
-        {
-            ScTokenArray* pCode1 = mpCurFormula->GetCode();
-            ScTokenArray* pCode2 = static_cast<ScFormulaCell*>(pCell2)->GetCode();
-
-            if (pCode1->GetLen() != pCode2->GetLen())
-                return false;
-
-            sal_uInt16 n = pCode1->GetLen();
-            formula::FormulaToken** ppToken1 = pCode1->GetArray();
-            formula::FormulaToken** ppToken2 = pCode2->GetArray();
-            for (sal_uInt16 i = 0; i < n; ++i)
-            {
-                if (!ppToken1[i]->TextEqual(*(ppToken2[i])))
-                    return false;
-            }
-
-            return true;
-        }
-        default:
-            ;
-    }
-    return false;
+    ScRefCellValue aOther;
+    aOther.assign(*mpDoc, rPos);
+    return maCurCell.equalsWithoutFormat(aOther);
 }
 
 bool ScCellIterator::first()
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index b1b683c..b5ce9c9 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1750,9 +1750,9 @@ ScChangeActionContentCellType ScChangeActionContent::GetContentCellType( const S
     }
 }
 
-ScChangeActionContentCellType ScChangeActionContent::GetContentCellType( const ScCellIterator& rIter )
+ScChangeActionContentCellType ScChangeActionContent::GetContentCellType( const ScRefCellValue& rCell )
 {
-    switch (rIter.getType())
+    switch (rCell.meType)
     {
         case CELLTYPE_VALUE:
         case CELLTYPE_STRING:
@@ -1760,7 +1760,7 @@ ScChangeActionContentCellType ScChangeActionContent::GetContentCellType( const S
             return SC_CACCT_NORMAL;
         case CELLTYPE_FORMULA:
         {
-            const ScFormulaCell* pCell = rIter.getFormulaCell();
+            const ScFormulaCell* pCell = rCell.mpFormula;
             switch (pCell->GetMatrixFlag())
             {
                 case MM_NONE :
@@ -2676,7 +2676,7 @@ void ScChangeTrack::LookUpContents( const ScRange& rOrgRange,
     ScCellIterator aIter( pRefDoc, rOrgRange );
     for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
     {
-        if (!ScChangeActionContent::GetContentCellType(aIter))
+        if (!ScChangeActionContent::GetContentCellType(aIter.getRefCellValue()))
             continue;
 
         aBigPos.Set( aIter.GetPos().Col() + nDx, aIter.GetPos().Row() + nDy,
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 1b598cf..574612c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4156,7 +4156,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
                     ScCellIterator aIter( pDok, aRange, glSubTotal );
                     for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
                     {
-                        if (!aIter.isEmpty())
+                        if (!aIter.hasEmptyData())
                             ++nCount;
                     }
 
@@ -5372,7 +5372,7 @@ void ScInterpreter::ScCountEmptyCells()
                     ScCellIterator aIter( pDok, aRange, glSubTotal);
                     for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
                     {
-                        if (!aIter.isEmpty())
+                        if (!aIter.hasEmptyData())
                             ++nCount;
                     }
                 }
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 8574490..a9a432c 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -428,7 +428,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken
         {
             nThisRow = aCellIter.GetPos().Row();
 
-            if (aCellIter.isEmpty())
+            if (aCellIter.hasEmptyData())
             {
                 aBucket.flush(*pMat, static_cast<SCSIZE>(nCol-nCol1));
                 continue;
commit 0b0e7ca9b3bae3b3295da33e5980f3f4c6a5f532
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 26 12:00:43 2013 -0400

    Add ScRefCellValue, which is ScCellValue without copied value.
    
    It directly points to the original cell value instance.
    
    Change-Id: I638ec8b931873d237871b6d8fa9f0e1277520d0f

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 236ad43..0b78f98 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -175,6 +175,7 @@ public:
 
     inline void     SetString( const rtl::OUString& rString ) { maString = rString; }
     inline const    rtl::OUString& GetString() const { return maString; }
+    const OUString* GetStringPtr() const { return &maString; }
 
 private:
     rtl::OUString   maString;
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 9dd3a9a..7998898 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -19,7 +19,8 @@ class ScBaseCell;
 
 /**
  * Store arbitrary cell value of any kind.  It only stores cell value and
- * nothing else.
+ * nothing else.  It creates a copy of the original cell value, and manages
+ * the life cycle of the copied value.
  */
 struct SC_DLLPUBLIC ScCellValue
 {
@@ -78,6 +79,59 @@ struct SC_DLLPUBLIC ScCellValue
     void swap( ScCellValue& r );
 };
 
+/**
+ * This is very similar to ScCellValue, except that it points to the
+ * original value instead of copying it.  As such, don't hold an instance of
+ * this class any longer than necessary.
+ */
+struct SC_DLLPUBLIC ScRefCellValue
+{
+    CellType meType;
+    union {
+        double mfValue;
+        const OUString* mpString;
+        const EditTextObject* mpEditText;
+        ScFormulaCell* mpFormula;
+    };
+
+    ScRefCellValue();
+    ScRefCellValue( double fValue );
+    ScRefCellValue( const OUString* pString );
+    ScRefCellValue( const EditTextObject* pEditText );
+    ScRefCellValue( ScFormulaCell* pFormula );
+    ScRefCellValue( const ScRefCellValue& r );
+    ~ScRefCellValue();
+
+    void clear();
+
+    /**
+     * Take cell value from specified position in specified document.
+     */
+    void assign( ScDocument& rDoc, const ScAddress& rPos );
+
+    /**
+     * TODO: Remove this later.
+     */
+    void assign( ScBaseCell& rCell );
+
+    /**
+     * Set cell value at specified position in specified document.
+     */
+    void commit( ScDocument& rDoc, const ScAddress& rPos ) const;
+
+    bool hasString() const;
+
+    bool hasNumeric() const;
+
+    bool isEmpty() const;
+
+    bool equalsWithoutFormat( const ScRefCellValue& r ) const;
+
+    ScRefCellValue& operator= ( const ScRefCellValue& r );
+
+    void swap( ScRefCellValue& r );
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index f25dc78..ac329b2 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -272,6 +272,7 @@ public:
     void        SetError( SCROW nRow, const sal_uInt16 nError);
 
     void        GetString( SCROW nRow, rtl::OUString& rString ) const;
+    const OUString* GetStringCell( SCROW nRow ) const;
     void        GetInputString( SCROW nRow, rtl::OUString& rString ) const;
     double      GetValue( SCROW nRow ) const;
     const EditTextObject* GetEditText( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 70c5620..892d18f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -802,6 +802,17 @@ public:
 
     SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
     OUString GetString( const ScAddress& rPos ) const;
+
+    /**
+     * Return a pointer to the string object stored in string cell.
+     *
+     * @param rPos cell position.
+     *
+     * @return pointer to the string object stored in string cell, or NULL if
+     *         the cell at specified position is not a string cell. Note that
+     *         it returns NULL even for a edit cell.
+     */
+    const OUString* GetStringCell( const ScAddress& rPos ) const;
     SC_DLLPUBLIC void           GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString );
     SC_DLLPUBLIC void           GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, rtl::OUString& rString );
     sal_uInt16                  GetStringForFormula( const ScAddress& rPos, rtl::OUString& rString );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 461da522..0a12ead 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -318,6 +318,7 @@ public:
     void        SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
 
     void        GetString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const;
+    const OUString* GetStringCell( SCCOL nCol, SCROW nRow ) const;
     void        GetInputString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const;
     double      GetValue( const ScAddress& rPos ) const
                     {
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 8b0baa4..5b853a3 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -16,6 +16,121 @@
 #include "editutil.hxx"
 #include "formula/token.hxx"
 
+namespace {
+
+CellType adjustCellType( CellType eOrig )
+{
+    switch (eOrig)
+    {
+        case CELLTYPE_NOTE:
+            return CELLTYPE_NONE;
+        case CELLTYPE_EDIT:
+            return CELLTYPE_STRING;
+        default:
+            ;
+    }
+    return eOrig;
+}
+
+template<typename _T>
+OUString getString( const _T& rVal )
+{
+    if (rVal.meType == CELLTYPE_STRING)
+        return *rVal.mpString;
+
+    if (rVal.meType == CELLTYPE_EDIT)
+    {
+        OUStringBuffer aRet;
+        size_t n = rVal.mpEditText->GetParagraphCount();
+        for (size_t i = 0; i < n; ++i)
+        {
+            if (i > 0)
+                aRet.append('\n');
+            aRet.append(rVal.mpEditText->GetText(i));
+        }
+        return aRet.makeStringAndClear();
+    }
+
+    return EMPTY_OUSTRING;
+}
+
+bool equalsFormulaCells( const ScFormulaCell* p1, const ScFormulaCell* p2 )
+{
+    const ScTokenArray* pCode1 = p1->GetCode();
+    const ScTokenArray* pCode2 = p2->GetCode();
+
+    if (pCode1->GetLen() != pCode2->GetLen())
+        return false;
+
+    sal_uInt16 n = pCode1->GetLen();
+    formula::FormulaToken** ppToken1 = pCode1->GetArray();
+    formula::FormulaToken** ppToken2 = pCode2->GetArray();
+    for (sal_uInt16 i = 0; i < n; ++i)
+    {
+        if (!ppToken1[i]->TextEqual(*(ppToken2[i])))
+            return false;
+    }
+
+    return true;
+}
+
+template<typename _T>
+bool equalsWithoutFormatImpl( const _T& left, const _T& right )
+{
+    CellType eType1 = adjustCellType(left.meType);
+    CellType eType2 = adjustCellType(right.meType);
+    if (eType1 != eType2)
+        return false;
+
+    switch (eType1)
+    {
+        case CELLTYPE_NONE:
+            return true;
+        case CELLTYPE_VALUE:
+            return left.mfValue == right.mfValue;
+        case CELLTYPE_STRING:
+        {
+            OUString aStr1 = getString(left);
+            OUString aStr2 = getString(right);
+            return aStr1 == aStr2;
+        }
+        case CELLTYPE_FORMULA:
+            return equalsFormulaCells(left.mpFormula, right.mpFormula);
+        default:
+            ;
+    }
+    return false;
+}
+
+bool hasStringImpl( CellType eType, ScFormulaCell* pFormula )
+{
+    switch (eType)
+    {
+        case CELLTYPE_STRING:
+        case CELLTYPE_EDIT:
+            return true;
+        case CELLTYPE_FORMULA:
+            return !pFormula->IsValue();
+        default:
+            return false;
+    }
+}
+
+bool hasNumericImpl( CellType eType, ScFormulaCell* pFormula )
+{
+    switch (eType)
+    {
+        case CELLTYPE_VALUE:
+            return true;
+        case CELLTYPE_FORMULA:
+            return pFormula->IsValue();
+        default:
+            return false;
+    }
+}
+
+}
+
 ScCellValue::ScCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {}
 ScCellValue::ScCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
 ScCellValue::ScCellValue( const OUString& rString ) : meType(CELLTYPE_STRING), mpString(new OUString(rString)) {}
@@ -223,29 +338,12 @@ void ScCellValue::release( ScDocument& rDoc, const ScAddress& rPos )
 
 bool ScCellValue::hasString() const
 {
-    switch (meType)
-    {
-        case CELLTYPE_STRING:
-        case CELLTYPE_EDIT:
-            return true;
-        case CELLTYPE_FORMULA:
-            return !mpFormula->IsValue();
-        default:
-            return false;
-    }
+    return hasStringImpl(meType, mpFormula);
 }
 
 bool ScCellValue::hasNumeric() const
 {
-    switch (meType)
-    {
-        case CELLTYPE_VALUE:
-            return true;
-        case CELLTYPE_FORMULA:
-            return mpFormula->IsValue();
-        default:
-            return false;
-    }
+    return hasNumericImpl(meType, mpFormula);
 }
 
 bool ScCellValue::isEmpty() const
@@ -253,97 +351,150 @@ bool ScCellValue::isEmpty() const
     return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE;
 }
 
-namespace {
+bool ScCellValue::equalsWithoutFormat( const ScCellValue& r ) const
+{
+    return equalsWithoutFormatImpl(*this, r);
+}
 
-CellType adjustCellType( CellType eOrig )
+ScCellValue& ScCellValue::operator= ( const ScCellValue& r )
 {
-    switch (eOrig)
+    ScCellValue aTmp(r);
+    swap(aTmp);
+    return *this;
+}
+
+void ScCellValue::swap( ScCellValue& r )
+{
+    std::swap(meType, r.meType);
+
+    // double is 8 bytes, whereas a pointer may be 4 or 8 bytes depending on
+    // the platform. Swap by double values.
+    std::swap(mfValue, r.mfValue);
+}
+
+ScRefCellValue::ScRefCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {}
+ScRefCellValue::ScRefCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
+ScRefCellValue::ScRefCellValue( const OUString* pString ) : meType(CELLTYPE_STRING), mpString(pString) {}
+ScRefCellValue::ScRefCellValue( const EditTextObject* pEditText ) : meType(CELLTYPE_EDIT), mpEditText(pEditText) {}
+ScRefCellValue::ScRefCellValue( ScFormulaCell* pFormula ) : meType(CELLTYPE_FORMULA), mpFormula(pFormula) {}
+
+// It should be enough to copy the double value, which is at least as large
+// as the pointer values.
+ScRefCellValue::ScRefCellValue( const ScRefCellValue& r ) : meType(r.meType), mfValue(r.mfValue) {}
+
+ScRefCellValue::~ScRefCellValue()
+{
+    clear();
+}
+
+void ScRefCellValue::clear()
+{
+    // Reset to empty value.
+    meType = CELLTYPE_NONE;
+    mfValue = 0.0;
+}
+
+void ScRefCellValue::assign( ScDocument& rDoc, const ScAddress& rPos )
+{
+    clear();
+
+    meType = rDoc.GetCellType(rPos);
+    switch (meType)
     {
-        case CELLTYPE_NOTE:
-            return CELLTYPE_NONE;
+        case CELLTYPE_STRING:
+            mpString = rDoc.GetStringCell(rPos);
+        break;
         case CELLTYPE_EDIT:
-            return CELLTYPE_STRING;
+            mpEditText = rDoc.GetEditText(rPos);
+        break;
+        case CELLTYPE_VALUE:
+            mfValue = rDoc.GetValue(rPos);
+        break;
+        case CELLTYPE_FORMULA:
+            mpFormula = rDoc.GetFormulaCell(rPos);
+        break;
         default:
-            ;
+            meType = CELLTYPE_NONE; // reset to empty.
     }
-    return eOrig;
 }
 
-OUString getString( const ScCellValue& rVal )
+void ScRefCellValue::assign( ScBaseCell& rCell )
 {
-    if (rVal.meType == CELLTYPE_STRING)
-        return *rVal.mpString;
+    clear();
 
-    if (rVal.meType == CELLTYPE_EDIT)
+    meType = rCell.GetCellType();
+    switch (meType)
     {
-        OUStringBuffer aRet;
-        size_t n = rVal.mpEditText->GetParagraphCount();
-        for (size_t i = 0; i < n; ++i)
-        {
-            if (i > 0)
-                aRet.append('\n');
-            aRet.append(rVal.mpEditText->GetText(i));
-        }
-        return aRet.makeStringAndClear();
+        case CELLTYPE_STRING:
+            mpString = static_cast<const ScStringCell&>(rCell).GetStringPtr();
+        break;
+        case CELLTYPE_EDIT:
+            mpEditText = static_cast<const ScEditCell&>(rCell).GetData();
+        break;
+        case CELLTYPE_VALUE:
+            mfValue = static_cast<const ScValueCell&>(rCell).GetValue();
+        break;
+        case CELLTYPE_FORMULA:
+            mpFormula = static_cast<ScFormulaCell*>(&rCell);
+        break;
+        default:
+            meType = CELLTYPE_NONE; // reset to empty.
     }
-
-    return EMPTY_OUSTRING;
 }
 
-}
-
-bool ScCellValue::equalsWithoutFormat( const ScCellValue& r ) const
+void ScRefCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) const
 {
-    CellType eType1 = adjustCellType(meType);
-    CellType eType2 = adjustCellType(r.meType);
-    if (eType1 != eType2)
-        return false;
-
     switch (meType)
     {
-        case CELLTYPE_NONE:
-            return true;
-        case CELLTYPE_VALUE:
-            return mfValue == r.mfValue;
         case CELLTYPE_STRING:
         {
-            OUString aStr1 = getString(*this);
-            OUString aStr2 = getString(r);
-            return aStr1 == aStr2;
+            ScSetStringParam aParam;
+            aParam.setTextInput();
+            rDoc.SetString(rPos, *mpString, &aParam);
         }
+        break;
+        case CELLTYPE_EDIT:
+            rDoc.SetEditText(rPos, mpEditText->Clone());
+        break;
+        case CELLTYPE_VALUE:
+            rDoc.SetValue(rPos, mfValue);
+        break;
         case CELLTYPE_FORMULA:
-        {
-            ScTokenArray* pCode1 = mpFormula->GetCode();
-            ScTokenArray* pCode2 = r.mpFormula->GetCode();
+            rDoc.SetFormulaCell(rPos, mpFormula->Clone());
+        break;
+        default:
+            rDoc.SetEmptyCell(rPos);
+    }
+}
 
-            if (pCode1->GetLen() != pCode2->GetLen())
-                return false;
+bool ScRefCellValue::hasString() const
+{
+    return hasStringImpl(meType, mpFormula);
+}
 
-            sal_uInt16 n = pCode1->GetLen();
-            formula::FormulaToken** ppToken1 = pCode1->GetArray();
-            formula::FormulaToken** ppToken2 = pCode2->GetArray();
-            for (sal_uInt16 i = 0; i < n; ++i)
-            {
-                if (!ppToken1[i]->TextEqual(*(ppToken2[i])))
-                    return false;
-            }
+bool ScRefCellValue::hasNumeric() const
+{
+    return hasNumericImpl(meType, mpFormula);
+}
 
-            return true;
-        }
-        default:
-            ;
-    }
-    return false;
+bool ScRefCellValue::isEmpty() const
+{
+    return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE;
 }
 
-ScCellValue& ScCellValue::operator= ( const ScCellValue& r )
+bool ScRefCellValue::equalsWithoutFormat( const ScRefCellValue& r ) const
 {
-    ScCellValue aTmp(r);
+    return equalsWithoutFormatImpl(*this, r);
+}
+
+ScRefCellValue& ScRefCellValue::operator= ( const ScRefCellValue& r )
+{
+    ScRefCellValue aTmp(r);
     swap(aTmp);
     return *this;
 }
 
-void ScCellValue::swap( ScCellValue& r )
+void ScRefCellValue::swap( ScRefCellValue& r )
 {
     std::swap(meType, r.meType);
 
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3297b88..3a591cd 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1758,6 +1758,18 @@ void ScColumn::GetString( SCROW nRow, rtl::OUString& rString ) const
         rString = rtl::OUString();
 }
 
+const OUString* ScColumn::GetStringCell( SCROW nRow ) const
+{
+    SCSIZE  nIndex;
+    if (!Search(nRow, nIndex))
+        return NULL;
+
+    const ScBaseCell* pCell = maItems[nIndex].pCell;
+    if (pCell->GetCellType() != CELLTYPE_STRING)
+        return NULL;
+
+    return static_cast<const ScStringCell*>(pCell)->GetStringPtr();
+}
 
 void ScColumn::GetInputString( SCROW nRow, rtl::OUString& rString ) const
 {
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 6ebbf39..1603d23 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3053,6 +3053,14 @@ OUString ScDocument::GetString( const ScAddress& rPos ) const
     return aStr;
 }
 
+const OUString* ScDocument::GetStringCell( const ScAddress& rPos ) const
+{
+    if (!TableExists(rPos.Tab()))
+        return NULL;
+
+    return maTabs[rPos.Tab()]->GetStringCell(rPos.Col(), rPos.Row());
+}
+
 void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString )
 {
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index f6d34c2..319226f 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1404,6 +1404,13 @@ void ScTable::GetString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const
         rString = rtl::OUString();
 }
 
+const OUString* ScTable::GetStringCell( SCCOL nCol, SCROW nRow ) const
+{
+    if (!ValidColRow(nCol,nRow))
+        return NULL;
+
+    return aCol[nCol].GetStringCell(nRow);
+}
 
 void ScTable::GetInputString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const
 {
commit 0fb1409d9682f118d28f89e27bba7887882dad91
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 26 10:42:06 2013 -0400

    This method no longer used. Good. Remove it.
    
    Change-Id: I397dedd6c7388b350af0f93151fdf0160698acc7

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 8c513aa..58d1215 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -76,7 +76,6 @@ public:
     bool                    GetFirst();
     bool                    GetNext();
 
-    ScBaseCell*             GetCell();
     ScCellValue GetCellValue() const;
     const ScPatternAttr*    GetPattern();
     void                    GetPos( SCCOL& rCol, SCROW& rRow, SCTAB& rTab );
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 24fd2b3..9f7dd02 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -197,13 +197,6 @@ bool ScDocumentIterator::GetNext()
     return GetThis();
 }
 
-//------------------------------------------------------------------------
-
-ScBaseCell* ScDocumentIterator::GetCell()
-{
-    return pCell;
-}
-
 ScCellValue ScDocumentIterator::GetCellValue() const
 {
     ScCellValue aRet;
commit c575e7f484817e355d5451ed001b4f874b63ff68
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 21:25:05 2013 +0200

    Fix bogus SAL_WARN use
    
    unknown log area 'IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl) [loplugin], huh?
    
    Change-Id: I265102a552615208db43fc7b6617189ad99b6aad

diff --git a/sal/inc/sal/log-areas.dox b/sal/inc/sal/log-areas.dox
index d473ff4..4f01fd5 100644
--- a/sal/inc/sal/log-areas.dox
+++ b/sal/inc/sal/log-areas.dox
@@ -260,6 +260,7 @@ certain functionality.
 @li @c sw
 @li @c sw.core - Writer core
 @li @c sw.docx
+ at li @c sw.envelp
 @li @c sw.level2
 @li @c sw.rtf - .rtf export filter
 @li @c sw.uno - Writer UNO interfaces
diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index bab1b18..7cfe360 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -631,7 +631,7 @@ IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl)
     {
         if ( rCfg.IsPredefinedLabel(sMake, sType) )
         {
-            SAL_WARN( "IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl)", "label is predefined and cannot be overwritten" );
+            SAL_WARN( "sw.envelp", "label is predefined and cannot be overwritten" );
             WarningBox( this, SW_RES( WB_PREDEFINED_LABEL ) ).Execute();
             return 0;
         }
commit c947d49b5e2cd96de137460311e54952d03414d2
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 21:19:33 2013 +0200

    Fix warning: statement aligned ... [loplugin]
    
    Change-Id: I0a0c40545101a82c9a4054c7a7ccd03e7cfa24d4

diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index d5ae614..67d5c9a 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -799,7 +799,7 @@ void SwWW8WrGrf::WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf,
         Set_UInt16( pArr, (sal_uInt16)::rtl::math::round(fVal) );
     }
     else
-    pArr += 2;
+        pArr += 2;
 
     Set_UInt16( pArr, nCropL );                     // set dxaCropLeft
     Set_UInt16( pArr, nCropT );                     // set dyaCropTop
commit dcac52821c28d2e6cd1240cdafaabb4c47b32dcf
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 21:16:03 2013 +0200

    Fix warning: statement aligned ... [loplugin]
    
    Change-Id: I8c9da74100d9c3db26ddb3aeaf18b1f199c4a297

diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 2944b59..bd87f34 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -332,7 +332,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl)
                 mpGraphicFilter->ImportGraphic( aGraphic, sImgUrl, *pStream, nFilter, NULL, nFilterImportFlags );
             else
                 mpGraphicFilter->ImportGraphic( aGraphic, aURLObj, nFilter, NULL, nFilterImportFlags );
-                delete pStream;
+            delete pStream;
         }
         else
         {
commit 60e55c7c2e9f9e6ad389b4527fa6332378e55e12
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Tue Mar 26 19:46:11 2013 +0100

    remove duplicate declaration
    
    Change-Id: I3ef565d61096189a9abe45a5a43951ceb7aff724

diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 5af60c8..45e0d08 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -3038,7 +3038,6 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT
                             if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextHorizontalAdjust" ) ), sal_True ) )
                             {
                                 MSO_GeoTextAlign  gTextAlign = mso_alignTextCenter;
-                                SdrFitToSizeType  eFTS( ((SdrTextFitToSizeTypeItem&)pCustoShape->GetMergedItem( SDRATTR_TEXT_FITTOSIZE )).GetValue() );
                                 drawing::TextHorizontalAdjust   eHA( drawing::TextHorizontalAdjust_LEFT );
                                 aAny >>= eHA;
                                 switch( eHA )
commit 2003acca7b2ffc5a494182685e6983c90c39d137
Author: Andre Fischer <af at apache.org>
Date:   Fri Jul 6 13:02:06 2012 +0000

    #i119884# Fixed export of fontwork alignment.
    
    Reported by: Li Feng Wang
    Patch by: SunYing
    Review by: Andre Fischer

diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 25a8443..5af60c8 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -70,6 +70,7 @@
 #include <com/sun/star/drawing/ProjectionMode.hpp>
 #include <com/sun/star/text/XSimpleText.hpp>
 #include <com/sun/star/drawing/ShadeMode.hpp>
+#include <com/sun/star/drawing/TextFitToSizeType.hpp>
 #include <vcl/hatch.hxx>
 #include <com/sun/star/awt/XGraphics.hpp>
 #include <com/sun/star/awt/FontSlant.hpp>
@@ -3033,6 +3034,42 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT
                                         nTextPathFlags &=~0x20;
                                 }
                             }
+                            //export gTextAlign attr
+                            if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextHorizontalAdjust" ) ), sal_True ) )
+                            {
+                                MSO_GeoTextAlign  gTextAlign = mso_alignTextCenter;
+                                SdrFitToSizeType  eFTS( ((SdrTextFitToSizeTypeItem&)pCustoShape->GetMergedItem( SDRATTR_TEXT_FITTOSIZE )).GetValue() );
+                                drawing::TextHorizontalAdjust   eHA( drawing::TextHorizontalAdjust_LEFT );
+                                aAny >>= eHA;
+                                switch( eHA )
+                                {
+                                case drawing::TextHorizontalAdjust_LEFT :
+                                    gTextAlign = mso_alignTextLeft;
+                                    break;
+                                case drawing::TextHorizontalAdjust_CENTER:
+                                    gTextAlign = mso_alignTextCenter;
+                                    break;
+                                case drawing::TextHorizontalAdjust_RIGHT:
+                                    gTextAlign = mso_alignTextRight;
+                                    break;
+                                case drawing::TextHorizontalAdjust_BLOCK:
+                                    {
+                                        SdrFitToSizeType  eFTS( ((SdrTextFitToSizeTypeItem&)pCustoShape->GetMergedItem( SDRATTR_TEXT_FITTOSIZE )).GetValue() );
+                                        if ( eFTS == SDRTEXTFIT_ALLLINES)
+                                        {
+                                            gTextAlign = mso_alignTextStretch;
+                                        }
+                                        else
+                                        {
+                                            gTextAlign = mso_alignTextWordJust;
+                                        }
+                                        break;
+                                    }
+                                default:
+                                    break;
+                                }
+                                AddOpt(DFF_Prop_gtextAlign,gTextAlign);
+                            }
                         }
                         if ( nTextPathFlags != nTextPathFlagsOrg )
                             AddOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags );
commit 8bfc664c6188b0d9128e80f5222bf252e854bff3
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Mar 26 19:32:20 2013 +0100

    autoconf can actually handle #define HAVE_FOO 0 as the default
    
    Change-Id: I6cd70d885a3fe3ab53f7523d1a5da6ae30ee01e3

diff --git a/config_host/README b/config_host/README
index 4f9d3ce..0e09752 100644
--- a/config_host/README
+++ b/config_host/README
@@ -20,11 +20,7 @@ Adding a new setting:
         - add AC_CONFIG_HEADERS([config_host/config_XXX.h]) next to the others
             in configure.ac
         - add config_XXX.h to config_host/.gitignore
-- add #undef HAVE_FOO to the config_host/config_XXX.h , possibly with a comment
-- if the setting is an on/off setting (i.e. not a value of anything),
-  add the following block right after it
-#ifndef HAVE_FOO
-#define HAVE_FOO 0
-#endif
+- add #define HAVE_FOO 0 to the config_host/config_XXX.h , possibly with a comment
+  (do not use #undef HAVE_FOO, unless the setting has more values than on/off)
 - add #include <config_XXX.h> before any #if HAVE_FOO in a source file
-- make sure you use #if HAVE_FOO, do not use #ifdef
+- make sure you use #if HAVE_FOO for on/off settings, do not use #ifdef
diff --git a/config_host/config_global.h.in b/config_host/config_global.h.in
index fa37a17..1e256b6 100644
--- a/config_host/config_global.h.in
+++ b/config_host/config_global.h.in
@@ -12,42 +12,14 @@ Any change in this header will cause a rebuild of almost everything.
 #ifndef CONFIG_GLOBAL_H
 #define CONFIG_GLOBAL_H
 
-#undef HAVE_CXX11_DELETE
-#ifndef HAVE_CXX11_DELETE
 #define HAVE_CXX11_DELETE 0
-#endif
-
-#undef HAVE_CXX11_OVERRIDE
-#ifndef HAVE_CXX11_OVERRIDE
 #define HAVE_CXX11_OVERRIDE 0
-#endif
-
-#undef HAVE_CXX11_PERFECT_FORWARDING
-#ifndef HAVE_CXX11_PERFECT_FORWARDING
 #define HAVE_CXX11_PERFECT_FORWARDING 0
-#endif
-
-#undef HAVE_GCC_BUILTIN_ATOMIC
-#ifndef HAVE_GCC_BUILTIN_ATOMIC
 #define HAVE_GCC_BUILTIN_ATOMIC 0
-#endif
-
 #define HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY 0
 #define HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE 0
-
-#undef HAVE_SFINAE_ANONYMOUS_BROKEN
-#ifndef HAVE_SFINAE_ANONYMOUS_BROKEN
 #define HAVE_SFINAE_ANONYMOUS_BROKEN 0
-#endif
-
-#undef HAVE_THREADSAFE_STATICS
-#ifndef HAVE_THREADSAFE_STATICS
 #define HAVE_THREADSAFE_STATICS 0
-#endif
-
-#undef HAVE_SYSLOG_H
-#ifndef HAVE_SYSLOG_H
 #define HAVE_SYSLOG_H 0
-#endif
 
 #endif
diff --git a/config_host/config_graphite.h.in b/config_host/config_graphite.h.in
index 2822abf..46e624d 100644
--- a/config_host/config_graphite.h.in
+++ b/config_host/config_graphite.h.in
@@ -1,9 +1,6 @@
 #ifndef CONFIG_GRAPHITE_H
 #define CONFIG_GRAPHITE_H
 
-#undef ENABLE_GRAPHITE
-#ifndef ENABLE_GRAPHITE
 #define ENABLE_GRAPHITE 0
-#endif
 
 #endif
diff --git a/config_host/config_kde4.h.in b/config_host/config_kde4.h.in
index 654d235..6e91b38 100644
--- a/config_host/config_kde4.h.in
+++ b/config_host/config_kde4.h.in
@@ -5,9 +5,6 @@ Settings for KDE4 integration.
 #ifndef CONFIG_KDE4_H
 #define CONFIG_KDE4_H
 
-#undef KDE_HAVE_GLIB
-#ifndef KDE_HAVE_GLIB
 #define KDE_HAVE_GLIB 0
-#endif
 
 #endif
diff --git a/config_host/config_mingw.h.in b/config_host/config_mingw.h.in
index 3747b7a..44d0ac9 100644
--- a/config_host/config_mingw.h.in
+++ b/config_host/config_mingw.h.in
@@ -1,9 +1,6 @@
 #ifndef CONFIG_MINGW
 #define CONFIG_MINGW
 
-#undef HAVE_FMERGENEUTRALITEMS
-#ifndef HAVE_FMERGENEUTRALITEMS
 #define HAVE_FMERGENEUTRALITEMS 0
-#endif
 
 #endif
diff --git a/config_host/config_telepathy.h.in b/config_host/config_telepathy.h.in
index 22bdc15..c5310bf 100644
--- a/config_host/config_telepathy.h.in
+++ b/config_host/config_telepathy.h.in
@@ -1,9 +1,6 @@
 #ifndef CONFIG_TELEPATHY
 #define CONFIG_TELEPATHY
 
-#undef ENABLE_TELEPATHY
-#ifndef ENABLE_TELEPATHY
 #define ENABLE_TELEPATHY 0
-#endif
 
 #endif
diff --git a/config_host/config_vclplug.h.in b/config_host/config_vclplug.h.in
index 9088a85..8eecf34 100644
--- a/config_host/config_vclplug.h.in
+++ b/config_host/config_vclplug.h.in
@@ -7,24 +7,9 @@ Settings about which X11 desktops have support enabled.
 #ifndef CONFIG_VCLPLUG_H
 #define CONFIG_VCLPLUG_H
 
-#undef ENABLE_GTK
-#ifndef ENABLE_GTK
 #define ENABLE_GTK 0
-#endif
-
-#undef ENABLE_KDE
-#ifndef ENABLE_KDE
 #define ENABLE_KDE 0
-#endif
-
-#undef ENABLE_KDE4
-#ifndef ENABLE_KDE4
 #define ENABLE_KDE4 0
-#endif
-
-#undef ENABLE_TDE
-#ifndef ENABLE_TDE
 #define ENABLE_TDE 0
-#endif
 
 #endif
commit 3326a85ae6ad417b37deeee52fd9a806f42004ba
Author: Peter Foley <pefoley2 at verizon.net>
Date:   Tue Mar 26 14:11:18 2013 -0400

    fix postgresql build
    
    Change-Id: I379029dbf600769e415582aa7162f320e707c3da

diff --git a/bin/module-deps.pl b/bin/module-deps.pl
index 7f39b58..de8022c 100755
--- a/bin/module-deps.pl
+++ b/bin/module-deps.pl
@@ -163,6 +163,7 @@ sub prune_redundant_deps($)
 sub create_lib_module_map()
 {
     my %l2m;
+    $l2m{'merged'} = 'merged';
     for (glob($src_root."/*/Library_*.mk"))
     {
         /.*\/(.*)\/Library_(.*)\.mk/;
diff --git a/connectivity/Library_postgresql-sdbc-impl.mk b/connectivity/Library_postgresql-sdbc-impl.mk
index d733f01..00832dd 100644
--- a/connectivity/Library_postgresql-sdbc-impl.mk
+++ b/connectivity/Library_postgresql-sdbc-impl.mk
@@ -61,7 +61,7 @@ $(eval $(call gb_Library_use_externals,postgresql-sdbc-impl,\
 	boost_headers \
 	postgresql \
 	openssl \
-	openldap \
+	$(if $(SYSTEM_OPENLDAP),openldap) \
 	nss3 \
 	plc4 \
 	ssl3 \
diff --git a/postgresql/ExternalPackage_postgresql.mk b/postgresql/ExternalPackage_postgresql.mk
index ace19d0..bc5aee1 100644
--- a/postgresql/ExternalPackage_postgresql.mk
+++ b/postgresql/ExternalPackage_postgresql.mk
@@ -24,8 +24,5 @@ else
 $(eval $(call gb_ExternalPackage_add_files,postgresql,lib,\
 	src/interfaces/libpq/libpq.a \
 ))
-$(eval $(call gb_ExternalPackage_add_files,postgresql,inc/postgresql,\
-	src/interfaces/libpq/libpq-flags.mk \
-))
 endif
 # vim: set noet sw=4 ts=4:
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 61bdec4..52d2684 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -826,15 +826,15 @@ $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Librar
 $$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
 endif
 
-# used by bin/module-deps.pl
-ifneq ($(ENABLE_PRINT_DEPS),)
-$$(eval $$(call gb_PrintDeps_info,$(1),$(2),$(3),$(4)))
-endif
-
 gb_LINKED_LIBS := $(if $(filter $(gb_MERGEDLIBS),$(2)), \
 	$(if $(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktargetname,$(lib)))),, merged)) \
 	$(filter-out $(gb_MERGEDLIBS),$(2))
 
+# used by bin/module-deps.pl
+ifneq ($(ENABLE_PRINT_DEPS),)
+$$(eval $$(call gb_PrintDeps_info,$(1),$$(gb_LINKED_LIBS),$(3),$(4)))
+endif
+
 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $$(gb_LINKED_LIBS)
 
 $(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$$(gb_LINKED_LIBS),$$(call gb_Library_get_target,$$(lib)))
commit ca9435ecbbf27e1d49a89956c80b527ae5c3efd1
Author: Peter Foley <pefoley2 at verizon.net>
Date:   Tue Mar 26 12:47:06 2013 -0400

    make module-deps.pl work in separate builddir
    
    Change-Id: I951e5b760fa4749cb712a927110e702949e0eaa3

diff --git a/bin/module-deps.pl b/bin/module-deps.pl
index a46634a..7f39b58 100755
--- a/bin/module-deps.pl
+++ b/bin/module-deps.pl
@@ -6,6 +6,7 @@ use Getopt::Long qw(GetOptions VersionMessage);
 use Pod::Usage;
 
 my $gnumake;
+my $src_root;
 my $makefile_build;
 my $verbose = 0;
 my $from_file;
@@ -162,9 +163,9 @@ sub prune_redundant_deps($)
 sub create_lib_module_map()
 {
     my %l2m;
-    for (glob("*/Library_*.mk"))
+    for (glob($src_root."/*/Library_*.mk"))
     {
-        /(.*)\/Library_(.*)\.mk/;
+        /.*\/(.*)\/Library_(.*)\.mk/;
         # add module -> module
         $l2m{$1} = $1;
         # add lib -> module
@@ -303,6 +304,7 @@ sub parse_options()
     ($gnumake, $makefile_build) = @ARGV if $#ARGV == 1;
     $gnumake = 'make' if (!defined $gnumake);
     $makefile_build = 'Makefile.gbuild' if (!defined $makefile_build);
+    $src_root = defined $ENV{SRC_ROOT} ? $ENV{SRC_ROOT} : ".";
 }
 
 sub main()
commit cac094a77f83face15ca40e51033119589756b8e
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Mar 26 19:16:24 2013 +0100

    coverity#982306 Logically dead code
    
    Change-Id: If02e50e1b57e2cae5834ecb17aa0f955572a2c6f

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index b3a26f4..80e9c2f 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -629,7 +629,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
         sal_Bool bSimple = false;
         sal_Bool bCommon = false;
         ScPatternAttr* pCellAttrs = NULL;
-        EditTextObject* pNewData = NULL;
         String aString;
 
         const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
@@ -743,7 +742,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
         lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh );
 
         delete pCellAttrs;
-        delete pNewData;
     }
     else
     {
commit daac7e3828e97d325e11b165a04b58ff4f96b131
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Mar 26 19:11:05 2013 +0100

    coverity#982310 Logically dead code
    
    Change-Id: Iee6d57bc9900d4c88d614eefe6878eaca6f5e2c3

diff --git a/sot/source/sdstor/stgdir.cxx b/sot/source/sdstor/stgdir.cxx
index dedb7cd..fc110ad 100644
--- a/sot/source/sdstor/stgdir.cxx
+++ b/sot/source/sdstor/stgdir.cxx
@@ -970,7 +970,7 @@ void* StgDirStrm::GetEntry( sal_Int32 n, bool bDirty )
         return NULL;
 
     n *= STGENTRY_SIZE;
-    if( n < 0 && n >= nSize )
+    if( n >= nSize )
         return NULL;
     return GetPtr( n, true, bDirty );
 }
commit 0e6a5bf1d9f4106af44996548ab0924ce7e5648c
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Wed May 23 01:14:58 2012 +0000

    framework::RecentFilesMenuController clean-up, add clear item.
    
    Conflicts:
    
    	framework/inc/uielement/recentfilesmenucontroller.hxx
    	framework/source/uielement/recentfilesmenucontroller.cxx
    
    Change-Id: Ia8b861b42bd77a90dce3bebdfa6aefd5e5cd91dd

diff --git a/framework/inc/classes/resource.hrc b/framework/inc/classes/resource.hrc
index f9e3bf6..8d1d236 100644
--- a/framework/inc/classes/resource.hrc
+++ b/framework/inc/classes/resource.hrc
@@ -48,6 +48,8 @@
 #define STR_SET_LANGUAGE_FOR_ALL_TEXT           (RID_STR_START+20)
 #define STR_UNTITLED_DOCUMENT                   (RID_STR_START+21)
 #define STR_RESET_TO_DEFAULT_LANGUAGE           (RID_STR_START+22)
+#define STR_CLEAR_RECENT_FILES                  (RID_STR_START+23)
+#define STR_CLEAR_RECENT_FILES_HELP             (RID_STR_START+24)
 
 #define POPUPMENU_TOOLBAR_QUICKCUSTOMIZATION    (RID_MENU_START+0)
 
diff --git a/framework/inc/uielement/recentfilesmenucontroller.hxx b/framework/inc/uielement/recentfilesmenucontroller.hxx
index 0df0fd3..2b07c41 100644
--- a/framework/inc/uielement/recentfilesmenucontroller.hxx
+++ b/framework/inc/uielement/recentfilesmenucontroller.hxx
@@ -21,23 +21,8 @@
 #define __FRAMEWORK_UIELEMENT_RECENTFILESMENUCONTROLLER_HXX_
 
 #include <macros/xserviceinfo.hxx>
-#include <stdtypes.h>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XTypeProvider.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/frame/XDispatch.hpp>
-#include <com/sun/star/frame/XStatusListener.hpp>
-#include <com/sun/star/frame/XPopupMenuController.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-
 #include <svtools/popupmenucontrollerbase.hxx>
-#include <toolkit/awt/vclxmenu.hxx>
-#include <cppuhelper/weak.hxx>
-#include <rtl/ustring.hxx>
+#include <macros/xserviceinfo.hxx>
 
 namespace framework
 {
@@ -59,9 +44,6 @@ namespace framework
             // XServiceInfo
             DECLARE_XSERVICEINFO
 
-            // XPopupMenuController
-            virtual void SAL_CALL updatePopupMenu() throw (::com::sun::star::uno::RuntimeException);
-
             // XStatusListener
             virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
 
@@ -74,8 +56,6 @@ namespace framework
 
             // XDispatch
             virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& seqProperties ) throw( ::com::sun::star::uno::RuntimeException );
-            virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw( ::com::sun::star::uno::RuntimeException );
-            virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw( ::com::sun::star::uno::RuntimeException );
 
             // XEventListener
             virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
diff --git a/framework/source/classes/resource.src b/framework/source/classes/resource.src
index 567777b..24874e5 100644
--- a/framework/source/classes/resource.src
+++ b/framework/source/classes/resource.src
@@ -104,6 +104,16 @@ String STR_NODOCUMENT
     Text [ en-US ] = "No Documents";
 };
 
+String STR_CLEAR_RECENT_FILES
+{
+    Text [ en-US ] = "Clear List";
+};
+
+String STR_CLEAR_RECENT_FILES_HELP
+{
+    Text [ en-US ] = "Clears the list with the most recently opened files. This action can not be undone.";
+};
+
 String STR_TOOLBAR_TITLE_ADDON
 {
     Text [ en-US ] = "Add-On %num%";
diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx
index f12fbe1..59d6fe5 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -18,45 +18,35 @@
  */
 
 #include <uielement/recentfilesmenucontroller.hxx>
-
 #include <threadhelp/resetableguard.hxx>
 #include "services.h"
 
 #include <classes/resource.hrc>
 #include <classes/fwkresid.hxx>
 
-#include <com/sun/star/awt/XDevice.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/awt/MenuItemStyle.hpp>
 #include <com/sun/star/util/XStringWidth.hpp>
 
-#include <vcl/menu.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/i18nhelp.hxx>
-#include <tools/urlobj.hxx>
-#include <rtl/ustrbuf.hxx>
-#include <unotools/historyoptions.hxx>
 #include <cppuhelper/implbase1.hxx>
 #include <osl/file.hxx>
-#ifdef WNT
-#define GradientStyle_RECT BLA_GradientStyle_RECT
-#include <windows.h>
-#undef GradientStyle_RECT
-#endif
+#include <tools/urlobj.hxx>
+#include <unotools/historyoptions.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/svapp.hxx>
 #include <osl/mutex.hxx>
 
-//_________________________________________________________________________________________________________________
-//  Defines
-//_________________________________________________________________________________________________________________
-
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::frame;
 using namespace com::sun::star::beans;
 using namespace com::sun::star::util;
-using namespace com::sun::star::container;
+
+#define MAX_STR_WIDTH   46
+#define MAX_MENU_ITEMS  99
 
 static const char SFX_REFERER_USER[] = "private:user";
+static const char CMD_CLEAR_LIST[]   = ".uno:ClearRecentFileList";
+static const char CMD_PREFIX[]       = "vnd.sun.star.popup:RecentFileList?entry=";
+static const char MENU_SHOTCUT[]     = "~N: ";
 
 namespace framework
 {
@@ -96,8 +86,8 @@ RecentFilesMenuController::~RecentFilesMenuController()
 // private function
 void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu )
 {
-    VCLXPopupMenu*                                     pPopupMenu        = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu );
-    PopupMenu*                                         pVCLPopupMenu     = 0;
+    VCLXPopupMenu* pPopupMenu    = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu );
+    PopupMenu*     pVCLPopupMenu = 0;
 
     SolarMutexGuard aSolarMutexGuard;
 
@@ -110,11 +100,7 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
         Sequence< Sequence< PropertyValue > > aHistoryList = SvtHistoryOptions().GetList( ePICKLIST );
         Reference< XStringWidth > xStringLength( new RecentFilesStringLength );
 
-        int nPickListMenuItems = ( aHistoryList.getLength() > 99 ) ? 99 : aHistoryList.getLength();
-
-        // New vnd.sun.star.popup: command URL to support direct dispatches
-        const OUString aCmdPrefix( "vnd.sun.star.popup:RecentFileList?entry=" );
-
+        int nPickListMenuItems = ( aHistoryList.getLength() > MAX_MENU_ITEMS ) ? MAX_MENU_ITEMS : aHistoryList.getLength();
         m_aRecentFilesItems.clear();
         if (( nPickListMenuItems > 0 ) && !m_bDisabled )
         {
@@ -141,73 +127,77 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
 
         if ( !m_aRecentFilesItems.empty() )
         {
-            URL aTargetURL;
-
             const sal_uInt32 nCount = m_aRecentFilesItems.size();
             for ( sal_uInt32 i = 0; i < nCount; i++ )
             {
 
-                OUString aMenuShortCut;
+                OUStringBuffer aMenuShortCut;
                 if ( i <= 9 )
                 {
                     if ( i == 9 )
-                        aMenuShortCut = OUString( "1~0: " );
+                        aMenuShortCut.append( "1~0: " );
                     else
                     {
-                        char menuShortCut[5] = "~n: ";
-                        menuShortCut[1] = (char)( '1' + i );
-                        aMenuShortCut = OUString::createFromAscii( menuShortCut );
+                        aMenuShortCut.append( MENU_SHOTCUT );
+                        aMenuShortCut[ 1 ] = sal_Unicode( i + '1' );
                     }
                 }
                 else
                 {
-                    aMenuShortCut = OUString::valueOf((sal_Int32)( i + 1 ));
-                    aMenuShortCut += ": ";
+                    aMenuShortCut.append( sal_Int32( i + 1 ) );
+                    aMenuShortCut.append( ": " );
                 }
 
+                rtl::OUStringBuffer aStrBuffer;
+                aStrBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( CMD_PREFIX ) );
+                aStrBuffer.append( sal_Int32( i ) );
+                rtl::OUString  aURLString( aStrBuffer.makeStringAndClear() );
+
                 // Abbreviate URL
-                OUString   aURLString( aCmdPrefix + OUString::valueOf( sal_Int32( i )));
-                OUString   aTipHelpText;
-                OUString   aMenuTitle;
+                rtl::OUString   aTipHelpText;
+                rtl::OUString   aMenuTitle;
                 INetURLObject   aURL( m_aRecentFilesItems[i].aURL );
 
                 if ( aURL.GetProtocol() == INET_PROT_FILE )
                 {
                     // Do handle file URL differently => convert it to a system
                     // path and abbreviate it with a special function:
-                    String aFileSystemPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
-
-                    OUString aSystemPath( aFileSystemPath );
-                    OUString aCompactedSystemPath;
-
+                    rtl::OUString aSystemPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
                     aTipHelpText = aSystemPath;
-                    oslFileError nError = osl_abbreviateSystemPath( aSystemPath.pData, &aCompactedSystemPath.pData, 46, NULL );
-                    if ( !nError )
-                        aMenuTitle = String( aCompactedSystemPath );
+
+                    ::rtl::OUString aCompactedSystemPath;
+                    if ( osl_abbreviateSystemPath( aSystemPath.pData, &aCompactedSystemPath.pData, MAX_STR_WIDTH, NULL ) == osl_File_E_None )
+                        aMenuTitle = aCompactedSystemPath;
                     else
                         aMenuTitle = aSystemPath;
                 }
                 else
                 {
                     // Use INetURLObject to abbreviate all other URLs
-                    String  aShortURL;
-                    aShortURL = aURL.getAbbreviated( xStringLength, 46, INetURLObject::DECODE_UNAMBIGUOUS );
-                    aMenuTitle += aShortURL;
+                    aMenuTitle   = aURL.getAbbreviated( xStringLength, MAX_STR_WIDTH, INetURLObject::DECODE_UNAMBIGUOUS );
                     aTipHelpText = aURLString;
                 }
 
-                OUString aTitle( aMenuShortCut + aMenuTitle );
+                aMenuShortCut.append( aMenuTitle );
 
-                pVCLPopupMenu->InsertItem( sal_uInt16( i+1 ), aTitle );
+                pVCLPopupMenu->InsertItem( sal_uInt16( i+1 ), aMenuShortCut.makeStringAndClear() );
                 pVCLPopupMenu->SetTipHelpText( sal_uInt16( i+1 ), aTipHelpText );
                 pVCLPopupMenu->SetItemCommand( sal_uInt16( i+1 ), aURLString );
             }
+
+            pVCLPopupMenu->InsertSeparator();
+            // Clear List menu entry
+            pVCLPopupMenu->InsertItem( sal_uInt16( nCount + 1 ),
+                                       String( FwkResId( STR_CLEAR_RECENT_FILES ) ) );
+            pVCLPopupMenu->SetItemCommand( sal_uInt16( nCount + 1 ),
+                                           rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CMD_CLEAR_LIST ) ) );
+            pVCLPopupMenu->SetHelpText( sal_uInt16( nCount + 1 ),
+                                        String( FwkResId( STR_CLEAR_RECENT_FILES_HELP ) ) );
         }
         else
         {
             // No recent documents => insert "no document" string
-            String aNoDocumentStr = String( FwkResId( STR_NODOCUMENT ));
-            pVCLPopupMenu->InsertItem( 1, aNoDocumentStr );
+            pVCLPopupMenu->InsertItem( 1, String( FwkResId( STR_NODOCUMENT ) ) );
             pVCLPopupMenu->EnableItem( 1, sal_False );
         }
     }
@@ -215,20 +205,15 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
 
 void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
 {
-    Reference< css::awt::XPopupMenu > xPopupMenu;
     Reference< XDispatch >            xDispatch;
     Reference< XDispatchProvider >    xDispatchProvider;
-    Reference< XMultiServiceFactory > xServiceManager;
+    css::util::URL                    aTargetURL;
+    Sequence< PropertyValue >         aArgsList;
 
     osl::ClearableMutexGuard aLock( m_aMutex );
-    xPopupMenu          = m_xPopupMenu;
-    xDispatchProvider   = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY );
-    xServiceManager     = m_xServiceManager;
+    xDispatchProvider = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY );
     aLock.clear();
 
-    css::util::URL            aTargetURL;
-    Sequence< PropertyValue > aArgsList;
-
     if (( nIndex >= 0 ) &&
         ( nIndex < sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() )))
     {
@@ -238,12 +223,12 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
         m_xURLTransformer->parseStrict( aTargetURL );
 
         sal_Int32 nSize = 2;
-        aArgsList.realloc(nSize);
-        aArgsList[0].Name = OUString( "Referer" );
-        aArgsList[0].Value = makeAny( OUString(SFX_REFERER_USER ));
+        aArgsList.realloc( nSize );
+        aArgsList[0].Name = "Referer";
+        aArgsList[0].Value = makeAny( OUString( SFX_REFERER_USER ) );
 
         // documents in the picklist will never be opened as templates
-        aArgsList[1].Name = OUString( "AsTemplate" );
+        aArgsList[1].Name = "AsTemplate";
         aArgsList[1].Value = makeAny( (sal_Bool) sal_False );
 
         if (!m_aModuleName.isEmpty())
@@ -254,7 +239,7 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
             aArgsList[nSize-1].Value <<= m_aModuleName;
         }
 
-        xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString("_default"), 0 );
+        xDispatch = xDispatchProvider->queryDispatch( aTargetURL, "_default", 0 );
     }
 
     if ( xDispatch.is() )
@@ -266,6 +251,7 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
         pLoadRecentFile->xDispatch  = xDispatch;
         pLoadRecentFile->aTargetURL = aTargetURL;
         pLoadRecentFile->aArgSeq    = aArgsList;
+
         Application::PostUserEvent( STATIC_LINK(0, RecentFilesMenuController, ExecuteHdl_Impl), pLoadRecentFile );
     }
 }
@@ -294,24 +280,23 @@ void SAL_CALL RecentFilesMenuController::statusChanged( const FeatureStateEvent&
 
 void SAL_CALL RecentFilesMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException)
 {
-    Reference< css::awt::XPopupMenu > xPopupMenu;
-    Reference< XDispatch >            xDispatch;
-    Reference< XDispatchProvider >    xDispatchProvider;
-    Reference< XMultiServiceFactory > xServiceManager;
+    Reference< css::awt::XPopupMenu >    xPopupMenu;
+    Reference< css::awt::XMenuExtended > xMenuExt;
 
     osl::ClearableMutexGuard aLock( m_aMutex );
     xPopupMenu          = m_xPopupMenu;
-    xDispatchProvider   = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY );
-    xServiceManager     = m_xServiceManager;
+    xMenuExt            = Reference< css::awt::XMenuExtended >( m_xPopupMenu, UNO_QUERY );
     aLock.clear();
 
-    css::util::URL aTargetURL;
-    Sequence< PropertyValue > aArgsList;
-
-    if ( xPopupMenu.is() && xDispatchProvider.is() )
+    if ( xMenuExt.is() )
     {
-        VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu );
-        if ( pPopupMenu )
+        const rtl::OUString aCommand( xMenuExt->getCommand( rEvent.MenuId ) );
+        OSL_TRACE( "RecentFilesMenuController::select() - Command : %s",
+                   rtl::OUStringToOString( aCommand, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+        if ( aCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( CMD_CLEAR_LIST ) ) )
+            SvtHistoryOptions().Clear( ePICKLIST );
+        else
             executeEntry( rEvent.MenuId-1 );
     }
 }
@@ -329,27 +314,6 @@ void RecentFilesMenuController::impl_setPopupMenu()
         fillPopupMenu( m_xPopupMenu );
 }
 
-void SAL_CALL RecentFilesMenuController::updatePopupMenu() throw (RuntimeException)
-{
-    osl::ClearableMutexGuard aLock( m_aMutex );
-
-    throwIfDisposed();
-
-    Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
-    Reference< XDispatch > xDispatch( m_xDispatch );
-    com::sun::star::util::URL aTargetURL;
-    aTargetURL.Complete = m_aCommandURL;
-    m_xURLTransformer->parseStrict( aTargetURL );
-    aLock.clear();
-
-    // Add/remove status listener to get a status update once
-    if ( xDispatch.is() )
-    {
-        xDispatch->addStatusListener( xStatusListener, aTargetURL );
-        xDispatch->removeStatusListener( xStatusListener, aTargetURL );
-    }
-}
-
 // XDispatchProvider
 Reference< XDispatch > SAL_CALL RecentFilesMenuController::queryDispatch(
     const URL& aURL,
@@ -403,26 +367,6 @@ throw( RuntimeException )
     }
 }
 
-void SAL_CALL RecentFilesMenuController::addStatusListener(
-    const Reference< XStatusListener >& xControl,
-    const URL& aURL )
-throw( RuntimeException )
-{
-    osl::MutexGuard aLock( m_aMutex );
-
-    throwIfDisposed();
-
-    svt::PopupMenuControllerBase::addStatusListener( xControl, aURL );
-}
-
-void SAL_CALL RecentFilesMenuController::removeStatusListener(
-    const Reference< XStatusListener >& xControl,
-    const URL& aURL )
-throw( RuntimeException )
-{
-    svt::PopupMenuControllerBase::removeStatusListener( xControl, aURL );
-}
-
 IMPL_STATIC_LINK_NOINSTANCE( RecentFilesMenuController, ExecuteHdl_Impl, LoadRecentFile*, pLoadRecentFile )
 {
     try
commit 700b6c1cbf4fee4044aa2b7179d3f1886ae928c6
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 19:24:15 2013 +0200

    Fix warning: unused variable 'sFormat' [loplugin]
    
    Presumably the call to m_pObjStrm->QuickReadStringPtr() is still necessary
    because of its side-effects (to update the stream pointer).
    
    Change-Id: I69f24de4e956d5fefb4fc5382c0cc7e0173a5a0f

diff --git a/lotuswordpro/source/filter/lwpoleobject.cxx b/lotuswordpro/source/filter/lwpoleobject.cxx
index c818118..842e199 100644
--- a/lotuswordpro/source/filter/lwpoleobject.cxx
+++ b/lotuswordpro/source/filter/lwpoleobject.cxx
@@ -220,7 +220,7 @@ void LwpOleObject::Read()
     {
         m_pObjStrm->QuickReaduInt16();
 
-        OUString sFormat = m_pObjStrm->QuickReadStringPtr();
+        m_pObjStrm->QuickReadStringPtr();
 
         if (LwpFileHeader::m_nFileRevision < 0x000B)
         {
commit 4ac0eff680a9fbf81dfd9e8a5772dee93bd0fb1a
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 18:32:41 2013 +0200

    Re-add change from 304cb6ab8fb159c883c42d2d42e82750fab4e4a7
    
    Was accidentally reverted.
    
    Change-Id: I1d62003cfab222664b7cf2053f640287910b2892

diff --git a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
index 7e7216f..271342b 100644
--- a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
+++ b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
@@ -26,7 +26,7 @@ static UIWindow *theWindow;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list