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

Kohei Yoshida kohei.yoshida at collabora.com
Tue May 6 15:49:54 PDT 2014


 sc/inc/formulacell.hxx                       |    2 +-
 sc/inc/formularesult.hxx                     |    2 +-
 sc/inc/token.hxx                             |    8 ++------
 sc/qa/unit/data/ods/hybrid-shared-string.ods |binary
 sc/qa/unit/subsequent_filters-test.cxx       |   15 +++++++++++++++
 sc/source/core/data/formulacell.cxx          |    2 +-
 sc/source/core/tool/formularesult.cxx        |    2 +-
 sc/source/core/tool/token.cxx                |    7 +++++++
 sc/source/filter/orcus/interface.cxx         |    3 ++-
 sc/source/filter/xml/xmlcelli.cxx            |    7 +++++--
 10 files changed, 35 insertions(+), 13 deletions(-)

New commits:
commit 740dac4d58a95709eb11fc7434a7904ff8fafbd8
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue May 6 18:36:55 2014 -0400

    fdo#77990: Write test for this, using the 2nd test document submitted.
    
    Change-Id: I70d71bb21ff43aeb49339ff1f1d9e73c923e0201

diff --git a/sc/qa/unit/data/ods/hybrid-shared-string.ods b/sc/qa/unit/data/ods/hybrid-shared-string.ods
new file mode 100644
index 0000000..89f59d6
Binary files /dev/null and b/sc/qa/unit/data/ods/hybrid-shared-string.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 8870b9b..7983e4c 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -172,6 +172,7 @@ public:
     void testSharedFormulaWrappedRefsXLS();
     void testExternalRefCacheXLSX();
     void testExternalRefCacheODS();
+    void testHybridSharedStringODS();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testBasicCellContentODS);
@@ -248,6 +249,7 @@ public:
     CPPUNIT_TEST(testSharedFormulaWrappedRefsXLS);
     CPPUNIT_TEST(testExternalRefCacheXLSX);
     CPPUNIT_TEST(testExternalRefCacheODS);
+    CPPUNIT_TEST(testHybridSharedStringODS);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2541,6 +2543,19 @@ void ScFiltersTest::testExternalRefCacheODS()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testHybridSharedStringODS()
+{
+    ScDocShellRef xDocSh = loadDoc("hybrid-shared-string.", ODS);
+
+    CPPUNIT_ASSERT(xDocSh.Is());
+    ScDocument* pDoc = xDocSh->GetDocument();
+
+    // A2 contains formula with MATCH function.  The result must be 2, not #N/A!
+    CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(ScAddress(0,1,0)));
+
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
commit 1899bd0c3b8a16ede2de0125e762b23ba013d81f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue May 6 18:25:56 2014 -0400

    fdo#77990: Intern strings for hybrid strings during import.
    
    Change-Id: I269497cac645e486ac08bb2b011df1b5b23dc021

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 91a3625..11c5cb1 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -338,7 +338,7 @@ public:
         If for whatever reason you have to use both, SetHybridDouble() and
         SetHybridString() or SetHybridFormula(), use SetHybridDouble() first
         for performance reasons.*/
-    void SetHybridString( const OUString& r );
+    void SetHybridString( const svl::SharedString& r );
     /** For import only: set a temporary formula string to be compiled later.
         If for whatever reason you have to use both, SetHybridDouble() and
         SetHybridString() or SetHybridFormula(), use SetHybridDouble() first
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index 78d7ae5..68a08e5 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -195,7 +195,7 @@ public:
     /** Should only be used by import filters, best in the order
         SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only
         SetHybridFormula() for formula string to be compiled later. */
