summaryrefslogtreecommitdiff
path: root/sc/source/filter
diff options
context:
space:
mode:
authorMohammed Abdul Azeem <azeemmysore@gmail.com>2016-02-09 03:54:15 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-02-17 08:41:12 +0000
commit2c02986b76f26d6f09d5b1f9d209879bfa427ea1 (patch)
tree60cb199d609d1b8f5f36ddfdefcc25bdd1065556 /sc/source/filter
parente327587699ed9e071da68bf7b2a3eb62c34af135 (diff)
tdf#97654 - replaced UNO cell types in xlsx import with calc internal ones
All reference to CellAddress in ApiCellRangeList::getBaseAddress() is changed to ScAddress and its chain of changes has been made. Change-Id: I43d9eb8dc02c74640d9fac11a44429850f31ade1 Reviewed-on: https://gerrit.libreoffice.org/22222 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source/filter')
-rw-r--r--sc/source/filter/inc/addressconverter.hxx77
-rw-r--r--sc/source/filter/inc/formulabase.hxx4
-rw-r--r--sc/source/filter/inc/formulabuffer.hxx15
-rw-r--r--sc/source/filter/inc/formulaparser.hxx9
-rw-r--r--sc/source/filter/inc/sheetdatabuffer.hxx14
-rw-r--r--sc/source/filter/inc/worksheethelper.hxx22
-rw-r--r--sc/source/filter/oox/addressconverter.cxx74
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx10
-rw-r--r--sc/source/filter/oox/excelchartconverter.cxx2
-rw-r--r--sc/source/filter/oox/formulabase.cxx5
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx45
-rw-r--r--sc/source/filter/oox/formulaparser.cxx54
-rw-r--r--sc/source/filter/oox/pivotcachebuffer.cxx4
-rw-r--r--sc/source/filter/oox/sheetdatabuffer.cxx61
-rw-r--r--sc/source/filter/oox/sheetdatacontext.cxx19
-rw-r--r--sc/source/filter/oox/worksheetfragment.cxx2
-rw-r--r--sc/source/filter/oox/worksheethelper.cxx70
17 files changed, 455 insertions, 32 deletions
diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx
index b84f153838bd..a85ee973d819 100644
--- a/sc/source/filter/inc/addressconverter.hxx
+++ b/sc/source/filter/inc/addressconverter.hxx
@@ -72,8 +72,7 @@ public:
{ mvAddresses.push_back( rAddress ); }
/** Returns the base address of this range list (top-left cell of first range). */
- css::table::CellAddress
- getBaseAddress() const;
+ ScAddress getBaseAddress() const;
/** Converts to a sequence. */
css::uno::Sequence< css::table::CellRangeAddress >
@@ -92,6 +91,7 @@ struct BinAddress
inline explicit BinAddress() : mnCol( 0 ), mnRow( 0 ) {}
inline explicit BinAddress( sal_Int32 nCol, sal_Int32 nRow ) : mnCol( nCol ), mnRow( nRow ) {}
inline explicit BinAddress( const css::table::CellAddress& rAddr ) : mnCol( rAddr.Column ), mnRow( rAddr.Row ) {}
+ inline explicit BinAddress( const ScAddress& rAddr ) : mnCol( rAddr.Col() ), mnRow( rAddr.Row() ) {}
void read( SequenceInputStream& rStrm );
void read( BiffInputStream& rStrm, bool bCol16Bit = true, bool bRow32Bit = false );
@@ -288,6 +288,17 @@ public:
const css::table::CellAddress& rAddress,
bool bTrackOverflow );
+ /** Checks the passed cell address if it fits into the spreadsheet limits.
+
+ @param rAddress The cell address to be checked.
+ @param bTrackOverflow true = Update the internal overflow flags, if
+ the address is outside of the supported sheet limits.
+ @return true = Passed address is valid (no index overflow).
+ */
+ bool checkCellAddress(
+ const ScAddress& rAddress,
+ bool bTrackOverflow );
+
/** Converts the passed string to a single cell address, without checking
any sheet limits.
@@ -301,9 +312,25 @@ public:
const OUString& rString,
sal_Int16 nSheet );
+ /** Converts the passed string to a single cell address, without checking
+ any sheet limits.
+
+ @param orAddress (out-parameter) Returns the converted cell address.
+ @param rString Cell address string in A1 notation.
+ @param nSheet Sheet index to be inserted into orAddress.
+ @return true = Cell address could be parsed from the passed string.
+ */
+ static bool convertToCellAddressUnchecked(
+ ScAddress& orAddress,
+ const OUString& rString,
+ sal_Int16 nSheet );
+
static bool convertToCellAddressUnchecked(
css::table::CellAddress& orAddress, const char* pStr, sal_Int16 nSheet );
+ static bool convertToCellAddressUnchecked(
+ ScAddress& orAddress, const char* pStr, sal_Int16 nSheet );
+
/** Tries to convert the passed string to a single cell address.
@param orAddress (out-parameter) Returns the converted cell address.
@@ -319,10 +346,29 @@ public:
sal_Int16 nSheet,
bool bTrackOverflow );
+ /** Tries to convert the passed string to a single cell address.
+
+ @param orAddress (out-parameter) Returns the converted cell address.
+ @param rString Cell address string in A1 notation.
+ @param nSheet Sheet index to be inserted into orAddress (will be checked).
+ @param bTrackOverflow true = Update the internal overflow flags, if
+ the address is outside of the supported sheet limits.
+ @return true = Converted address is valid (no index overflow).
+ */
+ bool convertToCellAddress(
+ ScAddress& orAddress,
+ const OUString& rString,
+ sal_Int16 nSheet,
+ bool bTrackOverflow );
+
bool convertToCellAddress(
css::table::CellAddress& rAddress,
const char* pStr, sal_Int16 nSheet, bool bTrackOverflow );
+ bool convertToCellAddress(
+ ScAddress& rAddress,
+ const char* pStr, sal_Int16 nSheet, bool bTrackOverflow );
+
/** Returns a valid cell address by moving it into allowed dimensions.
@param rString Cell address string in A1 notation.
@@ -348,6 +394,18 @@ public:
const BinAddress& rBinAddress,
sal_Int16 nSheet );
+ /** Converts the passed address to a single cell address, without checking
+ any sheet limits.
+
+ @param orAddress (out-parameter) Returns the converted cell address.
+ @param rBinAddress Binary cell address struct.
+ @param nSheet Sheet index to be inserted into orAddress.
+ */
+ static void convertToCellAddressUnchecked(
+ ScAddress& orAddress,
+ const BinAddress& rBinAddress,
+ sal_Int16 nSheet );
+
/** Tries to convert the passed address to a single cell address.
@param orAddress (out-parameter) Returns the converted cell address.
@@ -363,6 +421,21 @@ public:
sal_Int16 nSheet,
bool bTrackOverflow );
+ /** Tries to convert the passed address to a single cell address.
+
+ @param orAddress (out-parameter) Returns the converted cell address.
+ @param rBinAddress Binary cell address struct.
+ @param nSheet Sheet index to be inserted into orAddress (will be checked).
+ @param bTrackOverflow true = Update the internal overflow flags, if
+ the address is outside of the supported sheet limits.
+ @return true = Converted address is valid (no index overflow).
+ */
+ bool convertToCellAddress(
+ ScAddress& orAddress,
+ const BinAddress& rBinAddress,
+ sal_Int16 nSheet,
+ bool bTrackOverflow );
+
/** Returns a valid cell address by moving it into allowed dimensions.
@param rBinAddress Binary cell address struct.
diff --git a/sc/source/filter/inc/formulabase.hxx b/sc/source/filter/inc/formulabase.hxx
index 4f83fe9ff448..1eee9bc9b845 100644
--- a/sc/source/filter/inc/formulabase.hxx
+++ b/sc/source/filter/inc/formulabase.hxx
@@ -658,6 +658,10 @@ public:
const css::table::CellAddress& rAddress,
bool bAbsolute );
+ static OUString generateAddress2dString(
+ const ScAddress& rAddress,
+ bool bAbsolute );
+
/** Generates a cell address string in A1 notation from the passed binary
cell address.
diff --git a/sc/source/filter/inc/formulabuffer.hxx b/sc/source/filter/inc/formulabuffer.hxx
index 43aa58ce65c3..e718b1587262 100644
--- a/sc/source/filter/inc/formulabuffer.hxx
+++ b/sc/source/filter/inc/formulabuffer.hxx
@@ -44,6 +44,9 @@ public:
SharedFormulaEntry(
const css::table::CellAddress& rAddress,
const OUString& rTokenStr, sal_Int32 nSharedId );
+ SharedFormulaEntry(
+ const ScAddress& rAddress,
+ const OUString& rTokenStr, sal_Int32 nSharedId );
};
/**
@@ -59,6 +62,9 @@ public:
SharedFormulaDesc(
const css::table::CellAddress& rAddr, sal_Int32 nSharedId,
const OUString& rCellValue, sal_Int32 nValueType );
+ SharedFormulaDesc(
+ const ScAddress& rAddr, sal_Int32 nSharedId,
+ const OUString& rCellValue, sal_Int32 nValueType );
};
struct TokenAddressItem
@@ -66,6 +72,7 @@ public:
OUString maTokenStr;
css::table::CellAddress maCellAddress;
TokenAddressItem( const OUString& rTokenStr, const css::table::CellAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress ) {}
+ TokenAddressItem( const OUString& rTokenStr, const ScAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress.Tab(), rCellAddress.Col(), rCellAddress.Row() ) {}
};
struct TokenRangeAddressItem
@@ -117,19 +124,27 @@ public:
explicit FormulaBuffer( const WorkbookHelper& rHelper );
void finalizeImport();
void setCellFormula( const css::table::CellAddress& rAddress, const OUString& );
+ void setCellFormula( const ScAddress& rAddress, const OUString& );
void setCellFormula(
const css::table::CellAddress& rAddress, sal_Int32 nSharedId,
const OUString& rCellValue, sal_Int32 nValueType );
+ void setCellFormula(
+ const ScAddress& rAddress, sal_Int32 nSharedId,
+ const OUString& rCellValue, sal_Int32 nValueType );
void setCellFormulaValue(
const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
+ void setCellFormulaValue(
+ const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
void setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress,
const css::table::CellAddress& rTokenAddress,
const OUString& );
void createSharedFormulaMapEntry( const css::table::CellAddress& rAddress,
sal_Int32 nSharedId, const OUString& rTokens );
+ void createSharedFormulaMapEntry( const ScAddress& rAddress,
+ sal_Int32 nSharedId, const OUString& rTokens );
/// ensure sizes of vectors matches the number of sheets
void SetSheetCount( SCTAB nSheets );
diff --git a/sc/source/filter/inc/formulaparser.hxx b/sc/source/filter/inc/formulaparser.hxx
index f2158e3c2825..8f654e323829 100644
--- a/sc/source/filter/inc/formulaparser.hxx
+++ b/sc/source/filter/inc/formulaparser.hxx
@@ -108,12 +108,21 @@ public:
const css::table::CellAddress& rBaseAddr,
const OUString& rFormulaString ) const;
+ ApiTokenSequence importFormula(
+ const ScAddress& rBaseAddr,
+ const OUString& rFormulaString ) const;
+
/** Imports and converts a BIFF12 token array from the passed stream. */
ApiTokenSequence importFormula(
const css::table::CellAddress& rBaseAddr,
FormulaType eType,
SequenceInputStream& rStrm ) const;
+ ApiTokenSequence importFormula(
+ const ScAddress& rBaseAddr,
+ FormulaType eType,
+ SequenceInputStream& rStrm ) const;
+
/** Converts the passed XML formula to an OLE link target. */
OUString importOleTargetLink( const OUString& rFormulaString );
diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx
index de9138d8af47..7a1c282de09c 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -37,8 +37,7 @@ namespace xls {
/** Stores basic data about cell values and formatting. */
struct CellModel
{
- css::table::CellAddress
- maCellAddr; /// The address of the current cell.
+ ScAddress maCellAddr; /// The address of the current cell.
sal_Int32 mnCellType; /// Data type of the cell value.
sal_Int32 mnXfId; /// XF (cell formatting) identifier.
bool mbShowPhonetic; /// True = show phonetic text.
@@ -60,6 +59,7 @@ struct CellFormulaModel
bool isValidArrayRef( const css::table::CellAddress& rCellAddr );
/** Returns true, if the passed cell address is valid for a shared formula. */
bool isValidSharedRef( const css::table::CellAddress& rCellAddr );
+ bool isValidSharedRef( const ScAddress& rCellAddr );
};
/** Stores data about table operations. */
@@ -145,6 +145,11 @@ public:
void setStandardNumFmt(
const css::table::CellAddress& rCellAddr,
sal_Int16 nStdNumFmt );
+
+ void setStandardNumFmt(
+ const ScAddress& rCellAddr,
+ sal_Int16 nStdNumFmt );
+
/** Processes the cell formatting data of the passed cell.
@param nNumFmtId If set, overrides number format of the cell XF. */
void setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtId = -1 );
@@ -157,6 +162,9 @@ public:
const css::table::CellAddress& rCellAddr,
const ApiTokenSequence& rTokens );
+ void setCellFormula(
+ const ScAddress& rCellAddr,
+ const ApiTokenSequence& rTokens );
private:
struct XfIdRowRange;
@@ -223,7 +231,9 @@ private:
explicit MergedRange( const css::table::CellRangeAddress& rRange );
explicit MergedRange( const css::table::CellAddress& rAddress, sal_Int32 nHorAlign );
+ explicit MergedRange( const ScAddress& rAddress, sal_Int32 nHorAlign );
bool tryExpand( const css::table::CellAddress& rAddress, sal_Int32 nHorAlign );
+ bool tryExpand( const ScAddress& rAddress, sal_Int32 nHorAlign );
};
typedef ::std::list< MergedRange > MergedRangeList;
diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx
index 8de19efecfb1..c6718ebf749b 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -199,6 +199,9 @@ public:
/** Returns the XCell interface for the passed cell address. */
css::uno::Reference< css::table::XCell >
getCell( const css::table::CellAddress& rAddress ) const;
+
+ css::uno::Reference< css::table::XCell >
+ getCell( const ScAddress& rAddress ) const;
/** Returns the XCellRange interface for the passed cell range address. */
css::uno::Reference< css::table::XCellRange >
getCellRange( const css::table::CellRangeAddress& rRange ) const;
@@ -275,16 +278,26 @@ public:
/** Inserts a value cell directly into the Calc sheet. */
void putValue( const css::table::CellAddress& rAddress, double fValue );
+ void putValue( const ScAddress& rAddress, double fValue );
/** Inserts a string cell directly into the Calc sheet. */
void putString( const css::table::CellAddress& rAddress, const OUString& rText );
+ void putString( const ScAddress& rAddress, const OUString& rText );
+
/** Inserts a rich-string cell directly into the Calc sheet. */
void putRichString(
const css::table::CellAddress& rAddress,
const RichString& rString, const oox::xls::Font* pFirstPortionFont );
+
+ void putRichString(
+ const ScAddress& rAddress,
+ const RichString& rString, const oox::xls::Font* pFirstPortionFont );
+
/** Inserts a formula cell directly into the Calc sheet. */
void putFormulaTokens(
const css::table::CellAddress& rAddress, const ApiTokenSequence& rTokens );
+ void putFormulaTokens(
+ const ScAddress& rAddress, const ApiTokenSequence& rTokens );
/** Initial conversion before importing the worksheet. */
void initializeWorksheetImport();
@@ -294,19 +307,28 @@ public:
void finalizeDrawingImport();
void setCellFormula( const css::table::CellAddress& rTokenAddress, const OUString& );
+ void setCellFormula( const ScAddress& rTokenAddress, const OUString& );
void setCellFormula(
const css::table::CellAddress& rAddr, sal_Int32 nSharedId,
const OUString& rCellValue, sal_Int32 nValueType );
+ void setCellFormula(
+ const ScAddress& rAddr, sal_Int32 nSharedId,
+ const OUString& rCellValue, sal_Int32 nValueType );
void setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const css::table::CellAddress& rTokenAddress, const OUString& );
void createSharedFormulaMapEntry(
const css::table::CellAddress& rAddress,
sal_Int32 nSharedId, const OUString& rTokens );
+ void createSharedFormulaMapEntry(
+ const ScAddress& rAddress,
+ sal_Int32 nSharedId, const OUString& rTokens );
void setCellFormulaValue(
const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
+ void setCellFormulaValue(
+ const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
private:
WorksheetGlobals& mrSheetGlob;
diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx
index 1ee2fed11790..a740f97e3cfe 100644
--- a/sc/source/filter/oox/addressconverter.cxx
+++ b/sc/source/filter/oox/addressconverter.cxx
@@ -68,11 +68,12 @@ const sal_Int16 BIFF8_MAXTAB = BIFF5_MAXTAB;
} // namespace
-CellAddress ApiCellRangeList::getBaseAddress() const
+
+ScAddress ApiCellRangeList::getBaseAddress() const
{
if( mvAddresses.empty() )
- return CellAddress();
- return CellAddress( mvAddresses.front().Sheet, mvAddresses.front().StartColumn, mvAddresses.front().StartRow );
+ return ScAddress(0, 0, 0);
+ return ScAddress( SCCOL( mvAddresses.front().StartColumn ), SCROW( mvAddresses.front().StartRow ), SCTAB( mvAddresses.front().Sheet ) );
}
css::uno::Sequence< CellRangeAddress > ApiCellRangeList::toSequence() const
@@ -340,6 +341,14 @@ bool AddressConverter::checkCellAddress( const CellAddress& rAddress, bool bTrac
checkRow( rAddress.Row, bTrackOverflow );
}
+bool AddressConverter::checkCellAddress( const ScAddress& rAddress, bool bTrackOverflow )
+{
+ return
+ checkTab( rAddress.Tab(), bTrackOverflow ) &&
+ checkCol( rAddress.Col(), bTrackOverflow ) &&
+ checkRow( rAddress.Row(), bTrackOverflow );
+}
+
bool AddressConverter::convertToCellAddressUnchecked( CellAddress& orAddress,
const OUString& rString, sal_Int16 nSheet )
{
@@ -354,6 +363,32 @@ bool AddressConverter::convertToCellAddressUnchecked(
return parseOoxAddress2d(orAddress.Column, orAddress.Row, pStr);
}
+bool AddressConverter::convertToCellAddressUnchecked( ScAddress& orAddress,
+ const OUString& rString, sal_Int16 nSheet )
+{
+ orAddress.SetTab(nSheet);
+ sal_Int32 nCol = 0;
+ sal_Int32 nRow = 0;
+ bool bRes = parseOoxAddress2d( nCol, nRow, rString );
+ orAddress.SetRow(nRow);
+ orAddress.SetCol(nCol);
+
+ return bRes;
+}
+
+bool AddressConverter::convertToCellAddressUnchecked(
+ ScAddress& orAddress, const char* pStr, sal_Int16 nSheet )
+{
+ orAddress.SetTab(nSheet);
+ sal_Int32 nCol = 0;
+ sal_Int32 nRow = 0;
+ bool bRes = parseOoxAddress2d(nCol, nRow, pStr);
+ orAddress.SetRow(nRow);
+ orAddress.SetCol(nCol);
+
+ return bRes;
+}
+
bool AddressConverter::convertToCellAddress( CellAddress& orAddress,
const OUString& rString, sal_Int16 nSheet, bool bTrackOverflow )
{
@@ -372,6 +407,24 @@ bool AddressConverter::convertToCellAddress(
return checkCellAddress(rAddress, bTrackOverflow);
}
+bool AddressConverter::convertToCellAddress( ScAddress& orAddress,
+ const OUString& rString, sal_Int16 nSheet, bool bTrackOverflow )
+{
+ return
+ convertToCellAddressUnchecked( orAddress, rString, nSheet ) &&
+ checkCellAddress( orAddress, bTrackOverflow );
+}
+
+bool AddressConverter::convertToCellAddress(
+ ScAddress& rAddress,
+ const char* pStr, sal_Int16 nSheet, bool bTrackOverflow )
+{
+ if (!convertToCellAddressUnchecked(rAddress, pStr, nSheet))
+ return false;
+
+ return checkCellAddress(rAddress, bTrackOverflow);
+}
+
CellAddress AddressConverter::createValidCellAddress(
const OUString& rString, sal_Int16 nSheet, bool bTrackOverflow )
{
@@ -393,6 +446,14 @@ void AddressConverter::convertToCellAddressUnchecked( CellAddress& orAddress,
orAddress.Row = rBinAddress.mnRow;
}
+void AddressConverter::convertToCellAddressUnchecked( ScAddress& orAddress,
+ const BinAddress& rBinAddress, sal_Int16 nSheet )
+{
+ orAddress.SetTab(nSheet);
+ orAddress.SetCol(rBinAddress.mnCol);
+ orAddress.SetRow(rBinAddress.mnRow);
+}
+
bool AddressConverter::convertToCellAddress( CellAddress& orAddress,
const BinAddress& rBinAddress, sal_Int16 nSheet, bool bTrackOverflow )
{
@@ -400,6 +461,13 @@ bool AddressConverter::convertToCellAddress( CellAddress& orAddress,
return checkCellAddress( orAddress, bTrackOverflow );
}
+bool AddressConverter::convertToCellAddress( ScAddress& orAddress,
+ const BinAddress& rBinAddress, sal_Int16 nSheet, bool bTrackOverflow )
+{
+ convertToCellAddressUnchecked( orAddress, rBinAddress, nSheet );
+ return checkCellAddress( orAddress, bTrackOverflow );
+}
+
CellAddress AddressConverter::createValidCellAddress(
const BinAddress& rBinAddress, sal_Int16 nSheet, bool bTrackOverflow )
{
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 4aeeaa9b15b4..1e61d32ca3a7 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -489,7 +489,7 @@ void CondFormatRule::importCfRule( const AttributeList& rAttribs )
void CondFormatRule::appendFormula( const OUString& rFormula )
{
- CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
+ ScAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
ApiTokenSequence aTokens = getFormulaParser().importFormula( aBaseAddr, rFormula );
maModel.maFormulas.push_back( aTokens );
}
@@ -520,7 +520,7 @@ void CondFormatRule::importCfRule( SequenceInputStream& rStrm )
SAL_WARN_IF( !( (nFmla1Size > 0) == (rStrm.getRemaining() >= 8) ), "sc.filter", "CondFormatRule::importCfRule - formula size mismatch" );
if( rStrm.getRemaining() >= 8 )
{
- CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
+ ScAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
ApiTokenSequence aTokens = getFormulaParser().importFormula( aBaseAddr, FORMULATYPE_CONDFORMAT, rStrm );
maModel.maFormulas.push_back( aTokens );
@@ -862,9 +862,7 @@ void CondFormatRule::finalizeImport()
eOperator = SC_COND_DIRECT;
}
- CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
- ScAddress aPos;
- ScUnoConversion::FillScAddress( aPos, aBaseAddr );
+ ScAddress aPos = mrCondFormat.getRanges().getBaseAddress();
if( eOperator == SC_COND_ERROR || eOperator == SC_COND_NOERROR )
{
@@ -1078,7 +1076,7 @@ void CondFormat::finalizeImport()
return;
ScDocument& rDoc = getScDocument();
maRules.forEachMem( &CondFormatRule::finalizeImport );
- SCTAB nTab = maModel.maRanges.getBaseAddress().Sheet;
+ SCTAB nTab = maModel.maRanges.getBaseAddress().Tab();
sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, nTab);
ScRangeList aList;
diff --git a/sc/source/filter/oox/excelchartconverter.cxx b/sc/source/filter/oox/excelchartconverter.cxx
index c316cb7be381..71a161e1b940 100644
--- a/sc/source/filter/oox/excelchartconverter.cxx
+++ b/sc/source/filter/oox/excelchartconverter.cxx
@@ -80,7 +80,7 @@ Reference< XDataSequence > ExcelChartConverter::createDataSequence(
{
// parse the formula string, create a token sequence
FormulaParser& rParser = getFormulaParser();
- CellAddress aBaseAddr( getCurrentSheetIndex(), 0, 0 );
+ ScAddress aBaseAddr( SCCOL( 0 ), SCROW( 0 ), SCTAB( getCurrentSheetIndex() ) );
ApiTokenSequence aTokens = rParser.importFormula( aBaseAddr, rDataSeq.maFormula );
try
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index bf894e1383b4..5ea3c151962e 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -1599,6 +1599,11 @@ OUString FormulaProcessorBase::generateAddress2dString( const CellAddress& rAddr
return generateAddress2dString( BinAddress( rAddress ), bAbsolute );
}
+OUString FormulaProcessorBase::generateAddress2dString( const ScAddress& rAddress, bool bAbsolute )
+{
+ return generateAddress2dString( BinAddress( rAddress ), bAbsolute );
+}
+
OUString FormulaProcessorBase::generateAddress2dString( const BinAddress& rAddress, bool bAbsolute )
{
OUStringBuffer aBuffer;
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index ba14600def57..9f957dab0fa3 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -344,11 +344,21 @@ FormulaBuffer::SharedFormulaEntry::SharedFormulaEntry(
const OUString& rTokenStr, sal_Int32 nSharedId ) :
maAddress(rAddr), maTokenStr(rTokenStr), mnSharedId(nSharedId) {}
+FormulaBuffer::SharedFormulaEntry::SharedFormulaEntry(
+ const ScAddress& rAddr,
+ const OUString& rTokenStr, sal_Int32 nSharedId ) :
+ maAddress( CellAddress( rAddr.Tab(), rAddr.Col(), rAddr.Row() ) ), maTokenStr(rTokenStr), mnSharedId(nSharedId) {}
+
FormulaBuffer::SharedFormulaDesc::SharedFormulaDesc(
const css::table::CellAddress& rAddr, sal_Int32 nSharedId,
const OUString& rCellValue, sal_Int32 nValueType ) :
maAddress(rAddr), mnSharedId(nSharedId), maCellValue(rCellValue), mnValueType(nValueType) {}
+FormulaBuffer::SharedFormulaDesc::SharedFormulaDesc(
+ const ScAddress& rAddr, sal_Int32 nSharedId,
+ const OUString& rCellValue, sal_Int32 nValueType ) :
+ maAddress( CellAddress( rAddr.Tab(), rAddr.Col(), rAddr.Row() ) ), mnSharedId(nSharedId), maCellValue(rCellValue), mnValueType(nValueType) {}
+
FormulaBuffer::SheetItem::SheetItem() :
mpCellFormulas(nullptr),
mpArrayFormulas(nullptr),
@@ -466,12 +476,28 @@ void FormulaBuffer::createSharedFormulaMapEntry(
rSharedFormulas.push_back( aEntry );
}
+void FormulaBuffer::createSharedFormulaMapEntry(
+ const ScAddress& rAddress,
+ sal_Int32 nSharedId, const OUString& rTokens )
+{
+ assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maSharedFormulas.size() );
+ std::vector<SharedFormulaEntry>& rSharedFormulas = maSharedFormulas[ rAddress.Tab() ];
+ SharedFormulaEntry aEntry(rAddress, rTokens, nSharedId);
+ rSharedFormulas.push_back( aEntry );
+}
+
void FormulaBuffer::setCellFormula( const css::table::CellAddress& rAddress, const OUString& rTokenStr )
{
assert( rAddress.Sheet >= 0 && (size_t)rAddress.Sheet < maCellFormulas.size() );
maCellFormulas[ rAddress.Sheet ].push_back( TokenAddressItem( rTokenStr, rAddress ) );
}
+void FormulaBuffer::setCellFormula( const ScAddress& rAddress, const OUString& rTokenStr )
+{
+ assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maCellFormulas.size() );
+ maCellFormulas[ rAddress.Tab() ].push_back( TokenAddressItem( rTokenStr, rAddress ) );
+}
+
void FormulaBuffer::setCellFormula(
const table::CellAddress& rAddress, sal_Int32 nSharedId, const OUString& rCellValue, sal_Int32 nValueType )
{
@@ -480,6 +506,14 @@ void FormulaBuffer::setCellFormula(
SharedFormulaDesc(rAddress, nSharedId, rCellValue, nValueType));
}
+void FormulaBuffer::setCellFormula(
+ const ScAddress& rAddress, sal_Int32 nSharedId, const OUString& rCellValue, sal_Int32 nValueType )
+{
+ assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maSharedFormulaIds.size() );
+ maSharedFormulaIds[rAddress.Tab()].push_back(
+ SharedFormulaDesc(rAddress, nSharedId, rCellValue, nValueType));
+}
+
void FormulaBuffer::setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const css::table::CellAddress& rTokenAddress, const OUString& rTokenStr )
{
@@ -499,6 +533,17 @@ void FormulaBuffer::setCellFormulaValue(
maCellFormulaValues[rAddress.Sheet].push_back(aVal);
}
+void FormulaBuffer::setCellFormulaValue(
+ const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
+{
+ assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maCellFormulaValues.size() );
+ FormulaValue aVal;
+ aVal.maCellAddress = CellAddress( rAddress.Tab(), rAddress.Col(), rAddress.Row() );
+ aVal.maValueStr = rValueStr;
+ aVal.mnCellType = nCellType;
+ maCellFormulaValues[rAddress.Tab()].push_back(aVal);
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/oox/formulaparser.cxx b/sc/source/filter/oox/formulaparser.cxx
index 8748ffee4db3..685f60979874 100644
--- a/sc/source/filter/oox/formulaparser.cxx
+++ b/sc/source/filter/oox/formulaparser.cxx
@@ -426,12 +426,21 @@ public:
const CellAddress& rBaseAddress,
const OUString& rFormulaString );
+ virtual ApiTokenSequence importOoxFormulaSc(
+ const ScAddress& rBaseAddress,
+ const OUString& rFormulaString );
+
/** Imports and converts a BIFF12 token array from the passed stream. */
virtual ApiTokenSequence importBiff12Formula(
const CellAddress& rBaseAddress,
FormulaType eType,
SequenceInputStream& rStrm );
+ virtual ApiTokenSequence importBiff12FormulaSc(
+ const ScAddress& rBaseAddress,
+ FormulaType eType,
+ SequenceInputStream& rStrm );
+
/** Tries to resolve the passed ref-id to an OLE target URL. */
OUString resolveOleTarget( sal_Int32 nRefId, bool bUseRefSheets ) const;
@@ -579,12 +588,25 @@ ApiTokenSequence FormulaParserImpl::importOoxFormula( const CellAddress&, const
return ApiTokenSequence();
}
+ApiTokenSequence FormulaParserImpl::importOoxFormulaSc( const ScAddress&, const OUString& )
+{
+ OSL_FAIL( "FormulaParserImpl::importOoxFormula - not implemented" );
+ return ApiTokenSequence();
+}
+
ApiTokenSequence FormulaParserImpl::importBiff12Formula( const CellAddress&, FormulaType, SequenceInputStream& )
{
SAL_WARN("sc", "FormulaParserImpl::importBiff12Formula - not implemented" );
return ApiTokenSequence();
}
+ApiTokenSequence FormulaParserImpl::importBiff12FormulaSc( const ScAddress&, FormulaType, SequenceInputStream& )
+{
+ SAL_WARN("sc", "FormulaParserImpl::importBiff12Formula - not implemented" );
+ return ApiTokenSequence();
+}
+
+
OUString FormulaParserImpl::resolveOleTarget( sal_Int32 nRefId, bool bUseRefSheets ) const
{
const ExternalLink* pExtLink = getExternalLinks().getExternalLink( nRefId, bUseRefSheets ).get();
@@ -1225,6 +1247,15 @@ public:
FormulaType eType,
SequenceInputStream& rStrm ) override;
+ virtual ApiTokenSequence importOoxFormulaSc(
+ const ScAddress& rBaseAddr,
+ const OUString& rFormulaString ) override;
+
+ virtual ApiTokenSequence importBiff12FormulaSc(
+ const ScAddress& rBaseAddr,
+ FormulaType eType,
+ SequenceInputStream& rStrm ) override;
+
private:
// import token contents and create API formula token ---------------------
@@ -1280,6 +1311,19 @@ ApiTokenSequence OoxFormulaParserImpl::importOoxFormula( const CellAddress& rBas
return finalizeTokenArray( maApiParser.parseFormula( rFormulaString, rBaseAddr ) );
}
+ApiTokenSequence OoxFormulaParserImpl::importOoxFormulaSc( const ScAddress& rBaseAddr, const OUString& rFormulaString )
+{
+ CellAddress aTempAddress( rBaseAddr.Tab(), rBaseAddr.Col(), rBaseAddr.Row() );
+ return importOoxFormula(aTempAddress, rFormulaString);
+}
+
+// TODO: remove the importBiff12Formula function
+ApiTokenSequence OoxFormulaParserImpl::importBiff12FormulaSc( const ScAddress& rBaseAddr, FormulaType eType, SequenceInputStream& rStrm )
+{
+ CellAddress aTempAddress( rBaseAddr.Tab(), rBaseAddr.Col(), rBaseAddr.Row() );
+ return importBiff12Formula(aTempAddress, eType, rStrm);
+}
+
ApiTokenSequence OoxFormulaParserImpl::importBiff12Formula( const CellAddress& rBaseAddr, FormulaType eType, SequenceInputStream& rStrm )
{
initializeImport( rBaseAddr, eType );
@@ -2524,6 +2568,16 @@ ApiTokenSequence FormulaParser::importFormula( const CellAddress& rBaseAddress,
return mxImpl->importBiff12Formula( rBaseAddress, eType, rStrm );
}
+ApiTokenSequence FormulaParser::importFormula( const ScAddress& rBaseAddress, const OUString& rFormulaString ) const
+{
+ return mxImpl->importOoxFormulaSc( rBaseAddress, rFormulaString );
+}
+
+ApiTokenSequence FormulaParser::importFormula( const ScAddress& rBaseAddress, FormulaType eType, SequenceInputStream& rStrm ) const
+{
+ return mxImpl->importBiff12FormulaSc( rBaseAddress, eType, rStrm );
+}
+
OUString FormulaParser::importOleTargetLink( const OUString& rFormulaString )
{
sal_Int32 nRefId = -1;
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index df9196d3d133..2a6cfd19b50f 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -953,7 +953,7 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie
void PivotCacheField::writeSourceHeaderCell( WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow ) const
{
CellModel aModel;
- aModel.maCellAddr = CellAddress( rSheetHelper.getSheetIndex(), nCol, nRow );
+ aModel.maCellAddr = ScAddress( SCCOL( nCol ), SCROW( nRow ), SCTAB( rSheetHelper.getSheetIndex() ) );
rSheetHelper.getSheetData().setStringCell( aModel, maFieldModel.maName );
}
@@ -1001,7 +1001,7 @@ void PivotCacheField::writeItemToSourceDataCell( WorksheetHelper& rSheetHelper,
if( rItem.getType() != XML_m )
{
CellModel aModel;
- aModel.maCellAddr = CellAddress( rSheetHelper.getSheetIndex(), nCol, nRow );
+ aModel.maCellAddr = ScAddress( SCCOL( nCol ), SCROW( nRow ), SCTAB( rSheetHelper.getSheetIndex() ) );
SheetDataBuffer& rSheetData = rSheetHelper.getSheetData();
switch( rItem.getType() )
{
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index f6f7fb70a200..f6765b4d5b72 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -95,6 +95,14 @@ bool CellFormulaModel::isValidSharedRef( const CellAddress& rCellAddr )
(maFormulaRef.StartRow <= rCellAddr.Row) && (rCellAddr.Row <= maFormulaRef.EndRow);
}
+bool CellFormulaModel::isValidSharedRef( const ScAddress& rCellAddr )
+{
+ return
+ (maFormulaRef.Sheet == rCellAddr.Tab() ) &&
+ (maFormulaRef.StartColumn <= rCellAddr.Col() ) && (rCellAddr.Col() <= maFormulaRef.EndColumn) &&
+ (maFormulaRef.StartRow <= rCellAddr.Row() ) && (rCellAddr.Row() <= maFormulaRef.EndRow);
+}
+
DataTableModel::DataTableModel() :
mb2dTable( false ),
mbRowTable( false ),
@@ -256,7 +264,7 @@ void SheetDataBuffer::setFormulaCell( const CellModel& rModel, const ApiTokenSeq
aTokens = resolveSharedFormula( aTokenInfo.First );
if( !aTokens.hasElements() )
{
- maSharedFmlaAddr = rModel.maCellAddr;
+ maSharedFmlaAddr = ( CellAddress( rModel.maCellAddr.Tab(), rModel.maCellAddr.Col(), rModel.maCellAddr.Row() ) ); //should change this later
maSharedBaseAddr = aTokenInfo.First;
mbPendingSharedFmla = true;
}
@@ -329,6 +337,21 @@ void SheetDataBuffer::setStandardNumFmt( const CellAddress& rCellAddr, sal_Int16
}
}
+void SheetDataBuffer::setStandardNumFmt( const ScAddress& rCellAddr, sal_Int16 nStdNumFmt )
+{
+ try
+ {
+ Reference< XNumberFormatsSupplier > xNumFmtsSupp( getDocument(), UNO_QUERY_THROW );
+ Reference< XNumberFormatTypes > xNumFmtTypes( xNumFmtsSupp->getNumberFormats(), UNO_QUERY_THROW );
+ sal_Int32 nIndex = xNumFmtTypes->getStandardFormat( nStdNumFmt, Locale() );
+ PropertySet aPropSet( getCell( rCellAddr ) );
+ aPropSet.setProperty( PROP_NumberFormat, nIndex );
+ }
+ catch( Exception& )
+ {
+ }
+}
+
typedef std::pair<sal_Int32, sal_Int32> FormatKeyPair;
void addIfNotInMyMap( StylesBuffer& rStyles, std::map< FormatKeyPair, ApiCellRangeList >& rMap, sal_Int32 nXfId, sal_Int32 nFormatId, const ApiCellRangeList& rRangeList )
@@ -544,6 +567,12 @@ SheetDataBuffer::MergedRange::MergedRange( const CellAddress& rAddress, sal_Int3
{
}
+SheetDataBuffer::MergedRange::MergedRange( const ScAddress& rAddress, sal_Int32 nHorAlign ) :
+ maRange( rAddress.Tab(), rAddress.Col(), rAddress.Row(), rAddress.Col(), rAddress.Row() ),
+ mnHorAlign( nHorAlign )
+{
+}
+
bool SheetDataBuffer::MergedRange::tryExpand( const CellAddress& rAddress, sal_Int32 nHorAlign )
{
if( (mnHorAlign == nHorAlign) && (maRange.StartRow == rAddress.Row) &&
@@ -555,6 +584,17 @@ bool SheetDataBuffer::MergedRange::tryExpand( const CellAddress& rAddress, sal_I
return false;
}
+bool SheetDataBuffer::MergedRange::tryExpand( const ScAddress& rAddress, sal_Int32 nHorAlign )
+{
+ if( (mnHorAlign == nHorAlign) && (maRange.StartRow == rAddress.Row() ) &&
+ (maRange.EndRow == rAddress.Row() ) && (maRange.EndColumn + 1 == rAddress.Col() ) )
+ {
+ ++maRange.EndColumn;
+ return true;
+ }
+ return false;
+}
+
void SheetDataBuffer::setCellFormula( const CellAddress& rCellAddr, const ApiTokenSequence& rTokens )
{
if( rTokens.hasElements() )
@@ -563,6 +603,15 @@ void SheetDataBuffer::setCellFormula( const CellAddress& rCellAddr, const ApiTok
}
}
+void SheetDataBuffer::setCellFormula( const ScAddress& rCellAddr, const ApiTokenSequence& rTokens )
+{
+ if( rTokens.hasElements() )
+ {
+ putFormulaTokens( rCellAddr, rTokens );
+ }
+}
+
+
ApiTokenSequence SheetDataBuffer::resolveSharedFormula( const CellAddress& rAddr ) const
{
BinAddress aAddr(rAddr);
@@ -664,18 +713,18 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI
* It is sufficient to check if the row range size is one
*/
if( aIt != aItEnd &&
- aIt->Sheet == rModel.maCellAddr.Sheet &&
+ aIt->Sheet == rModel.maCellAddr.Tab() &&
aIt->StartRow == aIt->EndRow &&
- aIt->StartRow == rModel.maCellAddr.Row &&
- (aIt->EndColumn+1) == rModel.maCellAddr.Column )
+ aIt->StartRow == rModel.maCellAddr.Row() &&
+ (aIt->EndColumn+1) == rModel.maCellAddr.Col() )
{
aIt->EndColumn++; // Expand Column
}
else
{
maXfIdRangeLists[ XfIdNumFmtKey (rModel.mnXfId, nNumFmtId ) ].push_back(
- CellRangeAddress( rModel.maCellAddr.Sheet, rModel.maCellAddr.Column, rModel.maCellAddr.Row,
- rModel.maCellAddr.Column, rModel.maCellAddr.Row ) );
+ CellRangeAddress( rModel.maCellAddr.Tab(), rModel.maCellAddr.Col(), rModel.maCellAddr.Row(),
+ rModel.maCellAddr.Col(), rModel.maCellAddr.Row() ) );
}
aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin();
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index 3bc5b9800e61..7cf3be026d00 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -171,8 +171,8 @@ void SheetDataContext::onEndElement()
mbHasFormula = false;
break;
case XML_array:
- if( mbValidRange && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) )
- setCellArrayFormula( maFmlaData.maFormulaRef, maCellData.maCellAddr, maFormulaStr );
+ if( mbValidRange && maFmlaData.isValidArrayRef( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) ) )
+ setCellArrayFormula( maFmlaData.maFormulaRef, CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ), maFormulaStr );
// set cell formatting, but do not set result as cell value
mrSheetData.setBlankCell( maCellData );
break;
@@ -320,12 +320,12 @@ bool SheetDataContext::importCell( const AttributeList& rAttribs )
if (!p)
{
++mnCol;
- maCellData.maCellAddr = CellAddress( mnSheet, mnCol, mnRow );
+ maCellData.maCellAddr = ScAddress( mnCol, mnRow, mnSheet );
}
else
{
bValid = mrAddressConv.convertToCellAddress(maCellData.maCellAddr, p, mnSheet, true);
- mnCol = maCellData.maCellAddr.Column;
+ mnCol = maCellData.maCellAddr.Col();
}
if( bValid )
@@ -340,7 +340,8 @@ bool SheetDataContext::importCell( const AttributeList& rAttribs )
mbHasFormula = false;
// update used area of the sheet
- extendUsedArea( maCellData.maCellAddr );
+ CellAddress addrTemp = CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() );
+ extendUsedArea( addrTemp );
}
return bValid;
}
@@ -424,7 +425,7 @@ bool SheetDataContext::readCellHeader( SequenceInputStream& rStrm, CellType eCel
// update used area of the sheet
if( bValidAddr )
- extendUsedArea( maCellData.maCellAddr );
+ extendUsedArea( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) );
return bValidAddr;
}
@@ -538,7 +539,7 @@ void SheetDataContext::importCellString( SequenceInputStream& rStrm, CellType eC
void SheetDataContext::importArray( SequenceInputStream& rStrm )
{
- if( readFormulaRef( rStrm ) && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) )
+ if( readFormulaRef( rStrm ) && maFmlaData.isValidArrayRef( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) ) )
{
rStrm.skip( 1 );
ApiTokenSequence aTokens = mxFormulaParser->importFormula( maCellData.maCellAddr, FORMULATYPE_ARRAY, rStrm );
@@ -566,10 +567,10 @@ void SheetDataContext::importDataTable( SequenceInputStream& rStrm )
void SheetDataContext::importSharedFmla( SequenceInputStream& rStrm )
{
- if( readFormulaRef( rStrm ) && maFmlaData.isValidSharedRef( maCellData.maCellAddr ) )
+ if( readFormulaRef( rStrm ) && maFmlaData.isValidSharedRef( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) ) )
{
ApiTokenSequence aTokens = mxFormulaParser->importFormula( maCellData.maCellAddr, FORMULATYPE_SHAREDFORMULA, rStrm );
- mrSheetData.createSharedFormula( maCellData.maCellAddr, aTokens );
+ mrSheetData.createSharedFormula( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ), aTokens );
}
}
diff --git a/sc/source/filter/oox/worksheetfragment.cxx b/sc/source/filter/oox/worksheetfragment.cxx
index 81ef2cfa1231..dd6597f4ab16 100644
--- a/sc/source/filter/oox/worksheetfragment.cxx
+++ b/sc/source/filter/oox/worksheetfragment.cxx
@@ -179,7 +179,7 @@ void DataValidationsContext::importDataValidation( SequenceInputStream& rStrm )
// condition formula(s)
FormulaParser& rParser = getFormulaParser();
- CellAddress aBaseAddr = aModel.maRanges.getBaseAddress();
+ ScAddress aBaseAddr = aModel.maRanges.getBaseAddress();
aModel.maTokens1 = rParser.importFormula( aBaseAddr, FORMULATYPE_VALIDATION, rStrm );
aModel.maTokens2 = rParser.importFormula( aBaseAddr, FORMULATYPE_VALIDATION, rStrm );
// process string list of a list validation (convert to list of string tokens)
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 2c2dba1d0faf..7b86d8573e16 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -225,6 +225,7 @@ public:
/** Returns the XCell interface for the passed cell address. */
Reference< XCell > getCell( const CellAddress& rAddress ) const;
+ Reference< XCell > getCell( const ScAddress& rAddress ) const;
/** Returns the XCellRange interface for the passed cell range address. */
Reference< XCellRange > getCellRange( const CellRangeAddress& rRange ) const;
/** Returns the XSheetCellRanges interface for the passed cell range addresses. */
@@ -480,6 +481,19 @@ Reference< XCell > WorksheetGlobals::getCell( const CellAddress& rAddress ) cons
return xCell;
}
+Reference< XCell > WorksheetGlobals::getCell( const ScAddress& rAddress ) const
+{
+ Reference< XCell > xCell;
+ if( mxSheet.is() ) try
+ {
+ xCell = mxSheet->getCellByPosition( rAddress.Col(), rAddress.Row() );
+ }
+ catch( Exception& )
+ {
+ }
+ return xCell;
+}
+
Reference< XCellRange > WorksheetGlobals::getCellRange( const CellRangeAddress& rRange ) const
{
Reference< XCellRange > xRange;
@@ -1429,6 +1443,11 @@ Reference< XCell > WorksheetHelper::getCell( const CellAddress& rAddress ) const
return mrSheetGlob.getCell( rAddress );
}
+Reference< XCell > WorksheetHelper::getCell( const ScAddress& rAddress ) const
+{
+ return mrSheetGlob.getCell( rAddress );
+}
+
Reference< XCellRange > WorksheetHelper::getCellRange( const CellRangeAddress& rRange ) const
{
return mrSheetGlob.getCellRange( rRange );
@@ -1576,12 +1595,23 @@ void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue )
getDocImport().setNumericCell(aAddress, fValue);
}
+void WorksheetHelper::putValue( const ScAddress& rAddress, double fValue )
+{
+ getDocImport().setNumericCell(rAddress, fValue);
+}
+
void WorksheetHelper::setCellFormulaValue(
const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
{
getFormulaBuffer().setCellFormulaValue(rAddress, rValueStr, nCellType);
}
+void WorksheetHelper::setCellFormulaValue(
+ const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
+{
+ getFormulaBuffer().setCellFormulaValue(rAddress, rValueStr, nCellType);
+}
+
void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText )
{
ScAddress aAddress;
@@ -1590,6 +1620,12 @@ void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rT
getDocImport().setStringCell(aAddress, rText);
}
+void WorksheetHelper::putString( const ScAddress& rAddress, const OUString& rText )
+{
+ if ( !rText.isEmpty() )
+ getDocImport().setStringCell(rAddress, rText);
+}
+
void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichString& rString, const oox::xls::Font* pFirstPortionFont )
{
ScEditEngineDefaulter& rEE = getEditEngine();
@@ -1600,6 +1636,14 @@ void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichStri
getDocImport().setEditCell(aAddress, rString.convert(rEE, pFirstPortionFont));
}
+void WorksheetHelper::putRichString( const ScAddress& rAddress, const RichString& rString, const oox::xls::Font* pFirstPortionFont )
+{
+ ScEditEngineDefaulter& rEE = getEditEngine();
+
+ // The cell will own the text object instance returned from convert().
+ getDocImport().setEditCell(rAddress, rString.convert(rEE, pFirstPortionFont));
+}
+
void WorksheetHelper::putFormulaTokens( const CellAddress& rAddress, const ApiTokenSequence& rTokens )
{
ScDocumentImport& rDoc = getDocImport();
@@ -1610,6 +1654,14 @@ void WorksheetHelper::putFormulaTokens( const CellAddress& rAddress, const ApiTo
rDoc.setFormulaCell(aCellPos, new ScTokenArray(aTokenArray));
}
+void WorksheetHelper::putFormulaTokens( const ScAddress& rAddress, const ApiTokenSequence& rTokens )
+{
+ ScDocumentImport& rDoc = getDocImport();
+ ScTokenArray aTokenArray;
+ ScTokenConversion::ConvertToTokenArray(rDoc.getDoc(), aTokenArray, rTokens);
+ rDoc.setFormulaCell(rAddress, new ScTokenArray(aTokenArray));
+}
+
void WorksheetHelper::initializeWorksheetImport()
{
mrSheetGlob.initializeWorksheetImport();
@@ -1630,6 +1682,11 @@ void WorksheetHelper::setCellFormula( const css::table::CellAddress& rTokenAddre
getFormulaBuffer().setCellFormula( rTokenAddress, rTokenStr );
}
+void WorksheetHelper::setCellFormula( const ScAddress& rTokenAddress, const OUString& rTokenStr )
+{
+ getFormulaBuffer().setCellFormula( rTokenAddress, rTokenStr );
+}
+
void WorksheetHelper::setCellFormula(
const css::table::CellAddress& rAddr, sal_Int32 nSharedId,
const OUString& rCellValue, sal_Int32 nValueType )
@@ -1637,6 +1694,13 @@ void WorksheetHelper::setCellFormula(
getFormulaBuffer().setCellFormula(rAddr, nSharedId, rCellValue, nValueType);
}
+void WorksheetHelper::setCellFormula(
+ const ScAddress& rAddr, sal_Int32 nSharedId,
+ const OUString& rCellValue, sal_Int32 nValueType )
+{
+ getFormulaBuffer().setCellFormula(rAddr, nSharedId, rCellValue, nValueType);
+}
+
void WorksheetHelper::setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const css::table::CellAddress& rTokenAddress, const OUString& rTokenStr )
{
getFormulaBuffer().setCellArrayFormula( rRangeAddress, rTokenAddress, rTokenStr );
@@ -1648,6 +1712,12 @@ void WorksheetHelper::createSharedFormulaMapEntry(
getFormulaBuffer().createSharedFormulaMapEntry(rAddress, nSharedId, rTokens);
}
+void WorksheetHelper::createSharedFormulaMapEntry(
+ const ScAddress& rAddress, sal_Int32 nSharedId, const OUString& rTokens )
+{
+ getFormulaBuffer().createSharedFormulaMapEntry(rAddress, nSharedId, rTokens);
+}
+
} // namespace xls
} // namespace oox