[Libreoffice-commits] .: 3 commits - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Nov 23 08:29:59 PST 2012


 sc/inc/conditio.hxx              |   32 +++++++++---------
 sc/source/core/data/conditio.cxx |   68 ++++++++++++++++++++-------------------
 sc/source/core/data/table2.cxx   |    8 ++++
 3 files changed, 59 insertions(+), 49 deletions(-)

New commits:
commit 35c6bd77044c7c1c10bb5d42d781805751a1d8d8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Nov 23 17:20:42 2012 +0100

    String to OUString in conditio.[ch]xx
    
    Change-Id: Iea2da3947a76e45fb323abed3b9a14ccc3fdfbdc

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 71dcc4e..ee30be1 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -161,10 +161,10 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
     sal_uInt16              nOptions;
     double              nVal1;          // input or calculated
     double              nVal2;
-    String              aStrVal1;       // input or calculated
-    String              aStrVal2;
-    String              aStrNmsp1;      // namespace to be used on (re)compilation, e.g. in XML import
-    String              aStrNmsp2;      // namespace to be used on (re)compilation, e.g. in XML import
+    rtl::OUString              aStrVal1;       // input or calculated
+    rtl::OUString              aStrVal2;
+    rtl::OUString              aStrNmsp1;      // namespace to be used on (re)compilation, e.g. in XML import
+    rtl::OUString              aStrNmsp2;      // namespace to be used on (re)compilation, e.g. in XML import
     formula::FormulaGrammar::Grammar eTempGrammar1;  // grammar to be used on (re)compilation, e.g. in XML import
     formula::FormulaGrammar::Grammar eTempGrammar2;  // grammar to be used on (re)compilation, e.g. in XML import
     bool                bIsStr1;        // for recognition of empty strings
@@ -173,7 +173,7 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
     ScTokenArray*       pFormula2;
     ScAddress           aSrcPos;        // source position for formulas
                                         // temporary data:
-    String              aSrcString;     // formula source position as text during XML import
+    rtl::OUString              aSrcString;     // formula source position as text during XML import
     ScFormulaCell*      pFCell1;
     ScFormulaCell*      pFCell2;
     bool                bRelRef1;
@@ -181,8 +181,8 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
     bool                bFirstRun;
 
     void    MakeCells( const ScAddress& rPos );
