cid#1635773 Dereference after null check

and

cid#1635777 Dereference after null check

pass ScDocument& around when we know it can't be null,
drop mpDoc and redundant null checks

Change-Id: Ia7efe71c561ff084fbb2dc3cbabd02852a656099
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178046
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Caolán McNamara 2024-12-07 15:27:42 +00:00
parent b083e27de5
commit f74aa7c201
18 changed files with 679 additions and 715 deletions

View file

@ -28,8 +28,9 @@ using namespace xmloff::token;
namespace sc
{
SparklineGroupsExport::SparklineGroupsExport(ScXMLExport& rExport, SCTAB nTable)
: m_rExport(rExport)
SparklineGroupsExport::SparklineGroupsExport(ScDocument& rDoc, ScXMLExport& rExport, SCTAB nTable)
: m_rDoc(rDoc)
, m_rExport(rExport)
, m_nTable(nTable)
{
}
@ -62,12 +63,10 @@ void SparklineGroupsExport::insertBool(bool bValue, XMLTokenEnum eToken)
void SparklineGroupsExport::addSparklineAttributes(Sparkline const& rSparkline)
{
auto const* pDocument = m_rExport.GetDocument();
{
OUString sAddressString;
ScAddress aAddress(rSparkline.getColumn(), rSparkline.getRow(), m_nTable);
ScRangeStringConverter::GetStringFromAddress(sAddressString, aAddress, pDocument,
ScRangeStringConverter::GetStringFromAddress(sAddressString, aAddress, &m_rDoc,
formula::FormulaGrammar::CONV_OOO);
m_rExport.AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CELL_ADDRESS, sAddressString);
}
@ -75,7 +74,7 @@ void SparklineGroupsExport::addSparklineAttributes(Sparkline const& rSparkline)
{
OUString sDataRangeString;
ScRangeList const& rRangeList = rSparkline.getInputRange();
ScRangeStringConverter::GetStringFromRangeList(sDataRangeString, &rRangeList, pDocument,
ScRangeStringConverter::GetStringFromRangeList(sDataRangeString, &rRangeList, &m_rDoc,
formula::FormulaGrammar::CONV_OOO);
m_rExport.AddAttribute(XML_NAMESPACE_CALC_EXT, XML_DATA_RANGE, sDataRangeString);
}
@ -215,8 +214,7 @@ void SparklineGroupsExport::addSparklineGroup(
void SparklineGroupsExport::write()
{
auto* pDocument = m_rExport.GetDocument();
if (sc::SparklineList* pSparklineList = pDocument->GetSparklineList(m_nTable))
if (sc::SparklineList* pSparklineList = m_rDoc.GetSparklineList(m_nTable))
{
auto const aSparklineGroups = pSparklineList->getSparklineGroups();
if (!aSparklineGroups.empty())

View file

@ -29,6 +29,7 @@ namespace sc
/** Handle the export of sparkline groups and sparklines */
class SparklineGroupsExport
{
ScDocument& m_rDoc;
ScXMLExport& m_rExport;
SCTAB m_nTable;
@ -44,7 +45,7 @@ class SparklineGroupsExport
void insertBool(bool bValue, xmloff::token::XMLTokenEnum eToken);
public:
SparklineGroupsExport(ScXMLExport& rExport, SCTAB nTable);
SparklineGroupsExport(ScDocument& rDoc, ScXMLExport& rExport, SCTAB nTable);
void write();
};

View file

@ -42,12 +42,12 @@
using namespace ::com::sun::star;
using namespace xmloff::token;
ScChangeTrackingExportHelper::ScChangeTrackingExportHelper(ScXMLExport& rTempExport)
: rExport(rTempExport),
pChangeTrack(nullptr)
ScChangeTrackingExportHelper::ScChangeTrackingExportHelper(ScDocument& rDoc, ScXMLExport& rTempExport)
: m_rDoc(rDoc)
, rExport(rTempExport)
, pChangeTrack(nullptr)
{
ScDocument* pDoc = rExport.GetDocument();
pChangeTrack = pDoc ? pDoc->GetChangeTrack() : nullptr;
pChangeTrack = m_rDoc.GetChangeTrack();
}
ScChangeTrackingExportHelper::~ScChangeTrackingExportHelper()
@ -139,7 +139,7 @@ void ScChangeTrackingExportHelper::WriteGenerated(const ScChangeAction* pGenerat
#endif
SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_CELL_CONTENT_DELETION, true, true);
WriteBigRange(pGeneratedAction->GetBigRange(), XML_CELL_ADDRESS);
OUString sValue = static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewString(rExport.GetDocument());
OUString sValue = static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewString(&m_rDoc);
WriteCell(static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewCell(), sValue);
}
@ -157,7 +157,7 @@ void ScChangeTrackingExportHelper::WriteDeleted(const ScChangeAction* pDeletedAc
SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_CELL_CONTENT_DELETION, true, true);
if (static_cast<const ScChangeActionContent*>(pDeletedAction)->IsTopContent() && pDeletedAction->IsDeletedIn())
{
OUString sValue = pContentAction->GetNewString(rExport.GetDocument());
OUString sValue = pContentAction->GetNewString(&m_rDoc);
WriteCell(pContentAction->GetNewCell(), sValue);
}
}
@ -217,10 +217,9 @@ void ScChangeTrackingExportHelper::SetValueAttributes(const double& fValue, cons
{
sal_uInt32 nIndex = 0;
double fTempValue = 0.0;
ScDocument* pDoc = rExport.GetDocument();
if (pDoc && pDoc->GetFormatTable()->IsNumberFormat(sValue, nIndex, fTempValue))
if (m_rDoc.GetFormatTable()->IsNumberFormat(sValue, nIndex, fTempValue))
{
SvNumFormatType nType = pDoc->GetFormatTable()->GetType(nIndex);
SvNumFormatType nType = m_rDoc.GetFormatTable()->GetType(nIndex);
if (nType & SvNumFormatType::DEFINED)
nType &= ~SvNumFormatType::DEFINED;
switch(nType)
@ -289,7 +288,7 @@ void ScChangeTrackingExportHelper::WriteEditCell(const ScCellValue& rCell)
OUString sString;
if (rCell.getEditText())
sString = ScEditUtil::GetString(*rCell.getEditText(), rExport.GetDocument());
sString = ScEditUtil::GetString(*rCell.getEditText(), &m_rDoc);
rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING);
SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, true, true);
@ -305,15 +304,12 @@ void ScChangeTrackingExportHelper::WriteEditCell(const ScCellValue& rCell)
void ScChangeTrackingExportHelper::WriteFormulaCell(const ScCellValue& rCell, const OUString& sValue)
{
assert(rCell.getType() == CELLTYPE_FORMULA);
const ScDocument* pDoc = rExport.GetDocument();
if (!pDoc)
return;
ScFormulaCell* pFormulaCell = rCell.getFormula();
OUString sAddress;
ScRangeStringConverter::GetStringFromAddress(sAddress, pFormulaCell->aPos, pDoc, ::formula::FormulaGrammar::CONV_OOO);
ScRangeStringConverter::GetStringFromAddress(sAddress, pFormulaCell->aPos, &m_rDoc, ::formula::FormulaGrammar::CONV_OOO);
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_ADDRESS, sAddress);
const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
const formula::FormulaGrammar::Grammar eGrammar = m_rDoc.GetStorageGrammar();
sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
OUString sFormula = pFormulaCell->GetFormula(eGrammar);
ScMatrixMode nMatrixFlag(pFormulaCell->GetMatrixFlag());
@ -398,7 +394,7 @@ void ScChangeTrackingExportHelper::WriteContentChange(const ScChangeAction* pAct
if (pPrevAction)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(pPrevAction->GetActionNumber()));
SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_PREVIOUS, true, true);
OUString sValue = static_cast<const ScChangeActionContent*>(pAction)->GetOldString(rExport.GetDocument());
OUString sValue = static_cast<const ScChangeActionContent*>(pAction)->GetOldString(&m_rDoc);
WriteCell(static_cast<const ScChangeActionContent*>(pAction)->GetOldCell(), sValue);
}
}

View file

@ -29,6 +29,7 @@ class XText;
class ScChangeAction;
class ScChangeTrack;
class ScDocument;
class ScXMLExport;
struct ScCellValue;
class ScChangeActionDel;
@ -37,6 +38,7 @@ class ScEditEngineTextObj;
class ScChangeTrackingExportHelper
{
ScDocument& m_rDoc;
ScXMLExport& rExport;
ScChangeTrack* pChangeTrack;
@ -74,7 +76,7 @@ class ScChangeTrackingExportHelper
void WorkWithChangeAction(ScChangeAction* pAction);
public:
explicit ScChangeTrackingExportHelper(ScXMLExport& rExport);
explicit ScChangeTrackingExportHelper(ScDocument& rDoc, ScXMLExport& rExport);
~ScChangeTrackingExportHelper();
void CollectAutoStyles();

View file

@ -33,8 +33,9 @@
using namespace com::sun::star;
using namespace xmloff::token;
ScXMLExportDDELinks::ScXMLExportDDELinks(ScXMLExport& rTempExport)
: rExport(rTempExport)
ScXMLExportDDELinks::ScXMLExportDDELinks(ScDocument& rDoc, ScXMLExport& rTempExport)
: m_rDoc(rDoc)
, rExport(rTempExport)
{
}
@ -68,11 +69,7 @@ void ScXMLExportDDELinks::WriteCell(const ScMatrixValue& aVal, sal_Int32 nRepeat
void ScXMLExportDDELinks::WriteTable(const sal_Int32 nPos)
{
ScDocument* pDoc = rExport.GetDocument();
if (!pDoc)
return;
const ScMatrix* pMatrix = pDoc->GetDdeLinkResultMatrix(static_cast<sal_uInt16>(nPos));
const ScMatrix* pMatrix = m_rDoc.GetDdeLinkResultMatrix(static_cast<sal_uInt16>(nPos));
if (!pMatrix)
return;
@ -136,8 +133,7 @@ void ScXMLExportDDELinks::WriteDDELinks(const uno::Reference<sheet::XSpreadsheet
rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_DDE_ITEM, xDDELink->getItem());
rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_AUTOMATIC_UPDATE, XML_TRUE);
sal_uInt8 nMode;
ScDocument* pDoc = rExport.GetDocument();
if (pDoc && pDoc->GetDdeLinkMode(nDDELink, nMode))
if (m_rDoc.GetDdeLinkMode(nDDELink, nMode))
{
switch (nMode)
{

View file

@ -25,16 +25,18 @@ namespace com::sun::star::uno { template <class interface_type> class Reference;
namespace com::sun::star::sheet { class XSpreadsheetDocument; }
class ScXMLExport;
class ScDocument;
struct ScMatrixValue;
class ScXMLExportDDELinks
{
ScDocument& m_rDoc;
ScXMLExport& rExport;
void WriteCell(const ScMatrixValue& aVal, sal_Int32 nRepeat);
void WriteTable(const sal_Int32 nPos);
public:
explicit ScXMLExportDDELinks(ScXMLExport& rExport);
explicit ScXMLExportDDELinks(ScDocument& rDoc, ScXMLExport& rExport);
void WriteDDELinks(const css::uno::Reference < css::sheet::XSpreadsheetDocument >& xSpreadDoc);
};

View file

@ -57,8 +57,7 @@ using namespace com::sun::star;
using namespace xmloff::token;
ScXMLExportDataPilot::ScXMLExportDataPilot(ScXMLExport& rTempExport)
: rExport(rTempExport),
pDoc( nullptr )
: rExport(rTempExport)
{
}
@ -137,7 +136,7 @@ void ScXMLExportDataPilot::WriteDPCondition(const ScQueryEntry& aQueryEntry, boo
SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, true, true);
}
void ScXMLExportDataPilot::WriteDPFilter(const ScQueryParam& aQueryParam)
void ScXMLExportDataPilot::WriteDPFilter(ScDocument& rDoc, const ScQueryParam& aQueryParam)
{
SCSIZE nQueryEntryCount = aQueryParam.GetEntryCount();
if (nQueryEntryCount <= 0)
@ -177,7 +176,7 @@ void ScXMLExportDataPilot::WriteDPFilter(const ScQueryParam& aQueryParam)
ScRange aConditionRange(aQueryParam.nCol1, aQueryParam.nRow1, aQueryParam.nTab,
aQueryParam.nCol2, aQueryParam.nRow2, aQueryParam.nTab);
OUString sConditionRange;
ScRangeStringConverter::GetStringFromRange( sConditionRange, aConditionRange, pDoc, ::formula::FormulaGrammar::CONV_OOO );
ScRangeStringConverter::GetStringFromRange( sConditionRange, aConditionRange, &rDoc, ::formula::FormulaGrammar::CONV_OOO );
if (!sConditionRange.isEmpty())
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, sConditionRange);
}
@ -730,13 +729,9 @@ void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient
SvXMLElementExport aElemGrandTotal(rExport, XML_NAMESPACE_TABLE_EXT, XML_DATA_PILOT_GRAND_TOTAL, true, true);
}
void ScXMLExportDataPilot::WriteDataPilots()
void ScXMLExportDataPilot::WriteDataPilots(ScDocument& rDoc)
{
pDoc = rExport.GetDocument();
if (!pDoc)
return;
ScDPCollection* pDPs = pDoc->GetDPCollection();
ScDPCollection* pDPs = rDoc.GetDPCollection();
if (!pDPs)
return;
@ -754,8 +749,8 @@ void ScXMLExportDataPilot::WriteDataPilots()
ScRange aOutRange((*pDPs)[i].GetOutRange());
OUString sTargetRangeAddress;
ScRangeStringConverter::GetStringFromRange( sTargetRangeAddress, aOutRange, pDoc, ::formula::FormulaGrammar::CONV_OOO );
ScDocAttrIterator aAttrItr(*pDoc, aOutRange.aStart.Tab(),
ScRangeStringConverter::GetStringFromRange( sTargetRangeAddress, aOutRange, &rDoc, ::formula::FormulaGrammar::CONV_OOO );
ScDocAttrIterator aAttrItr(rDoc, aOutRange.aStart.Tab(),
aOutRange.aStart.Col(), aOutRange.aStart.Row(),
aOutRange.aEnd.Col(), aOutRange.aEnd.Row());
SCCOL nCol;
@ -771,7 +766,7 @@ void ScXMLExportDataPilot::WriteDataPilots()
{
ScAddress aButtonAddr(nCol, nButtonRow, aOutRange.aStart.Tab());
ScRangeStringConverter::GetStringFromAddress(
sOUButtonList, aButtonAddr, pDoc, ::formula::FormulaGrammar::CONV_OOO, ' ', true );
sOUButtonList, aButtonAddr, &rDoc, ::formula::FormulaGrammar::CONV_OOO, ' ', true );
}
}
pAttr = aAttrItr.GetNext(nCol, nRow1, nRow2);
@ -843,13 +838,13 @@ void ScXMLExportDataPilot::WriteDataPilots()
OUString sCellRangeAddress;
ScRangeStringConverter::GetStringFromRange(
sCellRangeAddress, pSheetSource->GetSourceRange(), pDoc,
sCellRangeAddress, pSheetSource->GetSourceRange(), &rDoc,
::formula::FormulaGrammar::CONV_OOO);
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sCellRangeAddress);
SvXMLElementExport aElemSCR(rExport, XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE, true, true);
rExport.CheckAttrList();
WriteDPFilter(pSheetSource->GetQueryParam());
WriteDPFilter(rDoc, pSheetSource->GetQueryParam());
}
else if ((*pDPs)[i].IsImportData())
{

View file

@ -42,12 +42,11 @@ struct ScQueryEntry;
class ScXMLExportDataPilot
{
ScXMLExport& rExport;
ScDocument* pDoc;
static OUString getDPOperatorXML(const ScQueryOp aFilterOperator, const utl::SearchParam::SearchType eSearchType);
void WriteDPCondition(const ScQueryEntry& aQueryEntry, bool bIsCaseSensitive,
utl::SearchParam::SearchType eSearchType);
void WriteDPFilter(const ScQueryParam& aQueryParam);
void WriteDPFilter(ScDocument& rDoc, const ScQueryParam& aQueryParam);
void WriteFieldReference(const ScDPSaveDimension* pDim);
void WriteSortInfo(const ScDPSaveDimension* pDim);
@ -68,7 +67,7 @@ class ScXMLExportDataPilot
public:
explicit ScXMLExportDataPilot(ScXMLExport& rExport);
void WriteDataPilots();
void WriteDataPilots(ScDocument& rDoc);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -55,7 +55,7 @@ constexpr OUString SC_USERLIST = u"UserList"_ustr;
using namespace com::sun::star;
using namespace xmloff::token;
void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange& aRange, const ScDocument* mpDoc)
void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange& aRange, const ScDocument& rDoc)
{
// Count sort items first.
size_t nSortCount = 0;
@ -78,7 +78,7 @@ void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange&
{
OUString aStr;
ScRangeStringConverter::GetStringFromAddress(
aStr, aOutPos, mpDoc, ::formula::FormulaGrammar::CONV_OOO);
aStr, aOutPos, &rDoc, ::formula::FormulaGrammar::CONV_OOO);
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, aStr);
}
@ -119,8 +119,7 @@ void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange&
}
ScXMLExportDatabaseRanges::ScXMLExportDatabaseRanges(ScXMLExport& rTempExport)
: rExport(rTempExport),
pDoc( nullptr )
: rExport(rTempExport)
{
}
@ -174,13 +173,13 @@ namespace {
class WriteDatabaseRange
{
ScXMLExport& mrExport;
ScDocument* mpDoc;
ScDocument& mrDoc;
sal_Int32 mnCounter;
ScDBCollection::RangeType meRangeType;
public:
WriteDatabaseRange(ScXMLExport& rExport, ScDocument* pDoc) :
mrExport(rExport), mpDoc(pDoc), mnCounter(0), meRangeType(ScDBCollection::GlobalNamed) {}
WriteDatabaseRange(ScXMLExport& rExport, ScDocument& rDoc) :
mrExport(rExport), mrDoc(rDoc), mnCounter(0), meRangeType(ScDBCollection::GlobalNamed) {}
void setRangeType(ScDBCollection::RangeType eNew)
{
@ -227,7 +226,7 @@ private:
rData.GetArea(aRange);
OUString aRangeStr;
ScRangeStringConverter::GetStringFromRange(
aRangeStr, aRange, mpDoc, ::formula::FormulaGrammar::CONV_OOO);
aRangeStr, aRange, &mrDoc, ::formula::FormulaGrammar::CONV_OOO);
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, aRangeStr);
// various boolean flags.
@ -271,7 +270,7 @@ private:
writeImport(rData);
writeFilter(rData);
writeSort(mrExport, aParam, aRange, mpDoc);
writeSort(mrExport, aParam, aRange, mrDoc);
writeSubtotals(rData);
}
@ -521,7 +520,7 @@ private:
{
OUString aAddrStr;
ScRangeStringConverter::GetStringFromAddress(
aAddrStr, ScAddress(aParam.nDestCol, aParam.nDestRow, aParam.nDestTab), mpDoc, ::formula::FormulaGrammar::CONV_OOO);
aAddrStr, ScAddress(aParam.nDestCol, aParam.nDestRow, aParam.nDestTab), &mrDoc, ::formula::FormulaGrammar::CONV_OOO);
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, aAddrStr);
}
@ -530,7 +529,7 @@ private:
{
OUString aAddrStr;
ScRangeStringConverter::GetStringFromRange(
aAddrStr, aAdvSource, mpDoc, ::formula::FormulaGrammar::CONV_OOO);
aAddrStr, aAdvSource, &mrDoc, ::formula::FormulaGrammar::CONV_OOO);
if (!aAddrStr.isEmpty())
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION_SOURCE_RANGE_ADDRESS, aAddrStr);
}
@ -703,18 +702,14 @@ private:
}
void ScXMLExportDatabaseRanges::WriteDatabaseRanges()
void ScXMLExportDatabaseRanges::WriteDatabaseRanges(ScDocument& rDoc)
{
pDoc = rExport.GetDocument();
if (!pDoc)
return;
// Get sheet-local anonymous ranges.
SCTAB nTabCount = pDoc->GetTableCount();
SCTAB nTabCount = rDoc.GetTableCount();
std::map<SCTAB, const ScDBData*> aSheetDBs;
for (SCTAB i = 0; i < nTabCount; ++i)
{
const ScDBData* p = pDoc->GetAnonymousDBData(i);
const ScDBData* p = rDoc.GetAnonymousDBData(i);
if (p)
aSheetDBs.emplace(i, p);
}
@ -722,7 +717,7 @@ void ScXMLExportDatabaseRanges::WriteDatabaseRanges()
bool bHasRanges = !aSheetDBs.empty();
// See if we have global ranges.
ScDBCollection* pDBCollection = pDoc->GetDBCollection();
ScDBCollection* pDBCollection = rDoc.GetDBCollection();
if (pDBCollection)
{
if (!pDBCollection->getNamedDBs().empty() || !pDBCollection->getAnonDBs().empty())
@ -735,7 +730,7 @@ void ScXMLExportDatabaseRanges::WriteDatabaseRanges()
SvXMLElementExport aElemDRs(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, true, true);
WriteDatabaseRange func(rExport, pDoc);
WriteDatabaseRange func(rExport, rDoc);
if (pDBCollection)
{

View file

@ -26,18 +26,17 @@ class ScXMLExport;
class ScDocument;
class ScMyEmptyDatabaseRangesContainer;
void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange& aRange,
const ScDocument* mpDoc);
void writeSort(ScXMLExport& rExport, const ScSortParam& rParam, const ScRange& rRange,
const ScDocument& rDoc);
class ScXMLExportDatabaseRanges
{
ScXMLExport& rExport;
ScDocument* pDoc;
public:
explicit ScXMLExportDatabaseRanges(ScXMLExport& rExport);
ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges();
void WriteDatabaseRanges();
void WriteDatabaseRanges(ScDocument& rDoc);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -568,7 +568,7 @@ void ScMyNotEmptyCellsIterator::UpdateAddress( ScAddress& rAddress )
}
}
void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, const ScAddress& rAddress )
void ScMyNotEmptyCellsIterator::SetCellData(ScDocument& rDoc, ScMyCell& rMyCell, const ScAddress& rAddress)
{
rMyCell.maBaseCell.clear();
rMyCell.aCellAddress = rAddress;
@ -603,7 +603,7 @@ void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, const ScAddress&
if (rMyCell.maBaseCell.getType() == CELLTYPE_FORMULA)
{
bool bIsMatrixBase = false;
if (rExport.IsMatrix(rMyCell.maCellAddress, rMyCell.aMatrixRange, bIsMatrixBase))
if (ScXMLExport::IsMatrix(rDoc, rMyCell.maCellAddress, rMyCell.aMatrixRange, bIsMatrixBase))
{
rMyCell.bIsMatrixBase = bIsMatrixBase;
rMyCell.bIsMatrixCovered = !bIsMatrixBase;
@ -611,10 +611,11 @@ void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, const ScAddress&
}
}
void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell)
//static
void ScMyNotEmptyCellsIterator::HasAnnotation(ScDocument& rDoc, ScMyCell& aCell)
{
aCell.bHasAnnotation = false;
ScPostIt* pNote = rExport.GetDocument()->GetNote(aCell.maCellAddress);
ScPostIt* pNote = rDoc.GetNote(aCell.maCellAddress);
if(pNote)
{
@ -623,7 +624,8 @@ void ScMyNotEmptyCellsIterator::HasAnnotation(ScMyCell& aCell)
}
}
void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
void ScMyNotEmptyCellsIterator::SetCurrentTable(ScDocument& rDoc,
const SCTAB nTable,
const uno::Reference<sheet::XSpreadsheet>& rxTable)
{
aLastAddress.SetRow( 0 );
@ -636,7 +638,7 @@ void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
mpCellItr.reset(
new ScHorizontalCellIterator(
*rExport.GetDocument(), nCurrentTable, 0, 0,
rDoc, nCurrentTable, 0, 0,
static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)),
static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable))));
@ -665,10 +667,9 @@ void ScMyNotEmptyCellsIterator::SkipTable(SCTAB nSkip)
pDetectiveOp->SkipTable(nSkip);
}
bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles)
bool ScMyNotEmptyCellsIterator::GetNext(ScDocument& rDoc, ScMyCell& aCell, ScFormatRangeStyles* pCellStyles)
{
ScDocument* pDoc = rExport.GetDocument();
ScAddress aAddress( pDoc->MaxCol() + 1, pDoc->MaxRow() + 1, nCurrentTable );
ScAddress aAddress( rDoc.MaxCol() + 1, rDoc.MaxRow() + 1, nCurrentTable );
UpdateAddress( aAddress );
@ -687,10 +688,10 @@ bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pC
if( pDetectiveOp )
pDetectiveOp->UpdateAddress( aAddress );
bool bFoundCell( ( aAddress.Col() <= pDoc->MaxCol() ) && ( aAddress.Row() <= pDoc->MaxRow() + 1 ) );
bool bFoundCell( ( aAddress.Col() <= rDoc.MaxCol() ) && ( aAddress.Row() <= rDoc.MaxRow() + 1 ) );
if( bFoundCell )
{
SetCellData( aCell, aAddress );
SetCellData(rDoc, aCell, aAddress);
if( pShapes )
pShapes->SetCellData( aCell );
if( pNoteShapes )
@ -706,7 +707,7 @@ bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pC
if( pDetectiveOp )
pDetectiveOp->SetCellData( aCell );
HasAnnotation( aCell );
HasAnnotation(rDoc, aCell);
bool bIsAutoStyle(false);
// Ranges before the previous cell are not needed by ExportFormatRanges anymore and can be removed
SCROW nRemoveBeforeRow = aLastAddress.Row();

View file

@ -335,9 +335,9 @@ class ScMyNotEmptyCellsIterator
SCTAB nCurrentTable;
void UpdateAddress( ScAddress& rAddress );
void SetCellData( ScMyCell& rMyCell, const ScAddress& rAddress );
void SetCellData(ScDocument& rDoc, ScMyCell& rMyCell, const ScAddress& rAddress);
void HasAnnotation( ScMyCell& aCell );
static void HasAnnotation(ScDocument& rDoc, ScMyCell& aCell);
public:
explicit ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
~ScMyNotEmptyCellsIterator();
@ -359,11 +359,11 @@ public:
void SetDetectiveOp(ScMyDetectiveOpContainer* pNewDetectiveOp)
{ pDetectiveOp = pNewDetectiveOp; }
void SetCurrentTable(const SCTAB nTable,
void SetCurrentTable(ScDocument& rDoc, const SCTAB nTable,
const css::uno::Reference<css::sheet::XSpreadsheet>& rxTable);
void SkipTable(SCTAB nSkip);
bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
bool GetNext(ScDocument& rDoc, ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -146,7 +146,7 @@ void ScMyValidationsContainer::AddValidation(const uno::Any& aTempAny,
}
}
OUString ScMyValidationsContainer::GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation)
OUString ScMyValidationsContainer::GetCondition(ScDocument& rDoc, ScXMLExport& rExport, const ScMyValidation& aValidation)
{
/* ATTENTION! Should the condition to not write sheet::ValidationType_ANY
* ever be changed, adapt the conditional call of
@ -252,12 +252,9 @@ OUString ScMyValidationsContainer::GetCondition(ScXMLExport& rExport, const ScMy
}
if (!sCondition.isEmpty())
{
if (ScDocument* pDoc = rExport.GetDocument())
{
const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
sCondition = rExport.GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sCondition, false );
}
const formula::FormulaGrammar::Grammar eGrammar = rDoc.GetStorageGrammar();
sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
sCondition = rExport.GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sCondition, false );
}
return sCondition;
@ -311,7 +308,7 @@ void ScMyValidationsContainer::WriteMessage(ScXMLExport& rExport,
}
}
void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
void ScMyValidationsContainer::WriteValidations(ScDocument& rDoc, ScXMLExport& rExport)
{
if (aValidationVec.empty())
return;
@ -320,7 +317,7 @@ void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
for (const auto& rValidation : aValidationVec)
{
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, rValidation.sName);
OUString sCondition(GetCondition(rExport, rValidation));
OUString sCondition(GetCondition(rDoc, rExport, rValidation));
if (!sCondition.isEmpty())
{
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION, sCondition);
@ -350,7 +347,7 @@ void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
}
}
}
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), rValidation.aBaseCell));
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(&rDoc, rValidation.aBaseCell));
SvXMLElementExport aElemV(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, true, true);
if (rValidation.bShowInputMessage || !rValidation.sInputMessage.isEmpty() || !rValidation.sInputTitle.isEmpty())
{

View file

@ -68,12 +68,12 @@ public:
~ScMyValidationsContainer();
void AddValidation(const css::uno::Any& aAny,
sal_Int32& nValidationIndex);
static OUString GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation);
static OUString GetCondition(ScDocument& rDoc, ScXMLExport& rExport, const ScMyValidation& aValidation);
static OUString GetBaseCellAddress(const ScDocument* pDoc, const ScAddress& aCell);
static void WriteMessage(ScXMLExport& rExport,
const OUString& sTitle, const OUString& sMessage,
const bool bShowMessage, const bool bIsHelpMessage);
void WriteValidations(ScXMLExport& rExport);
void WriteValidations(ScDocument& rDoc, ScXMLExport& rExport);
const OUString& GetValidationName(const sal_Int32 nIndex);
};

File diff suppressed because it is too large Load diff

View file

@ -71,7 +71,6 @@ class CompileFormulaContext;
class ScXMLExport : public SvXMLExport
{
ScDocument* mpDoc;
css::uno::Reference <css::sheet::XSpreadsheet> xCurrentTable;
css::uno::Reference<css::io::XInputStream> xSourceStream;
@ -138,11 +137,11 @@ class ScXMLExport : public SvXMLExport
virtual void ExportContent_() override;
virtual void ExportMeta_() override;
void CollectInternalShape( css::uno::Reference< css::drawing::XShape > const & xShape );
void CollectInternalShape(ScDocument& rDoc, css::uno::Reference< css::drawing::XShape > const & xShape);
static css::table::CellRangeAddress GetEndAddress(const css::uno::Reference<css::sheet::XSpreadsheet>& xTable);
ScMyAreaLinksContainer GetAreaLinks();
ScMyDetectiveOpContainer GetDetectiveOpList();
static ScMyAreaLinksContainer GetAreaLinks(ScDocument& rDoc);
ScMyDetectiveOpContainer GetDetectiveOpList(ScDocument& rDoc);
void WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex,
const sal_Int32 nIndex, const bool bIsAutoStyle, const bool bIsVisible);
void WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns,
@ -150,9 +149,9 @@ class ScXMLExport : public SvXMLExport
void OpenHeaderColumn();
void CloseHeaderColumn();
void ExportColumns(const sal_Int32 nTable, const ScRange& aColumnHeaderRange, const bool bHasColumnHeader);
void ExportExternalRefCacheStyles();
void ExportCellTextAutoStyles(sal_Int32 nTable);
void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
void ExportExternalRefCacheStyles(ScDocument& rDoc);
void ExportCellTextAutoStyles(ScDocument& rDoc, sal_Int32 nTable);
void ExportFormatRanges(ScDocument& rDoc, const sal_Int32 nStartCol, const sal_Int32 nStartRow,
const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet);
void WriteRowContent();
void WriteRowStartTag(const sal_Int32 nIndex, const sal_Int32 nEmptyRows, bool bHidden, bool bFiltered);
@ -164,43 +163,43 @@ class ScXMLExport : public SvXMLExport
bool bHidden, bool bFiltered);
void OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, const sal_Int32 nRepeatRow, ScXMLCachedRowAttrAccess& rRowAttr);
void CloseRow(const sal_Int32 nRow);
void GetColumnRowHeader(bool& bHasColumnHeader, ScRange& aColumnHeaderRange,
void GetColumnRowHeader(ScDocument& rDoc, bool& bHasColumnHeader, ScRange& aColumnHeaderRange,
bool& bHasRowHeader, ScRange& aRowHeaderRange, OUString& rPrintRanges) const;
static void FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRowGroup* pGroups);
void FillColumnRowGroups();
void FillColumnRowGroups(ScDocument& rDoc);
bool GetMerged (const css::table::CellRangeAddress* pCellRange,
const css::uno::Reference <css::sheet::XSpreadsheet>& xTable);
void WriteTable(sal_Int32 nTable, const css::uno::Reference< css::sheet::XSpreadsheet>& xTable);
void WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount);
void WriteEditCell(const EditTextObject* pText);
void WriteTable(ScDocument& rDoc, sal_Int32 nTable, const css::uno::Reference< css::sheet::XSpreadsheet>& xTable);
void WriteCell(ScDocument& rDoc, ScMyCell& aCell, sal_Int32 nEqualCellCount);
void WriteEditCell(ScDocument& rDoc, const EditTextObject* pText);
void WriteMultiLineFormulaResult(const ScFormulaCell* pCell);
void WriteAreaLink(const ScMyCell& rMyCell);
void WriteAnnotation(const ScMyCell& rMyCell);
void WriteDetective(const ScMyCell& rMyCell);
void ExportShape(const css::uno::Reference < css::drawing::XShape >& xShape, css::awt::Point* pPoint);
void WriteShapes(const ScMyCell& rMyCell);
void WriteTableShapes();
void WriteAnnotation(ScDocument& rDoc, const ScMyCell& rMyCell);
void WriteDetective(ScDocument& rDoc, const ScMyCell& rMyCell);
void ExportShape(ScDocument& rDoc, const css::uno::Reference < css::drawing::XShape >& xShape, css::awt::Point* pPoint);
void WriteShapes(ScDocument& rDoc, const ScMyCell& rMyCell);
void WriteTableShapes(ScDocument& rDoc);
void SetRepeatAttribute(sal_Int32 nEqualCellCount, bool bIncProgress);
static bool IsEditCell(const ScMyCell& rCell);
bool IsCellEqual(const ScMyCell& aCell1, const ScMyCell& aCell2);
static bool IsCellEqual(ScDocument& rDoc, const ScMyCell& aCell1, const ScMyCell& aCell2);
void WriteCalculationSettings(const css::uno::Reference <css::sheet::XSpreadsheetDocument>& xSpreadDoc);
void WriteCalculationSettings(ScDocument& rDoc, const css::uno::Reference <css::sheet::XSpreadsheetDocument>& xSpreadDoc);
void WriteTableSource();
void WriteScenario(); // core implementation
void WriteTheLabelRanges(const css::uno::Reference< css::sheet::XSpreadsheetDocument >& xSpreadDoc);
void WriteLabelRanges( const css::uno::Reference< css::container::XIndexAccess >& xRangesIAccess, bool bColumn );
void WriteNamedExpressions();
void WriteExternalDataMapping();
void WriteExternalDataTransformations(const std::vector<std::shared_ptr<sc::DataTransformation>>& aDataTransformations);
void WriteDataStream();
void WriteNamedRange(ScRangeName* pRangeName);
void exportSparklineGroups(SCTAB nTab);
void ExportConditionalFormat(SCTAB nTab);
void WriteExternalRefCaches();
void WriteConsolidation(); // core implementation
void WriteScenario(ScDocument& rDoc); // core implementation
void WriteTheLabelRanges(ScDocument& rDoc, const css::uno::Reference< css::sheet::XSpreadsheetDocument >& xSpreadDoc);
void WriteLabelRanges(ScDocument& rDoc, const css::uno::Reference< css::container::XIndexAccess >& xRangesIAccess, bool bColumn);
void WriteNamedExpressions(ScDocument& rDoc);
void WriteExternalDataMapping(ScDocument& rDoc);
void WriteExternalDataTransformations(ScDocument& rDoc, const std::vector<std::shared_ptr<sc::DataTransformation>>& rDataTransformations);
void WriteDataStream(ScDocument& rDoc);
void WriteNamedRange(ScDocument& rDoc, ScRangeName* pRangeName);
void exportSparklineGroups(ScDocument& rDoc, SCTAB nTab);
void ExportConditionalFormat(ScDocument& rDoc, SCTAB nTab);
void WriteExternalRefCaches(ScDocument& rDoc);
void WriteConsolidation(ScDocument& rDoc); // core implementation
void CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib);
@ -238,17 +237,16 @@ public:
void collectAutoStyles() override;
static sal_Int16 GetMeasureUnit();
SAL_RET_MAYBENULL ScDocument* GetDocument() { return mpDoc; }
SAL_RET_MAYBENULL const ScDocument* GetDocument() const { return mpDoc; }
bool IsMatrix (const ScAddress& aCell,
ScRange& aCellAddress, bool& bIsFirst) const;
SAL_RET_MAYBENULL ScDocument* GetDocument();
static bool IsMatrix (ScDocument& rDoc, const ScAddress& aCell,
ScRange& aCellAddress, bool& bIsFirst);
const rtl::Reference < XMLPropertySetMapper >& GetCellStylesPropertySetMapper() const { return xCellStylesPropertySetMapper; }
const rtl::Reference < XMLPropertySetMapper >& GetTableStylesPropertySetMapper() const { return xTableStylesPropertySetMapper; }
void SetSourceStream( const css::uno::Reference<css::io::XInputStream>& xNewStream );
void GetChangeTrackViewSettings(css::uno::Sequence<css::beans::PropertyValue>& rProps);
static void GetChangeTrackViewSettings(ScDocument& rDoc, css::uno::Sequence<css::beans::PropertyValue>& rProps);
virtual void GetViewSettings(css::uno::Sequence<css::beans::PropertyValue>& rProps) override;
virtual void GetConfigurationSettings(css::uno::Sequence<css::beans::PropertyValue>& rProps) override;

View file

@ -41,7 +41,7 @@ private:
void AddFontItems(const sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const bool bExportDefaults);
public:
ScXMLFontAutoStylePool_Impl( ScXMLExport& rExport, bool bEmbedFonts);
ScXMLFontAutoStylePool_Impl(ScDocument* pDoc, ScXMLExport& rExport, bool bEmbedFonts);
};
}
@ -71,10 +71,9 @@ void ScXMLFontAutoStylePool_Impl::AddFontItems(const sal_uInt16* pWhichIds, sal_
}
}
ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP, bool bEmbedFonts)
ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScDocument* pDoc, ScXMLExport& rExportP, bool bEmbedFonts)
: XMLFontAutoStylePool(rExportP, bEmbedFonts)
{
ScDocument* pDoc = rExportP.GetDocument();
if (!pDoc)
return;
@ -156,9 +155,10 @@ XMLFontAutoStylePool* ScXMLExport::CreateFontAutoStylePool()
// the embedding only in one of them.
if(!( getExportFlags() & SvXMLExportFlags::CONTENT ))
blockFontEmbedding = true;
if (mpDoc && !mpDoc->IsEmbedFonts())
ScDocument* pDoc = GetDocument();
if (pDoc && !pDoc->IsEmbedFonts())
blockFontEmbedding = true;
return new ScXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
return new ScXMLFontAutoStylePool_Impl(pDoc, *this, !blockFontEmbedding);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -710,6 +710,8 @@ void ScXMLAutoStylePoolP::exportStyleContent(
if (nFamily != XmlStyleFamily::TABLE_CELL)
return;
ScDocument* pDoc = rScXMLExport.GetDocument();
for(const auto& rProperty : rProperties)
{
if (rProperty.mnIndex != -1)
@ -743,7 +745,6 @@ void ScXMLAutoStylePoolP::exportStyleContent(
rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_CONDITION, sCondition);
rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_APPLY_STYLE_NAME, rScXMLExport.EncodeStyleName( sStyleName ));
OUString sOUBaseAddress;
ScDocument* pDoc = rScXMLExport.GetDocument();
ScRangeStringConverter::GetStringFromAddress( sOUBaseAddress,
xSheetCondition->getSourcePosition(), pDoc, FormulaGrammar::CONV_OOO );
rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_BASE_CELL_ADDRESS, sOUBaseAddress);
@ -798,7 +799,7 @@ void ScXMLAutoStylePoolP::exportStyleContent(
rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_APPLY_STYLE_NAME, rScXMLExport.EncodeStyleName( sStyleName ));
OUString sOUBaseAddress;
ScRangeStringConverter::GetStringFromAddress( sOUBaseAddress,
xSheetCondition->getSourcePosition(), rScXMLExport.GetDocument(), FormulaGrammar::CONV_OOO );
xSheetCondition->getSourcePosition(), pDoc, FormulaGrammar::CONV_OOO );
rScXMLExport.AddAttribute(XML_NAMESPACE_STYLE, XML_BASE_CELL_ADDRESS, sOUBaseAddress);
SvXMLElementExport aMElem(rScXMLExport, XML_NAMESPACE_STYLE, XML_MAP, true, true);
}