Kaydet (Commit) 38d13e70 authored tarafından Matúš Kukan's avatar Matúš Kukan

remove now unused ScMyDefaultStyles.maRowDefaults

Also adapt to GetColDefault() being always true.

Change-Id: I4701f02c540591b3d9f5095b22de82623c22c0db
üst ad737687
...@@ -454,121 +454,59 @@ const OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nInd ...@@ -454,121 +454,59 @@ const OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nInd
sal_Int32 ScMyDefaultStyles::GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles, sal_Int32 ScMyDefaultStyles::GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
const sal_Int32 nTable, const sal_Int32 nPos, const sal_Int32 nTable, const sal_Int32 nPos,
const sal_Int32 i, const bool bRow, bool& bIsAutoStyle) const sal_Int32 i, bool& bIsAutoStyle)
{ {
if (bRow) return pCellStyles->GetStyleNameIndex(nTable, i, nPos, bIsAutoStyle);
return pCellStyles->GetStyleNameIndex(nTable, nPos, i,
bIsAutoStyle);
else
return pCellStyles->GetStyleNameIndex(nTable, i, nPos,
bIsAutoStyle);
} }
void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable, void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
const sal_Int32 nLastRow, const sal_Int32 nLastCol, const sal_Int32 nLastRow, const sal_Int32 nLastCol,
const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc, const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc)
const bool bRow)
{ {
if (pDoc) maColDefaults.clear();
maColDefaults.resize(nLastCol + 1);
if (!pDoc)
return ;
SCTAB nTab = static_cast<SCTAB>(nTable);
sal_Int32 nPos;
ScMyDefaultStyleList* pDefaults = &maColDefaults;
bool bPrevAutoStyle(false);
bool bIsAutoStyle;
sal_Int32 nPrevIndex(0);
sal_Int32 nRepeat(0);
for (sal_Int32 i = nLastCol; i >= 0; --i)
{ {
SCTAB nTab = static_cast<SCTAB>(nTable); pDoc->GetColDefault(nTab, static_cast<SCCOL>(i), static_cast<SCROW>(nLastRow), nPos);
sal_Int32 nPos; if (!nRepeat)
sal_Int32 nLast;
ScMyDefaultStyleList* pDefaults;
if (bRow)
{ {
pDefaults = &maRowDefaults; nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i, bPrevAutoStyle);
nLast = nLastRow; (*pDefaults)[i].nIndex = nPrevIndex;
(*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
nRepeat = 1;
} }
else else
{ {
pDefaults = &maColDefaults; sal_Int32 nIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i, bIsAutoStyle);
nLast = nLastCol; if ((nIndex != nPrevIndex) || (bIsAutoStyle != bPrevAutoStyle))
}
bool bPrevAutoStyle(false);
bool bIsAutoStyle;
bool bResult;
sal_Int32 nPrevIndex(0);
sal_Int32 nIndex;
sal_Int32 nRepeat(0);
sal_Int32 nEmptyRepeat(0);
for (sal_Int32 i = nLast; i >= 0; --i)
{
if (bRow)
{
SCCOL nCol;
bResult = pDoc->GetRowDefault(nTab,
static_cast<SCROW>(i), static_cast<SCCOL>(nLastCol), nCol);
nPos = static_cast<sal_Int32>(nCol);
}
else
{ {
SCROW nRow; nRepeat = 1;
bResult = pDoc->GetColDefault(nTab, nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i, bPrevAutoStyle);
static_cast<SCCOL>(i), static_cast<SCROW>(nLastRow), nRow); (*pDefaults)[i].nIndex = nPrevIndex;
nPos = static_cast<sal_Int32>(nRow); (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
}
if (bResult)
{
nEmptyRepeat = 0;
if (!nRepeat)
{
nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
bRow, bPrevAutoStyle);
(*pDefaults)[i].nIndex = nPrevIndex;
(*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
nRepeat = 1;
}
else
{
nIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
bRow, bIsAutoStyle);
if ((nIndex != nPrevIndex) || (bIsAutoStyle != bPrevAutoStyle))
{
nRepeat = 1;
nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
bRow, bPrevAutoStyle);
(*pDefaults)[i].nIndex = nPrevIndex;
(*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
}
else
{
(*pDefaults)[i].nIndex = nPrevIndex;
(*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
++nRepeat;
if (nRepeat > 1)
(*pDefaults)[i].nRepeat = nRepeat;
}
}
} }
else else
{ {
nRepeat = 0; (*pDefaults)[i].nIndex = nPrevIndex;
if (!nEmptyRepeat) (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
nEmptyRepeat = 1; ++nRepeat;
else if (nRepeat > 1)
{ (*pDefaults)[i].nRepeat = nRepeat;
++nEmptyRepeat;
if (nEmptyRepeat > 1)
(*pDefaults)[i].nRepeat = nEmptyRepeat;
}
} }
} }
} }
} }
void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
const sal_Int32 nLastRow, const sal_Int32 nLastCol,
const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc)
{
maRowDefaults.clear();
maRowDefaults.resize(nLastRow + 1);
FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, true);
maColDefaults.clear();
maColDefaults.resize(nLastCol + 1);
FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, false);
}
ScMyRowFormatRange::ScMyRowFormatRange() ScMyRowFormatRange::ScMyRowFormatRange()
: nStartColumn(0), : nStartColumn(0),
nRepeatColumns(0), nRepeatColumns(0),
......
...@@ -115,23 +115,17 @@ class ScFormatRangeStyles; ...@@ -115,23 +115,17 @@ class ScFormatRangeStyles;
class ScMyDefaultStyles class ScMyDefaultStyles
{ {
ScMyDefaultStyleList maRowDefaults;
ScMyDefaultStyleList maColDefaults; ScMyDefaultStyleList maColDefaults;
sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles, sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
const sal_Int32 nTable, const sal_Int32 nPos, const sal_Int32 nTable, const sal_Int32 nPos,
const sal_Int32 i, const bool bRow, bool& bIsAutoStyle); const sal_Int32 i, bool& bIsAutoStyle);
void FillDefaultStyles(const sal_Int32 nTable,
const sal_Int32 nLastRow, const sal_Int32 nLastCol,
const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc,
const bool bRow);
public: public:
void FillDefaultStyles(const sal_Int32 nTable, void FillDefaultStyles(const sal_Int32 nTable,
const sal_Int32 nLastRow, const sal_Int32 nLastCol, const sal_Int32 nLastRow, const sal_Int32 nLastCol,
const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc); const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc);
const ScMyDefaultStyleList* GetRowDefaults() const { return &maRowDefaults; }
const ScMyDefaultStyleList* GetColDefaults() const { return &maColDefaults; } const ScMyDefaultStyleList* GetColDefaults() const { return &maColDefaults; }
}; };
......
...@@ -1440,7 +1440,7 @@ void ScXMLExport::WriteRowContent() ...@@ -1440,7 +1440,7 @@ void ScXMLExport::WriteRowContent()
} }
void ScXMLExport::WriteRowStartTag( void ScXMLExport::WriteRowStartTag(
sal_Int32 nRow, const sal_Int32 nIndex, const sal_Int32 nEqualRows, const sal_Int32 nIndex, const sal_Int32 nEqualRows,
bool bHidden, bool bFiltered) bool bHidden, bool bFiltered)
{ {
AddAttribute(sAttrStyleName, *pRowStyles->GetStyleNameByIndex(nIndex)); AddAttribute(sAttrStyleName, *pRowStyles->GetStyleNameByIndex(nIndex));
...@@ -1458,18 +1458,6 @@ void ScXMLExport::WriteRowStartTag( ...@@ -1458,18 +1458,6 @@ void ScXMLExport::WriteRowStartTag(
AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aBuf.makeStringAndClear()); AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aBuf.makeStringAndClear());
} }
const ScMyDefaultStyleList& rRowDefaults = *pDefaults->GetRowDefaults();
if ( nRow >= sal::static_int_cast<sal_Int32>( rRowDefaults.size() ) )
{
// used to happen with detective operations - if there are more cases, use the last row's style
OSL_FAIL("WriteRowStartTag: not enough defaults");
nRow = rRowDefaults.size() - 1;
}
sal_Int32 nCellStyleIndex(rRowDefaults[nRow].nIndex);
if (nCellStyleIndex != -1)
AddAttribute(XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME,
*pCellStyles->GetStyleNameByIndex(nCellStyleIndex,
(*pDefaults->GetRowDefaults())[nRow].bIsAutoStyle));
StartElement( sElemRow, true); StartElement( sElemRow, true);
} }
...@@ -1506,17 +1494,17 @@ void ScXMLExport::OpenNewRow( ...@@ -1506,17 +1494,17 @@ void ScXMLExport::OpenNewRow(
nEquals = aRowHeaderRange.EndRow - nStartRow + 1; nEquals = aRowHeaderRange.EndRow - nStartRow + 1;
else else
nEquals = nEqualRows; nEquals = nEqualRows;
WriteRowStartTag(nStartRow, nIndex, nEquals, bHidden, bFiltered); WriteRowStartTag(nIndex, nEquals, bHidden, bFiltered);
nOpenRow = nStartRow + nEquals - 1; nOpenRow = nStartRow + nEquals - 1;
if (nEquals < nEqualRows) if (nEquals < nEqualRows)
{ {
CloseRow(nStartRow + nEquals - 1); CloseRow(nStartRow + nEquals - 1);
WriteRowStartTag(nStartRow, nIndex, nEqualRows - nEquals, bHidden, bFiltered); WriteRowStartTag(nIndex, nEqualRows - nEquals, bHidden, bFiltered);
nOpenRow = nStartRow + nEqualRows - 1; nOpenRow = nStartRow + nEqualRows - 1;
} }
} }
else else
WriteRowStartTag(nStartRow, nIndex, nEqualRows, bHidden, bFiltered); WriteRowStartTag(nIndex, nEqualRows, bHidden, bFiltered);
} }
void ScXMLExport::OpenAndCloseRow( void ScXMLExport::OpenAndCloseRow(
......
...@@ -158,7 +158,7 @@ class ScXMLExport : public SvXMLExport ...@@ -158,7 +158,7 @@ class ScXMLExport : public SvXMLExport
void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow, void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet); const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet);
void WriteRowContent(); void WriteRowContent();
void WriteRowStartTag(sal_Int32 nRow, const sal_Int32 nIndex, const sal_Int32 nEmptyRows, bool bHidden, bool bFiltered); void WriteRowStartTag(const sal_Int32 nIndex, const sal_Int32 nEmptyRows, bool bHidden, bool bFiltered);
void OpenHeaderRows(); void OpenHeaderRows();
void CloseHeaderRows(); void CloseHeaderRows();
void OpenNewRow(const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEmptyRows, void OpenNewRow(const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEmptyRows,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment