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

Kohei Yoshida kohei.yoshida at gmail.com
Thu Feb 7 20:11:53 PST 2013


 sc/source/filter/xml/xmlcelli.cxx |   99 ++++++++++++--------------------------
 sc/source/filter/xml/xmlcelli.hxx |    6 --
 2 files changed, 35 insertions(+), 70 deletions(-)

New commits:
commit 576fea5068cd43999da230a872c8d1217a5d2e86
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Feb 7 23:12:55 2013 -0500

    Import multi-line content into ScEditCell.
    
    Change-Id: I4fc53ddb888ff31a78dc233dd487f0e70daa6522

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 2272e98..abe8353 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -676,6 +676,27 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
     }
 }
 
+namespace {
+
+ScBaseCell* createEditCell(ScDocument* pDoc, const std::vector<OUString>& rParagraphs)
+{
+    // Create edit cell.
+    OUStringBuffer aBuf;
+    std::vector<OUString>::const_iterator it = rParagraphs.begin(), itEnd = rParagraphs.end();
+    bool bFirst = true;
+    for (; it != itEnd; ++it)
+    {
+        if (bFirst)
+            bFirst = false;
+        else
+            aBuf.append('\n');
+        aBuf.append(*it);
+    }
+    return ScBaseCell::CreateTextCell(aBuf.makeStringAndClear(), pDoc);
+}
+
+}
+
 void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
         const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText )
 {
@@ -728,7 +749,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
         if (maStringValue)
             pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc );
         else if (!maParagraphs.empty())
-            pNewCell = ScBaseCell::CreateTextCell(maParagraphs.back(), pDoc);
+            pNewCell = createEditCell(pDoc, maParagraphs);
         else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
             pNewCell = ScBaseCell::CreateTextCell( *pOUText, pDoc );
 
commit 5e2305c438eed64a56ff8beb515126ca0107306b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Feb 7 22:57:00 2013 -0500

    No need to check for empty value; it's checked when a value is assigned.
    
    Change-Id: I7d96910a6d8216aa17858b0cb05e161080c8dccc

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index d1df64f..2272e98 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -690,7 +690,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
         {
             ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
             OUString aCellString;
-            if (maStringValue && !maStringValue->isEmpty())
+            if (maStringValue)
                 aCellString = *maStringValue;
             else if (!maParagraphs.empty())
                 aCellString = maParagraphs.back();
@@ -725,7 +725,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
     {
         ScBaseCell* pNewCell = NULL;
         ScDocument* pDoc = rXMLImport.GetDocument();
-        if (maStringValue && !maStringValue->isEmpty())
+        if (maStringValue)
             pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc );
         else if (!maParagraphs.empty())
             pNewCell = ScBaseCell::CreateTextCell(maParagraphs.back(), pDoc);
@@ -935,7 +935,7 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
             pOUText.reset( getOutputString(rXMLImport.GetDocument(), rCellPos) );
 
         if (maParagraphs.empty() && !pOUText && !maStringValue)
-                bIsEmpty = true;
+            bIsEmpty = true;
     }
 
     ScAddress aCurrentPos( rCellPos );
commit 21c7138535f64d4263da822607537f661db95181
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Feb 7 22:51:50 2013 -0500

    These method names should use singular 'Cell', not 'Cells'.
    
    Change-Id: I9faa2727eda05be041aff4347f921ec9cd9b49d2

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 179c992..d1df64f 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -785,7 +785,7 @@ bool isEmptyOrNote( ScDocument* pDoc, const ScAddress& rCurrentPos )
 
 }
 
