[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Wed Mar 27 12:11:10 PDT 2013


 sc/source/filter/excel/xicontent.cxx     |    3 
 sc/source/filter/excel/xistyle.cxx       |    2 
 sc/source/filter/oox/sheetdatabuffer.cxx |    2 
 sc/source/ui/app/transobj.cxx            |   22 ++----
 sc/source/ui/inc/viewfunc.hxx            |    2 
 sc/source/ui/undo/undocell.cxx           |    7 --
 sc/source/ui/unoobj/textuno.cxx          |   15 ++--
 sc/source/ui/view/gridwin.cxx            |    3 
 sc/source/ui/view/spelleng.cxx           |   20 ++---
 sc/source/ui/view/tabvwsha.cxx           |   11 +--
 sc/source/ui/view/viewfun4.cxx           |  105 ++++++++++++++-----------------
 11 files changed, 88 insertions(+), 104 deletions(-)

New commits:
commit ace0ff1c36eb51397488f814510a3e4cec41c8a8
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 27 15:13:26 2013 -0400

    Started killing direct use of ScEditCell.
    
    Change-Id: Id4afe6b748b5317db93e0a36257311e5bcff3820

diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index 86ed9de..ecee9c8 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -169,8 +169,7 @@ void lclInsertUrl( const XclImpRoot& rRoot, const String& rUrl, SCCOL nScCol, SC
             ScEditEngineDefaulter& rEE = rRoot.GetEditEngine();
             SvxURLField aUrlField( rUrl, aDisplText, SVXURLFORMAT_APPDEFAULT );
 
-            const ScEditCell* pEditCell = (eCellType == CELLTYPE_EDIT) ? static_cast< const ScEditCell* >( rDoc.GetCell( aScPos ) ) : 0;
-            const EditTextObject* pEditObj = pEditCell ? pEditCell->GetData() : 0;
+            const EditTextObject* pEditObj = rDoc.GetEditText(aScPos);
             if( pEditObj )
             {
                 rEE.SetText( *pEditObj );
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index a118f83..55e0087 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -2003,7 +2003,7 @@ void XclImpXFRangeBuffer::Finalize()
         {
             bool bTextWrap = static_cast< const SfxBoolItem* >( rDoc.GetAttr( rStart.Col(), rStart.Row(), rStart.Tab(), ATTR_LINEBREAK ) )->GetValue();
             if( !bTextWrap && (rDoc.GetCellType( rStart ) == CELLTYPE_EDIT) )
-                if( const EditTextObject* pEditObj = static_cast< const ScEditCell* >( rDoc.GetCell( rStart ) )->GetData() )
+                if (const EditTextObject* pEditObj = rDoc.GetEditText(rStart))
                     bTextWrap = pEditObj->GetParagraphCount() > 1;
             if( bTextWrap )
                 GetOldRoot().pColRowBuff->SetManualRowHeight( rStart.Row() );
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 4ea10d0..1e804ff 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -693,7 +693,7 @@ void SheetDataBuffer::applyCellMerging( const CellRangeAddress& rRange )
         bool bTextWrap = static_cast< const SfxBoolItem* >( rDoc.GetAttr( rStart.Col(), rStart.Row(), rStart.Tab(), ATTR_LINEBREAK ) )->GetValue();
         if( !bTextWrap && (rDoc.GetCellType( rStart ) == CELLTYPE_EDIT) )
         {
-            if( const EditTextObject* pEditObj = static_cast< const ScEditCell* >( rDoc.GetCell( rStart ) )->GetData() )
+            if (const EditTextObject* pEditObj = rDoc.GetEditText(rStart))
                 bTextWrap = pEditObj->GetParagraphCount() > 1;
         }
     }
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index bb3019e..275d50b 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -264,23 +264,21 @@ sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor )
             SCCOL nCol = aBlock.aStart.Col();
             SCROW nRow = aBlock.aStart.Row();
             SCTAB nTab = aBlock.aStart.Tab();
+            ScAddress aPos(nCol, nRow, nTab);
 
             const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
             ScTabEditEngine aEngine( *pPattern, pDoc->GetEditPool() );
-            ScBaseCell* pCell = NULL;
-            pDoc->GetCell( nCol, nRow, nTab, pCell );
-            if (pCell)
+            if (pDoc->GetCellType(aPos) == CELLTYPE_EDIT)
             {
-                if (pCell->GetCellType() == CELLTYPE_EDIT)
-                {
-                    const EditTextObject* pObj = static_cast<const ScEditCell*>(pCell)->GetData();
-                    aEngine.SetText( *pObj );
-                }
-                else
-                {
-                    OUString aText = pDoc->GetString(nCol, nRow, nTab);
+                const EditTextObject* pObj = pDoc->GetEditText(aPos);
+                if (pObj)
+                    aEngine.SetText(*pObj);
+            }
+            else
+            {
+                OUString aText = pDoc->GetString(nCol, nRow, nTab);
+                if (!aText.isEmpty())
                     aEngine.SetText(aText);
-                }
             }
 
             bOK = SetObject( &aEngine,
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 76c6734..5229b99 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -146,7 +146,7 @@ public:
     void            InsertBookmark( const String& rDescription, const String& rURL,
                                     SCCOL nPosX, SCROW nPosY, const String* pTarget = NULL,
                                     sal_Bool bTryReplace = false );
-    sal_Bool            HasBookmarkAtCursor( SvxHyperlinkItem* pContent );
+    bool HasBookmarkAtCursor( SvxHyperlinkItem* pContent );
 
     long            DropRequestHdl( Exchange* pExchange );
     sal_Bool            MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos,
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 5d487a8..a1f0f9e 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -100,12 +100,11 @@ void ScUndoCursorAttr::SetEditData( EditTextObject* pOld, EditTextObject* pNew )
 void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const shared_ptr<EditTextObject>& pEditData ) const
 {
     ScDocument* pDoc = pDocShell->GetDocument();
+    ScAddress aPos(nCol, nRow, nTab);
     pDoc->SetPattern( nCol, nRow, nTab, *pWhichPattern, true );
 
-    ScBaseCell* pCell;
-    pDoc->GetCell(nCol, nRow, nTab, pCell);
-    if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData)
-        static_cast<ScEditCell*>(pCell)->SetData(*pEditData, NULL);
+    if (pDoc->GetCellType(aPos) == CELLTYPE_EDIT && pEditData)
+        pDoc->SetEditText(aPos, *pEditData, NULL);
 
     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     if (pViewShell)
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index fbd48a5..c5c31e2 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -1003,20 +1003,23 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder()
             pPattern->FillEditParaItems( &aDefaults );  // including alignment etc. (for reading)
         }
 
-        const ScBaseCell* pCell = pDoc->GetCell( aCellPos );
-        if ( pCell && pCell->GetCellType() == CELLTYPE_EDIT )
-            pEditEngine->SetTextNewDefaults( *((const ScEditCell*)pCell)->GetData(), aDefaults );
+        if (pDoc->GetCellType(aCellPos) == CELLTYPE_EDIT)
+        {
+            const EditTextObject* pObj = pDoc->GetEditText(aCellPos);
+            if (pObj)
+                pEditEngine->SetTextNewDefaults(*pObj, aDefaults);
+        }
         else
         {
-            GetCellText( aCellPos, aText );
+            GetCellText(aCellPos, aText);
             if (aText.Len())
-                pEditEngine->SetTextNewDefaults( aText, aDefaults );
+                pEditEngine->SetTextNewDefaults(aText, aDefaults);
             else
                 pEditEngine->SetDefaults(aDefaults);
         }
     }
 
