diff options
-rw-r--r-- | sc/source/filter/excel/xicontent.cxx | 16 | ||||
-rw-r--r-- | sc/source/filter/rtf/rtfexp.cxx | 15 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleCell.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleText.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 59 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/unoobj/textuno.cxx | 13 |
10 files changed, 117 insertions, 91 deletions
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index 69ecaa668879..a7a857a99bcd 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -37,6 +37,8 @@ #include <editeng/colritem.hxx> #include <editeng/crossedoutitem.hxx> #include "stringutil.hxx" +#include "cellform.hxx" +#include "cellvalue.hxx" #include "document.hxx" #include "editutil.hxx" #include "formulacell.hxx" @@ -163,23 +165,27 @@ void lclInsertUrl( XclImpRoot& rRoot, const OUString& rUrl, SCCOL nScCol, SCROW { ScDocumentImport& rDoc = rRoot.GetDocImport(); ScAddress aScPos( nScCol, nScRow, nScTab ); - CellType eCellType = rDoc.getDoc().GetCellType(aScPos); - switch( eCellType ) + ScRefCellValue aCell(rDoc.getDoc(), aScPos); + switch( aCell.meType ) { // #i54261# hyperlinks in string cells case CELLTYPE_STRING: case CELLTYPE_EDIT: { - OUString aDisplText = rDoc.getDoc().GetString(nScCol, nScRow, nScTab); + sal_uLong nNumFmt = rDoc.getDoc().GetNumberFormat(aScPos); + SvNumberFormatter* pFormatter = rDoc.getDoc().GetFormatTable(); + Color* pColor; + OUString aDisplText; + ScCellFormat::GetString(aCell, nNumFmt, aDisplText, &pColor, *pFormatter, &rDoc.getDoc()); if (aDisplText.isEmpty()) aDisplText = rUrl; ScEditEngineDefaulter& rEE = rRoot.GetEditEngine(); SvxURLField aUrlField( rUrl, aDisplText, SVXURLFORMAT_APPDEFAULT ); - const EditTextObject* pEditObj = rDoc.getDoc().GetEditText(aScPos); - if( pEditObj ) + if( aCell.meType == CELLTYPE_EDIT ) { + const EditTextObject* pEditObj = aCell.mpEditText; rEE.SetText( *pEditObj ); rEE.QuickInsertField( SvxFieldItem( aUrlField, EE_FEATURE_FIELD ), ESelection( 0, 0, EE_PARA_ALL, 0 ) ); } diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx index 4c16276380e8..c2d065d49719 100644 --- a/sc/source/filter/rtf/rtfexp.cxx +++ b/sc/source/filter/rtf/rtfexp.cxx @@ -33,6 +33,7 @@ #include "rtfexp.hxx" #include "filter.hxx" +#include "cellvalue.hxx" #include "document.hxx" #include "patattr.hxx" #include "attrib.hxx" @@ -165,7 +166,8 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) bool bValueData = false; OUString aContent; ScAddress aPos(nCol, nRow, nTab); - switch (pDoc->GetCellType(aPos)) + ScRefCellValue aCell(*pDoc, aPos); + switch (aCell.meType) { case CELLTYPE_NONE: bValueData = false; @@ -173,13 +175,10 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) case CELLTYPE_EDIT: { bValueData = false; - const EditTextObject* pObj = pDoc->GetEditText(aPos); - if (pObj) - { - EditEngine& rEngine = GetEditEngine(); - rEngine.SetText(*pObj); - aContent = rEngine.GetText(); // LineFeed in between paragraphs! - } + const EditTextObject* pObj = aCell.mpEditText; + EditEngine& rEngine = GetEditEngine(); + rEngine.SetText(*pObj); + aContent = rEngine.GetText(); // LineFeed in between paragraphs! } break; default: diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 6fbad6d3500a..556d4abe4619 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -23,6 +23,7 @@ #include "xmlstyli.hxx" #include "xmlannoi.hxx" #include "global.hxx" +#include "cellvalue.hxx" #include "document.hxx" #include "cellsuno.hxx" #include "docuno.hxx" @@ -1047,10 +1048,11 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, //cell was already put in document, just need to set text here. if( rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos) ) { - bDoIncrement = rXMLImport.GetDocument()->GetCellType(rCurrentPos) == CELLTYPE_FORMULA; + ScRefCellValue aCell(*rXMLImport.GetDocument(), rCurrentPos); + bDoIncrement = aCell.meType == CELLTYPE_FORMULA; if ( bDoIncrement ) { - ScFormulaCell* pFCell = rXMLImport.GetDocument()->GetFormulaCell(rCurrentPos); + ScFormulaCell* pFCell = aCell.mpFormula; OUString aCellString; if (maStringValue) aCellString = *maStringValue; @@ -1147,9 +1149,10 @@ void ScXMLTableRowCellContext::PutValueCell( const ScAddress& rCurrentPos ) //cell was already put in document, just need to set value here. if( rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos) ) { - if (rXMLImport.GetDocument()->GetCellType(rCurrentPos) == CELLTYPE_FORMULA) + ScRefCellValue aCell(*rXMLImport.GetDocument(), rCurrentPos); + if (aCell.meType == CELLTYPE_FORMULA) { - ScFormulaCell* pFCell = rXMLImport.GetDocument()->GetFormulaCell(rCurrentPos); + ScFormulaCell* pFCell = aCell.mpFormula;; SetFormulaCell(pFCell); if (pFCell) pFCell->SetNeedNumberFormat( true ); @@ -1291,8 +1294,8 @@ OUString getOutputString( ScDocument* pDoc, const ScAddress& aCellPos ) if (!pDoc) return OUString(); - CellType eType = pDoc->GetCellType(aCellPos); - switch (eType) + ScRefCellValue aCell(*pDoc, aCellPos); + switch (aCell.meType) { case CELLTYPE_NONE: return OUString(); @@ -1300,13 +1303,10 @@ OUString getOutputString( ScDocument* pDoc, const ScAddress& aCellPos ) { // GetString on EditCell replaces linebreaks with spaces; // however here we need line breaks - const EditTextObject* pData = pDoc->GetEditText(aCellPos); - if (pData) - { - EditEngine& rEngine = pDoc->GetEditEngine(); - rEngine.SetText(*pData); - return rEngine.GetText(); - } + const EditTextObject* pData = aCell.mpEditText; + EditEngine& rEngine = pDoc->GetEditEngine(); + rEngine.SetText(*pData); + return rEngine.GetText(); // also don't format EditCells per NumberFormatter } break; @@ -1315,12 +1315,11 @@ OUString getOutputString( ScDocument* pDoc, const ScAddress& aCellPos ) // like in GetString for document (column) Color* pColor; sal_uLong nNumFmt = pDoc->GetNumberFormat(aCellPos); - return ScCellFormat::GetString( - *pDoc, aCellPos, nNumFmt, &pColor, *pDoc->GetFormatTable()); + OUString aStr; + ScCellFormat::GetString(aCell, nNumFmt, aStr, &pColor, *pDoc->GetFormatTable(), pDoc); + return aStr; } } - - return OUString(); } } diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index c615155ef4e7..4e5519653f87 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -431,16 +431,18 @@ void ScAccessibleCell::FillDependends(utl::AccessibleRelationSetHelper* pRelatio void ScAccessibleCell::FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet) { - if (mpDoc && mpDoc->GetCellType(maCellAddress) == CELLTYPE_FORMULA) + if (mpDoc) { - ScFormulaCell* pCell = mpDoc->GetFormulaCell(maCellAddress); - if (!pCell) - return; - ScDetectiveRefIter aIter(pCell); - ScRange aRef; - while ( aIter.GetNextRef( aRef ) ) + ScRefCellValue aCell(*mpDoc, maCellAddress); + if (aCell.meType == CELLTYPE_FORMULA) { - AddRelation( aRef, AccessibleRelationType::CONTROLLED_BY, pRelationSet); + ScFormulaCell* pCell = aCell.mpFormula; + ScDetectiveRefIter aIter(pCell); + ScRange aRef; + while ( aIter.GetNextRef( aRef ) ) + { + AddRelation( aRef, AccessibleRelationType::CONTROLLED_BY, pRelationSet); + } } } } diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx index 0ff33178fa42..75904774d971 100644 --- a/sc/source/ui/Accessibility/AccessibleText.cxx +++ b/sc/source/ui/Accessibility/AccessibleText.cxx @@ -25,6 +25,8 @@ #include "AccessibleCell.hxx" #include "tabvwsh.hxx" #include "editutil.hxx" +#include "cellvalue.hxx" +#include "formulacell.hxx" #include "document.hxx" #include "scmod.hxx" #include "prevwsh.hxx" @@ -745,15 +747,14 @@ void ScAccessibleCellTextData::GetCellText(const ScAddress& rCellPos, OUString& if (mpViewShell) { const ScViewOptions& aOptions = mpViewShell->GetViewData().GetOptions(); - CellType aCellType; - rDoc.GetCellType(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), aCellType); - if (aCellType == CELLTYPE_FORMULA && aOptions.GetOption( VOPT_FORMULAS )) + ScRefCellValue aCell(rDoc, ScAddress(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab())); + if (aCell.meType == CELLTYPE_FORMULA && aOptions.GetOption( VOPT_FORMULAS )) { - rDoc.GetFormula( rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText); + aCell.mpFormula->GetFormula(rText); } else if (!aOptions.GetOption( VOPT_NULLVALS )) { - if ((aCellType == CELLTYPE_VALUE || aCellType == CELLTYPE_FORMULA) && rDoc.GetValue(rCellPos) == 0.0) + if ((aCell.meType == CELLTYPE_VALUE || aCell.meType == CELLTYPE_FORMULA) && aCell.getValue() == 0.0) rText.clear(); } } diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 85f65e2dc168..a5d90f40e139 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -36,6 +36,9 @@ #include <sfx2/docfile.hxx> #include "transobj.hxx" +#include "patattr.hxx" +#include "cellvalue.hxx" +#include "cellform.hxx" #include "document.hxx" #include "viewopti.hxx" #include "editutil.hxx" @@ -261,15 +264,19 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab ); ScTabEditEngine aEngine( *pPattern, pDoc->GetEditPool() ); - if (pDoc->GetCellType(aPos) == CELLTYPE_EDIT) + ScRefCellValue aCell(*pDoc, aPos); + if (aCell.meType == CELLTYPE_EDIT) { - const EditTextObject* pObj = pDoc->GetEditText(aPos); - if (pObj) - aEngine.SetText(*pObj); + const EditTextObject* pObj = aCell.mpEditText; + aEngine.SetText(*pObj); } else { - OUString aText = pDoc->GetString(nCol, nRow, nTab); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + sal_uLong nNumFmt = pPattern->GetNumberFormat(pFormatter); + OUString aText; + Color* pColor; + ScCellFormat::GetString(aCell, nNumFmt, aText, &pColor, *pFormatter, pDoc); if (!aText.isEmpty()) aEngine.SetText(aText); } diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index dd8a98d370e4..47a796414ce8 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -35,6 +35,7 @@ #include "filter.hxx" #include "asciiopt.hxx" #include "formulacell.hxx" +#include "cellform.hxx" #include "docoptio.hxx" #include "progress.hxx" #include "scitems.hxx" @@ -1601,7 +1602,7 @@ bool ScImportExport::Doc2Text( SvStream& rStrm ) if (!pDoc->GetClipParam().isMultiRange() && nStartTab == nEndTab) pDoc->ShrinkToDataArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow ); - OUString aCell; + OUString aCellStr; bool bConvertLF = (GetSystemLineEnd() != LINEEND_LF); @@ -1611,71 +1612,77 @@ bool ScImportExport::Doc2Text( SvStream& rStrm ) { for (nCol = nStartCol; nCol <= nEndCol; nCol++) { - CellType eType; - pDoc->GetCellType( nCol, nRow, nStartTab, eType ); - switch (eType) + ScAddress aPos(nCol, nRow, nStartTab); + sal_uLong nNumFmt = pDoc->GetNumberFormat(aPos); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + + ScRefCellValue aCell(*pDoc, aPos); + switch (aCell.meType) { case CELLTYPE_FORMULA: { if (bFormulas) { - pDoc->GetFormula( nCol, nRow, nStartTab, aCell ); - if( aCell.indexOf( cSep ) != -1 ) - lcl_WriteString( rStrm, aCell, cStr, cStr ); + aCell.mpFormula->GetFormula( aCellStr ); + if( aCellStr.indexOf( cSep ) != -1 ) + lcl_WriteString( rStrm, aCellStr, cStr, cStr ); else - lcl_WriteSimpleString( rStrm, aCell ); + lcl_WriteSimpleString( rStrm, aCellStr ); } else { - aCell = pDoc->GetString(nCol, nRow, nStartTab); + Color* pColor; + ScCellFormat::GetString(aCell, nNumFmt, aCellStr, &pColor, *pFormatter, pDoc); - bool bMultiLineText = ( aCell.indexOf( '\n' ) != -1 ); + bool bMultiLineText = ( aCellStr.indexOf( '\n' ) != -1 ); if( bMultiLineText ) { if( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSpace ) - aCell = aCell.replaceAll( "\n", " " ); + aCellStr = aCellStr.replaceAll( "\n", " " ); else if ( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSystem && bConvertLF ) - aCell = convertLineEnd(aCell, GetSystemLineEnd()); + aCellStr = convertLineEnd(aCellStr, GetSystemLineEnd()); } if( mExportTextOptions.mcSeparatorConvertTo && cSep ) - aCell = aCell.replaceAll( OUString(cSep), OUString(mExportTextOptions.mcSeparatorConvertTo) ); + aCellStr = aCellStr.replaceAll( OUString(cSep), OUString(mExportTextOptions.mcSeparatorConvertTo) ); - if( mExportTextOptions.mbAddQuotes && ( aCell.indexOf( cSep ) != -1 ) ) - lcl_WriteString( rStrm, aCell, cStr, cStr ); + if( mExportTextOptions.mbAddQuotes && ( aCellStr.indexOf( cSep ) != -1 ) ) + lcl_WriteString( rStrm, aCellStr, cStr, cStr ); else - lcl_WriteSimpleString( rStrm, aCell ); + lcl_WriteSimpleString( rStrm, aCellStr ); } } break; case CELLTYPE_VALUE: { - aCell = pDoc->GetString(nCol, nRow, nStartTab); - lcl_WriteSimpleString( rStrm, aCell ); + Color* pColor; + ScCellFormat::GetString(aCell, nNumFmt, aCellStr, &pColor, *pFormatter, pDoc); + lcl_WriteSimpleString( rStrm, aCellStr ); } break; case CELLTYPE_NONE: break; default: { - aCell = pDoc->GetString(nCol, nRow, nStartTab); + Color* pColor; + ScCellFormat::GetString(aCell, nNumFmt, aCellStr, &pColor, *pFormatter, pDoc); - bool bMultiLineText = ( aCell.indexOf( '\n' ) != -1 ); + bool bMultiLineText = ( aCellStr.indexOf( '\n' ) != -1 ); if( bMultiLineText ) { if( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSpace ) - aCell = aCell.replaceAll( "\n", " " ); + aCellStr = aCellStr.replaceAll( "\n", " " ); else if ( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSystem && bConvertLF ) - aCell = convertLineEnd(aCell, GetSystemLineEnd()); + aCellStr = convertLineEnd(aCellStr, GetSystemLineEnd()); } if( mExportTextOptions.mcSeparatorConvertTo && cSep ) - aCell = aCell.replaceAll( OUString(cSep), OUString(mExportTextOptions.mcSeparatorConvertTo) ); + aCellStr = aCellStr.replaceAll( OUString(cSep), OUString(mExportTextOptions.mcSeparatorConvertTo) ); - if( mExportTextOptions.mbAddQuotes && hasLineBreaksOrSeps(aCell, cSep) ) - lcl_WriteString( rStrm, aCell, cStr, cStr ); + if( mExportTextOptions.mbAddQuotes && hasLineBreaksOrSeps(aCellStr, cSep) ) + lcl_WriteString( rStrm, aCellStr, cStr, cStr ); else - lcl_WriteSimpleString( rStrm, aCell ); + lcl_WriteSimpleString( rStrm, aCellStr ); } } if( nCol < nEndCol ) diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 2e262b44abfd..a7370d5a8344 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -63,6 +63,7 @@ #include <com/sun/star/sheet/XConditionalFormats.hpp> #include "autoform.hxx" +#include "cellvalue.hxx" #include "cellmergeoption.hxx" #include "cellsuno.hxx" #include "cursuno.hxx" @@ -6483,14 +6484,16 @@ void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeExc { SolarMutexGuard aGuard; ScDocShell* pDocSh = GetDocShell(); - if ( pDocSh && pDocSh->GetDocument().GetCellType( aCellPos ) == CELLTYPE_FORMULA ) + if (pDocSh) { - ScFormulaCell* pCell = pDocSh->GetDocument().GetFormulaCell(aCellPos); - if (!pCell) - return; - pCell->SetHybridDouble( nValue ); - pCell->ResetDirty(); - pCell->SetChanged(false); + ScRefCellValue aCell(pDocSh->GetDocument(), aCellPos); + if (aCell.meType == CELLTYPE_FORMULA) + { + ScFormulaCell* pCell = aCell.mpFormula; + pCell->SetHybridDouble( nValue ); + pCell->ResetDirty(); + pCell->SetChanged(false); + } } } diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 521619b5c7a0..160c94e83a84 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2578,17 +2578,16 @@ void ScChart2DataSequence::BuildDataCache() ScAddress aAdr(nCol, nRow, nTab); aItem.maString = m_pDocument->GetString(aAdr); - switch (m_pDocument->GetCellType(aAdr)) + ScRefCellValue aCell(*m_pDocument, aAdr); + switch (aCell.meType) { case CELLTYPE_VALUE: - aItem.mfValue = m_pDocument->GetValue(aAdr); + aItem.mfValue = aCell.getValue(); aItem.mbIsValue = true; break; case CELLTYPE_FORMULA: { - ScFormulaCell* pFCell = m_pDocument->GetFormulaCell(aAdr); - if (!pFCell) - break; + ScFormulaCell* pFCell = aCell.mpFormula; sal_uInt16 nErr = pFCell->GetErrCode(); if (nErr) break; diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx index b5bdc0c05cda..053e41b3f081 100644 --- a/sc/source/ui/unoobj/textuno.cxx +++ b/sc/source/ui/unoobj/textuno.cxx @@ -42,6 +42,8 @@ #include "miscuno.hxx" #include "cellsuno.hxx" #include "hints.hxx" +#include "cellvalue.hxx" +#include "cellform.hxx" #include "patattr.hxx" #include "formulacell.hxx" #include "docfunc.hxx" @@ -982,15 +984,16 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder() pPattern->FillEditParaItems( &aDefaults ); // including alignment etc. (for reading) } - if (rDoc.GetCellType(aCellPos) == CELLTYPE_EDIT) + ScRefCellValue aCell(rDoc, aCellPos); + if (aCell.meType == CELLTYPE_EDIT) { - const EditTextObject* pObj = rDoc.GetEditText(aCellPos); - if (pObj) - pEditEngine->SetTextNewDefaults(*pObj, aDefaults); + const EditTextObject* pObj = aCell.mpEditText; + pEditEngine->SetTextNewDefaults(*pObj, aDefaults); } else { - GetCellText(aCellPos, aText); + sal_uLong nFormat = rDoc.GetNumberFormat(aCellPos); + ScCellFormat::GetInputString(aCell, nFormat, aText, *rDoc.GetFormatTable(), &rDoc); if (!aText.isEmpty()) pEditEngine->SetTextNewDefaults(aText, aDefaults); else |