26#include <unonames.hxx>
27#include <document.hxx>
111#include <rtl/ustring.hxx>
115#include <rtl/math.hxx>
127#include <com/sun/star/beans/XPropertySet.hpp>
128#include <com/sun/star/container/XNamed.hpp>
129#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
130#include <com/sun/star/form/XFormsSupplier2.hpp>
131#include <com/sun/star/io/XActiveDataSource.hpp>
132#include <com/sun/star/io/XSeekable.hpp>
133#include <com/sun/star/sheet/XUsedAreaCursor.hpp>
134#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
135#include <com/sun/star/sheet/XPrintAreas.hpp>
136#include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp>
137#include <com/sun/star/sheet/XLabelRange.hpp>
138#include <com/sun/star/sheet/NamedRangeFlag.hpp>
139#include <com/sun/star/sheet/XSheetCellCursor.hpp>
140#include <com/sun/star/sheet/XSheetCellRanges.hpp>
141#include <com/sun/star/sheet/XSheetLinkable.hpp>
142#include <com/sun/star/sheet/GlobalSheetSettings.hpp>
143#include <com/sun/star/table/XColumnRowRange.hpp>
144#include <com/sun/star/util/XProtectable.hpp>
145#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
146#include <com/sun/star/chart2/XChartDocument.hpp>
147#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
148#include <com/sun/star/chart2/data/XDataReceiver.hpp>
150#include <com/sun/star/document/XDocumentProperties.hpp>
151#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
161#include <officecfg/Office/Common.hxx>
170#define SC_VIEWCHANGES_COUNT 13
171#define SC_SHOW_CHANGES 0
172#define SC_SHOW_ACCEPTED_CHANGES 1
173#define SC_SHOW_REJECTED_CHANGES 2
174#define SC_SHOW_CHANGES_BY_DATETIME 3
175#define SC_SHOW_CHANGES_BY_DATETIME_MODE 4
176#define SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME 5
177#define SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME 6
178#define SC_SHOW_CHANGES_BY_AUTHOR 7
179#define SC_SHOW_CHANGES_BY_AUTHOR_NAME 8
180#define SC_SHOW_CHANGES_BY_COMMENT 9
181#define SC_SHOW_CHANGES_BY_COMMENT_TEXT 10
182#define SC_SHOW_CHANGES_BY_RANGES 11
183#define SC_SHOW_CHANGES_BY_RANGES_LIST 12
189using ::com::sun::star::uno::UNO_QUERY;
193OUString lcl_RangeSequenceToString(
194 const uno::Sequence< OUString > & rRanges,
195 const uno::Reference< chart2::data::XRangeXMLConversion > & xFormatConverter )
197 OUStringBuffer aResult;
198 const sal_Int32 nMaxIndex( rRanges.getLength() - 1 );
200 for( sal_Int32
i=0;
i<=nMaxIndex; ++
i )
202 OUString aRange( rRanges[
i] );
203 if( xFormatConverter.is())
204 aRange = xFormatConverter->convertRangeToXML( aRange );
205 aResult.append( aRange );
207 aResult.append( cSep );
209 return aResult.makeStringAndClear();
249extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
252 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLExporter", SvXMLExportFlags::ALL));
255extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
258 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLMetaExporter", SvXMLExportFlags::META));
261extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
264 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLStylesExporter", SvXMLExportFlags::STYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::FONTDECLS));
267extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
270 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLContentExporter", SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::CONTENT|SvXMLExportFlags::SCRIPTS|SvXMLExportFlags::FONTDECLS));
273extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
276 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLSettingsExporter", SvXMLExportFlags::SETTINGS));
279extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
282 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLOasisExporter", SvXMLExportFlags::ALL|SvXMLExportFlags::OASIS));
285extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
288 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLOasisMetaExporter", SvXMLExportFlags::META|SvXMLExportFlags::OASIS));
291extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
294 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLOasisStylesExporter", SvXMLExportFlags::STYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::OASIS));
297extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
300 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLOasisContentExporter", SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::CONTENT|SvXMLExportFlags::SCRIPTS|SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::OASIS));
303extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
306 return cppu::acquire(
new ScXMLExport(context,
"com.sun.star.comp.Calc.XMLOasisSettingsExporter", SvXMLExportFlags::SETTINGS|SvXMLExportFlags::OASIS));
322 virtual void onExport(
const uno::Reference < drawing::XShape >& xShape )
override;
327void ScXMLShapeExport::onExport(
const uno::Reference < drawing::XShape >& xShape )
329 uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY );
330 if( xShapeProp.is() )
332 sal_Int16 nLayerID = 0;
334 GetExport().AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_BACKGROUND, XML_TRUE);
340 css::uno::Reference<css::sheet::XGlobalSheetSettings> xProperties =
347 const css::uno::Reference< css::uno::XComponentContext >& rContext,
353 pCurrentCell(nullptr),
357 bHasRowHeader(false),
358 bRowHeaderOpen(false)
398 if( !(
getExportFlags() & (SvXMLExportFlags::STYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT)) )
445 const char pXmlHeader[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
446 sal_Int32 nLen = strlen(pXmlHeader);
448 uno::Sequence<sal_Int8> aFileStart(nLen);
449 sal_Int32 nRead =
xSourceStream->readBytes( aFileStart, nLen );
451 if ( nRead != nLen || memcmp( aFileStart.getConstArray(), pXmlHeader, nLen ) != 0 )
477 NumberFormatIndexMap::const_iterator itr =
aNumFmtIndexMap.find(nNumFmt);
489 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
GetModel(), uno::UNO_QUERY);
490 if (!xSpreadDoc.is())
493 uno::Reference<container::XIndexAccess> xIndex(xSpreadDoc->getSheets(), uno::UNO_QUERY);
497 nTableCount = xIndex->getCount();
503 for (
SCTAB nTable = 0; nTable < nTableCount; ++nTable)
506 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY);
507 if (!xDrawPageSupplier.is())
510 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage());
518 sal_Int32 nShapes = xDrawPage->getCount();
519 for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape)
521 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(nShape), uno::UNO_QUERY);
525 uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
526 if (!xShapeProp.is())
529 sal_Int16 nLayerID = 0;
530 bool bExtracted = xShapeProp->getPropertyValue(
SC_LAYERID) >>= nLayerID;
549 aMyShape.
aAddress = pAnchor->maStart;
554 aMyShape.
nEndX = pAnchor->maEndOffset.X();
555 aMyShape.
nEndY = pAnchor->maEndOffset.Y();
558 pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col());
559 pSharedData->SetLastRow(nTable, pAnchor->maStart.Row());
578 ScMyShapeList::const_iterator aShapeItr = aDummyInitList.end();
581 pShapeList = &
pSharedData->GetShapesContainer()->GetShapes();
582 aShapeItr = pShapeList->begin();
586 for (
SCTAB nTable = 0; nTable < nTableCount; ++nTable)
588 uno::Reference<drawing::XDrawPage> xDrawPage(
pSharedData->GetDrawPage(nTable));
593 uno::Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, uno::UNO_QUERY );
594 if( xFormsSupplier.is() && xFormsSupplier->hasForms() )
602 for (
const auto& rxShape : (*pTableShapes)[nTable])
610 ScMyShapeList::const_iterator aEndItr(pShapeList->end());
611 while ( aShapeItr != aEndItr && ( aShapeItr->aAddress.Tab() == nTable ) )
621 for (
const auto& rNoteShape : rNoteShapes)
623 if ( rNoteShape.aPos.Tab() == nTable )
636 SCTAB nTableCount(0);
637 sal_Int32 nShapesCount(0);
641 uno::Sequence<beans::NamedValue> stats
643 {
"TableCount",
uno::Any(
static_cast<sal_Int32
>(nTableCount)) },
644 {
"CellCount",
uno::Any(nCellCount) },
645 {
"ObjectCount",
uno::Any(nShapesCount) }
649 uno::Reference<document::XDocumentPropertiesSupplier> xPropSup(
GetModel(),
650 uno::UNO_QUERY_THROW);
651 uno::Reference<document::XDocumentProperties> xDocProps(
652 xPropSup->getDocumentProperties());
653 if (xDocProps.is()) {
654 xDocProps->setDocumentStatistics(stats);
669 table::CellRangeAddress aCellAddress;
670 uno::Reference<sheet::XSheetCellCursor> xCursor(xTable->createCursor());
671 uno::Reference<sheet::XUsedAreaCursor> xUsedArea (xCursor, uno::UNO_QUERY);
672 uno::Reference<sheet::XCellRangeAddressable> xCellAddress (xCursor, uno::UNO_QUERY);
673 if (xUsedArea.is() && xCellAddress.is())
675 xUsedArea->gotoEndOfUsedArea(
true);
676 aCellAddress = xCellAddress->getRangeAddress();
686 for (
const auto & rLink : rLinks)
721 if ( nTab < pDoc->GetTableCount() )
734 const sal_Int32 nIndex,
const bool bIsAutoStyle,
const bool bIsVisible)
738 if (nStyleIndex != -1)
742 if (nRepeatColumns > 1)
744 OUString sOUEndCol(OUString::number(nRepeatColumns));
753 const sal_Int32 nStyleIndex,
const bool bIsVisible)
755 sal_Int32 nRepeat(1);
756 sal_Int32 nPrevIndex(
pDefaults->GetColDefaults()[nColumn].nIndex);
757 bool bPrevAutoStyle(
pDefaults->GetColDefaults()[nColumn].bIsAutoStyle);
758 for (sal_Int32
i = nColumn + 1;
i < nColumn + nRepeatColumns; ++
i)
760 if ((
pDefaults->GetColDefaults()[
i].nIndex != nPrevIndex) ||
761 (
pDefaults->GetColDefaults()[
i].bIsAutoStyle != bPrevAutoStyle))
764 nPrevIndex =
pDefaults->GetColDefaults()[
i].nIndex;
765 bPrevAutoStyle =
pDefaults->GetColDefaults()[
i].bIsAutoStyle;
786 sal_Int32 nColsRepeated (1);
788 sal_Int32 nPrevColumn(0);
789 bool bPrevIsVisible (
true);
790 bool bWasHeader (
false);
791 bool bIsClosed (
true);
792 sal_Int32 nPrevIndex (-1);
794 for (nColumn = 0; nColumn <=
pSharedData->GetLastColumn(nTable); ++nColumn)
797 bool bIsVisible(
true);
800 const bool bIsHeader = bHasColumnHeader && (aColumnHeaderRange.
aStart.
Col() <= nColumn) && (nColumn <= aColumnHeaderRange.
aEnd.
Col());
801 if (bIsHeader != bWasHeader)
807 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
811 bPrevIsVisible = bIsVisible;
813 nPrevColumn = nColumn;
823 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
829 bPrevIsVisible = bIsVisible;
831 nPrevColumn = nColumn;
837 else if (nColumn == 0)
841 bPrevIsVisible = bIsVisible;
844 else if ((bIsVisible == bPrevIsVisible) && (
nIndex == nPrevIndex) &&
849 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
866 bPrevIsVisible = bIsVisible;
868 nPrevColumn = nColumn;
872 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
894 vector<sal_uInt32> aNumFmts;
896 static constexpr OUStringLiteral aDefaultStyle(
u"Default");
897 for (
const auto& rNumFmt : aNumFmts)
899 sal_Int32 nNumFmt =
static_cast<sal_Int32
>(rNumFmt);
905 vector<XMLPropertyState> aProps;
906 aVal <<= OUString(aDefaultStyle);
907 aProps.emplace_back(nEntryIndex, aVal);
931 std::vector<XMLPropertyState>& rPropStates,
934 sal_Int32 nEntryCount = xMapper->GetEntryCount();
939 sal_Int32 nIndexFontName = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, rXMLName, 0);
941 if (nIndexFontName == -1 || nIndexFontName >= nEntryCount)
947 auto const nPitch(pItem->
GetPitch());
950 sFamilyName, sStyleName, nFamily, nPitch, eEnc));
956 rPropStates.emplace_back(nIndexFontName,
uno::Any(sName));
961 std::vector<XMLPropertyState>& rPropStates,
const std::vector<const SfxPoolItem*>& rSecAttrs,
965 sal_Int32 nEntryCount = xMapper->GetEntryCount();
966 rPropStates.reserve(rSecAttrs.size());
969 if (
p->Which() == EE_FEATURE_FIELD)
979 sal_Int32
nIndex = xMapper->GetEntryIndex(
982 if (nIndex == -1 || nIndex >= nEntryCount)
989 handleFont(rExport, rPropStates, p, xMapper, u
"font-name");
992 handleFont(rExport, rPropStates, p, xMapper, u
"font-name-asian");
995 handleFont(rExport, rPropStates, p, xMapper, u
"font-name-complex");
1004 rPropStates.emplace_back(nIndex, aAny);
1014 rPropStates.emplace_back(nIndex, aAny);
1024 rPropStates.emplace_back(nIndex, aAny);
1030 sal_Int32 nIndexStyle = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u
"text-underline-style", 0);
1031 if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
1034 sal_Int32 nIndexWidth = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u
"text-underline-width", 0);
1035 if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
1038 sal_Int32 nIndexType = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u
"text-underline-type", 0);
1039 if (nIndexType == -1 || nIndexType > nEntryCount)
1042 sal_Int32 nIndexColor = xMapper->FindEntryIndex(
"CharUnderlineColor", XML_NAMESPACE_STYLE, u
"text-underline-color");
1043 if (nIndexColor == -1 || nIndexColor > nEntryCount)
1046 sal_Int32 nIndexHasColor = xMapper->FindEntryIndex(
"CharUnderlineHasColor", XML_NAMESPACE_STYLE, u
"text-underline-color");
1047 if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
1052 rPropStates.emplace_back(nIndexStyle, aAny);
1053 rPropStates.emplace_back(nIndexType, aAny);
1054 rPropStates.emplace_back(nIndexWidth, aAny);
1057 rPropStates.emplace_back(nIndexColor, aAny);
1060 rPropStates.emplace_back(nIndexHasColor, aAny);
1066 sal_Int32 nIndexStyle = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u
"text-overline-style", 0);
1067 if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
1070 sal_Int32 nIndexWidth = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u
"text-overline-width", 0);
1071 if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
1074 sal_Int32 nIndexType = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u
"text-overline-type", 0);
1075 if (nIndexType == -1 || nIndexType > nEntryCount)
1078 sal_Int32 nIndexColor = xMapper->FindEntryIndex(
"CharOverlineColor", XML_NAMESPACE_STYLE, u
"text-overline-color");
1079 if (nIndexColor == -1 || nIndexColor > nEntryCount)
1082 sal_Int32 nIndexHasColor = xMapper->FindEntryIndex(
"CharOverlineHasColor", XML_NAMESPACE_STYLE, u
"text-overline-color");
1083 if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
1088 rPropStates.emplace_back(nIndexStyle, aAny);
1089 rPropStates.emplace_back(nIndexType, aAny);
1090 rPropStates.emplace_back(nIndexWidth, aAny);
1093 rPropStates.emplace_back(nIndexColor, aAny);
1096 rPropStates.emplace_back(nIndexHasColor, aAny);
1105 if ( aAny >>= nColor )
1107 sal_Int32 nIndexColor = ( nColor ==
COL_AUTO ) ? xMapper->GetEntryIndex(
1108 XML_NAMESPACE_STYLE,
GetXMLToken( XML_USE_WINDOW_FONT_COLOR ), 0 ) : nIndex;
1109 rPropStates.emplace_back( nIndexColor, aAny );
1118 rPropStates.emplace_back(nIndex, aAny);
1126 rPropStates.emplace_back(nIndex, aAny);
1134 rPropStates.emplace_back(nIndex, aAny);
1142 rPropStates.emplace_back(nIndex, aAny);
1150 rPropStates.emplace_back(nIndex, aAny);
1158 rPropStates.emplace_back(nIndex, aAny);
1166 rPropStates.emplace_back(nIndex, aAny);
1174 rPropStates.emplace_back(nIndex, aAny);
1179 sal_Int32 nIndexEsc = xMapper->FindEntryIndex(
"CharEscapement", XML_NAMESPACE_STYLE, u
"text-position");
1180 if (nIndexEsc == -1 || nIndexEsc > nEntryCount)
1183 sal_Int32 nIndexEscHeight = xMapper->FindEntryIndex(
"CharEscapementHeight", XML_NAMESPACE_STYLE, u
"text-position");
1184 if (nIndexEscHeight == -1 || nIndexEscHeight > nEntryCount)
1190 rPropStates.emplace_back(nIndexEsc, aAny);
1193 rPropStates.emplace_back(nIndexEscHeight, aAny);
1202 rPropStates.emplace_back(nIndex, aAny);
1213 sal_Int32 nIndexLanguage, nIndexCountry, nIndexScript, nIndexTag;
1217 nIndexLanguage = xMapper->GetEntryIndex( XML_NAMESPACE_FO, u
"language", 0);
1218 nIndexCountry = xMapper->GetEntryIndex( XML_NAMESPACE_FO, u
"country", 0);
1219 nIndexScript = xMapper->GetEntryIndex( XML_NAMESPACE_FO, u
"script", 0);
1220 nIndexTag = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"rfc-language-tag", 0);
1223 nIndexLanguage = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"language-asian", 0);
1224 nIndexCountry = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"country-asian", 0);
1225 nIndexScript = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"script-asian", 0);
1226 nIndexTag = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"rfc-language-tag-asian", 0);
1229 nIndexLanguage = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"language-complex", 0);
1230 nIndexCountry = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"country-complex", 0);
1231 nIndexScript = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"script-complex", 0);
1232 nIndexTag = xMapper->GetEntryIndex( XML_NAMESPACE_STYLE, u
"rfc-language-tag-complex", 0);
1235 nIndexLanguage = nIndexCountry = nIndexScript = nIndexTag = -1;
1237 assert( nIndexLanguage >= 0 && nIndexCountry >= 0 && nIndexScript >= 0 && nIndexTag >= 0);
1238 rPropStates.emplace_back( nIndexLanguage, aAny);
1239 rPropStates.emplace_back( nIndexCountry, aAny);
1240 rPropStates.emplace_back( nIndexScript, aAny);
1241 rPropStates.emplace_back( nIndexTag, aAny);
1264 sal_Int32 nCellCount = 0;
1267 std::vector<editeng::Section> aAttrs;
1268 pEdit->GetAllSections(aAttrs);
1272 for (
const auto& rSec : aAttrs)
1274 const std::vector<const SfxPoolItem*>& rSecAttrs = rSec.maAttributes;
1275 if (rSecAttrs.empty())
1279 std::vector<XMLPropertyState> aPropStates;
1280 toXMLPropertyStates(*
this, aPropStates, rSecAttrs, xMapper, rAttrMap);
1281 if (!aPropStates.empty())
1282 xStylePool->Add(XmlStyleFamily::TEXT_TEXT, OUString(), std::move(aPropStates));
1293#if OSL_DEBUG_LEVEL > 0
1294 sal_Int32 nPrevCol(0);
1297 sal_Int32 nPrevValidationIndex(-1);
1298 bool bIsAutoStyle(
true);
1299 bool bIsFirst(
true);
1302#if OSL_DEBUG_LEVEL > 0
1303 OSL_ENSURE(bIsFirst || (!bIsFirst && (nPrevCol + nCols == aRange.
nStartColumn)),
"here are some columns missing");
1312#if OSL_DEBUG_LEVEL > 0
1326 if (nPrevValidationIndex > -1)
1337#if OSL_DEBUG_LEVEL > 0
1347 if (nPrevValidationIndex > -1)
1358 const sal_Int32 nIndex,
const sal_Int32 nEqualRows,
1359 bool bHidden,
bool bFiltered)
1391 const sal_Int32 nIndex,
const sal_Int32 nStartRow,
const sal_Int32 nEqualRows,
1392 bool bHidden,
bool bFiltered)
1411 nEquals = nEqualRows;
1413 nOpenRow = nStartRow + nEquals - 1;
1414 if (nEquals < nEqualRows)
1418 nOpenRow = nStartRow + nEqualRows - 1;
1426 const sal_Int32 nIndex,
const sal_Int32 nStartRow,
const sal_Int32 nEqualRows,
1427 bool bHidden,
bool bFiltered)
1431 CloseRow(nStartRow + nEqualRows - 1);
1439 sal_Int32 nPrevIndex(0),
nIndex;
1440 bool bPrevHidden =
false;
1441 bool bPrevFiltered =
false;
1442 bool bHidden =
false;
1443 bool bFiltered =
false;
1444 sal_Int32 nEqualRows(1);
1445 sal_Int32 nEndRow(nStartRow + nRepeatRow);
1446 sal_Int32 nEndRowHidden = nStartRow - 1;
1447 sal_Int32 nEndRowFiltered = nStartRow - 1;
1449 for (nRow = nStartRow; nRow < nEndRow; ++nRow)
1451 if (nRow == nStartRow)
1453 nPrevIndex =
pRowStyles->GetStyleNameIndex(nTable, nRow);
1456 if (nRow > nEndRowHidden)
1458 bPrevHidden = rRowAttr.
rowHidden(nTable, nRow, nEndRowHidden);
1459 bHidden = bPrevHidden;
1461 if (nRow > nEndRowFiltered)
1463 bPrevFiltered = rRowAttr.
rowFiltered(nTable, nRow, nEndRowFiltered);
1464 bFiltered = bPrevFiltered;
1474 if (nRow > nEndRowHidden)
1475 bHidden = rRowAttr.
rowHidden(nTable, nRow, nEndRowHidden);
1476 if (nRow > nEndRowFiltered)
1477 bFiltered = rRowAttr.
rowFiltered(nTable, nRow, nEndRowFiltered);
1479 if (
nIndex == nPrevIndex && bHidden == bPrevHidden && bFiltered == bPrevFiltered &&
1486 assert(nPrevIndex >= 0 &&
"coverity#1438402");
1488 OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
1492 bPrevHidden = bHidden;
1493 bPrevFiltered = bFiltered;
1497 assert(nPrevIndex >= 0 &&
"coverity#1438402");
1498 OpenNewRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
1503 bool bHidden =
false;
1504 bool bFiltered =
false;
1507 sal_Int32 nEndRowHidden;
1508 sal_Int32 nEndRowFiltered;
1509 bHidden = rRowAttr.
rowHidden(nTable, nStartRow, nEndRowHidden);
1510 bFiltered = rRowAttr.
rowFiltered(nTable, nStartRow, nEndRowFiltered);
1512 assert(
nIndex >= 0 &&
"coverity#1438402");
1515 nOpenRow = nStartRow + nRepeatRow - 1;
1541 const sal_Int32 nEndCol,
const sal_Int32 nEndRow,
const sal_Int32 nSheet)
1545 if (nStartRow == nEndRow)
1549 OpenRow(nSheet, nStartRow, 1, aRowAttr);
1561 sal_Int32 nTotalRows(nEndRow - nStartRow + 1 - 1);
1562 while (nRows < nTotalRows)
1567 OSL_ENSURE(nMaxRows,
"something went wrong");
1568 if (nMaxRows >= nTotalRows - nRows)
1570 OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows, aRowAttr);
1571 nRows += nTotalRows - nRows;
1575 OpenRow(nSheet, nStartRow + nRows, nMaxRows, aRowAttr);
1583 if (nTotalRows == 1)
1585 OpenRow(nSheet, nEndRow, 1, aRowAttr);
1593 sal_Int32 nTotalRows(nEndRow - nStartRow + 1 - 1);
1594 while (nRows < nTotalRows)
1598 OSL_ENSURE(nMaxRows,
"something went wrong");
1599 if (nMaxRows >= nTotalRows - nRows)
1601 OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows, aRowAttr);
1602 nRows += nTotalRows - nRows;
1606 OpenRow(nSheet, nStartRow + nRows, nMaxRows, aRowAttr);
1614 OpenRow(nSheet, nEndRow, 1, aRowAttr);
1623 bool& rHasRowHeader,
ScRange& rRowHeaderRange,
1624 OUString& rPrintRanges)
const
1626 uno::Reference <sheet::XPrintAreas> xPrintAreas (
xCurrentTable, uno::UNO_QUERY);
1627 if (!xPrintAreas.is())
1630 rHasRowHeader = xPrintAreas->getPrintTitleRows();
1631 rHasColumnHeader = xPrintAreas->getPrintTitleColumns();
1632 table::CellRangeAddress rTempRowHeaderRange = xPrintAreas->getTitleRows();
1633 rRowHeaderRange =
ScRange(rTempRowHeaderRange.StartColumn,
1634 rTempRowHeaderRange.StartRow,
1635 rTempRowHeaderRange.Sheet,
1636 rTempRowHeaderRange.EndColumn,
1637 rTempRowHeaderRange.EndRow,
1638 rTempRowHeaderRange.Sheet);
1639 table::CellRangeAddress rTempColumnHeaderRange = xPrintAreas->getTitleColumns();
1640 rColumnHeaderRange =
ScRange(rTempColumnHeaderRange.StartColumn,
1641 rTempColumnHeaderRange.StartRow,
1642 rTempColumnHeaderRange.Sheet,
1643 rTempColumnHeaderRange.EndColumn,
1644 rTempColumnHeaderRange.EndRow,
1645 rTempColumnHeaderRange.Sheet);
1646 uno::Sequence< table::CellRangeAddress > aRangeList( xPrintAreas->getPrintAreas() );
1652 size_t nDepth = pFields->
GetDepth();
1653 for (
size_t i = 0;
i < nDepth; ++
i)
1656 for (
size_t j = 0; j < nFields; ++j)
1661 aGroup.
nLevel =
static_cast<sal_Int16
>(
i);
1694 uno::Sequence<sal_Int8> aPassHash;
1744 const uno::Reference< io::XOutputStream >& xOutput,
1747 const sal_Int32 nBufSize = 16*1024;
1748 uno::Sequence<sal_Int8> aSequence(nBufSize);
1750 sal_Int32 nRemaining =
nCount;
1753 while ( nRemaining > 0 )
1755 sal_Int32 nRead = xInput->readBytes( aSequence, std::min( nRemaining, nBufSize ) );
1759 if ( nRead < 1 || aSequence[0] !=
static_cast<sal_Int8>(
'<') )
1765 if (nRead == nRemaining)
1768 if ( aSequence[nRead-1] !=
static_cast<sal_Int8>(
'>') )
1774 if ( nRead == nBufSize )
1776 xOutput->writeBytes( aSequence );
1777 nRemaining -= nRead;
1783 uno::Sequence<sal_Int8> aTempBuf( aSequence.getConstArray(), nRead );
1784 xOutput->writeBytes( aTempBuf );
1798 const sal_Int32 nMaxSize = 32*1024;
1800 if ( nBytesToSkip > 0 )
1802 sal_Int32 nRemaining = nBytesToSkip;
1803 while ( nRemaining > 0 )
1805 sal_Int32 nSkip = std::min( nRemaining, nMaxSize );
1806 xInput->skipBytes( nSkip );
1807 nRemaining -= nSkip;
1814 uno::Reference<xml::sax::XDocumentHandler> xHandler =
GetDocHandler();
1815 uno::Reference<io::XActiveDataSource> xDestSource( xHandler, uno::UNO_QUERY );
1816 if ( !xDestSource.is() )
1819 uno::Reference<io::XOutputStream> xDestStream = xDestSource->getOutputStream();
1820 uno::Reference<io::XSeekable> xDestSeek( xDestStream, uno::UNO_QUERY );
1821 if ( !xDestSeek.is() )
1825 xDestSource->setOutputStream( xDestStream );
1829 static constexpr OStringLiteral aOutStr(
"\n ");
1830 uno::Sequence<sal_Int8> aOutSeq(
reinterpret_cast<sal_Int8 const *
>(aOutStr.getStr()), aOutStr.getLength() );
1831 xDestStream->writeBytes( aOutSeq );
1834 rNewStart =
static_cast<sal_Int32
>(xDestSeek->getPosition());
1844 uno::Sequence<OUString> aEmptySeq;
1849 rNewEnd =
static_cast<sal_Int32
>(xDestSeek->getPosition());
1861 ScFormatSaveData* pFormatData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetFormatSaveData();
1863 for (
const auto& rFormatInfo : pFormatData->
maIDToName)
1865 xAutoStylePool->RegisterDefinedName(XmlStyleFamily::TABLE_CELL, rFormatInfo.second);
1874 SCTAB nTableCount(0);
1875 sal_Int32 nShapesCount(0);
1877 OSL_FAIL(
"no shared data set");
1885 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
GetModel(), uno::UNO_QUERY );
1886 if ( !xSpreadDoc.is() )
1889 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetSheetSaveData();
1893 uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
1899 sal_Int32 nTableCount(xIndex->getCount());
1915 mpCellsItr->SetEmptyDatabaseRanges( &aEmptyRanges );
1917 mpCellsItr->SetDetectiveOp( &aDetectiveOpContainer );
1919 if (nTableCount > 0)
1922 for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable)
1924 sal_Int32 nStartOffset = -1;
1925 sal_Int32 nEndOffset = -1;
1927 pSheetData->
GetStreamPos( nTable, nStartOffset, nEndOffset );
1929 if ( nStartOffset >= 0 && nEndOffset >= 0 &&
xSourceStream.is() )
1931 sal_Int32 nNewStart = -1;
1932 sal_Int32 nNewEnd = -1;
1936 pSheetData->
AddSavePos( nTable, nNewStart, nNewEnd );
1943 uno::Reference<sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
1965 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
GetModel(), uno::UNO_QUERY );
1966 if (xSpreadDoc.is())
1971 SCTAB nTableCount(0);
1972 sal_Int32 nShapesCount(0);
1978 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(
GetModel(), uno::UNO_QUERY);
1979 if (xMultiServiceFactory.is())
1981 uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance(
"com.sun.star.sheet.Defaults"), uno::UNO_QUERY);
1982 if (xProperties.is())
1990 aStylesExp->exportStyleFamily(
"CellStyles",
1997 const uno::Reference<sheet::XSpreadsheet>& xTable,
1998 sal_Int32 nTable,
const OUString* pOldName)
2000 css::uno::Any aAny = xProperties->getPropertyValue(
"FormatID");
2001 sal_uInt64 nKey = 0;
2005 uno::Reference<sheet::XSheetCellRanges> xCellRanges( xProperties, uno::UNO_QUERY );
2007 OUString sStyleName;
2008 sal_Int32 nNumberFormat(-1);
2009 sal_Int32 nValidationIndex(-1);
2011 std::vector< XMLPropertyState >::iterator aItr(aPropStates.begin());
2012 std::vector< XMLPropertyState >::iterator aEndItr(aPropStates.end());
2014 while (aItr != aEndItr)
2016 if (aItr->mnIndex != -1)
2027 aItr = aPropStates.erase(aItr);
2028 aEndItr = aPropStates.end();
2033 aItr->maValue >>= sStyleName;
2041 if (aItr->maValue >>= nNumberFormat)
2062 aPropStates.clear();
2063 if (nNumberFormat == -1)
2065 if (sStyleName.isEmpty())
2068 if (!aPropStates.empty())
2073 if (
GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_CELL, sStyleName, std::move(aPropStates)))
2083 bool bAdded =
false;
2086 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
GetModel(), uno::UNO_QUERY );
2087 ScFormatSaveData* pFormatData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetFormatSaveData();
2088 auto itr = pFormatData->
maIDToName.find(nKey);
2091 sName = itr->second;
2097 bool bIsAutoStyle(
true);
2105 const uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
2106 bool bGetMerge(
true);
2107 for (table::CellRangeAddress
const & address : aAddresses)
2109 pSharedData->SetLastColumn(nTable, address.EndColumn);
2111 pCellStyles->AddRangeStyleName(address,
nIndex, bIsAutoStyle, nValidationIndex, nNumberFormat);
2113 bGetMerge =
GetMerged(&address, xTable);
2124 const uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
2125 bool bGetMerge(
true);
2126 for (table::CellRangeAddress
const & address : aAddresses)
2129 bGetMerge =
GetMerged(&address, xTable);
2130 pCellStyles->AddRangeStyleName(address,
nIndex,
false, nValidationIndex, nNumberFormat);
2131 if( sStyleName !=
"Default" || nValidationIndex != -1 )
2133 pSharedData->SetLastColumn(nTable, address.EndColumn);
2142 const OUString* pOldName, sal_Int32& rIndex,
bool& rIsVisible)
2145 if(aPropStates.empty())
2148 auto aItr = std::find_if(aPropStates.begin(), aPropStates.end(),
2150 return xColumnStylesPropertySetMapper->GetEntryContextId(rPropState.mnIndex) == CTF_SC_ISVISIBLE; });
2151 if (aItr != aPropStates.end())
2153 aItr->maValue >>= rIsVisible;
2156 const OUString sParent;
2159 if (
GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_COLUMN, sParent, std::move(aPropStates)))
2179 const OUString* pOldName, sal_Int32& rIndex)
2182 if(aPropStates.empty())
2185 const OUString sParent;
2188 if (
GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_ROW, sParent, std::move(aPropStates)))
2192 rIndex =
pRowStyles->AddStyleName(*pOldName);
2210 uno::Reference<container::XEnumeration> xEnum( xEnumAccess->createEnumeration() );
2213 sal_Int32 nSkip =
nIndex;
2216 (void) xEnum->nextElement();
2219 aRet = xEnum->nextElement();
2221 catch (container::NoSuchElementException&)
2238 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
GetModel(), uno::UNO_QUERY );
2239 if (!xSpreadDoc.is())
2242 uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
2252 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetSheetSaveData();
2253 if (pSheetData &&
pDoc)
2258 for (
SCTAB nTab=0; nTab<nTabCount; ++nTab)
2263 const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->
GetCellStyles();
2264 for (
const auto& rCellEntry : rCellEntries)
2267 sal_Int32 nTable = aPos.
Tab();
2271 uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2272 uno::Reference <beans::XPropertySet> xProperties(
2273 xTable->getCellByPosition( aPos.
Col(), aPos.
Row() ), uno::UNO_QUERY );
2280 const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->
GetColumnStyles();
2281 for (
const auto& rColumnEntry : rColumnEntries)
2283 ScAddress aPos = rColumnEntry.maCellPos;
2284 sal_Int32 nTable = aPos.
Tab();
2288 uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2289 uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
2290 uno::Reference<beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex( aPos.
Col() ), uno::UNO_QUERY);
2293 bool bIsVisible(
true);
2299 const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->
GetRowStyles();
2300 for (
const auto& rRowEntry : rRowEntries)
2303 sal_Int32 nTable = aPos.
Tab();
2307 uno::Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2308 uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
2309 uno::Reference<beans::XPropertySet> xRowProperties(xTableRows->getByIndex( aPos.
Row() ), uno::UNO_QUERY);
2317 const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->
GetTableStyles();
2318 for (
const auto& rTableEntry : rTableEntries)
2321 sal_Int32 nTable = aPos.
Tab();
2326 uno::Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2327 if (xTableProperties.is())
2330 OUString
sName( rTableEntry.maName );
2331 GetAutoStylePool()->AddNamed(
sName, XmlStyleFamily::TABLE_TABLE, OUString(), std::move(aPropStates));
2341 const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->
GetNoteStyles();
2342 for (
const auto& rNoteEntry : rNoteEntries)
2352 OSL_ENSURE( pNote,
"note not found" );
2357 uno::Reference<beans::XPropertySet> xShapeProperties( pDrawObj->
getUnoShape(), uno::UNO_QUERY );
2358 if (xShapeProperties.is())
2360 if ( !rNoteEntry.maStyleName.isEmpty() )
2362 std::vector<XMLPropertyState> aPropStates(xShapeMapper->Filter(*
this, xShapeProperties));
2363 OUString
sName( rNoteEntry.maStyleName );
2364 GetAutoStylePool()->AddNamed(
sName, XmlStyleFamily::SD_GRAPHICS_ID, OUString(), std::move(aPropStates));
2367 if ( !rNoteEntry.maTextStyle.isEmpty() )
2369 std::vector<XMLPropertyState> aPropStates(
2371 OUString
sName( rNoteEntry.maTextStyle );
2372 GetAutoStylePool()->AddNamed(
sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), std::move(aPropStates));
2384 const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->
GetNoteParaStyles();
2385 for (
const auto& rNoteParaEntry : rNoteParaEntries)
2387 ScAddress aPos = rNoteParaEntry.maCellPos;
2393 OSL_ENSURE( pNote,
"note not found" );
2397 uno::Reference<container::XEnumerationAccess> xCellText(pDrawObj->
getUnoShape(), uno::UNO_QUERY);
2398 uno::Reference<beans::XPropertySet> xParaProp(
2399 lcl_GetEnumerated( xCellText, rNoteParaEntry.maSelection.nStartPara ), uno::UNO_QUERY );
2400 if ( xParaProp.is() )
2402 std::vector<XMLPropertyState> aPropStates(xParaPropMapper->Filter(*
this, xParaProp));
2403 OUString
sName( rNoteParaEntry.maName );
2404 GetAutoStylePool()->AddNamed(
sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), std::move(aPropStates));
2415 const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->
GetNoteTextStyles();
2416 for (
const auto& rNoteTextEntry : rNoteTextEntries)
2418 ScAddress aPos = rNoteTextEntry.maCellPos;
2424 OSL_ENSURE( pNote,
"note not found" );
2428 uno::Reference<text::XSimpleText> xCellText(pDrawObj->
getUnoShape(), uno::UNO_QUERY);
2429 uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY);
2430 ScDrawTextCursor* pCursor = comphelper::getFromUnoTunnel<ScDrawTextCursor>( xCursorProp );
2433 pCursor->SetSelection( rNoteTextEntry.maSelection );
2435 std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*
this, xCursorProp));
2436 OUString
sName( rNoteTextEntry.maName );
2449 uno::Reference<beans::XPropertySet> xPrevCursorProp;
2450 const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->
GetTextStyles();
2451 for (
const auto& rTextEntry : rTextEntries)
2454 sal_Int32 nTable = aPos.
Tab();
2462 uno::Reference<beans::XPropertySet> xCursorProp;
2463 if (xPrevCursorProp && aPrevPos == aPos)
2464 xCursorProp = xPrevCursorProp;
2467 uno::Reference<table::XCellRange> xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2468 uno::Reference<text::XSimpleText> xCellText(xCellRange->getCellByPosition(aPos.
Col(), aPos.
Row()), uno::UNO_QUERY);
2469 xCursorProp.set(xCellText->createTextCursor(), uno::UNO_QUERY);
2471 ScCellTextCursor* pCursor = comphelper::getFromUnoTunnel<ScCellTextCursor>( xCursorProp );
2474 pCursor->SetSelection( rTextEntry.maSelection );
2476 std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*
this, xCursorProp));
2477 OUString
sName( rTextEntry.maName );
2480 xPrevCursorProp = xCursorProp;
2489 SCTAB nTableCount(0);
2490 sal_Int32 nShapesCount(0);
2493 sal_Int32 nTableCount(xIndex->getCount());
2498 uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2503 uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
2504 if (xTableProperties.is())
2507 if(!aPropStates.empty())
2516 uno::Reference<sheet::XUniqueCellFormatRangesSupplier> xCellFormatRanges ( xTable, uno::UNO_QUERY );
2517 if ( xCellFormatRanges.is() )
2519 uno::Reference<container::XIndexAccess> xFormatRangesIndex(xCellFormatRanges->getUniqueCellFormatRanges());
2520 if (xFormatRangesIndex.is())
2522 sal_Int32 nFormatRangesCount(xFormatRangesIndex->getCount());
2524 for (sal_Int32 nFormatRange = 0; nFormatRange < nFormatRangesCount; ++nFormatRange)
2526 uno::Reference< sheet::XSheetCellRanges> xCellRanges(xFormatRangesIndex->getByIndex(nFormatRange), uno::UNO_QUERY);
2527 if (xCellRanges.is())
2529 uno::Reference <beans::XPropertySet> xProperties (xCellRanges, uno::UNO_QUERY);
2530 if (xProperties.is())
2539 uno::Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY);
2540 if (xColumnRowRange.is() &&
pDoc)
2543 uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
2544 if (xTableColumns.is())
2548 table::CellRangeAddress aCellAddress(
GetEndAddress(xTable));
2549 if (aCellAddress.EndColumn > nColumns)
2556 sal_Int32 nColumn = 0;
2557 while (nColumn <= pDoc->MaxCol())
2560 bool bIsVisible(
true);
2561 uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY);
2562 if (xColumnProperties.is())
2567 sal_Int32 nOld(nColumn);
2569 for (sal_Int32
i = nOld + 1;
i < nColumn; ++
i)
2572 if (aCellAddress.EndColumn > nColumns)
2574 bool bIsVisible(
true);
2576 for (sal_Int32
i = nColumns + 1;
i <= aCellAddress.EndColumn; ++
i)
2580 uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
2581 if (xTableRows.is())
2588 while (nRow <= pDoc->MaxRow())
2591 uno::Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY);
2592 if(xRowProperties.is())
2597 sal_Int32 nOld(nRow);
2599 if (nRow > nOld + 1)
2622 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
GetModel(), uno::UNO_QUERY );
2623 if (!xSpreadDoc.is())
2626 uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
2690 pSharedData->AddNoteObj( xShape, pCaptData->maStart );
2694 OSL_ENSURE( pCaptData->maStart.Tab() ==
nCurrentTable,
"invalid table in object data" );
2713 const uno::Reference <sheet::XSpreadsheet>& xTable)
2716 sal_Int32 nRow(pCellAddress->StartRow);
2717 sal_Int32 nCol(pCellAddress->StartColumn);
2718 sal_Int32 nEndRow(pCellAddress->EndRow);
2719 sal_Int32 nEndCol(pCellAddress->EndColumn);
2720 bool bRowInc(nEndRow > nRow);
2721 while(!bReady && nRow <= nEndRow && nCol <= nEndCol)
2723 uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xTable->getCellRangeByPosition(nCol, nRow, nCol, nRow), uno::UNO_QUERY);
2724 if (xSheetCellRange.is())
2726 uno::Reference<sheet::XSheetCellCursor> xCursor(xTable->createCursorByRange(xSheetCellRange));
2729 uno::Reference<sheet::XCellRangeAddressable> xCellAddress (xCursor, uno::UNO_QUERY);
2730 xCursor->collapseToMergedArea();
2731 table::CellRangeAddress aCellAddress2(xCellAddress->getRangeAddress());
2732 ScRange aScRange( aCellAddress2.StartColumn, aCellAddress2.StartRow, aCellAddress2.Sheet,
2733 aCellAddress2.EndColumn, aCellAddress2.EndRow, aCellAddress2.Sheet );
2735 if ((aScRange.
aEnd.
Row() > nRow ||
2736 aScRange.
aEnd.
Col() > nCol) &&
2756 OSL_ENSURE(!(!bReady && nEndRow > nRow && nEndCol > nCol),
"should not be possible");
2761 ScRange& aCellAddress,
bool& bIsFirst)
const
2769 aCellAddress = aMatrixRange;
2795 uno::Reference<container::XNamed> xName (xTable, uno::UNO_QUERY );
2800 OUString sOUTableName(xName->getName());
2804 uno::Reference<util::XProtectable> xProtectable (xTable, uno::UNO_QUERY);
2806 if (xProtectable.is() && xProtectable->isProtected())
2863 OUString sPrintRanges;
2865 bool bHasColumnHeader;
2867 if( !sPrintRanges.isEmpty() )
2902 uno::Reference<document::XEventsSupplier> xSupplier(xTable, uno::UNO_QUERY);
2903 uno::Reference<container::XNameAccess> xEvents = xSupplier->getEvents();
2909 uno::Reference<drawing::XDrawPage> xDrawPage;
2910 if (
pSharedData->HasForm(nTable, xDrawPage) && xDrawPage.is())
2915 OSL_ENSURE( bRet,
"OFormLayerXMLExport::seekPage failed!" );
2923 pSharedData->SetLastColumn(nTable, aRange.EndColumn);
2929 if (bHasColumnHeader)
2938 ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader);
2939 bool bIsFirst(
true);
2940 sal_Int32 nEqualCells(0);
2991 if (pRangeName && !pRangeName->
empty())
3009 std::unique_ptr<SvXMLElementExport> pElem;
3010 if (!rStyleName.isEmpty())
3013 rExport.
AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, rStyleName);
3025 case text::textfield::Type::URL:
3032 rExport.
AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE,
"simple");
3034 if (!aTargetFrame.isEmpty())
3035 rExport.
AddAttribute(XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, aTargetFrame);
3048 OUStringBuffer
aBuf;
3049 sal_Int32 nVal = aDate.GetYear();
3050 aBuf.append(OUString::number(nVal) +
"-");
3051 nVal = aDate.GetMonth();
3054 aBuf.append(OUString::number(nVal) +
"-");
3055 nVal = aDate.GetDay();
3059 rExport.
AddAttribute(XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME,
"N2");
3060 rExport.
AddAttribute(XML_NAMESPACE_TEXT, XML_DATE_VALUE,
aBuf.makeStringAndClear());
3068 case text::textfield::Type::DOCINFO_TITLE:
3097 ScXMLExport& rExport, std::u16string_view rParaText,
3100 std::vector<editeng::Section>::const_iterator it, std::vector<editeng::Section>::const_iterator
const & itEnd )
3106 for (; it != itEnd; ++it)
3112 std::vector<XMLPropertyState> aPropStates;
3114 OUString aStyleName = xStylePool->Find(XmlStyleFamily::TEXT_TEXT, OUString(), aPropStates);
3115 if (aContent ==
"\x001" && !pField)
3119 if (
p->Which() == EE_FEATURE_TAB)
3127 writeContent(rExport, aStyleName, aContent, pField);
3143 if (bIsFirstMatrixCell)
3150 bool bIsEmpty(
false);
3151 switch (aCell.
nType)
3153 case table::CellContentType_EMPTY :
3158 case table::CellContentType_VALUE :
3167 case table::CellContentType_TEXT :
3171 bool bExportValue = sCellString.indexOf(
'\x001') == -1;
3173 sCellString, sFormattedString, bExportValue);
3179 case table::CellContentType_FORMULA :
3185 if (!bIsMatrix || bIsFirstMatrixCell)
3194 sal_uInt16 nNamespacePrefix =
3206 if (pFormulaCell->
GetErrCode() != FormulaError::NONE)
3216 else if (pFormulaCell->
IsValue())
3288 bool bPrevCharWasSpace =
true;
3304 std::vector<OUString> aParaTexts;
3306 aParaTexts.reserve(nParaCount);
3307 for (sal_Int32
i = 0;
i < nParaCount; ++
i)
3308 aParaTexts.push_back(pText->
GetText(
i));
3311 std::vector<editeng::Section> aAttrs;
3313 std::vector<editeng::Section>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end();
3314 std::vector<editeng::Section>::const_iterator itPara = itSec;
3315 sal_Int32 nCurPara = 0;
3316 for (; itSec != itSecEnd; ++itSec)
3324 flushParagraph(*
this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSec);
3329 flushParagraph(*
this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSecEnd);
3338 const sal_Unicode* pEnd =
p +
static_cast<size_t>(aResStr.getLength());
3340 for (;
p != pEnd; ++
p)
3350 aContent = OUString(pPara,
p-pPara);
3362 aContent = OUString(pPara, pEnd-pPara);
3370 uno::Reference < beans::XPropertySet > xShapeProps ( xShape, uno::UNO_QUERY );
3371 bool bIsChart(
false );
3372 if (xShapeProps.is())
3374 sal_Int32 nZOrder = 0;
3375 if (xShapeProps->getPropertyValue(
"ZOrder") >>= nZOrder)
3379 uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xShapeProps->getPropertySetInfo();
3380 OUString sPropCLSID (
"CLSID");
3381 if( xPropSetInfo->hasPropertyByName( sPropCLSID ) )
3384 if (xShapeProps->getPropertyValue( sPropCLSID ) >>= sCLSID)
3386 if ( sCLSID.equalsIgnoreAsciiCase(
GetChartExport()->getChartCLSID()) )
3392 OUString aChartName;
3393 xShapeProps->getPropertyValue(
"PersistName" ) >>= aChartName;
3401 if ( rRangeList.
is() )
3404 if ( !sRanges.isEmpty() )
3408 pAttrList->AddAttribute(
3417 if ( sRanges.isEmpty() )
3419 uno::Reference< frame::XModel > xChartModel;
3420 if( ( xShapeProps->getPropertyValue(
"Model" ) >>= xChartModel ) &&
3423 uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY );
3424 uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY );
3425 if( xChartDoc.is() && xReceiver.is() &&
3426 ! xChartDoc->hasInternalDataProvider())
3430 uno::Sequence< OUString > aRepresentations(
3431 xReceiver->getUsedRangeRepresentations());
3435 if (aRepresentations.hasElements())
3440 uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY );
3441 sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter );
3443 pAttrList->AddAttribute(
3447 catch (
const lang::IllegalArgumentException&)
3480 aPoint.X = aCellRectFull.
Right();
3482 aPoint.X = aCellRectFull.
Left();
3483 aPoint.Y = aCellRectFull.
Top();
3485 for (
const auto& rShape : rMyCell.
aShapeList)
3489 if (!rShape.xShape.is())
3498 if (!aSnapStartAddress.
IsValid())
3508 bool bNeedsRestore =
false;
3509 std::unique_ptr<SdrObjGeoData> pGeoData = pObj->
GetGeoData();
3512 SCTAB aTab(aSnapStartAddress.
Tab());
3513 SCCOL aCol(aSnapStartAddress.
Col());
3514 SCROW aRow(aSnapStartAddress.
Row());
3518 Point aFullTopPoint;
3528 if (aFullTopPoint != aActualTopPoint)
3530 bNeedsRestore =
true;
3531 Point aMoveBy = aFullTopPoint - aActualTopPoint;
3544 aCol = aSnapEndAddress.
Col();
3545 aRow = aSnapEndAddress.
Row();
3548 Point aFullBottomPoint;
3550 aFullBottomPoint.
setX(aFullEndCellRect.
Right() - aSnapEndOffset.
X());
3552 aFullBottomPoint.
setX(aFullEndCellRect.
Left() + aSnapEndOffset.
X());
3553 aFullBottomPoint.
setY(aFullEndCellRect.
Top() + aSnapEndOffset.
Y());
3557 if (aFullSnapRect != aActualSnapRect)
3559 bNeedsRestore =
true;
3567 pObj->
NbcResize(aFullTopPoint, aScaleWidth, aScaleHeight);
3578 OUString sEndAddress;
3580 FormulaGrammar::CONV_OOO);
3582 OUStringBuffer sBuffer;
3604 awt::Point aMatrixTranslate = rShape.xShape->getPosition();
3613 if (bNeedsRestore && pGeoData)
3621 if (!pTableShapes || (*pTableShapes)[
nCurrentTable].empty())
3624 OSL_ENSURE(pTableShapes->size() >
static_cast<size_t>(
nCurrentTable),
"wrong Table");
3635 uno::Reference<beans::XPropertySet> xShapeProp(rxShape, uno::UNO_QUERY);
3636 awt::Rectangle aFrameRect;
3637 if (xShapeProp.is() && (xShapeProp->getPropertyValue(
"FrameRect") >>= aFrameRect))
3643 awt::Point aRefPoint;
3644 aRefPoint.X = 2 * aFrameRect.X + aFrameRect.Width - 1;
3673 OUStringBuffer sValue;
3692 uno::Reference<drawing::XShape> xCurrentShape( pNoteCaption->
getUnoShape(), uno::UNO_QUERY );
3693 if (xCurrentShape.get()!=xShape.get())
3696 const OUString& sAuthor(pNote->
GetAuthor());
3697 if (!sAuthor.isEmpty())
3705 const OUString& aDate(pNote->
GetDate());
3713 OUStringBuffer sBuf;
3751 uno::Reference<drawing::XShape> xShape( pNoteCaption->
getUnoShape(), uno::UNO_QUERY );
3766 sal_Int32 nObjCount(rObjVec.size());
3767 sal_Int32 nOpCount(rOpVec.size());
3768 if( !(nObjCount || nOpCount) )
3773 for(
const auto& rObj : rObjVec)
3784 if( rObj.bHasError )
3791 for(
const auto& rOp : rOpVec)
3803 if (nEqualCellCount > 0)
3805 sal_Int32 nTemp(nEqualCellCount + 1);
3806 OUString sOUEqualCellCount(OUString::number(nTemp));
3820 bool bIsEqual =
false;
3843 switch ( aCell1.
nType )
3845 case table::CellContentType_EMPTY :
3850 case table::CellContentType_VALUE :
3858 case table::CellContentType_TEXT :
3868 case table::CellContentType_FORMULA :
3888 uno::Reference<beans::XPropertySet> xPropertySet(xSpreadDoc, uno::UNO_QUERY);
3889 if (!xPropertySet.is())
3892 bool bCalcAsShown (::cppu::any2bool( xPropertySet->getPropertyValue(
SC_UNO_CALCASSHOWN) ));
3893 bool bIgnoreCase (::cppu::any2bool( xPropertySet->getPropertyValue(
SC_UNO_IGNORECASE) ));
3894 bool bLookUpLabels (::cppu::any2bool( xPropertySet->getPropertyValue(
SC_UNO_LOOKUPLABELS) ));
3895 bool bMatchWholeCell (::cppu::any2bool( xPropertySet->getPropertyValue(
SC_UNO_MATCHWHOLE) ));
3896 bool bUseRegularExpressions (::cppu::any2bool( xPropertySet->getPropertyValue(
SC_UNO_REGEXENABLED) ));
3898 if (bUseWildcards && bUseRegularExpressions)
3899 bUseRegularExpressions =
false;
3900 bool bIsIterationEnabled (::cppu::any2bool( xPropertySet->getPropertyValue(
SC_UNO_ITERENABLED) ));
3902 sal_Int32 nIterationCount(100);
3904 double fIterationEpsilon = 0;
3906 util::Date aNullDate;
3908 if (!(bCalcAsShown || bIgnoreCase || !bLookUpLabels || !bMatchWholeCell || !bUseRegularExpressions ||
3910 bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001) ||
3911 aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 || nYear2000 != 1930))
3918 if (!bMatchWholeCell)
3922 if (!bUseRegularExpressions)
3926 if (nYear2000 != 1930)
3932 if (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899)
3934 OUStringBuffer sDate;
3939 if (bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001))
3941 if (bIsIterationEnabled)
3943 if (nIterationCount != 100)
3947 if (!::rtl::math::approxEqual(fIterationEpsilon, 0.001))
3949 OUStringBuffer sBuffer;
3961 uno::Reference <sheet::XSheetLinkable> xLinkable (
xCurrentTable, uno::UNO_QUERY);
3962 if (!(xLinkable.is() &&
GetModel().is()))
3965 sheet::SheetLinkMode nMode (xLinkable->getLinkMode());
3966 if (nMode == sheet::SheetLinkMode_NONE)
3969 OUString sLink (xLinkable->getLinkUrl());
3970 uno::Reference <beans::XPropertySet> xProps (
GetModel(), uno::UNO_QUERY);
3974 uno::Reference <container::XIndexAccess> xIndex(xProps->getPropertyValue(
SC_UNO_SHEETLINKS), uno::UNO_QUERY);
3978 sal_Int32
nCount(xIndex->getCount());
3983 uno::Reference <beans::XPropertySet> xLinkProps;
3984 for (sal_Int32
i = 0; (
i <
nCount) && !bFound; ++
i)
3986 xLinkProps.set(xIndex->getByIndex(
i), uno::UNO_QUERY);
3987 if (xLinkProps.is())
3991 bFound = sLink == sNewLink;
3994 if (!(bFound && xLinkProps.is()))
3998 OUString sFilterOptions;
3999 OUString sTableName (xLinkable->getLinkSheetName());
4000 sal_Int32 nRefresh(0);
4004 if (sLink.isEmpty())
4009 if (!sTableName.isEmpty())
4011 if (!sFilter.isEmpty())
4013 if (!sFilterOptions.isEmpty())
4015 if (nMode != sheet::SheetLinkMode_NORMAL)
4019 OUStringBuffer sBuffer;
4021 static_cast<double>(nRefresh) / 86400 );
4054 OUString sRangeListStr;
4057 if (!sComment.isEmpty())
4064 uno::Reference< beans::XPropertySet > xDocProp( xSpreadDoc, uno::UNO_QUERY );
4065 if( !xDocProp.is() )
return;
4068 uno::Reference< container::XIndexAccess > xColRangesIAccess(xDocProp->getPropertyValue(
SC_UNO_COLLABELRNG ), uno::UNO_QUERY);
4069 if( xColRangesIAccess.is() )
4070 nCount += xColRangesIAccess->getCount();
4072 uno::Reference< container::XIndexAccess > xRowRangesIAccess(xDocProp->getPropertyValue(
SC_UNO_ROWLABELRNG ), uno::UNO_QUERY);
4073 if( xRowRangesIAccess.is() )
4074 nCount += xRowRangesIAccess->getCount();
4086 if( !xRangesIAccess.is() )
return;
4088 sal_Int32
nCount(xRangesIAccess->getCount());
4091 uno::Reference< sheet::XLabelRange > xRange(xRangesIAccess->getByIndex(
nIndex ), uno::UNO_QUERY);
4095 table::CellRangeAddress aCellRange( xRange->getLabelArea() );
4098 aCellRange = xRange->getDataArea();
4127 if (rDataSources.empty())
4131 for (
const auto& itr : rDataSources)
4148 for (
auto& itr : aDataTransformations)
4152 switch(aTransformationType)
4157 std::shared_ptr<sc::ColumnRemoveTransformation> aDeleteTransformation = std::dynamic_pointer_cast<sc::ColumnRemoveTransformation>(itr);
4158 std::set<SCCOL> aColumns = aDeleteTransformation->getColumns();
4160 for(
auto&
col : aColumns)
4170 std::shared_ptr<sc::SplitColumnTransformation> aSplitTransformation = std::dynamic_pointer_cast<sc::SplitColumnTransformation>(itr);
4180 std::shared_ptr<sc::MergeColumnTransformation> aMergeTransformation = std::dynamic_pointer_cast<sc::MergeColumnTransformation>(itr);
4181 std::set<SCCOL> aColumns = aMergeTransformation->getColumns();
4186 for(
auto&
col : aColumns)
4197 std::shared_ptr<sc::SortTransformation> aSortTransformation = std::dynamic_pointer_cast<sc::SortTransformation>(itr);
4198 ScSortParam aSortParam = aSortTransformation->getSortParam();
4216 std::shared_ptr<sc::TextTransformation> aTextTransformation = std::dynamic_pointer_cast<sc::TextTransformation>(itr);
4220 switch ( aTextTransformType )
4236 std::set<SCCOL> aColumns = aTextTransformation->getColumns();
4240 for(
auto&
col : aColumns)
4251 std::shared_ptr<sc::AggregateFunction> aAggregateFunction = std::dynamic_pointer_cast<sc::AggregateFunction>(itr);
4252 std::set<SCCOL> aColumns = aAggregateFunction->getColumns();
4256 switch (aAggregateType)
4274 for(
auto&
col : aColumns)
4285 std::shared_ptr<sc::NumberTransformation> aNumberTransformation = std::dynamic_pointer_cast<sc::NumberTransformation>(itr);
4289 switch ( aNumberTransformType )
4335 std::set<SCCOL> aColumns = aNumberTransformation->getColumn();
4336 for(
auto&
col : aColumns)
4347 std::shared_ptr<sc::ReplaceNullTransformation> aReplaceNullTransformation = std::dynamic_pointer_cast<sc::ReplaceNullTransformation>(itr);
4348 std::set<SCCOL> aColumns = aReplaceNullTransformation->getColumn();
4353 for(
auto&
col : aColumns)
4364 std::shared_ptr<sc::DateTimeTransformation> aDateTimeTransformation = std::dynamic_pointer_cast<sc::DateTimeTransformation>(itr);
4368 switch ( aDateTimeTransformationType )
4428 std::set<SCCOL> aColumns = aDateTimeTransformation->getColumn();
4429 for(
auto&
col : aColumns)
4448 if (!officecfg::Office::Common::Misc::ExperimentalMode::get())
4489 for (
const auto& rxEntry : *pRangeName)
4493 OUString sBaseCellAddress;
4494 rxEntry.second->ValidateTabRefs();
4497 assert(!sBaseCellAddress.isEmpty());
4501 OUString sTempSymbol(sSymbol);
4503 if (rxEntry.second->IsReference(aRange))
4506 OUString sContent(sTempSymbol.copy(1, sTempSymbol.getLength() -2 ));
4509 sal_Int32 nRangeType = rxEntry.second->GetUnoType();
4510 OUStringBuffer sBufferRangeType;
4515 if (!sBufferRangeType.isEmpty())
4516 sBufferRangeType.append(
" ");
4519 if ((nRangeType & sheet::NamedRangeFlag::FILTER_CRITERIA) == sheet::NamedRangeFlag::FILTER_CRITERIA)
4521 if (!sBufferRangeType.isEmpty())
4522 sBufferRangeType.append(
" ");
4525 if ((nRangeType & sheet::NamedRangeFlag::PRINT_AREA) == sheet::NamedRangeFlag::PRINT_AREA)
4527 if (!sBufferRangeType.isEmpty())
4528 sBufferRangeType.append(
" ");
4531 OUString sRangeType = sBufferRangeType.makeStringAndClear();
4532 if (!sRangeType.isEmpty())
4548 aSparklineGroupExport.
write();
4553OUString getCondFormatEntryType(
const ScColorScaleEntry& rEntry,
bool bFirst =
true)
4564 return "percentile";
4572 return "auto-minimum";
4574 return "auto-maximum";
4590 return "last-7-days";
4598 return "this-month";
4600 return "last-month";
4602 return "next-month";
4619 if(!pCondFormatList)
4622 if (pCondFormatList->
empty())
4627 for(
const auto& rxCondFormat : *pCondFormatList)
4630 const ScRangeList& rRangeList = rxCondFormat->GetRange();