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

Kohei Yoshida kohei.yoshida at collabora.com
Tue Apr 15 07:16:07 PDT 2014


 sc/inc/cellform.hxx                        |    3 ++
 sc/source/core/tool/cellform.cxx           |   32 +++++++++++++++++++++++++++++
 sc/source/filter/xml/XMLExportIterator.cxx |    3 +-
 sc/source/filter/xml/XMLExportIterator.hxx |    4 ++-
 sc/source/filter/xml/xmlexprt.cxx          |    9 ++++++--
 5 files changed, 47 insertions(+), 4 deletions(-)

New commits:
commit a0752fa4246dc71b64907c679657a1af3cb617e1
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Apr 15 10:12:58 2014 -0400

    fdo#76409: Write output cell string to <text:p> element when saving to ods.
    
    The change was made by accident.
    
    Change-Id: Ife2461b0fca6e3ea5a65d72d985d1e0976737b5a

diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index 1f6b13a..caea246 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -54,6 +54,9 @@ public:
     static void GetInputString(
         ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter,
         const ScDocument* pDoc );
+
+    static OUString GetOutputString(
+        ScDocument& rDoc, const ScAddress& rPos, ScRefCellValue& rCell );
 };
 
 #endif
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 3e15517..804088d 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -29,6 +29,7 @@
 #include "cellvalue.hxx"
 #include "formula/errorcodes.hxx"
 #include "sc.hrc"
+#include <editutil.hxx>
 
 // STATIC DATA
 // Err527 Workaround
@@ -268,4 +269,35 @@ void ScCellFormat::GetInputString(
     rString = aString;
 }
 
+OUString ScCellFormat::GetOutputString( ScDocument& rDoc, const ScAddress& rPos, ScRefCellValue& rCell )
+{
+    if (rCell.isEmpty())
+        return EMPTY_OUSTRING;
+
+    OUString aVal;
+
+    if (rCell.meType == CELLTYPE_EDIT)
+    {
+        //  GetString an der EditCell macht Leerzeichen aus Umbruechen,
+        //  hier werden die Umbrueche aber gebraucht
+        const EditTextObject* pData = rCell.mpEditText;
+        if (pData)
+        {
+            ScFieldEditEngine& rEngine = rDoc.GetEditEngine();
+            rEngine.SetText(*pData);
+            aVal = rEngine.GetText(LINEEND_LF);
+        }
+        //  Edit-Zellen auch nicht per NumberFormatter formatieren
+        //  (passend zur Ausgabe)
+    }
+    else
+    {
+        //  wie in GetString am Dokument (column)
+        Color* pColor;
+        sal_uLong nNumFmt = rDoc.GetNumberFormat(rPos);
+        aVal = GetString(rDoc, rPos, nNumFmt, &pColor, *rDoc.GetFormatTable());
+    }
+    return aVal;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index 4ec1be5..ff0b419 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -641,10 +641,11 @@ void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress )
     }
 }
 
-void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddress& rAddress )
+void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, const table::CellAddress& rAddress )
 {
     rMyCell.maBaseCell.clear();
     rMyCell.aCellAddress = rAddress;
+    ScUnoConversion::FillScAddress(rMyCell.maCellAddress, rMyCell.aCellAddress);
 
     if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) )
     {
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx
index 0275dd3..e2180e9 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -278,6 +278,8 @@ public:
 // contains data to export for the current cell position
 struct ScMyCell
 {
+    ScAddress maCellAddress; /// Use this instead of the UNO one.
+
     com::sun::star::table::CellAddress      aCellAddress;
     com::sun::star::table::CellRangeAddress aMergeRange;
     com::sun::star::table::CellRangeAddress aMatrixRange;
@@ -336,7 +338,7 @@ class ScMyNotEmptyCellsIterator : boost::noncopyable
     SCTAB                       nCurrentTable;
 
     void                        UpdateAddress( ::com::sun::star::table::CellAddress& rAddress );
-    void                        SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress );
+    void SetCellData( ScMyCell& rMyCell, const css::table::CellAddress& rAddress );
 
     void                        HasAnnotation( ScMyCell& aCell );
 public:
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 89badd5..2603d05 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -67,6 +67,7 @@
 #include <datastream.hxx>
 #include <documentlinkmgr.hxx>
 #include <tokenstringcontext.hxx>
+#include <cellform.hxx>
 
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmlnmspe.hxx>
@@ -3287,8 +3288,12 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
         else
         {
             SvXMLElementExport aElemP(*this, sElemP, true, false);
-            bool bPrevCharWasSpace(true);
-            GetTextParagraphExport()->exportText(aCell.maBaseCell.getString(pDoc), bPrevCharWasSpace);
+
+            OUString aParaStr =
+                ScCellFormat::GetOutputString(*pDoc, aCell.maCellAddress, aCell.maBaseCell);
+
+            bool bPrevCharWasSpace = true;
+            GetTextParagraphExport()->exportText(aParaStr, bPrevCharWasSpace);
         }
     }
     WriteShapes(aCell);


More information about the Libreoffice-commits mailing list