[Libreoffice-commits] core.git: Branch 'feature/ods-edit-cell-import' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Thu Feb 7 21:01:56 PST 2013


 sc/source/filter/xml/celltextparacontext.cxx |   23 +++++++++++------------
 sc/source/filter/xml/celltextparacontext.hxx |    2 +-
 sc/source/filter/xml/xmlcelli.cxx            |    9 +++++++--
 sc/source/filter/xml/xmlcelli.hxx            |    4 +++-
 4 files changed, 22 insertions(+), 16 deletions(-)

New commits:
commit 7d1a7c119b4fc1476b75ef858cd30c9daf86c98b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Feb 8 00:02:28 2013 -0500

    Push everything to the cell context.
    
    This is to prepare for the use of EditEngine to create rich text paragraphs.
    
    Change-Id: Ic3577e38352429a61c3524114d071c80507e4a4b

diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index a70143e..66c48e7 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -28,24 +28,26 @@ void ScXMLCellTextParaContext::StartElement(const uno::Reference<xml::sax::XAttr
 
 void ScXMLCellTextParaContext::EndElement()
 {
-    OUString aPara = maContent.makeStringAndClear();
-    if (aPara.isEmpty())
-        return;
+    if (!maContent.isEmpty())
+        mrParentCxt.PushParagraphSpan(maContent);
 
-    mrParentCxt.PushParagraph(aPara);
+    mrParentCxt.PushParagraphEnd();
 }
 
 void ScXMLCellTextParaContext::Characters(const OUString& rChars)
 {
-    if (rChars.isEmpty())
-        return;
-
-    maContent.append(rChars);
+    maContent = rChars;
 }
 
 SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext(
     sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList)
 {
+    if (!maContent.isEmpty())
+    {
+        mrParentCxt.PushParagraphSpan(maContent);
+        maContent = OUString();
+    }
+
     const SvXMLTokenMap& rTokenMap = GetScImport().GetCellTextParaElemTokenMap();
     switch (rTokenMap.Get(nPrefix, rLocalName))
     {
@@ -61,10 +63,7 @@ SvXMLImportContext* ScXMLCellTextParaContext::CreateChildContext(
 
 void ScXMLCellTextParaContext::PushSpan(const OUString& rSpan)
 {
-    if (rSpan.isEmpty())
-        return;
-
-    maContent.append(rSpan);
+    mrParentCxt.PushParagraphSpan(rSpan);
 }
 
 ScXMLCellTextSpanContext::ScXMLCellTextSpanContext(
diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx
index ecc6880..75ce3f8 100644
--- a/sc/source/filter/xml/celltextparacontext.hxx
+++ b/sc/source/filter/xml/celltextparacontext.hxx
@@ -21,7 +21,7 @@ class ScXMLTableRowCellContext;
 class ScXMLCellTextParaContext : public ScXMLImportContext
 {
     ScXMLTableRowCellContext& mrParentCxt;
-    OUStringBuffer maContent;
+    OUString maContent;
 public:
     ScXMLCellTextParaContext(ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, ScXMLTableRowCellContext& rParent);
 
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index abe8353..e13cb82 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -300,9 +300,14 @@ bool cellExists( const ScAddress& rCellPos )
 
 }
 
-void ScXMLTableRowCellContext::PushParagraph(const OUString& rPara)
+void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan)
 {
-    maParagraphs.push_back(rPara);
+    maParagraph.append(rSpan);
+}
+
+void ScXMLTableRowCellContext::PushParagraphEnd()
+{
+    maParagraphs.push_back(maParagraph.makeStringAndClear());
 }
 
 SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPrefix,
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 58d0e45..cb61ce4 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -41,6 +41,7 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
     boost::optional<OUString> maContentValidationName;
 
     std::vector<OUString> maParagraphs;
+    OUStringBuffer maParagraph;
 
     boost::scoped_ptr< ScXMLAnnotationData > mxAnnotationData;
     ScMyImpDetectiveObjVec* pDetectiveObjVec;
@@ -106,7 +107,8 @@ public:
                                      const ::com::sun::star::uno::Reference<
                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
 
-    void PushParagraph(const OUString& rPara);
+    void PushParagraphSpan(const OUString& rSpan);
+    void PushParagraphEnd();
 
     void SetAnnotation( const ScAddress& rPosition );
     void SetDetectiveObj( const ScAddress& rPosition );


More information about the Libreoffice-commits mailing list