-    SC_DLLPUBLIC void SetHybridString( const OUString & rStr );
+    SC_DLLPUBLIC void SetHybridString( const svl::SharedString & rStr );
 
     /** Should only be used by import filters, best in the order
         SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index a233fe5..2c21e4a 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2084,7 +2084,7 @@ void ScFormulaCell::SetHybridDouble( double n )
     aResult.SetHybridDouble( n);
 }
 
-void ScFormulaCell::SetHybridString( const OUString& r )
+void ScFormulaCell::SetHybridString( const svl::SharedString& r )
 {
     aResult.SetHybridString( r);
 }
diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx
index 66ee0a9..658eb97 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -518,7 +518,7 @@ void ScFormulaResult::SetHybridDouble( double f )
     }
 }
 
-void ScFormulaResult::SetHybridString( const OUString & rStr )
+void ScFormulaResult::SetHybridString( const svl::SharedString& rStr )
 {
     // Obtain values before changing anything.
     double f = GetDouble();
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index 8bd650e..6c05627 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -20,6 +20,7 @@
 
 #include "formula/token.hxx"
 #include "tools/datetime.hxx"
+#include <svl/sharedstringpool.hxx>
 
 #include <com/sun/star/task/XStatusIndicator.hpp>
 
@@ -305,7 +306,7 @@ void ScOrcusSheet::set_formula_result(os::row_t row, os::col_t col, const char*
         return;
     }
     OUString aResult( p, n, RTL_TEXTENCODING_UTF8);
-    pCell->SetHybridString(aResult);
+    pCell->SetHybridString(mrDoc.getDoc().GetSharedStringPool().intern(aResult));
 }
 
 void ScOrcusSheet::set_shared_formula(
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index c61657e..364833f 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -86,6 +86,7 @@
 #include "editeng/langitem.hxx"
 #include <svx/unoapi.hxx>
 #include <svl/languageoptions.hxx>
+#include <svl/sharedstringpool.hxx>
 #include <svtools/miscopt.hxx>
 #include <sax/tools/converter.hxx>
 
@@ -1025,7 +1026,8 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
         {
             if( !IsPossibleErrorString() )
             {
-                pFCell->SetHybridString( *maStringValue );
+                ScDocument* pDoc = rXMLImport.GetDocument();
+                pFCell->SetHybridString(pDoc->GetSharedStringPool().intern(*maStringValue));
                 pFCell->ResetDirty();
             }
         }
@@ -1066,7 +1068,8 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
             {
                 if (bDoIncrement && !IsPossibleErrorString())
                 {
-                    pFCell->SetHybridString( aCellString );
+                    ScDocument* pDoc = rXMLImport.GetDocument();
+                    pFCell->SetHybridString(pDoc->GetSharedStringPool().intern(aCellString));
                     pFCell->ResetDirty();
                 }
                 else
commit 639d33af28d5ed4c2223cfb7b1422478942e6e52
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue May 6 18:21:33 2014 -0400

    Let's make this non-inline...
    
    Change-Id: Ib427cea392c953e6bce121bfe82e9215eb1bb99a

diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 272a8f8..ec0bfc2 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -414,12 +414,8 @@ private:
     svl::SharedString maString;
     OUString maFormula;
 public:
-    ScHybridCellToken( double f,
-            const svl::SharedString & rStr,
-            const OUString & rFormula ) :
-        ScToken( formula::svHybridCell ),
-        mfDouble( f ), maString( rStr ),
-        maFormula( rFormula ) {}
+    ScHybridCellToken(
+        double f, const svl::SharedString & rStr, const OUString & rFormula );
 
     const OUString& GetFormula() const  { return maFormula; }
     virtual double GetDouble() const SAL_OVERRIDE;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 636ff01..f6b3741 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1157,6 +1157,13 @@ void ScMatrixFormulaCellToken::ResetResult()
     xUpperLeft = NULL;
 }
 
+ScHybridCellToken::ScHybridCellToken(
+    double f, const svl::SharedString & rStr, const OUString & rFormula ) :
+        ScToken( formula::svHybridCell ),
+        mfDouble( f ), maString( rStr ),
+        maFormula( rFormula )
+{
+}
 
 double ScHybridCellToken::GetDouble() const { return mfDouble; }
 


More information about the Libreoffice-commits mailing list