-    void    Compile( const String& rExpr1, const String& rExpr2,
-                        const String& rExprNmsp1, const String& rExprNmsp2,
+    void    Compile( const rtl::OUString& rExpr1, const rtl::OUString& rExpr2,
+                        const rtl::OUString& rExprNmsp1, const rtl::OUString& rExprNmsp2,
                         formula::FormulaGrammar::Grammar eGrammar1,
                         formula::FormulaGrammar::Grammar eGrammar2,
                         bool bTextToReal );
@@ -193,9 +193,9 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
 
 public:
             ScConditionEntry( ScConditionMode eOper,
-                                const String& rExpr1, const String& rExpr2,
+                                const rtl::OUString& rExpr1, const rtl::OUString& rExpr2,
                                 ScDocument* pDocument, const ScAddress& rPos,
-                                const String& rExprNmsp1, const String& rExprNmsp2,
+                                const rtl::OUString& rExprNmsp1, const rtl::OUString& rExprNmsp2,
                                 formula::FormulaGrammar::Grammar eGrammar1,
                                 formula::FormulaGrammar::Grammar eGrammar2 );
             ScConditionEntry( ScConditionMode eOper,
@@ -219,12 +219,12 @@ public:
 
     ScAddress       GetValidSrcPos() const;     // adjusted to allow textual representation of expressions
 
-    void            SetSrcString( const String& rNew );     // for XML import
+    void            SetSrcString( const rtl::OUString& rNew );     // for XML import
 
     void            SetFormula1( const ScTokenArray& rArray );
     void            SetFormula2( const ScTokenArray& rArray );
 
-    String          GetExpression( const ScAddress& rCursor, sal_uInt16 nPos, sal_uLong nNumFmt = 0,
+    rtl::OUString          GetExpression( const ScAddress& rCursor, sal_uInt16 nPos, sal_uLong nNumFmt = 0,
                                     const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
 
     ScTokenArray*   CreateTokenArry( sal_uInt16 nPos ) const;
@@ -300,17 +300,17 @@ class SC_DLLPUBLIC ScCondFormatEntry : public ScConditionEntry
 
 public:
             ScCondFormatEntry( ScConditionMode eOper,
-                                const String& rExpr1, const String& rExpr2,
+                                const rtl::OUString& rExpr1, const rtl::OUString& rExpr2,
                                 ScDocument* pDocument, const ScAddress& rPos,
-                                const String& rStyle,
-                                const String& rExprNmsp1 = EMPTY_STRING,
-                                const String& rExprNmsp2 = EMPTY_STRING,
+                                const rtl::OUString& rStyle,
+                                const rtl::OUString& rExprNmsp1 = EMPTY_STRING,
+                                const rtl::OUString& rExprNmsp2 = EMPTY_STRING,
                                 formula::FormulaGrammar::Grammar eGrammar1 = formula::FormulaGrammar::GRAM_DEFAULT,
                                 formula::FormulaGrammar::Grammar eGrammar2 = formula::FormulaGrammar::GRAM_DEFAULT );
             ScCondFormatEntry( ScConditionMode eOper,
                                 const ScTokenArray* pArr1, const ScTokenArray* pArr2,
                                 ScDocument* pDocument, const ScAddress& rPos,
-                                const String& rStyle );
+                                const rtl::OUString& rStyle );
             ScCondFormatEntry( const ScCondFormatEntry& r );
             ScCondFormatEntry( ScDocument* pDocument, const ScCondFormatEntry& r );
     virtual ~ScCondFormatEntry();
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 769a95e..fa71951 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -216,12 +216,12 @@ ScConditionEntry::ScConditionEntry( ScDocument* pDocument, const ScConditionEntr
 }
 
 ScConditionEntry::ScConditionEntry( ScConditionMode eOper,
-        const String& rExpr1, const String& rExpr2, ScDocument* pDocument, const ScAddress& rPos,
-        const String& rExprNmsp1, const String& rExprNmsp2,
+        const rtl::OUString& rExpr1, const rtl::OUString& rExpr2, ScDocument* pDocument, const ScAddress& rPos,
+        const rtl::OUString& rExprNmsp1, const rtl::OUString& rExprNmsp2,
         FormulaGrammar::Grammar eGrammar1, FormulaGrammar::Grammar eGrammar2 ) :
     ScFormatEntry(pDocument),
     eOp(eOper),
-    nOptions(0),    // spaeter...
+    nOptions(0),
     nVal1(0.0),
     nVal2(0.0),
     aStrNmsp1(rExprNmsp1),
@@ -250,7 +250,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper,
                                 ScDocument* pDocument, const ScAddress& rPos ) :
     ScFormatEntry(pDocument),
     eOp(eOper),
-    nOptions(0),    // spaeter...
+    nOptions(0),
     nVal1(0.0),
     nVal2(0.0),
     eTempGrammar1(FormulaGrammar::GRAM_DEFAULT),
@@ -328,15 +328,15 @@ ScConditionEntry::~ScConditionEntry()
     delete pFormula2;
 }
 
-void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2,
-        const String& rExprNmsp1, const String& rExprNmsp2,
+void ScConditionEntry::Compile( const rtl::OUString& rExpr1, const rtl::OUString& rExpr2,
+        const rtl::OUString& rExprNmsp1, const rtl::OUString& rExprNmsp2,
         FormulaGrammar::Grammar eGrammar1, FormulaGrammar::Grammar eGrammar2, bool bTextToReal )
 {
-    if ( rExpr1.Len() || rExpr2.Len() )
+    if ( !rExpr1.isEmpty() || !rExpr2.isEmpty() )
     {
         ScCompiler aComp( mpDoc, aSrcPos );
 
-        if ( rExpr1.Len() )
+        if ( !rExpr1.isEmpty() )
         {
             aComp.SetGrammar( eGrammar1 );
             if ( mpDoc->IsImportingXML() && !bTextToReal )
@@ -373,7 +373,7 @@ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2,
             }
         }
 
-        if ( rExpr2.Len() )
+        if ( !rExpr2.isEmpty() )
         {
             aComp.SetGrammar( eGrammar2 );
             if ( mpDoc->IsImportingXML() && !bTextToReal )
@@ -453,7 +453,7 @@ void ScConditionEntry::CompileXML()
 {
     //  First parse the formula source position if it was stored as text
 
-    if ( aSrcString.Len() )
+    if ( !aSrcString.isEmpty() )
     {
         ScAddress aNew;
         /* XML is always in OOo:A1 format, although R1C1 would be more amenable
@@ -461,7 +461,7 @@ void ScConditionEntry::CompileXML()
         if ( aNew.Parse( aSrcString, mpDoc ) & SCA_VALID )
             aSrcPos = aNew;
         // if the position is invalid, there isn't much we can do at this time
-        aSrcString.Erase();
+        aSrcString = rtl::OUString();
     }
 
     //  Convert the text tokens that were created during XML import into real tokens.
@@ -471,7 +471,7 @@ void ScConditionEntry::CompileXML()
              aStrNmsp1, aStrNmsp2, eTempGrammar1, eTempGrammar2, true );
 }
 
-void ScConditionEntry::SetSrcString( const String& rNew )
+void ScConditionEntry::SetSrcString( const rtl::OUString& rNew )
 {
     // aSrcString is only evaluated in CompileXML
     OSL_ENSURE( mpDoc->IsImportingXML(), "SetSrcString is only valid for XML import" );
@@ -671,7 +671,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
             {
                 bIsStr1 = false;
                 nVal1 = pEff1->GetValue();
-                aStrVal1.Erase();
+                aStrVal1 = rtl::OUString();
             }
             else
             {
@@ -700,7 +700,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
             {
                 bIsStr2 = false;
                 nVal2 = pEff2->GetValue();
-                aStrVal2.Erase();
+                aStrVal2 = rtl::OUString();
             }
             else
             {
@@ -1098,7 +1098,7 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const
                 bValid = !bValid;
             break;
         case SC_COND_BEGINS_WITH:
-            if(!aStrVal1.Len())
+            if(aStrVal1.isEmpty())
             {
                 rtl::OUString aStr = rtl::OUString::valueOf(nVal1);
                 rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
@@ -1110,7 +1110,7 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const
                 bValid = aStr2.indexOf(aStrVal1) == 0;
             }
         case SC_COND_ENDS_WITH:
-            if(!aStrVal1.Len())
+            if(aStrVal1.isEmpty())
             {
                 rtl::OUString aStr = rtl::OUString::valueOf(nVal1);
                 rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
@@ -1123,7 +1123,7 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const
             }
         case SC_COND_CONTAINS_TEXT:
         case SC_COND_NOT_CONTAINS_TEXT:
-            if(!aStrVal1.Len())
+            if(aStrVal1.isEmpty())
             {
                 rtl::OUString aStr = rtl::OUString::valueOf(nVal1);
                 rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
@@ -1180,7 +1180,7 @@ bool ScConditionEntry::IsValidStr( const rtl::OUString& rArg, const ScAddress& r
                 == COMPARE_GREATER )
         {
             //  richtige Reihenfolge fuer Wertebereich
-            String aTemp( aUpVal1 ); aUpVal1 = aUpVal2; aUpVal2 = aTemp;
+            rtl::OUString aTemp( aUpVal1 ); aUpVal1 = aUpVal2; aUpVal2 = aTemp;
         }
 
     switch ( eOp )
@@ -1269,11 +1269,11 @@ bool ScConditionEntry::IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) c
         return IsValidStr( aArgStr, rPos );
 }
 
-String ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 nIndex,
+rtl::OUString ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 nIndex,
                                         sal_uLong nNumFmt,
                                         const FormulaGrammar::Grammar eGrammar ) const
 {
-    String aRet;
+    rtl::OUString aRet;
 
     if ( FormulaGrammar::isEnglish( eGrammar) && nNumFmt == 0 )
         nNumFmt = mpDoc->GetFormatTable()->GetStandardIndex( LANGUAGE_ENGLISH_US );
@@ -1284,13 +1284,15 @@ String ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 nIn
         {
             ScCompiler aComp(mpDoc, rCursor, *pFormula1);
             aComp.SetGrammar(eGrammar);
-            aComp.CreateStringFromTokenArray( aRet );
+            rtl::OUStringBuffer aBuffer;
+            aComp.CreateStringFromTokenArray( aBuffer );
+            aRet = aBuffer.makeStringAndClear();
         }
         else if (bIsStr1)
         {
-            aRet = '"';
+            aRet = """";
             aRet += aStrVal1;
-            aRet += '"';
+            aRet += """";
         }
         else
             mpDoc->GetFormatTable()->GetInputLineString(nVal1, nNumFmt, aRet);
@@ -1301,13 +1303,15 @@ String ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 nIn
         {
             ScCompiler aComp(mpDoc, rCursor, *pFormula2);
             aComp.SetGrammar(eGrammar);
-            aComp.CreateStringFromTokenArray( aRet );
+            rtl::OUStringBuffer aBuffer;
+            aComp.CreateStringFromTokenArray( aBuffer );
+            aRet = aBuffer.makeStringAndClear();
         }
         else if (bIsStr2)
         {
-            aRet = '"';
+            aRet = """";
             aRet += aStrVal2;
-            aRet += '"';
+            aRet += """";
         }
         else
             mpDoc->GetFormatTable()->GetInputLineString(nVal2, nNumFmt, aRet);
@@ -1333,7 +1337,7 @@ ScTokenArray* ScConditionEntry::CreateTokenArry( sal_uInt16 nIndex ) const
         {
             pRet = new ScTokenArray();
             if (bIsStr1)
-                pRet->AddString( aStrVal1.GetBuffer() );
+                pRet->AddString( aStrVal1 );
             else
                 pRet->AddDouble( nVal1 );
         }
@@ -1346,7 +1350,7 @@ ScTokenArray* ScConditionEntry::CreateTokenArry( sal_uInt16 nIndex ) const
         {
             pRet = new ScTokenArray();
             if (bIsStr2)
-                pRet->AddString( aStrVal2.GetBuffer() );
+                pRet->AddString( aStrVal2 );
             else
                 pRet->AddDouble( nVal2 );
         }
@@ -1573,10 +1577,10 @@ void ScConditionEntry::endRendering()
 //------------------------------------------------------------------------
 
 ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper,
-                                        const String& rExpr1, const String& rExpr2,
+                                        const rtl::OUString& rExpr1, const rtl::OUString& rExpr2,
                                         ScDocument* pDocument, const ScAddress& rPos,
-                                        const String& rStyle,
-                                        const String& rExprNmsp1, const String& rExprNmsp2,
+                                        const rtl::OUString& rStyle,
+                                        const rtl::OUString& rExprNmsp1, const rtl::OUString& rExprNmsp2,
                                         FormulaGrammar::Grammar eGrammar1,
                                         FormulaGrammar::Grammar eGrammar2 ) :
     ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, rExprNmsp1, rExprNmsp2, eGrammar1, eGrammar2 ),
@@ -1587,7 +1591,7 @@ ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper,
 ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper,
                                         const ScTokenArray* pArr1, const ScTokenArray* pArr2,
                                         ScDocument* pDocument, const ScAddress& rPos,
-                                        const String& rStyle ) :
+                                        const rtl::OUString& rStyle ) :
     ScConditionEntry( eOper, pArr1, pArr2, pDocument, rPos ),
     aStyleName( rStyle )
 {
commit f8eed7ad9d4fda19578c13c8d2142005ff0023d7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Nov 23 17:19:51 2012 +0100

    support undoing conditional formats correctly
    
    Change-Id: Ice698827b3bc559a1e5ad0ea929145fa8c0dfffe

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index ea7f039..ce11688 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1004,6 +1004,9 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         pDestTab->maNotes.CopyFromClip(maNotes, pDestTab->pDocument, nCol1, nRow1, nCol2, nRow2, 0, 0, pDestTab->nTab, bCloneCaption);
     }
 
+    if(pDestTab->pDocument->IsUndo() && (nFlags & IDF_ATTRIB))
+        pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->pDocument, *mpCondFormatList));
+
     if (pDBDataNoName)
     {
         ScDBData* pNewDBData = new ScDBData(*pDBDataNoName);
@@ -1119,6 +1122,9 @@ void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         if (nFlags & IDF_CONTENTS)
             pDestTab->maNotes.erase(nCol1, nRow1, nCol2, nRow2);
 
+        if (nFlags & IDF_ATTRIB)
+            pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->pDocument, *mpCondFormatList));
+
         bool bAddNotes = nFlags & (IDF_NOTE | IDF_ADDNOTES);
         if (bAddNotes)
         {
commit ac5b0cd66a0fa0158a8ec35b2853c18450d9965c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Nov 23 17:18:32 2012 +0100

    this should be IDF_NOTE
    
    Change-Id: Id460ed774b4ccedd5e72ba41756fc7c78f8c2313

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 98a0fdd..ea7f039 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -994,7 +994,7 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         return;
 
     //remove old notes
-    if (nFlags & IDF_CONTENTS)
+    if (nFlags & IDF_NOTE)
         pDestTab->maNotes.erase(nCol1, nRow1, nCol2, nRow2);
 
     bool bAddNotes = nFlags & (IDF_NOTE | IDF_ADDNOTES);


More information about the Libreoffice-commits mailing list