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

Kohei Yoshida kohei.yoshida at gmail.com
Mon Feb 11 10:24:36 PST 2013


 sc/source/filter/xml/celltextparacontext.cxx |    4 +++-
 sc/source/filter/xml/celltextparacontext.hxx |    2 +-
 sc/source/filter/xml/xmlcelli.cxx            |   26 ++++++++++++++++++--------
 sc/source/filter/xml/xmlcelli.hxx            |    7 +++++--
 4 files changed, 27 insertions(+), 12 deletions(-)

New commits:
commit 0486de9881eb88d9e7ebba0c8ea4f21c36c9b414
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Feb 11 13:25:53 2013 -0500

    Import document title field as well.
    
    Change-Id: Iea73d553927ce95afbb9b6e9062b398733228687

diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx
index 84249b4..a4ce72d 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -82,8 +82,9 @@ void ScXMLCellTextParaContext::PushFieldDate(const OUString& rOutput)
 {
 }
 
-void ScXMLCellTextParaContext::PushFieldTitle(const OUString& rTitle)
+void ScXMLCellTextParaContext::PushFieldTitle()
 {
+    mrParentCxt.PushParagraphFieldDocTitle();
 }
 
 ScXMLCellTextSpanContext::ScXMLCellTextSpanContext(
@@ -205,6 +206,7 @@ void ScXMLCellFieldTitleContext::StartElement(const uno::Reference<xml::sax::XAt
 
 void ScXMLCellFieldTitleContext::EndElement()
 {
+    mrParentCxt.PushFieldTitle();
 }
 
 void ScXMLCellFieldTitleContext::Characters(const OUString& rChars)
diff --git a/sc/source/filter/xml/celltextparacontext.hxx b/sc/source/filter/xml/celltextparacontext.hxx
index 7840cd6..55ea8ef 100644
--- a/sc/source/filter/xml/celltextparacontext.hxx
+++ b/sc/source/filter/xml/celltextparacontext.hxx
@@ -34,7 +34,7 @@ public:
     void PushSpan(const OUString& rSpan, const OUString& rStyleName);
     void PushFieldSheetName();
     void PushFieldDate(const OUString& rOutput);
-    void PushFieldTitle(const OUString& rTitle);
+    void PushFieldTitle();
 };
 
 /**
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index aff762f..255d5ae 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -116,11 +116,11 @@ using namespace xmloff::token;
 ScXMLTableRowCellContext::ParaFormat::ParaFormat(ScEditEngineDefaulter& rEditEngine) :
     maItemSet(rEditEngine.GetEmptyItemSet()) {}
 
-ScXMLTableRowCellContext::Field::Field() : mpItem(NULL) {}
+ScXMLTableRowCellContext::Field::Field(SvxFieldData* pData) : mpData(pData) {}
 
 ScXMLTableRowCellContext::Field::~Field()
 {
-    delete mpItem;
+    delete mpData;
 }
 
 ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
@@ -557,20 +557,30 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
         rFmt.maItemSet.Put(*pPoolItem);
 }
 
-void ScXMLTableRowCellContext::PushParagraphFieldSheetName()
+void ScXMLTableRowCellContext::PushParagraphField(SvxFieldData* pData)
 {
-    SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
-    maFields.push_back(new Field);
+    maFields.push_back(new Field(pData));
     Field& rField = maFields.back();
-    rField.mpItem = new SvxTableField(nTab);
+
     sal_Int32 nPos = maParagraph.getLength();
-    maParagraph.append(sal_Unicode('\1'));
+    maParagraph.append(sal_Unicode('\1')); // Placeholder text for inserted field item.
     rField.maSelection.nStartPara = mnCurParagraph;
     rField.maSelection.nEndPara = mnCurParagraph;
     rField.maSelection.nStartPos = nPos;
     rField.maSelection.nEndPos = nPos+1;
 }
 
+void ScXMLTableRowCellContext::PushParagraphFieldSheetName()
+{
+    SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
+    PushParagraphField(new SvxTableField(nTab));
+}
+
+void ScXMLTableRowCellContext::PushParagraphFieldDocTitle()
+{
+    PushParagraphField(new SvxFileField);
+}
+
 void ScXMLTableRowCellContext::PushParagraphEnd()
 {
     // EditEngine always has at least one paragraph even when its content is empty.
@@ -1027,7 +1037,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
                 {
                     FieldsType::const_iterator it = maFields.begin(), itEnd = maFields.end();
                     for (; it != itEnd; ++it)
-                        mpEditEngine->QuickInsertField(SvxFieldItem(*it->mpItem, EE_FEATURE_FIELD), it->maSelection);
+                        mpEditEngine->QuickInsertField(SvxFieldItem(*it->mpData, EE_FEATURE_FIELD), it->maSelection);
                 }
 
                 pNewCell = new ScEditCell(mpEditEngine->CreateTextObject(), pDoc, pDoc->GetEditPool());
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 20f4465..022d5a2 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -49,10 +49,10 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
 
     struct Field : boost::noncopyable
     {
-        SvxFieldData* mpItem;
+        SvxFieldData* mpData;
         ESelection maSelection;
 
-        Field();
+        Field(SvxFieldData* pData);
         ~Field();
     };
 
@@ -118,6 +118,8 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
 
     bool IsPossibleErrorString() const;
 
+    void PushParagraphField(SvxFieldData* pData);
+
 public:
 
     ScXMLTableRowCellContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
@@ -135,6 +137,7 @@ public:
 
     void PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName);
     void PushParagraphFieldSheetName();
+    void PushParagraphFieldDocTitle();
     void PushParagraphEnd();
 
     void SetAnnotation( const ScAddress& rPosition );


More information about the Libreoffice-commits mailing list