summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-26 19:13:21 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-27 00:07:15 -0400
commitf051163d699c802dc51be0b9af9a9879bcee5307 (patch)
tree3c10b6dff0b6e7a477d79d61756f37a6aa03d4cb /sc
parente45f3aa3580cb4ba05a778f192c60e42db8a3500 (diff)
More of the same...
Change-Id: I829d221d6bf164cd6087d41c65e26240108aa021
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/cellform.hxx7
-rw-r--r--sc/source/core/tool/cellform.cxx103
-rw-r--r--sc/source/filter/dif/difexp.cxx94
-rw-r--r--sc/source/filter/html/htmlexp.cxx92
-rw-r--r--sc/source/filter/inc/htmlexp.hxx4
5 files changed, 196 insertions, 104 deletions
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index e6314fc32e98..e2935a0bbe11 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -28,6 +28,7 @@ class SvNumberFormatter;
class Color;
class ScDocument;
class ScAddress;
+class ScRefCellValue;
enum ScForceTextFmt {
ftDontForce, // numbers as numbers
@@ -47,6 +48,12 @@ public:
ScForceTextFmt eForceTextFmt = ftDontForce,
bool bUseStarFormat = false );
+ static void GetString(
+ ScRefCellValue& rCell, sal_uLong nFormat, rtl::OUString& rString,
+ Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
+ bool bFormula = false, ScForceTextFmt eForceTextFmt = ftDontForce,
+ bool bUseStarFormat = false );
+
static OUString GetString(
const ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat,
Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 254bb431804b..8254a96ca52c 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -24,6 +24,7 @@
#include "cellform.hxx"
#include "cell.hxx"
#include "document.hxx"
+#include "cellvalue.hxx"
#include "formula/errorcodes.hxx"
#include "sc.hrc"
@@ -143,6 +144,108 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, OUString& rS
}
}
+void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
+ Color** ppColor, SvNumberFormatter& rFormatter,
+ bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt,
+ bool bUseStarFormat )
+{
+ *ppColor = NULL;
+ if (&rFormatter==NULL)
+ {
+ rString = OUString();
+ return;
+ }
+
+ switch (rCell.meType)
+ {
+ case CELLTYPE_STRING:
+ rFormatter.GetOutputString(*rCell.mpString, nFormat, rString, ppColor, bUseStarFormat);
+ break;
+ case CELLTYPE_EDIT:
+ rFormatter.GetOutputString(rCell.getString(), nFormat, rString, ppColor );
+ break;
+ case CELLTYPE_VALUE:
+ {
+ double nValue = rCell.mfValue;
+ if (!bNullVals && nValue == 0.0)
+ rString = OUString();
+ else
+ {
+ if( eForceTextFmt == ftCheck )
+ {
+ if( nFormat && rFormatter.IsTextFormat( nFormat ) )
+ eForceTextFmt = ftForce;
+ }
+ if( eForceTextFmt == ftForce )
+ {
+ OUString aTemp;
+ rFormatter.GetOutputString( nValue, 0, aTemp, ppColor );
+ rFormatter.GetOutputString( aTemp, nFormat, rString, ppColor );
+ }
+ else
+ rFormatter.GetOutputString( nValue, nFormat, rString, ppColor, bUseStarFormat );
+ }
+ }
+ break;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = rCell.mpFormula;
+ if ( bFormula )
+ {
+ pFCell->GetFormula( rString );
+ }
+ else
+ {
+ // A macro started from the interpreter, which has
+ // access to Formular Cells, becomes a CellText, even if
+ // that triggers further interpretation, except if those
+ // cells are already being interpreted.
+ // IdleCalc generally doesn't trigger futher interpretation,
+ // as not to get Err522 (circular).
+ if ( pFCell->GetDocument()->IsInInterpreter() &&
+ (!pFCell->GetDocument()->GetMacroInterpretLevel()
+ || pFCell->IsRunning()) )
+ {
+ rString = OUString("...");
+ }
+ else
+ {
+ sal_uInt16 nErrCode = pFCell->GetErrCode();
+
+ // get the number format only after interpretation (GetErrCode):
+ if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ nFormat = pFCell->GetStandardFormat( rFormatter,
+ nFormat );
+
+ if (nErrCode != 0)
+ rString = ScGlobal::GetErrorString(nErrCode);
+ else if ( pFCell->IsEmptyDisplayedAsString() )
+ rString = OUString();
+ else if ( pFCell->IsValue() )
+ {
+ double fValue = pFCell->GetValue();
+ if ( !bNullVals && fValue == 0.0 )
+ rString = OUString();
+ else if ( pFCell->IsHybridValueCell() )
+ rString = pFCell->GetString();
+ else
+ rFormatter.GetOutputString( fValue, nFormat, rString, ppColor, bUseStarFormat );
+ }
+ else
+ {
+ OUString aCellString = pFCell->GetString();
+ rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor, bUseStarFormat );
+ }
+ }
+ }
+ }
+ break;
+ default:
+ rString = OUString();
+ break;
+ }
+}
+
OUString ScCellFormat::GetString(
const ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat, Color** ppColor,
SvNumberFormatter& rFormatter, bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt,
diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx
index 2bca320716cb..d55a02a0cc29 100644
--- a/sc/source/filter/dif/difexp.cxx
+++ b/sc/source/filter/dif/difexp.cxx
@@ -30,6 +30,7 @@
#include "progress.hxx"
#include <rtl/tencinfo.h>
#include "ftools.hxx"
+#include "cellvalue.hxx"
#include "rtl/strbuf.hxx"
FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rStream, ScDocument* pDoc,
@@ -143,7 +144,8 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
SCCOL nColCnt;
SCROW nRowCnt;
- ScBaseCell* pAkt;
+
+ ScRefCellValue aCell;
for( nRowCnt = rRange.aStart.Row() ; nRowCnt <= nEndRow ; nRowCnt++ )
{
@@ -156,20 +158,43 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
{
OSL_ASSERT(aOS.getLength() == 0);
bool bWriteStringData = false;
- pDoc->GetCell( nColCnt, nRowCnt, nTab, pAkt );
- if( pAkt )
+ aCell.assign(*pDoc, ScAddress(nColCnt, nRowCnt, nTab));
+
+ switch (aCell.meType)
{
- switch( pAkt->GetCellType() )
- {
- case CELLTYPE_NONE:
- case CELLTYPE_NOTE:
- aOS.appendAscii(pEmptyData);
- break;
- case CELLTYPE_VALUE:
+ case CELLTYPE_NONE:
+ case CELLTYPE_NOTE:
+ aOS.appendAscii(pEmptyData);
+ break;
+ case CELLTYPE_VALUE:
+ aOS.appendAscii(pNumData);
+ if( bPlain )
+ {
+ aOS.append(
+ rtl::math::doubleToUString(
+ aCell.mfValue, rtl_math_StringFormat_G, 14, '.', true));
+ }
+ else
+ {
+ pDoc->GetInputString( nColCnt, nRowCnt, nTab, aString );
+ aOS.append(aString);
+ }
+ aOS.appendAscii("\nV\n");
+ break;
+ case CELLTYPE_EDIT:
+ case CELLTYPE_STRING:
+ aString = aCell.getString();
+ bWriteStringData = true;
+ break;
+ case CELLTYPE_FORMULA:
+ if (aCell.mpFormula->GetErrCode())
+ aOS.appendAscii(pNumDataERROR);
+ else if (aCell.mpFormula->IsValue())
+ {
aOS.appendAscii(pNumData);
if( bPlain )
{
- fVal = static_cast<ScValueCell*>(pAkt)->GetValue();
+ fVal = aCell.mpFormula->GetValue();
aOS.append(
rtl::math::doubleToUString(
fVal, rtl_math_StringFormat_G, 14, '.', true));
@@ -180,49 +205,16 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
aOS.append(aString);
}
aOS.appendAscii("\nV\n");
- break;
- case CELLTYPE_EDIT:
- aString = static_cast<ScEditCell*>(pAkt)->GetString();
- bWriteStringData = true;
- break;
- case CELLTYPE_STRING:
- aString = static_cast<ScStringCell*>(pAkt)->GetString();
+ }
+ else
+ {
+ aString = aCell.mpFormula->GetString();
bWriteStringData = true;
- break;
- case CELLTYPE_FORMULA:
- if (static_cast<ScFormulaCell*>(pAkt)->GetErrCode())
- aOS.appendAscii(pNumDataERROR);
- else if( pAkt->HasValueData() )
- {
- aOS.appendAscii(pNumData);
- if( bPlain )
- {
- fVal = static_cast<ScFormulaCell*>(pAkt)->GetValue();
- aOS.append(
- rtl::math::doubleToUString(
- fVal, rtl_math_StringFormat_G, 14, '.', true));
- }
- else
- {
- pDoc->GetInputString( nColCnt, nRowCnt, nTab, aString );
- aOS.append(aString);
- }
- aOS.appendAscii("\nV\n");
- }
- else if( pAkt->HasStringData() )
- {
- aString = static_cast<ScFormulaCell*>(pAkt)->GetString();
- bWriteStringData = true;
- }
- else
- aOS.appendAscii(pNumDataERROR);
+ }
- break;
- default:;
- }
+ break;
+ default:;
}
- else
- aOS.appendAscii(pEmptyData);
if ( !bWriteStringData )
rOut.WriteUnicodeOrByteText(aOS.makeStringAndClear());
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 4dafed61357c..5853f7a6bc83 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -62,7 +62,7 @@
#include "docoptio.hxx"
#include "editutil.hxx"
#include "ftools.hxx"
-
+#include "cellvalue.hxx"
#include <editeng/flditem.hxx>
#include <editeng/borderline.hxx>
@@ -876,24 +876,19 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
}
}
- ScBaseCell* pCell = pDoc->GetCell( aPos );
+ ScRefCellValue aCell;
+ aCell.assign(*pDoc, aPos);
+
sal_uLong nFormat = pAttr->GetNumberFormat( pFormatter );
- sal_Bool bValueData;
- sal_uInt8 nScriptType;
- if ( pCell )
- {
- bValueData = pCell->HasValueData();
+ bool bValueData = aCell.hasNumeric();
+ sal_uInt8 nScriptType = 0;
+ if (!aCell.isEmpty())
nScriptType = pDoc->GetScriptType(nCol, nRow, nTab);
- }
- else
- {
- bValueData = false;
- nScriptType = 0;
- }
+
if ( nScriptType == 0 )
nScriptType = aHTMLStyle.nDefaultScriptType;
- rtl::OStringBuffer aStrTD(OOO_STRING_SVTOOLS_HTML_tabledata);
+ OStringBuffer aStrTD(OOO_STRING_SVTOOLS_HTML_tabledata);
// border of the cells
SvxBoxItem* pBorder = (SvxBoxItem*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_BORDER );
@@ -1061,24 +1056,21 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
double fVal = 0.0;
if ( bValueData )
{
- if ( pCell )
+ switch (aCell.meType)
{
- switch ( pCell->GetCellType() )
- {
- case CELLTYPE_VALUE:
- fVal = ((ScValueCell*)pCell)->GetValue();
- if ( bCalcAsShown && fVal != 0.0 )
- fVal = pDoc->RoundValueAsShown( fVal, nFormat );
- break;
- case CELLTYPE_FORMULA:
- fVal = ((ScFormulaCell*)pCell)->GetValue();
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nFormat = ScGlobal::GetStandardFormat( fVal, *pFormatter,
- nFormat, ((ScFormulaCell*)pCell)->GetFormatType() );
- break;
- default:
- OSL_FAIL( "value data with unsupported cell type" );
- }
+ case CELLTYPE_VALUE:
+ fVal = aCell.mfValue;
+ if ( bCalcAsShown && fVal != 0.0 )
+ fVal = pDoc->RoundValueAsShown( fVal, nFormat );
+ break;
+ case CELLTYPE_FORMULA:
+ fVal = aCell.mpFormula->GetValue();
+ if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ nFormat = ScGlobal::GetStandardFormat( fVal, *pFormatter,
+ nFormat, aCell.mpFormula->GetFormatType() );
+ break;
+ default:
+ OSL_FAIL( "value data with unsupported cell type" );
}
}
@@ -1140,25 +1132,24 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
TAG_ON(aStr.makeStringAndClear().getStr());
}
- rtl::OUString aStrOut;
- sal_Bool bFieldText = false;
- if ( pCell )
- { // cell content
- Color* pColor;
- switch ( pCell->GetCellType() )
- {
- case CELLTYPE_NOTE :
- // nothing
- break;
- case CELLTYPE_EDIT :
- bFieldText = WriteFieldText( (const ScEditCell*) pCell );
- if ( bFieldText )
- break;
- //! else: fallthru
- default:
- ScCellFormat::GetString( pCell, nFormat, aStrOut, &pColor, *pFormatter );
- }
+ OUString aStrOut;
+ bool bFieldText = false;
+
+ Color* pColor;
+ switch (aCell.meType)
+ {
+ case CELLTYPE_NOTE :
+ // nothing
+ break;
+ case CELLTYPE_EDIT :
+ bFieldText = WriteFieldText(aCell.mpEditText);
+ if ( bFieldText )
+ break;
+ //! else: fallthru
+ default:
+ ScCellFormat::GetString(aCell, nFormat, aStrOut, &pColor, *pFormatter);
}
+
if ( !bFieldText )
{
if ( aStrOut.isEmpty() )
@@ -1201,10 +1192,9 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
}
-sal_Bool ScHTMLExport::WriteFieldText( const ScEditCell* pCell )
+bool ScHTMLExport::WriteFieldText( const EditTextObject* pData )
{
bool bFields = false;
- const EditTextObject* pData = pCell->GetData();
// text and anchor of URL fields, Doc-Engine is a ScFieldEditEngine
EditEngine& rEngine = pDoc->GetEditEngine();
rEngine.SetText( *pData );
diff --git a/sc/source/filter/inc/htmlexp.hxx b/sc/source/filter/inc/htmlexp.hxx
index f5855fcd6618..71fc58bb099a 100644
--- a/sc/source/filter/inc/htmlexp.hxx
+++ b/sc/source/filter/inc/htmlexp.hxx
@@ -37,7 +37,7 @@ class Graphic;
class SdrObject;
class OutputDevice;
class ScDrawLayer;
-class ScEditCell;
+class EditTextObject;
namespace editeng { class SvxBorderLine; }
@@ -128,7 +128,7 @@ class ScHTMLExport : public ScExportBase
// nXOutFlags fuer XOutBitmap::WriteGraphic
// write to stream if and only if URL fields in edit cell
- sal_Bool WriteFieldText( const ScEditCell* pCell );
+ bool WriteFieldText( const EditTextObject* pData );
// kopiere ggfs. eine lokale Datei ins Internet
sal_Bool CopyLocalFileToINet( String& rFileNm,