-    bDataValid = sal_True;
+    bDataValid = true;
     return pForwarder;
 }
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index a0d7634..1a47370 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -127,6 +127,7 @@
 #include <svx/sdr/overlay/overlayselection.hxx>
 
 #include <vector>
+#include <boost/scoped_ptr.hpp>
 
 using namespace com::sun::star;
 using ::com::sun::star::uno::Sequence;
@@ -5079,7 +5080,7 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
         aPaperSize.Width() = nThisColLogic;
     aEngine.SetPaperSize( aPaperSize );
 
-    ::std::auto_ptr< EditTextObject > pTextObj;
+    boost::scoped_ptr<EditTextObject> pTextObj;
     if(pCell->GetCellType() == CELLTYPE_EDIT)
     {
         const EditTextObject* pData = static_cast<ScEditCell*>(pCell)->GetData();
diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx
index 65f1d9e..61bc765 100644
--- a/sc/source/ui/view/spelleng.cxx
+++ b/sc/source/ui/view/spelleng.cxx
@@ -247,31 +247,25 @@ void ScConversionEngineBase::ShowFinishDialog()
 
 void ScConversionEngineBase::FillFromCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
 {
-    CellType eCellType;
-    mrDoc.GetCellType( nCol, nRow, nTab, eCellType );
+    ScAddress aPos(nCol, nRow, nTab);
 
-    switch( eCellType )
+    switch (mrDoc.GetCellType(aPos))
     {
         case CELLTYPE_STRING:
         {
-            OUString aText = mrDoc.GetString(nCol, nRow, nTab);
+            OUString aText = mrDoc.GetString(aPos);
             SetText( aText );
         }
         break;
         case CELLTYPE_EDIT:
         {
-            ScBaseCell* pCell = NULL;
-            mrDoc.GetCell( nCol, nRow, nTab, pCell );
-            if( pCell )
-            {
-                const EditTextObject* pNewEditObj = static_cast<ScEditCell*>(pCell)->GetData();
-                if( pNewEditObj )
-                    SetText( *pNewEditObj );
-            }
+            const EditTextObject* pNewEditObj = mrDoc.GetEditText(aPos);
+            if (pNewEditObj)
+                SetText(*pNewEditObj);
         }
         break;
         default:
-            SetText( EMPTY_STRING );
+            SetText(EMPTY_OUSTRING);
     }
 }
 
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 5d8e622..071c4e4 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -627,6 +627,7 @@ void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_
         SCROW                   nStartRow   = 0;
         SCCOL                   nEndCol     = 0;
         SCROW                   nEndRow     = 0;
+        ScAddress aPos = pViewData->GetCurPos();
 
         pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
                                   nEndCol,   nEndRow,   nEndTab );
