[Libreoffice-commits] .: 8 commits - sc/qa sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Wed Jun 20 02:03:23 PDT 2012
sc/qa/unit/data/ods/formats.ods |binary
sc/qa/unit/subsequent_filters-test.cxx | 23 +
sc/source/filter/xml/XMLDetectiveContext.cxx | 2
sc/source/filter/xml/xmlcelli.cxx | 362 +++++++++++----------------
sc/source/filter/xml/xmlcelli.hxx | 8
sc/source/filter/xml/xmlcoli.cxx | 1
sc/source/filter/xml/xmlsubti.cxx | 296 ++--------------------
sc/source/filter/xml/xmlsubti.hxx | 62 ----
sc/source/filter/xml/xmltabi.cxx | 113 +++-----
sc/source/filter/xml/xmltabi.hxx | 4
10 files changed, 271 insertions(+), 600 deletions(-)
New commits:
commit 7f3c614d2b7b63937bfedb465c86596997f358a6
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Tue Jun 19 16:42:54 2012 -0500
Clean up logic a bit for formula cell ODS import
Made Markus's recommended changes for logic clean up.
Change-Id: I8d2820558d1d68888414e19aa8d4e9034258c57e
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 328b8dd..1457033 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1012,6 +1012,11 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
pDoc->IncXMLImportedFormulaCount( aText.getLength() );
pNewCell = new ScFormulaCell( pDoc, rCellPos, pCode, eGrammar, MM_NONE );
delete pCode;
+
+ if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
+ static_cast<ScFormulaCell*>(pNewCell)->SetHybridString( *pOUTextValue );
+ else
+ static_cast<ScFormulaCell*>(pNewCell)->SetHybridDouble( fValue );
}
else if ( aText[0] == '\'' && aText.getLength() > 1 )
{
@@ -1025,26 +1030,14 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
double fVal;
if ( pFormatter->IsNumberFormat( aText, nEnglish, fVal ) )
- {
pNewCell = new ScValueCell( fVal );
- }
+ //the (english) number format will not be set
+ //search matching local format and apply it
else
pNewCell = ScBaseCell::CreateTextCell( aText, pDoc );
- // das (englische) Zahlformat wird nicht gesetzt
- //! passendes lokales Format suchen und setzen???
}
- if( pNewCell )
- pDoc->PutCell( rCellPos, pNewCell );
-
- ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( rCellPos );
- if( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
- {
- if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
- static_cast<ScFormulaCell*>(pCell)->SetHybridString( *pOUTextValue );
- else
- static_cast<ScFormulaCell*>(pCell)->SetHybridDouble( fValue );
- }
+ pDoc->PutCell( rCellPos, pNewCell );
}
}
commit 2636b44b1d7148ebcbf678c3e01f06875164ac02
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Mon Jun 18 16:04:36 2012 -0500
Use better variable and method names for ScMyTables current cell position
Change-Id: Icdefd17751b61e9c27e3ab4468691bba08e245c0
diff --git a/sc/source/filter/xml/XMLDetectiveContext.cxx b/sc/source/filter/xml/XMLDetectiveContext.cxx
index e669dae..fbe2143 100644
--- a/sc/source/filter/xml/XMLDetectiveContext.cxx
+++ b/sc/source/filter/xml/XMLDetectiveContext.cxx
@@ -241,7 +241,7 @@ ScXMLDetectiveOperationContext::ScXMLDetectiveOperationContext(
break;
}
}
- aDetectiveOp.aPosition = rImport.GetTables().GetRealScCellPos();
+ aDetectiveOp.aPosition = rImport.GetTables().GetCurrentCellPos();
}
ScXMLDetectiveOperationContext::~ScXMLDetectiveOperationContext()
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 6d03fad..328b8dd 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -299,7 +299,7 @@ bool cellExists( const ScAddress& rCellPos )
void ScXMLTableRowCellContext::SetCursorOnTextImport(const rtl::OUString& rOUTempText)
{
- ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+ ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
if (cellExists(aCellPos))
{
sal_Int32 nCol = static_cast<sal_Int32>( aCellPos.Col() );
@@ -349,7 +349,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
bIsEmpty = false;
bTextP = true;
- ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+ ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
if( ((nCellType == util::NumberFormat::TEXT) || bFormulaTextResult) &&
!rXMLImport.GetTables().IsPartOfMatrix(aCellPos.Col(), aCellPos.Row()) )
@@ -427,7 +427,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
if (!pContext && !bTextP)
{
- ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+ ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
if (xShapes.is())
{
@@ -1098,7 +1098,7 @@ void ScXMLTableRowCellContext::EndElement()
}
}
- ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+ ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
if( bIsMerged )
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index feb8435..662f278 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -74,7 +74,7 @@ ScXMLTabProtectionData::ScXMLTabProtectionData() :
ScMyTables::ScMyTables(ScXMLImport& rTempImport)
: rImport(rTempImport),
aFixupOLEs(rTempImport),
- maCellPos(ScAddress::INITIALIZE_INVALID),
+ maCurrentCellPos(ScAddress::INITIALIZE_INVALID),
nCurrentColStylePos(0),
nCurrentDrawPage( -1 ),
nCurrentXShapes( -1 )
@@ -116,22 +116,22 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
nCurrentColStylePos = 0;
sCurrentSheetName = sTableName;
//reset cols and rows for new sheet, but increment tab
- maCellPos.SetCol(-1);
- maCellPos.SetRow(-1);
- maCellPos.SetTab(maCellPos.Tab() + 1);
+ maCurrentCellPos.SetCol(-1);
+ maCurrentCellPos.SetRow(-1);
+ maCurrentCellPos.SetTab(maCurrentCellPos.Tab() + 1);
maProtectionData = rProtectData;
ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel());
// The document contains one sheet when created. So for the first
// sheet, we only need to set its name.
- if (maCellPos.Tab() > 0)
+ if (maCurrentCellPos.Tab() > 0)
pDoc->AppendTabOnLoad(sTableName);
else
- pDoc->SetTabNameOnLoad(maCellPos.Tab(), sTableName);
+ pDoc->SetTabNameOnLoad(maCurrentCellPos.Tab(), sTableName);
rImport.SetTableStyle(sStyleName);
- xCurrentSheet = getCurrentSheet(rImport.GetModel(), maCellPos.Tab());
+ xCurrentSheet = getCurrentSheet(rImport.GetModel(), maCurrentCellPos.Tab());
if (xCurrentSheet.is())
{
// We need to set the current cell range here regardless of
@@ -172,7 +172,7 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
pStyle->FillPropertySet(xProperties);
ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData();
- pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, maCellPos.Tab() ) );
+ pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, maCurrentCellPos.Tab() ) );
}
}
}
@@ -182,8 +182,8 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
void ScMyTables::AddRow()
{
- maCellPos.SetRow(maCellPos.Row() + 1);
- maCellPos.SetCol(-1); //reset columns for new row
+ maCurrentCellPos.SetRow(maCurrentCellPos.Row() + 1);
+ maCurrentCellPos.SetCol(-1); //reset columns for new row
}
void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName)
@@ -193,11 +193,11 @@ void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName)
void ScMyTables::AddColumn(bool bIsCovered)
{
- maCellPos.SetCol( maCellPos.Col() + 1 );
+ maCurrentCellPos.SetCol( maCurrentCellPos.Col() + 1 );
//here only need to set column style if this is the first row and
//the cell is not covered.
- if(maCellPos.Row() == 0 && !bIsCovered)
- rImport.GetStylesImportHelper()->InsertCol(maCellPos.Col(), maCellPos.Tab(), rImport.GetDocument());
+ if(maCurrentCellPos.Row() == 0 && !bIsCovered)
+ rImport.GetStylesImportHelper()->InsertCol(maCurrentCellPos.Col(), maCurrentCellPos.Tab(), rImport.GetDocument());
}
void ScMyTables::UpdateRowHeights()
@@ -274,7 +274,7 @@ void ScMyTables::DeleteTable()
pProtect->setPasswordHash(aHash, maProtectionData.meHash1, maProtectionData.meHash2);
pProtect->setOption(ScTableProtection::SELECT_LOCKED_CELLS, maProtectionData.mbSelectProtectedCells);
pProtect->setOption(ScTableProtection::SELECT_UNLOCKED_CELLS, maProtectionData.mbSelectUnprotectedCells);
- rImport.GetDocument()->SetTabProtection(maCellPos.Tab(), pProtect.get());
+ rImport.GetDocument()->SetTabProtection(maCurrentCellPos.Tab(), pProtect.get());
}
}
@@ -286,24 +286,24 @@ void ScMyTables::AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCell
uno::Reference< drawing::XDrawPage > ScMyTables::GetCurrentXDrawPage()
{
- if( (maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is() )
+ if( (maCurrentCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is() )
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier( xCurrentSheet, uno::UNO_QUERY );
if( xDrawPageSupplier.is() )
xDrawPage.set(xDrawPageSupplier->getDrawPage());
- nCurrentDrawPage = sal::static_int_cast<sal_Int16>(maCellPos.Tab());
+ nCurrentDrawPage = sal::static_int_cast<sal_Int16>(maCurrentCellPos.Tab());
}
return xDrawPage;
}
uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes()
{
- if( (maCellPos.Tab() != nCurrentXShapes) || !xShapes.is() )
+ if( (maCurrentCellPos.Tab() != nCurrentXShapes) || !xShapes.is() )
{
xShapes.set(GetCurrentXDrawPage(), uno::UNO_QUERY);
rImport.GetShapeImport()->startPage(xShapes);
rImport.GetShapeImport()->pushGroupForSorting ( xShapes );
- nCurrentXShapes = sal::static_int_cast<sal_Int16>(maCellPos.Tab());
+ nCurrentXShapes = sal::static_int_cast<sal_Int16>(maCurrentCellPos.Tab());
return xShapes;
}
else
@@ -312,12 +312,12 @@ uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes()
bool ScMyTables::HasDrawPage()
{
- return !((maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is());
+ return !((maCurrentCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is());
}
bool ScMyTables::HasXShapes()
{
- return !((maCellPos.Tab() != nCurrentXShapes) || !xShapes.is());
+ return !((maCurrentCellPos.Tab() != nCurrentXShapes) || !xShapes.is());
}
void ScMyTables::AddOLE(uno::Reference <drawing::XShape>& rShape,
@@ -333,8 +333,8 @@ void ScMyTables::AddMatrixRange(
OSL_ENSURE(nEndRow >= nStartRow, "wrong row order");
OSL_ENSURE(nEndColumn >= nStartColumn, "wrong column order");
ScRange aScRange(
- nStartColumn, nStartRow, maCellPos.Tab(),
- nEndColumn, nEndRow, maCellPos.Tab()
+ nStartColumn, nStartRow, maCurrentCellPos.Tab(),
+ nEndColumn, nEndRow, maCurrentCellPos.Tab()
);
ScMatrixRange aMRange(aScRange, rFormula, rFormulaNmsp, eGrammar);
aMatrixRangeList.push_back(aMRange);
@@ -350,7 +350,7 @@ bool ScMyTables::IsPartOfMatrix(const SCCOL nColumn, const SCROW nRow)
bool bReady(false);
while(!bReady && aItr != aEndItr)
{
- if (maCellPos.Tab() > aItr->aScRange.aStart.Tab())
+ if (maCurrentCellPos.Tab() > aItr->aScRange.aStart.Tab())
{
OSL_FAIL("should never hapen, because the list should be cleared in DeleteTable");
aItr = aMatrixRangeList.erase(aItr);
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index 7b69d5b..971cb69 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -88,7 +88,7 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage;
::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShapes > xShapes;
rtl::OUString sCurrentSheetName;
- ScAddress maCellPos;
+ ScAddress maCurrentCellPos;
ScXMLTabProtectionData maProtectionData;
ScMyMatrixRangeList aMatrixRangeList;
sal_Int32 nCurrentColStylePos;
@@ -112,13 +112,13 @@ public:
bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const
{ return ScMyOLEFixer::IsOLE(rShape); }
void DeleteTable();
- ScAddress GetRealScCellPos() const { return maCellPos; };
+ ScAddress GetCurrentCellPos() const { return maCurrentCellPos; };
void AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName);
ScXMLTabProtectionData& GetCurrentProtectionData() { return maProtectionData; }
rtl::OUString GetCurrentSheetName() const { return sCurrentSheetName; }
- SCTAB GetCurrentSheet() const { return (maCellPos.Tab() >= 0) ? maCellPos.Tab() : 0; }
- SCCOL GetCurrentColumn() const { return (maCellPos.Col() >= 0) ? maCellPos.Col() : 0; }
- SCROW GetCurrentRow() const { return (maCellPos.Row() >= 0) ? maCellPos.Row() : 0; }
+ SCTAB GetCurrentSheet() const { return (maCurrentCellPos.Tab() >= 0) ? maCurrentCellPos.Tab() : 0; }
+ SCCOL GetCurrentColumn() const { return (maCurrentCellPos.Col() >= 0) ? maCurrentCellPos.Col() : 0; }
+ SCROW GetCurrentRow() const { return (maCurrentCellPos.Row() >= 0) ? maCurrentCellPos.Row() : 0; }
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >
GetCurrentXSheet() const { return xCurrentSheet; }
::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
commit f012dba24249f1a500613de0fabf4f847534da5c
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Mon Jun 18 15:50:38 2012 -0500
Simplify table ODS import logic to improve performance
- Removed subtable import logic since sc core doesn't support it.
- Simplified the overall table import logic.
Should have an overall table import performance increase.
Change-Id: I79d27470321bf17f7ef16becd7cb6aa840491f80
diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx
index 9be1a19..624fa1d 100644
--- a/sc/source/filter/xml/xmlcoli.cxx
+++ b/sc/source/filter/xml/xmlcoli.cxx
@@ -167,7 +167,6 @@ void ScXMLTableColContext::EndElement()
if ( sCellStyleName.isEmpty() )
sCellStyleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Default" ));
- GetScImport().GetTables().AddColCount(nColCount);
GetScImport().GetTables().AddColStyle(nColCount, sCellStyleName);
}
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 9eb1d10..feb8435 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -59,88 +59,8 @@
#include <memory>
using ::std::auto_ptr;
-
-//------------------------------------------------------------------
-
using namespace com::sun::star;
-ScMyTableData::ScMyTableData(SCTAB nSheet, SCCOL nCol, SCROW nRow)
- : maTableCellPos(nCol, nRow, nSheet),
- nColsPerCol(nDefaultColCount, 1),
- nRealCols(nDefaultColCount + 1, 0),
- nRowsPerRow(nDefaultRowCount, 1),
- nRealRows(nDefaultRowCount + 1, 0),
- nChangedCols()
-{
- for (sal_Int32 i = 0; i < 3; ++i)
- nRealCols[i] = i;
- for (sal_Int32 j = 0; j < 3; ++j)
- nRealRows[j] = j;
-
- nSpannedCols = 1;
- nColCount = 0;
- nSubTableSpanned = 1;
-}
-
-ScMyTableData::~ScMyTableData()
-{
-}
-
-void ScMyTableData::AddRow()
-{
- maTableCellPos.SetRow( maTableCellPos.Row() + 1 );
- if (static_cast<sal_uInt32>(maTableCellPos.Row()) >= nRowsPerRow.size())
- {
- nRowsPerRow.resize(nRowsPerRow.size() + nDefaultRowCount, 1);
- nRealRows.resize(nRowsPerRow.size() + nDefaultRowCount + 1, 0);
- }
- nRealRows[maTableCellPos.Row() + 1] = nRealRows[maTableCellPos.Row()] + nRowsPerRow[maTableCellPos.Row()];
-}
-
-void ScMyTableData::AddColumn()
-{
- maTableCellPos.SetCol( maTableCellPos.Col() + 1 );
- if (static_cast<sal_uInt32>(maTableCellPos.Col()) >= nColsPerCol.size())
- {
- nColsPerCol.resize(nColsPerCol.size() + nDefaultColCount, 1);
- nRealCols.resize(nColsPerCol.size() + nDefaultColCount + 1, 0);
- }
- nRealCols[maTableCellPos.Col() + 1] = nRealCols[maTableCellPos.Col()] + nColsPerCol[maTableCellPos.Col()];
-}
-
-sal_Int32 ScMyTableData::GetRealCols(const sal_Int32 nIndex, const bool /* bIsNormal */) const
-{
- return (nIndex < 0) ? 0 : nRealCols[nIndex];
-}
-
-sal_Int32 ScMyTableData::GetChangedCols(const sal_Int32 nFromIndex, const sal_Int32 nToIndex) const
-{
- ScMysalIntList::const_iterator i(nChangedCols.begin());
- ScMysalIntList::const_iterator endi(nChangedCols.end());
- while ((i != endi) && ((*i < nToIndex) && !(*i >= nFromIndex)))
- ++i;
- if (i == endi)
- return -1;
- else
- if ((*i >= nFromIndex) && (*i < nToIndex))
- return *i;
- else
- return -1;
-}
-
-void ScMyTableData::SetChangedCols(const sal_Int32 nValue)
-{
- ScMysalIntList::iterator i(nChangedCols.begin());
- ScMysalIntList::iterator endi(nChangedCols.end());
- while ((i != endi) && (*i < nValue))
- {
- ++i;
- }
- if ((i == endi) || (*i != nValue))
- nChangedCols.insert(i, nValue);
-}
-
-/*******************************************************************************************************************************/
ScXMLTabProtectionData::ScXMLTabProtectionData() :
meHash1(PASSHASH_SHA1),
@@ -154,11 +74,10 @@ ScXMLTabProtectionData::ScXMLTabProtectionData() :
ScMyTables::ScMyTables(ScXMLImport& rTempImport)
: rImport(rTempImport),
aFixupOLEs(rTempImport),
+ maCellPos(ScAddress::INITIALIZE_INVALID),
nCurrentColStylePos(0),
nCurrentDrawPage( -1 ),
- nCurrentXShapes( -1 ),
- nCurrentSheet( -1 ),
- pCurrentTab(NULL)
+ nCurrentXShapes( -1 )
{
}
@@ -196,22 +115,23 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
{
nCurrentColStylePos = 0;
sCurrentSheetName = sTableName;
- maTables.clear();
- pCurrentTab = NULL;
- ++nCurrentSheet;
+ //reset cols and rows for new sheet, but increment tab
+ maCellPos.SetCol(-1);
+ maCellPos.SetRow(-1);
+ maCellPos.SetTab(maCellPos.Tab() + 1);
maProtectionData = rProtectData;
ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel());
// The document contains one sheet when created. So for the first
// sheet, we only need to set its name.
- if (nCurrentSheet > 0)
+ if (maCellPos.Tab() > 0)
pDoc->AppendTabOnLoad(sTableName);
else
- pDoc->SetTabNameOnLoad(nCurrentSheet, sTableName);
+ pDoc->SetTabNameOnLoad(maCellPos.Tab(), sTableName);
rImport.SetTableStyle(sStyleName);
- xCurrentSheet = getCurrentSheet(rImport.GetModel(), nCurrentSheet);
+ xCurrentSheet = getCurrentSheet(rImport.GetModel(), maCellPos.Tab());
if (xCurrentSheet.is())
{
// We need to set the current cell range here regardless of
@@ -220,10 +140,6 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
SetTableStyle(sStyleName);
}
}
-
- maTables.push_back(new ScMyTableData(nCurrentSheet));
- pCurrentTab = & maTables.back();
- pCurrentTab->SetSpannedCols(1);
}
void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
@@ -256,7 +172,7 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
pStyle->FillPropertySet(xProperties);
ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData();
- pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, nCurrentSheet ) );
+ pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, maCellPos.Tab() ) );
}
}
}
@@ -264,42 +180,10 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
}
}
-void ScMyTables::NewRow()
-{
- size_t n = maTables.size();
- if (n <= 1)
- return;
-
- if (pCurrentTab->GetRealRows(pCurrentTab->GetRow()) >
- maTables[n-2].GetRowsPerRow(maTables[n-2].GetRow()) - 1)
- {
- if (GetRealScCellPos().Col() > 0)
- rImport.GetStylesImportHelper()->InsertRow(GetRealScCellPos().Row(), nCurrentSheet, rImport.GetDocument());
-
- for (size_t i = n - 1; i > 0; --i)
- {
- sal_Int32 nRow = maTables[i-1].GetRow();
- maTables[i-1].SetRowsPerRow(
- nRow,
- maTables[i-1].GetRowsPerRow(nRow) + 1);
-
- maTables[i-1].SetRealRows(
- nRow + 1,
- maTables[i-1].GetRealRows(nRow) + maTables[i-1].GetRowsPerRow(nRow));
- }
- }
-}
-
void ScMyTables::AddRow()
{
- pCurrentTab->AddRow();
- pCurrentTab->SetFirstColumn();
- sal_Int32 nRow = pCurrentTab->GetRow();
- if (nRow > 0)
- NewRow();
-
- pCurrentTab->SetRealRows(
- nRow + 1, pCurrentTab->GetRealRows(nRow) + pCurrentTab->GetRowsPerRow(nRow));
+ maCellPos.SetRow(maCellPos.Row() + 1);
+ maCellPos.SetCol(-1); //reset columns for new row
}
void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName)
@@ -307,69 +191,13 @@ void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName)
rImport.GetStylesImportHelper()->SetRowStyle(rCellStyleName);
}
-void ScMyTables::NewColumn(bool bIsCovered)
-{
- if (bIsCovered)
- return;
-
- sal_Int32 nColCount = pCurrentTab->GetColCount();
- sal_Int32 nSpannedCols = pCurrentTab->GetSpannedCols();
- if ( (nSpannedCols > nColCount) &&
- (pCurrentTab->GetRow() == 0) &&
- (pCurrentTab->GetColumn() == 0) )
- {
- if (nColCount > 0)
- {
- sal_Int32 FirstColsSpanned(nSpannedCols / nColCount);
- sal_Int32 LastColSpanned(FirstColsSpanned
- + (nSpannedCols % nColCount));
- for (sal_Int32 i = 0; i < nColCount - 1; ++i)
- {
- pCurrentTab->SetColsPerCol(i, FirstColsSpanned);
- pCurrentTab->SetRealCols(i + 1, pCurrentTab->GetRealCols(i) + FirstColsSpanned);
- }
- pCurrentTab->SetColsPerCol(nColCount - 1, LastColSpanned);
- pCurrentTab->SetRealCols(
- nColCount, pCurrentTab->GetRealCols(nColCount - 1) + LastColSpanned);
- }
- }
- if (pCurrentTab->GetRealCols(pCurrentTab->GetColumn()) > nSpannedCols - 1)
- {
- if (pCurrentTab->GetRow() == 0)
- {
- rImport.GetStylesImportHelper()->InsertCol(GetRealScCellPos().Col(), nCurrentSheet, rImport.GetDocument());
- size_t n = maTables.size();
- for (size_t i = n - 1; i > 0; --i)
- {
- sal_Int32 nColPos =
- maTables[i-1].GetColumn() + maTables[i].GetSpannedCols() - 1;
-
- maTables[i-1].SetColsPerCol(nColPos,
- maTables[i-1].GetColsPerCol(nColPos) +
- pCurrentTab->GetColsPerCol(pCurrentTab->GetColumn()));
-
- maTables[i-1].SetRealCols(
- nColPos + 1,
- maTables[i-1].GetRealCols(nColPos) + maTables[i-1].GetColsPerCol(nColPos));
-
- maTables[i-1].SetChangedCols(nColPos);
- }
- }
- }
-}
-
void ScMyTables::AddColumn(bool bIsCovered)
{
- pCurrentTab->AddColumn();
- if (pCurrentTab->GetSubTableSpanned() > 1)
- pCurrentTab->SetSubTableSpanned(pCurrentTab->GetSubTableSpanned() - 1);
- else
- {
- NewColumn(bIsCovered);
- sal_Int32 nCol = pCurrentTab->GetColumn();
- pCurrentTab->SetRealCols(
- nCol + 1, pCurrentTab->GetRealCols(nCol) + pCurrentTab->GetColsPerCol(nCol));
- }
+ maCellPos.SetCol( maCellPos.Col() + 1 );
+ //here only need to set column style if this is the first row and
+ //the cell is not covered.
+ if(maCellPos.Row() == 0 && !bIsCovered)
+ rImport.GetStylesImportHelper()->InsertCol(maCellPos.Col(), maCellPos.Tab(), rImport.GetDocument());
}
void ScMyTables::UpdateRowHeights()
@@ -418,21 +246,8 @@ void ScMyTables::DeleteTable()
{
ScXMLImport::MutexGuard aGuard(rImport);
- nCurrentColStylePos = 0;
- if (!maTables.empty())
- {
- maTables.pop_back();
- if (!maTables.empty())
- pCurrentTab = &maTables.back();
- else
- pCurrentTab = NULL;
- }
-
- if (maTables.empty()) // only set the styles if all subtables are imported and the table is finished
- {
- rImport.GetStylesImportHelper()->SetStylesToRanges();
- rImport.SetStylesToRangesFinished();
- }
+ rImport.GetStylesImportHelper()->SetStylesToRanges();
+ rImport.SetStylesToRangesFinished();
//#i48793#; has to be set before protection
if (!aMatrixRangeList.empty())
@@ -459,56 +274,36 @@ void ScMyTables::DeleteTable()
pProtect->setPasswordHash(aHash, maProtectionData.meHash1, maProtectionData.meHash2);
pProtect->setOption(ScTableProtection::SELECT_LOCKED_CELLS, maProtectionData.mbSelectProtectedCells);
pProtect->setOption(ScTableProtection::SELECT_UNLOCKED_CELLS, maProtectionData.mbSelectUnprotectedCells);
- rImport.GetDocument()->SetTabProtection(nCurrentSheet, pProtect.get());
+ rImport.GetDocument()->SetTabProtection(maCellPos.Tab(), pProtect.get());
}
}
-ScAddress ScMyTables::GetRealScCellPos() const
-{
- SCROW nRow = 0;
- SCCOL nCol = 0;
- size_t n = maTables.size();
- for (size_t i = 0; i < n; ++i)
- {
- const ScMyTableData& rTab = maTables[i];
- nCol += rTab.GetRealCols(rTab.GetColumn());
- nRow += rTab.GetRealRows(rTab.GetRow());
- }
- return ScAddress( nCol, nRow, nCurrentSheet );
-}
-
-void ScMyTables::AddColCount(sal_Int32 nTempColCount)
-{
- pCurrentTab->SetColCount(pCurrentTab->GetColCount() + nTempColCount);
-}
-
void ScMyTables::AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName)
{
- OSL_ENSURE(maTables.size() == 1, "not possible to use default styles on columns in subtables");
rImport.GetStylesImportHelper()->AddColumnStyle(rCellStyleName, nCurrentColStylePos, nRepeat);
nCurrentColStylePos += nRepeat;
}
uno::Reference< drawing::XDrawPage > ScMyTables::GetCurrentXDrawPage()
{
- if( (nCurrentSheet != nCurrentDrawPage) || !xDrawPage.is() )
+ if( (maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is() )
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier( xCurrentSheet, uno::UNO_QUERY );
if( xDrawPageSupplier.is() )
xDrawPage.set(xDrawPageSupplier->getDrawPage());
- nCurrentDrawPage = sal::static_int_cast<sal_Int16>(nCurrentSheet);
+ nCurrentDrawPage = sal::static_int_cast<sal_Int16>(maCellPos.Tab());
}
return xDrawPage;
}
uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes()
{
- if( (nCurrentSheet != nCurrentXShapes) || !xShapes.is() )
+ if( (maCellPos.Tab() != nCurrentXShapes) || !xShapes.is() )
{
xShapes.set(GetCurrentXDrawPage(), uno::UNO_QUERY);
rImport.GetShapeImport()->startPage(xShapes);
rImport.GetShapeImport()->pushGroupForSorting ( xShapes );
- nCurrentXShapes = sal::static_int_cast<sal_Int16>(nCurrentSheet);
+ nCurrentXShapes = sal::static_int_cast<sal_Int16>(maCellPos.Tab());
return xShapes;
}
else
@@ -517,12 +312,12 @@ uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes()
bool ScMyTables::HasDrawPage()
{
- return !((nCurrentSheet != nCurrentDrawPage) || !xDrawPage.is());
+ return !((maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is());
}
bool ScMyTables::HasXShapes()
{
- return !((nCurrentSheet != nCurrentXShapes) || !xShapes.is());
+ return !((maCellPos.Tab() != nCurrentXShapes) || !xShapes.is());
}
void ScMyTables::AddOLE(uno::Reference <drawing::XShape>& rShape,
@@ -538,8 +333,8 @@ void ScMyTables::AddMatrixRange(
OSL_ENSURE(nEndRow >= nStartRow, "wrong row order");
OSL_ENSURE(nEndColumn >= nStartColumn, "wrong column order");
ScRange aScRange(
- nStartColumn, nStartRow, nCurrentSheet,
- nEndColumn, nEndRow, nCurrentSheet
+ nStartColumn, nStartRow, maCellPos.Tab(),
+ nEndColumn, nEndRow, maCellPos.Tab()
);
ScMatrixRange aMRange(aScRange, rFormula, rFormulaNmsp, eGrammar);
aMatrixRangeList.push_back(aMRange);
@@ -555,7 +350,7 @@ bool ScMyTables::IsPartOfMatrix(const SCCOL nColumn, const SCROW nRow)
bool bReady(false);
while(!bReady && aItr != aEndItr)
{
- if (nCurrentSheet > aItr->aScRange.aStart.Tab())
+ if (maCellPos.Tab() > aItr->aScRange.aStart.Tab())
{
OSL_FAIL("should never hapen, because the list should be cleared in DeleteTable");
aItr = aMatrixRangeList.erase(aItr);
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index 8252f4c..7b69d5b 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -47,52 +47,6 @@
class ScXMLImport;
-typedef std::vector<sal_Int32> ScMysalIntVec;
-typedef std::list<sal_Int32> ScMysalIntList;
-
-const ScMysalIntVec::size_type nDefaultRowCount = 20;
-const ScMysalIntVec::size_type nDefaultColCount = 20;
-const ScMysalIntVec::size_type nDefaultTabCount = 10;
-
-class ScMyTableData
-{
-private:
- ScAddress maTableCellPos;
- ScMysalIntVec nColsPerCol;
- ScMysalIntVec nRealCols;
- ScMysalIntVec nRowsPerRow;
- ScMysalIntVec nRealRows;
- sal_Int32 nSpannedCols;
- sal_Int32 nColCount;
- sal_Int32 nSubTableSpanned;
- ScMysalIntList nChangedCols;
-public:
- ScMyTableData(SCTAB nSheet = -1, SCCOL nCol = -1, SCROW nRow = -1);
- ~ScMyTableData();
- SCROW GetRow() const { return maTableCellPos.Row(); }
- SCCOL GetColumn() const { return maTableCellPos.Col(); }
- void AddRow();
- void AddColumn();
- void SetFirstColumn() { maTableCellPos.SetCol(-1); }
- sal_Int32 GetColsPerCol(const sal_Int32 nIndex) const { return nColsPerCol[nIndex]; }
- void SetColsPerCol(const sal_Int32 nIndex, sal_Int32 nValue = 1) { nColsPerCol[nIndex] = nValue; }
- sal_Int32 GetRealCols(const sal_Int32 nIndex, const bool bIsNormal = true) const;
- void SetRealCols(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealCols[nIndex] = nValue; }
- sal_Int32 GetRowsPerRow(const sal_Int32 nIndex) const { return nRowsPerRow[nIndex]; }
- void SetRowsPerRow(const sal_Int32 nIndex, const sal_Int32 nValue = 1) { nRowsPerRow[nIndex] = nValue; }
- sal_Int32 GetRealRows(const sal_Int32 nIndex) const { return nIndex < 0 ? 0 : nRealRows[nIndex]; }
- void SetRealRows(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealRows[nIndex] = nValue; }
- sal_Int32 GetSpannedCols() const { return nSpannedCols; }
- void SetSpannedCols(const sal_Int32 nTempSpannedCols) { nSpannedCols = nTempSpannedCols; }
- sal_Int32 GetColCount() const { return nColCount; }
- void SetColCount(const sal_Int32 nTempColCount) { nColCount = nTempColCount; }
- sal_Int32 GetSubTableSpanned() const { return nSubTableSpanned; }
- void SetSubTableSpanned(const sal_Int32 nValue) { nSubTableSpanned = nValue; }
- sal_Int32 GetChangedCols(const sal_Int32 nFromIndex, const sal_Int32 nToIndex) const;
- void SetChangedCols(const sal_Int32 nValue);
-};
-
-
struct ScMatrixRange
{
rtl::OUString sFormula;
@@ -134,14 +88,12 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage;
::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShapes > xShapes;
rtl::OUString sCurrentSheetName;
- ::boost::ptr_vector<ScMyTableData> maTables;
+ ScAddress maCellPos;
ScXMLTabProtectionData maProtectionData;
ScMyMatrixRangeList aMatrixRangeList;
sal_Int32 nCurrentColStylePos;
sal_Int16 nCurrentDrawPage;
sal_Int16 nCurrentXShapes;
- SCTAB nCurrentSheet;
- ScMyTableData* pCurrentTab;
void NewRow();
void NewColumn(bool bIsCovered);
@@ -158,16 +110,15 @@ public:
void UpdateRowHeights();
void FixupOLEs() { aFixupOLEs.FixupOLEs(); }
bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const
- { return ScMyOLEFixer::IsOLE(rShape); }
+ { return ScMyOLEFixer::IsOLE(rShape); }
void DeleteTable();
- ScAddress GetRealScCellPos() const;
- void AddColCount(sal_Int32 nTempColCount);
+ ScAddress GetRealScCellPos() const { return maCellPos; };
void AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName);
ScXMLTabProtectionData& GetCurrentProtectionData() { return maProtectionData; }
rtl::OUString GetCurrentSheetName() const { return sCurrentSheetName; }
- SCTAB GetCurrentSheet() const { return nCurrentSheet; }
- sal_Int32 GetCurrentColumn() const { return maTables.back().GetColCount(); }
- sal_Int32 GetCurrentRow() const { return maTables.back().GetRow(); }
+ SCTAB GetCurrentSheet() const { return (maCellPos.Tab() >= 0) ? maCellPos.Tab() : 0; }
+ SCCOL GetCurrentColumn() const { return (maCellPos.Col() >= 0) ? maCellPos.Col() : 0; }
+ SCROW GetCurrentRow() const { return (maCellPos.Row() >= 0) ? maCellPos.Row() : 0; }
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >
GetCurrentXSheet() const { return xCurrentSheet; }
::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
commit ade70c0e36bf8d8daf674ded0a4d23c422293000
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Sat Jun 16 04:42:05 2012 -0500
Remove subtable import code since sc core doesn't support it
Change-Id: Ic9be156a9468bec4bccdce40ddd51344002067f9
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 55a92b6..6d03fad 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -128,7 +128,6 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
nCellType(util::NumberFormat::TEXT),
bIsMerged(false),
bIsMatrix(false),
- bHasSubTable(false),
bIsCovered(bTempIsCovered),
bIsEmpty(true),
bHasTextImport(false),
@@ -394,23 +393,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
break;
case XML_TOK_TABLE_ROW_CELL_TABLE:
{
- const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- rtl::OUString aLocalName;
- for( sal_Int16 i=0; i < nAttrCount; i++ )
- {
- sal_uInt16 nAttrPrefix = rXMLImport.GetNamespaceMap().GetKeyByAttrName(
- xAttrList->getNameByIndex( i ), &aLocalName );
- if ( nAttrPrefix == XML_NAMESPACE_TABLE
- && IsXMLToken(aLocalName, XML_IS_SUB_TABLE))
- {
- bHasSubTable = IsXMLToken(xAttrList->getValueByIndex( i ), XML_TRUE);
- }
- }
- OSL_ENSURE(bHasSubTable, "it should be a subtable");
- pContext = new ScXMLTableContext( rXMLImport , nPrefix,
- rLName, xAttrList, true, static_cast<sal_Int32>(nMergedCols) );
- nMergedCols = 1;
- bIsMerged = false;
+ SAL_WARN("sc", "ScXMLTableRowCellContext::CreateChildContext: subtables are not supported");
}
break;
case XML_TOK_TABLE_ROW_CELL_ANNOTATION:
@@ -1101,34 +1084,31 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
void ScXMLTableRowCellContext::EndElement()
{
- if( !bHasSubTable )
+ if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
{
- if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
+ UniReference< XMLTextImportHelper > aTextImport = rXMLImport.GetTextImport();
+ if( aTextImport->GetCursor().is() )
{
- UniReference< XMLTextImportHelper > aTextImport = rXMLImport.GetTextImport();
- if( aTextImport->GetCursor().is() )
+ if( aTextImport->GetCursor()->goLeft(1, true) )
{
- if( aTextImport->GetCursor()->goLeft(1, true) )
- {
- aTextImport->GetText()->insertString(
- aTextImport->GetCursorAsRange(), rtl::OUString(), true );
- }
- aTextImport->ResetCursor();
+ aTextImport->GetText()->insertString(
+ aTextImport->GetCursorAsRange(), rtl::OUString(), true );
}
+ aTextImport->ResetCursor();
}
-
- ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
- if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
- aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
- if( bIsMerged )
- DoMerge( aCellPos, nMergedCols - 1, nMergedRows - 1 );
- if( !pOUFormula )
- AddNonFormulaCells( aCellPos );
- else // if ( pOUFormula )
- AddFormulaCell( aCellPos );
}
+
+ ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+ if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
+ aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
+ if( bIsMerged )
+ DoMerge( aCellPos, nMergedCols - 1, nMergedRows - 1 );
+ if( !pOUFormula )
+ AddNonFormulaCells( aCellPos );
+ else // if ( pOUFormula )
+ AddFormulaCell( aCellPos );
+
bIsMerged = false;
- bHasSubTable = false;
nMergedCols = 1;
nMergedRows = 1;
nColsRepeated = 1;
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index cf1b091..3df155e 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -67,7 +67,6 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
sal_Int16 nCellType;
bool bIsMerged;
bool bIsMatrix;
- bool bHasSubTable;
bool bIsCovered;
bool bIsEmpty;
bool bHasTextImport;
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 0dc4c5c..9eb1d10 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -221,7 +221,9 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
}
}
- NewTable(1);
+ maTables.push_back(new ScMyTableData(nCurrentSheet));
+ pCurrentTab = & maTables.back();
+ pCurrentTab->SetSpannedCols(1);
}
void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
@@ -370,41 +372,6 @@ void ScMyTables::AddColumn(bool bIsCovered)
}
}
-void ScMyTables::NewTable(sal_Int32 nTempSpannedCols)
-{
- maTables.push_back(new ScMyTableData(nCurrentSheet));
- pCurrentTab = & maTables.back();
-
- size_t nTables = maTables.size();
- if (nTables > 1)
- {
- ScMyTableData& rFirstTab = maTables.front();
-
- const sal_Int32 nCol = rFirstTab.GetColumn();
- const sal_Int32 nColCount = rFirstTab.GetColCount();
- const sal_Int32 nColsPerCol = rFirstTab.GetColsPerCol(nCol);
-
- sal_Int32 nSpannedCols = rFirstTab.GetSpannedCols();
- sal_Int32 nTemp = nSpannedCols - nColCount;
- sal_Int32 nTemp2 = nCol - nColCount + 1;
- if ((nTemp > 0) && (nTemp2 == 0))
- nTempSpannedCols *= nTemp + 1;
- else
- if (nColsPerCol > 1)
- nTempSpannedCols *= nColsPerCol;
-
- sal_Int32 nToMerge;
- if (nSpannedCols > nColCount)
- nToMerge = rFirstTab.GetChangedCols(nCol, nCol + nColsPerCol + nSpannedCols - nColCount);
- else
- nToMerge = rFirstTab.GetChangedCols(nCol, nCol + nColsPerCol);
- if (nToMerge > nCol)
- nTempSpannedCols += nToMerge;
- }
-
- pCurrentTab->SetSpannedCols(nTempSpannedCols);
-}
-
void ScMyTables::UpdateRowHeights()
{
if (rImport.GetModel().is())
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index edab1bd..8252f4c 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -155,7 +155,6 @@ public:
void AddRow();
void SetRowStyle(const rtl::OUString& rCellStyleName);
void AddColumn(bool bIsCovered);
- void NewTable(sal_Int32 nTempSpannedCols);
void UpdateRowHeights();
void FixupOLEs() { aFixupOLEs.FixupOLEs(); }
bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index ea9178d..69b9fa7 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -151,9 +151,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport,
sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- const bool bTempIsSubTable,
- const sal_Int32 nSpannedCols) :
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) :
SvXMLImportContext( rImport, nPrfx, rLName ),
pExternalRefInfo(NULL),
nStartOffset(-1),
@@ -163,77 +161,70 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport,
// get start offset in file (if available)
nStartOffset = GetScImport().GetByteOffset();
- if (!bTempIsSubTable)
+ ScXMLTabProtectionData aProtectData;
+ rtl::OUString sName;
+ rtl::OUString sStyleName;
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
{
- ScXMLTabProtectionData aProtectData;
- rtl::OUString sName;
- rtl::OUString sStyleName;
- sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName ));
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_TABLE_NAME:
- sName = sValue;
- break;
- case XML_TOK_TABLE_STYLE_NAME:
- sStyleName = sValue;
- break;
- case XML_TOK_TABLE_PROTECTED:
- aProtectData.mbProtected = IsXMLToken(sValue, XML_TRUE);
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_TABLE_NAME:
+ sName = sValue;
break;
- case XML_TOK_TABLE_PRINT_RANGES:
- sPrintRanges = sValue;
- break;
- case XML_TOK_TABLE_PASSWORD:
- aProtectData.maPassword = sValue;
+ case XML_TOK_TABLE_STYLE_NAME:
+ sStyleName = sValue;
break;
- case XML_TOK_TABLE_PASSHASH:
- aProtectData.meHash1 = ScPassHashHelper::getHashTypeFromURI(sValue);
+ case XML_TOK_TABLE_PROTECTED:
+ aProtectData.mbProtected = IsXMLToken(sValue, XML_TRUE);
+ break;
+ case XML_TOK_TABLE_PRINT_RANGES:
+ sPrintRanges = sValue;
break;
- case XML_TOK_TABLE_PASSHASH_2:
- aProtectData.meHash2 = ScPassHashHelper::getHashTypeFromURI(sValue);
+ case XML_TOK_TABLE_PASSWORD:
+ aProtectData.maPassword = sValue;
+ break;
+ case XML_TOK_TABLE_PASSHASH:
+ aProtectData.meHash1 = ScPassHashHelper::getHashTypeFromURI(sValue);
+ break;
+ case XML_TOK_TABLE_PASSHASH_2:
+ aProtectData.meHash2 = ScPassHashHelper::getHashTypeFromURI(sValue);
+ break;
+ case XML_TOK_TABLE_PRINT:
+ {
+ if (IsXMLToken(sValue, XML_FALSE))
+ bPrintEntireSheet = false;
+ }
break;
- case XML_TOK_TABLE_PRINT:
- {
- if (IsXMLToken(sValue, XML_FALSE))
- bPrintEntireSheet = false;
- }
- break;
- }
}
+ }
- rtl::OUString aExtUrl, aExtTabName;
- if (lcl_isExternalRefCache(sName, aExtUrl, aExtTabName))
- {
- // This is an external ref cache table.
- pExternalRefInfo.reset(new ScXMLExternalTabData);
- pExternalRefInfo->maFileUrl = aExtUrl;
- ScDocument* pDoc = GetScImport().GetDocument();
- if (pDoc)
- {
- ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- pExternalRefInfo->mnFileId = pRefMgr->getExternalFileId(aExtUrl);
- pExternalRefInfo->mpCacheTable = pRefMgr->getCacheTable(pExternalRefInfo->mnFileId, aExtTabName, true);
- pExternalRefInfo->mpCacheTable->setWholeTableCached();
- }
- }
- else
+ rtl::OUString aExtUrl, aExtTabName;
+ if (lcl_isExternalRefCache(sName, aExtUrl, aExtTabName))
+ {
+ // This is an external ref cache table.
+ pExternalRefInfo.reset(new ScXMLExternalTabData);
+ pExternalRefInfo->maFileUrl = aExtUrl;
+ ScDocument* pDoc = GetScImport().GetDocument();
+ if (pDoc)
{
- // This is a regular table.
- GetScImport().GetTables().NewSheet(sName, sStyleName, aProtectData);
+ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
+ pExternalRefInfo->mnFileId = pRefMgr->getExternalFileId(aExtUrl);
+ pExternalRefInfo->mpCacheTable = pRefMgr->getCacheTable(pExternalRefInfo->mnFileId, aExtTabName, true);
+ pExternalRefInfo->mpCacheTable->setWholeTableCached();
}
}
else
{
- GetScImport().GetTables().NewTable(nSpannedCols);
+ // This is a regular table.
+ GetScImport().GetTables().NewSheet(sName, sStyleName, aProtectData);
}
}
diff --git a/sc/source/filter/xml/xmltabi.hxx b/sc/source/filter/xml/xmltabi.hxx
index 8ccf841..8a55978 100644
--- a/sc/source/filter/xml/xmltabi.hxx
+++ b/sc/source/filter/xml/xmltabi.hxx
@@ -62,9 +62,7 @@ public:
ScXMLTableContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- const bool bTempIsSubTable = false,
- const sal_Int32 nSpannedCols = 0);
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
virtual ~ScXMLTableContext();
commit 410d7416ee3b83ab8d2c2a6476752c575c5a4e4f
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Fri Jun 15 01:08:05 2012 -0500
Clean minor misc code leftovers from conversion
Change-Id: I6e6fbc1508cb5f46a0084f0aa2d8f2ad974de644
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 95af710..55a92b6 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -176,7 +176,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
nMatrixRows = static_cast<SCROW>(sValue.toInt32());
break;
case XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED:
- nColsRepeated = static_cast<SCCOL>(std::max( sValue.toInt32(), (sal_Int32) 1 ));
+ nColsRepeated = static_cast<SCCOL>(std::max( sValue.toInt32(), static_cast<sal_Int32>(1) ));
break;
case XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE:
nCellType = GetScImport().GetCellType(sValue);
@@ -290,7 +290,7 @@ void ScXMLTableRowCellContext::UnlockSolarMutex()
namespace {
-bool scCellExists( const ScAddress& rCellPos )
+bool cellExists( const ScAddress& rCellPos )
{
return( rCellPos.Col() >= 0 && rCellPos.Row() >= 0 &&
rCellPos.Col() <= MAXCOL && rCellPos.Row() <= MAXROW );
@@ -300,17 +300,15 @@ bool scCellExists( const ScAddress& rCellPos )
void ScXMLTableRowCellContext::SetCursorOnTextImport(const rtl::OUString& rOUTempText)
{
- //extra step here until this area is fully converted
- com::sun::star::table::CellAddress aCellPos;
- ScAddress aScCellPos = rXMLImport.GetTables().GetRealScCellPos();
- ScUnoConversion::FillApiAddress( aCellPos, aScCellPos );
-
- if (CellExists(aCellPos))
+ ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+ if (cellExists(aCellPos))
{
+ sal_Int32 nCol = static_cast<sal_Int32>( aCellPos.Col() );
+ sal_Int32 nRow = static_cast<sal_Int32>( aCellPos.Row() );
uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange());
if (xCellRange.is())
{
- xBaseCell.set(xCellRange->getCellByPosition(aCellPos.Column, aCellPos.Row));
+ xBaseCell.set( xCellRange->getCellByPosition(nCol, nRow) );
if (xBaseCell.is())
{
xLockable.set(xBaseCell, uno::UNO_QUERY);
@@ -347,18 +345,15 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
bool bTextP(false);
switch( rTokenMap.Get( nPrefix, rLName ) )
{
- case XML_TOK_TABLE_ROW_CELL_P:
+ case XML_TOK_TABLE_ROW_CELL_P:
{
bIsEmpty = false;
bTextP = true;
- //extra step here until this area is fully converted
- com::sun::star::table::CellAddress aCellPos;
- ScAddress aScCellPos = rXMLImport.GetTables().GetRealScCellPos();
- ScUnoConversion::FillApiAddress( aCellPos, aScCellPos );
+ ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
if( ((nCellType == util::NumberFormat::TEXT) || bFormulaTextResult) &&
- !rXMLImport.GetTables().IsPartOfMatrix(static_cast<SCCOL>(aCellPos.Column), static_cast<SCROW>(aCellPos.Row)) )
+ !rXMLImport.GetTables().IsPartOfMatrix(aCellPos.Col(), aCellPos.Row()) )
{
if (!bHasTextImport)
{
@@ -368,7 +363,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
}
else
{
- if (CellExists(aCellPos))
+ if (cellExists(aCellPos))
{
if (bIsFirstTextImport && !rXMLImport.GetRemoveLastChar())
{
@@ -397,7 +392,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
}
}
break;
- case XML_TOK_TABLE_ROW_CELL_TABLE:
+ case XML_TOK_TABLE_ROW_CELL_TABLE:
{
const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
rtl::OUString aLocalName;
@@ -418,7 +413,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
bIsMerged = false;
}
break;
- case XML_TOK_TABLE_ROW_CELL_ANNOTATION:
+ case XML_TOK_TABLE_ROW_CELL_ANNOTATION:
{
bIsEmpty = false;
OSL_ENSURE( !mxAnnotationData.get(), "ScXMLTableRowCellContext::CreateChildContext - multiple annotations in one cell" );
@@ -427,7 +422,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
xAttrList, *mxAnnotationData, this);
}
break;
- case XML_TOK_TABLE_ROW_CELL_DETECTIVE:
+ case XML_TOK_TABLE_ROW_CELL_DETECTIVE:
{
bIsEmpty = false;
if (!pDetectiveObjVec)
@@ -436,7 +431,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
rXMLImport, nPrefix, rLName, pDetectiveObjVec );
}
break;
- case XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE:
+ case XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE:
{
bIsEmpty = false;
if (!pCellRangeSource)
@@ -449,21 +444,20 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
if (!pContext && !bTextP)
{
- //extra step here until this area is fully converted
- com::sun::star::table::CellAddress aCellPos;
- ScAddress aScCellPos = rXMLImport.GetTables().GetRealScCellPos();
- ScUnoConversion::FillApiAddress( aCellPos, aScCellPos );
-
+ ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
if (xShapes.is())
{
- if (aCellPos.Column > MAXCOL)
- aCellPos.Column = MAXCOL;
- if (aCellPos.Row > MAXROW)
- aCellPos.Row = MAXROW;
- XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)rXMLImport.GetShapeImport().get();
+ if (aCellPos.Col() > MAXCOL)
+ aCellPos.SetCol(MAXCOL);
+ if (aCellPos.Row() > MAXROW)
+ aCellPos.SetRow(MAXROW);
+ XMLTableShapeImportHelper* pTableShapeImport =
+ static_cast< XMLTableShapeImportHelper* >( rXMLImport.GetShapeImport().get() );
pTableShapeImport->SetOnTable(false);
- pTableShapeImport->SetCell(aCellPos);
+ com::sun::star::table::CellAddress aCellAddress;
+ ScUnoConversion::FillApiAddress( aCellAddress, aCellPos );
+ pTableShapeImport->SetCell(aCellAddress);
pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext(
rXMLImport, nPrefix, rLName, xAttrList, xShapes);
if (pContext)
@@ -603,9 +597,9 @@ void ScXMLTableRowCellContext::SetContentValidation( const ScRange& rScRange )
}
}
-void ScXMLTableRowCellContext::SetContentValidation( const ScAddress& rScCellPos )
+void ScXMLTableRowCellContext::SetContentValidation( const ScAddress& rCellPos )
{
- SetContentValidation( ScRange(rScCellPos, rScCellPos) );
+ SetContentValidation( ScRange(rCellPos, rCellPos) );
}
void ScXMLTableRowCellContext::SetAnnotation(const ScAddress& rPos)
@@ -717,7 +711,7 @@ void ScXMLTableRowCellContext::SetAnnotation(const ScAddress& rPos)
// core implementation
void ScXMLTableRowCellContext::SetDetectiveObj( const ScAddress& rPosition )
{
- if( scCellExists(rPosition) && pDetectiveObjVec && pDetectiveObjVec->size() )
+ if( cellExists(rPosition) && pDetectiveObjVec && pDetectiveObjVec->size() )
{
LockSolarMutex();
ScDetectiveFunc aDetFunc( rXMLImport.GetDocument(), rPosition.Tab() );
@@ -741,7 +735,7 @@ void ScXMLTableRowCellContext::SetDetectiveObj( const ScAddress& rPosition )
// core implementation
void ScXMLTableRowCellContext::SetCellRangeSource( const ScAddress& rPosition )
{
- if( scCellExists(rPosition) && pCellRangeSource && !pCellRangeSource->sSourceStr.isEmpty() &&
+ if( cellExists(rPosition) && pCellRangeSource && !pCellRangeSource->sSourceStr.isEmpty() &&
!pCellRangeSource->sFilterName.isEmpty() && !pCellRangeSource->sURL.isEmpty() )
{
ScDocument* pDoc = rXMLImport.GetDocument();
@@ -761,59 +755,13 @@ void ScXMLTableRowCellContext::SetCellRangeSource( const ScAddress& rPosition )
}
}
-bool lcl_IsEmptyOrNote( ScDocument* pDoc, const ScAddress& rScCurrentPos )
-{
- ScBaseCell* pCell = pDoc->GetCell( rScCurrentPos );
- return ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE );
-}
-
-namespace {
-
-// from ScCellObj::GetOutputString_Imp(). all of it may not be necessary.
-rtl::OUString getOutputString(ScDocument* pDoc, const ScAddress& aCellPos)
-{
- rtl::OUString aVal;
- if ( pDoc )
- {
- ScBaseCell* pCell = pDoc->GetCell( aCellPos );
- if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
- {
- if ( pCell->GetCellType() == CELLTYPE_EDIT )
- {
- // GetString an der EditCell macht Leerzeichen aus Umbruechen,
- // hier werden die Umbrueche aber gebraucht
- const EditTextObject* pData = ((ScEditCell*)pCell)->GetData();
- if (pData)
- {
- EditEngine& rEngine = pDoc->GetEditEngine();
- rEngine.SetText( *pData );
- aVal = rEngine.GetText( LINEEND_LF );
- }
- // Edit-Zellen auch nicht per NumberFormatter formatieren
- // (passend zur Ausgabe)
- }
- else
- {
- // wie in GetString am Dokument (column)
- Color* pColor;
- sal_uLong nNumFmt = pDoc->GetNumberFormat( aCellPos );
- ScCellFormat::GetString( pCell, nNumFmt, aVal, &pColor, *pDoc->GetFormatTable() );
- }
- }
- }
- return aVal;
-}
-
-} // anon namespace
-
-void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rScCurrentPos,
+void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rCurrentPos,
const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText )
{
bool bDoIncrement = true;
- if( rXMLImport.GetTables().IsPartOfMatrix(rScCurrentPos.Col(), rScCurrentPos.Row()) )
+ if( rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos.Col(), rCurrentPos.Row()) )
{
- LockSolarMutex(); //is this still needed?
- ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( rScCurrentPos );
+ ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( rCurrentPos );
bDoIncrement = ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA );
if ( bDoIncrement )
{
@@ -830,7 +778,6 @@ void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rScCurrentPos,
}
else
{
- LockSolarMutex(); //is this still needed?
ScBaseCell* pNewCell = NULL;
ScDocument* pDoc = rXMLImport.GetDocument();
if (pOUTextValue && !pOUTextValue->isEmpty())
@@ -842,29 +789,26 @@ void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rScCurrentPos,
bDoIncrement = pNewCell != NULL;
if ( bDoIncrement )
- pDoc->PutCell( rScCurrentPos, pNewCell );
+ pDoc->PutCell( rCurrentPos, pNewCell );
}
// #i56027# This is about setting simple text, not edit cells,
// so ProgressBarIncrement must be called with bEditCell = FALSE.
// Formatted text that is put into the cell by the child context
- // is handled below (bIsEmpty is true then).
+ // is handled in AddCellsToTable() (bIsEmpty is true then).
if (bDoIncrement || bHasTextImport)
rXMLImport.ProgressBarIncrement(false);
}
-void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rScCurrentPos )
+void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos )
{
- if( rXMLImport.GetTables().IsPartOfMatrix(rScCurrentPos.Col(), rScCurrentPos.Row()) )
+ if( rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos.Col(), rCurrentPos.Row()) )
{
- LockSolarMutex(); //is this still needed?
- ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( rScCurrentPos );
+ ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( rCurrentPos );
if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
static_cast<ScFormulaCell*>(pCell)->SetHybridDouble( fValue );
}
else
{
- LockSolarMutex(); //is this still needed?
-
// #i62435# Initialize the value cell's script type
// if the default style's number format is latin-only.
// If the cell uses a different format, the script type
@@ -874,41 +818,51 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rScCurrentPo
if ( rXMLImport.IsLatinDefaultStyle() )
pNewCell->SetScriptType( SCRIPTTYPE_LATIN );
rXMLImport.GetDocument()->PutCell(
- rScCurrentPos.Col(), rScCurrentPos.Row(),
- rScCurrentPos.Tab(), pNewCell );
+ rCurrentPos.Col(), rCurrentPos.Row(),
+ rCurrentPos.Tab(), pNewCell );
}
rXMLImport.ProgressBarIncrement(false);
}
-void ScXMLTableRowCellContext::AddCellsToTable( const ScAddress& rScCellPos,
- const ::boost::optional< rtl::OUString >& pOUText, ScAddress& rScCurrentPos )
+namespace {
+
+bool isEmptyOrNote( ScDocument* pDoc, const ScAddress& rCurrentPos )
+{
+ ScBaseCell* pCell = pDoc->GetCell( rCurrentPos );
+ return ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE );
+}
+
+}
+
+void ScXMLTableRowCellContext::AddCellsToTable( const ScAddress& rCellPos,
+ const ::boost::optional< rtl::OUString >& pOUText, ScAddress& rCurrentPos )
{
ScMyTables& rTables = rXMLImport.GetTables();
bool bWasEmpty = bIsEmpty;
for (SCCOL i = 0; i < nColsRepeated; ++i)
{
- rScCurrentPos.SetCol( rScCellPos.Col() + i );
+ rCurrentPos.SetCol( rCellPos.Col() + i );
if (i > 0)
rTables.AddColumn(false);
if (!bIsEmpty)
{
for (SCROW j = 0; j < nRepeatedRows; ++j)
{
- rScCurrentPos.SetRow( rScCellPos.Row() + j );
- if( (rScCurrentPos.Col() == 0) && (j > 0) )
+ rCurrentPos.SetRow( rCellPos.Row() + j );
+ if( (rCurrentPos.Col() == 0) && (j > 0) )
{
rTables.AddRow();
rTables.AddColumn(false);
}
- if( scCellExists(rScCurrentPos) )
+ if( cellExists(rCurrentPos) )
{
- if( ( !(bIsCovered) || lcl_IsEmptyOrNote(rXMLImport.GetDocument(), rScCurrentPos) ) )
+ if( ( !(bIsCovered) || isEmptyOrNote(rXMLImport.GetDocument(), rCurrentPos) ) )
{
switch (nCellType)
{
case util::NumberFormat::TEXT:
{
- AddTextCellToDoc( rScCurrentPos, i, pOUText );
+ AddTextCellToDoc( rCurrentPos, i, pOUText );
}
break;
case util::NumberFormat::NUMBER:
@@ -918,7 +872,7 @@ void ScXMLTableRowCellContext::AddCellsToTable( const ScAddress& rScCellPos,
case util::NumberFormat::DATETIME:
case util::NumberFormat::LOGICAL:
{
- AddNumberCellToDoc( rScCurrentPos );
+ AddNumberCellToDoc( rCurrentPos );
}
break;
default:
@@ -929,15 +883,15 @@ void ScXMLTableRowCellContext::AddCellsToTable( const ScAddress& rScCellPos,
}
}
- SetAnnotation( rScCurrentPos );
- SetDetectiveObj( rScCurrentPos );
- SetCellRangeSource( rScCurrentPos );
+ SetAnnotation( rCurrentPos );
+ SetDetectiveObj( rCurrentPos );
+ SetCellRangeSource( rCurrentPos );
}
else
{
if (!bWasEmpty || mxAnnotationData.get())
{
- if (rScCurrentPos.Row() > MAXROW)
+ if (rCurrentPos.Row() > MAXROW)
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
else
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
@@ -952,7 +906,7 @@ void ScXMLTableRowCellContext::AddCellsToTable( const ScAddress& rScCellPos,
// with bEditCell = TRUE.
if (bHasTextImport)
rXMLImport.ProgressBarIncrement(true);
- if ((i == 0) && (rScCellPos.Col() == 0))
+ if ((i == 0) && (rCellPos.Col() == 0))
{
for (sal_Int32 j = 1; j < nRepeatedRows; ++j)
{
@@ -964,9 +918,9 @@ void ScXMLTableRowCellContext::AddCellsToTable( const ScAddress& rScCellPos,
}
}
-bool ScXMLTableRowCellContext::ContextIsEmpty() const
+bool ScXMLTableRowCellContext::HasSpecialContent() const
{
- return !( (pContentValidationName && !pContentValidationName->isEmpty()) ||
+ return ( (pContentValidationName && !pContentValidationName->isEmpty()) ||
mxAnnotationData.get() || pDetectiveObjVec || pCellRangeSource );
}
@@ -975,52 +929,83 @@ bool ScXMLTableRowCellContext::CellsAreRepeated() const
return ( (nColsRepeated > 1) || (nRepeatedRows > 1) );
}
-void ScXMLTableRowCellContext::AddNonFormulaCells( const ScAddress& rScCellPos )
+namespace {
+
+// from ScCellObj::GetOutputString_Imp(). all of it may not be necessary.
+rtl::OUString getOutputString(ScDocument* pDoc, const ScAddress& aCellPos)
+{
+ rtl::OUString aVal;
+ if ( pDoc )
+ {
+ ScBaseCell* pCell = pDoc->GetCell( aCellPos );
+ if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
+ {
+ if ( pCell->GetCellType() == CELLTYPE_EDIT )
+ {
+ // GetString an der EditCell macht Leerzeichen aus Umbruechen,
+ // hier werden die Umbrueche aber gebraucht
+ const EditTextObject* pData = ( static_cast< ScEditCell* >(pCell) )->GetData();
+ if (pData)
+ {
+ EditEngine& rEngine = pDoc->GetEditEngine();
+ rEngine.SetText( *pData );
+ aVal = rEngine.GetText( LINEEND_LF );
+ }
+ // Edit-Zellen auch nicht per NumberFormatter formatieren
+ // (passend zur Ausgabe)
+ }
+ else
+ {
+ // wie in GetString am Dokument (column)
+ Color* pColor;
+ sal_uLong nNumFmt = pDoc->GetNumberFormat( aCellPos );
+ ScCellFormat::GetString( pCell, nNumFmt, aVal, &pColor, *pDoc->GetFormatTable() );
+ }
+ }
+ }
+ return aVal;
+}
+
+}
+
+void ScXMLTableRowCellContext::AddNonFormulaCells( const ScAddress& rCellPos )
{
::boost::optional< rtl::OUString > pOUText;
if( nCellType == util::NumberFormat::TEXT )
{
- if( xLockable.is() ) //is this still needed?
- xLockable->removeActionLock();
-
- // #i61702# The formatted text content of xBaseCell / xLockable is invalidated,
- // so it can't be used after calling removeActionLock (getString always uses the document).
-
- if( scCellExists(rScCellPos) && CellsAreRepeated() )
- pOUText.reset( getOutputString(rXMLImport.GetDocument(), rScCellPos) );
+ if( cellExists(rCellPos) && CellsAreRepeated() )
+ pOUText.reset( getOutputString(rXMLImport.GetDocument(), rCellPos) );
if( !pOUTextContent && !pOUText && !pOUTextValue )
bIsEmpty = true;
}
- ScAddress aScCurrentPos( rScCellPos );
- if( !ContextIsEmpty() )
+ ScAddress aCurrentPos( rCellPos );
+ if( HasSpecialContent() )
bIsEmpty = false;
- AddCellsToTable( rScCellPos, pOUText, aScCurrentPos );
+ AddCellsToTable( rCellPos, pOUText, aCurrentPos );
if( CellsAreRepeated() )
{
- SCCOL nStartCol( rScCellPos.Col() < MAXCOL ? rScCellPos.Col() : MAXCOL );
- SCROW nStartRow( rScCellPos.Row() < MAXROW ? rScCellPos.Row() : MAXROW );
- SCCOL nEndCol( rScCellPos.Col() + nColsRepeated - 1 < MAXCOL ? rScCellPos.Col() + nColsRepeated - 1 : MAXCOL );
- SCROW nEndRow( rScCellPos.Row() + nRepeatedRows - 1 < MAXROW ? rScCellPos.Row() + nRepeatedRows - 1 : MAXROW );
- ScRange aScRange( nStartCol, nStartRow, rScCellPos.Tab(), nEndCol, nEndRow, rScCellPos.Tab() );
+ SCCOL nStartCol( rCellPos.Col() < MAXCOL ? rCellPos.Col() : MAXCOL );
+ SCROW nStartRow( rCellPos.Row() < MAXROW ? rCellPos.Row() : MAXROW );
+ SCCOL nEndCol( rCellPos.Col() + nColsRepeated - 1 < MAXCOL ? rCellPos.Col() + nColsRepeated - 1 : MAXCOL );
+ SCROW nEndRow( rCellPos.Row() + nRepeatedRows - 1 < MAXROW ? rCellPos.Row() + nRepeatedRows - 1 : MAXROW );
+ ScRange aScRange( nStartCol, nStartRow, rCellPos.Tab(), nEndCol, nEndRow, rCellPos.Tab() );
SetContentValidation( aScRange );
rXMLImport.GetStylesImportHelper()->AddRange( aScRange );
}
- else if( scCellExists(rScCellPos) )
+ else if( cellExists(rCellPos) )
{
- rXMLImport.GetStylesImportHelper()->AddCell(rScCellPos);
- SetContentValidation( rScCellPos );
+ rXMLImport.GetStylesImportHelper()->AddCell(rCellPos);
+ SetContentValidation( rCellPos );
}
}
-void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rScCellPos )
+void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPos )
{
- LockSolarMutex(); //is this still needed
-
ScDocument* pDoc = rXMLImport.GetDocument();
rtl::OUString aText = pOUFormula->first;
@@ -1042,7 +1027,7 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rScCell
pCode->AddStringXML( aFormulaNmsp );
pDoc->IncXMLImportedFormulaCount( aText.getLength() );
- pNewCell = new ScFormulaCell( pDoc, rScCellPos, pCode, eGrammar, MM_NONE );
+ pNewCell = new ScFormulaCell( pDoc, rCellPos, pCode, eGrammar, MM_NONE );
delete pCode;
}
else if ( aText[0] == '\'' && aText.getLength() > 1 )
@@ -1067,9 +1052,9 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rScCell
}
if( pNewCell )
- pDoc->PutCell( rScCellPos, pNewCell );
+ pDoc->PutCell( rCellPos, pNewCell );
- ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( rScCellPos );
+ ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( rCellPos );
if( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
{
if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
@@ -1080,34 +1065,34 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rScCell
}
}
-void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rScCellPos )
+void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
{
- if( scCellExists(rScCellPos) )
+ if( cellExists(rCellPos) )
{
- SetContentValidation( rScCellPos );
+ SetContentValidation( rCellPos );
OSL_ENSURE(((nColsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now");
- rXMLImport.GetStylesImportHelper()->AddCell(rScCellPos);
+ rXMLImport.GetStylesImportHelper()->AddCell(rCellPos);
if (!bIsMatrix)
- AddNonMatrixFormulaCell( rScCellPos );
+ AddNonMatrixFormulaCell( rCellPos );
else
{
if (nMatrixCols > 0 && nMatrixRows > 0)
{
rXMLImport.GetTables().AddMatrixRange(
- rScCellPos.Col(), rScCellPos.Row(),
- rScCellPos.Col() + nMatrixCols - 1,
- rScCellPos.Row() + nMatrixRows - 1,
+ rCellPos.Col(), rCellPos.Row(),
+ rCellPos.Col() + nMatrixCols - 1,
+ rCellPos.Row() + nMatrixRows - 1,
pOUFormula->first, pOUFormula->second, eGrammar);
}
}
- SetAnnotation( rScCellPos );
- SetDetectiveObj( rScCellPos );
- SetCellRangeSource( rScCellPos );
+ SetAnnotation( rCellPos );
+ SetDetectiveObj( rCellPos );
+ SetCellRangeSource( rCellPos );
rXMLImport.ProgressBarIncrement(false);
}
else
{
- if (rScCellPos.Row() > MAXROW)
+ if (rCellPos.Row() > MAXROW)
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
else
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
@@ -1132,17 +1117,15 @@ void ScXMLTableRowCellContext::EndElement()
}
}
- ScAddress aScCellPos = rXMLImport.GetTables().GetRealScCellPos();
- if( aScCellPos.Col() > 0 && nRepeatedRows > 1 )
- aScCellPos.SetRow( aScCellPos.Row() - (nRepeatedRows - 1) );
+ ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+ if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
+ aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
if( bIsMerged )
- DoMerge( aScCellPos, nMergedCols - 1, nMergedRows - 1 );
+ DoMerge( aCellPos, nMergedCols - 1, nMergedRows - 1 );
if( !pOUFormula )
- AddNonFormulaCells( aScCellPos );
+ AddNonFormulaCells( aCellPos );
else // if ( pOUFormula )
- AddFormulaCell( aScCellPos );
-
- UnlockSolarMutex(); //is this still needed?
+ AddFormulaCell( aCellPos );
}
bIsMerged = false;
bHasSubTable = false;
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 978c9c1..cf1b091 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -88,12 +88,7 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
void LockSolarMutex();
void UnlockSolarMutex();
- bool CellExists(const com::sun::star::table::CellAddress& aCellPos) const
- {
- return (aCellPos.Column <= MAXCOL && aCellPos.Row <= MAXROW);
- }
-
- bool ContextIsEmpty() const;
+ bool HasSpecialContent() const;
bool CellsAreRepeated() const;
void AddTextCellToDoc ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol,
commit 8f47232ba90bd6582cf3c02857fbb406a311bcec
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Wed Jun 13 17:51:58 2012 -0500
Add test case for cell text with line breaks
Change-Id: Ibecefc21048817a566357ac3a65ee9a74a5af9fc
diff --git a/sc/qa/unit/data/ods/formats.ods b/sc/qa/unit/data/ods/formats.ods
index c4c9ba8..5ce8d0f 100644
Binary files a/sc/qa/unit/data/ods/formats.ods and b/sc/qa/unit/data/ods/formats.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 4d90a9f..739fac8 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -464,6 +464,13 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n
rtl::OString aKnownGoodOStr(rtl::OUStringToOString(aKnownGoodOUStr, RTL_TEXTENCODING_UTF8));
rtl::OString aMsg2("Expected: \"" + aKnownGoodOStr + "\"; Actual: \"" + aTestOStr + "\"");
CPPUNIT_ASSERT_MESSAGE( aMsg2.pData->buffer, aKnownGoodOUStr.equals(aTestOUStr) );
+ //test case for cell text with line breaks.
+ pDoc->GetString(3,5,1, aTestOUStr);
+ aKnownGoodOUStr = "Hello,\nCalc!";
+ aTestOStr = rtl::OUStringToOString(aTestOUStr, RTL_TEXTENCODING_UTF8);
+ aKnownGoodOStr = rtl::OUStringToOString(aKnownGoodOUStr, RTL_TEXTENCODING_UTF8);
+ rtl::OString aMsg3("Expected: \"" + aKnownGoodOStr + "\"; Actual: \"" + aTestOStr + "\"");
+ CPPUNIT_ASSERT_MESSAGE( aMsg3.pData->buffer, aKnownGoodOUStr.equals(aTestOUStr) );
}
pPattern = pDoc->GetPattern(1,4,1);
Color aColor = static_cast<const SvxBrushItem&>(pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
commit 4efb3baa79ce596ffa990751eefdff9a11e42f01
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Tue Jun 12 04:46:29 2012 -0500
Add test case for row height to formats unit test
-Added test case for proper import height of first row with styles and text
(related to i53253).
Change-Id: I18eae540bbd388b3b703b4b113dad5745db53b0f
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 848c211..4d90a9f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -450,14 +450,20 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n
pPattern = pDoc->GetPattern(1,3,1);
pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
CPPUNIT_ASSERT_MESSAGE("font should be underlined with a dotted line", aFont.GetUnderline() == UNDERLINE_DOTTED);
+ //test case for proper import height of first row with styles and text (related to i53253)
+ sal_uInt16 nRowHeight = pDoc->GetRowHeight(0,1);
+ rtl::OString sRowHeight = rtl::OString::valueOf( static_cast<sal_Int32>(nRowHeight) );
+ rtl::OString aMsg1("Expected: 253; Actual: ");
+ aMsg1 += sRowHeight;
+ CPPUNIT_ASSERT_MESSAGE( aMsg1.pData->buffer, nRowHeight == 253 );
//test case for i53253 where a cell has text with different styles and space between the text.
rtl::OUString aTestOUStr;
pDoc->GetString(3,0,1, aTestOUStr);
rtl::OUString aKnownGoodOUStr("text14 space");
rtl::OString aTestOStr(rtl::OUStringToOString(aTestOUStr, RTL_TEXTENCODING_UTF8));
rtl::OString aKnownGoodOStr(rtl::OUStringToOString(aKnownGoodOUStr, RTL_TEXTENCODING_UTF8));
- rtl::OString aMsg("Expected: \"" + aKnownGoodOStr + "\"; Actual: \"" + aTestOStr + "\"");
- CPPUNIT_ASSERT_MESSAGE( aMsg.pData->buffer, aKnownGoodOUStr.equals(aTestOUStr) );
+ rtl::OString aMsg2("Expected: \"" + aKnownGoodOStr + "\"; Actual: \"" + aTestOStr + "\"");
+ CPPUNIT_ASSERT_MESSAGE( aMsg2.pData->buffer, aKnownGoodOUStr.equals(aTestOUStr) );
}
pPattern = pDoc->GetPattern(1,4,1);
Color aColor = static_cast<const SvxBrushItem&>(pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
commit 366b9a2296c53781854de066a66fba289a32f9b7
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Tue Jun 12 03:20:42 2012 -0500
Add test case for i53253 to formats unit test
-Added test case for i53253 where a cell has text with different styles and
space between the text.
Change-Id: I69afa689dcb28d15b22ebed2d97e4b60178d6101
diff --git a/sc/qa/unit/data/ods/formats.ods b/sc/qa/unit/data/ods/formats.ods
index 2fa9c13..c4c9ba8 100644
Binary files a/sc/qa/unit/data/ods/formats.ods and b/sc/qa/unit/data/ods/formats.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index ac3be48..848c211 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -441,7 +441,7 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n
pPattern = pDoc->GetPattern(1,1,1);
pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
CPPUNIT_ASSERT_MESSAGE("font should be striked out with a single line", aFont.GetStrikeout() == STRIKEOUT_SINGLE );
- //test double strikeout only for ods
+ //some tests on sheet2 only for ods
if (nFormat == ODS)
{
pPattern = pDoc->GetPattern(1,2,1);
@@ -450,6 +450,14 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n
pPattern = pDoc->GetPattern(1,3,1);
pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
CPPUNIT_ASSERT_MESSAGE("font should be underlined with a dotted line", aFont.GetUnderline() == UNDERLINE_DOTTED);
+ //test case for i53253 where a cell has text with different styles and space between the text.
+ rtl::OUString aTestOUStr;
+ pDoc->GetString(3,0,1, aTestOUStr);
+ rtl::OUString aKnownGoodOUStr("text14 space");
+ rtl::OString aTestOStr(rtl::OUStringToOString(aTestOUStr, RTL_TEXTENCODING_UTF8));
+ rtl::OString aKnownGoodOStr(rtl::OUStringToOString(aKnownGoodOUStr, RTL_TEXTENCODING_UTF8));
+ rtl::OString aMsg("Expected: \"" + aKnownGoodOStr + "\"; Actual: \"" + aTestOStr + "\"");
+ CPPUNIT_ASSERT_MESSAGE( aMsg.pData->buffer, aKnownGoodOUStr.equals(aTestOUStr) );
}
pPattern = pDoc->GetPattern(1,4,1);
Color aColor = static_cast<const SvxBrushItem&>(pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
More information about the Libreoffice-commits
mailing list