[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Wed Mar 27 12:50:53 PDT 2013
sc/inc/cell.hxx | 2 -
sc/inc/dociter.hxx | 2 -
sc/inc/document.hxx | 1
sc/inc/editutil.hxx | 3 ++
sc/source/core/data/cell.cxx | 12 ---------
sc/source/core/data/document.cxx | 9 ++++++-
sc/source/core/tool/editutil.cxx | 10 +++++++
sc/source/ui/docshell/docsh8.cxx | 50 +++++++++++++++++++++------------------
sc/source/ui/view/gridwin.cxx | 47 +++++++++++++++++-------------------
9 files changed, 75 insertions(+), 61 deletions(-)
New commits:
commit c2a63024f4c5d105e9678163cbb2ad6c7806afb0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Mar 27 15:53:09 2013 -0400
More on killing direct use of ScEditCell.
Change-Id: If6e3529666ff064107d3c5687b6993822572c0d9
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 0b78f98..c3443d2 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -105,8 +105,6 @@ public:
bool HasValueData() const;
bool HasStringData() const;
rtl::OUString GetStringData() const; // only real strings
- // default implementation, creates url object from passed url
- static EditTextObject* CreateURLObjectFromURL( ScDocument& rDoc, const OUString& rURL, const OUString& rText );
static bool CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 );
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 4477ba3..5e9b16d 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -425,7 +425,7 @@ private:
SCTAB nTab;
SCCOL nStartCol;
SCCOL nEndCol;
- SCROW nStartRow;
+ SCROW nStartRow;
SCROW nEndRow;
SCROW* pNextRows;
SCSIZE* pNextIndices;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a245da8..ec944f6 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1227,6 +1227,7 @@ public:
SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const;
SC_DLLPUBLIC const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
+ SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const;
SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
ScPatternAttr* CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index ac8fc23..5f979cb 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -61,6 +61,9 @@ public:
SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText );
+ static EditTextObject* CreateURLObjectFromURL(
+ ScDocument& rDoc, const OUString& rURL, const OUString& rText );
+
public:
ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
const Point& rScrPosPixel,
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index c34e55c..03fbe68 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -600,16 +600,6 @@ bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 )
return false;
}
-EditTextObject* ScBaseCell::CreateURLObjectFromURL( ScDocument& rDoc, const OUString& rURL, const OUString& rText )
-{
- SvxURLField aUrlField( rURL, rText, SVXURLFORMAT_APPDEFAULT);
- EditEngine& rEE = rDoc.GetEditEngine();
- rEE.SetText( EMPTY_STRING );
- rEE.QuickInsertField( SvxFieldItem( aUrlField, EE_FEATURE_FIELD ), ESelection( 0xFFFF, 0xFFFF ) );
-
- return rEE.CreateTextObject();
-}
-
// ============================================================================
ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) :
@@ -1978,7 +1968,7 @@ EditTextObject* ScFormulaCell::CreateURLObject()
rtl::OUString aURL;
GetURLResult( aURL, aCellText );
- return CreateURLObjectFromURL( *pDocument, aURL, aCellText );
+ return ScEditUtil::CreateURLObjectFromURL( *pDocument, aURL, aCellText );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 93ddc9f..97e66a7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4309,11 +4309,18 @@ const SfxPoolItem* ScDocument::GetAttr( const ScAddress& rPos, sal_uInt16 nWhich
const ScPatternAttr* ScDocument::GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
{
- if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
+ if (TableExists(nTab))
return maTabs[nTab]->GetPattern( nCol, nRow );
return NULL;
}
+const ScPatternAttr* ScDocument::GetPattern( const ScAddress& rPos ) const
+{
+ if (TableExists(rPos.Tab()))
+ return maTabs[rPos.Tab()]->GetPattern(rPos.Col(), rPos.Row());
+
+ return NULL;
+}
const ScPatternAttr* ScDocument::GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const
{
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 67ff543..53f36ad 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -104,6 +104,16 @@ OUString ScEditUtil::GetString( const EditTextObject& rEditText )
return aRet.makeStringAndClear();
}
+EditTextObject* ScEditUtil::CreateURLObjectFromURL( ScDocument& rDoc, const OUString& rURL, const OUString& rText )
+{
+ SvxURLField aUrlField( rURL, rText, SVXURLFORMAT_APPDEFAULT);
+ EditEngine& rEE = rDoc.GetEditEngine();
+ rEE.SetText( EMPTY_OUSTRING );
+ rEE.QuickInsertField( SvxFieldItem( aUrlField, EE_FEATURE_FIELD ), ESelection( 0xFFFF, 0xFFFF ) );
+
+ return rEE.CreateTextObject();
+}
+
//------------------------------------------------------------------------
Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, sal_Bool bForceToTop )
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index e17b8c4..2170b86 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -72,6 +72,7 @@
#include "docpool.hxx"
#include "segmenttree.hxx"
#include "docparam.hxx"
+#include "cellvalue.hxx"
#include <vector>
#include <boost/unordered_set.hpp>
@@ -761,10 +762,13 @@ void lcl_GetColumnTypes(
}
}
-inline void lcl_getLongVarCharEditString( rtl::OUString& rString,
- const ScBaseCell* pCell, ScFieldEditEngine& rEditEngine )
+inline void lcl_getLongVarCharEditString( OUString& rString,
+ const ScRefCellValue& rCell, ScFieldEditEngine& rEditEngine )
{
- rEditEngine.SetText( *((const ScEditCell*)pCell)->GetData() );
+ if (!rCell.mpEditText)
+ return;
+
+ rEditEngine.SetText(*rCell.mpEditText);
rString = rEditEngine.GetText( LINEEND_CRLF );
}
@@ -968,27 +972,26 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
switch (pColTypes[nCol])
{
case sdbc::DataType::LONGVARCHAR:
+ {
+ ScRefCellValue aCell;
+ aCell.assign(aDocument, ScAddress(nDocCol, nDocRow, nTab));
+ if (!aCell.isEmpty())
{
- ScBaseCell* pCell;
- aDocument.GetCell( nDocCol, nDocRow, nTab, pCell );
- if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
- {
- if ( pCell->GetCellType() == CELLTYPE_EDIT )
- { // Paragraphs erhalten
- lcl_getLongVarCharEditString( aString,
- pCell, aEditEngine);
- }
- else
- {
- lcl_getLongVarCharString(
- aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt);
- }
- xRowUpdate->updateString( nCol+1, aString );
+ if (aCell.meType == CELLTYPE_EDIT)
+ { // Paragraphs erhalten
+ lcl_getLongVarCharEditString(aString, aCell, aEditEngine);
}
else
- xRowUpdate->updateNull( nCol+1 );
+ {
+ lcl_getLongVarCharString(
+ aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt);
+ }
+ xRowUpdate->updateString( nCol+1, aString );
}
- break;
+ else
+ xRowUpdate->updateNull( nCol+1 );
+ }
+ break;
case sdbc::DataType::VARCHAR:
aString = aDocument.GetString(nDocCol, nDocRow, nTab);
@@ -1090,8 +1093,11 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
if ( pCell->GetCellType() != CELLTYPE_NOTE )
{
if ( pCell->GetCellType() == CELLTYPE_EDIT )
- lcl_getLongVarCharEditString( aString,
- pCell, aEditEngine);
+ {
+ ScRefCellValue aCell;
+ aCell.assign(*pCell);
+ lcl_getLongVarCharEditString(aString, aCell, aEditEngine);
+ }
else
lcl_getLongVarCharString(
aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1a47370..c31a2c3 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -379,13 +379,15 @@ static void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pD
}
}
-static sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell, OUString& rURL )
+static bool lcl_GetHyperlinkCell(
+ ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScRefCellValue& rCell, OUString& rURL )
{
- sal_Bool bFound = false;
+ bool bFound = false;
do
{
- pDoc->GetCell( rPosX, rPosY, nTab, rpCell );
- if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE )
+ ScAddress aPos(rPosX, rPosY, nTab);
+ rCell.assign(*pDoc, aPos);
+ if (rCell.isEmpty())
{
if ( rPosX <= 0 )
return false; // alles leer bis links
@@ -394,17 +396,16 @@ static sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPos
}
else
{
- const ScPatternAttr* pPattern = pDoc->GetPattern( rPosX, rPosY, nTab );
+ const ScPatternAttr* pPattern = pDoc->GetPattern(aPos);
if ( !((SfxStringItem&)pPattern->GetItem(ATTR_HYPERLINK)).GetValue().isEmpty() )
{
rURL = ((SfxStringItem&)pPattern->GetItem(ATTR_HYPERLINK)).GetValue();
bFound = true;
}
- else if ( rpCell->GetCellType() == CELLTYPE_EDIT)
- bFound = sal_True;
- else if (rpCell->GetCellType() == CELLTYPE_FORMULA &&
- static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell())
- bFound = sal_True;
+ else if (rCell.meType == CELLTYPE_EDIT)
+ bFound = true;
+ else if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->IsHyperLinkCell())
+ bFound = true;
else
return false; // andere Zelle
}
@@ -2325,9 +2326,9 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
SCsROW nPosY;
SCTAB nTab = pViewData->GetTabNo();
pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
- ScBaseCell* pCell = NULL;
OUString sURL;
- if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell, sURL ) )
+ ScRefCellValue aCell;
+ if (lcl_GetHyperlinkCell(pDoc, nPosX, nPosY, nTab, aCell, sURL))
{
ScAddress aCellPos( nPosX, nPosY, nTab );
uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) );
@@ -5009,9 +5010,9 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
SCTAB nTab = pViewData->GetTabNo();
ScDocShell* pDocSh = pViewData->GetDocShell();
ScDocument* pDoc = pDocSh->GetDocument();
- ScBaseCell* pCell = NULL;
OUString sURL;
- sal_Bool bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell, sURL );
+ ScRefCellValue aCell;
+ bool bFound = lcl_GetHyperlinkCell(pDoc, nPosX, nPosY, nTab, aCell, sURL);
if( !bFound )
return false;
@@ -5067,7 +5068,7 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
Rectangle aLogicEdit = PixelToLogic( aEditRect, aEditMode );
long nThisColLogic = aLogicEdit.Right() - aLogicEdit.Left() + 1;
Size aPaperSize = Size( 1000000, 1000000 );
- if(pCell->GetCellType() == CELLTYPE_FORMULA)
+ if (aCell.meType == CELLTYPE_FORMULA)
{
long nSizeX = 0;
long nSizeY = 0;
@@ -5081,20 +5082,19 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
aEngine.SetPaperSize( aPaperSize );
boost::scoped_ptr<EditTextObject> pTextObj;
- if(pCell->GetCellType() == CELLTYPE_EDIT)
+ if (aCell.meType == CELLTYPE_EDIT)
{
- const EditTextObject* pData = static_cast<ScEditCell*>(pCell)->GetData();
- if (pData)
- aEngine.SetText(*pData);
+ if (aCell.mpEditText)
+ aEngine.SetText(*aCell.mpEditText);
}
else // Not an Edit cell and is a formula cell with 'Hyperlink'
// function if we have no URL, otherwise it could be a formula
// cell ( or other type ? ) with a hyperlink associated with it.
{
- if ( sURL.isEmpty() )
- pTextObj.reset((static_cast<ScFormulaCell*>(pCell))->CreateURLObject());
+ if (sURL.isEmpty())
+ pTextObj.reset(aCell.mpFormula->CreateURLObject());
else
- pTextObj.reset( ScBaseCell::CreateURLObjectFromURL( *pDoc, sURL, sURL ) );
+ pTextObj.reset(ScEditUtil::CreateURLObjectFromURL(*pDoc, sURL, sURL));
if (pTextObj.get())
aEngine.SetText(*pTextObj);
@@ -5119,8 +5119,7 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
// There is one glitch when dealing with a hyperlink cell and
// the cell content is NUMERIC. This defaults to right aligned and
// we need to adjust accordingly.
- if(pCell->GetCellType() == CELLTYPE_FORMULA &&
- static_cast<ScFormulaCell*>(pCell)->IsValue() &&
+ if (aCell.meType == CELLTYPE_FORMULA && aCell.mpFormula->IsValue() &&
eHorJust == SVX_HOR_JUSTIFY_STANDARD)
{
aLogicEdit.Right() = aLogicEdit.Left() + nThisColLogic - 1;
More information about the Libreoffice-commits
mailing list