-void ScXMLTableRowCellContext::AddTextAndValueCells( const ScAddress& rCellPos,
+void ScXMLTableRowCellContext::AddTextAndValueCell( const ScAddress& rCellPos,
         const ::boost::optional< rtl::OUString >& pOUText, ScAddress& rCurrentPos )
 {
     ScMyTables& rTables = rXMLImport.GetTables();
@@ -925,7 +925,7 @@ rtl::OUString getOutputString(ScDocument* pDoc, const ScAddress& aCellPos)
 
 }
 
-void ScXMLTableRowCellContext::AddNonFormulaCells( const ScAddress& rCellPos )
+void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
 {
     ::boost::optional< rtl::OUString > pOUText;
 
@@ -942,7 +942,7 @@ void ScXMLTableRowCellContext::AddNonFormulaCells( const ScAddress& rCellPos )
     if( HasSpecialContent() )
         bIsEmpty = false;
 
-    AddTextAndValueCells( rCellPos, pOUText, aCurrentPos );
+    AddTextAndValueCell( rCellPos, pOUText, aCurrentPos );
 
     if( CellsAreRepeated() )
     {
@@ -1114,10 +1114,11 @@ void ScXMLTableRowCellContext::EndElement()
         aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
     if( bIsMerged )
         DoMerge( aCellPos, nMergedCols - 1, nMergedRows - 1 );
-    if (!maFormula)
-        AddNonFormulaCells( aCellPos );
+
+    if (maFormula)
+        AddFormulaCell(aCellPos);
     else
-        AddFormulaCell( aCellPos );
+        AddNonFormulaCell(aCellPos);
 
     UnlockSolarMutex(); //if LockSolarMutex got used, we presumably need to ensure an UnlockSolarMutex
 
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index b71537e..58d0e45 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -81,9 +81,9 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
     void PutTextCell                ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol,
                                       const ::boost::optional< rtl::OUString >& pOUText );
     void PutValueCell               ( const ScAddress& rScCurrentPos );
-    void AddTextAndValueCells       ( const ScAddress& rScCellPos,
+    void AddTextAndValueCell       ( const ScAddress& rScCellPos,
                                       const ::boost::optional< rtl::OUString >& pOUText, ScAddress& rScCurrentPos );
-    void AddNonFormulaCells         ( const ScAddress& rScCellPos );
+    void AddNonFormulaCell         ( const ScAddress& rScCellPos );
     void PutFormulaCell             ( const ScAddress& rScCurrentPos );
     void AddFormulaCell             ( const ScAddress& rScCellPos );
 
commit 0757bf72bc77eb559c61b375aabce58777014ba0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Feb 7 22:36:07 2013 -0500

    Removal of more obsolete stuff...
    
    Change-Id: Idad9121270ae89c504577f4e8d70ca4c4ed2e64b

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 4659c2a..179c992 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -120,7 +120,6 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
     bIsMatrix(false),
     bIsCovered(bTempIsCovered),
     bIsEmpty(true),
-    bHasTextImport(false),
     bIsFirstTextImport(false),
     bSolarMutexLocked(false),
     bFormulaTextResult(false),
@@ -306,42 +305,6 @@ void ScXMLTableRowCellContext::PushParagraph(const OUString& rPara)
     maParagraphs.push_back(rPara);
 }
 
-void ScXMLTableRowCellContext::SetCursorOnTextImport(const rtl::OUString& rOUTempText)
-{
-    ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
-    if (cellExists(aCellPos))
-    {
-        sal_Int32 nCol = static_cast<sal_Int32>( aCellPos.Col() );
-        sal_Int32 nRow = static_cast<sal_Int32>( aCellPos.Row() );
-        uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange());
-        if (xCellRange.is())
-        {
-            com::sun::star::uno::Reference<com::sun::star::table::XCell> xBaseCell( xCellRange->getCellByPosition(nCol, nRow) );
-            if (xBaseCell.is())
-            {
-                com::sun::star::uno::Reference<com::sun::star::document::XActionLockable> xLockable(xBaseCell, uno::UNO_QUERY);
-                if (xLockable.is())
-                    xLockable->addActionLock();
-                uno::Reference<text::XText> xText(xBaseCell, uno::UNO_QUERY);
-                if (xText.is())
-                {
-                    uno::Reference<text::XTextCursor> xTextCursor(xText->createTextCursor());
-                    if (xTextCursor.is())
-                    {
-                        xTextCursor->setString(rOUTempText);
-                        xTextCursor->gotoEnd(false);
-                        rXMLImport.GetTextImport()->SetCursor(xTextCursor);
-                    }
-                }
-            }
-        }
-    }
-    else
-    {
-        OSL_FAIL("this method should only be called for a existing cell");
-    }
-}
-
 SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPrefix,
                                             const ::rtl::OUString& rLName,
                                             const ::com::sun::star::uno::Reference<
@@ -777,7 +740,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
     // so ProgressBarIncrement must be called with bEditCell = FALSE.
     // Formatted text that is put into the cell by the child context
     // is handled in AddCellsToTable() (bIsEmpty is true then).
-    if (bDoIncrement || bHasTextImport)
+    if (bDoIncrement)
         rXMLImport.ProgressBarIncrement(false);
 }
 
@@ -901,11 +864,6 @@ void ScXMLTableRowCellContext::AddTextAndValueCells( const ScAddress& rCellPos,
         }
         else
         {
-            // #i56027# If the child context put formatted text into the cell,
-            // bIsEmpty is true and ProgressBarIncrement has to be called
-            // with bEditCell = TRUE.
-            if (bHasTextImport)
-                rXMLImport.ProgressBarIncrement(true);
             if ((i == 0) && (rCellPos.Col() == 0))
             {
                 for (sal_Int32 j = 1; j < nRepeatedRows; ++j)
@@ -1144,19 +1102,6 @@ bool ScXMLTableRowCellContext::IsPossibleErrorString() const
 
 void ScXMLTableRowCellContext::EndElement()
 {
-    if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
-    {
-        UniReference< XMLTextImportHelper > aTextImport = rXMLImport.GetTextImport();
-        if( aTextImport->GetCursor().is() )
-        {
-            if( aTextImport->GetCursor()->goLeft(1, true) )
-            {
-                aTextImport->GetText()->insertString(
-                    aTextImport->GetCursorAsRange(), rtl::OUString(), true );
-            }
-            aTextImport->ResetCursor();
-        }
-    }
     HasSpecialCaseFormulaText();
     if( bFormulaTextResult && (mbPossibleErrorCell || mbCheckWithCompilerForError) )
     {
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index cd0ce08..b71537e 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -55,7 +55,6 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
     bool        bIsMatrix;
     bool        bIsCovered;
     bool        bIsEmpty;
-    bool        bHasTextImport;
     bool        bIsFirstTextImport;
     bool        bSolarMutexLocked;
     bool        bFormulaTextResult;
@@ -108,7 +107,6 @@ public:
                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
 
     void PushParagraph(const OUString& rPara);
-    void SetCursorOnTextImport(const rtl::OUString& rOUTempText);
 
     void SetAnnotation( const ScAddress& rPosition );
     void SetDetectiveObj( const ScAddress& rPosition );


More information about the Libreoffice-commits mailing list