summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-12-07 15:27:42 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-12-08 16:56:15 +0100
commitf74aa7c2012e1cb127292a44951647f85f5c4752 (patch)
tree255be0adc9a9579bcac68eb3f3632f43cc645683
parentb083e27de5e3cd7d46df089915572340325b2bd1 (diff)
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
-rw-r--r--sc/source/filter/xml/SparklineGroupsExport.cxx14
-rw-r--r--sc/source/filter/xml/SparklineGroupsExport.hxx3
-rw-r--r--sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx30
-rw-r--r--sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx4
-rw-r--r--sc/source/filter/xml/XMLExportDDELinks.cxx14
-rw-r--r--sc/source/filter/xml/XMLExportDDELinks.hxx4
-rw-r--r--sc/source/filter/xml/XMLExportDataPilot.cxx25
-rw-r--r--sc/source/filter/xml/XMLExportDataPilot.hxx5
-rw-r--r--sc/source/filter/xml/XMLExportDatabaseRanges.cxx35
-rw-r--r--sc/source/filter/xml/XMLExportDatabaseRanges.hxx7
-rw-r--r--sc/source/filter/xml/XMLExportIterator.cxx25
-rw-r--r--sc/source/filter/xml/XMLExportIterator.hxx8
-rw-r--r--sc/source/filter/xml/XMLStylesExportHelper.cxx17
-rw-r--r--sc/source/filter/xml/XMLStylesExportHelper.hxx4
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx1078
-rw-r--r--sc/source/filter/xml/xmlexprt.hxx70
-rw-r--r--sc/source/filter/xml/xmlfonte.cxx10
-rw-r--r--sc/source/filter/xml/xmlstyle.cxx5
18 files changed, 661 insertions, 697 deletions
diff --git a/sc/source/filter/xml/SparklineGroupsExport.cxx b/sc/source/filter/xml/SparklineGroupsExport.cxx
index 2048e421cb0d..2aecc4d01fcb 100644
--- a/sc/source/filter/xml/SparklineGroupsExport.cxx
+++ b/sc/source/filter/xml/SparklineGroupsExport.cxx
@@ -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())
diff --git a/sc/source/filter/xml/SparklineGroupsExport.hxx b/sc/source/filter/xml/SparklineGroupsExport.hxx
index a2ed4a8ef853..774fe084fa3c 100644
--- a/sc/source/filter/xml/SparklineGroupsExport.hxx
+++ b/sc/source/filter/xml/SparklineGroupsExport.hxx
@@ -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();
};
diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
index cdc9fe2419d5..83001f45aff9 100644
--- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
@@ -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);
}
}
diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx
index be721de62c24..e975953517aa 100644
--- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx
+++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx
@@ -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();
diff --git a/sc/source/filter/xml/XMLExportDDELinks.cxx b/sc/source/filter/xml/XMLExportDDELinks.cxx
index 1cb08d41c4b0..ce9bd6f4da4c 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.cxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.cxx
@@ -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)
{
diff --git a/sc/source/filter/xml/XMLExportDDELinks.hxx b/sc/source/filter/xml/XMLExportDDELinks.hxx
index 560f495877e0..98ce043bae43 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.hxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.hxx
@@ -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);
};
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 5161dede5137..b49bad992a42 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -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())
{
diff --git a/sc/source/filter/xml/XMLExportDataPilot.hxx b/sc/source/filter/xml/XMLExportDataPilot.hxx
index 04717aa10e1a..882ebc9c86c6 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.hxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.hxx
@@ -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: */
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 5deb8978da66..5089bea2ca6b 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -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)
{
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
index ed8f79497526..bc83cc6f182e 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
@@ -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: */
diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index 3283a743adcc..cb8934456ede 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -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();
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx
index f05e487b8d19..356429037eac 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -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: */
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index 57caeaf83665..9d81eb609436 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -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())
{
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.hxx b/sc/source/filter/xml/XMLStylesExportHelper.hxx
index dbfc12be1e70..a23c6b393ac5 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.hxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.hxx
@@ -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);
};
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index e13a3880a637..246a7fe8e3a1 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -210,20 +210,17 @@ OUString lcl_RangeSequenceToString(
return aResult.makeStringAndClear();
}
-OUString lcl_GetFormattedString(ScDocument* pDoc, const ScRefCellValue& rCell, const ScAddress& rAddr)
+OUString lcl_GetFormattedString(ScDocument& rDoc, const ScRefCellValue& rCell, const ScAddress& rAddr)
{
// return text/edit cell string content, with line feeds in edit cells
- if (!pDoc)
- return OUString();
-
switch (rCell.getType())
{
case CELLTYPE_STRING:
{
const Color* pColor;
- sal_uInt32 nFormat = pDoc->GetNumberFormat(ScRange(rAddr));
- return ScCellFormat::GetString(rCell, nFormat, &pColor, nullptr, *pDoc);
+ sal_uInt32 nFormat = rDoc.GetNumberFormat(ScRange(rAddr));
+ return ScCellFormat::GetString(rCell, nFormat, &pColor, nullptr, rDoc);
}
case CELLTYPE_EDIT:
{
@@ -231,7 +228,7 @@ OUString lcl_GetFormattedString(ScDocument* pDoc, const ScRefCellValue& rCell, c
if (!pData)
return OUString();
- EditEngine& rEngine = pDoc->GetEditEngine();
+ EditEngine& rEngine = rDoc.GetEditEngine();
rEngine.SetText(*pData);
return rEngine.GetText();
}
@@ -347,7 +344,6 @@ ScXMLExport::ScXMLExport(
OUString const & implementationName, SvXMLExportFlags nExportFlag)
: SvXMLExport(
rContext, implementationName, GetMeasureUnit(), XML_SPREADSHEET, nExportFlag ),
- mpDoc(nullptr),
nSourceStreamPos(0),
pCurrentCell(nullptr),
nOpenRow(-1),
@@ -480,6 +476,11 @@ sal_Int32 ScXMLExport::GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const
return itr->second;
}
+ScDocument* ScXMLExport::GetDocument()
+{
+ return ScXMLConverter::GetScDocument(GetModel());
+}
+
void ScXMLExport::CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount)
{
if (!GetModel().is())
@@ -497,6 +498,8 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount)
if (!pSharedData)
pSharedData.reset(new ScMySharedData(nTableCount));
+ ScDocument* pDoc = GetDocument();
+
for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
{
nCurrentTable = sal::static_int_cast<sal_uInt16>(nTable);
@@ -530,7 +533,8 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount)
if ((SdrLayerID(nLayerID) == SC_LAYER_INTERN) || (SdrLayerID(nLayerID) == SC_LAYER_HIDDEN))
{
- CollectInternalShape(xShape);
+ if (pDoc)
+ CollectInternalShape(*pDoc, xShape);
continue;
}
@@ -629,7 +633,8 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB nTableCount)
void ScXMLExport::ExportMeta_()
{
- sal_Int32 nCellCount(mpDoc ? mpDoc->GetCellCount() : 0);
+ ScDocument* pDoc = GetDocument();
+ sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0);
SCTAB nTableCount(0);
sal_Int32 nShapesCount(0);
GetAutoStylePool()->ClearEntries();
@@ -675,11 +680,10 @@ table::CellRangeAddress ScXMLExport::GetEndAddress(const uno::Reference<sheet::X
return aCellAddress;
}
-ScMyAreaLinksContainer ScXMLExport::GetAreaLinks()
+//static
+ScMyAreaLinksContainer ScXMLExport::GetAreaLinks(ScDocument& rDoc)
{
- if (!mpDoc)
- return {};
- sfx2::LinkManager* pManager = mpDoc->GetLinkManager();
+ sfx2::LinkManager* pManager = rDoc.GetLinkManager();
if (!pManager)
return {};
@@ -702,12 +706,9 @@ ScMyAreaLinksContainer ScXMLExport::GetAreaLinks()
}
// core implementation
-ScMyDetectiveOpContainer ScXMLExport::GetDetectiveOpList()
+ScMyDetectiveOpContainer ScXMLExport::GetDetectiveOpList(ScDocument& rDoc)
{
- if (!mpDoc)
- return {};
-
- ScDetOpList* pOpList(mpDoc->GetDetOpList());
+ ScDetOpList* pOpList(rDoc.GetDetOpList());
if( !pOpList )
return {};
@@ -718,7 +719,7 @@ ScMyDetectiveOpContainer ScXMLExport::GetDetectiveOpList()
const ScDetOpData& rDetData = pOpList->GetObject( nIndex);
const ScAddress& rDetPos = rDetData.GetPos();
SCTAB nTab = rDetPos.Tab();
- if ( nTab < mpDoc->GetTableCount() )
+ if ( nTab < rDoc.GetTableCount() )
{
aDetOp.push_back({ rDetPos, rDetData.GetOperation(), static_cast<sal_Int32>(nIndex) });
@@ -876,7 +877,7 @@ void ScXMLExport::ExportColumns(const sal_Int32 nTable, const ScRange& aColumnHe
pGroupColumns->CloseGroups(nColumn - 1);
}
-void ScXMLExport::ExportExternalRefCacheStyles()
+void ScXMLExport::ExportExternalRefCacheStyles(ScDocument& rDoc)
{
sal_Int32 nEntryIndex = GetCellStylesPropertySetMapper()->FindEntryIndex(
"NumberFormat", XML_NAMESPACE_STYLE, u"data-style-name");
@@ -885,10 +886,7 @@ void ScXMLExport::ExportExternalRefCacheStyles()
// No entry index for the number format is found.
return;
- if (!mpDoc)
- return;
-
- ScExternalRefManager* pRefMgr = mpDoc->GetExternalRefManager();
+ ScExternalRefManager* pRefMgr = rDoc.GetExternalRefManager();
if (!pRefMgr->hasExternalData())
// No external reference data cached.
return;
@@ -1253,19 +1251,16 @@ const SvxFieldData* toXMLPropertyStates(
}
-void ScXMLExport::ExportCellTextAutoStyles(sal_Int32 nTable)
+void ScXMLExport::ExportCellTextAutoStyles(ScDocument& rDoc, sal_Int32 nTable)
{
if (!ValidTab(nTable))
return;
- if (!mpDoc)
- return;
-
rtl::Reference<XMLPropertySetMapper> xMapper = GetTextParagraphExport()->GetTextPropMapper()->getPropertySetMapper();
rtl::Reference<SvXMLAutoStylePoolP> xStylePool = GetAutoStylePool();
const ScXMLEditAttributeMap& rAttrMap = GetEditAttributeMap();
- sc::EditTextIterator aIter(*mpDoc, nTable);
+ sc::EditTextIterator aIter(rDoc, nTable);
sal_Int32 nCellCount = 0;
for (const EditTextObject* pEdit = aIter.first(); pEdit; pEdit = aIter.next(), ++nCellCount)
{
@@ -1533,11 +1528,11 @@ void ScXMLExport::CloseRow(const sal_Int32 nRow)
nOpenRow = -1;
}
-void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
+void ScXMLExport::ExportFormatRanges(ScDocument& rDoc, const sal_Int32 nStartCol, const sal_Int32 nStartRow,
const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet)
{
pRowFormatRanges->Clear();
- ScXMLCachedRowAttrAccess aRowAttr(mpDoc);
+ ScXMLCachedRowAttrAccess aRowAttr(&rDoc);
if (nStartRow == nEndRow)
{
pCellStyles->GetFormatRanges(nStartCol, nEndCol, nStartRow, nSheet, pRowFormatRanges.get());
@@ -1621,7 +1616,7 @@ void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32
}
}
-void ScXMLExport::GetColumnRowHeader(bool& rHasColumnHeader, ScRange& rColumnHeaderRange,
+void ScXMLExport::GetColumnRowHeader(ScDocument& rDoc, bool& rHasColumnHeader, ScRange& rColumnHeaderRange,
bool& rHasRowHeader, ScRange& rRowHeaderRange,
OUString& rPrintRanges) const
{
@@ -1646,7 +1641,7 @@ void ScXMLExport::GetColumnRowHeader(bool& rHasColumnHeader, ScRange& rColumnHea
rTempColumnHeaderRange.EndRow,
rTempColumnHeaderRange.Sheet);
uno::Sequence< table::CellRangeAddress > aRangeList( xPrintAreas->getPrintAreas() );
- ScRangeStringConverter::GetStringFromRangeList( rPrintRanges, aRangeList, mpDoc, FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromRangeList( rPrintRanges, aRangeList, &rDoc, FormulaGrammar::CONV_OOO );
}
void ScXMLExport::FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRowGroup* pGroups)
@@ -1669,12 +1664,9 @@ void ScXMLExport::FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRow
pGroups->Sort();
}
-void ScXMLExport::FillColumnRowGroups()
+void ScXMLExport::FillColumnRowGroups(ScDocument& rDoc)
{
- if (!mpDoc)
- return;
-
- ScOutlineTable* pOutlineTable = mpDoc->GetOutlineTable( static_cast<SCTAB>(nCurrentTable) );
+ ScOutlineTable* pOutlineTable = rDoc.GetOutlineTable( static_cast<SCTAB>(nCurrentTable) );
if(pOutlineTable)
{
ScOutlineArray& rCols(pOutlineTable->GetColArray());
@@ -1688,14 +1680,15 @@ void ScXMLExport::FillColumnRowGroups()
void ScXMLExport::SetBodyAttributes()
{
- if (!(mpDoc && mpDoc->IsDocProtected()))
+ ScDocument* pDoc = GetDocument();
+ if (!(pDoc && pDoc->IsDocProtected()))
return;
AddAttribute(XML_NAMESPACE_TABLE, XML_STRUCTURE_PROTECTED, XML_TRUE);
OUStringBuffer aBuffer;
uno::Sequence<sal_Int8> aPassHash;
ScPasswordHash eHashUsed = PASSHASH_UNSPECIFIED;
- const ScDocProtection* p = mpDoc->GetDocProtection();
+ const ScDocProtection* p = pDoc->GetDocProtection();
if (p)
{
if (p->hasPasswordHash(PASSHASH_SHA1))
@@ -1888,7 +1881,16 @@ void ScXMLExport::ExportContent_()
if ( !xSpreadDoc.is() )
return;
- ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetSheetSaveData();
+ ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc);
+
+ ScDocument* pDoc = pModel->GetDocument();
+ if (!pDoc)
+ {
+ SAL_WARN("sc", "no ScDocument!");
+ return;
+ }
+
+ ScSheetSaveData* pSheetData = pModel->GetSheetSaveData();
if (pSheetData)
pSheetData->ResetSaveEntries();
@@ -1897,11 +1899,11 @@ void ScXMLExport::ExportContent_()
{
//_GetNamespaceMap().ClearQNamesCache();
pChangeTrackingExportHelper->CollectAndWriteChanges();
- WriteCalculationSettings(xSpreadDoc);
+ WriteCalculationSettings(*pDoc, xSpreadDoc);
sal_Int32 nTableCount(xIndex->getCount());
- ScMyAreaLinksContainer aAreaLinks = GetAreaLinks();
+ ScMyAreaLinksContainer aAreaLinks = GetAreaLinks(*pDoc);
ScMyEmptyDatabaseRangesContainer aEmptyRanges(aExportDatabaseRanges.GetEmptyDatabaseRanges());
- ScMyDetectiveOpContainer aDetectiveOpContainer = GetDetectiveOpList();
+ ScMyDetectiveOpContainer aDetectiveOpContainer = GetDetectiveOpList(*pDoc);
pMergedRangesContainer->Sort();
pSharedData->GetDetectiveObjContainer()->Sort();
@@ -1916,13 +1918,13 @@ void ScXMLExport::ExportContent_()
mpCellsItr->SetDetectiveOp( &aDetectiveOpContainer );
if (nTableCount > 0)
- pValidationsContainer->WriteValidations(*this);
- WriteTheLabelRanges( xSpreadDoc );
+ pValidationsContainer->WriteValidations(*pDoc, *this);
+ WriteTheLabelRanges(*pDoc, xSpreadDoc);
for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable)
{
sal_Int64 nStartOffset = -1;
sal_Int64 nEndOffset = -1;
- if (pSheetData && mpDoc && mpDoc->IsStreamValid(static_cast<SCTAB>(nTable)) && !mpDoc->GetChangeTrack())
+ if (pSheetData && pDoc->IsStreamValid(static_cast<SCTAB>(nTable)) && !pDoc->GetChangeTrack())
pSheetData->GetStreamPos( nTable, nStartOffset, nEndOffset );
if ( nStartOffset >= 0 && nEndOffset >= 0 && xSourceStream.is() )
@@ -1940,20 +1942,20 @@ void ScXMLExport::ExportContent_()
else
{
uno::Reference<sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
- WriteTable(nTable, xTable);
+ WriteTable(*pDoc, nTable, xTable);
}
IncrementProgressBar(false);
}
}
- WriteExternalRefCaches();
- WriteNamedExpressions();
- WriteDataStream();
- aExportDatabaseRanges.WriteDatabaseRanges();
- WriteExternalDataMapping();
+ WriteExternalRefCaches(*pDoc);
+ WriteNamedExpressions(*pDoc);
+ WriteDataStream(*pDoc);
+ aExportDatabaseRanges.WriteDatabaseRanges(*pDoc);
+ WriteExternalDataMapping(*pDoc);
ScXMLExportDataPilot aExportDataPilot(*this);
- aExportDataPilot.WriteDataPilots();
- WriteConsolidation();
- ScXMLExportDDELinks aExportDDELinks(*this);
+ aExportDataPilot.WriteDataPilots(*pDoc);
+ WriteConsolidation(*pDoc);
+ ScXMLExportDDELinks aExportDDELinks(*pDoc, *this);
aExportDDELinks.WriteDDELinks(xSpreadDoc);
IncrementProgressBar(true, 0);
GetProgressBarHelper()->SetValue(GetProgressBarHelper()->GetReference());
@@ -1999,7 +2001,11 @@ void ScXMLExport::exportTheme()
if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0)
return;
- SdrModel* pModel = mpDoc ? mpDoc->GetDrawLayer() : nullptr;
+ ScDocument* pDoc = GetDocument();
+ if (!pDoc)
+ return;
+
+ SdrModel* pModel = pDoc->GetDrawLayer();
if (!pModel)
return;
@@ -2265,241 +2271,246 @@ void ScXMLExport::collectAutoStyles()
// Reserve the loaded cell style names.
RegisterDefinedStyleNames( xSpreadDoc);
- // re-create automatic styles with old names from stored data
- ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetSheetSaveData();
- if (pSheetData && mpDoc)
+ ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc);
+ ScDocument* pDoc = pModel->GetDocument();
+ if (pDoc)
{
- // formulas have to be calculated now, to detect changed results
- // (during normal save, they will be calculated anyway)
- SCTAB nTabCount = mpDoc->GetTableCount();
- for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
- if (mpDoc->IsStreamValid(nTab))
- mpDoc->InterpretDirtyCells(ScRange(0, 0, nTab, mpDoc->MaxCol(), mpDoc->MaxRow(), nTab));
-
- // stored cell styles
- const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles();
- for (const auto& rCellEntry : rCellEntries)
+ // re-create automatic styles with old names from stored data
+ ScSheetSaveData* pSheetData = pModel->GetSheetSaveData();
+ if (pSheetData)
{
- ScAddress aPos = rCellEntry.maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
- if (bCopySheet)
+ // formulas have to be calculated now, to detect changed results
+ // (during normal save, they will be calculated anyway)
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->InterpretDirtyCells(ScRange(0, 0, nTab, pDoc->MaxCol(), pDoc->MaxRow(), nTab));
+
+ // stored cell styles
+ const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles();
+ for (const auto& rCellEntry : rCellEntries)
{
- uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
- uno::Reference <beans::XPropertySet> xProperties(
- xTable->getCellByPosition( aPos.Col(), aPos.Row() ), uno::UNO_QUERY );
+ ScAddress aPos = rCellEntry.maCellPos;
+ sal_Int32 nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ if (bCopySheet)
+ {
+ uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
+ uno::Reference <beans::XPropertySet> xProperties(
+ xTable->getCellByPosition( aPos.Col(), aPos.Row() ), uno::UNO_QUERY );
- AddStyleFromCells(xProperties, xTable, nTable, &rCellEntry.maName);
+ AddStyleFromCells(xProperties, xTable, nTable, &rCellEntry.maName);
+ }
}
- }
- // stored column styles
- const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->GetColumnStyles();
- for (const auto& rColumnEntry : rColumnEntries)
- {
- ScAddress aPos = rColumnEntry.maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
- if (bCopySheet)
+ // stored column styles
+ const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->GetColumnStyles();
+ for (const auto& rColumnEntry : rColumnEntries)
{
- uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
- uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
- uno::Reference<beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex( aPos.Col() ), uno::UNO_QUERY);
+ ScAddress aPos = rColumnEntry.maCellPos;
+ sal_Int32 nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ if (bCopySheet)
+ {
+ uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
+ uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
+ uno::Reference<beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex( aPos.Col() ), uno::UNO_QUERY);
- sal_Int32 nIndex(-1);
- bool bIsVisible(true);
- AddStyleFromColumn( xColumnProperties, &rColumnEntry.maName, nIndex, bIsVisible );
+ sal_Int32 nIndex(-1);
+ bool bIsVisible(true);
+ AddStyleFromColumn( xColumnProperties, &rColumnEntry.maName, nIndex, bIsVisible );
+ }
}
- }
- // stored row styles
- const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->GetRowStyles();
- for (const auto& rRowEntry : rRowEntries)
- {
- ScAddress aPos = rRowEntry.maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
- if (bCopySheet)
+ // stored row styles
+ const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->GetRowStyles();
+ for (const auto& rRowEntry : rRowEntries)
{
- uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
- uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
- uno::Reference<beans::XPropertySet> xRowProperties(xTableRows->getByIndex( aPos.Row() ), uno::UNO_QUERY);
+ ScAddress aPos = rRowEntry.maCellPos;
+ sal_Int32 nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ if (bCopySheet)
+ {
+ uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
+ uno::Reference<beans::XPropertySet> xRowProperties(xTableRows->getByIndex( aPos.Row() ), uno::UNO_QUERY);
- sal_Int32 nIndex(-1);
- AddStyleFromRow( xRowProperties, &rRowEntry.maName, nIndex );
+ sal_Int32 nIndex(-1);
+ AddStyleFromRow( xRowProperties, &rRowEntry.maName, nIndex );
+ }
}
- }
- // stored table styles
- const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->GetTableStyles();
- for (const auto& rTableEntry : rTableEntries)
- {
- ScAddress aPos = rTableEntry.maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
- if (bCopySheet)
+ // stored table styles
+ const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->GetTableStyles();
+ for (const auto& rTableEntry : rTableEntries)
{
- //! separate method AddStyleFromTable needed?
- uno::Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY);
- if (xTableProperties.is())
+ ScAddress aPos = rTableEntry.maCellPos;
+ sal_Int32 nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ if (bCopySheet)
{
- std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(*this, xTableProperties));
- OUString sName( rTableEntry.maName );
- GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TABLE_TABLE, OUString(), std::move(aPropStates));
- GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_TABLE, sName);
+ //! separate method AddStyleFromTable needed?
+ uno::Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY);
+ if (xTableProperties.is())
+ {
+ std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(*this, xTableProperties));
+ OUString sName( rTableEntry.maName );
+ GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TABLE_TABLE, OUString(), std::move(aPropStates));
+ GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_TABLE, sName);
+ }
}
}
- }
- // stored styles for notes
+ // stored styles for notes
- rtl::Reference<SvXMLExportPropertyMapper> xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this );
+ rtl::Reference<SvXMLExportPropertyMapper> xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this );
- const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles();
- for (const auto& rNoteEntry : rNoteEntries)
- {
- ScAddress aPos = rNoteEntry.maCellPos;
- SCTAB nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( nTable );
- if (bCopySheet)
+ const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles();
+ for (const auto& rNoteEntry : rNoteEntries)
{
- //! separate method AddStyleFromNote needed?
-
- ScPostIt* pNote = mpDoc->GetNote(aPos);
- OSL_ENSURE( pNote, "note not found" );
- if (pNote)
+ ScAddress aPos = rNoteEntry.maCellPos;
+ SCTAB nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( nTable );
+ if (bCopySheet)
{
- SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
- // all uno shapes are created anyway in CollectSharedData
- uno::Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY );
- if (xShapeProperties.is())
+ //! separate method AddStyleFromNote needed?
+
+ ScPostIt* pNote = pDoc->GetNote(aPos);
+ OSL_ENSURE( pNote, "note not found" );
+ if (pNote)
{
- if ( !rNoteEntry.maStyleName.isEmpty() )
+ SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
+ // all uno shapes are created anyway in CollectSharedData
+ uno::Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY );
+ if (xShapeProperties.is())
{
- std::vector<XMLPropertyState> aPropStates(xShapeMapper->Filter(*this, xShapeProperties));
- OUString sName( rNoteEntry.maStyleName );
- GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::SD_GRAPHICS_ID, OUString(), std::move(aPropStates));
- GetAutoStylePool()->RegisterName(XmlStyleFamily::SD_GRAPHICS_ID, sName);
- }
- if ( !rNoteEntry.maTextStyle.isEmpty() )
- {
- std::vector<XMLPropertyState> aPropStates(
- GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(*this, xShapeProperties));
- OUString sName( rNoteEntry.maTextStyle );
- GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), std::move(aPropStates));
- GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName);
+ if ( !rNoteEntry.maStyleName.isEmpty() )
+ {
+ std::vector<XMLPropertyState> aPropStates(xShapeMapper->Filter(*this, xShapeProperties));
+ OUString sName( rNoteEntry.maStyleName );
+ GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::SD_GRAPHICS_ID, OUString(), std::move(aPropStates));
+ GetAutoStylePool()->RegisterName(XmlStyleFamily::SD_GRAPHICS_ID, sName);
+ }
+ if ( !rNoteEntry.maTextStyle.isEmpty() )
+ {
+ std::vector<XMLPropertyState> aPropStates(
+ GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(*this, xShapeProperties));
+ OUString sName( rNoteEntry.maTextStyle );
+ GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), std::move(aPropStates));
+ GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName);
+ }
}
}
}
}
- }
- // note paragraph styles
+ // note paragraph styles
- rtl::Reference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper();
+ rtl::Reference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper();
- const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles();
- for (const auto& rNoteParaEntry : rNoteParaEntries)
- {
- ScAddress aPos = rNoteParaEntry.maCellPos;
- SCTAB nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( nTable );
- if (bCopySheet)
+ const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles();
+ for (const auto& rNoteParaEntry : rNoteParaEntries)
{
- ScPostIt* pNote = mpDoc->GetNote( aPos );
- OSL_ENSURE( pNote, "note not found" );
- if (pNote)
+ ScAddress aPos = rNoteParaEntry.maCellPos;
+ SCTAB nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( nTable );
+ if (bCopySheet)
{
- SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
- uno::Reference<container::XEnumerationAccess> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xParaProp(
- lcl_GetEnumerated( xCellText, rNoteParaEntry.maSelection.start.nPara ), uno::UNO_QUERY );
- if ( xParaProp.is() )
+ ScPostIt* pNote = pDoc->GetNote( aPos );
+ OSL_ENSURE( pNote, "note not found" );
+ if (pNote)
{
- std::vector<XMLPropertyState> aPropStates(xParaPropMapper->Filter(*this, xParaProp));
- OUString sName( rNoteParaEntry.maName );
- GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), std::move(aPropStates));
- GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName);
+ SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
+ uno::Reference<container::XEnumerationAccess> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xParaProp(
+ lcl_GetEnumerated( xCellText, rNoteParaEntry.maSelection.start.nPara ), uno::UNO_QUERY );
+ if ( xParaProp.is() )
+ {
+ std::vector<XMLPropertyState> aPropStates(xParaPropMapper->Filter(*this, xParaProp));
+ OUString sName( rNoteParaEntry.maName );
+ GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), std::move(aPropStates));
+ GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName);
+ }
}
}
}
- }
- // note text styles
+ // note text styles
- rtl::Reference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this );
+ rtl::Reference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this );
- const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles();
- for (const auto& rNoteTextEntry : rNoteTextEntries)
- {
- ScAddress aPos = rNoteTextEntry.maCellPos;
- SCTAB nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( nTable );
- if (bCopySheet)
+ const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles();
+ for (const auto& rNoteTextEntry : rNoteTextEntries)
{
- ScPostIt* pNote = mpDoc->GetNote( aPos );
- OSL_ENSURE( pNote, "note not found" );
- if (pNote)
+ ScAddress aPos = rNoteTextEntry.maCellPos;
+ SCTAB nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( nTable );
+ if (bCopySheet)
{
- SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
- uno::Reference<text::XSimpleText> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY);
- ScDrawTextCursor* pCursor = comphelper::getFromUnoTunnel<ScDrawTextCursor>( xCursorProp );
- if (pCursor)
+ ScPostIt* pNote = pDoc->GetNote( aPos );
+ OSL_ENSURE( pNote, "note not found" );
+ if (pNote)
{
- pCursor->SetSelection( rNoteTextEntry.maSelection );
+ SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
+ uno::Reference<text::XSimpleText> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY);
+ ScDrawTextCursor* pCursor = comphelper::getFromUnoTunnel<ScDrawTextCursor>( xCursorProp );
+ if (pCursor)
+ {
+ pCursor->SetSelection( rNoteTextEntry.maSelection );
- std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp));
- OUString sName( rNoteTextEntry.maName );
- GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), std::move(aPropStates));
- GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName);
+ std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp));
+ OUString sName( rNoteTextEntry.maName );
+ GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), std::move(aPropStates));
+ GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName);
+ }
}
}
}
- }
- // stored text styles
+ // stored text styles
- // Calling createTextCursor fires up editeng, which is very slow, and often subsequent style entries
- // refer to the same cell, so cache it.
- ScAddress aPrevPos;
- uno::Reference<beans::XPropertySet> xPrevCursorProp;
- const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles();
- for (const auto& rTextEntry : rTextEntries)
- {
- ScAddress aPos = rTextEntry.maCellPos;
- sal_Int32 nTable = aPos.Tab();
- bool bCopySheet = mpDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
- if (!bCopySheet)
- continue;
+ // Calling createTextCursor fires up editeng, which is very slow, and often subsequent style entries
+ // refer to the same cell, so cache it.
+ ScAddress aPrevPos;
+ uno::Reference<beans::XPropertySet> xPrevCursorProp;
+ const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles();
+ for (const auto& rTextEntry : rTextEntries)
+ {
+ ScAddress aPos = rTextEntry.maCellPos;
+ sal_Int32 nTable = aPos.Tab();
+ bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
+ if (!bCopySheet)
+ continue;
- //! separate method AddStyleFromText needed?
- //! cache sheet object
+ //! separate method AddStyleFromText needed?
+ //! cache sheet object
- uno::Reference<beans::XPropertySet> xCursorProp;
- if (xPrevCursorProp && aPrevPos == aPos)
- xCursorProp = xPrevCursorProp;
- else
- {
- uno::Reference<table::XCellRange> xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
- uno::Reference<text::XSimpleText> xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY);
- xCursorProp.set(xCellText->createTextCursor(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xCursorProp;
+ if (xPrevCursorProp && aPrevPos == aPos)
+ xCursorProp = xPrevCursorProp;
+ else
+ {
+ uno::Reference<table::XCellRange> xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
+ uno::Reference<text::XSimpleText> xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY);
+ xCursorProp.set(xCellText->createTextCursor(), uno::UNO_QUERY);
+ }
+ ScCellTextCursor* pCursor = comphelper::getFromUnoTunnel<ScCellTextCursor>( xCursorProp );
+ if (!pCursor)
+ continue;
+ pCursor->SetSelection( rTextEntry.maSelection );
+
+ std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp));
+ OUString sName( rTextEntry.maName );
+ GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), std::move(aPropStates));
+ GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName);
+ xPrevCursorProp = std::move(xCursorProp);
+ aPrevPos = aPos;
}
- ScCellTextCursor* pCursor = comphelper::getFromUnoTunnel<ScCellTextCursor>( xCursorProp );
- if (!pCursor)
- continue;
- pCursor->SetSelection( rTextEntry.maSelection );
-
- std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp));
- OUString sName( rTextEntry.maName );
- GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), std::move(aPropStates));
- GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName);
- xPrevCursorProp = std::move(xCursorProp);
- aPrevPos = aPos;
}
- }
- ExportExternalRefCacheStyles();
+ ExportExternalRefCacheStyles(*pDoc);
+ }
if (!pSharedData)
{
@@ -2552,72 +2563,75 @@ void ScXMLExport::collectAutoStyles()
}
}
}
- uno::Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY);
- if (xColumnRowRange.is() && mpDoc)
+ if (pDoc)
{
- mpDoc->SyncColRowFlags();
- uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
- if (xTableColumns.is())
+ uno::Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY);
+ if (xColumnRowRange.is())
{
- sal_Int32 nColumns(mpDoc->GetLastChangedColFlagsWidth(sal::static_int_cast<SCTAB>(nTable)));
- pSharedData->SetLastColumn(nTable, nColumns);
- table::CellRangeAddress aCellAddress(GetEndAddress(xTable));
- if (aCellAddress.EndColumn > nColumns)
- {
- ++nColumns;
- pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn);
- }
- else
- pColumnStyles->AddNewTable(nTable, nColumns);
- sal_Int32 nColumn = 0;
- while (nColumn <= mpDoc->MaxCol())
+ pDoc->SyncColRowFlags();
+ uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
+ if (xTableColumns.is())
{
- sal_Int32 nIndex(-1);
- bool bIsVisible(true);
- uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY);
- if (xColumnProperties.is())
+ sal_Int32 nColumns(pDoc->GetLastChangedColFlagsWidth(sal::static_int_cast<SCTAB>(nTable)));
+ pSharedData->SetLastColumn(nTable, nColumns);
+ table::CellRangeAddress aCellAddress(GetEndAddress(xTable));
+ if (aCellAddress.EndColumn > nColumns)
{
- AddStyleFromColumn( xColumnProperties, nullptr, nIndex, bIsVisible );
- pColumnStyles->AddFieldStyleName(nTable, nColumn, nIndex, bIsVisible);
+ ++nColumns;
+ pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn);
+ }
+ else
+ pColumnStyles->AddNewTable(nTable, nColumns);
+ sal_Int32 nColumn = 0;
+ while (nColumn <= pDoc->MaxCol())
+ {
+ sal_Int32 nIndex(-1);
+ bool bIsVisible(true);
+ uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY);
+ if (xColumnProperties.is())
+ {
+ AddStyleFromColumn( xColumnProperties, nullptr, nIndex, bIsVisible );
+ pColumnStyles->AddFieldStyleName(nTable, nColumn, nIndex, bIsVisible);
+ }
+ sal_Int32 nOld(nColumn);
+ nColumn = pDoc->GetNextDifferentChangedColFlagsWidth(sal::static_int_cast<SCTAB>(nTable), static_cast<SCCOL>(nColumn));
+ for (sal_Int32 i = nOld + 1; i < nColumn; ++i)
+ pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
+ }
+ if (aCellAddress.EndColumn > nColumns)
+ {
+ bool bIsVisible(true);
+ sal_Int32 nIndex(pColumnStyles->GetStyleNameIndex(nTable, nColumns, bIsVisible));
+ for (sal_Int32 i = nColumns + 1; i <= aCellAddress.EndColumn; ++i)
+ pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
}
- sal_Int32 nOld(nColumn);
- nColumn = mpDoc->GetNextDifferentChangedColFlagsWidth(sal::static_int_cast<SCTAB>(nTable), static_cast<SCCOL>(nColumn));
- for (sal_Int32 i = nOld + 1; i < nColumn; ++i)
- pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
}
- if (aCellAddress.EndColumn > nColumns)
+ uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
+ if (xTableRows.is())
{
- bool bIsVisible(true);
- sal_Int32 nIndex(pColumnStyles->GetStyleNameIndex(nTable, nColumns, bIsVisible));
- for (sal_Int32 i = nColumns + 1; i <= aCellAddress.EndColumn; ++i)
- pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
- }
- }
- uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
- if (xTableRows.is())
- {
- sal_Int32 nRows(mpDoc->GetLastChangedRowFlagsWidth(sal::static_int_cast<SCTAB>(nTable)));
- pSharedData->SetLastRow(nTable, nRows);
+ sal_Int32 nRows(pDoc->GetLastChangedRowFlagsWidth(sal::static_int_cast<SCTAB>(nTable)));
+ pSharedData->SetLastRow(nTable, nRows);
- pRowStyles->AddNewTable(nTable, mpDoc->MaxRow());
- sal_Int32 nRow = 0;
- while (nRow <= mpDoc->MaxRow())
- {
- sal_Int32 nIndex = 0;
- uno::Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY);
- if(xRowProperties.is())
+ pRowStyles->AddNewTable(nTable, pDoc->MaxRow());
+ sal_Int32 nRow = 0;
+ while (nRow <= pDoc->MaxRow())
{
- AddStyleFromRow( xRowProperties, nullptr, nIndex );
- pRowStyles->AddFieldStyleName(nTable, nRow, nIndex);
+ sal_Int32 nIndex = 0;
+ uno::Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY);
+ if(xRowProperties.is())
+ {
+ AddStyleFromRow( xRowProperties, nullptr, nIndex );
+ pRowStyles->AddFieldStyleName(nTable, nRow, nIndex);
+ }
+ sal_Int32 nOld(nRow);
+ nRow = pDoc->GetNextDifferentChangedRowFlagsWidth(sal::static_int_cast<SCTAB>(nTable), static_cast<SCROW>(nRow));
+ if (nRow > nOld + 1)
+ pRowStyles->AddFieldStyleName(nTable, nOld + 1, nIndex, nRow - 1);
}
- sal_Int32 nOld(nRow);
- nRow = mpDoc->GetNextDifferentChangedRowFlagsWidth(sal::static_int_cast<SCTAB>(nTable), static_cast<SCROW>(nRow));
- if (nRow > nOld + 1)
- pRowStyles->AddFieldStyleName(nTable, nOld + 1, nIndex, nRow - 1);
}
}
+ ExportCellTextAutoStyles(*pDoc, nTable);
}
- ExportCellTextAutoStyles(nTable);
}
pChangeTrackingExportHelper->CollectAutoStyles();
@@ -2656,9 +2670,9 @@ void ScXMLExport::ExportAutoStyles_()
GetShapeExport()->exportAutoStyles();
GetFormExport()->exportAutoStyles( );
- if (mpDoc)
+ if (ScDocument* pDoc = GetDocument())
{
- ScExternalRefManager* pRefMgr = mpDoc->GetExternalRefManager();
+ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
// #i100879# write the table style for cached tables only if there are cached tables
// (same logic as in ExportExternalRefCacheStyles)
if (pRefMgr->hasExternalData())
@@ -2691,20 +2705,17 @@ void ScXMLExport::ExportMasterStyles_()
GetPageExport()->exportMasterStyles( false );
}
-void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > const & xShape )
+void ScXMLExport::CollectInternalShape(ScDocument& rDoc, uno::Reference< drawing::XShape > const & xShape )
{
// detective objects and notes
SdrObject* pObject = SdrObject::getSdrObjectFromXShape( xShape );
if( !pObject )
return;
- if (!mpDoc)
- return;
-
// collect note caption objects from all layers (internal or hidden)
if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, static_cast< SCTAB >( nCurrentTable ) ) )
{
- if(mpDoc->GetNote(pCaptData->maStart))
+ if (rDoc.GetNote(pCaptData->maStart))
{
pSharedData->AddNoteObj( xShape, pCaptData->maStart );
@@ -2718,7 +2729,7 @@ void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > const
// other objects from internal layer only (detective)
else if( pObject->GetLayer() == SC_LAYER_INTERN )
{
- ScDetectiveFunc aDetFunc( *mpDoc, static_cast<SCTAB>(nCurrentTable) );
+ ScDetectiveFunc aDetFunc(rDoc, static_cast<SCTAB>(nCurrentTable));
ScAddress aPosition;
ScRange aSourceRange;
bool bRedLine;
@@ -2790,14 +2801,15 @@ bool ScXMLExport::GetMerged (const table::CellRangeAddress* pCellAddress,
return !bReady;
}
-bool ScXMLExport::IsMatrix (const ScAddress& aCell,
- ScRange& aCellAddress, bool& bIsFirst) const
+//static
+bool ScXMLExport::IsMatrix (ScDocument& rDoc, const ScAddress& aCell,
+ ScRange& aCellAddress, bool& bIsFirst)
{
bIsFirst = false;
ScRange aMatrixRange;
- if (mpDoc && mpDoc->GetMatrixFormulaRange(aCell, aMatrixRange))
+ if (rDoc.GetMatrixFormulaRange(aCell, aMatrixRange))
{
aCellAddress = aMatrixRange;
if ((aCellAddress.aStart.Col() == aCell.Col() && aCellAddress.aStart.Row() == aCell.Row()) &&
@@ -2819,7 +2831,7 @@ bool ScXMLExport::IsMatrix (const ScAddress& aCell,
return false;
}
-void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpreadsheet>& xTable)
+void ScXMLExport::WriteTable(ScDocument& rDoc, sal_Int32 nTable, const uno::Reference<sheet::XSpreadsheet>& xTable)
{
if (!xTable.is())
return;
@@ -2839,55 +2851,52 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
if (xProtectable.is() && xProtectable->isProtected())
{
AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE);
- if (mpDoc)
+ pProtect = rDoc.GetTabProtection(nTable);
+ if (pProtect)
{
- pProtect = mpDoc->GetTabProtection(nTable);
- if (pProtect)
+ OUStringBuffer aBuffer;
+ ScPasswordHash eHashUsed = PASSHASH_UNSPECIFIED;
+ if (pProtect->hasPasswordHash(PASSHASH_SHA1))
{
- OUStringBuffer aBuffer;
- ScPasswordHash eHashUsed = PASSHASH_UNSPECIFIED;
- if (pProtect->hasPasswordHash(PASSHASH_SHA1))
- {
- ::comphelper::Base64::encode(aBuffer,
- pProtect->getPasswordHash(PASSHASH_SHA1));
- eHashUsed = PASSHASH_SHA1;
- }
- else if (pProtect->hasPasswordHash(PASSHASH_SHA256))
- {
- ::comphelper::Base64::encode(aBuffer,
- pProtect->getPasswordHash(PASSHASH_SHA256));
- eHashUsed = PASSHASH_SHA256;
- }
- else if (pProtect->hasPasswordHash(PASSHASH_XL, PASSHASH_SHA1))
- {
- // Double-hash this by SHA1 on top of the legacy xls hash.
- uno::Sequence<sal_Int8> aHash = pProtect->getPasswordHash(PASSHASH_XL, PASSHASH_SHA1);
- ::comphelper::Base64::encode(aBuffer, aHash);
- eHashUsed = PASSHASH_XL;
- }
- if (!aBuffer.isEmpty())
+ ::comphelper::Base64::encode(aBuffer,
+ pProtect->getPasswordHash(PASSHASH_SHA1));
+ eHashUsed = PASSHASH_SHA1;
+ }
+ else if (pProtect->hasPasswordHash(PASSHASH_SHA256))
+ {
+ ::comphelper::Base64::encode(aBuffer,
+ pProtect->getPasswordHash(PASSHASH_SHA256));
+ eHashUsed = PASSHASH_SHA256;
+ }
+ else if (pProtect->hasPasswordHash(PASSHASH_XL, PASSHASH_SHA1))
+ {
+ // Double-hash this by SHA1 on top of the legacy xls hash.
+ uno::Sequence<sal_Int8> aHash = pProtect->getPasswordHash(PASSHASH_XL, PASSHASH_SHA1);
+ ::comphelper::Base64::encode(aBuffer, aHash);
+ eHashUsed = PASSHASH_XL;
+ }
+ if (!aBuffer.isEmpty())
+ {
+ AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear());
+ if (getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
{
- AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear());
- if (getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
+ if (eHashUsed == PASSHASH_XL)
{
- if (eHashUsed == PASSHASH_XL)
- {
- AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
- ScPassHashHelper::getHashURI(PASSHASH_XL));
- if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
- AddAttribute(XML_NAMESPACE_LO_EXT, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
- ScPassHashHelper::getHashURI(PASSHASH_SHA1));
- }
- else if (eHashUsed == PASSHASH_SHA1)
- {
- AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
- ScPassHashHelper::getHashURI(PASSHASH_SHA1));
- }
- else if (eHashUsed == PASSHASH_SHA256)
- {
- AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
- ScPassHashHelper::getHashURI(PASSHASH_SHA256));
- }
+ AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+ ScPassHashHelper::getHashURI(PASSHASH_XL));
+ if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
+ AddAttribute(XML_NAMESPACE_LO_EXT, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
+ ScPassHashHelper::getHashURI(PASSHASH_SHA1));
+ }
+ else if (eHashUsed == PASSHASH_SHA1)
+ {
+ AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+ ScPassHashHelper::getHashURI(PASSHASH_SHA1));
+ }
+ else if (eHashUsed == PASSHASH_SHA256)
+ {
+ AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
+ ScPassHashHelper::getHashURI(PASSHASH_SHA256));
}
}
}
@@ -2896,10 +2905,10 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
OUString sPrintRanges;
ScRange aColumnHeaderRange;
bool bHasColumnHeader;
- GetColumnRowHeader(bHasColumnHeader, aColumnHeaderRange, bHasRowHeader, aRowHeaderRange, sPrintRanges);
+ GetColumnRowHeader(rDoc, bHasColumnHeader, aColumnHeaderRange, bHasRowHeader, aRowHeaderRange, sPrintRanges);
if( !sPrintRanges.isEmpty() )
AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT_RANGES, sPrintRanges );
- else if (mpDoc && !mpDoc->IsPrintEntireSheet(static_cast<SCTAB>(nTable)))
+ else if (!rDoc.IsPrintEntireSheet(static_cast<SCTAB>(nTable)))
AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT, XML_FALSE);
SvXMLElementExport aElemT(*this, sElemTab, true, true);
@@ -2933,7 +2942,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
CheckAttrList();
- if ( mpDoc && mpDoc->GetSheetEvents( static_cast<SCTAB>(nTable) ) &&
+ if (rDoc.GetSheetEvents( static_cast<SCTAB>(nTable) ) &&
getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
{
// store sheet events
@@ -2943,7 +2952,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
}
WriteTableSource();
- WriteScenario();
+ WriteScenario(rDoc);
uno::Reference<drawing::XDrawPage> xDrawPage;
if (pSharedData->HasForm(nTable, xDrawPage) && xDrawPage.is())
{
@@ -2955,22 +2964,22 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
if (pSharedData->HasDrawPage())
{
GetShapeExport()->seekShapes(pSharedData->GetDrawPage(nTable));
- WriteTableShapes();
+ WriteTableShapes(rDoc);
}
table::CellRangeAddress aRange(GetEndAddress(xTable));
pSharedData->SetLastColumn(nTable, aRange.EndColumn);
pSharedData->SetLastRow(nTable, aRange.EndRow);
- mpCellsItr->SetCurrentTable(static_cast<SCTAB>(nTable), xCurrentTable);
+ mpCellsItr->SetCurrentTable(rDoc, static_cast<SCTAB>(nTable), xCurrentTable);
pGroupColumns->NewTable();
pGroupRows->NewTable();
- FillColumnRowGroups();
+ FillColumnRowGroups(rDoc);
if (bHasColumnHeader)
pSharedData->SetLastColumn(nTable, aColumnHeaderRange.aEnd.Col());
bRowHeaderOpen = false;
if (bHasRowHeader)
pSharedData->SetLastRow(nTable, aRowHeaderRange.aEnd.Row());
pDefaults->FillDefaultStyles(nTable, pSharedData->GetLastRow(nTable),
- pSharedData->GetLastColumn(nTable), pCellStyles.get(), mpDoc);
+ pSharedData->GetLastColumn(nTable), pCellStyles.get(), &rDoc);
pRowFormatRanges->SetColDefaults(&pDefaults->GetColDefaults());
pCellStyles->SetColDefaults(&pDefaults->GetColDefaults());
ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader);
@@ -2978,11 +2987,11 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
sal_Int32 nEqualCells(0);
ScMyCell aCell;
ScMyCell aPrevCell;
- while (mpCellsItr->GetNext(aCell, pCellStyles.get()))
+ while (mpCellsItr->GetNext(rDoc, aCell, pCellStyles.get()))
{
if (bIsFirst)
{
- ExportFormatRanges(0, 0, aCell.maCellAddress.Col()-1, aCell.maCellAddress.Row(), nTable);
+ ExportFormatRanges(rDoc, 0, 0, aCell.maCellAddress.Col()-1, aCell.maCellAddress.Row(), nTable);
aPrevCell = aCell;
bIsFirst = false;
}
@@ -2991,19 +3000,19 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
if ((aPrevCell.maCellAddress.Row() == aCell.maCellAddress.Row()) &&
(aPrevCell.maCellAddress.Col() + nEqualCells + 1 == aCell.maCellAddress.Col()))
{
- if(IsCellEqual(aPrevCell, aCell))
+ if (IsCellEqual(rDoc, aPrevCell, aCell))
++nEqualCells;
else
{
- WriteCell(aPrevCell, nEqualCells);
+ WriteCell(rDoc, aPrevCell, nEqualCells);
nEqualCells = 0;
aPrevCell = aCell;
}
}
else
{
- WriteCell(aPrevCell, nEqualCells);
- ExportFormatRanges(aPrevCell.maCellAddress.Col() + nEqualCells + 1, aPrevCell.maCellAddress.Row(),
+ WriteCell(rDoc, aPrevCell, nEqualCells);
+ ExportFormatRanges(rDoc, aPrevCell.maCellAddress.Col() + nEqualCells + 1, aPrevCell.maCellAddress.Row(),
aCell.maCellAddress.Col()-1, aCell.maCellAddress.Row(), nTable);
nEqualCells = 0;
aPrevCell = aCell;
@@ -3012,37 +3021,34 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
}
if (!bIsFirst)
{
- WriteCell(aPrevCell, nEqualCells);
- ExportFormatRanges(aPrevCell.maCellAddress.Col() + nEqualCells + 1, aPrevCell.maCellAddress.Row(),
+ WriteCell(rDoc, aPrevCell, nEqualCells);
+ ExportFormatRanges(rDoc, aPrevCell.maCellAddress.Col() + nEqualCells + 1, aPrevCell.maCellAddress.Row(),
pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable);
}
else
- ExportFormatRanges(0, 0, pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable);
+ ExportFormatRanges(rDoc, 0, 0, pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable);
CloseRow(pSharedData->GetLastRow(nTable));
- if (!mpDoc)
- return;
-
// Export sheet-local named ranges.
- ScRangeName* pRangeName = mpDoc->GetRangeName(nTable);
+ ScRangeName* pRangeName = rDoc.GetRangeName(nTable);
if (pRangeName && !pRangeName->empty())
{
- WriteNamedRange(pRangeName);
+ WriteNamedRange(rDoc, pRangeName);
}
if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
{
//export new conditional format information
- ExportConditionalFormat(nTable);
- exportSparklineGroups(nTable);
+ ExportConditionalFormat(rDoc, nTable);
+ exportSparklineGroups(rDoc, nTable);
}
}
namespace {
-void writeContent(
- ScXMLExport& rExport, const OUString& rStyleName, const OUString& rContent, const SvxFieldData* pField )
+void writeContent(ScDocument& rDoc, ScXMLExport& rExport, const OUString& rStyleName,
+ const OUString& rContent, const SvxFieldData* pField)
{
std::unique_ptr<SvXMLElementExport> pElem;
if (!rStyleName.isEmpty())
@@ -3057,7 +3063,7 @@ void writeContent(
if (pField)
{
// Write a field item.
- OUString aFieldVal = ScEditUtil::GetCellFieldValue(*pField, rExport.GetDocument(), nullptr, nullptr);
+ OUString aFieldVal = ScEditUtil::GetCellFieldValue(*pField, &rDoc, nullptr, nullptr);
switch (pField->GetClassId())
{
case text::textfield::Type::URL:
@@ -3132,6 +3138,7 @@ void writeContent(
}
void flushParagraph(
+ ScDocument& rDoc,
ScXMLExport& rExport, std::u16string_view rParaText,
rtl::Reference<XMLPropertySetMapper> const & xMapper, rtl::Reference<SvXMLAutoStylePoolP> const & xStylePool,
const ScXMLEditAttributeMap& rAttrMap,
@@ -3167,13 +3174,13 @@ void flushParagraph(
}
}
else
- writeContent(rExport, aStyleName, aContent, pField);
+ writeContent(rDoc, rExport, aStyleName, aContent, pField);
}
}
}
-void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
+void ScXMLExport::WriteCell(ScDocument& rDoc, ScMyCell& aCell, sal_Int32 nEqualCellCount)
{
// nEqualCellCount is the number of additional cells
SetRepeatAttribute(nEqualCellCount, (aCell.nType != table::CellContentType_EMPTY));
@@ -3209,8 +3216,8 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
break;
case table::CellContentType_TEXT :
{
- OUString sFormattedString(lcl_GetFormattedString(mpDoc, aCell.maBaseCell, aCell.maCellAddress));
- OUString sCellString = aCell.maBaseCell.getString(mpDoc);
+ OUString sFormattedString(lcl_GetFormattedString(rDoc, aCell.maBaseCell, aCell.maCellAddress));
+ OUString sCellString = aCell.maBaseCell.getString(&rDoc);
bool bExportValue = sCellString.indexOf('\x001') == -1;
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
sCellString, sFormattedString, bExportValue);
@@ -3227,10 +3234,10 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
ScFormulaCell* pFormulaCell = aCell.maBaseCell.getFormula();
if (!bIsMatrix || bIsFirstMatrixCell)
{
- if (!mpCompileFormulaCxt && mpDoc)
+ if (!mpCompileFormulaCxt)
{
- const formula::FormulaGrammar::Grammar eGrammar = mpDoc->GetStorageGrammar();
- mpCompileFormulaCxt.reset(new sc::CompileFormulaContext(*mpDoc, eGrammar));
+ const formula::FormulaGrammar::Grammar eGrammar = rDoc.GetStorageGrammar();
+ mpCompileFormulaCxt.reset(new sc::CompileFormulaContext(rDoc, eGrammar));
}
mpCompileFormulaCxt->setODFSavingVersion(getSaneDefaultVersion());
OUString aFormula = pFormulaCell->GetFormula(*mpCompileFormulaCxt);
@@ -3249,7 +3256,7 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
if (pFormulaCell->GetErrCode() != FormulaError::NONE)
{
AddAttribute(sAttrValueType, XML_STRING);
- AddAttribute(sAttrStringValue, aCell.maBaseCell.getString(mpDoc));
+ AddAttribute(sAttrStringValue, aCell.maBaseCell.getString(&rDoc));
if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
{
//export calcext:value-type="error"
@@ -3261,23 +3268,20 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
bool bIsStandard;
OUString sCurrency;
GetNumberFormatAttributesExportHelper()->GetCellType(aCell.nNumberFormat, sCurrency, bIsStandard);
- if (mpDoc)
+ GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
+ aCell.nNumberFormat, rDoc.GetValue(aCell.maCellAddress));
+ if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
{
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- aCell.nNumberFormat, mpDoc->GetValue(aCell.maCellAddress));
- if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
- {
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- aCell.nNumberFormat, mpDoc->GetValue(aCell.maCellAddress), false, XML_NAMESPACE_CALC_EXT, false );
- }
+ aCell.nNumberFormat, rDoc.GetValue(aCell.maCellAddress), false, XML_NAMESPACE_CALC_EXT, false );
}
}
else
{
- if (!aCell.maBaseCell.getString(mpDoc).isEmpty())
+ if (!aCell.maBaseCell.getString(&rDoc).isEmpty())
{
AddAttribute(sAttrValueType, XML_STRING);
- AddAttribute(sAttrStringValue, aCell.maBaseCell.getString(mpDoc));
+ AddAttribute(sAttrStringValue, aCell.maBaseCell.getString(&rDoc));
if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
{
AddAttribute(XML_NAMESPACE_CALC_EXT,XML_VALUE_TYPE, XML_STRING);
@@ -3308,36 +3312,36 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
SvXMLElementExport aElemC(*this, *pCellString, true, true);
CheckAttrList();
WriteAreaLink(aCell);
- WriteAnnotation(aCell);
- WriteDetective(aCell);
+ WriteAnnotation(rDoc, aCell);
+ WriteDetective(rDoc, aCell);
if (!bIsEmpty)
{
if (aCell.maBaseCell.getType() == CELLTYPE_EDIT)
{
- WriteEditCell(aCell.maBaseCell.getEditText());
+ WriteEditCell(rDoc, aCell.maBaseCell.getEditText());
}
else if (aCell.maBaseCell.getType() == CELLTYPE_FORMULA && aCell.maBaseCell.getFormula()->IsMultilineResult())
{
WriteMultiLineFormulaResult(aCell.maBaseCell.getFormula());
}
- else if (mpDoc)
+ else
{
SvXMLElementExport aElemP(*this, sElemP, true, false);
OUString aParaStr =
- ScCellFormat::GetOutputString(*mpDoc, aCell.maCellAddress, aCell.maBaseCell);
+ ScCellFormat::GetOutputString(rDoc, aCell.maCellAddress, aCell.maBaseCell);
bool bPrevCharWasSpace = true;
GetTextParagraphExport()->exportCharacterData(aParaStr, bPrevCharWasSpace);
}
}
- WriteShapes(aCell);
+ WriteShapes(rDoc, aCell);
if (!bIsEmpty)
IncrementProgressBar(false);
}
-void ScXMLExport::WriteEditCell(const EditTextObject* pText)
+void ScXMLExport::WriteEditCell(ScDocument& rDoc, const EditTextObject* pText)
{
rtl::Reference<XMLPropertySetMapper> xMapper = GetTextParagraphExport()->GetTextPropMapper()->getPropertySetMapper();
rtl::Reference<SvXMLAutoStylePoolP> xStylePool = GetAutoStylePool();
@@ -3364,12 +3368,12 @@ void ScXMLExport::WriteEditCell(const EditTextObject* pText)
continue;
// Start of a new paragraph. Flush the old paragraph.
- flushParagraph(*this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSec);
+ flushParagraph(rDoc, *this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSec);
nCurPara = rSec.mnParagraph;
itPara = itSec;
}
- flushParagraph(*this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSecEnd);
+ flushParagraph(rDoc, *this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSecEnd);
}
void ScXMLExport::WriteMultiLineFormulaResult(const ScFormulaCell* pCell)
@@ -3408,7 +3412,7 @@ void ScXMLExport::WriteMultiLineFormulaResult(const ScFormulaCell* pCell)
Characters(aContent);
}
-void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, awt::Point* pPoint)
+void ScXMLExport::ExportShape(ScDocument& rDoc, const uno::Reference < drawing::XShape >& xShape, awt::Point* pPoint)
{
uno::Reference < beans::XPropertySet > xShapeProps ( xShape, uno::UNO_QUERY );
bool bIsChart( false );
@@ -3430,28 +3434,25 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape,
{
// we have a chart
OUString sRanges;
- if ( mpDoc )
+ OUString aChartName;
+ xShapeProps->getPropertyValue( u"PersistName"_ustr ) >>= aChartName;
+ ScChartListenerCollection* pCollection = rDoc.GetChartListenerCollection();
+ if (pCollection)
{
- OUString aChartName;
- xShapeProps->getPropertyValue( u"PersistName"_ustr ) >>= aChartName;
- ScChartListenerCollection* pCollection = mpDoc->GetChartListenerCollection();
- if (pCollection)
+ ScChartListener* pListener = pCollection->findByName(aChartName);
+ if (pListener)
{
- ScChartListener* pListener = pCollection->findByName(aChartName);
- if (pListener)
+ const ScRangeListRef xRangeList = pListener->GetRangeList();
+ if ( xRangeList.is() )
{
- const ScRangeListRef xRangeList = pListener->GetRangeList();
- if ( xRangeList.is() )
+ ScRangeStringConverter::GetStringFromRangeList( sRanges, xRangeList.get(), &rDoc, FormulaGrammar::CONV_OOO );
+ if ( !sRanges.isEmpty() )
{
- ScRangeStringConverter::GetStringFromRangeList( sRanges, xRangeList.get(), mpDoc, FormulaGrammar::CONV_OOO );
- if ( !sRanges.isEmpty() )
- {
- bIsChart = true;
- rtl::Reference<comphelper::AttributeList> pAttrList = new comphelper::AttributeList();
- pAttrList->AddAttribute(
- GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges );
- GetShapeExport()->exportShape( xShape, SEF_DEFAULT, pPoint, pAttrList.get() );
- }
+ bIsChart = true;
+ rtl::Reference<comphelper::AttributeList> pAttrList = new comphelper::AttributeList();
+ pAttrList->AddAttribute(
+ GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges );
+ GetShapeExport()->exportShape( xShape, SEF_DEFAULT, pPoint, pAttrList.get() );
}
}
}
@@ -3505,20 +3506,20 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape,
IncrementProgressBar(false);
}
-void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
+void ScXMLExport::WriteShapes(ScDocument& rDoc, const ScMyCell& rMyCell)
{
- if( !(rMyCell.bHasShape && !rMyCell.aShapeList.empty() && mpDoc) )
+ if( !(rMyCell.bHasShape && !rMyCell.aShapeList.empty()) )
return;
// Reference point to turn absolute coordinates in reference point + offset. That happens in most
// cases in XMLShapeExport::ImpExportNewTrans_DecomposeAndRefPoint, which gets the absolute
// coordinates as translation from matrix in property "Transformation". For cell anchored shapes
// the reference point is left-top (in LTR mode) of that cell, which contains the shape.
- tools::Rectangle aCellRectFull = mpDoc->GetMMRect(
+ tools::Rectangle aCellRectFull = rDoc.GetMMRect(
rMyCell.maCellAddress.Col(), rMyCell.maCellAddress.Row(), rMyCell.maCellAddress.Col(),
rMyCell.maCellAddress.Row(), rMyCell.maCellAddress.Tab(), false /*bHiddenAsZero*/);
awt::Point aPoint;
- bool bNegativePage = mpDoc->IsNegativePage(rMyCell.maCellAddress.Tab());
+ bool bNegativePage = rDoc.IsNegativePage(rMyCell.maCellAddress.Tab());
if (bNegativePage)
aPoint.X = aCellRectFull.Right();
else
@@ -3558,7 +3559,7 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
SCCOL aCol(aSnapStartAddress.Col());
SCROW aRow(aSnapStartAddress.Row());
tools::Rectangle aFullStartCellRect
- = mpDoc->GetMMRect(aCol, aRow, aCol, aRow, aTab, false /*bHiddenAsZero*/);
+ = rDoc.GetMMRect(aCol, aRow, aCol, aRow, aTab, false /*bHiddenAsZero*/);
// The reference corner for the offset is top-left in case of LTR and top-right for RTL.
Point aFullTopPoint;
if (bNegativePage)
@@ -3590,7 +3591,7 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
aCol = aSnapEndAddress.Col();
aRow = aSnapEndAddress.Row();
tools::Rectangle aFullEndCellRect
- = mpDoc->GetMMRect(aCol, aRow, aCol, aRow, aTab, false /*bHiddenAsZero*/);
+ = rDoc.GetMMRect(aCol, aRow, aCol, aRow, aTab, false /*bHiddenAsZero*/);
Point aFullBottomPoint;
if (bNegativePage)
aFullBottomPoint.setX(aFullEndCellRect.Right() - aSnapEndOffset.X());
@@ -3623,7 +3624,7 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
if (pObjData->mbResizeWithCell && !pObj->IsResizeProtect())
{
OUString sEndAddress;
- ScRangeStringConverter::GetStringFromAddress(sEndAddress, rShape.aEndAddress, mpDoc,
+ ScRangeStringConverter::GetStringFromAddress(sEndAddress, rShape.aEndAddress, &rDoc,
FormulaGrammar::CONV_OOO);
AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress);
OUStringBuffer sBuffer;
@@ -3654,7 +3655,7 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
}
}
- ExportShape(rShape.xShape, &aPoint);
+ ExportShape(rDoc, rShape.xShape, &aPoint);
if (bNeedsRestoreSize)
{
@@ -3673,7 +3674,7 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
}
}
-void ScXMLExport::WriteTableShapes()
+void ScXMLExport::WriteTableShapes(ScDocument& rDoc)
{
ScMyTableShapes* pTableShapes(pSharedData->GetTableShapes());
if (!pTableShapes || (*pTableShapes)[nCurrentTable].empty())
@@ -3685,7 +3686,7 @@ void ScXMLExport::WriteTableShapes()
{
if (rxShape.is())
{
- if (mpDoc && mpDoc->IsNegativePage(static_cast<SCTAB>(nCurrentTable)))
+ if (rDoc.IsNegativePage(static_cast<SCTAB>(nCurrentTable)))
{
// RTL-mirroring refers to snap rectangle, not to logic rectangle, therefore cannot use
// getPosition() and getSize(), but need property "FrameRect" from rxShape or
@@ -3712,12 +3713,12 @@ void ScXMLExport::WriteTableShapes()
awt::Point aRefPoint;
aRefPoint.X = 2 * aFrameRect.X + aFrameRect.Width - 1;
aRefPoint.Y = 0;
- ExportShape(rxShape, &aRefPoint);
+ ExportShape(rDoc, rxShape, &aRefPoint);
}
// else should not happen
}
else
- ExportShape(rxShape, nullptr);
+ ExportShape(rDoc, rxShape, nullptr);
}
}
(*pTableShapes)[nCurrentTable].clear();
@@ -3778,9 +3779,9 @@ void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape >
}
const OUString aDate(bRemovePersonalInfo ? u"1970-01-01"_ustr : pNote->GetDate()); // Epoch time
- if (mpDoc)
+ if (ScDocument* pDoc = GetDocument())
{
- SvNumberFormatter* pNumForm = mpDoc->GetFormatTable();
+ SvNumberFormatter* pNumForm = pDoc->GetFormatTable();
double fDate;
sal_uInt32 nfIndex = pNumForm->GetFormatIndex(NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM);
if (pNumForm->IsNumberFormat(aDate, nfIndex, fDate))
@@ -3809,12 +3810,9 @@ void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape >
}
}
-void ScXMLExport::WriteAnnotation(const ScMyCell& rMyCell)
+void ScXMLExport::WriteAnnotation(ScDocument& rDoc, const ScMyCell& rMyCell)
{
- if (!mpDoc)
- return;
-
- ScPostIt* pNote = mpDoc->GetNote(rMyCell.maCellAddress);
+ ScPostIt* pNote = rDoc.GetNote(rMyCell.maCellAddress);
if (!pNote)
return;
@@ -3834,7 +3832,7 @@ void ScXMLExport::WriteAnnotation(const ScMyCell& rMyCell)
pCurrentCell = nullptr;
}
-void ScXMLExport::WriteDetective( const ScMyCell& rMyCell )
+void ScXMLExport::WriteDetective(ScDocument& rDoc, const ScMyCell& rMyCell)
{
if( !(rMyCell.bHasDetectiveObj || rMyCell.bHasDetectiveOp) )
return;
@@ -3854,7 +3852,7 @@ void ScXMLExport::WriteDetective( const ScMyCell& rMyCell )
{
if( (rObj.eObjType == SC_DETOBJ_ARROW) || (rObj.eObjType == SC_DETOBJ_TOOTHERTAB))
{
- ScRangeStringConverter::GetStringFromRange( sString, rObj.aSourceRange, mpDoc, FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromRange( sString, rObj.aSourceRange, &rDoc, FormulaGrammar::CONV_OOO );
AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sString );
}
sString = ScXMLConverter::GetStringFromDetObjType( rObj.eObjType );
@@ -3888,12 +3886,14 @@ void ScXMLExport::SetRepeatAttribute(sal_Int32 nEqualCellCount, bool bIncProgres
}
}
+//static
bool ScXMLExport::IsEditCell(const ScMyCell& rCell)
{
return rCell.maBaseCell.getType() == CELLTYPE_EDIT;
}
-bool ScXMLExport::IsCellEqual (const ScMyCell& aCell1, const ScMyCell& aCell2)
+//static
+bool ScXMLExport::IsCellEqual(ScDocument& rDoc, const ScMyCell& aCell1, const ScMyCell& aCell2)
{
bool bIsEqual = false;
if( !aCell1.bIsMergedBase && !aCell2.bIsMergedBase &&
@@ -3939,7 +3939,7 @@ bool ScXMLExport::IsCellEqual (const ScMyCell& aCell1, const ScMyCell& aCell2)
bIsEqual = false;
else
{
- bIsEqual = (aCell1.maBaseCell.getString(mpDoc) == aCell2.maBaseCell.getString(mpDoc));
+ bIsEqual = (aCell1.maBaseCell.getString(&rDoc) == aCell2.maBaseCell.getString(&rDoc));
}
}
break;
@@ -3961,7 +3961,7 @@ bool ScXMLExport::IsCellEqual (const ScMyCell& aCell1, const ScMyCell& aCell2)
return bIsEqual;
}
-void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc)
+void ScXMLExport::WriteCalculationSettings(ScDocument& rDoc, const uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc)
{
uno::Reference<beans::XPropertySet> xPropertySet(xSpreadDoc, uno::UNO_QUERY);
if (!xPropertySet.is())
@@ -3976,7 +3976,7 @@ void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreads
if (bUseWildcards && bUseRegularExpressions)
bUseRegularExpressions = false; // mutually exclusive, wildcards take precedence
bool bIsIterationEnabled (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_ITERENABLED) ));
- sal_uInt16 nYear2000 (mpDoc ? mpDoc->GetDocOptions().GetYear2000() : 0);
+ sal_uInt16 nYear2000 (rDoc.GetDocOptions().GetYear2000());
sal_Int32 nIterationCount(100);
xPropertySet->getPropertyValue( SC_UNO_ITERCOUNT ) >>= nIterationCount;
double fIterationEpsilon = 0;
@@ -4103,15 +4103,15 @@ void ScXMLExport::WriteTableSource()
}
// core implementation
-void ScXMLExport::WriteScenario()
+void ScXMLExport::WriteScenario(ScDocument& rDoc)
{
- if (!(mpDoc && mpDoc->IsScenario(static_cast<SCTAB>(nCurrentTable))))
+ if (!rDoc.IsScenario(static_cast<SCTAB>(nCurrentTable)))
return;
OUString sComment;
Color aColor;
ScScenarioFlags nFlags;
- mpDoc->GetScenarioData(static_cast<SCTAB>(nCurrentTable), sComment, aColor, nFlags);
+ rDoc.GetScenarioData(static_cast<SCTAB>(nCurrentTable), sComment, aColor, nFlags);
if (!(nFlags & ScScenarioFlags::ShowFrame))
AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_BORDER, XML_FALSE);
OUStringBuffer aBuffer;
@@ -4126,18 +4126,18 @@ void ScXMLExport::WriteScenario()
if (nFlags & ScScenarioFlags::Protected)
AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE);
::sax::Converter::convertBool(aBuffer,
- mpDoc->IsActiveScenario(static_cast<SCTAB>(nCurrentTable)));
+ rDoc.IsActiveScenario(static_cast<SCTAB>(nCurrentTable)));
AddAttribute(XML_NAMESPACE_TABLE, XML_IS_ACTIVE, aBuffer.makeStringAndClear());
- const ScRangeList* pRangeList = mpDoc->GetScenarioRanges(static_cast<SCTAB>(nCurrentTable));
+ const ScRangeList* pRangeList = rDoc.GetScenarioRanges(static_cast<SCTAB>(nCurrentTable));
OUString sRangeListStr;
- ScRangeStringConverter::GetStringFromRangeList( sRangeListStr, pRangeList, mpDoc, FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromRangeList( sRangeListStr, pRangeList, &rDoc, FormulaGrammar::CONV_OOO );
AddAttribute(XML_NAMESPACE_TABLE, XML_SCENARIO_RANGES, sRangeListStr);
if (!sComment.isEmpty())
AddAttribute(XML_NAMESPACE_TABLE, XML_COMMENT, sComment);
SvXMLElementExport aElem(*this, XML_NAMESPACE_TABLE, XML_SCENARIO, true, true);
}
-void ScXMLExport::WriteTheLabelRanges( const uno::Reference< sheet::XSpreadsheetDocument >& xSpreadDoc )
+void ScXMLExport::WriteTheLabelRanges(ScDocument& rDoc, const uno::Reference< sheet::XSpreadsheetDocument >& xSpreadDoc)
{
uno::Reference< beans::XPropertySet > xDocProp( xSpreadDoc, uno::UNO_QUERY );
if( !xDocProp.is() ) return;
@@ -4154,12 +4154,12 @@ void ScXMLExport::WriteTheLabelRanges( const uno::Reference< sheet::XSpreadsheet
if( nCount )
{
SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGES, true, true );
- WriteLabelRanges( xColRangesIAccess, true );
- WriteLabelRanges( xRowRangesIAccess, false );
+ WriteLabelRanges(rDoc, xColRangesIAccess, true);
+ WriteLabelRanges(rDoc, xRowRangesIAccess, false);
}
}
-void ScXMLExport::WriteLabelRanges( const uno::Reference< container::XIndexAccess >& xRangesIAccess, bool bColumn )
+void ScXMLExport::WriteLabelRanges(ScDocument& rDoc, const uno::Reference< container::XIndexAccess >& xRangesIAccess, bool bColumn)
{
if( !xRangesIAccess.is() ) return;
@@ -4171,10 +4171,10 @@ void ScXMLExport::WriteLabelRanges( const uno::Reference< container::XIndexAcces
{
OUString sRangeStr;
table::CellRangeAddress aCellRange( xRange->getLabelArea() );
- ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, mpDoc, FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, &rDoc, FormulaGrammar::CONV_OOO );
AddAttribute( XML_NAMESPACE_TABLE, XML_LABEL_CELL_RANGE_ADDRESS, sRangeStr );
aCellRange = xRange->getDataArea();
- ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, mpDoc, FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, &rDoc, FormulaGrammar::CONV_OOO );
AddAttribute( XML_NAMESPACE_TABLE, XML_DATA_CELL_RANGE_ADDRESS, sRangeStr );
AddAttribute( XML_NAMESPACE_TABLE, XML_ORIENTATION, bColumn ? XML_COLUMN : XML_ROW );
SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGE, true, true );
@@ -4182,24 +4182,19 @@ void ScXMLExport::WriteLabelRanges( const uno::Reference< container::XIndexAcces
}
}
-void ScXMLExport::WriteNamedExpressions()
+void ScXMLExport::WriteNamedExpressions(ScDocument& rDoc)
{
- if (!mpDoc)
- return;
- ScRangeName* pNamedRanges = mpDoc->GetRangeName();
- WriteNamedRange(pNamedRanges);
+ ScRangeName* pNamedRanges = rDoc.GetRangeName();
+ WriteNamedRange(rDoc, pNamedRanges);
}
-void ScXMLExport::WriteExternalDataMapping()
+void ScXMLExport::WriteExternalDataMapping(ScDocument& rDoc)
{
- if (!mpDoc)
- return;
-
if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0)
// Export this only for 1.2 extended and above.
return;
- sc::ExternalDataMapper& rDataMapper = mpDoc->GetExternalDataMapper();
+ sc::ExternalDataMapper& rDataMapper = rDoc.GetExternalDataMapper();
auto& rDataSources = rDataMapper.getDataSources();
if (rDataSources.empty())
@@ -4216,11 +4211,11 @@ void ScXMLExport::WriteExternalDataMapping()
SvXMLElementExport aMapping(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_MAPPING, true, true);
// Add the data transformations
- WriteExternalDataTransformations(itr.getDataTransformation());
+ WriteExternalDataTransformations(rDoc, itr.getDataTransformation());
}
}
-void ScXMLExport::WriteExternalDataTransformations(const std::vector<std::shared_ptr<sc::DataTransformation>>& aDataTransformations)
+void ScXMLExport::WriteExternalDataTransformations(ScDocument& rDoc, const std::vector<std::shared_ptr<sc::DataTransformation>>& aDataTransformations)
{
SvXMLElementExport aTransformations(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_TRANSFORMATIONS, true, true);
for (auto& itr : aDataTransformations)
@@ -4271,13 +4266,10 @@ void ScXMLExport::WriteExternalDataTransformations(const std::vector<std::shared
break;
case sc::TransformationType::SORT_TRANSFORMATION:
{
- if (!mpDoc)
- return;
-
// Sort Transformation
std::shared_ptr<sc::SortTransformation> aSortTransformation = std::dynamic_pointer_cast<sc::SortTransformation>(itr);
ScSortParam aSortParam = aSortTransformation->getSortParam();
- const sc::DocumentLinkManager& rMgr = mpDoc->GetDocLinkManager();
+ const sc::DocumentLinkManager& rMgr = rDoc.GetDocLinkManager();
const sc::DataStream* pStrm = rMgr.getDataStream();
if (!pStrm)
// No data stream.
@@ -4288,7 +4280,7 @@ void ScXMLExport::WriteExternalDataTransformations(const std::vector<std::shared
SvXMLElementExport aTransformation(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN_SORT_TRANSFORMATION, true, true);
- writeSort(*this, aSortParam, aRange, mpDoc);
+ writeSort(*this, aSortParam, aRange, rDoc);
}
break;
case sc::TransformationType::TEXT_TRANSFORMATION:
@@ -4521,11 +4513,8 @@ void ScXMLExport::WriteExternalDataTransformations(const std::vector<std::shared
}
}
-void ScXMLExport::WriteDataStream()
+void ScXMLExport::WriteDataStream(ScDocument& rDoc)
{
- if (!mpDoc)
- return;
-
if (!officecfg::Office::Common::Misc::ExperimentalMode::get())
// Export this only in experimental mode.
return;
@@ -4534,7 +4523,7 @@ void ScXMLExport::WriteDataStream()
// Export this only for 1.2 extended and above.
return;
- const sc::DocumentLinkManager& rMgr = mpDoc->GetDocLinkManager();
+ const sc::DocumentLinkManager& rMgr = rDoc.GetDocLinkManager();
const sc::DataStream* pStrm = rMgr.getDataStream();
if (!pStrm)
// No data stream.
@@ -4547,7 +4536,7 @@ void ScXMLExport::WriteDataStream()
ScRange aRange = pStrm->GetRange();
OUString aRangeStr;
ScRangeStringConverter::GetStringFromRange(
- aRangeStr, aRange, mpDoc, formula::FormulaGrammar::CONV_OOO);
+ aRangeStr, aRange, &rDoc, formula::FormulaGrammar::CONV_OOO);
AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, aRangeStr);
// Empty line refresh option.
@@ -4563,11 +4552,8 @@ void ScXMLExport::WriteDataStream()
SvXMLElementExport aElem(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_STREAM_SOURCE, true, true);
}
-void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
+void ScXMLExport::WriteNamedRange(ScDocument& rDoc, ScRangeName* pRangeName)
{
- if (!mpDoc)
- return;
-
//write a global or local ScRangeName
SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, true, true);
for (const auto& rxEntry : *pRangeName)
@@ -4576,12 +4562,12 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
OUString sBaseCellAddress;
rxEntry.second->ValidateTabRefs();
- ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, rxEntry.second->GetPos(), mpDoc,
+ ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, rxEntry.second->GetPos(), &rDoc,
FormulaGrammar::CONV_OOO, ' ', false, ScRefFlags::ADDR_ABS_3D);
assert(!sBaseCellAddress.isEmpty());
AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sBaseCellAddress);
- OUString sTempSymbol(rxEntry.second->GetSymbol(mpDoc->GetStorageGrammar()));
+ OUString sTempSymbol(rxEntry.second->GetSymbol(rDoc.GetStorageGrammar()));
ScRange aRange;
if (rxEntry.second->IsReference(aRange))
{
@@ -4635,9 +4621,9 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
}
}
-void ScXMLExport::exportSparklineGroups(SCTAB nTable)
+void ScXMLExport::exportSparklineGroups(ScDocument& rDoc, SCTAB nTable)
{
- sc::SparklineGroupsExport aSparklineGroupExport(*this, nTable);
+ sc::SparklineGroupsExport aSparklineGroupExport(rDoc, *this, nTable);
aSparklineGroupExport.write();
}
@@ -4706,12 +4692,9 @@ OUString getDateStringForType(condformat::ScCondFormatDateType eType)
}
-void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
+void ScXMLExport::ExportConditionalFormat(ScDocument& rDoc, SCTAB nTab)
{
- if (!mpDoc)
- return;
-
- ScConditionalFormatList* pCondFormatList = mpDoc->GetCondFormList(nTab);
+ ScConditionalFormatList* pCondFormatList = rDoc.GetCondFormList(nTab);
if(!pCondFormatList)
return;
@@ -4724,7 +4707,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
{
OUString sRanges;
const ScRangeList& rRangeList = rxCondFormat->GetRange();
- ScRangeStringConverter::GetStringFromRangeList( sRanges, &rRangeList, mpDoc, formula::FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromRangeList( sRanges, &rRangeList, &rDoc, formula::FormulaGrammar::CONV_OOO );
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TARGET_RANGE_ADDRESS, sRanges);
SvXMLElementExport aElementCondFormat(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMAT, true, true);
size_t nEntries = rxCondFormat->size();
@@ -4849,7 +4832,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, aCond.makeStringAndClear());
OUString sBaseAddress;
- ScRangeStringConverter::GetStringFromAddress( sBaseAddress, aPos, mpDoc,formula::FormulaGrammar::CONV_ODF );
+ ScRangeStringConverter::GetStringFromAddress( sBaseAddress, aPos, &rDoc, formula::FormulaGrammar::CONV_ODF );
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_BASE_CELL_ADDRESS, sBaseAddress);
SvXMLElementExport aElementCondEntry(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITION, true, true);
}
@@ -5002,12 +4985,9 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
}
}
-void ScXMLExport::WriteExternalRefCaches()
+void ScXMLExport::WriteExternalRefCaches(ScDocument& rDoc)
{
- if (!mpDoc)
- return;
-
- ScExternalRefManager* pRefMgr = mpDoc->GetExternalRefManager();
+ ScExternalRefManager* pRefMgr = rDoc.GetExternalRefManager();
pRefMgr->resetSrcFileData(GetOrigFileName());
sal_uInt16 nCount = pRefMgr->getExternalFileCount();
for (sal_uInt16 nFileId = 0; nFileId < nCount; ++nFileId)
@@ -5193,12 +5173,9 @@ void ScXMLExport::WriteExternalRefCaches()
}
// core implementation
-void ScXMLExport::WriteConsolidation()
+void ScXMLExport::WriteConsolidation(ScDocument& rDoc)
{
- if (!mpDoc)
- return;
-
- const ScConsolidateParam* pCons(mpDoc->GetConsolidateDlgData());
+ const ScConsolidateParam* pCons(rDoc.GetConsolidateDlgData());
if( !pCons )
return;
@@ -5207,10 +5184,10 @@ void ScXMLExport::WriteConsolidation()
sStrData.clear();
for( sal_Int32 nIndex = 0; nIndex < pCons->nDataAreaCount; ++nIndex )
- ScRangeStringConverter::GetStringFromArea( sStrData, pCons->pDataAreas[ nIndex ], mpDoc, FormulaGrammar::CONV_OOO, ' ', true );
+ ScRangeStringConverter::GetStringFromArea( sStrData, pCons->pDataAreas[ nIndex ], &rDoc, FormulaGrammar::CONV_OOO, ' ', true );
AddAttribute( XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES, sStrData );
- ScRangeStringConverter::GetStringFromAddress( sStrData, ScAddress( pCons->nCol, pCons->nRow, pCons->nTab ), mpDoc, FormulaGrammar::CONV_OOO );
+ ScRangeStringConverter::GetStringFromAddress( sStrData, ScAddress( pCons->nCol, pCons->nRow, pCons->nTab ), &rDoc, FormulaGrammar::CONV_OOO );
AddAttribute( XML_NAMESPACE_TABLE, XML_TARGET_CELL_ADDRESS, sStrData );
if( pCons->bByCol && !pCons->bByRow )
@@ -5236,9 +5213,10 @@ XMLPageExport* ScXMLExport::CreatePageExport()
return new XMLTableMasterPageExport( *this );
}
-void ScXMLExport::GetChangeTrackViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
+//static
+void ScXMLExport::GetChangeTrackViewSettings(ScDocument& rDoc, uno::Sequence<beans::PropertyValue>& rProps)
{
- ScChangeViewSettings* pViewSettings(mpDoc ? mpDoc->GetChangeViewSettings() : nullptr);
+ ScChangeViewSettings* pViewSettings(rDoc.GetChangeViewSettings());
if (!pViewSettings)
return;
@@ -5273,7 +5251,7 @@ void ScXMLExport::GetChangeTrackViewSettings(uno::Sequence<beans::PropertyValue>
pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Name = "ShowChangesByRanges";
pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Value <<= pViewSettings->HasRange();
OUString sRangeList;
- ScRangeStringConverter::GetStringFromRangeList(sRangeList, &(pViewSettings->GetTheRangeList()), mpDoc, FormulaGrammar::CONV_OOO);
+ ScRangeStringConverter::GetStringFromRangeList(sRangeList, &(pViewSettings->GetTheRangeList()), &rDoc, FormulaGrammar::CONV_OOO);
pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Name = "ShowChangesByRangesList";
pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Value <<= sRangeList;
@@ -5305,8 +5283,14 @@ void ScXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
pProps[i].Value <<= static_cast<sal_Int32>(aRect.getOpenHeight());
}
}
+ ScDocument* pDoc = pDocObj->GetDocument();
+ if (!pDoc)
+ {
+ SAL_WARN("sc", "no ScDocument!");
+ return;
+ }
+ GetChangeTrackViewSettings(*pDoc, rProps);
}
- GetChangeTrackViewSettings(rProps);
}
void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)
@@ -5322,28 +5306,30 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&
if (xProperties.is())
SvXMLUnitConverter::convertPropertySet(rProps, xProperties);
+ ScDocument* pDoc = GetDocument();
+
sal_Int32 nPropsToAdd = 0;
OUStringBuffer aTrackedChangesKey;
- if (mpDoc && mpDoc->GetChangeTrack() && mpDoc->GetChangeTrack()->IsProtected())
+ if (pDoc && pDoc->GetChangeTrack() && pDoc->GetChangeTrack()->IsProtected())
{
::comphelper::Base64::encode(aTrackedChangesKey,
- mpDoc->GetChangeTrack()->GetProtection());
+ pDoc->GetChangeTrack()->GetProtection());
if (!aTrackedChangesKey.isEmpty())
++nPropsToAdd;
}
bool bVBACompat = false;
uno::Reference <container::XNameAccess> xCodeNameAccess;
- OSL_ENSURE( mpDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" );
+ OSL_ENSURE( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" );
// tdf#71271 - add code names regardless of VBA compatibility mode
- if (mpDoc)
+ if (pDoc)
{
// VBA compatibility mode
- if (bVBACompat = mpDoc->IsInVBAMode(); bVBACompat)
+ if (bVBACompat = pDoc->IsInVBAMode(); bVBACompat)
++nPropsToAdd;
// code names
- xCodeNameAccess = new XMLCodeNameProvider( mpDoc );
+ xCodeNameAccess = new XMLCodeNameProvider( pDoc );
if( xCodeNameAccess->hasElements() )
++nPropsToAdd;
else
@@ -5436,25 +5422,23 @@ ErrCode ScXMLExport::exportDoc( enum XMLTokenEnum eClass )
if( getExportFlags() & (SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::STYLES|
SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT) )
{
- if (mpDoc)
+ uno::Reference< frame::XModel > xModel = GetModel();
+ if (ScDocument* pDoc = GetDocument())
{
// if source doc was Excel then
- uno::Reference< frame::XModel > xModel = GetModel();
- if ( xModel.is() )
+ auto pFoundShell = comphelper::getFromUnoTunnel<SfxObjectShell>(xModel);
+ if ( pFoundShell && ooo::vba::isAlienExcelDoc( *pFoundShell ) )
{
- auto pFoundShell = comphelper::getFromUnoTunnel<SfxObjectShell>(xModel);
- if ( pFoundShell && ooo::vba::isAlienExcelDoc( *pFoundShell ) )
- {
- xRowStylesPropertySetMapper = new XMLPropertySetMapper(aXMLScFromXLSRowStylesProperties, xScPropHdlFactory, true);
- xRowStylesExportPropertySetMapper = new ScXMLRowExportPropertyMapper(xRowStylesPropertySetMapper);
- GetAutoStylePool()->SetFamilyPropSetMapper( XmlStyleFamily::TABLE_ROW,
- xRowStylesExportPropertySetMapper );
- }
+ xRowStylesPropertySetMapper = new XMLPropertySetMapper(aXMLScFromXLSRowStylesProperties, xScPropHdlFactory, true);
+ xRowStylesExportPropertySetMapper = new ScXMLRowExportPropertyMapper(xRowStylesPropertySetMapper);
+ GetAutoStylePool()->SetFamilyPropSetMapper( XmlStyleFamily::TABLE_ROW,
+ xRowStylesExportPropertySetMapper );
}
- CollectUserDefinedNamespaces(mpDoc->GetPool(), ATTR_USERDEF);
- CollectUserDefinedNamespaces(mpDoc->GetEditPool(), EE_PARA_XMLATTRIBS);
- CollectUserDefinedNamespaces(mpDoc->GetEditPool(), EE_CHAR_XMLATTRIBS);
- ScDrawLayer* pDrawLayer = mpDoc->GetDrawLayer();
+
+ CollectUserDefinedNamespaces(pDoc->GetPool(), ATTR_USERDEF);
+ CollectUserDefinedNamespaces(pDoc->GetEditPool(), EE_PARA_XMLATTRIBS);
+ CollectUserDefinedNamespaces(pDoc->GetEditPool(), EE_CHAR_XMLATTRIBS);
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
if (pDrawLayer)
{
CollectUserDefinedNamespaces(&pDrawLayer->GetItemPool(), EE_PARA_XMLATTRIBS);
@@ -5467,9 +5451,9 @@ ErrCode ScXMLExport::exportDoc( enum XMLTokenEnum eClass )
getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
{
bool bAnySheetEvents = false;
- SCTAB nTabCount = mpDoc->GetTableCount();
+ SCTAB nTabCount = pDoc->GetTableCount();
for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
- if (mpDoc->GetSheetEvents(nTab))
+ if (pDoc->GetSheetEvents(nTab))
bAnySheetEvents = true;
if (bAnySheetEvents)
GetNamespaceMap_().Add(
@@ -5488,13 +5472,13 @@ void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XCompon
SolarMutexGuard aGuard;
SvXMLExport::setSourceDocument( xComponent );
- mpDoc = ScXMLConverter::GetScDocument( GetModel() );
- OSL_ENSURE( mpDoc, "ScXMLExport::setSourceDocument - no ScDocument!" );
- if (!mpDoc)
+ ScDocument* pDoc = GetDocument();
+ OSL_ENSURE( pDoc, "ScXMLExport::setSourceDocument - no ScDocument!" );
+ if (!pDoc)
throw lang::IllegalArgumentException();
// create ScChangeTrackingExportHelper after document is known
- pChangeTrackingExportHelper.reset(new ScChangeTrackingExportHelper(*this));
+ pChangeTrackingExportHelper.reset(new ScChangeTrackingExportHelper(*pDoc, *this));
// Set the document's storage grammar corresponding to the ODF version that
// is to be written.
@@ -5504,10 +5488,10 @@ void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XCompon
// ODF 1.0 and 1.1 use GRAM_PODF, everything later or unspecified GRAM_ODFF
case SvtSaveOptions::ODFSVER_010:
case SvtSaveOptions::ODFSVER_011:
- mpDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_PODF);
+ pDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_PODF);
break;
default:
- mpDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_ODFF);
+ pDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_ODFF);
}
}
@@ -5515,19 +5499,20 @@ void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XCompon
sal_Bool SAL_CALL ScXMLExport::filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor )
{
SolarMutexGuard aGuard;
- if (mpDoc)
- mpDoc->EnableIdle(false);
+ ScDocument* pDoc = GetDocument();
+ if (pDoc)
+ pDoc->EnableIdle(true);
bool bReturn(SvXMLExport::filter(aDescriptor));
- if (mpDoc)
- mpDoc->EnableIdle(true);
+ if (pDoc)
+ pDoc->EnableIdle(true);
return bReturn;
}
void SAL_CALL ScXMLExport::cancel()
{
SolarMutexGuard aGuard;
- if (mpDoc)
- mpDoc->EnableIdle(true);
+ if (ScDocument* pDoc = GetDocument())
+ pDoc->EnableIdle(true);
SvXMLExport::cancel();
}
@@ -5541,7 +5526,6 @@ void SAL_CALL ScXMLExport::initialize( const css::uno::Sequence< css::uno::Any >
void ScXMLExport::DisposingModel()
{
SvXMLExport::DisposingModel();
- mpDoc = nullptr;
xCurrentTable = nullptr;
}
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index cb03a354cb59..d7ad2c726187 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -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;
diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx
index 48900a8d0807..46bf1f159bdb 100644
--- a/sc/source/filter/xml/xmlfonte.cxx
+++ b/sc/source/filter/xml/xmlfonte.cxx
@@ -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: */
diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx
index 7ae12c462367..7f98e13be3f9 100644
--- a/sc/source/filter/xml/xmlstyle.cxx
+++ b/sc/source/filter/xml/xmlstyle.cxx
@@ -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);
}