@@ -635,8 +636,8 @@ void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_
         PutInOrder( nStartRow, nEndRow );
         PutInOrder( nStartTab, nEndTab );
 
-        sal_Bool bHideFormula = false;
-        sal_Bool bHideAll     = false;
+        bool bHideFormula = false;
+        bool bHideAll     = false;
 
         if (pDoc->IsTabProtected(nTab))
         {
@@ -649,7 +650,7 @@ void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_
 
         if (!bHideAll)
         {
-            pDoc->GetCellType( nPosX, nPosY, nTab, eType );
+            eType = pDoc->GetCellType(aPos);
             if (eType == CELLTYPE_FORMULA)
             {
                 if (!bHideFormula)
@@ -657,9 +658,7 @@ void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_
             }
             else if (eType == CELLTYPE_EDIT)
             {
-                ScBaseCell* pCell;
-                pDoc->GetCell( nPosX, nPosY, nTab, pCell );
-                pObject = static_cast<ScEditCell*>(pCell)->GetData();
+                pObject = pDoc->GetEditText(aPos);
             }
             else
             {
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index d05795e..7e7e3df 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -307,7 +307,6 @@ void ScViewFunc::DoThesaurus( sal_Bool bRecord )
     ScDocument* pDoc = pDocSh->GetDocument();
     ScMarkData& rMark = GetViewData()->GetMarkData();
     ScSplitPos eWhich = GetViewData()->GetActivePart();
-    CellType eCellType;
     EESpellState eState;
     String sOldText, sNewString;
     EditTextObject* pOldTObj = NULL;
@@ -333,21 +332,22 @@ void ScViewFunc::DoThesaurus( sal_Bool bRecord )
     }
     nTab = GetViewData()->GetTabNo();
 
+    ScAddress aPos(nCol, nRow, nTab);
     ScEditableTester aTester( pDoc, nCol, nRow, nCol, nRow, rMark );
     if (!aTester.IsEditable())
     {
         ErrorMessage(aTester.GetMessageId());
         return;
     }
-    pDoc->GetCellType(nCol, nRow, nTab, eCellType);
+
+    CellType eCellType = pDoc->GetCellType(aPos);
     if (eCellType != CELLTYPE_STRING && eCellType != CELLTYPE_EDIT)
     {
         ErrorMessage(STR_THESAURUS_NO_STRING);
         return;
     }
 
-    com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1>
-                                        xSpeller = LinguMgr::GetSpellChecker();
+    uno::Reference<linguistic2::XSpellChecker1> xSpeller = LinguMgr::GetSpellChecker();
 
     pThesaurusEngine = new ScEditEngineDefaulter( pDoc->GetEnginePool() );
     pThesaurusEngine->SetEditTextObjectPool( pDoc->GetEditPool() );
@@ -357,7 +357,7 @@ void ScViewFunc::DoThesaurus( sal_Bool bRecord )
     const ScPatternAttr* pPattern = NULL;
     SfxItemSet* pEditDefaults = new SfxItemSet(pThesaurusEngine->GetEmptyItemSet());
     pPattern = pDoc->GetPattern(nCol, nRow, nTab);
-    if (pPattern )
+    if (pPattern)
     {
         pPattern->FillEditItemSet( pEditDefaults );
         pThesaurusEngine->SetDefaults( *pEditDefaults );
@@ -365,20 +365,16 @@ void ScViewFunc::DoThesaurus( sal_Bool bRecord )
 
     if (eCellType == CELLTYPE_STRING)
     {
-        sOldText = pDoc->GetString(nCol, nRow, nTab);
+        sOldText = pDoc->GetString(aPos);
         pThesaurusEngine->SetText(sOldText);
     }
     else if (eCellType == CELLTYPE_EDIT)
     {
-        pDoc->GetCell(nCol, nRow, nTab, pCell);
-        if (pCell)
+        pTObject = pDoc->GetEditText(aPos);
+        if (pTObject)
         {
-            pTObject = static_cast<ScEditCell*>(pCell)->GetData();
-            if (pTObject)
-            {
-                pOldTObj = pTObject->Clone();
-                pThesaurusEngine->SetText(*pTObject);
-            }
+            pOldTObj = pTObject->Clone();
+            pThesaurusEngine->SetText(*pTObject);
         }
     }
     else
@@ -723,23 +719,17 @@ void ScViewFunc::InsertBookmark( const String& rDescription, const String& rURL,
     ScDocument* pDoc = GetViewData()->GetDocument();
     SCTAB nTab = GetViewData()->GetTabNo();
     ScAddress aCellPos( nPosX, nPosY, nTab );
-    ScBaseCell* pCell = pDoc->GetCell( aCellPos );
     EditEngine aEngine( pDoc->GetEnginePool() );
-    if (pCell)
+
+    const EditTextObject* pOld = pDoc->GetEditText(aCellPos);
+    if (pOld)
+        aEngine.SetText(*pOld);
+    else
     {
-        if (pCell->GetCellType() == CELLTYPE_EDIT)
-        {
-            const EditTextObject* pOld = static_cast<ScEditCell*>(pCell)->GetData();
-            if (pOld)
-                aEngine.SetText(*pOld);
-        }
-        else
-        {
-            String aOld;
-            pDoc->GetInputString( nPosX, nPosY, nTab, aOld );
-            if (aOld.Len())
-                aEngine.SetText(aOld);
-        }
+        OUString aOld;
+        pDoc->GetInputString(nPosX, nPosY, nTab, aOld);
+        if (!aOld.isEmpty())
+            aEngine.SetText(aOld);
     }
 
     sal_uInt16 nPara = aEngine.GetParagraphCount();
@@ -765,40 +755,41 @@ void ScViewFunc::InsertBookmark( const String& rDescription, const String& rURL,
     EnterData(nPosX, nPosY, nTab, *pData);
 }
 
-sal_Bool ScViewFunc::HasBookmarkAtCursor( SvxHyperlinkItem* pContent )
+bool ScViewFunc::HasBookmarkAtCursor( SvxHyperlinkItem* pContent )
 {
     ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
     ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
 
-    ScBaseCell* pCell = pDoc->GetCell( aPos );
-    if ( pCell && pCell->GetCellType() == CELLTYPE_EDIT )
+    const EditTextObject* pData = pDoc->GetEditText(aPos);
+    if (pData)
+        return false;
+
+    if (!pData->IsFieldObject())
+        // not a field object.
+        return false;
+
+    const SvxFieldItem* pFieldItem = pData->GetField();
+    if (!pFieldItem)
+        // doesn't have a field item.
+        return false;
+
+    const SvxFieldData* pField = pFieldItem->GetField();
+    if (!pField)
+        // doesn't have a field item data.
+        return false;
+
+    if (pField->GetClassId() != com::sun::star::text::textfield::Type::URL)
+        // not a URL field.
+        return false;
+
+    if (pContent)
     {
-        const EditTextObject* pData = static_cast<ScEditCell*>(pCell)->GetData();
-        if (pData)
-        {
-            sal_Bool bField = pData->IsFieldObject();
-            if (bField)
-            {
-                const SvxFieldItem* pFieldItem = pData->GetField();
-                if (pFieldItem)
-                {
-                    const SvxFieldData* pField = pFieldItem->GetField();
-                    if ( pField && pField->ISA(SvxURLField) )
-                    {
-                        if (pContent)
-                        {
-                            const SvxURLField* pURLField = (const SvxURLField*)pField;
-                            pContent->SetName( pURLField->GetRepresentation() );
-                            pContent->SetURL( pURLField->GetURL() );
-                            pContent->SetTargetFrame( pURLField->GetTargetFrame() );
-                        }
-                        return sal_True;
-                    }
-                }
-            }
-        }
+        const SvxURLField* pURLField = static_cast<const SvxURLField*>(pField);
+        pContent->SetName( pURLField->GetRepresentation() );
+        pContent->SetURL( pURLField->GetURL() );
+        pContent->SetTargetFrame( pURLField->GetTargetFrame() );
     }
-    return false;
+    return true;
 }
 
 


More information about the Libreoffice-commits mailing list