LibreOffice Module sc (master) 1
xmlexprt.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21#include <sal/log.hxx>
22
23#include "xmlexprt.hxx"
24#include "XMLConverter.hxx"
25#include "xmlstyle.hxx"
26#include <unonames.hxx>
27#include <document.hxx>
28#include <olinetab.hxx>
29#include <formulacell.hxx>
30#include <rangenam.hxx>
32#include <drwlayer.hxx>
35#include "XMLExportDDELinks.hxx"
36#include "XMLExportIterator.hxx"
40#include <sheetdata.hxx>
41#include <docoptio.hxx>
43#include <chgviset.hxx>
44#include <docuno.hxx>
45#include <textuno.hxx>
46#include <chartlis.hxx>
47#include <scitems.hxx>
48#include <docpool.hxx>
49#include <userdat.hxx>
50#include <chgtrack.hxx>
51#include <rangeutl.hxx>
52#include <postit.hxx>
53#include <externalrefmgr.hxx>
54#include <editutil.hxx>
55#include <tabprotection.hxx>
56#include "cachedattraccess.hxx"
57#include <colorscale.hxx>
58#include <conditio.hxx>
59#include <cellvalue.hxx>
60#include <stylehelper.hxx>
61#include <edittextiterator.hxx>
62#include "editattributemap.hxx"
63#include <arealink.hxx>
64#include <datastream.hxx>
65#include <documentlinkmgr.hxx>
67#include <cellform.hxx>
68#include <datamapper.hxx>
71#include <SparklineList.hxx>
72
73#include <xmloff/xmltoken.hxx>
75#include <xmloff/xmluconv.hxx>
77#include <xmloff/families.hxx>
78#include <xmloff/numehelp.hxx>
79#include <xmloff/txtparae.hxx>
83#include <editeng/colritem.hxx>
88#include <editeng/fhgtitem.hxx>
89#include <editeng/fontitem.hxx>
90#include <editeng/kernitem.hxx>
91#include <editeng/langitem.hxx>
92#include <editeng/postitem.hxx>
93#include <editeng/section.hxx>
94#include <editeng/shdditem.hxx>
95#include <editeng/udlnitem.hxx>
96#include <editeng/wghtitem.hxx>
97#include <editeng/wrlmitem.hxx>
98#include <editeng/xmlcnitm.hxx>
99#include <editeng/flditem.hxx>
100#include <editeng/eeitem.hxx>
101#include <formula/errorcodes.hxx>
102#include <xmloff/xmlerror.hxx>
104#include <xmloff/xmlprmap.hxx>
107
109#include <tools/fldunit.hxx>
110
111#include <rtl/ustring.hxx>
112
113#include <tools/color.hxx>
115#include <rtl/math.hxx>
116#include <svl/numformat.hxx>
117#include <svl/zforlist.hxx>
118#include <comphelper/base64.hxx>
119#include <comphelper/extract.hxx>
120#include <svx/svdoashp.hxx>
121#include <svx/svdobj.hxx>
122#include <svx/svdocapt.hxx>
123#include <svx/svdomeas.hxx>
124#include <vcl/svapp.hxx>
125
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>
149
150#include <com/sun/star/document/XDocumentProperties.hpp>
151#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
152
154
155#include <sfx2/linkmgr.hxx>
156#include <sfx2/objsh.hxx>
157
158#include <memory>
159#include <vector>
161#include <officecfg/Office/Common.hxx>
162
163namespace com::sun::star::uno { class XComponentContext; }
164
165
166
168constexpr OUStringLiteral SC_LAYERID = u"LayerID";
169
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
184
185using namespace formula;
186using namespace com::sun::star;
187using namespace xmloff::token;
188using ::std::vector;
189using ::com::sun::star::uno::UNO_QUERY;
190
191namespace
192{
193OUString lcl_RangeSequenceToString(
194 const uno::Sequence< OUString > & rRanges,
195 const uno::Reference< chart2::data::XRangeXMLConversion > & xFormatConverter )
196{
197 OUStringBuffer aResult;
198 const sal_Int32 nMaxIndex( rRanges.getLength() - 1 );
199 const sal_Unicode cSep(' ');
200 for( sal_Int32 i=0; i<=nMaxIndex; ++i )
201 {
202 OUString aRange( rRanges[i] );
203 if( xFormatConverter.is())
204 aRange = xFormatConverter->convertRangeToXML( aRange );
205 aResult.append( aRange );
206 if( i < nMaxIndex )
207 aResult.append( cSep );
208 }
209 return aResult.makeStringAndClear();
210}
211
212OUString lcl_GetFormattedString(ScDocument* pDoc, const ScRefCellValue& rCell, const ScAddress& rAddr)
213{
214 // return text/edit cell string content, with line feeds in edit cells
215
216 if (!pDoc)
217 return OUString();
218
219 switch (rCell.getType())
220 {
221 case CELLTYPE_STRING:
222 {
223 const Color* pColor;
224 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
225
226 sal_uInt32 nFormat = pDoc->GetNumberFormat(rAddr);
227 return ScCellFormat::GetString(rCell, nFormat, &pColor, *pFormatter, *pDoc);
228 }
229 case CELLTYPE_EDIT:
230 {
231 const EditTextObject* pData = rCell.getEditText();
232 if (!pData)
233 return OUString();
234
235 EditEngine& rEngine = pDoc->GetEditEngine();
236 rEngine.SetText(*pData);
237 return rEngine.GetText();
238 }
239 break;
240 default:
241 ;
242 }
243
244 return OUString();
245}
246
247} // anonymous namespace
248
249extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
250Calc_XMLExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
251{
252 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLExporter", SvXMLExportFlags::ALL));
253}
254
255extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
256Calc_XMLMetaExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
257{
258 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLMetaExporter", SvXMLExportFlags::META));
259}
260
261extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
262Calc_XMLStylesExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
263{
264 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLStylesExporter", SvXMLExportFlags::STYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::FONTDECLS));
265}
266
267extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
268Calc_XMLContentExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
269{
270 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLContentExporter", SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::CONTENT|SvXMLExportFlags::SCRIPTS|SvXMLExportFlags::FONTDECLS));
271}
272
273extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
274Calc_XMLSettingsExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
275{
276 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLSettingsExporter", SvXMLExportFlags::SETTINGS));
277}
278
279extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
280Calc_XMLOasisExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
281{
282 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLOasisExporter", SvXMLExportFlags::ALL|SvXMLExportFlags::OASIS));
283}
284
285extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
286Calc_XMLOasisMetaExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
287{
288 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLOasisMetaExporter", SvXMLExportFlags::META|SvXMLExportFlags::OASIS));
289}
290
291extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
292Calc_XMLOasisStylesExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
293{
294 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLOasisStylesExporter", SvXMLExportFlags::STYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::OASIS));
295}
296
297extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
298Calc_XMLOasisContentExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
299{
300 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLOasisContentExporter", SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::CONTENT|SvXMLExportFlags::SCRIPTS|SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::OASIS));
301}
302
303extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
304Calc_XMLOasisSettingsExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &)
305{
306 return cppu::acquire(new ScXMLExport(context, "com.sun.star.comp.Calc.XMLOasisSettingsExporter", SvXMLExportFlags::SETTINGS|SvXMLExportFlags::OASIS));
307}
308
309namespace {
310
311class ScXMLShapeExport : public XMLShapeExport
312{
313public:
314 explicit ScXMLShapeExport(SvXMLExport& rExp)
315 : XMLShapeExport(rExp,
316 // chain text attributes
317 XMLTextParagraphExport::CreateParaExtPropMapper(rExp))
318 {
319 }
320
322 virtual void onExport( const uno::Reference < drawing::XShape >& xShape ) override;
323};
324
325}
326
327void ScXMLShapeExport::onExport( const uno::Reference < drawing::XShape >& xShape )
328{
329 uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY );
330 if( xShapeProp.is() )
331 {
332 sal_Int16 nLayerID = 0;
333 if( (xShapeProp->getPropertyValue( SC_LAYERID ) >>= nLayerID) && (SdrLayerID(nLayerID) == SC_LAYER_BACK) )
334 GetExport().AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_BACKGROUND, XML_TRUE);
335 }
336}
337
339{
340 css::uno::Reference<css::sheet::XGlobalSheetSettings> xProperties =
341 css::sheet::GlobalSheetSettings::create( comphelper::getProcessComponentContext() );
342 const FieldUnit eFieldUnit = static_cast<FieldUnit>(xProperties->getMetric());
343 return SvXMLUnitConverter::GetMeasureUnit(eFieldUnit);
344}
345
347 const css::uno::Reference< css::uno::XComponentContext >& rContext,
348 OUString const & implementationName, SvXMLExportFlags nExportFlag)
350 rContext, implementationName, GetMeasureUnit(), XML_SPREADSHEET, nExportFlag ),
351 pDoc(nullptr),
352 nSourceStreamPos(0),
353 pCurrentCell(nullptr),
354 nOpenRow(-1),
355 nProgressCount(0),
356 nCurrentTable(0),
357 bHasRowHeader(false),
358 bRowHeaderOpen(false)
359{
360 if (getExportFlags() & SvXMLExportFlags::CONTENT)
361 {
364 pColumnStyles.reset( new ScColumnStyles() );
365 pRowStyles.reset( new ScRowStyles() );
366 pRowFormatRanges.reset( new ScRowFormatRanges() );
369 mpCellsItr.reset(new ScMyNotEmptyCellsIterator(*this));
370 pDefaults.reset( new ScMyDefaultStyles );
371 }
372 pCellStyles.reset( new ScFormatRangeStyles() );
373
374 // document is not set here - create ScChangeTrackingExportHelper later
375
386
387 GetAutoStylePool()->AddFamily(XmlStyleFamily::TABLE_CELL, XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME,
389 GetAutoStylePool()->AddFamily(XmlStyleFamily::TABLE_COLUMN, XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME,
391 GetAutoStylePool()->AddFamily(XmlStyleFamily::TABLE_ROW, XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME,
393 GetAutoStylePool()->AddFamily(XmlStyleFamily::TABLE_TABLE, XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME,
395
396 GetShapeExport(); // make sure the graphics styles family is added
397
398 if( !(getExportFlags() & (SvXMLExportFlags::STYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT)) )
399 return;
400
401 // This name is reserved for the external ref cache tables. This
402 // should not conflict with user-defined styles since this name is
403 // used for a table style which is not available in the UI.
404 sExternalRefTabStyleName = "ta_extref";
405 GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_TABLE, sExternalRefTabStyleName);
406
419}
420
422{
423 pGroupColumns.reset();
424 pGroupRows.reset();
425 pColumnStyles.reset();
426 pRowStyles.reset();
427 pCellStyles.reset();
428 pRowFormatRanges.reset();
430 pValidationsContainer.reset();
432 pDefaults.reset();
434}
435
436void ScXMLExport::SetSourceStream( const uno::Reference<io::XInputStream>& xNewStream )
437{
438 xSourceStream = xNewStream;
439
440 if ( !xSourceStream.is() )
441 return;
442
443 // make sure it's a plain UTF-8 stream as written by OOo itself
444
445 const char pXmlHeader[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
446 sal_Int32 nLen = strlen(pXmlHeader);
447
448 uno::Sequence<sal_Int8> aFileStart(nLen);
449 sal_Int32 nRead = xSourceStream->readBytes( aFileStart, nLen );
450
451 if ( nRead != nLen || memcmp( aFileStart.getConstArray(), pXmlHeader, nLen ) != 0 )
452 {
453 // invalid - ignore stream, save normally
454 xSourceStream.clear();
455 }
456 else
457 {
458 // keep track of the bytes already read
459 nSourceStreamPos = nRead;
460
461 const ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
462 if (pSheetData)
463 {
464 // add the loaded namespaces to the name space map
465
466 if ( !pSheetData->AddLoadedNamespaces( GetNamespaceMap_() ) )
467 {
468 // conflicts in the namespaces - ignore the stream, save normally
469 xSourceStream.clear();
470 }
471 }
472 }
473}
474
475sal_Int32 ScXMLExport::GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const
476{
477 NumberFormatIndexMap::const_iterator itr = aNumFmtIndexMap.find(nNumFmt);
478 if (itr == aNumFmtIndexMap.end())
479 return -1;
480
481 return itr->second;
482}
483
484void ScXMLExport::CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount)
485{
486 if (!GetModel().is())
487 return;
488
489 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(GetModel(), uno::UNO_QUERY);
490 if (!xSpreadDoc.is())
491 return;
492
493 uno::Reference<container::XIndexAccess> xIndex(xSpreadDoc->getSheets(), uno::UNO_QUERY);
494 if (!xIndex.is())
495 return;
496
497 nTableCount = xIndex->getCount();
498 if (!pSharedData)
499 pSharedData.reset(new ScMySharedData(nTableCount));
500
501 pCellStyles->AddNewTable(nTableCount - 1);
502
503 for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
504 {
505 nCurrentTable = sal::static_int_cast<sal_uInt16>(nTable);
506 uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY);
507 if (!xDrawPageSupplier.is())
508 continue;
509
510 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage());
511 ScMyDrawPage aDrawPage;
512 aDrawPage.bHasForms = false;
513 aDrawPage.xDrawPage.set(xDrawPage);
514 pSharedData->AddDrawPage(aDrawPage, nTable);
515 if (!xDrawPage.is())
516 continue;
517
518 sal_Int32 nShapes = xDrawPage->getCount();
519 for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape)
520 {
521 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(nShape), uno::UNO_QUERY);
522 if (!xShape.is())
523 continue;
524
525 uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
526 if (!xShapeProp.is())
527 continue;
528
529 sal_Int16 nLayerID = 0;
530 bool bExtracted = xShapeProp->getPropertyValue(SC_LAYERID) >>= nLayerID;
531 if (!bExtracted)
532 continue;
533
534 if ((SdrLayerID(nLayerID) == SC_LAYER_INTERN) || (SdrLayerID(nLayerID) == SC_LAYER_HIDDEN))
535 {
536 CollectInternalShape(xShape);
537 continue;
538 }
539
540 ++nShapesCount;
541
543 if (!pSdrObj)
544 continue;
545
546 if (ScDrawObjData *pAnchor = ScDrawLayer::GetNonRotatedObjData(pSdrObj))
547 {
548 ScMyShape aMyShape;
549 aMyShape.aAddress = pAnchor->maStart;
550 SAL_WARN_IF(aMyShape.aAddress.Tab() != nTable, "sc", "not anchored to current sheet!");
551 aMyShape.aAddress.SetTab(nTable);
552 aMyShape.aEndAddress = pAnchor->maEnd;
553 aMyShape.aEndAddress.SetTab( nTable );
554 aMyShape.nEndX = pAnchor->maEndOffset.X();
555 aMyShape.nEndY = pAnchor->maEndOffset.Y();
556 aMyShape.xShape = xShape;
557 pSharedData->AddNewShape(aMyShape);
558 pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col());
559 pSharedData->SetLastRow(nTable, pAnchor->maStart.Row());
560 }
561 else
562 pSharedData->AddTableShape(nTable, xShape);
563 }
564 }
565}
566
568{
569 // #i84077# To avoid compiler warnings about uninitialized aShapeItr,
570 // it's initialized using this dummy list. The iterator contains shapes
571 // from all sheets, so it can't be declared inside the nTable loop where
572 // it is used.
573 ScMyShapeList aDummyInitList;
574
575 pSharedData->SortShapesContainer();
576 pSharedData->SortNoteShapes();
577 const ScMyShapeList* pShapeList(nullptr);
578 ScMyShapeList::const_iterator aShapeItr = aDummyInitList.end();
579 if (pSharedData->GetShapesContainer())
580 {
581 pShapeList = &pSharedData->GetShapesContainer()->GetShapes();
582 aShapeItr = pShapeList->begin();
583 }
584 if (pSharedData->HasDrawPage())
585 {
586 for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
587 {
588 uno::Reference<drawing::XDrawPage> xDrawPage(pSharedData->GetDrawPage(nTable));
589
590 if (xDrawPage.is())
591 {
592 GetShapeExport()->seekShapes(xDrawPage);
593 uno::Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, uno::UNO_QUERY );
594 if( xFormsSupplier.is() && xFormsSupplier->hasForms() )
595 {
596 GetFormExport()->examineForms(xDrawPage);
597 pSharedData->SetDrawPageHasForms(nTable, true);
598 }
599 ScMyTableShapes* pTableShapes(pSharedData->GetTableShapes());
600 if (pTableShapes)
601 {
602 for (const auto& rxShape : (*pTableShapes)[nTable])
603 {
604 GetShapeExport()->collectShapeAutoStyles(rxShape);
606 }
607 }
608 if (pShapeList)
609 {
610 ScMyShapeList::const_iterator aEndItr(pShapeList->end());
611 while ( aShapeItr != aEndItr && ( aShapeItr->aAddress.Tab() == nTable ) )
612 {
613 GetShapeExport()->collectShapeAutoStyles(aShapeItr->xShape);
615 ++aShapeItr;
616 }
617 }
618 if (pSharedData->GetNoteShapes())
619 {
620 const ScMyNoteShapeList& rNoteShapes = pSharedData->GetNoteShapes()->GetNotes();
621 for (const auto& rNoteShape : rNoteShapes)
622 {
623 if ( rNoteShape.aPos.Tab() == nTable )
624 GetShapeExport()->collectShapeAutoStyles(rNoteShape.xShape);
625 }
626 }
627 }
628 }
629 }
630 pSharedData->SortNoteShapes(); // sort twice, because some more shapes are added
631}
632
634{
635 sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0);
636 SCTAB nTableCount(0);
637 sal_Int32 nShapesCount(0);
638 GetAutoStylePool()->ClearEntries();
639 CollectSharedData(nTableCount, nShapesCount);
640
641 uno::Sequence<beans::NamedValue> stats
642 {
643 { "TableCount", uno::Any(static_cast<sal_Int32>(nTableCount)) },
644 { "CellCount", uno::Any(nCellCount) },
645 { "ObjectCount", uno::Any(nShapesCount) }
646 };
647
648 // update document statistics at the model
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);
655 }
656
657 // export document properties
659}
660
662{
663 GetFontAutoStylePool(); // make sure the pool is created
665}
666
667table::CellRangeAddress ScXMLExport::GetEndAddress(const uno::Reference<sheet::XSpreadsheet>& xTable)
668{
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())
674 {
675 xUsedArea->gotoEndOfUsedArea(true);
676 aCellAddress = xCellAddress->getRangeAddress();
677 }
678 return aCellAddress;
679}
680
682{
683 if (pDoc->GetLinkManager())
684 {
685 const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks();
686 for (const auto & rLink : rLinks)
687 {
688 ScAreaLink *pLink = dynamic_cast<ScAreaLink*>(rLink.get());
689 if (pLink)
690 {
691 ScMyAreaLink aAreaLink;
692 aAreaLink.aDestRange = pLink->GetDestArea();
693 aAreaLink.sSourceStr = pLink->GetSource();
694 aAreaLink.sFilter = pLink->GetFilter();
695 aAreaLink.sFilterOptions = pLink->GetOptions();
696 aAreaLink.sURL = pLink->GetFile();
697 aAreaLink.nRefreshDelaySeconds = pLink->GetRefreshDelaySeconds();
698 rAreaLinks.AddNewAreaLink( aAreaLink );
699 }
700 }
701 }
702 rAreaLinks.Sort();
703}
704
705// core implementation
707{
708 if (!pDoc)
709 return;
710
711 ScDetOpList* pOpList(pDoc->GetDetOpList());
712 if( !pOpList )
713 return;
714
715 size_t nCount = pOpList->Count();
716 for (size_t nIndex = 0; nIndex < nCount; ++nIndex )
717 {
718 const ScDetOpData& rDetData = pOpList->GetObject( nIndex);
719 const ScAddress& rDetPos = rDetData.GetPos();
720 SCTAB nTab = rDetPos.Tab();
721 if ( nTab < pDoc->GetTableCount() )
722 {
723 rDetOp.AddOperation( rDetData.GetOperation(), rDetPos, static_cast<sal_uInt32>( nIndex) );
724
725 // cells with detective operations are written even if empty
726 pSharedData->SetLastColumn( nTab, rDetPos.Col() );
727 pSharedData->SetLastRow( nTab, rDetPos.Row() );
728 }
729 }
730 rDetOp.Sort();
731}
732
733void ScXMLExport::WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex,
734 const sal_Int32 nIndex, const bool bIsAutoStyle, const bool bIsVisible)
735{
737 // tdf#138466
738 if (nStyleIndex != -1)
739 AddAttribute(sAttrStyleName, pColumnStyles->GetStyleNameByIndex(nStyleIndex));
740 if (!bIsVisible)
742 if (nRepeatColumns > 1)
743 {
744 OUString sOUEndCol(OUString::number(nRepeatColumns));
746 }
747 if (nIndex != -1)
749 SvXMLElementExport aElemC(*this, sElemCol, true, true);
750}
751
752void ScXMLExport::WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns,
753 const sal_Int32 nStyleIndex, const bool bIsVisible)
754{
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)
759 {
760 if ((pDefaults->GetColDefaults()[i].nIndex != nPrevIndex) ||
761 (pDefaults->GetColDefaults()[i].bIsAutoStyle != bPrevAutoStyle))
762 {
763 WriteSingleColumn(nRepeat, nStyleIndex, nPrevIndex, bPrevAutoStyle, bIsVisible);
764 nPrevIndex = pDefaults->GetColDefaults()[i].nIndex;
765 bPrevAutoStyle = pDefaults->GetColDefaults()[i].bIsAutoStyle;
766 nRepeat = 1;
767 }
768 else
769 ++nRepeat;
770 }
771 WriteSingleColumn(nRepeat, nStyleIndex, nPrevIndex, bPrevAutoStyle, bIsVisible);
772}
773
775{
777}
778
780{
782}
783
784void ScXMLExport::ExportColumns(const sal_Int32 nTable, const ScRange& aColumnHeaderRange, const bool bHasColumnHeader)
785{
786 sal_Int32 nColsRepeated (1);
787 sal_Int32 nIndex;
788 sal_Int32 nPrevColumn(0);
789 bool bPrevIsVisible (true);
790 bool bWasHeader (false);
791 bool bIsClosed (true);
792 sal_Int32 nPrevIndex (-1);
793 sal_Int32 nColumn;
794 for (nColumn = 0; nColumn <= pSharedData->GetLastColumn(nTable); ++nColumn)
795 {
797 bool bIsVisible(true);
798 nIndex = pColumnStyles->GetStyleNameIndex(nTable, nColumn, bIsVisible);
799
800 const bool bIsHeader = bHasColumnHeader && (aColumnHeaderRange.aStart.Col() <= nColumn) && (nColumn <= aColumnHeaderRange.aEnd.Col());
801 if (bIsHeader != bWasHeader)
802 {
803 if (bIsHeader)
804 {
805 if (nColumn > 0)
806 {
807 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
808 if (pGroupColumns->IsGroupEnd(nColumn - 1))
809 pGroupColumns->CloseGroups(nColumn - 1);
810 }
811 bPrevIsVisible = bIsVisible;
812 nPrevIndex = nIndex;
813 nPrevColumn = nColumn;
814 nColsRepeated = 1;
815 if(pGroupColumns->IsGroupStart(nColumn))
816 pGroupColumns->OpenGroups(nColumn);
818 bWasHeader = true;
819 bIsClosed = false;
820 }
821 else
822 {
823 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
825 if (pGroupColumns->IsGroupEnd(nColumn - 1))
826 pGroupColumns->CloseGroups(nColumn - 1);
827 if(pGroupColumns->IsGroupStart(nColumn))
828 pGroupColumns->OpenGroups(nColumn);
829 bPrevIsVisible = bIsVisible;
830 nPrevIndex = nIndex;
831 nPrevColumn = nColumn;
832 nColsRepeated = 1;
833 bWasHeader = false;
834 bIsClosed = true;
835 }
836 }
837 else if (nColumn == 0)
838 {
839 if (pGroupColumns->IsGroupStart(nColumn))
840 pGroupColumns->OpenGroups(nColumn);
841 bPrevIsVisible = bIsVisible;
842 nPrevIndex = nIndex;
843 }
844 else if ((bIsVisible == bPrevIsVisible) && (nIndex == nPrevIndex) &&
845 !pGroupColumns->IsGroupStart(nColumn) && !pGroupColumns->IsGroupEnd(nColumn - 1))
846 ++nColsRepeated;
847 else
848 {
849 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
850 if (pGroupColumns->IsGroupEnd(nColumn - 1))
851 {
852 if (bIsHeader)
854 pGroupColumns->CloseGroups(nColumn - 1);
855 if (bIsHeader)
857 }
858 if (pGroupColumns->IsGroupStart(nColumn))
859 {
860 if (bIsHeader)
862 pGroupColumns->OpenGroups(nColumn);
863 if (bIsHeader)
865 }
866 bPrevIsVisible = bIsVisible;
867 nPrevIndex = nIndex;
868 nPrevColumn = nColumn;
869 nColsRepeated = 1;
870 }
871 }
872 WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
873 if (!bIsClosed)
875 if (pGroupColumns->IsGroupEnd(nColumn - 1))
876 pGroupColumns->CloseGroups(nColumn - 1);
877}
878
880{
881 sal_Int32 nEntryIndex = GetCellStylesPropertySetMapper()->FindEntryIndex(
882 "NumberFormat", XML_NAMESPACE_STYLE, u"data-style-name");
883
884 if (nEntryIndex < 0)
885 // No entry index for the number format is found.
886 return;
887
889 if (!pRefMgr->hasExternalData())
890 // No external reference data cached.
891 return;
892
893 // Export each unique number format used in the external ref cache.
894 vector<sal_uInt32> aNumFmts;
895 pRefMgr->getAllCachedNumberFormats(aNumFmts);
896 static constexpr OUStringLiteral aDefaultStyle(u"Default");
897 for (const auto& rNumFmt : aNumFmts)
898 {
899 sal_Int32 nNumFmt = static_cast<sal_Int32>(rNumFmt);
900
901 addDataStyle(nNumFmt);
902
903 uno::Any aVal;
904 aVal <<= nNumFmt;
905 vector<XMLPropertyState> aProps;
906 aVal <<= OUString(aDefaultStyle);
907 aProps.emplace_back(nEntryIndex, aVal);
908
909 OUString aName;
910 sal_Int32 nIndex;
911 if (GetAutoStylePool()->Add(aName, XmlStyleFamily::TABLE_CELL, aDefaultStyle, std::move(aProps)))
912 {
913 pCellStyles->AddStyleName(aName, nIndex);
914 }
915 else
916 {
917 bool bIsAuto;
918 nIndex = pCellStyles->GetIndexOfStyleName(
920 }
921
922 // store the number format to index mapping for later use.
923 aNumFmtIndexMap.emplace(nNumFmt, nIndex);
924 }
925}
926
927namespace {
928
929void handleFont(
930 SvXMLExport & rExport,
931 std::vector<XMLPropertyState>& rPropStates,
932 const SfxPoolItem* p, const rtl::Reference<XMLPropertySetMapper>& xMapper, std::u16string_view rXMLName )
933{
934 sal_Int32 nEntryCount = xMapper->GetEntryCount();
935
936 // Apparently font info needs special handling.
937 const SvxFontItem* pItem = static_cast<const SvxFontItem*>(p);
938
939 sal_Int32 nIndexFontName = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, rXMLName, 0);
940
941 if (nIndexFontName == -1 || nIndexFontName >= nEntryCount)
942 return;
943
944 OUString const sFamilyName(pItem->GetFamilyName());
945 OUString const sStyleName(pItem->GetStyleName());
946 auto const nFamily(pItem->GetFamily());
947 auto const nPitch(pItem->GetPitch());
948 auto const eEnc(pItem->GetCharSet());
949 OUString const sName(rExport.GetFontAutoStylePool()->Find(
950 sFamilyName, sStyleName, nFamily, nPitch, eEnc));
951 if (sName.isEmpty())
952 {
953 assert(false); // fallback to fo:font-family etc. probably not needed
954 }
955
956 rPropStates.emplace_back(nIndexFontName, uno::Any(sName));
957}
958
959const SvxFieldData* toXMLPropertyStates(
960 SvXMLExport & rExport,
961 std::vector<XMLPropertyState>& rPropStates, const std::vector<const SfxPoolItem*>& rSecAttrs,
962 const rtl::Reference<XMLPropertySetMapper>& xMapper, const ScXMLEditAttributeMap& rAttrMap )
963{
964 const SvxFieldData* pField = nullptr;
965 sal_Int32 nEntryCount = xMapper->GetEntryCount();
966 rPropStates.reserve(rSecAttrs.size());
967 for (const SfxPoolItem* p : rSecAttrs)
968 {
969 if (p->Which() == EE_FEATURE_FIELD)
970 {
971 pField = static_cast<const SvxFieldItem*>(p)->GetField();
972 continue;
973 }
974
975 const ScXMLEditAttributeMap::Entry* pEntry = rAttrMap.getEntryByItemID(p->Which());
976 if (!pEntry)
977 continue;
978
979 sal_Int32 nIndex = xMapper->GetEntryIndex(
980 pEntry->nmXMLNS, OUString::createFromAscii(pEntry->mpXMLName), 0);
981
982 if (nIndex == -1 || nIndex >= nEntryCount)
983 continue;
984
985 uno::Any aAny;
986 switch (p->Which())
987 {
988 case EE_CHAR_FONTINFO:
989 handleFont(rExport, rPropStates, p, xMapper, u"font-name");
990 break;
992 handleFont(rExport, rPropStates, p, xMapper, u"font-name-asian");
993 break;
995 handleFont(rExport, rPropStates, p, xMapper, u"font-name-complex");
996 break;
997 case EE_CHAR_WEIGHT:
1000 {
1001 if (!static_cast<const SvxWeightItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1002 continue;
1003
1004 rPropStates.emplace_back(nIndex, aAny);
1005 }
1006 break;
1007 case EE_CHAR_FONTHEIGHT:
1010 {
1011 if (!static_cast<const SvxFontHeightItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1012 continue;
1013
1014 rPropStates.emplace_back(nIndex, aAny);
1015 }
1016 break;
1017 case EE_CHAR_ITALIC:
1018 case EE_CHAR_ITALIC_CJK:
1019 case EE_CHAR_ITALIC_CTL:
1020 {
1021 if (!static_cast<const SvxPostureItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1022 continue;
1023
1024 rPropStates.emplace_back(nIndex, aAny);
1025 }
1026 break;
1027 case EE_CHAR_UNDERLINE:
1028 {
1029 // Underline attribute needs to export multiple entries.
1030 sal_Int32 nIndexStyle = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u"text-underline-style", 0);
1031 if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
1032 break;
1033
1034 sal_Int32 nIndexWidth = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u"text-underline-width", 0);
1035 if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
1036 break;
1037
1038 sal_Int32 nIndexType = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u"text-underline-type", 0);
1039 if (nIndexType == -1 || nIndexType > nEntryCount)
1040 break;
1041
1042 sal_Int32 nIndexColor = xMapper->FindEntryIndex("CharUnderlineColor", XML_NAMESPACE_STYLE, u"text-underline-color");
1043 if (nIndexColor == -1 || nIndexColor > nEntryCount)
1044 break;
1045
1046 sal_Int32 nIndexHasColor = xMapper->FindEntryIndex("CharUnderlineHasColor", XML_NAMESPACE_STYLE, u"text-underline-color");
1047 if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
1048 break;
1049
1050 const SvxUnderlineItem* pUL = static_cast<const SvxUnderlineItem*>(p);
1051 pUL->QueryValue(aAny, MID_TL_STYLE);
1052 rPropStates.emplace_back(nIndexStyle, aAny);
1053 rPropStates.emplace_back(nIndexType, aAny);
1054 rPropStates.emplace_back(nIndexWidth, aAny);
1055
1056 pUL->QueryValue(aAny, MID_TL_COLOR);
1057 rPropStates.emplace_back(nIndexColor, aAny);
1058
1059 pUL->QueryValue(aAny, MID_TL_HASCOLOR);
1060 rPropStates.emplace_back(nIndexHasColor, aAny);
1061 }
1062 break;
1063 case EE_CHAR_OVERLINE:
1064 {
1065 // Same with overline. Do just as we do with underline attributes.
1066 sal_Int32 nIndexStyle = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u"text-overline-style", 0);
1067 if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
1068 break;
1069
1070 sal_Int32 nIndexWidth = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u"text-overline-width", 0);
1071 if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
1072 break;
1073
1074 sal_Int32 nIndexType = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, u"text-overline-type", 0);
1075 if (nIndexType == -1 || nIndexType > nEntryCount)
1076 break;
1077
1078 sal_Int32 nIndexColor = xMapper->FindEntryIndex("CharOverlineColor", XML_NAMESPACE_STYLE, u"text-overline-color");
1079 if (nIndexColor == -1 || nIndexColor > nEntryCount)
1080 break;
1081
1082 sal_Int32 nIndexHasColor = xMapper->FindEntryIndex("CharOverlineHasColor", XML_NAMESPACE_STYLE, u"text-overline-color");
1083 if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
1084 break;
1085
1086 const SvxOverlineItem* pOL = static_cast<const SvxOverlineItem*>(p);
1087 pOL->QueryValue(aAny, MID_TL_STYLE);
1088 rPropStates.emplace_back(nIndexStyle, aAny);
1089 rPropStates.emplace_back(nIndexType, aAny);
1090 rPropStates.emplace_back(nIndexWidth, aAny);
1091
1092 pOL->QueryValue(aAny, MID_TL_COLOR);
1093 rPropStates.emplace_back(nIndexColor, aAny);
1094
1095 pOL->QueryValue(aAny, MID_TL_HASCOLOR);
1096 rPropStates.emplace_back(nIndexHasColor, aAny);
1097 }
1098 break;
1099 case EE_CHAR_COLOR:
1100 {
1101 if (!static_cast<const SvxColorItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1102 continue;
1103
1104 ::Color nColor;
1105 if ( aAny >>= nColor )
1106 {
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 );
1110 }
1111 }
1112 break;
1113 case EE_CHAR_WLM:
1114 {
1115 if (!static_cast<const SvxWordLineModeItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1116 continue;
1117
1118 rPropStates.emplace_back(nIndex, aAny);
1119 }
1120 break;
1121 case EE_CHAR_STRIKEOUT:
1122 {
1123 if (!static_cast<const SvxCrossedOutItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1124 continue;
1125
1126 rPropStates.emplace_back(nIndex, aAny);
1127 }
1128 break;
1129 case EE_CHAR_RELIEF:
1130 {
1131 if (!static_cast<const SvxCharReliefItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1132 continue;
1133
1134 rPropStates.emplace_back(nIndex, aAny);
1135 }
1136 break;
1137 case EE_CHAR_OUTLINE:
1138 {
1139 if (!static_cast<const SvxContourItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1140 continue;
1141
1142 rPropStates.emplace_back(nIndex, aAny);
1143 }
1144 break;
1145 case EE_CHAR_SHADOW:
1146 {
1147 if (!static_cast<const SvxShadowedItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1148 continue;
1149
1150 rPropStates.emplace_back(nIndex, aAny);
1151 }
1152 break;
1153 case EE_CHAR_KERNING:
1154 {
1155 if (!static_cast<const SvxKerningItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1156 continue;
1157
1158 rPropStates.emplace_back(nIndex, aAny);
1159 }
1160 break;
1162 {
1163 if (!static_cast<const SvxAutoKernItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1164 continue;
1165
1166 rPropStates.emplace_back(nIndex, aAny);
1167 }
1168 break;
1169 case EE_CHAR_FONTWIDTH:
1170 {
1171 if (!static_cast<const SvxCharScaleWidthItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1172 continue;
1173
1174 rPropStates.emplace_back(nIndex, aAny);
1175 }
1176 break;
1177 case EE_CHAR_ESCAPEMENT:
1178 {
1179 sal_Int32 nIndexEsc = xMapper->FindEntryIndex("CharEscapement", XML_NAMESPACE_STYLE, u"text-position");
1180 if (nIndexEsc == -1 || nIndexEsc > nEntryCount)
1181 break;
1182
1183 sal_Int32 nIndexEscHeight = xMapper->FindEntryIndex("CharEscapementHeight", XML_NAMESPACE_STYLE, u"text-position");
1184 if (nIndexEscHeight == -1 || nIndexEscHeight > nEntryCount)
1185 break;
1186
1187 const SvxEscapementItem* pEsc = static_cast<const SvxEscapementItem*>(p);
1188
1189 pEsc->QueryValue(aAny);
1190 rPropStates.emplace_back(nIndexEsc, aAny);
1191
1192 pEsc->QueryValue(aAny, MID_ESC_HEIGHT);
1193 rPropStates.emplace_back(nIndexEscHeight, aAny);
1194
1195 }
1196 break;
1198 {
1199 if (!static_cast<const SvxEmphasisMarkItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1200 continue;
1201
1202 rPropStates.emplace_back(nIndex, aAny);
1203 }
1204 break;
1205 case EE_CHAR_LANGUAGE:
1208 {
1209 if (!static_cast<const SvxLanguageItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
1210 continue;
1211
1212 // Export multiple entries.
1213 sal_Int32 nIndexLanguage, nIndexCountry, nIndexScript, nIndexTag;
1214 switch (p->Which())
1215 {
1216 case EE_CHAR_LANGUAGE:
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);
1221 break;
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);
1227 break;
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);
1233 break;
1234 default:
1235 nIndexLanguage = nIndexCountry = nIndexScript = nIndexTag = -1;
1236 }
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);
1242 }
1243 break;
1244 default:
1245 continue;
1246 }
1247 }
1248
1249 return pField;
1250}
1251
1252}
1253
1255{
1256 if (!ValidTab(nTable))
1257 return;
1258
1259 rtl::Reference<XMLPropertySetMapper> xMapper = GetTextParagraphExport()->GetTextPropMapper()->getPropertySetMapper();
1261 const ScXMLEditAttributeMap& rAttrMap = GetEditAttributeMap();
1262
1263 sc::EditTextIterator aIter(*pDoc, nTable);
1264 sal_Int32 nCellCount = 0;
1265 for (const EditTextObject* pEdit = aIter.first(); pEdit; pEdit = aIter.next(), ++nCellCount)
1266 {
1267 std::vector<editeng::Section> aAttrs;
1268 pEdit->GetAllSections(aAttrs);
1269 if (aAttrs.empty())
1270 continue;
1271
1272 for (const auto& rSec : aAttrs)
1273 {
1274 const std::vector<const SfxPoolItem*>& rSecAttrs = rSec.maAttributes;
1275 if (rSecAttrs.empty())
1276 // No formats applied to this section. Skip it.
1277 continue;
1278
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));
1283 }
1284 }
1285
1286 GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCellCount);
1287}
1288
1290{
1291 ScMyRowFormatRange aRange;
1292 sal_Int32 nIndex(-1);
1293#if OSL_DEBUG_LEVEL > 0
1294 sal_Int32 nPrevCol(0);
1295#endif
1296 sal_Int32 nCols(0);
1297 sal_Int32 nPrevValidationIndex(-1);
1298 bool bIsAutoStyle(true);
1299 bool bIsFirst(true);
1300 while (pRowFormatRanges->GetNext(aRange))
1301 {
1302#if OSL_DEBUG_LEVEL > 0
1303 OSL_ENSURE(bIsFirst || (!bIsFirst && (nPrevCol + nCols == aRange.nStartColumn)), "here are some columns missing");
1304#endif
1305 if (bIsFirst)
1306 {
1307 nIndex = aRange.nIndex;
1308 nPrevValidationIndex = aRange.nValidationIndex;
1309 bIsAutoStyle = aRange.bIsAutoStyle;
1310 nCols = aRange.nRepeatColumns;
1311 bIsFirst = false;
1312#if OSL_DEBUG_LEVEL > 0
1313 nPrevCol = aRange.nStartColumn;
1314#endif
1315 }
1316 else
1317 {
1318 if (((aRange.nIndex == nIndex && aRange.bIsAutoStyle == bIsAutoStyle) ||
1319 (aRange.nIndex == nIndex && nIndex == -1)) &&
1320 nPrevValidationIndex == aRange.nValidationIndex)
1321 nCols += aRange.nRepeatColumns;
1322 else
1323 {
1324 if (nIndex != -1)
1325 AddAttribute(sAttrStyleName, pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle));
1326 if (nPrevValidationIndex > -1)
1327 AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(nPrevValidationIndex));
1328 if (nCols > 1)
1329 {
1330 AddAttribute(sAttrColumnsRepeated, OUString::number(nCols));
1331 }
1332 SvXMLElementExport aElemC(*this, sElemCell, true, true);
1333 nIndex = aRange.nIndex;
1334 bIsAutoStyle = aRange.bIsAutoStyle;
1335 nCols = aRange.nRepeatColumns;
1336 nPrevValidationIndex = aRange.nValidationIndex;
1337#if OSL_DEBUG_LEVEL > 0
1338 nPrevCol = aRange.nStartColumn;
1339#endif
1340 }
1341 }
1342 }
1343 if (!bIsFirst)
1344 {
1345 if (nIndex != -1)
1346 AddAttribute(sAttrStyleName, pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle));
1347 if (nPrevValidationIndex > -1)
1348 AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(nPrevValidationIndex));
1349 if (nCols > 1)
1350 {
1351 AddAttribute(sAttrColumnsRepeated, OUString::number(nCols));
1352 }
1353 SvXMLElementExport aElemC(*this, sElemCell, true, true);
1354 }
1355}
1356
1358 const sal_Int32 nIndex, const sal_Int32 nEqualRows,
1359 bool bHidden, bool bFiltered)
1360{
1361 // tdf#143940
1362 if (nIndex != -1)
1363 AddAttribute(sAttrStyleName, pRowStyles->GetStyleNameByIndex(nIndex));
1364 if (bHidden)
1365 {
1366 if (bFiltered)
1368 else
1370 }
1371 if (nEqualRows > 1)
1372 {
1373 AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, OUString::number(nEqualRows));
1374 }
1375
1376 StartElement( sElemRow, true);
1377}
1378
1380{
1382 bRowHeaderOpen = true;
1383}
1384
1386{
1388}
1389
1391 const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEqualRows,
1392 bool bHidden, bool bFiltered)
1393{
1394 nOpenRow = nStartRow;
1395 if (pGroupRows->IsGroupStart(nStartRow))
1396 {
1399 pGroupRows->OpenGroups(nStartRow);
1402 }
1403 if (bHasRowHeader && !bRowHeaderOpen && nStartRow >= aRowHeaderRange.aStart.Row() && nStartRow <= aRowHeaderRange.aEnd.Row())
1404 {
1405 if (nStartRow == aRowHeaderRange.aStart.Row())
1407 sal_Int32 nEquals;
1408 if (aRowHeaderRange.aEnd.Row() < nStartRow + nEqualRows - 1)
1409 nEquals = aRowHeaderRange.aEnd.Row() - nStartRow + 1;
1410 else
1411 nEquals = nEqualRows;
1412 WriteRowStartTag(nIndex, nEquals, bHidden, bFiltered);
1413 nOpenRow = nStartRow + nEquals - 1;
1414 if (nEquals < nEqualRows)
1415 {
1416 CloseRow(nStartRow + nEquals - 1);
1417 WriteRowStartTag(nIndex, nEqualRows - nEquals, bHidden, bFiltered);
1418 nOpenRow = nStartRow + nEqualRows - 1;
1419 }
1420 }
1421 else
1422 WriteRowStartTag(nIndex, nEqualRows, bHidden, bFiltered);
1423}
1424
1426 const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEqualRows,
1427 bool bHidden, bool bFiltered)
1428{
1429 OpenNewRow(nIndex, nStartRow, nEqualRows, bHidden, bFiltered);
1431 CloseRow(nStartRow + nEqualRows - 1);
1432 pRowFormatRanges->Clear();
1433}
1434
1435void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, const sal_Int32 nRepeatRow, ScXMLCachedRowAttrAccess& rRowAttr)
1436{
1437 if (nRepeatRow > 1)
1438 {
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;
1448 sal_Int32 nRow;
1449 for (nRow = nStartRow; nRow < nEndRow; ++nRow)
1450 {
1451 if (nRow == nStartRow)
1452 {
1453 nPrevIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
1454 if (pDoc)
1455 {
1456 if (nRow > nEndRowHidden)
1457 {
1458 bPrevHidden = rRowAttr.rowHidden(nTable, nRow, nEndRowHidden);
1459 bHidden = bPrevHidden;
1460 }
1461 if (nRow > nEndRowFiltered)
1462 {
1463 bPrevFiltered = rRowAttr.rowFiltered(nTable, nRow, nEndRowFiltered);
1464 bFiltered = bPrevFiltered;
1465 }
1466 }
1467
1468 }
1469 else
1470 {
1471 nIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
1472 if (pDoc)
1473 {
1474 if (nRow > nEndRowHidden)
1475 bHidden = rRowAttr.rowHidden(nTable, nRow, nEndRowHidden);
1476 if (nRow > nEndRowFiltered)
1477 bFiltered = rRowAttr.rowFiltered(nTable, nRow, nEndRowFiltered);
1478 }
1479 if (nIndex == nPrevIndex && bHidden == bPrevHidden && bFiltered == bPrevFiltered &&
1480 !(bHasRowHeader && ((nRow == aRowHeaderRange.aStart.Row()) || (nRow - 1 == aRowHeaderRange.aEnd.Row()))) &&
1481 !(pGroupRows->IsGroupStart(nRow)) &&
1482 !(pGroupRows->IsGroupEnd(nRow - 1)))
1483 ++nEqualRows;
1484 else
1485 {
1486 assert(nPrevIndex >= 0 && "coverity#1438402");
1487 ScRowFormatRanges* pTempRowFormatRanges = new ScRowFormatRanges(pRowFormatRanges.get());
1488 OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
1489 pRowFormatRanges.reset(pTempRowFormatRanges);
1490 nEqualRows = 1;
1491 nPrevIndex = nIndex;
1492 bPrevHidden = bHidden;
1493 bPrevFiltered = bFiltered;
1494 }
1495 }
1496 }
1497 assert(nPrevIndex >= 0 && "coverity#1438402");
1498 OpenNewRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
1499 }
1500 else
1501 {
1502 sal_Int32 nIndex = pRowStyles->GetStyleNameIndex(nTable, nStartRow);
1503 bool bHidden = false;
1504 bool bFiltered = false;
1505 if (pDoc)
1506 {
1507 sal_Int32 nEndRowHidden;
1508 sal_Int32 nEndRowFiltered;
1509 bHidden = rRowAttr.rowHidden(nTable, nStartRow, nEndRowHidden);
1510 bFiltered = rRowAttr.rowFiltered(nTable, nStartRow, nEndRowFiltered);
1511 }
1512 assert(nIndex >= 0 && "coverity#1438402");
1513 OpenNewRow(nIndex, nStartRow, 1, bHidden, bFiltered);
1514 }
1515 nOpenRow = nStartRow + nRepeatRow - 1;
1516}
1517
1518void ScXMLExport::CloseRow(const sal_Int32 nRow)
1519{
1520 if (nOpenRow > -1)
1521 {
1522 EndElement(sElemRow, true);
1523 if (bHasRowHeader && nRow == aRowHeaderRange.aEnd.Row())
1524 {
1526 bRowHeaderOpen = false;
1527 }
1528 if (pGroupRows->IsGroupEnd(nRow))
1529 {
1532 pGroupRows->CloseGroups(nRow);
1535 }
1536 }
1537 nOpenRow = -1;
1538}
1539
1540void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
1541 const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet)
1542{
1543 pRowFormatRanges->Clear();
1545 if (nStartRow == nEndRow)
1546 {
1547 pCellStyles->GetFormatRanges(nStartCol, nEndCol, nStartRow, nSheet, pRowFormatRanges.get());
1548 if (nOpenRow == - 1)
1549 OpenRow(nSheet, nStartRow, 1, aRowAttr);
1551 pRowFormatRanges->Clear();
1552 }
1553 else
1554 {
1555 if (nOpenRow > -1)
1556 {
1557 pCellStyles->GetFormatRanges(nStartCol, pSharedData->GetLastColumn(nSheet), nStartRow, nSheet, pRowFormatRanges.get());
1559 CloseRow(nStartRow);
1560 sal_Int32 nRows(1);
1561 sal_Int32 nTotalRows(nEndRow - nStartRow + 1 - 1);
1562 while (nRows < nTotalRows)
1563 {
1564 pRowFormatRanges->Clear();
1565 pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
1566 sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows();
1567 OSL_ENSURE(nMaxRows, "something went wrong");
1568 if (nMaxRows >= nTotalRows - nRows)
1569 {
1570 OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows, aRowAttr);
1571 nRows += nTotalRows - nRows;
1572 }
1573 else
1574 {
1575 OpenRow(nSheet, nStartRow + nRows, nMaxRows, aRowAttr);
1576 nRows += nMaxRows;
1577 }
1578 if (!pRowFormatRanges->GetSize())
1579 pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
1581 CloseRow(nStartRow + nRows - 1);
1582 }
1583 if (nTotalRows == 1)
1584 CloseRow(nStartRow);
1585 OpenRow(nSheet, nEndRow, 1, aRowAttr);
1586 pRowFormatRanges->Clear();
1587 pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges.get());
1589 }
1590 else
1591 {
1592 sal_Int32 nRows(0);
1593 sal_Int32 nTotalRows(nEndRow - nStartRow + 1 - 1);
1594 while (nRows < nTotalRows)
1595 {
1596 pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
1597 sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows();
1598 OSL_ENSURE(nMaxRows, "something went wrong");
1599 if (nMaxRows >= nTotalRows - nRows)
1600 {
1601 OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows, aRowAttr);
1602 nRows += nTotalRows - nRows;
1603 }
1604 else
1605 {
1606 OpenRow(nSheet, nStartRow + nRows, nMaxRows, aRowAttr);
1607 nRows += nMaxRows;
1608 }
1609 if (!pRowFormatRanges->GetSize())
1610 pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges.get());
1612 CloseRow(nStartRow + nRows - 1);
1613 }
1614 OpenRow(nSheet, nEndRow, 1, aRowAttr);
1615 pRowFormatRanges->Clear();
1616 pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges.get());
1618 }
1619 }
1620}
1621
1622void ScXMLExport::GetColumnRowHeader(bool& rHasColumnHeader, ScRange& rColumnHeaderRange,
1623 bool& rHasRowHeader, ScRange& rRowHeaderRange,
1624 OUString& rPrintRanges) const
1625{
1626 uno::Reference <sheet::XPrintAreas> xPrintAreas (xCurrentTable, uno::UNO_QUERY);
1627 if (!xPrintAreas.is())
1628 return;
1629
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() );
1647 ScRangeStringConverter::GetStringFromRangeList( rPrintRanges, aRangeList, pDoc, FormulaGrammar::CONV_OOO );
1648}
1649
1651{
1652 size_t nDepth = pFields->GetDepth();
1653 for (size_t i = 0; i < nDepth; ++i)
1654 {
1655 size_t nFields = pFields->GetCount(i);
1656 for (size_t j = 0; j < nFields; ++j)
1657 {
1658 ScMyColumnRowGroup aGroup;
1659 const ScOutlineEntry* pEntry = pFields->GetEntry(i, j);
1660 aGroup.nField = pEntry->GetStart();
1661 aGroup.nLevel = static_cast<sal_Int16>(i);
1662 aGroup.bDisplay = !(pEntry->IsHidden());
1663 pGroups->AddGroup(aGroup, pEntry->GetEnd());
1664 }
1665 }
1666 if (nDepth)
1667 pGroups->Sort();
1668}
1669
1671{
1672 if (!pDoc)
1673 return;
1674
1675 ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable( static_cast<SCTAB>(nCurrentTable) );
1676 if(pOutlineTable)
1677 {
1678 ScOutlineArray& rCols(pOutlineTable->GetColArray());
1679 ScOutlineArray& rRows(pOutlineTable->GetRowArray());
1680 FillFieldGroup(&rCols, pGroupColumns.get());
1681 FillFieldGroup(&rRows, pGroupRows.get());
1682 pSharedData->SetLastColumn(nCurrentTable, pGroupColumns->GetLast());
1683 pSharedData->SetLastRow(nCurrentTable, pGroupRows->GetLast());
1684 }
1685}
1686
1688{
1689 if (!(pDoc && pDoc->IsDocProtected()))
1690 return;
1691
1693 OUStringBuffer aBuffer;
1694 uno::Sequence<sal_Int8> aPassHash;
1697 if (p)
1698 {
1699 if (p->hasPasswordHash(PASSHASH_SHA1))
1700 {
1701 aPassHash = p->getPasswordHash(PASSHASH_SHA1);
1702 eHashUsed = PASSHASH_SHA1;
1703 }
1704 else if (p->hasPasswordHash(PASSHASH_SHA256))
1705 {
1706 aPassHash = p->getPasswordHash(PASSHASH_SHA256);
1707 eHashUsed = PASSHASH_SHA256;
1708 }
1709 else if (p->hasPasswordHash(PASSHASH_XL, PASSHASH_SHA1))
1710 {
1711 aPassHash = p->getPasswordHash(PASSHASH_XL, PASSHASH_SHA1);
1712 eHashUsed = PASSHASH_XL;
1713 }
1714 }
1716 if (aBuffer.isEmpty())
1717 return;
1718
1721 return;
1722
1723 if (eHashUsed == PASSHASH_XL)
1724 {
1730 }
1731 else if (eHashUsed == PASSHASH_SHA1)
1732 {
1735 }
1736 else if (eHashUsed == PASSHASH_SHA256)
1737 {
1740 }
1741}
1742
1743static bool lcl_CopyStreamElement( const uno::Reference< io::XInputStream >& xInput,
1744 const uno::Reference< io::XOutputStream >& xOutput,
1745 sal_Int32 nCount )
1746{
1747 const sal_Int32 nBufSize = 16*1024;
1748 uno::Sequence<sal_Int8> aSequence(nBufSize);
1749
1750 sal_Int32 nRemaining = nCount;
1751 bool bFirst = true;
1752
1753 while ( nRemaining > 0 )
1754 {
1755 sal_Int32 nRead = xInput->readBytes( aSequence, std::min( nRemaining, nBufSize ) );
1756 if (bFirst)
1757 {
1758 // safety check: Make sure the copied part actually points to the start of an element
1759 if ( nRead < 1 || aSequence[0] != static_cast<sal_Int8>('<') )
1760 {
1761 return false; // abort and set an error
1762 }
1763 bFirst = false;
1764 }
1765 if (nRead == nRemaining)
1766 {
1767 // safety check: Make sure the copied part also ends at the end of an element
1768 if ( aSequence[nRead-1] != static_cast<sal_Int8>('>') )
1769 {
1770 return false; // abort and set an error
1771 }
1772 }
1773
1774 if ( nRead == nBufSize )
1775 {
1776 xOutput->writeBytes( aSequence );
1777 nRemaining -= nRead;
1778 }
1779 else
1780 {
1781 if ( nRead > 0 )
1782 {
1783 uno::Sequence<sal_Int8> aTempBuf( aSequence.getConstArray(), nRead );
1784 xOutput->writeBytes( aTempBuf );
1785 }
1786 nRemaining = 0;
1787 }
1788 }
1789 return true; // successful
1790}
1791
1792static void lcl_SkipBytesInBlocks( const uno::Reference< io::XInputStream >& xInput, sal_Int32 nBytesToSkip )
1793{
1794 // skipBytes in zip stream is implemented as reading.
1795 // For now, split into several calls to avoid allocating a large buffer.
1796 // Later, skipBytes should be changed.
1797
1798 const sal_Int32 nMaxSize = 32*1024;
1799
1800 if ( nBytesToSkip > 0 )
1801 {
1802 sal_Int32 nRemaining = nBytesToSkip;
1803 while ( nRemaining > 0 )
1804 {
1805 sal_Int32 nSkip = std::min( nRemaining, nMaxSize );
1806 xInput->skipBytes( nSkip );
1807 nRemaining -= nSkip;
1808 }
1809 }
1810}
1811
1812void ScXMLExport::CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset, sal_Int32& rNewStart, sal_Int32& rNewEnd )
1813{
1814 uno::Reference<xml::sax::XDocumentHandler> xHandler = GetDocHandler();
1815 uno::Reference<io::XActiveDataSource> xDestSource( xHandler, uno::UNO_QUERY );
1816 if ( !xDestSource.is() )
1817 return;
1818
1819 uno::Reference<io::XOutputStream> xDestStream = xDestSource->getOutputStream();
1820 uno::Reference<io::XSeekable> xDestSeek( xDestStream, uno::UNO_QUERY );
1821 if ( !xDestSeek.is() )
1822 return;
1823
1824 // temporary: set same stream again to clear buffer
1825 xDestSource->setOutputStream( xDestStream );
1826
1827 if ( getExportFlags() & SvXMLExportFlags::PRETTY )
1828 {
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 );
1832 }
1833
1834 rNewStart = static_cast<sal_Int32>(xDestSeek->getPosition());
1835
1836 if ( nStartOffset > nSourceStreamPos )
1838
1839 if ( !lcl_CopyStreamElement( xSourceStream, xDestStream, nEndOffset - nStartOffset ) )
1840 {
1841 // If copying went wrong, set an error.
1842 // ScXMLImportWrapper then resets all stream flags, so the next save attempt will use normal saving.
1843
1844 uno::Sequence<OUString> aEmptySeq;
1846 }
1847 nSourceStreamPos = nEndOffset;
1848
1849 rNewEnd = static_cast<sal_Int32>(xDestSeek->getPosition());
1850}
1851
1853{
1854 if (!mpEditAttrMap)
1856 return *mpEditAttrMap;
1857}
1858
1859void ScXMLExport::RegisterDefinedStyleNames( const uno::Reference< css::sheet::XSpreadsheetDocument > & xSpreadDoc )
1860{
1861 ScFormatSaveData* pFormatData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetFormatSaveData();
1862 auto xAutoStylePool = GetAutoStylePool();
1863 for (const auto& rFormatInfo : pFormatData->maIDToName)
1864 {
1865 xAutoStylePool->RegisterDefinedName(XmlStyleFamily::TABLE_CELL, rFormatInfo.second);
1866 }
1867}
1868
1870{
1871 nCurrentTable = 0;
1872 if (!pSharedData)
1873 {
1874 SCTAB nTableCount(0);
1875 sal_Int32 nShapesCount(0);
1876 CollectSharedData(nTableCount, nShapesCount);
1877 OSL_FAIL("no shared data set");
1878 if (!pSharedData)
1879 return;
1880 }
1881 ScXMLExportDatabaseRanges aExportDatabaseRanges(*this);
1882 if (!GetModel().is())
1883 return;
1884
1885 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
1886 if ( !xSpreadDoc.is() )
1887 return;
1888
1889 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetSheetSaveData();
1890 if (pSheetData)
1891 pSheetData->ResetSaveEntries();
1892
1893 uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
1894 if ( xIndex.is() )
1895 {
1896 //_GetNamespaceMap().ClearQNamesCache();
1897 pChangeTrackingExportHelper->CollectAndWriteChanges();
1898 WriteCalculationSettings(xSpreadDoc);
1899 sal_Int32 nTableCount(xIndex->getCount());
1900 ScMyAreaLinksContainer aAreaLinks;
1901 GetAreaLinks( aAreaLinks );
1902 ScMyEmptyDatabaseRangesContainer aEmptyRanges(aExportDatabaseRanges.GetEmptyDatabaseRanges());
1903 ScMyDetectiveOpContainer aDetectiveOpContainer;
1904 GetDetectiveOpList( aDetectiveOpContainer );
1905
1906 pCellStyles->Sort();
1907 pMergedRangesContainer->Sort();
1908 pSharedData->GetDetectiveObjContainer()->Sort();
1909
1910 mpCellsItr->Clear();
1911 mpCellsItr->SetShapes( pSharedData->GetShapesContainer() );
1912 mpCellsItr->SetNoteShapes( pSharedData->GetNoteShapes() );
1913 mpCellsItr->SetMergedRanges( pMergedRangesContainer.get() );
1914 mpCellsItr->SetAreaLinks( &aAreaLinks );
1915 mpCellsItr->SetEmptyDatabaseRanges( &aEmptyRanges );
1916 mpCellsItr->SetDetectiveObj( pSharedData->GetDetectiveObjContainer() );
1917 mpCellsItr->SetDetectiveOp( &aDetectiveOpContainer );
1918
1919 if (nTableCount > 0)
1920 pValidationsContainer->WriteValidations(*this);
1921 WriteTheLabelRanges( xSpreadDoc );
1922 for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable)
1923 {
1924 sal_Int32 nStartOffset = -1;
1925 sal_Int32 nEndOffset = -1;
1926 if (pSheetData && pDoc && pDoc->IsStreamValid(static_cast<SCTAB>(nTable)) && !pDoc->GetChangeTrack())
1927 pSheetData->GetStreamPos( nTable, nStartOffset, nEndOffset );
1928
1929 if ( nStartOffset >= 0 && nEndOffset >= 0 && xSourceStream.is() )
1930 {
1931 sal_Int32 nNewStart = -1;
1932 sal_Int32 nNewEnd = -1;
1933 CopySourceStream( nStartOffset, nEndOffset, nNewStart, nNewEnd );
1934
1935 // store position of copied sheet in output
1936 pSheetData->AddSavePos( nTable, nNewStart, nNewEnd );
1937
1938 // skip iterator entries for this sheet
1939 mpCellsItr->SkipTable(static_cast<SCTAB>(nTable));
1940 }
1941 else
1942 {
1943 uno::Reference<sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
1944 WriteTable(nTable, xTable);
1945 }
1946 IncrementProgressBar(false);
1947 }
1948 }
1952 aExportDatabaseRanges.WriteDatabaseRanges();
1954 ScXMLExportDataPilot aExportDataPilot(*this);
1955 aExportDataPilot.WriteDataPilots();
1957 ScXMLExportDDELinks aExportDDELinks(*this);
1958 aExportDDELinks.WriteDDELinks(xSpreadDoc);
1959 IncrementProgressBar(true, 0);
1961}
1962
1964{
1965 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
1966 if (xSpreadDoc.is())
1967 RegisterDefinedStyleNames( xSpreadDoc);
1968
1969 if (!pSharedData)
1970 {
1971 SCTAB nTableCount(0);
1972 sal_Int32 nShapesCount(0);
1973 CollectSharedData(nTableCount, nShapesCount);
1974 }
1976 if (GetModel().is())
1977 {
1978 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
1979 if (xMultiServiceFactory.is())
1980 {
1981 uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance("com.sun.star.sheet.Defaults"), uno::UNO_QUERY);
1982 if (xProperties.is())
1983 aStylesExp->exportDefaultStyle(xProperties, XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME, xCellStylesExportPropertySetMapper);
1984 GetShapeExport()->ExportGraphicDefaults();
1985 }
1986 collectDataStyles(false);
1987 }
1989
1990 aStylesExp->exportStyleFamily("CellStyles",
1992
1994}
1995
1996void ScXMLExport::AddStyleFromCells(const uno::Reference<beans::XPropertySet>& xProperties,
1997 const uno::Reference<sheet::XSpreadsheet>& xTable,
1998 sal_Int32 nTable, const OUString* pOldName)
1999{
2000 css::uno::Any aAny = xProperties->getPropertyValue("FormatID");
2001 sal_uInt64 nKey = 0;
2002 aAny >>= nKey;
2003
2005 uno::Reference<sheet::XSheetCellRanges> xCellRanges( xProperties, uno::UNO_QUERY );
2006
2007 OUString sStyleName;
2008 sal_Int32 nNumberFormat(-1);
2009 sal_Int32 nValidationIndex(-1);
2010 std::vector<XMLPropertyState> aPropStates(xCellStylesExportPropertySetMapper->Filter(*this, xProperties));
2011 std::vector< XMLPropertyState >::iterator aItr(aPropStates.begin());
2012 std::vector< XMLPropertyState >::iterator aEndItr(aPropStates.end());
2013 sal_Int32 nCount(0);
2014 while (aItr != aEndItr)
2015 {
2016 if (aItr->mnIndex != -1)
2017 {
2018 switch (xCellStylesPropertySetMapper->GetEntryContextId(aItr->mnIndex))
2019 {
2020 case CTF_SC_VALIDATION :
2021 {
2022 pValidationsContainer->AddValidation(aItr->maValue, nValidationIndex);
2023 // this is not very slow, because it is most the last property or
2024 // if it is not the last property it is the property before the last property,
2025 // so in the worst case only one property has to be copied, but in the best case no
2026 // property has to be copied
2027 aItr = aPropStates.erase(aItr);
2028 aEndItr = aPropStates.end(); // old aEndItr is invalidated!
2029 }
2030 break;
2031 case CTF_SC_CELLSTYLE :
2032 {
2033 aItr->maValue >>= sStyleName;
2034 aItr->mnIndex = -1;
2035 ++aItr;
2036 ++nCount;
2037 }
2038 break;
2039 case CTF_SC_NUMBERFORMAT :
2040 {
2041 if (aItr->maValue >>= nNumberFormat)
2042 addDataStyle(nNumberFormat);
2043 ++aItr;
2044 ++nCount;
2045 }
2046 break;
2047 default:
2048 {
2049 ++aItr;
2050 ++nCount;
2051 }
2052 break;
2053 }
2054 }
2055 else
2056 {
2057 ++aItr;
2058 ++nCount;
2059 }
2060 }
2061 if (nCount == 1) // this is the CellStyle and should be removed if alone
2062 aPropStates.clear();
2063 if (nNumberFormat == -1)
2064 xProperties->getPropertyValue(SC_UNONAME_NUMFMT) >>= nNumberFormat;
2065 if (sStyleName.isEmpty())
2066 return;
2067
2068 if (!aPropStates.empty())
2069 {
2070 sal_Int32 nIndex;
2071 if (pOldName)
2072 {
2073 if (GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_CELL, sStyleName, std::move(aPropStates)))
2074 {
2075 GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_CELL, *pOldName);
2076 // add to pCellStyles, so the name is found for normal sheets
2077 pCellStyles->AddStyleName(*pOldName, nIndex);
2078 }
2079 }
2080 else
2081 {
2082 OUString sName;
2083 bool bAdded = false;
2084 if (nKey)
2085 {
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);
2089 if (itr != pFormatData->maIDToName.end())
2090 {
2091 sName = itr->second;
2092 bAdded = GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TABLE_CELL, sStyleName, aPropStates);
2093 if (bAdded)
2094 GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_CELL, sName);
2095 }
2096 }
2097 bool bIsAutoStyle(true);
2098 if (bAdded || GetAutoStylePool()->Add(sName, XmlStyleFamily::TABLE_CELL, sStyleName, std::move(aPropStates)))
2099 {
2100 pCellStyles->AddStyleName(sName, nIndex);
2101 }
2102 else
2103 nIndex = pCellStyles->GetIndexOfStyleName(sName, XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX, bIsAutoStyle);
2104
2105 const uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
2106 bool bGetMerge(true);
2107 for (table::CellRangeAddress const & address : aAddresses)
2108 {
2109 pSharedData->SetLastColumn(nTable, address.EndColumn);
2110 pSharedData->SetLastRow(nTable, address.EndRow);
2111 pCellStyles->AddRangeStyleName(address, nIndex, bIsAutoStyle, nValidationIndex, nNumberFormat);
2112 if (bGetMerge)
2113 bGetMerge = GetMerged(&address, xTable);
2114 }
2115 }
2116 }
2117 else
2118 {
2119 OUString sEncodedStyleName(EncodeStyleName(sStyleName));
2120 sal_Int32 nIndex(0);
2121 pCellStyles->AddStyleName(sEncodedStyleName, nIndex, false);
2122 if ( !pOldName )
2123 {
2124 const uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
2125 bool bGetMerge(true);
2126 for (table::CellRangeAddress const & address : aAddresses)
2127 {
2128 if (bGetMerge)
2129 bGetMerge = GetMerged(&address, xTable);
2130 pCellStyles->AddRangeStyleName(address, nIndex, false, nValidationIndex, nNumberFormat);
2131 if( sStyleName != "Default" || nValidationIndex != -1 )
2132 {
2133 pSharedData->SetLastColumn(nTable, address.EndColumn);
2134 pSharedData->SetLastRow(nTable, address.EndRow);
2135 }
2136 }
2137 }
2138 }
2139}
2140
2141void ScXMLExport::AddStyleFromColumn(const uno::Reference<beans::XPropertySet>& xColumnProperties,
2142 const OUString* pOldName, sal_Int32& rIndex, bool& rIsVisible)
2143{
2144 std::vector<XMLPropertyState> aPropStates(xColumnStylesExportPropertySetMapper->Filter(*this, xColumnProperties));
2145 if(aPropStates.empty())
2146 return;
2147
2148 auto aItr = std::find_if(aPropStates.begin(), aPropStates.end(),
2149 [this](const XMLPropertyState& rPropState) {
2150 return xColumnStylesPropertySetMapper->GetEntryContextId(rPropState.mnIndex) == CTF_SC_ISVISIBLE; });
2151 if (aItr != aPropStates.end())
2152 {
2153 aItr->maValue >>= rIsVisible;
2154 }
2155
2156 const OUString sParent;
2157 if (pOldName)
2158 {
2159 if (GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_COLUMN, sParent, std::move(aPropStates)))
2160 {
2161 GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_COLUMN, *pOldName);
2162 // add to pColumnStyles, so the name is found for normal sheets
2163 rIndex = pColumnStyles->AddStyleName(*pOldName);
2164 }
2165 }
2166 else
2167 {
2168 OUString sName;
2169 if (GetAutoStylePool()->Add(sName, XmlStyleFamily::TABLE_COLUMN, sParent, std::move(aPropStates)))
2170 {
2171 rIndex = pColumnStyles->AddStyleName(sName);
2172 }
2173 else
2174 rIndex = pColumnStyles->GetIndexOfStyleName(sName, XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX);
2175 }
2176}
2177
2178void ScXMLExport::AddStyleFromRow(const uno::Reference<beans::XPropertySet>& xRowProperties,
2179 const OUString* pOldName, sal_Int32& rIndex)
2180{
2181 std::vector<XMLPropertyState> aPropStates(xRowStylesExportPropertySetMapper->Filter(*this, xRowProperties));
2182 if(aPropStates.empty())
2183 return;
2184
2185 const OUString sParent;
2186 if (pOldName)
2187 {
2188 if (GetAutoStylePool()->AddNamed(*pOldName, XmlStyleFamily::TABLE_ROW, sParent, std::move(aPropStates)))
2189 {
2190 GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_ROW, *pOldName);
2191 // add to pRowStyles, so the name is found for normal sheets
2192 rIndex = pRowStyles->AddStyleName(*pOldName);
2193 }
2194 }
2195 else
2196 {
2197 OUString sName;
2198 if (GetAutoStylePool()->Add(sName, XmlStyleFamily::TABLE_ROW, sParent, std::move(aPropStates)))
2199 {
2200 rIndex = pRowStyles->AddStyleName(sName);
2201 }
2202 else
2203 rIndex = pRowStyles->GetIndexOfStyleName(sName, XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX);
2204 }
2205}
2206
2207static uno::Any lcl_GetEnumerated( uno::Reference<container::XEnumerationAccess> const & xEnumAccess, sal_Int32 nIndex )
2208{
2209 uno::Any aRet;
2210 uno::Reference<container::XEnumeration> xEnum( xEnumAccess->createEnumeration() );
2211 try
2212 {
2213 sal_Int32 nSkip = nIndex;
2214 while ( nSkip > 0 )
2215 {
2216 (void) xEnum->nextElement();
2217 --nSkip;
2218 }
2219 aRet = xEnum->nextElement();
2220 }
2221 catch (container::NoSuchElementException&)
2222 {
2223 // leave aRet empty
2224 }
2225 return aRet;
2226}
2227
2229{
2231
2233 return;
2234
2235 if (!GetModel().is())
2236 return;
2237
2238 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
2239 if (!xSpreadDoc.is())
2240 return;
2241
2242 uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
2243 if (!xIndex.is())
2244 return;
2245
2246 if (getExportFlags() & SvXMLExportFlags::CONTENT)
2247 {
2248 // Reserve the loaded cell style names.
2249 RegisterDefinedStyleNames( xSpreadDoc);
2250
2251 // re-create automatic styles with old names from stored data
2252 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(xSpreadDoc)->GetSheetSaveData();
2253 if (pSheetData && pDoc)
2254 {
2255 // formulas have to be calculated now, to detect changed results
2256 // (during normal save, they will be calculated anyway)
2257 SCTAB nTabCount = pDoc->GetTableCount();
2258 for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
2259 if (pDoc->IsStreamValid(nTab))
2260 pDoc->InterpretDirtyCells(ScRange(0, 0, nTab, pDoc->MaxCol(), pDoc->MaxRow(), nTab));
2261
2262 // stored cell styles
2263 const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles();
2264 for (const auto& rCellEntry : rCellEntries)
2265 {
2266 ScAddress aPos = rCellEntry.maCellPos;
2267 sal_Int32 nTable = aPos.Tab();
2268 bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2269 if (bCopySheet)
2270 {
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 );
2274
2275 AddStyleFromCells(xProperties, xTable, nTable, &rCellEntry.maName);
2276 }
2277 }
2278
2279 // stored column styles
2280 const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->GetColumnStyles();
2281 for (const auto& rColumnEntry : rColumnEntries)
2282 {
2283 ScAddress aPos = rColumnEntry.maCellPos;
2284 sal_Int32 nTable = aPos.Tab();
2285 bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2286 if (bCopySheet)
2287 {
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);
2291
2292 sal_Int32 nIndex(-1);
2293 bool bIsVisible(true);
2294 AddStyleFromColumn( xColumnProperties, &rColumnEntry.maName, nIndex, bIsVisible );
2295 }
2296 }
2297
2298 // stored row styles
2299 const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->GetRowStyles();
2300 for (const auto& rRowEntry : rRowEntries)
2301 {
2302 ScAddress aPos = rRowEntry.maCellPos;
2303 sal_Int32 nTable = aPos.Tab();
2304 bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2305 if (bCopySheet)
2306 {
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);
2310
2311 sal_Int32 nIndex(-1);
2312 AddStyleFromRow( xRowProperties, &rRowEntry.maName, nIndex );
2313 }
2314 }
2315
2316 // stored table styles
2317 const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->GetTableStyles();
2318 for (const auto& rTableEntry : rTableEntries)
2319 {
2320 ScAddress aPos = rTableEntry.maCellPos;
2321 sal_Int32 nTable = aPos.Tab();
2322 bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2323 if (bCopySheet)
2324 {
2326 uno::Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2327 if (xTableProperties.is())
2328 {
2329 std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(*this, xTableProperties));
2330 OUString sName( rTableEntry.maName );
2331 GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TABLE_TABLE, OUString(), std::move(aPropStates));
2332 GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_TABLE, sName);
2333 }
2334 }
2335 }
2336
2337 // stored styles for notes
2338
2340
2341 const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles();
2342 for (const auto& rNoteEntry : rNoteEntries)
2343 {
2344 ScAddress aPos = rNoteEntry.maCellPos;
2345 SCTAB nTable = aPos.Tab();
2346 bool bCopySheet = pDoc->IsStreamValid( nTable );
2347 if (bCopySheet)
2348 {
2350
2351 ScPostIt* pNote = pDoc->GetNote(aPos);
2352 OSL_ENSURE( pNote, "note not found" );
2353 if (pNote)
2354 {
2355 SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
2356 // all uno shapes are created anyway in CollectSharedData
2357 uno::Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY );
2358 if (xShapeProperties.is())
2359 {
2360 if ( !rNoteEntry.maStyleName.isEmpty() )
2361 {
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));
2365 GetAutoStylePool()->RegisterName(XmlStyleFamily::SD_GRAPHICS_ID, sName);
2366 }
2367 if ( !rNoteEntry.maTextStyle.isEmpty() )
2368 {
2369 std::vector<XMLPropertyState> aPropStates(
2370 GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(*this, xShapeProperties));
2371 OUString sName( rNoteEntry.maTextStyle );
2372 GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), std::move(aPropStates));
2373 GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName);
2374 }
2375 }
2376 }
2377 }
2378 }
2379
2380 // note paragraph styles
2381
2382 rtl::Reference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper();
2383
2384 const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles();
2385 for (const auto& rNoteParaEntry : rNoteParaEntries)
2386 {
2387 ScAddress aPos = rNoteParaEntry.maCellPos;
2388 SCTAB nTable = aPos.Tab();
2389 bool bCopySheet = pDoc->IsStreamValid( nTable );
2390 if (bCopySheet)
2391 {
2392 ScPostIt* pNote = pDoc->GetNote( aPos );
2393 OSL_ENSURE( pNote, "note not found" );
2394 if (pNote)
2395 {
2396 SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
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() )
2401 {
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));
2405 GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName);
2406 }
2407 }
2408 }
2409 }
2410
2411 // note text styles
2412
2414
2415 const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles();
2416 for (const auto& rNoteTextEntry : rNoteTextEntries)
2417 {
2418 ScAddress aPos = rNoteTextEntry.maCellPos;
2419 SCTAB nTable = aPos.Tab();
2420 bool bCopySheet = pDoc->IsStreamValid( nTable );
2421 if (bCopySheet)
2422 {
2423 ScPostIt* pNote = pDoc->GetNote( aPos );
2424 OSL_ENSURE( pNote, "note not found" );
2425 if (pNote)
2426 {
2427 SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
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 );
2431 if (pCursor)
2432 {
2433 pCursor->SetSelection( rNoteTextEntry.maSelection );
2434
2435 std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp));
2436 OUString sName( rNoteTextEntry.maName );
2437 GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), std::move(aPropStates));
2438 GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName);
2439 }
2440 }
2441 }
2442 }
2443
2444 // stored text styles
2445
2446 // Calling createTextCursor fires up editeng, which is very slow, and often subsequent style entries
2447 // refer to the same cell, so cache it.
2448 ScAddress aPrevPos;
2449 uno::Reference<beans::XPropertySet> xPrevCursorProp;
2450 const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles();
2451 for (const auto& rTextEntry : rTextEntries)
2452 {
2453 ScAddress aPos = rTextEntry.maCellPos;
2454 sal_Int32 nTable = aPos.Tab();
2455 bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2456 if (!bCopySheet)
2457 continue;
2458
2461
2462 uno::Reference<beans::XPropertySet> xCursorProp;
2463 if (xPrevCursorProp && aPrevPos == aPos)
2464 xCursorProp = xPrevCursorProp;
2465 else
2466 {
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);
2470 }
2471 ScCellTextCursor* pCursor = comphelper::getFromUnoTunnel<ScCellTextCursor>( xCursorProp );
2472 if (!pCursor)
2473 continue;
2474 pCursor->SetSelection( rTextEntry.maSelection );
2475
2476 std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp));
2477 OUString sName( rTextEntry.maName );
2478 GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), std::move(aPropStates));
2479 GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName);
2480 xPrevCursorProp = xCursorProp;
2481 aPrevPos = aPos;
2482 }
2483 }
2484
2486
2487 if (!pSharedData)
2488 {
2489 SCTAB nTableCount(0);
2490 sal_Int32 nShapesCount(0);
2491 CollectSharedData(nTableCount, nShapesCount);
2492 }
2493 sal_Int32 nTableCount(xIndex->getCount());
2494 pCellStyles->AddNewTable(nTableCount - 1);
2495 CollectShapesAutoStyles(nTableCount);
2496 for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable, IncrementProgressBar(false))
2497 {
2498 uno::Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2499 if (!xTable.is())
2500 continue;
2501
2502 // table styles array must be complete, including copied tables - Add should find the stored style
2503 uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
2504 if (xTableProperties.is())
2505 {
2506 std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(*this, xTableProperties));
2507 if(!aPropStates.empty())
2508 {
2509 OUString sName;
2510 GetAutoStylePool()->Add(sName, XmlStyleFamily::TABLE_TABLE, OUString(), std::move(aPropStates));
2511 aTableStyles.push_back(sName);
2512 }
2513 }
2514
2515 // collect other auto-styles only for non-copied sheets
2516 uno::Reference<sheet::XUniqueCellFormatRangesSupplier> xCellFormatRanges ( xTable, uno::UNO_QUERY );
2517 if ( xCellFormatRanges.is() )
2518 {
2519 uno::Reference<container::XIndexAccess> xFormatRangesIndex(xCellFormatRanges->getUniqueCellFormatRanges());
2520 if (xFormatRangesIndex.is())
2521 {
2522 sal_Int32 nFormatRangesCount(xFormatRangesIndex->getCount());
2523 GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nFormatRangesCount);
2524 for (sal_Int32 nFormatRange = 0; nFormatRange < nFormatRangesCount; ++nFormatRange)
2525 {
2526 uno::Reference< sheet::XSheetCellRanges> xCellRanges(xFormatRangesIndex->getByIndex(nFormatRange), uno::UNO_QUERY);
2527 if (xCellRanges.is())
2528 {
2529 uno::Reference <beans::XPropertySet> xProperties (xCellRanges, uno::UNO_QUERY);
2530 if (xProperties.is())
2531 {
2532 AddStyleFromCells(xProperties, xTable, nTable, nullptr);
2533 IncrementProgressBar(false);
2534 }
2535 }
2536 }
2537 }
2538 }
2539 uno::Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY);
2540 if (xColumnRowRange.is() && pDoc)
2541 {
2543 uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
2544 if (xTableColumns.is())
2545 {
2546 sal_Int32 nColumns(pDoc->GetLastChangedColFlagsWidth(sal::static_int_cast<SCTAB>(nTable)));
2547 pSharedData->SetLastColumn(nTable, nColumns);
2548 table::CellRangeAddress aCellAddress(GetEndAddress(xTable));
2549 if (aCellAddress.EndColumn > nColumns)
2550 {
2551 ++nColumns;
2552 pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn);
2553 }
2554 else
2555 pColumnStyles->AddNewTable(nTable, nColumns);
2556 sal_Int32 nColumn = 0;
2557 while (nColumn <= pDoc->MaxCol())
2558 {
2559 sal_Int32 nIndex(-1);
2560 bool bIsVisible(true);
2561 uno::Reference <beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY);
2562 if (xColumnProperties.is())
2563 {
2564 AddStyleFromColumn( xColumnProperties, nullptr, nIndex, bIsVisible );
2565 pColumnStyles->AddFieldStyleName(nTable, nColumn, nIndex, bIsVisible);
2566 }
2567 sal_Int32 nOld(nColumn);
2568 nColumn = pDoc->GetNextDifferentChangedColFlagsWidth(sal::static_int_cast<SCTAB>(nTable), static_cast<SCCOL>(nColumn));
2569 for (sal_Int32 i = nOld + 1; i < nColumn; ++i)
2570 pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
2571 }
2572 if (aCellAddress.EndColumn > nColumns)
2573 {
2574 bool bIsVisible(true);
2575 sal_Int32 nIndex(pColumnStyles->GetStyleNameIndex(nTable, nColumns, bIsVisible));
2576 for (sal_Int32 i = nColumns + 1; i <= aCellAddress.EndColumn; ++i)
2577 pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
2578 }
2579 }
2580 uno::Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
2581 if (xTableRows.is())
2582 {
2583 sal_Int32 nRows(pDoc->GetLastChangedRowFlagsWidth(sal::static_int_cast<SCTAB>(nTable)));
2584 pSharedData->SetLastRow(nTable, nRows);
2585
2586 pRowStyles->AddNewTable(nTable, pDoc->MaxRow());
2587 sal_Int32 nRow = 0;
2588 while (nRow <= pDoc->MaxRow())
2589 {
2590 sal_Int32 nIndex = 0;
2591 uno::Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY);
2592 if(xRowProperties.is())
2593 {
2594 AddStyleFromRow( xRowProperties, nullptr, nIndex );
2595 pRowStyles->AddFieldStyleName(nTable, nRow, nIndex);
2596 }
2597 sal_Int32 nOld(nRow);
2598 nRow = pDoc->GetNextDifferentChangedRowFlagsWidth(sal::static_int_cast<SCTAB>(nTable), static_cast<SCROW>(nRow));
2599 if (nRow > nOld + 1)
2600 pRowStyles->AddFieldStyleName(nTable, nOld + 1, nIndex, nRow - 1);
2601 }
2602 }
2603 }
2605 }
2606
2607 pChangeTrackingExportHelper->CollectAutoStyles();
2608 }
2609
2610 if (getExportFlags() & SvXMLExportFlags::MASTERSTYLES)
2611 // tdf#154445 - export all page styles even if they are not in use
2612 GetPageExport()->collectAutoStyles(false);
2613
2614 mbAutoStylesCollected = true;
2615}
2616
2618{
2619 if (!GetModel().is())
2620 return;
2621
2622 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
2623 if (!xSpreadDoc.is())
2624 return;
2625
2626 uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
2627 if (!xIndex.is())
2628 return;
2629
2631
2632 if (getExportFlags() & SvXMLExportFlags::CONTENT)
2633 {
2634 GetAutoStylePool()->exportXML(XmlStyleFamily::TABLE_COLUMN);
2635 GetAutoStylePool()->exportXML(XmlStyleFamily::TABLE_ROW);
2636 GetAutoStylePool()->exportXML(XmlStyleFamily::TABLE_TABLE);
2638 GetAutoStylePool()->exportXML(XmlStyleFamily::TABLE_CELL);
2639
2640 GetShapeExport()->exportAutoStyles();
2641 GetFormExport()->exportAutoStyles( );
2642
2643 if (pDoc)
2644 {
2646 // #i100879# write the table style for cached tables only if there are cached tables
2647 // (same logic as in ExportExternalRefCacheStyles)
2648 if (pRefMgr->hasExternalData())
2649 {
2650 // Special table style for the external ref cache tables.
2653 SvXMLElementExport aElemStyle(*this, XML_NAMESPACE_STYLE, XML_STYLE, true, true);
2655 SvXMLElementExport aElemStyleTabProps(*this, XML_NAMESPACE_STYLE, XML_TABLE_PROPERTIES, true, true);
2656 }
2657 }
2658 }
2659
2660 if (getExportFlags() & SvXMLExportFlags::MASTERSTYLES)
2661 {
2663 GetPageExport()->exportAutoStyles();
2664 }
2665
2666 // #i30251#; only write Text Styles once
2667
2668 if ((getExportFlags() & SvXMLExportFlags::CONTENT) || (getExportFlags() & SvXMLExportFlags::MASTERSTYLES))
2669 GetTextParagraphExport()->exportTextAutoStyles();
2670}
2671
2673{
2674 // tdf#154445 - export all page styles even if they are not in use
2675 GetPageExport()->exportMasterStyles( false );
2676}
2677
2678void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > const & xShape )
2679{
2680 // detective objects and notes
2682 if( !pObject )
2683 return;
2684
2685 // collect note caption objects from all layers (internal or hidden)
2686 if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, static_cast< SCTAB >( nCurrentTable ) ) )
2687 {
2688 if(pDoc->GetNote(pCaptData->maStart))
2689 {
2690 pSharedData->AddNoteObj( xShape, pCaptData->maStart );
2691
2692 // #i60851# When the file is saved while editing a new note,
2693 // the cell is still empty -> last column/row must be updated
2694 OSL_ENSURE( pCaptData->maStart.Tab() == nCurrentTable, "invalid table in object data" );
2695 pSharedData->SetLastColumn( nCurrentTable, pCaptData->maStart.Col() );
2696 pSharedData->SetLastRow( nCurrentTable, pCaptData->maStart.Row() );
2697 }
2698 }
2699 // other objects from internal layer only (detective)
2700 else if( pObject->GetLayer() == SC_LAYER_INTERN )
2701 {
2702 ScDetectiveFunc aDetFunc( *pDoc, static_cast<SCTAB>(nCurrentTable) );
2703 ScAddress aPosition;
2704 ScRange aSourceRange;
2705 bool bRedLine;
2706 ScDetectiveObjType eObjType = aDetFunc.GetDetectiveObjectType(
2707 pObject, nCurrentTable, aPosition, aSourceRange, bRedLine );
2708 pSharedData->GetDetectiveObjContainer()->AddObject( eObjType, static_cast<SCTAB>(nCurrentTable), aPosition, aSourceRange, bRedLine );
2709 }
2710}
2711
2712bool ScXMLExport::GetMerged (const table::CellRangeAddress* pCellAddress,
2713 const uno::Reference <sheet::XSpreadsheet>& xTable)
2714{
2715 bool bReady(false);
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)
2722 {
2723 uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xTable->getCellRangeByPosition(nCol, nRow, nCol, nRow), uno::UNO_QUERY);
2724 if (xSheetCellRange.is())
2725 {
2726 uno::Reference<sheet::XSheetCellCursor> xCursor(xTable->createCursorByRange(xSheetCellRange));
2727 if(xCursor.is())
2728 {
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 );
2734
2735 if ((aScRange.aEnd.Row() > nRow ||
2736 aScRange.aEnd.Col() > nCol) &&
2737 aScRange.aStart.Row() == nRow &&
2738 aScRange.aStart.Col() == nCol)
2739 {
2740 pMergedRangesContainer->AddRange(aScRange);
2741 pSharedData->SetLastColumn(aScRange.aEnd.Tab(), aScRange.aEnd.Col());
2742 pSharedData->SetLastRow(aScRange.aEnd.Tab(), aScRange.aEnd.Row());
2743 }
2744 else
2745 bReady = true;
2746 }
2747 }
2748 if (!bReady)
2749 {
2750 if (bRowInc)
2751 ++nRow;
2752 else
2753 ++nCol;
2754 }
2755 }
2756 OSL_ENSURE(!(!bReady && nEndRow > nRow && nEndCol > nCol), "should not be possible");
2757 return !bReady;
2758}
2759
2761 ScRange& aCellAddress, bool& bIsFirst) const
2762{
2763 bIsFirst = false;
2764
2765 ScRange aMatrixRange;
2766
2767 if (pDoc && pDoc->GetMatrixFormulaRange(aCell, aMatrixRange))
2768 {
2769 aCellAddress = aMatrixRange;
2770 if ((aCellAddress.aStart.Col() == aCell.Col() && aCellAddress.aStart.Row() == aCell.Row()) &&
2771 (aCellAddress.aEnd.Col() > aCell.Col() || aCellAddress.aEnd.Row() > aCell.Row()))
2772 {
2773 bIsFirst = true;
2774 return true;
2775 }
2776 else if (aCellAddress.aStart.Col() != aCell.Col() || aCellAddress.aStart.Row() != aCell.Row() ||
2777 aCellAddress.aEnd.Col() != aCell.Col() || aCellAddress.aEnd.Row()!= aCell.Row())
2778 return true;
2779 else
2780 {
2781 bIsFirst = true;
2782 return true;
2783 }
2784 }
2785
2786 return false;
2787}
2788
2789void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpreadsheet>& xTable)
2790{
2791 if (!xTable.is())
2792 return;
2793
2794 xCurrentTable.set(xTable);
2795 uno::Reference<container::XNamed> xName (xTable, uno::UNO_QUERY );
2796 if (!xName.is())
2797 return;
2798
2799 nCurrentTable = sal::static_int_cast<sal_uInt16>( nTable );
2800 OUString sOUTableName(xName->getName());
2801 AddAttribute(sAttrName, sOUTableName);
2803
2804 uno::Reference<util::XProtectable> xProtectable (xTable, uno::UNO_QUERY);
2805 const ScTableProtection* pProtect = nullptr;
2806 if (xProtectable.is() && xProtectable->isProtected())
2807 {
2809 if (pDoc)
2810 {
2811 pProtect = pDoc->GetTabProtection(nTable);
2812 if (pProtect)
2813 {
2814 OUStringBuffer aBuffer;
2816 if (pProtect->hasPasswordHash(PASSHASH_SHA1))
2817 {
2819 pProtect->getPasswordHash(PASSHASH_SHA1));
2820 eHashUsed = PASSHASH_SHA1;
2821 }
2822 else if (pProtect->hasPasswordHash(PASSHASH_SHA256))
2823 {
2825 pProtect->getPasswordHash(PASSHASH_SHA256));
2826 eHashUsed = PASSHASH_SHA256;
2827 }
2828 else if (pProtect->hasPasswordHash(PASSHASH_XL, PASSHASH_SHA1))
2829 {
2830 // Double-hash this by SHA1 on top of the legacy xls hash.
2831 uno::Sequence<sal_Int8> aHash = pProtect->getPasswordHash(PASSHASH_XL, PASSHASH_SHA1);
2833 eHashUsed = PASSHASH_XL;
2834 }
2835 if (!aBuffer.isEmpty())
2836 {
2839 {
2840 if (eHashUsed == PASSHASH_XL)
2841 {
2847 }
2848 else if (eHashUsed == PASSHASH_SHA1)
2849 {
2852 }
2853 else if (eHashUsed == PASSHASH_SHA256)
2854 {
2857 }
2858 }
2859 }
2860 }
2861 }
2862 }
2863 OUString sPrintRanges;
2864 ScRange aColumnHeaderRange;
2865 bool bHasColumnHeader;
2866 GetColumnRowHeader(bHasColumnHeader, aColumnHeaderRange, bHasRowHeader, aRowHeaderRange, sPrintRanges);
2867 if( !sPrintRanges.isEmpty() )
2869 else if (pDoc && !pDoc->IsPrintEntireSheet(static_cast<SCTAB>(nTable)))
2871 SvXMLElementExport aElemT(*this, sElemTab, true, true);
2872
2873 if (pProtect && pProtect->isProtected() && getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
2874 {
2879
2884
2889
2890 OUString aElemName = GetNamespaceMap().GetQNameByKey(
2892
2893 SvXMLElementExport aElemProtected(*this, aElemName, true, true);
2894 }
2895
2896 CheckAttrList();
2897
2898 if ( pDoc && pDoc->GetSheetEvents( static_cast<SCTAB>(nTable) ) &&
2900 {
2901 // store sheet events
2902 uno::Reference<document::XEventsSupplier> xSupplier(xTable, uno::UNO_QUERY);
2903 uno::Reference<container::XNameAccess> xEvents = xSupplier->getEvents();
2904 GetEventExport().ExportExt( xEvents );
2905 }
2906
2908 WriteScenario();
2909 uno::Reference<drawing::XDrawPage> xDrawPage;
2910 if (pSharedData->HasForm(nTable, xDrawPage) && xDrawPage.is())
2911 {
2912 ::xmloff::OOfficeFormsExport aForms(*this);
2913 GetFormExport()->exportForms( xDrawPage );
2914 bool bRet(GetFormExport()->seekPage( xDrawPage ));
2915 OSL_ENSURE( bRet, "OFormLayerXMLExport::seekPage failed!" );
2916 }
2917 if (pSharedData->HasDrawPage())
2918 {
2919 GetShapeExport()->seekShapes(pSharedData->GetDrawPage(nTable));
2921 }
2922 table::CellRangeAddress aRange(GetEndAddress(xTable));
2923 pSharedData->SetLastColumn(nTable, aRange.EndColumn);
2924 pSharedData->SetLastRow(nTable, aRange.EndRow);
2925 mpCellsItr->SetCurrentTable(static_cast<SCTAB>(nTable), xCurrentTable);
2926 pGroupColumns->NewTable();
2927 pGroupRows->NewTable();
2929 if (bHasColumnHeader)
2930 pSharedData->SetLastColumn(nTable, aColumnHeaderRange.aEnd.Col());
2931 bRowHeaderOpen = false;
2932 if (bHasRowHeader)
2933 pSharedData->SetLastRow(nTable, aRowHeaderRange.aEnd.Row());
2934 pDefaults->FillDefaultStyles(nTable, pSharedData->GetLastRow(nTable),
2935 pSharedData->GetLastColumn(nTable), pCellStyles.get(), pDoc);
2936 pRowFormatRanges->SetColDefaults(&pDefaults->GetColDefaults());
2937 pCellStyles->SetColDefaults(&pDefaults->GetColDefaults());
2938 ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader);
2939 bool bIsFirst(true);
2940 sal_Int32 nEqualCells(0);
2941 ScMyCell aCell;
2942 ScMyCell aPrevCell;
2943 while (mpCellsItr->GetNext(aCell, pCellStyles.get()))
2944 {
2945 if (bIsFirst)
2946 {
2947 ExportFormatRanges(0, 0, aCell.maCellAddress.Col()-1, aCell.maCellAddress.Row(), nTable);
2948 aPrevCell = aCell;
2949 bIsFirst = false;
2950 }
2951 else
2952 {
2953 if ((aPrevCell.maCellAddress.Row() == aCell.maCellAddress.Row()) &&
2954 (aPrevCell.maCellAddress.Col() + nEqualCells + 1 == aCell.maCellAddress.Col()))
2955 {
2956 if(IsCellEqual(aPrevCell, aCell))
2957 ++nEqualCells;
2958 else
2959 {
2960 WriteCell(aPrevCell, nEqualCells);
2961 nEqualCells = 0;
2962 aPrevCell = aCell;
2963 }
2964 }
2965 else
2966 {
2967 WriteCell(aPrevCell, nEqualCells);
2968 ExportFormatRanges(aPrevCell.maCellAddress.Col() + nEqualCells + 1, aPrevCell.maCellAddress.Row(),
2969 aCell.maCellAddress.Col()-1, aCell.maCellAddress.Row(), nTable);
2970 nEqualCells = 0;
2971 aPrevCell = aCell;
2972 }
2973 }
2974 }
2975 if (!bIsFirst)
2976 {
2977 WriteCell(aPrevCell, nEqualCells);
2978 ExportFormatRanges(aPrevCell.maCellAddress.Col() + nEqualCells + 1, aPrevCell.maCellAddress.Row(),
2979 pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable);
2980 }
2981 else
2982 ExportFormatRanges(0, 0, pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable);
2983
2984 CloseRow(pSharedData->GetLastRow(nTable));
2985
2986 if (!pDoc)
2987 return;
2988
2989 // Export sheet-local named ranges.
2990 ScRangeName* pRangeName = pDoc->GetRangeName(nTable);
2991 if (pRangeName && !pRangeName->empty())
2992 {
2993 WriteNamedRange(pRangeName);
2994 }
2995
2997 {
2998 //export new conditional format information
3000 exportSparklineGroups(nTable);
3001 }
3002}
3003
3004namespace {
3005
3006void writeContent(
3007 ScXMLExport& rExport, const OUString& rStyleName, const OUString& rContent, const SvxFieldData* pField )
3008{
3009 std::unique_ptr<SvXMLElementExport> pElem;
3010 if (!rStyleName.isEmpty())
3011 {
3012 // Formatted section with automatic style.
3013 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, rStyleName);
3014 OUString aElemName = rExport.GetNamespaceMap().GetQNameByKey(
3015 XML_NAMESPACE_TEXT, GetXMLToken(XML_SPAN));
3016 pElem.reset(new SvXMLElementExport(rExport, aElemName, false, false));
3017 }
3018
3019 if (pField)
3020 {
3021 // Write a field item.
3022 OUString aFieldVal = ScEditUtil::GetCellFieldValue(*pField, rExport.GetDocument(), nullptr, nullptr);
3023 switch (pField->GetClassId())
3024 {
3025 case text::textfield::Type::URL:
3026 {
3027 // <text:a xlink:href="url" xlink:type="simple">value</text:a>
3028
3029 const SvxURLField* pURLField = static_cast<const SvxURLField*>(pField);
3030 const OUString& aURL = pURLField->GetURL();
3031 rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, rExport.GetRelativeReference(aURL));
3032 rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, "simple");
3033 const OUString& aTargetFrame = pURLField->GetTargetFrame();
3034 if (!aTargetFrame.isEmpty())
3035 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, aTargetFrame);
3036
3037 OUString aElemName = rExport.GetNamespaceMap().GetQNameByKey(
3038 XML_NAMESPACE_TEXT, GetXMLToken(XML_A));
3039 SvXMLElementExport aElem(rExport, aElemName, false, false);
3040 rExport.Characters(aFieldVal);
3041 }
3042 break;
3044 {
3045 // <text:date style:data-style-name="N2" text:date-value="YYYY-MM-DD">value</text:date>
3046
3047 Date aDate(Date::SYSTEM);
3048 OUStringBuffer aBuf;
3049 sal_Int32 nVal = aDate.GetYear();
3050 aBuf.append(OUString::number(nVal) + "-");
3051 nVal = aDate.GetMonth();
3052 if (nVal < 10)
3053 aBuf.append('0');
3054 aBuf.append(OUString::number(nVal) + "-");
3055 nVal = aDate.GetDay();
3056 if (nVal < 10)
3057 aBuf.append('0');
3058 aBuf.append(nVal);
3059 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, "N2");
3060 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_DATE_VALUE, aBuf.makeStringAndClear());
3061
3062 OUString aElemName = rExport.GetNamespaceMap().GetQNameByKey(
3063 XML_NAMESPACE_TEXT, GetXMLToken(XML_DATE));
3064 SvXMLElementExport aElem(rExport, aElemName, false, false);
3065 rExport.Characters(aFieldVal);
3066 }
3067 break;
3068 case text::textfield::Type::DOCINFO_TITLE:
3069 {
3070 // <text:title>value</text:title>
3071
3072 OUString aElemName = rExport.GetNamespaceMap().GetQNameByKey(
3073 XML_NAMESPACE_TEXT, GetXMLToken(XML_TITLE));
3074 SvXMLElementExport aElem(rExport, aElemName, false, false);
3075 rExport.Characters(aFieldVal);
3076 }
3077 break;
3079 {
3080 // <text:sheet-name>value</text:sheet-name>
3081
3082 OUString aElemName = rExport.GetNamespaceMap().GetQNameByKey(
3083 XML_NAMESPACE_TEXT, GetXMLToken(XML_SHEET_NAME));
3084 SvXMLElementExport aElem(rExport, aElemName, false, false);
3085 rExport.Characters(aFieldVal);
3086 }
3087 break;
3088 default:
3089 rExport.Characters(aFieldVal);
3090 }
3091 }
3092 else
3093 rExport.Characters(rContent);
3094}
3095
3096void flushParagraph(
3097 ScXMLExport& rExport, std::u16string_view rParaText,
3099 const ScXMLEditAttributeMap& rAttrMap,
3100 std::vector<editeng::Section>::const_iterator it, std::vector<editeng::Section>::const_iterator const & itEnd )
3101{
3102 OUString aElemName = rExport.GetNamespaceMap().GetQNameByKey(
3103 XML_NAMESPACE_TEXT, GetXMLToken(XML_P));
3104 SvXMLElementExport aElemP(rExport, aElemName, false, false);
3105
3106 for (; it != itEnd; ++it)
3107 {
3108 const editeng::Section& rSec = *it;
3109
3110 OUString aContent(rParaText.substr(rSec.mnStart, rSec.mnEnd - rSec.mnStart));
3111
3112 std::vector<XMLPropertyState> aPropStates;
3113 const SvxFieldData* pField = toXMLPropertyStates(rExport, aPropStates, rSec.maAttributes, xMapper, rAttrMap);
3114 OUString aStyleName = xStylePool->Find(XmlStyleFamily::TEXT_TEXT, OUString(), aPropStates);
3115 if (aContent == "\x001" && !pField)
3116 {
3117 for (const SfxPoolItem* p : rSec.maAttributes)
3118 {
3119 if (p->Which() == EE_FEATURE_TAB)
3120 {
3121 SvXMLElementExport Tab(rExport, XML_NAMESPACE_TEXT, XML_TAB, false, false);
3122 break;
3123 }
3124 }
3125 }
3126 else
3127 writeContent(rExport, aStyleName, aContent, pField);
3128 }
3129}
3130
3131}
3132
3133void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
3134{
3135 // nEqualCellCount is the number of additional cells
3136 SetRepeatAttribute(nEqualCellCount, (aCell.nType != table::CellContentType_EMPTY));
3137
3138 if (aCell.nStyleIndex != -1)
3139 AddAttribute(sAttrStyleName, pCellStyles->GetStyleNameByIndex(aCell.nStyleIndex, aCell.bIsAutoStyle));
3140 if (aCell.nValidationIndex > -1)
3142 const bool bIsFirstMatrixCell(aCell.bIsMatrixBase);
3143 if (bIsFirstMatrixCell)
3144 {
3145 SCCOL nColumns( aCell.aMatrixRange.aEnd.Col() - aCell.aMatrixRange.aStart.Col() + 1 );
3146 SCROW nRows( aCell.aMatrixRange.aEnd.Row() - aCell.aMatrixRange.aStart.Row() + 1 );
3149 }
3150 bool bIsEmpty(false);
3151 switch (aCell.nType)
3152 {
3153 case table::CellContentType_EMPTY :
3154 {
3155 bIsEmpty = true;
3156 }
3157 break;
3158 case table::CellContentType_VALUE :
3159 {
3161 aCell.nNumberFormat, aCell.maBaseCell.getDouble());
3164 aCell.nNumberFormat, aCell.maBaseCell.getDouble(), false, XML_NAMESPACE_CALC_EXT, false);
3165 }
3166 break;
3167 case table::CellContentType_TEXT :
3168 {
3169 OUString sFormattedString(lcl_GetFormattedString(pDoc, aCell.maBaseCell, aCell.maCellAddress));
3170 OUString sCellString = aCell.maBaseCell.getString(pDoc);
3171 bool bExportValue = sCellString.indexOf('\x001') == -1;
3173 sCellString, sFormattedString, bExportValue);
3176 sCellString, sFormattedString, false, XML_NAMESPACE_CALC_EXT);
3177 }
3178 break;
3179 case table::CellContentType_FORMULA :
3180 {
3181 if (aCell.maBaseCell.getType() == CELLTYPE_FORMULA)
3182 {
3183 const bool bIsMatrix(bIsFirstMatrixCell || aCell.bIsMatrixCovered);
3184 ScFormulaCell* pFormulaCell = aCell.maBaseCell.getFormula();
3185 if (!bIsMatrix || bIsFirstMatrixCell)
3186 {
3188 {
3190 mpCompileFormulaCxt.reset(new sc::CompileFormulaContext(*pDoc, eGrammar));
3191 }
3192
3193 OUString aFormula = pFormulaCell->GetFormula(*mpCompileFormulaCxt);
3194 sal_uInt16 nNamespacePrefix =
3196
3197 if (!bIsMatrix)
3198 {
3199 AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey(nNamespacePrefix, aFormula, false));
3200 }
3201 else
3202 {
3203 AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey(nNamespacePrefix, aFormula.copy(1, aFormula.getLength()-2), false));
3204 }
3205 }
3206 if (pFormulaCell->GetErrCode() != FormulaError::NONE)
3207 {
3211 {
3212 //export calcext:value-type="error"
3214 }
3215 }
3216 else if (pFormulaCell->IsValue())
3217 {
3218 bool bIsStandard;
3219 OUString sCurrency;
3220 GetNumberFormatAttributesExportHelper()->GetCellType(aCell.nNumberFormat, sCurrency, bIsStandard);
3221 if (pDoc)
3222 {
3224 aCell.nNumberFormat, pDoc->GetValue(aCell.maCellAddress));
3226 {
3228 aCell.nNumberFormat, pDoc->GetValue(aCell.maCellAddress), false, XML_NAMESPACE_CALC_EXT, false );
3229 }
3230 }
3231 }
3232 else
3233 {
3234 if (!aCell.maBaseCell.getString(pDoc).isEmpty())
3235 {
3239 {
3241 }
3242 }
3243 }
3244 }
3245 }
3246 break;
3247 default:
3248 break;
3249 }
3250 OUString* pCellString(&sElemCell);
3251 if (aCell.bIsCovered)
3252 {
3253 pCellString = &sElemCoveredCell;
3254 }
3255 else
3256 {
3257 if (aCell.bIsMergedBase)
3258 {
3259 SCCOL nColumns( aCell.aMergeRange.aEnd.Col() - aCell.aMergeRange.aStart.Col() + 1 );
3260 SCROW nRows( aCell.aMergeRange.aEnd.Row() - aCell.aMergeRange.aStart.Row() + 1 );
3261 AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, OUString::number(nColumns));
3262 AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, OUString::number(nRows));
3263 }
3264 }
3265 SvXMLElementExport aElemC(*this, *pCellString, true, true);
3266 CheckAttrList();
3267 WriteAreaLink(aCell);
3268 WriteAnnotation(aCell);
3269 WriteDetective(aCell);
3270
3271 if (!bIsEmpty)
3272 {
3273 if (aCell.maBaseCell.getType() == CELLTYPE_EDIT)
3274 {
3276 }
3278 {
3280 }
3281 else
3282 {
3283 SvXMLElementExport aElemP(*this, sElemP, true, false);
3284
3285 OUString aParaStr =
3287
3288 bool bPrevCharWasSpace = true;
3289 GetTextParagraphExport()->exportCharacterData(aParaStr, bPrevCharWasSpace);
3290 }
3291 }
3292 WriteShapes(aCell);
3293 if (!bIsEmpty)
3294 IncrementProgressBar(false);
3295}
3296
3298{
3299 rtl::Reference<XMLPropertySetMapper> xMapper = GetTextParagraphExport()->GetTextPropMapper()->getPropertySetMapper();
3301 const ScXMLEditAttributeMap& rAttrMap = GetEditAttributeMap();
3302
3303 // Get raw paragraph texts first.
3304 std::vector<OUString> aParaTexts;
3305 sal_Int32 nParaCount = pText->GetParagraphCount();
3306 aParaTexts.reserve(nParaCount);
3307 for (sal_Int32 i = 0; i < nParaCount; ++i)
3308 aParaTexts.push_back(pText->GetText(i));
3309
3310 // Get all section data and iterate through them.
3311 std::vector<editeng::Section> aAttrs;
3312 pText->GetAllSections(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; // current paragraph
3316 for (; itSec != itSecEnd; ++itSec)
3317 {
3318 const editeng::Section& rSec = *itSec;
3319 if (nCurPara == rSec.mnParagraph)
3320 // Still in the same paragraph.
3321 continue;
3322
3323 // Start of a new paragraph. Flush the old paragraph.
3324 flushParagraph(*this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSec);
3325 nCurPara = rSec.mnParagraph;
3326 itPara = itSec;
3327 }
3328
3329 flushParagraph(*this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSecEnd);
3330}
3331
3333{
3335
3336 OUString aResStr = pCell->GetResultString().getString();
3337 const sal_Unicode* p = aResStr.getStr();
3338 const sal_Unicode* pEnd = p + static_cast<size_t>(aResStr.getLength());
3339 const sal_Unicode* pPara = p; // paragraph head.
3340 for (; p != pEnd; ++p)
3341 {
3342 if (*p != '\n')
3343 continue;
3344
3345 // flush the paragraph.
3346 OUString aContent;
3347 if (*pPara == '\n')
3348 ++pPara;
3349 if (p > pPara)
3350 aContent = OUString(pPara, p-pPara);
3351
3352 SvXMLElementExport aElem(*this, aElemName, false, false);
3353 Characters(aContent);
3354
3355 pPara = p;
3356 }
3357
3358 OUString aContent;
3359 if (*pPara == '\n')
3360 ++pPara;
3361 if (pEnd > pPara)
3362 aContent = OUString(pPara, pEnd-pPara);
3363
3364 SvXMLElementExport aElem(*this, aElemName, false, false);
3365 Characters(aContent);
3366}
3367
3368void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, awt::Point* pPoint)
3369{
3370 uno::Reference < beans::XPropertySet > xShapeProps ( xShape, uno::UNO_QUERY );
3371 bool bIsChart( false );
3372 if (xShapeProps.is())
3373 {
3374 sal_Int32 nZOrder = 0;
3375 if (xShapeProps->getPropertyValue("ZOrder") >>= nZOrder)
3376 {
3377 AddAttribute(XML_NAMESPACE_DRAW, XML_ZINDEX, OUString::number(nZOrder));
3378 }
3379 uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xShapeProps->getPropertySetInfo();
3380 OUString sPropCLSID ("CLSID");
3381 if( xPropSetInfo->hasPropertyByName( sPropCLSID ) )
3382 {
3383 OUString sCLSID;
3384 if (xShapeProps->getPropertyValue( sPropCLSID ) >>= sCLSID)
3385 {
3386 if ( sCLSID.equalsIgnoreAsciiCase(GetChartExport()->getChartCLSID()) )
3387 {
3388 // we have a chart
3389 OUString sRanges;
3390 if ( pDoc )
3391 {
3392 OUString aChartName;
3393 xShapeProps->getPropertyValue( "PersistName" ) >>= aChartName;
3395 if (pCollection)
3396 {
3397 ScChartListener* pListener = pCollection->findByName(aChartName);
3398 if (pListener)
3399 {
3400 const ScRangeListRef& rRangeList = pListener->GetRangeList();
3401 if ( rRangeList.is() )
3402 {
3403 ScRangeStringConverter::GetStringFromRangeList( sRanges, rRangeList.get(), pDoc, FormulaGrammar::CONV_OOO );
3404 if ( !sRanges.isEmpty() )
3405 {
3406 bIsChart = true;
3408 pAttrList->AddAttribute(
3410 GetShapeExport()->exportShape( xShape, SEF_DEFAULT, pPoint, pAttrList.get() );
3411 }
3412 }
3413 }
3414 }
3415 }
3416
3417 if ( sRanges.isEmpty() )
3418 {
3419 uno::Reference< frame::XModel > xChartModel;
3420 if( ( xShapeProps->getPropertyValue( "Model" ) >>= xChartModel ) &&
3421 xChartModel.is())
3422 {
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())
3427 {
3428 // we have a chart that gets its data from Calc
3429 bIsChart = true;
3430 uno::Sequence< OUString > aRepresentations(
3431 xReceiver->getUsedRangeRepresentations());
3433 try
3434 {
3435 if (aRepresentations.hasElements())
3436 {
3437 // add the ranges used by the chart to the shape
3438 // element to be able to start listening after
3439 // load (when the chart is not yet loaded)
3440 uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY );
3441 sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter );
3442 pAttrList = new comphelper::AttributeList();
3443 pAttrList->AddAttribute(
3445 }
3446 }
3447 catch (const lang::IllegalArgumentException&)
3448 {
3449 TOOLS_WARN_EXCEPTION("sc", "Exception in lcl_RangeSequenceToString - invalid range?");
3450 }
3451 GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint, pAttrList.get());
3452 }
3453 }
3454 }
3455 }
3456 }
3457 }
3458 }
3459 if (!bIsChart)
3460 GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint);
3461
3462 IncrementProgressBar(false);
3463}
3464
3466{
3467 if( !(rMyCell.bHasShape && !rMyCell.aShapeList.empty() && pDoc) )
3468 return;
3469
3470 // Reference point to turn absolute coordinates in reference point + offset. That happens in most
3471 // cases in XMLShapeExport::ImpExportNewTrans_DecomposeAndRefPoint, which gets the absolute
3472 // coordinates as translation from matrix in property "Transformation". For cell anchored shapes
3473 // the reference point is left-top (in LTR mode) of that cell, which contains the shape.
3474 tools::Rectangle aCellRectFull = pDoc->GetMMRect(
3475 rMyCell.maCellAddress.Col(), rMyCell.maCellAddress.Row(), rMyCell.maCellAddress.Col(),
3476 rMyCell.maCellAddress.Row(), rMyCell.maCellAddress.Tab(), false /*bHiddenAsZero*/);
3477 awt::Point aPoint;
3478 bool bNegativePage = pDoc->IsNegativePage(rMyCell.maCellAddress.Tab());
3479 if (bNegativePage)
3480 aPoint.X = aCellRectFull.Right();
3481 else
3482 aPoint.X = aCellRectFull.Left();
3483 aPoint.Y = aCellRectFull.Top();
3484
3485 for (const auto& rShape : rMyCell.aShapeList)
3486 {
3487 // Skip the shape if requirements are not met. The tests should not fail, but allow
3488 // shorter conditions in main part below.
3489 if (!rShape.xShape.is())
3490 continue;
3491 SdrObject* pObj = SdrObject::getSdrObjectFromXShape(rShape.xShape);
3492 if (!pObj)
3493 continue;
3494 ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObj);
3495 if (!pObjData)
3496 continue;
3497 ScAddress aSnapStartAddress = pObjData->maStart;
3498 if (!aSnapStartAddress.IsValid())
3499 continue;
3500
3501 // The current object geometry is based on bHiddenAsZero=true, but ODF file format
3502 // needs it as if there were no hidden rows or columns. We determine a fictive snap
3503 // rectangle from the anchor as if all column/rows are shown. Then we move and resize
3504 // (in case of "resize with cell") the object to meet this snap rectangle. We need to
3505 // manipulate the object itself, because the used methods in xmloff do not evaluate the
3506 // ObjData. This manipulation is only done temporarily for export. Thus we stash the geometry
3507 // and restore it when export is done and we use NbcFoo methods.
3508 bool bNeedsRestore = false;
3509 std::unique_ptr<SdrObjGeoData> pGeoData = pObj->GetGeoData();
3510
3511 // Determine top point of fictive snap rectangle ('Full' rectangle).
3512 SCTAB aTab(aSnapStartAddress.Tab());
3513 SCCOL aCol(aSnapStartAddress.Col());
3514 SCROW aRow(aSnapStartAddress.Row());
3515 tools::Rectangle aFullStartCellRect
3516 = pDoc->GetMMRect(aCol, aRow, aCol, aRow, aTab, false /*bHiddenAsZero*/);
3517 // The reference corner for the offset is top-left in case of LTR and top-right for RTL.
3518 Point aFullTopPoint;
3519 if (bNegativePage)
3520 aFullTopPoint.setX(aFullStartCellRect.Right() - pObjData->maStartOffset.X());
3521 else
3522 aFullTopPoint.setX(aFullStartCellRect.Left() + pObjData->maStartOffset.X());
3523 aFullTopPoint.setY(aFullStartCellRect.Top() + pObjData->maStartOffset.Y());
3524
3525 // Compare actual top point and full top point and move object accordingly.
3526 tools::Rectangle aOrigSnapRect(pObj->GetSnapRect());
3527 Point aActualTopPoint = bNegativePage ? aOrigSnapRect.TopRight() : aOrigSnapRect.TopLeft();
3528 if (aFullTopPoint != aActualTopPoint)
3529 {
3530 bNeedsRestore = true;
3531 Point aMoveBy = aFullTopPoint - aActualTopPoint;
3532 pObj->NbcMove(Size(aMoveBy.X(), aMoveBy.Y()));
3533 }
3534
3535 ScAddress aSnapEndAddress = pObjData->maEnd;
3536 // tdf#154005: We treat the combination of "To cell (resize with cell)" with 'size protected'
3537 // as being "To cell".
3538 if (pObjData->mbResizeWithCell && aSnapEndAddress.IsValid() && !pObj->IsResizeProtect())
3539 {
3540 // Object is anchored "To cell (resize with cell)". Compare size of actual snap rectangle
3541 // and fictive full one. Resize object accordingly.
3542 tools::Rectangle aActualSnapRect(pObj->GetSnapRect());
3543 Point aSnapEndOffset(pObjData->maEndOffset);
3544 aCol = aSnapEndAddress.Col();
3545 aRow = aSnapEndAddress.Row();
3546 tools::Rectangle aFullEndCellRect
3547 = pDoc->GetMMRect(aCol, aRow, aCol, aRow, aTab, false /*bHiddenAsZero*/);
3548 Point aFullBottomPoint;
3549 if (bNegativePage)
3550 aFullBottomPoint.setX(aFullEndCellRect.Right() - aSnapEndOffset.X());
3551 else
3552 aFullBottomPoint.setX(aFullEndCellRect.Left() + aSnapEndOffset.X());
3553 aFullBottomPoint.setY(aFullEndCellRect.Top() + aSnapEndOffset.Y());
3554 tools::Rectangle aFullSnapRect(aFullTopPoint, aFullBottomPoint);
3555 aFullSnapRect.Normalize();
3556
3557 if (aFullSnapRect != aActualSnapRect)
3558 {
3559 bNeedsRestore = true;
3560 Fraction aScaleWidth(aFullSnapRect.getOpenWidth(), aActualSnapRect.getOpenWidth());
3561 if (!aScaleWidth.IsValid())
3562 aScaleWidth = Fraction(1, 1);
3563 Fraction aScaleHeight(aFullSnapRect.getOpenHeight(),
3564 aActualSnapRect.getOpenHeight());
3565 if (!aScaleHeight.IsValid())
3566 aScaleHeight = Fraction(1, 1);
3567 pObj->NbcResize(aFullTopPoint, aScaleWidth, aScaleHeight);
3568 }
3569 }
3570
3571 // The existence of an end address is equivalent to anchor mode "To Cell (resize with cell)".
3572 // XML needs end address in regard of untransformed shape. Those are contained in rShape but
3573 // could be received from NonRotatedObjData as well.
3574 // tdf#154005: We treat the combination of "To Cell (resize with cell)" anchor with 'size
3575 // protected' property as being "To cell" anchor.
3576 if (pObjData->mbResizeWithCell && !pObj->IsResizeProtect())
3577 {
3578 OUString sEndAddress;
3579 ScRangeStringConverter::GetStringFromAddress(sEndAddress, rShape.aEndAddress, pDoc,
3580 FormulaGrammar::CONV_OOO);
3582 OUStringBuffer sBuffer;
3583 GetMM100UnitConverter().convertMeasureToXML(sBuffer, rShape.nEndX);
3584 AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear());
3585 GetMM100UnitConverter().convertMeasureToXML(sBuffer, rShape.nEndY);
3586 AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear());
3587 }
3588
3589 // Correct above calculated reference point for these cases:
3590 // a) For a RTL-sheet translate from matrix is not suitable, because the shape
3591 // from xml (which is always LTR) is not mirrored to negative page but shifted.
3592 // b) In case of horizontal mirrored, 'resize with cell' anchored custom shape, translate from
3593 // matrix has wrong values. FixMe: Why is translate wrong?
3594 if (bNegativePage
3595 || (pObj->GetObjIdentifier() == SdrObjKind::CustomShape
3596 && static_cast<SdrObjCustomShape*>(pObj)->IsMirroredX()
3597 && pObjData->mbResizeWithCell))
3598 {
3599 // In these cases we set reference point so that the offset calculation in XML export
3600 // (= matrix translate - reference point) results in maStartOffset.
3602 if (pNRObjData)
3603 {
3604 awt::Point aMatrixTranslate = rShape.xShape->getPosition();
3605 aPoint.X = aMatrixTranslate.X - pNRObjData->maStartOffset.X();
3606 aPoint.Y = aMatrixTranslate.Y - pNRObjData->maStartOffset.Y();
3607 }
3608 }
3609
3610 ExportShape(rShape.xShape, &aPoint);
3611
3612 // Restore object geometry
3613 if (bNeedsRestore && pGeoData)
3614 pObj->SetGeoData(*pGeoData);
3615 }
3616}
3617
3619{
3620 ScMyTableShapes* pTableShapes(pSharedData->GetTableShapes());
3621 if (!pTableShapes || (*pTableShapes)[nCurrentTable].empty())
3622 return;
3623
3624 OSL_ENSURE(pTableShapes->size() > static_cast<size_t>(nCurrentTable), "wrong Table");
3625 SvXMLElementExport aShapesElem(*this, XML_NAMESPACE_TABLE, XML_SHAPES, true, false);
3626 for (const auto& rxShape : (*pTableShapes)[nCurrentTable])
3627 {
3628 if (rxShape.is())
3629 {
3630 if (pDoc->IsNegativePage(static_cast<SCTAB>(nCurrentTable)))
3631 {
3632 // RTL-mirroring refers to snap rectangle, not to logic rectangle, therefore cannot use
3633 // getPosition() and getSize(), but need property "FrameRect" from rxShape or
3634 // GetSnapRect() from associated SdrObject.
3635 uno::Reference<beans::XPropertySet> xShapeProp(rxShape, uno::UNO_QUERY);
3636 awt::Rectangle aFrameRect;
3637 if (xShapeProp.is() && (xShapeProp->getPropertyValue("FrameRect") >>= aFrameRect))
3638 {
3639 // file format uses shape in LTR mode. newLeft = - oldRight = - (oldLeft + width).
3640 // newTranslate = oldTranslate - refPoint, oldTranslate from transformation matrix,
3641 // calculated in XMLShapeExport::exportShape common for all modules.
3642 // oldTranslate.X = oldLeft ==> refPoint.X = 2 * oldLeft + width
3643 awt::Point aRefPoint;
3644 aRefPoint.X = 2 * aFrameRect.X + aFrameRect.Width - 1;
3645 aRefPoint.Y = 0;
3646 ExportShape(rxShape, &aRefPoint);
3647 }
3648 // else should not happen
3649 }
3650 else
3651 ExportShape(rxShape, nullptr);
3652 }
3653 }
3654 (*pTableShapes)[nCurrentTable].clear();
3655}
3656
3658{
3659 if( !rMyCell.bHasAreaLink )
3660 return;
3661
3662 const ScMyAreaLink& rAreaLink = rMyCell.aAreaLink;
3667 if( !rAreaLink.sFilterOptions.isEmpty() )
3669 AddAttribute( XML_NAMESPACE_TABLE, XML_LAST_COLUMN_SPANNED, OUString::number(rAreaLink.GetColCount()) );
3670 AddAttribute( XML_NAMESPACE_TABLE, XML_LAST_ROW_SPANNED, OUString::number(rAreaLink.GetRowCount()) );
3671 if( rAreaLink.nRefreshDelaySeconds )
3672 {
3673 OUStringBuffer sValue;
3675 static_cast<double>(rAreaLink.nRefreshDelaySeconds) / 86400 );
3676 AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sValue.makeStringAndClear() );
3677 }
3679}
3680
3681void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape >& xShape)
3682{
3683 ScPostIt* pNote = pCurrentCell->pNote;
3684
3685 if (!pNote)
3686 return;
3687
3688 // TODO : notes
3689 //is it still useful, as this call back is only called from ScXMLExport::WriteAnnotation
3690 // and should be in sync with pCurrentCell
3692 uno::Reference<drawing::XShape> xCurrentShape( pNoteCaption->getUnoShape(), uno::UNO_QUERY );
3693 if (xCurrentShape.get()!=xShape.get())
3694 return;
3695
3696 const OUString& sAuthor(pNote->GetAuthor());
3697 if (!sAuthor.isEmpty())
3698 {
3699 SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC,
3700 XML_CREATOR, true,
3701 false );
3702 Characters(sAuthor);
3703 }
3704
3705 const OUString& aDate(pNote->GetDate());
3706 if (pDoc)
3707 {
3708 SvNumberFormatter* pNumForm = pDoc->GetFormatTable();
3709 double fDate;
3710 sal_uInt32 nfIndex = pNumForm->GetFormatIndex(NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM);
3711 if (pNumForm->IsNumberFormat(aDate, nfIndex, fDate))
3712 {
3713 OUStringBuffer sBuf;
3714 GetMM100UnitConverter().convertDateTime(sBuf, fDate,true);
3715 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC,
3716 XML_DATE, true,
3717 false );
3718 Characters(sBuf.makeStringAndClear());
3719 }
3720 else
3721 {
3722 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_META,
3723 XML_DATE_STRING, true,
3724 false );
3725 Characters(aDate);
3726 }
3727 }
3728 else
3729 {
3730 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_META,
3731 XML_DATE_STRING, true,
3732 false );
3733 Characters(aDate);
3734 }
3735}
3736
3738{
3739 ScPostIt* pNote = pDoc->GetNote(rMyCell.maCellAddress);
3740 if (!pNote)
3741 return;
3742
3743 if (pNote->IsCaptionShown())
3745
3746 pCurrentCell = &rMyCell;
3747
3748 SdrCaptionObj* pNoteCaption = pNote->GetOrCreateCaption(rMyCell.maCellAddress);
3749 if (pNoteCaption)
3750 {
3751 uno::Reference<drawing::XShape> xShape( pNoteCaption->getUnoShape(), uno::UNO_QUERY );
3752 if (xShape.is())
3753 GetShapeExport()->exportShape(xShape, SEF_DEFAULT|XMLShapeExportFlags::ANNOTATION);
3754 }
3755
3756 pCurrentCell = nullptr;
3757}
3758
3760{
3761 if( !(rMyCell.bHasDetectiveObj || rMyCell.bHasDetectiveOp) )
3762 return;
3763
3764 const ScMyDetectiveObjVec& rObjVec = rMyCell.aDetectiveObjVec;
3765 const ScMyDetectiveOpVec& rOpVec = rMyCell.aDetectiveOpVec;
3766 sal_Int32 nObjCount(rObjVec.size());
3767 sal_Int32 nOpCount(rOpVec.size());
3768 if( !(nObjCount || nOpCount) )
3769 return;
3770
3771 SvXMLElementExport aDetElem( *this, XML_NAMESPACE_TABLE, XML_DETECTIVE, true, true );
3772 OUString sString;
3773 for(const auto& rObj : rObjVec)
3774 {
3775 if (rObj.eObjType != SC_DETOBJ_CIRCLE)
3776 {
3777 if( (rObj.eObjType == SC_DETOBJ_ARROW) || (rObj.eObjType == SC_DETOBJ_TOOTHERTAB))
3778 {
3779 ScRangeStringConverter::GetStringFromRange( sString, rObj.aSourceRange, pDoc, FormulaGrammar::CONV_OOO );
3781 }
3782 sString = ScXMLConverter::GetStringFromDetObjType( rObj.eObjType );
3784 if( rObj.bHasError )
3786 }
3787 else
3789 SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_HIGHLIGHTED_RANGE, true, true );
3790 }
3791 for(const auto& rOp : rOpVec)
3792 {
3793 OUString sOpString = ScXMLConverter::GetStringFromDetOpType( rOp.eOpType );
3795 AddAttribute( XML_NAMESPACE_TABLE, XML_INDEX, OUString::number(rOp.nIndex) );
3796 SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_OPERATION, true, true );
3797 }
3798}
3799
3800void ScXMLExport::SetRepeatAttribute(sal_Int32 nEqualCellCount, bool bIncProgress)
3801{
3802 // nEqualCellCount is additional cells, so the attribute value is nEqualCellCount+1
3803 if (nEqualCellCount > 0)
3804 {
3805 sal_Int32 nTemp(nEqualCellCount + 1);
3806 OUString sOUEqualCellCount(OUString::number(nTemp));
3807 AddAttribute(sAttrColumnsRepeated, sOUEqualCellCount);
3808 if (bIncProgress)
3809 IncrementProgressBar(false, nEqualCellCount);
3810 }
3811}
3812
3814{
3815 return rCell.maBaseCell.getType() == CELLTYPE_EDIT;
3816}
3817
3818bool ScXMLExport::IsCellEqual (const ScMyCell& aCell1, const ScMyCell& aCell2)
3819{
3820 bool bIsEqual = false;
3821 if( !aCell1.bIsMergedBase && !aCell2.bIsMergedBase &&
3822 aCell1.bIsCovered == aCell2.bIsCovered &&
3823 !aCell1.bIsMatrixBase && !aCell2.bIsMatrixBase &&
3824 aCell1.bIsMatrixCovered == aCell2.bIsMatrixCovered &&
3825 aCell1.bHasAnnotation == aCell2.bHasAnnotation &&
3826 !aCell1.bHasShape && !aCell2.bHasShape &&
3827 aCell1.bHasAreaLink == aCell2.bHasAreaLink &&
3828 !aCell1.bHasDetectiveObj && !aCell2.bHasDetectiveObj)
3829 {
3830 if( (aCell1.bHasAreaLink &&
3831 (aCell1.aAreaLink.GetColCount() == 1) &&
3832 (aCell2.aAreaLink.GetColCount() == 1) &&
3833 aCell1.aAreaLink.Compare( aCell2.aAreaLink ) ) ||
3834 !aCell1.bHasAreaLink )
3835 {
3836 if (!aCell1.bHasAnnotation)
3837 {
3838 if ((((aCell1.nStyleIndex == aCell2.nStyleIndex) && (aCell1.bIsAutoStyle == aCell2.bIsAutoStyle)) ||
3839 ((aCell1.nStyleIndex == aCell2.nStyleIndex) && (aCell1.nStyleIndex == -1))) &&
3840 aCell1.nValidationIndex == aCell2.nValidationIndex &&
3841 aCell1.nType == aCell2.nType)
3842 {
3843 switch ( aCell1.nType )
3844 {
3845 case table::CellContentType_EMPTY :
3846 {
3847 bIsEqual = true;
3848 }
3849 break;
3850 case table::CellContentType_VALUE :
3851 {
3852 // #i29101# number format may be different from column default styles,
3853 // but can lead to different value types, so it must also be compared
3854 bIsEqual = (aCell1.nNumberFormat == aCell2.nNumberFormat) &&
3855 (aCell1.maBaseCell.getDouble() == aCell2.maBaseCell.getDouble());
3856 }
3857 break;
3858 case table::CellContentType_TEXT :
3859 {
3860 if (IsEditCell(aCell1) || IsEditCell(aCell2))
3861 bIsEqual = false;
3862 else
3863 {
3864 bIsEqual = (aCell1.maBaseCell.getString(pDoc) == aCell2.maBaseCell.getString(pDoc));
3865 }
3866 }
3867 break;
3868 case table::CellContentType_FORMULA :
3869 {
3870 bIsEqual = false;
3871 }
3872 break;
3873 default :
3874 {
3875 bIsEqual = false;
3876 }
3877 break;
3878 }
3879 }
3880 }
3881 }
3882 }
3883 return bIsEqual;
3884}
3885
3886void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc)
3887{
3888 uno::Reference<beans::XPropertySet> xPropertySet(xSpreadDoc, uno::UNO_QUERY);
3889 if (!xPropertySet.is())
3890 return;
3891
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) ));
3897 bool bUseWildcards (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_WILDCARDSENABLED) ));
3898 if (bUseWildcards && bUseRegularExpressions)
3899 bUseRegularExpressions = false; // mutually exclusive, wildcards take precedence
3900 bool bIsIterationEnabled (::cppu::any2bool( xPropertySet->getPropertyValue(SC_UNO_ITERENABLED) ));
3901 sal_uInt16 nYear2000 (pDoc ? pDoc->GetDocOptions().GetYear2000() : 0);
3902 sal_Int32 nIterationCount(100);
3903 xPropertySet->getPropertyValue( SC_UNO_ITERCOUNT ) >>= nIterationCount;
3904 double fIterationEpsilon = 0;
3905 xPropertySet->getPropertyValue( SC_UNO_ITEREPSILON ) >>= fIterationEpsilon;
3906 util::Date aNullDate;
3907 xPropertySet->getPropertyValue( SC_UNO_NULLDATE ) >>= aNullDate;
3908 if (!(bCalcAsShown || bIgnoreCase || !bLookUpLabels || !bMatchWholeCell || !bUseRegularExpressions ||
3909 bUseWildcards ||
3910 bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001) ||
3911 aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 || nYear2000 != 1930))
3912 return;
3913
3914 if (bIgnoreCase)
3916 if (bCalcAsShown)
3918 if (!bMatchWholeCell)
3920 if (!bLookUpLabels)
3922 if (!bUseRegularExpressions)
3924 if (bUseWildcards)
3926 if (nYear2000 != 1930)
3927 {
3928 AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, OUString::number(nYear2000));
3929 }
3930 SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, true, true);
3931 {
3932 if (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899)
3933 {
3934 OUStringBuffer sDate;
3935 SvXMLUnitConverter::convertDateTime(sDate, 0.0, aNullDate);
3936 AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_VALUE, sDate.makeStringAndClear());
3937 SvXMLElementExport aElemNullDate(*this, XML_NAMESPACE_TABLE, XML_NULL_DATE, true, true);
3938 }
3939 if (bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001))
3940 {
3941 if (bIsIterationEnabled)
3943 if (nIterationCount != 100)
3944 {
3945 AddAttribute(XML_NAMESPACE_TABLE, XML_STEPS, OUString::number(nIterationCount));
3946 }
3947 if (!::rtl::math::approxEqual(fIterationEpsilon, 0.001))
3948 {
3949 OUStringBuffer sBuffer;
3951 fIterationEpsilon);
3952 AddAttribute(XML_NAMESPACE_TABLE, XML_MAXIMUM_DIFFERENCE, sBuffer.makeStringAndClear());
3953 }
3954 SvXMLElementExport aElemIteration(*this, XML_NAMESPACE_TABLE, XML_ITERATION, true, true);
3955 }
3956 }
3957}
3958
3960{
3961 uno::Reference <sheet::XSheetLinkable> xLinkable (xCurrentTable, uno::UNO_QUERY);
3962 if (!(xLinkable.is() && GetModel().is()))
3963 return;
3964
3965 sheet::SheetLinkMode nMode (xLinkable->getLinkMode());
3966 if (nMode == sheet::SheetLinkMode_NONE)
3967 return;
3968
3969 OUString sLink (xLinkable->getLinkUrl());
3970 uno::Reference <beans::XPropertySet> xProps (GetModel(), uno::UNO_QUERY);
3971 if (!xProps.is())
3972 return;
3973
3974 uno::Reference <container::XIndexAccess> xIndex(xProps->getPropertyValue(SC_UNO_SHEETLINKS), uno::UNO_QUERY);
3975 if (!xIndex.is())
3976 return;
3977
3978 sal_Int32 nCount(xIndex->getCount());
3979 if (!nCount)
3980 return;
3981
3982 bool bFound(false);
3983 uno::Reference <beans::XPropertySet> xLinkProps;
3984 for (sal_Int32 i = 0; (i < nCount) && !bFound; ++i)
3985 {
3986 xLinkProps.set(xIndex->getByIndex(i), uno::UNO_QUERY);
3987 if (xLinkProps.is())
3988 {
3989 OUString sNewLink;
3990 if (xLinkProps->getPropertyValue(SC_UNONAME_LINKURL) >>= sNewLink)
3991 bFound = sLink == sNewLink;
3992 }
3993 }
3994 if (!(bFound && xLinkProps.is()))
3995 return;
3996
3997 OUString sFilter;
3998 OUString sFilterOptions;
3999 OUString sTableName (xLinkable->getLinkSheetName());
4000 sal_Int32 nRefresh(0);
4001 xLinkProps->getPropertyValue(SC_UNONAME_FILTER) >>= sFilter;
4002 xLinkProps->getPropertyValue(SC_UNONAME_FILTOPT) >>= sFilterOptions;
4003 xLinkProps->getPropertyValue(SC_UNONAME_REFDELAY) >>= nRefresh;
4004 if (sLink.isEmpty())
4005 return;
4006
4009 if (!sTableName.isEmpty())
4011 if (!sFilter.isEmpty())
4013 if (!sFilterOptions.isEmpty())
4015 if (nMode != sheet::SheetLinkMode_NORMAL)
4017 if( nRefresh )
4018 {
4019 OUStringBuffer sBuffer;
4021 static_cast<double>(nRefresh) / 86400 );
4022 AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sBuffer.makeStringAndClear() );
4023 }
4024 SvXMLElementExport aSourceElem(*this, XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, true, true);
4025}
4026
4027// core implementation
4029{
4030 if (!(pDoc && pDoc->IsScenario(static_cast<SCTAB>(nCurrentTable))))
4031 return;
4032
4033 OUString sComment;
4034 Color aColor;
4035 ScScenarioFlags nFlags;
4036 pDoc->GetScenarioData(static_cast<SCTAB>(nCurrentTable), sComment, aColor, nFlags);
4037 if (!(nFlags & ScScenarioFlags::ShowFrame))
4039 OUStringBuffer aBuffer;
4042 if (!(nFlags & ScScenarioFlags::TwoWay))
4044 if (!(nFlags & ScScenarioFlags::Attrib))
4046 if (nFlags & ScScenarioFlags::Value)
4048 if (nFlags & ScScenarioFlags::Protected)
4051 pDoc->IsActiveScenario(static_cast<SCTAB>(nCurrentTable)));
4052 AddAttribute(XML_NAMESPACE_TABLE, XML_IS_ACTIVE, aBuffer.makeStringAndClear());
4053 const ScRangeList* pRangeList = pDoc->GetScenarioRanges(static_cast<SCTAB>(nCurrentTable));
4054 OUString sRangeListStr;
4055 ScRangeStringConverter::GetStringFromRangeList( sRangeListStr, pRangeList, pDoc, FormulaGrammar::CONV_OOO );
4057 if (!sComment.isEmpty())
4059 SvXMLElementExport aElem(*this, XML_NAMESPACE_TABLE, XML_SCENARIO, true, true);
4060}
4061
4062void ScXMLExport::WriteTheLabelRanges( const uno::Reference< sheet::XSpreadsheetDocument >& xSpreadDoc )
4063{
4064 uno::Reference< beans::XPropertySet > xDocProp( xSpreadDoc, uno::UNO_QUERY );
4065 if( !xDocProp.is() ) return;
4066
4067 sal_Int32 nCount(0);
4068 uno::Reference< container::XIndexAccess > xColRangesIAccess(xDocProp->getPropertyValue( SC_UNO_COLLABELRNG ), uno::UNO_QUERY);
4069 if( xColRangesIAccess.is() )
4070 nCount += xColRangesIAccess->getCount();
4071
4072 uno::Reference< container::XIndexAccess > xRowRangesIAccess(xDocProp->getPropertyValue( SC_UNO_ROWLABELRNG ), uno::UNO_QUERY);
4073 if( xRowRangesIAccess.is() )
4074 nCount += xRowRangesIAccess->getCount();
4075
4076 if( nCount )
4077 {
4078 SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGES, true, true );
4079 WriteLabelRanges( xColRangesIAccess, true );
4080 WriteLabelRanges( xRowRangesIAccess, false );
4081 }
4082}
4083
4084void ScXMLExport::WriteLabelRanges( const uno::Reference< container::XIndexAccess >& xRangesIAccess, bool bColumn )
4085{
4086 if( !xRangesIAccess.is() ) return;
4087
4088 sal_Int32 nCount(xRangesIAccess->getCount());
4089 for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
4090 {
4091 uno::Reference< sheet::XLabelRange > xRange(xRangesIAccess->getByIndex( nIndex ), uno::UNO_QUERY);
4092 if( xRange.is() )
4093 {
4094 OUString sRangeStr;
4095 table::CellRangeAddress aCellRange( xRange->getLabelArea() );
4096 ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, pDoc, FormulaGrammar::CONV_OOO );
4098 aCellRange = xRange->getDataArea();
4099 ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, pDoc, FormulaGrammar::CONV_OOO );
4102 SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGE, true, true );
4103 }
4104 }
4105}
4106
4108{
4109 if (!pDoc)
4110 return;
4111 ScRangeName* pNamedRanges = pDoc->GetRangeName();
4112 WriteNamedRange(pNamedRanges);
4113}
4114
4116{
4117 if (!pDoc)
4118 return;
4119
4121 // Export this only for 1.2 extended and above.
4122 return;
4123
4125 auto& rDataSources = rDataMapper.getDataSources();
4126
4127 if (rDataSources.empty())
4128 return;
4129
4130 SvXMLElementExport aMappings(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_MAPPINGS, true, true);
4131 for (const auto& itr : rDataSources)
4132 {
4138
4139 SvXMLElementExport aMapping(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_MAPPING, true, true);
4140 // Add the data transformations
4141 WriteExternalDataTransformations(itr.getDataTransformation());
4142 }
4143}
4144
4145void ScXMLExport::WriteExternalDataTransformations(const std::vector<std::shared_ptr<sc::DataTransformation>>& aDataTransformations)
4146{
4147 SvXMLElementExport aTransformations(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_TRANSFORMATIONS, true, true);
4148 for (auto& itr : aDataTransformations)
4149 {
4150 sc::TransformationType aTransformationType = itr->getTransformationType();
4151
4152 switch(aTransformationType)
4153 {
4155 {
4156 // Delete Columns Transformation
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)
4161 {
4162 // Add Columns
4164 SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true);
4165 }
4166 }
4167 break;
4169 {
4170 std::shared_ptr<sc::SplitColumnTransformation> aSplitTransformation = std::dynamic_pointer_cast<sc::SplitColumnTransformation>(itr);
4171
4172 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLUMN, OUString::number(aSplitTransformation->getColumn()));
4173 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_SEPARATOR, OUString::number(aSplitTransformation->getSeparator()));
4175 }
4176 break;
4178 {
4179 // Merge Transformation
4180 std::shared_ptr<sc::MergeColumnTransformation> aMergeTransformation = std::dynamic_pointer_cast<sc::MergeColumnTransformation>(itr);
4181 std::set<SCCOL> aColumns = aMergeTransformation->getColumns();
4182
4183 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_MERGE_STRING, aMergeTransformation->getMergeString());
4185
4186 for(auto& col : aColumns)
4187 {
4188 // Columns
4190 SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true);
4191 }
4192 }
4193 break;
4195 {
4196 // Sort Transformation
4197 std::shared_ptr<sc::SortTransformation> aSortTransformation = std::dynamic_pointer_cast<sc::SortTransformation>(itr);
4198 ScSortParam aSortParam = aSortTransformation->getSortParam();
4200 const sc::DataStream* pStrm = rMgr.getDataStream();
4201 if (!pStrm)
4202 // No data stream.
4203 return;
4204
4205 // Streamed range
4206 ScRange aRange = pStrm->GetRange();
4207
4209
4210 writeSort(*this, aSortParam, aRange, pDoc);
4211 }
4212 break;
4214 {
4215 // Text Transformation
4216 std::shared_ptr<sc::TextTransformation> aTextTransformation = std::dynamic_pointer_cast<sc::TextTransformation>(itr);
4217
4218 sc::TEXT_TRANSFORM_TYPE aTextTransformType = aTextTransformation->getTextTransformationType();
4219
4220 switch ( aTextTransformType )
4221 {
4224 break;
4227 break;
4230 break;
4233 break;
4234 }
4235
4236 std::set<SCCOL> aColumns = aTextTransformation->getColumns();
4237
4239
4240 for(auto& col : aColumns)
4241 {
4242 // Columns
4244 SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true);
4245 }
4246 }
4247 break;
4249 {
4250 // Aggregate Transformation
4251 std::shared_ptr<sc::AggregateFunction> aAggregateFunction = std::dynamic_pointer_cast<sc::AggregateFunction>(itr);
4252 std::set<SCCOL> aColumns = aAggregateFunction->getColumns();
4253
4254 sc::AGGREGATE_FUNCTION aAggregateType = aAggregateFunction->getAggregateType();
4255
4256 switch (aAggregateType)
4257 {
4260 break;
4263 break;
4266 break;
4269 break;
4270 }
4271
4273
4274 for(auto& col : aColumns)
4275 {
4276 // Columns
4278 SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true);
4279 }
4280 }
4281 break;
4283 {
4284 // Number Transformation
4285 std::shared_ptr<sc::NumberTransformation> aNumberTransformation = std::dynamic_pointer_cast<sc::NumberTransformation>(itr);
4286
4287 sc::NUMBER_TRANSFORM_TYPE aNumberTransformType = aNumberTransformation->getNumberTransformationType();
4288
4289 switch ( aNumberTransformType )
4290 {
4293 break;
4296 break;
4299 break;
4302 break;
4305 break;
4308 break;
4311 break;
4314 break;
4317 break;
4320 break;
4323 break;
4326 break;
4329 break;
4330 }
4331
4332 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_PRECISION, OUString::number(aNumberTransformation->getPrecision()));
4334
4335 std::set<SCCOL> aColumns = aNumberTransformation->getColumn();
4336 for(auto& col : aColumns)
4337 {
4338 // Columns
4340 SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true);
4341 }
4342 }
4343 break;
4345 {
4346 // Replace Null Transformation
4347 std::shared_ptr<sc::ReplaceNullTransformation> aReplaceNullTransformation = std::dynamic_pointer_cast<sc::ReplaceNullTransformation>(itr);
4348 std::set<SCCOL> aColumns = aReplaceNullTransformation->getColumn();
4349
4350 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_REPLACE_STRING, aReplaceNullTransformation->getReplaceString());
4352
4353 for(auto& col : aColumns)
4354 {
4355 // Columns
4357 SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true);
4358 }
4359 }
4360 break;
4362 {
4363 // Number Transformation
4364 std::shared_ptr<sc::DateTimeTransformation> aDateTimeTransformation = std::dynamic_pointer_cast<sc::DateTimeTransformation>(itr);
4365
4366 sc::DATETIME_TRANSFORMATION_TYPE aDateTimeTransformationType = aDateTimeTransformation->getDateTimeTransformationType();
4367
4368 switch ( aDateTimeTransformationType )
4369 {
4372 break;
4375 break;
4378 break;
4381 break;
4384 break;
4387 break;
4390 break;
4393 break;
4396 break;
4399 break;
4402 break;
4405 break;
4408 break;
4411 break;
4414 break;
4417 break;
4420 break;
4423 break;
4424 }
4425
4427
4428 std::set<SCCOL> aColumns = aDateTimeTransformation->getColumn();
4429 for(auto& col : aColumns)
4430 {
4431 // Columns
4433 SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, XML_COLUMN, true, true);
4434 }
4435 }
4436 break;
4437 default:
4438 break;
4439 }
4440 }
4441}
4442
4444{
4445 if (!pDoc)
4446 return;
4447
4448 if (!officecfg::Office::Common::Misc::ExperimentalMode::get())
4449 // Export this only in experimental mode.
4450 return;
4451
4453 // Export this only for 1.2 extended and above.
4454 return;
4455
4457 const sc::DataStream* pStrm = rMgr.getDataStream();
4458 if (!pStrm)
4459 // No data stream.
4460 return;
4461
4462 // Source URL
4464
4465 // Streamed range
4466 ScRange aRange = pStrm->GetRange();
4467 OUString aRangeStr;
4469 aRangeStr, aRange, pDoc, formula::FormulaGrammar::CONV_OOO);
4471
4472 // Empty line refresh option.
4474
4475 // New data insertion position. Either top of bottom. Default to bottom.
4476 xmloff::token::XMLTokenEnum eInsertPosition = XML_BOTTOM;
4477 if (pStrm->GetMove() == sc::DataStream::MOVE_DOWN)
4478 eInsertPosition = XML_TOP;
4479
4481
4483}
4484
4486{
4487 //write a global or local ScRangeName
4488 SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, true, true);
4489 for (const auto& rxEntry : *pRangeName)
4490 {
4491 AddAttribute(sAttrName, rxEntry.second->GetName());
4492
4493 OUString sBaseCellAddress;
4494 rxEntry.second->ValidateTabRefs();
4495 ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, rxEntry.second->GetPos(), pDoc,
4496 FormulaGrammar::CONV_OOO, ' ', false, ScRefFlags::ADDR_ABS_3D);
4497 assert(!sBaseCellAddress.isEmpty());
4499
4500 OUString sSymbol = rxEntry.second->GetSymbol(pDoc->GetStorageGrammar());
4501 OUString sTempSymbol(sSymbol);
4502 ScRange aRange;
4503 if (rxEntry.second->IsReference(aRange))
4504 {
4505
4506 OUString sContent(sTempSymbol.copy(1, sTempSymbol.getLength() -2 ));
4508
4509 sal_Int32 nRangeType = rxEntry.second->GetUnoType();
4510 OUStringBuffer sBufferRangeType;
4512 sBufferRangeType.append(GetXMLToken(XML_REPEAT_COLUMN));
4514 {
4515 if (!sBufferRangeType.isEmpty())
4516 sBufferRangeType.append(" ");
4517 sBufferRangeType.append(GetXMLToken(XML_REPEAT_ROW));
4518 }
4519 if ((nRangeType & sheet::NamedRangeFlag::FILTER_CRITERIA) == sheet::NamedRangeFlag::FILTER_CRITERIA)
4520 {
4521 if (!sBufferRangeType.isEmpty())
4522 sBufferRangeType.append(" ");
4523 sBufferRangeType.append(GetXMLToken(XML_FILTER));
4524 }
4525 if ((nRangeType & sheet::NamedRangeFlag::PRINT_AREA) == sheet::NamedRangeFlag::PRINT_AREA)
4526 {
4527 if (!sBufferRangeType.isEmpty())
4528 sBufferRangeType.append(" ");
4529 sBufferRangeType.append(GetXMLToken(XML_PRINT_RANGE));
4530 }
4531 OUString sRangeType = sBufferRangeType.makeStringAndClear();
4532 if (!sRangeType.isEmpty())
4534 SvXMLElementExport aElemNR(*this, XML_NAMESPACE_TABLE, XML_NAMED_RANGE, true, true);
4535
4536 }
4537 else
4538 {
4540 SvXMLElementExport aElemNE(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, true, true);
4541 }
4542 }
4543}
4544
4546{
4547 sc::SparklineGroupsExport aSparklineGroupExport(*this, nTable);
4548 aSparklineGroupExport.write();
4549}
4550
4551namespace {
4552
4553OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry, bool bFirst = true)
4554{
4555 switch(rEntry.GetType())
4556 {
4557 case COLORSCALE_MIN:
4558 return "minimum";
4559 case COLORSCALE_MAX:
4560 return "maximum";
4561 case COLORSCALE_PERCENT:
4562 return "percent";
4564 return "percentile";
4565 case COLORSCALE_FORMULA:
4566 return "formula";
4567 case COLORSCALE_VALUE:
4568 return "number";
4569 case COLORSCALE_AUTO:
4570 // only important for data bars
4571 if(bFirst)
4572 return "auto-minimum";
4573 else
4574 return "auto-maximum";
4575 }
4576 return OUString();
4577}
4578
4579OUString getDateStringForType(condformat::ScCondFormatDateType eType)
4580{
4581 switch(eType)
4582 {
4583 case condformat::TODAY:
4584 return "today";
4586 return "yesterday";
4588 return "tomorrow";
4590 return "last-7-days";
4592 return "this-week";
4594 return "last-week";
4596 return "next-week";
4598 return "this-month";
4600 return "last-month";
4602 return "next-month";
4604 return "this-year";
4606 return "last-year";
4608 return "next-year";
4609 }
4610
4611 return OUString();
4612}
4613
4614}
4615
4617{
4618 ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(nTab);
4619 if(!pCondFormatList)
4620 return;
4621
4622 if (pCondFormatList->empty())
4623 return;
4624
4625 SvXMLElementExport aElementCondFormats(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMATS, true, true);
4626
4627 for(const auto& rxCondFormat : *pCondFormatList)
4628 {
4629 OUString sRanges;
4630 const ScRangeList& rRangeList = rxCondFormat->GetRange();
4633 SvXMLElementExport aElementCondFormat(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMAT, true, true);
4634 size_t nEntries = rxCondFormat->size();
4635 for(size_t i = 0; i < nEntries; ++i)
4636 {
4637 const ScFormatEntry* pFormatEntry = rxCondFormat->GetEntry(i);
4638 if(pFormatEntry->GetType()==ScFormatEntry::Type::Condition)
4639 {
4640 const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry);
4641 OUStringBuffer aCond;
4642 ScAddress aPos = pEntry->GetSrcPos();
4643 switch(pEntry->GetOperation())
4644 {
4646 aCond.append("=" + pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
4647 break;
4649 aCond.append("<" + pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
4650 break;
4652 aCond.append(">" + pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
4653 break;
4655 aCond.append("<=" + pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
4656 break;
4658 aCond.append(">=" + pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
4659 break;
4661 aCond.append("!=" + pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
4662 break;
4664 aCond.append("between("
4666 + ","
4668 + ")");
4669 break;
4671 aCond.append("not-between("
4673 + ","
4675 + ")");
4676 break;
4678 aCond.append("duplicate");
4679 break;
4681 aCond.append("unique");
4682 break;
4684 aCond.append("formula-is("
4686 + ")");
4687 break;
4689 aCond.append("top-elements("
4691 + ")");
4692 break;
4694 aCond.append("bottom-elements("
4696 + ")");
4697 break;
4699 aCond.append("top-percent("
4701 + ")");
4702 break;
4704 aCond.append("bottom-percent("
4706 + ")");
4707 break;
4709 aCond.append("above-average");
4710 break;
4712 aCond.append("below-average");
4713 break;
4715 aCond.append("above-equal-average");
4716 break;
4718 aCond.append("below-equal-average");
4719 break;
4721 aCond.append("is-error");
4722 break;
4724 aCond.append("is-no-error");
4725 break;
4727 aCond.append("begins-with("
4729 + ")");
4730 break;
4732 aCond.append("ends-with("
4734 + ")");
4735 break;
4737 aCond.append("contains-text("
4739 + ")");
4740 break;
4742 aCond.append("not-contains-text("
4744 + ")");
4745 break;
4747 continue;
4748 default:
4749 SAL_WARN("sc", "unimplemented conditional format export");
4750 }
4751 OUString sStyle = ScStyleNameConversion::DisplayToProgrammaticName(pEntry->GetStyle(), SfxStyleFamily::Para);
4753 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, aCond.makeStringAndClear());
4754
4755 OUString sBaseAddress;
4758 SvXMLElementExport aElementCondEntry(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITION, true, true);
4759 }
4760 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Colorscale)
4761 {
4762 SvXMLElementExport aElementColorScale(*this, XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE, true, true);
4763 const ScColorScaleFormat& rColorScale = static_cast<const ScColorScaleFormat&>(*pFormatEntry);
4764 for(const auto& rxItem : rColorScale)
4765 {
4766 if(rxItem->GetType() == COLORSCALE_FORMULA)
4767 {
4768 OUString sFormula = rxItem->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
4770 }
4771 else
4772 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, OUString::number(rxItem->GetValue()));
4773
4774 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*rxItem));
4775 OUStringBuffer aBuffer;
4776 ::sax::Converter::convertColor(aBuffer, rxItem->GetColor());
4777 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLOR, aBuffer.makeStringAndClear());
4778 SvXMLElementExport aElementColorScaleEntry(*this, XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE_ENTRY, true, true);
4779 }
4780 }
4781 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Databar)
4782 {
4783 const ScDataBarFormatData* pFormatData = static_cast<const ScDataBarFormat&>(*pFormatEntry).GetDataBarData();
4784 if(!pFormatData->mbGradient)
4786 if(pFormatData->mbOnlyBar)
4788
4789 if (pFormatData->mnMinLength != 0.0)
4790 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_MIN_LENGTH, OUString::number(pFormatData->mnMinLength));
4791
4792 if (pFormatData->mnMaxLength != 0.0)
4793 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_MAX_LENGTH, OUString::number(pFormatData->mnMaxLength));
4794
4795 if(pFormatData->mbNeg)
4796 {
4797 if(pFormatData->mxNegativeColor)
4798 {
4799 OUStringBuffer aBuffer;
4802 }
4803 else
4804 {
4805 OUStringBuffer aBuffer;
4808 }
4809 }
4810
4811 if(pFormatData->meAxisPosition != databar::AUTOMATIC)
4812 {
4813 if(pFormatData->meAxisPosition == databar::NONE)
4814 {
4816 }
4817 else
4818 {
4820 }
4821 }
4822
4823 OUStringBuffer aBuffer;
4826
4827 aBuffer.truncate();
4830 SvXMLElementExport aElementDataBar(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, true, true);
4831
4832 {
4833 if(pFormatData->mpLowerLimit->GetType() == COLORSCALE_FORMULA)
4834 {
4835 OUString sFormula = pFormatData->mpLowerLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
4837 }
4838 else
4839 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, OUString::number(pFormatData->mpLowerLimit->GetValue()));
4840 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpLowerLimit));
4841 SvXMLElementExport aElementDataBarEntryLower(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
4842 }
4843
4844 {
4845 if(pFormatData->mpUpperLimit->GetType() == COLORSCALE_FORMULA)
4846 {
4847 OUString sFormula = pFormatData->mpUpperLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
4849 }
4850 else
4851 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, OUString::number(pFormatData->mpUpperLimit->GetValue()));
4852 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpUpperLimit, false));
4853 SvXMLElementExport aElementDataBarEntryUpper(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
4854 }
4855 }
4856 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Iconset)
4857 {
4858 const ScIconSetFormat& rIconSet = static_cast<const ScIconSetFormat&>(*pFormatEntry);
4859 OUString aIconSetName = OUString::createFromAscii(ScIconSetFormat::getIconSetName(rIconSet.GetIconSetData()->eIconSetType));
4861 if (rIconSet.GetIconSetData()->mbCustom)
4862 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM, OUString::boolean(true));
4863
4864 SvXMLElementExport aElementColorScale(*this, XML_NAMESPACE_CALC_EXT, XML_ICON_SET, true, true);
4865
4866 if (rIconSet.GetIconSetData()->mbCustom)
4867 {
4868 for (const auto& [rType, rIndex] : rIconSet.GetIconSetData()->maCustomVector)
4869 {
4872 SvXMLElementExport aCustomIcon(*this, XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET, true, true);
4873 }
4874
4875 }
4876
4877 if(!rIconSet.GetIconSetData()->mbShowValue)
4879 for (auto const& it : rIconSet)
4880 {
4881 if(it->GetType() == COLORSCALE_FORMULA)
4882 {
4883 OUString sFormula = it->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
4885 }
4886 else
4887 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, OUString::number(it->GetValue()));
4888
4889 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*it));
4890 SvXMLElementExport aElementColorScaleEntry(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
4891 }
4892 }
4893 else if(pFormatEntry->GetType() == ScFormatEntry::Type::Date)
4894 {
4895 const ScCondDateFormatEntry& rDateFormat = static_cast<const ScCondDateFormatEntry&>(*pFormatEntry);
4896 OUString aDateType = getDateStringForType(rDateFormat.GetDateType());
4897 OUString aStyleName = ScStyleNameConversion::DisplayToProgrammaticName(rDateFormat.GetStyleName(), SfxStyleFamily::Para );
4900 SvXMLElementExport aElementDateFormat(*this, XML_NAMESPACE_CALC_EXT, XML_DATE_IS, true, true);
4901 }
4902 }
4903 }
4904}
4905
4907{
4908 if (!pDoc)
4909 return;
4910
4913 sal_uInt16 nCount = pRefMgr->getExternalFileCount();
4914 for (sal_uInt16 nFileId = 0; nFileId < nCount; ++nFileId)
4915 {
4916 const OUString* pUrl = pRefMgr->getExternalFileName(nFileId);
4917 if (!pUrl)
4918 continue;
4919
4920 vector<OUString> aTabNames;
4921 pRefMgr->getAllCachedTableNames(nFileId, aTabNames);
4922 if (aTabNames.empty())
4923 continue;
4924
4925 for (const auto& rTabName : aTabNames)
4926 {
4927 ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, rTabName, false);
4928 if (!pTable || !pTable->isReferenced())
4929 continue;
4930
4931 AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, "'" + *pUrl + "'#" + rTabName);
4934 SvXMLElementExport aElemTable(*this, XML_NAMESPACE_TABLE, XML_TABLE, true, true);
4935 {
4936 const ScExternalRefManager::SrcFileData* pExtFileData = pRefMgr->getExternalFileData(nFileId);
4937 if (pExtFileData)
4938 {
4939 OUString aRelUrl;
4940 if (!pExtFileData->maRelativeName.isEmpty())
4941 aRelUrl = pExtFileData->maRelativeName;
4942 else
4943 aRelUrl = GetRelativeReference(pExtFileData->maRelativeName);
4947 if (!pExtFileData->maFilterName.isEmpty())
4949 if (!pExtFileData->maFilterOptions.isEmpty())
4952 }
4953 SvXMLElementExport aElemTableSource(*this, XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, true, true);
4954 }
4955
4956 // Determine maximum column count of used area, for repeated cells.
4957 SCCOL nMaxColsUsed = 1; // assume that there is at least one cell somewhere...
4958 vector<SCROW> aRows;
4959 pTable->getAllRows(aRows);
4960 for (SCROW nRow : aRows)
4961 {
4962 vector<SCCOL> aCols;
4963 pTable->getAllCols(nRow, aCols);
4964 if (!aCols.empty())
4965 {
4966 SCCOL nCol = aCols.back();
4967 if (nMaxColsUsed <= nCol)
4968 nMaxColsUsed = nCol + 1;
4969 }
4970 }
4971
4972 // Column definitions have to be present to make a valid file
4973 {
4974 if (nMaxColsUsed > 1)
4976 OUString::number(nMaxColsUsed));
4977 SvXMLElementExport aElemColumn(*this, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, true, true);
4978 }
4979
4980 // Write cache content for this table.
4981 SCROW nLastRow = 0;
4982 bool bFirstRow = true;
4983 for (SCROW nRow : aRows)
4984 {
4985 if (bFirstRow)
4986 {
4987 if (nRow > 0)
4988 {
4989 if (nRow > 1)
4990 {
4991 OUString aVal = OUString::number(nRow);
4993 }
4994 SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
4995 OUString aVal = OUString::number(static_cast<sal_Int32>(nMaxColsUsed));
4997 SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
4998 }
4999 }
5000 else
5001 {
5002 SCROW nRowGap = nRow - nLastRow;
5003 if (nRowGap > 1)
5004 {
5005 if (nRowGap > 2)
5006 {
5007 OUString aVal = OUString::number(static_cast<sal_Int32>(nRowGap-1));
5009 }
5010 SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
5011 OUString aVal = OUString::number(static_cast<sal_Int32>(nMaxColsUsed));
5013 SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
5014 }
5015 }
5016 SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
5017
5018 vector<SCCOL> aCols;
5019 pTable->getAllCols(nRow, aCols);
5020 SCCOL nLastCol = 0;
5021 bool bFirstCol = true;
5022 for (SCCOL nCol : aCols)
5023 {
5024 if (bFirstCol)
5025 {
5026 if (nCol > 0)
5027 {
5028 if (nCol > 1)
5029 {
5030 OUString aVal = OUString::number(static_cast<sal_Int32>(nCol));
5032 }
5033 SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
5034 }
5035 }
5036 else
5037 {
5038 SCCOL nColGap = nCol - nLastCol;
5039 if (nColGap > 1)
5040 {
5041 if (nColGap > 2)
5042 {
5043 OUString aVal = OUString::number(static_cast<sal_Int32>(nColGap-1));
5045 }
5046 SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
5047 }
5048 }
5049
5050 // Write out this cell.
5051 sal_uInt32 nNumFmt = 0;
5052 ScExternalRefCache::TokenRef pToken = pTable->getCell(nCol, nRow, &nNumFmt);
5053 OUString aStrVal;
5054 if (pToken)
5055 {
5056 sal_Int32 nIndex = GetNumberFormatStyleIndex(nNumFmt);
5057 if (nIndex >= 0)
5058 {
5059 const OUString & aStyleName = pCellStyles->GetStyleNameByIndex(nIndex, true);
5061 }
5062
5063 switch(pToken->GetType())
5064 {
5065 case svDouble:
5066 {
5068 aStrVal = OUString::number(pToken->GetDouble());
5070 }
5071 break;
5072 case svString:
5073 {
5075 aStrVal = pToken->GetString().getString();
5076 }
5077 break;
5078 default:
5079 ;
5080 }
5081 }
5082 SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
5083 SvXMLElementExport aElemText(*this, XML_NAMESPACE_TEXT, XML_P, true, false);
5084 Characters(aStrVal);
5085
5086 nLastCol = nCol;
5087 bFirstCol = false;
5088 }
5089 nLastRow = nRow;
5090 bFirstRow = false;
5091 }
5092 }
5093 }
5094}
5095
5096// core implementation
5098{
5099 if (!pDoc)
5100 return;
5101
5103 if( !pCons )
5104 return;
5105
5106 OUString sStrData = ScXMLConverter::GetStringFromFunction( pCons->eFunction );
5108
5109 sStrData.clear();
5110 for( sal_Int32 nIndex = 0; nIndex < pCons->nDataAreaCount; ++nIndex )
5111 ScRangeStringConverter::GetStringFromArea( sStrData, pCons->pDataAreas[ nIndex ], pDoc, FormulaGrammar::CONV_OOO, ' ', true );
5113
5114 ScRangeStringConverter::GetStringFromAddress( sStrData, ScAddress( pCons->nCol, pCons->nRow, pCons->nTab ), pDoc, FormulaGrammar::CONV_OOO );
5116
5117 if( pCons->bByCol && !pCons->bByRow )
5119 else if( !pCons->bByCol && pCons->bByRow )
5121 else if( pCons->bByCol && pCons->bByRow )
5123
5124 if( pCons->bReferenceData )
5126
5127 SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_CONSOLIDATION, true, true );
5128}
5129
5131{
5132 return new ScXMLAutoStylePoolP(*this);
5133}
5134
5136{
5137 return new XMLTableMasterPageExport( *this );
5138}
5139
5140void ScXMLExport::GetChangeTrackViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
5141{
5142 ScChangeViewSettings* pViewSettings(GetDocument() ? GetDocument()->GetChangeViewSettings() : nullptr);
5143 if (!pViewSettings)
5144 return;
5145
5146 sal_Int32 nChangePos(rProps.getLength());
5147 rProps.realloc(nChangePos + 1);
5148 beans::PropertyValue* pProps(rProps.getArray());
5149
5150 uno::Sequence<beans::PropertyValue> aChangeProps(SC_VIEWCHANGES_COUNT);
5151 beans::PropertyValue* pChangeProps(aChangeProps.getArray());
5152 pChangeProps[SC_SHOW_CHANGES].Name = "ShowChanges";
5153 pChangeProps[SC_SHOW_CHANGES].Value <<= pViewSettings->ShowChanges();
5154 pChangeProps[SC_SHOW_ACCEPTED_CHANGES].Name = "ShowAcceptedChanges";
5155 pChangeProps[SC_SHOW_ACCEPTED_CHANGES].Value <<= pViewSettings->IsShowAccepted();
5156 pChangeProps[SC_SHOW_REJECTED_CHANGES].Name = "ShowRejectedChanges";
5157 pChangeProps[SC_SHOW_REJECTED_CHANGES].Value <<= pViewSettings->IsShowRejected();
5158 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME].Name = "ShowChangesByDatetime";
5159 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME].Value <<= pViewSettings->HasDate();
5160 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Name = "ShowChangesByDatetimeMode";
5161 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Value <<= static_cast<sal_Int16>(pViewSettings->GetTheDateMode());
5162 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Name = "ShowChangesByDatetimeFirstDatetime";
5163 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Value <<= pViewSettings->GetTheFirstDateTime().GetUNODateTime();
5164 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Name = "ShowChangesByDatetimeSecondDatetime";
5165 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Value <<= pViewSettings->GetTheLastDateTime().GetUNODateTime();
5166 pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Name = "ShowChangesByAuthor";
5167 pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Value <<= pViewSettings->HasAuthor();
5168 pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR_NAME].Name = "ShowChangesByAuthorName";
5169 pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR_NAME].Value <<= pViewSettings->GetTheAuthorToShow();
5170 pChangeProps[SC_SHOW_CHANGES_BY_COMMENT].Name = "ShowChangesByComment";
5171 pChangeProps[SC_SHOW_CHANGES_BY_COMMENT].Value <<= pViewSettings->HasComment();
5172 pChangeProps[SC_SHOW_CHANGES_BY_COMMENT_TEXT].Name = "ShowChangesByCommentText";
5173 pChangeProps[SC_SHOW_CHANGES_BY_COMMENT_TEXT].Value <<= pViewSettings->GetTheComment();
5174 pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Name = "ShowChangesByRanges";
5175 pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Value <<= pViewSettings->HasRange();
5176 OUString sRangeList;
5177 ScRangeStringConverter::GetStringFromRangeList(sRangeList, &(pViewSettings->GetTheRangeList()), GetDocument(), FormulaGrammar::CONV_OOO);
5178 pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Name = "ShowChangesByRangesList";
5179 pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Value <<= sRangeList;
5180
5181 pProps[nChangePos].Name = "TrackedChangesViewSettings";
5182 pProps[nChangePos].Value <<= aChangeProps;
5183}
5184
5185void ScXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
5186{
5187 if (GetModel().is())
5188 {
5189 rProps.realloc(4);
5190 beans::PropertyValue* pProps(rProps.getArray());
5191 ScModelObj* pDocObj(comphelper::getFromUnoTunnel<ScModelObj>( GetModel() ));
5192 if (pDocObj)
5193 {
5194 SfxObjectShell* pEmbeddedObj = pDocObj->GetEmbeddedObject();
5195 if (pEmbeddedObj)
5196 {
5197 tools::Rectangle aRect(pEmbeddedObj->GetVisArea());
5198 sal_uInt16 i(0);
5199 pProps[i].Name = "VisibleAreaTop";
5200 pProps[i].Value <<= static_cast<sal_Int32>(aRect.Top());
5201 pProps[++i].Name = "VisibleAreaLeft";
5202 pProps[i].Value <<= static_cast<sal_Int32>(aRect.Left());
5203 pProps[++i].Name = "VisibleAreaWidth";
5204 pProps[i].Value <<= static_cast<sal_Int32>(aRect.getOpenWidth());
5205 pProps[++i].Name = "VisibleAreaHeight";
5206 pProps[i].Value <<= static_cast<sal_Int32>(aRect.getOpenHeight());
5207 }
5208 }
5209 }
5211}
5212
5213void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)
5214{
5215 if (!GetModel().is())
5216 return;
5217
5218 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
5219 if (!xMultiServiceFactory.is())
5220 return;
5221
5222 uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance("com.sun.star.comp.SpreadsheetSettings"), uno::UNO_QUERY);
5223 if (xProperties.is())
5224 SvXMLUnitConverter::convertPropertySet(rProps, xProperties);
5225
5226 sal_Int32 nPropsToAdd = 0;
5227 OUStringBuffer aTrackedChangesKey;
5228 if (GetDocument() && GetDocument()->GetChangeTrack() && GetDocument()->GetChangeTrack()->IsProtected())
5229 {
5230 ::comphelper::Base64::encode(aTrackedChangesKey,
5231 GetDocument()->GetChangeTrack()->GetProtection());
5232 if (!aTrackedChangesKey.isEmpty())
5233 ++nPropsToAdd;
5234 }
5235
5236 bool bVBACompat = false;
5237 uno::Reference <container::XNameAccess> xCodeNameAccess;
5238 OSL_ENSURE( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" );
5239 // tdf#71271 - add code names regardless of VBA compatibility mode
5240 if (pDoc)
5241 {
5242 // VBA compatibility mode
5243 if (bVBACompat = pDoc->IsInVBAMode(); bVBACompat)
5244 ++nPropsToAdd;
5245
5246 // code names
5247 xCodeNameAccess = new XMLCodeNameProvider( pDoc );
5248 if( xCodeNameAccess->hasElements() )
5249 ++nPropsToAdd;
5250 else
5251 xCodeNameAccess.clear();
5252 }
5253
5254 if( nPropsToAdd <= 0 )
5255 return;
5256
5257 sal_Int32 nCount(rProps.getLength());
5258 rProps.realloc(nCount + nPropsToAdd);
5259 auto pProps = rProps.getArray();
5260 if (!aTrackedChangesKey.isEmpty())
5261 {
5262 pProps[nCount].Name = "TrackedChangesProtectionKey";
5263 pProps[nCount].Value <<= aTrackedChangesKey.makeStringAndClear();
5264 ++nCount;
5265 }
5266 if( bVBACompat )
5267 {
5268 pProps[nCount].Name = "VBACompatibilityMode";
5269 pProps[nCount].Value <<= bVBACompat;
5270 ++nCount;
5271 }
5272 if( xCodeNameAccess.is() )
5273 {
5274 pProps[nCount].Name = "ScriptConfiguration";
5275 pProps[nCount].Value <<= xCodeNameAccess;
5276 ++nCount;
5277 }
5278}
5279
5281{
5282 return new ScXMLShapeExport(*this);
5283}
5284
5286{
5290}
5291
5292void ScXMLExport::CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib)
5293{
5294 for (const SfxPoolItem* pItem : pPool->GetItemSurrogates(nAttrib))
5295 {
5296 const SvXMLAttrContainerItem *pUnknown(static_cast<const SvXMLAttrContainerItem *>(pItem));
5297 if( pUnknown->GetAttrCount() > 0 )
5298 {
5299 sal_uInt16 nIdx(pUnknown->GetFirstNamespaceIndex());
5300 while( USHRT_MAX != nIdx )
5301 {
5302 if( (XML_NAMESPACE_UNKNOWN_FLAG & nIdx) != 0 )
5303 {
5304 const OUString& rPrefix = pUnknown->GetPrefix( nIdx );
5305 // Add namespace declaration for unknown attributes if
5306 // there aren't existing ones for the prefix used by the
5307 // attributes
5308 GetNamespaceMap_().Add( rPrefix,
5309 pUnknown->GetNamespace( nIdx ) );
5310 }
5311 nIdx = pUnknown->GetNextNamespaceIndex( nIdx );
5312 }
5313 }
5314 }
5315
5316 // #i66550# needed for 'presentation:event-listener' element for URLs in shapes
5321}
5322
5323void ScXMLExport::IncrementProgressBar(bool bFlush, sal_Int32 nInc)
5324{
5325 nProgressCount += nInc;
5326 if (bFlush || nProgressCount > 100)
5327 {
5329 nProgressCount = 0;
5330 }
5331}
5332
5334{
5335 if( getExportFlags() & (SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::STYLES|
5336 SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT) )
5337 {
5338 if (GetDocument())
5339 {
5340 // if source doc was Excel then
5341 uno::Reference< frame::XModel > xModel = GetModel();
5342 if ( xModel.is() )
5343 {
5344 auto pFoundShell = comphelper::getFromUnoTunnel<SfxObjectShell>(xModel);
5345 if ( pFoundShell && ooo::vba::isAlienExcelDoc( *pFoundShell ) )
5346 {
5349 GetAutoStylePool()->SetFamilyPropSetMapper( XmlStyleFamily::TABLE_ROW,
5351 }
5352 }
5356 ScDrawLayer* pDrawLayer = GetDocument()->GetDrawLayer();
5357 if (pDrawLayer)
5358 {
5362 }
5363
5364 // sheet events use officeooo namespace
5365 if( (getExportFlags() & SvXMLExportFlags::CONTENT) &&
5367 {
5368 bool bAnySheetEvents = false;
5369 SCTAB nTabCount = pDoc->GetTableCount();
5370 for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
5371 if (pDoc->GetSheetEvents(nTab))
5372 bAnySheetEvents = true;
5373 if (bAnySheetEvents)
5378 }
5379 }
5380 }
5381 return SvXMLExport::exportDoc( eClass );
5382}
5383
5384// XExporter
5385void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XComponent>& xComponent )
5386{
5387 SolarMutexGuard aGuard;
5388 SvXMLExport::setSourceDocument( xComponent );
5389
5391 OSL_ENSURE( pDoc, "ScXMLExport::setSourceDocument - no ScDocument!" );
5392 if (!pDoc)
5393 throw lang::IllegalArgumentException();
5394
5395 // create ScChangeTrackingExportHelper after document is known
5397
5398 // Set the document's storage grammar corresponding to the ODF version that
5399 // is to be written.
5401 switch (meODFDefaultVersion)
5402 {
5403 // ODF 1.0 and 1.1 use GRAM_PODF, everything later or unspecified GRAM_ODFF
5407 break;
5408 default:
5410 }
5411}
5412
5413// XFilter
5414sal_Bool SAL_CALL ScXMLExport::filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor )
5415{
5416 SolarMutexGuard aGuard;
5417 if (pDoc)
5418 pDoc->EnableIdle(false);
5419 bool bReturn(SvXMLExport::filter(aDescriptor));
5420 if (pDoc)
5421 pDoc->EnableIdle(true);
5422 return bReturn;
5423}
5424
5425void SAL_CALL ScXMLExport::cancel()
5426{
5427 SolarMutexGuard aGuard;
5428 if (pDoc)
5429 pDoc->EnableIdle(true);
5431}
5432
5433// XInitialization
5434void SAL_CALL ScXMLExport::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
5435{
5436 SolarMutexGuard aGuard;
5438}
5439
5441{
5443 pDoc = nullptr;
5444 xCurrentTable = nullptr;
5445}
5446
5447void ScXMLExport::SetSharedData(std::unique_ptr<ScMySharedData> pTemp) { pSharedData = std::move(pTemp); }
5448
5449std::unique_ptr<ScMySharedData> ScXMLExport::ReleaseSharedData() { return std::move(pSharedData); }
5450/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void writeSort(ScXMLExport &mrExport, const ScSortParam &aParam, const ScRange &aRange, const ScDocument *mpDoc)
::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec
std::list< ScMyShape > ScMyShapeList
::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec
std::list< ScMyNoteShape > ScMyNoteShapeList
std::vector< ScMyTableXShapes > ScMyTableShapes
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
css::util::DateTime GetUNODateTime() const
OUString GetText(LineEnd eEnd=LINEEND_LF) const
void SetText(const OUString &rStr)
virtual sal_Int32 GetParagraphCount() const=0
virtual OUString GetText(sal_Int32 nPara) const=0
virtual void GetAllSections(std::vector< editeng::Section > &rAttrs) const=0
bool IsValid() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
void SetValue(sal_Int32 nValue)
void ChangeReference(sal_Int32 nNewReference)
void Increment(sal_Int32 nInc=1)
SCTAB Tab() const
Definition: address.hxx:283
bool IsValid() const
Definition: address.hxx:305
SCROW Row() const
Definition: address.hxx:274
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
SCCOL Col() const
Definition: address.hxx:279
static OUString GetOutputString(ScDocument &rDoc, const ScAddress &rPos, const ScRefCellValue &rCell)
Definition: cellform.cxx:188
static OUString GetString(const ScRefCellValue &rCell, sal_uInt32 nFormat, const Color **ppColor, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bNullVals=true, bool bFormula=false, bool bUseStarFormat=false)
Definition: cellform.cxx:31
uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
Definition: textuno.hxx:209
const ScRangeList & GetTheRangeList() const
Definition: chgviset.hxx:109
bool HasAuthor() const
Definition: chgviset.hxx:92
const OUString & GetTheComment() const
Definition: chgviset.hxx:101
const DateTime & GetTheFirstDateTime() const
Definition: chgviset.hxx:87
SvxRedlinDateMode GetTheDateMode() const
Definition: chgviset.hxx:84
bool IsShowRejected() const
Definition: chgviset.hxx:115
bool HasComment() const
Definition: chgviset.hxx:98
bool HasDate() const
Definition: chgviset.hxx:80
bool HasRange() const
Definition: chgviset.hxx:106
bool ShowChanges() const
Definition: chgviset.hxx:77
const DateTime & GetTheLastDateTime() const
Definition: chgviset.hxx:90
bool IsShowAccepted() const
Definition: chgviset.hxx:112
const OUString & GetTheAuthorToShow() const
Definition: chgviset.hxx:95
ScChartListener * findByName(const OUString &rName)
Definition: chartlis.cxx:403
ScRangeListRef GetRangeList() const
Definition: chartlis.cxx:186
ScColorScaleEntryType GetType() const
Definition: colorscale.hxx:76
condformat::ScCondFormatDateType GetDateType() const
Definition: conditio.hxx:512
const OUString & GetStyleName() const
Definition: conditio.hxx:514
const OUString & GetStyle() const
Definition: conditio.hxx:473
ScConditionMode GetOperation() const
Definition: conditio.hxx:369
const ScAddress & GetSrcPos() const
Definition: conditio.hxx:374
OUString GetExpression(const ScAddress &rCursor, sal_uInt16 nPos, sal_uInt32 nNumFmt=0, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
Definition: conditio.cxx:1256
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:784
ScDetOpType GetOperation() const
Definition: detdata.hxx:45
const ScAddress & GetPos() const
Definition: detdata.hxx:44
size_t Count() const
Definition: detdata.hxx:78
const ScDetOpData & GetObject(size_t nPos) const
Definition: detdata.cxx:83
ScDetectiveObjType GetDetectiveObjectType(SdrObject *pObject, SCTAB nObjTab, ScAddress &rPosition, ScRange &rSource, bool &rRedLine)
Definition: detfunc.cxx:1516
sal_uInt16 GetYear2000() const
Definition: docoptio.hxx:85
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:432
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3640
SC_DLLPUBLIC bool GetMatrixFormulaRange(const ScAddress &rCellPos, ScRange &rMatrix)
Definition: document.cxx:5416
SC_DLLPUBLIC sal_uInt64 GetCellCount() const
Definition: document.cxx:6125
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1914
SC_DLLPUBLIC bool IsDocProtected() const
Definition: documen3.cxx:1894
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:661
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:483
ScDetOpList * GetDetOpList() const
Definition: document.hxx:1852
SCROW GetLastChangedRowFlagsWidth(SCTAB nTab) const
Definition: document.cxx:4553
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3626
SC_DLLPUBLIC ScChartListenerCollection * GetChartListenerCollection() const
Definition: document.hxx:2233
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
Definition: document.cxx:6587
SCROW GetNextDifferentChangedRowFlagsWidth(SCTAB nTab, SCROW nStart) const
Definition: document.cxx:4580
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:982
void SetStorageGrammar(formula::FormulaGrammar::Grammar eGrammar)
Should only be GRAM_PODF or GRAM_ODFF.
Definition: documen2.cxx:251
formula::FormulaGrammar::Grammar GetStorageGrammar() const
Definition: document.hxx:2543
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
Definition: documen3.cxx:625
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:469
SCCOL GetLastChangedColFlagsWidth(SCTAB nTab) const
Definition: document.cxx:4546
bool IsInVBAMode() const
Definition: document.cxx:6477
SC_DLLPUBLIC sc::ExternalDataMapper & GetExternalDataMapper()
bool IsStreamValid(SCTAB nTab) const
Definition: document.cxx:897
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
SC_DLLPUBLIC const ScRangeList * GetScenarioRanges(SCTAB nTab) const
Definition: documen3.cxx:872
const ScConsolidateParam * GetConsolidateDlgData() const
Definition: document.hxx:654
void EnableIdle(bool bDo)
Definition: document.hxx:2208
SC_DLLPUBLIC ScDocProtection * GetDocProtection() const
Definition: documen3.cxx:1881
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
Definition: documen3.cxx:737
SCCOL GetNextDifferentChangedColFlagsWidth(SCTAB nTab, SCCOL nStart) const
Definition: document.cxx:4560
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
Definition: documen4.cxx:860
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:171
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:241
void SyncColRowFlags()
Write all column row flags to table's flag data, because not all column row attributes are stored in ...
Definition: document.cxx:4530
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:231
bool IsPrintEntireSheet(SCTAB nTab) const
Returns true, if the specified sheet is always printed.
Definition: document.cxx:6255
void InterpretDirtyCells(const ScRangeList &rRanges)
Definition: document.cxx:3872
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1936
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:880
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1986
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
static ScDrawObjData * GetObjData(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2874
static ScDrawObjData * GetNonRotatedObjData(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2855
static ScDrawObjData * GetNoteCaptionData(SdrObject *pObj, SCTAB nTab)
Returns the object data, if the passed object is a cell note caption.
Definition: drwlayer.cxx:2907
ScAddress maStart
Definition: userdat.hxx:36
Point maStartOffset
Definition: userdat.hxx:38
Point maEndOffset
Definition: userdat.hxx:39
bool mbResizeWithCell
Definition: userdat.hxx:41
ScAddress maEnd
Definition: userdat.hxx:37
static OUString GetCellFieldValue(const SvxFieldData &rFieldData, const ScDocument *pDoc, std::optional< Color > *ppTextColor, std::optional< FontLineStyle > *ppFldLineStyle)
Definition: editutil.cxx:215
std::shared_ptr< Table > TableTypeRef
::formula::FormulaTokenRef TokenRef
sal_uInt16 getExternalFileCount() const
void resetSrcFileData(const OUString &rBaseFileUrl)
Re-generates relative names for all stored source files.
void getAllCachedNumberFormats(::std::vector< sal_uInt32 > &rNumFmts) const
Get all unique number format indices that are used in the cache tables.
ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const
Get a cache table instance for specified table and table index.
const SrcFileData * getExternalFileData(sal_uInt16 nFileId) const
const OUString * getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal=false)
It returns a pointer to the name of the URI associated with a given external file ID.
void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector< OUString > &rTabNames) const
Returns a vector containing all (real) table names and cache tables of the specified file.
bool hasExternalData() const
virtual Type GetType() const =0
const svl::SharedString & GetResultString() const
FormulaError GetErrCode()
bool IsMultilineResult()
Determines whether or not the result string contains more than one paragraph.
OUString GetFormula(const formula::FormulaGrammar::Grammar=formula::FormulaGrammar::GRAM_DEFAULT, const ScInterpreterContext *pContext=nullptr) const
static const char * getIconSetName(ScIconSetType eType)
const ScIconSetFormatData * GetIconSetData() const
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:445
void AddOperation(ScDetOpType eOpType, const ScAddress &rPosition, sal_uInt32 nIndex)
virtual void Sort() override
void AddGroup(const ScMyColumnRowGroup &aGroup, const sal_Int32 nEndField)
size_t GetCount(size_t nLevel) const
Definition: olinetab.cxx:456
ScOutlineEntry * GetEntry(size_t nLevel, size_t nIndex)
Definition: olinetab.cxx:428
size_t GetDepth() const
Definition: olinetab.hxx:110
SC_DLLPUBLIC SCCOLROW GetStart() const
Definition: olinetab.hxx:42
SC_DLLPUBLIC bool IsHidden() const
Definition: olinetab.hxx:49
SC_DLLPUBLIC SCCOLROW GetEnd() const
Definition: olinetab.cxx:42
const ScOutlineArray & GetColArray() const
Definition: olinetab.hxx:158
const ScOutlineArray & GetRowArray() const
Definition: olinetab.hxx:160
Additional class containing cell annotation data.
Definition: postit.hxx:58
const OUString & GetDate() const
Returns the creation date of this note.
Definition: postit.hxx:106
const OUString & GetAuthor() const
Returns the author date of this note.
Definition: postit.hxx:111
SdrCaptionObj * GetOrCreateCaption(const ScAddress &rPos) const
Returns the caption object of this note.
Definition: postit.cxx:555
bool IsCaptionShown() const
Returns true, if the caption object is visible.
Definition: postit.hxx:150
bool empty() const
Definition: rangenam.hxx:249
static void GetStringFromRange(OUString &rString, const ScRange &rRange, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator=' ', bool bAppendStr=false, ScRefFlags nFormatFlags=ScRefFlags::VALID|ScRefFlags::TAB_3D)
static void GetStringFromRangeList(OUString &rString, const ScRangeList *pRangeList, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator=' ')
static void GetStringFromArea(OUString &rString, const ScArea &rArea, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator, bool bAppendStr=false, ScRefFlags nFormatFlags=ScRefFlags::VALID|ScRefFlags::TAB_3D)
Definition: rangeutl.cxx:674
static void GetStringFromAddress(OUString &rString, const ScAddress &rAddress, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator=' ', bool bAppendStr=false, ScRefFlags nFormatFlags=ScRefFlags::VALID|ScRefFlags::TAB_3D)
Range to String core.
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
void GetStreamPos(SCTAB nTab, sal_Int32 &rStartOffset, sal_Int32 &rEndOffset) const
Definition: sheetdata.cxx:134
const std::vector< ScTextStyleEntry > & GetTextStyles() const
Definition: sheetdata.hxx:169
const std::vector< ScTextStyleEntry > & GetNoteParaStyles() const
Definition: sheetdata.hxx:167
const std::vector< ScCellStyleEntry > & GetRowStyles() const
Definition: sheetdata.hxx:164
const std::vector< ScTextStyleEntry > & GetNoteTextStyles() const
Definition: sheetdata.hxx:168
bool AddLoadedNamespaces(SvXMLNamespaceMap &rNamespaces) const
Definition: sheetdata.cxx:205
const std::vector< ScCellStyleEntry > & GetCellStyles() const
Definition: sheetdata.hxx:162
const std::vector< ScNoteStyleEntry > & GetNoteStyles() const
Definition: sheetdata.hxx:166
void ResetSaveEntries()
Definition: sheetdata.cxx:154
const std::vector< ScCellStyleEntry > & GetTableStyles() const
Definition: sheetdata.hxx:165
void AddSavePos(SCTAB nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset)
Definition: sheetdata.cxx:159
const std::vector< ScCellStyleEntry > & GetColumnStyles() const
Definition: sheetdata.hxx:163
static OUString DisplayToProgrammaticName(const OUString &rDispName, SfxStyleFamily nType)
sheet protection state container
bool isOptionEnabled(Option eOption) const
virtual bool hasPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED) const override
virtual css::uno::Sequence< sal_Int8 > getPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED) const override
virtual bool isProtected() const override
Wrapper for accessing hidden and filtered row attributes.
bool rowFiltered(sal_Int32 nTab, sal_Int32 nRow, sal_Int32 &nEndRow)
bool rowHidden(sal_Int32 nTab, sal_Int32 nRow, sal_Int32 &nEndRow)
static OUString GetStringFromFunction(const sal_Int16 eFunction)
static ScDocument * GetScDocument(const css::uno::Reference< css::frame::XModel > &xModel)
static OUString GetStringFromDetObjType(const ScDetectiveObjType eObjType)
static OUString GetStringFromDetOpType(const ScDetOpType eOpType)
Provide mapping from ODF text formatting styles to EditEngine's, for rich-text cell content import.
const Entry * getEntryByItemID(sal_uInt16 nItemID) const
ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges()
void OpenNewRow(const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEmptyRows, bool bHidden, bool bFiltered)
Definition: xmlexprt.cxx:1390
OUString sElemRow
Definition: xmlexprt.hxx:121
std::unique_ptr< ScFormatRangeStyles > pCellStyles
Definition: xmlexprt.hxx:99
void WriteNamedRange(ScRangeName *pRangeName)
Definition: xmlexprt.cxx:4485
virtual void ExportMeta_() override
Definition: xmlexprt.cxx:633
void GetDetectiveOpList(ScMyDetectiveOpContainer &rDetOp)
Definition: xmlexprt.cxx:706
void OpenAndCloseRow(const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEmptyRows, bool bHidden, bool bFiltered)
Definition: xmlexprt.cxx:1425
void WriteRowContent()
Definition: xmlexprt.cxx:1289
sal_Int32 nOpenRow
Definition: xmlexprt.hxx:124
void WriteEditCell(const EditTextObject *pText)
Definition: xmlexprt.cxx:3297
const ScMyCell * pCurrentCell
Definition: xmlexprt.hxx:106
void AddStyleFromRow(const css::uno::Reference< css::beans::XPropertySet > &xRowProperties, const OUString *pOldName, sal_Int32 &rIndex)
Definition: xmlexprt.cxx:2178
sal_Int32 GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const
Definition: xmlexprt.cxx:475
void WriteCell(ScMyCell &aCell, sal_Int32 nEqualCellCount)
Definition: xmlexprt.cxx:3133
void exportSparklineGroups(SCTAB nTab)
Definition: xmlexprt.cxx:4545
void WriteTableShapes()
Definition: xmlexprt.cxx:3618
void ExportCellTextAutoStyles(sal_Int32 nTable)
Definition: xmlexprt.cxx:1254
rtl::Reference< XMLPropertySetMapper > xColumnStylesPropertySetMapper
Definition: xmlexprt.hxx:86
std::unique_ptr< ScMyNotEmptyCellsIterator > mpCellsItr
Definition: xmlexprt.hxx:82
void WriteConsolidation()
Definition: xmlexprt.cxx:5097
virtual ~ScXMLExport() override
Definition: xmlexprt.cxx:421
OUString sAttrFormula
Definition: xmlexprt.hxx:115
std::unique_ptr< ScColumnStyles > pColumnStyles
Definition: xmlexprt.hxx:97
std::unique_ptr< ScChangeTrackingExportHelper > pChangeTrackingExportHelper
Definition: xmlexprt.hxx:110
NumberFormatIndexMap aNumFmtIndexMap
Definition: xmlexprt.hxx:95
std::vector< OUString > aTableStyles
Definition: xmlexprt.hxx:101
void SetRepeatAttribute(sal_Int32 nEqualCellCount, bool bIncProgress)
Definition: xmlexprt.cxx:3800
void ExportColumns(const sal_Int32 nTable, const ScRange &aColumnHeaderRange, const bool bHasColumnHeader)
Definition: xmlexprt.cxx:784
void CloseHeaderColumn()
Definition: xmlexprt.cxx:779
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlexprt.cxx:5434
virtual void ExportContent_() override
Definition: xmlexprt.cxx:1869
ScDocument * GetDocument()
Definition: xmlexprt.hxx:240
sal_uInt16 nCurrentTable
Definition: xmlexprt.hxx:126
std::unique_ptr< XMLNumberFormatAttributesExportHelper > pNumberFormatAttributesExportHelper
Definition: xmlexprt.hxx:93
OUString sElemCell
Definition: xmlexprt.hxx:118
void WriteDetective(const ScMyCell &rMyCell)
Definition: xmlexprt.cxx:3759
void WriteLabelRanges(const css::uno::Reference< css::container::XIndexAccess > &xRangesIAccess, bool bColumn)
Definition: xmlexprt.cxx:4084
void WriteAnnotation(const ScMyCell &rMyCell)
Definition: xmlexprt.cxx:3737
std::unique_ptr< ScMySharedData > pSharedData
Definition: xmlexprt.hxx:96
virtual void ExportAutoStyles_() override
Definition: xmlexprt.cxx:2617
static css::table::CellRangeAddress GetEndAddress(const css::uno::Reference< css::sheet::XSpreadsheet > &xTable)
Definition: xmlexprt.cxx:667
XMLNumberFormatAttributesExportHelper * GetNumberFormatAttributesExportHelper()
Definition: xmlexprt.cxx:5285
rtl::Reference< XMLPropertySetMapper > xCellStylesPropertySetMapper
Definition: xmlexprt.hxx:85
void WriteCalculationSettings(const css::uno::Reference< css::sheet::XSpreadsheetDocument > &xSpreadDoc)
Definition: xmlexprt.cxx:3886
bool bRowHeaderOpen
Definition: xmlexprt.hxx:128
rtl::Reference< SvXMLExportPropertyMapper > xTableStylesExportPropertySetMapper
Definition: xmlexprt.hxx:92
virtual void ExportMasterStyles_() override
Definition: xmlexprt.cxx:2672
virtual void DisposingModel() override
Definition: xmlexprt.cxx:5440
virtual void exportAnnotationMeta(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: xmlexprt.cxx:3681
void GetAreaLinks(ScMyAreaLinksContainer &rAreaLinks)
Definition: xmlexprt.cxx:681
void AddStyleFromColumn(const css::uno::Reference< css::beans::XPropertySet > &xColumnProperties, const OUString *pOldName, sal_Int32 &rIndex, bool &rIsVisible)
Definition: xmlexprt.cxx:2141
OUString sAttrStringValue
Definition: xmlexprt.hxx:117
void CloseHeaderRows()
Definition: xmlexprt.cxx:1385
std::unique_ptr< ScMySharedData > ReleaseSharedData()
Definition: xmlexprt.cxx:5449
virtual SvXMLAutoStylePoolP * CreateAutoStylePool() override
Definition: xmlexprt.cxx:5130
virtual XMLShapeExport * CreateShapeExport() override
Definition: xmlexprt.cxx:5280
void CollectInternalShape(css::uno::Reference< css::drawing::XShape > const &xShape)
Definition: xmlexprt.cxx:2678
void RegisterDefinedStyleNames(const css::uno::Reference< css::sheet::XSpreadsheetDocument > &xSpreadDoc)
Definition: xmlexprt.cxx:1859
OUString sExternalRefTabStyleName
Definition: xmlexprt.hxx:111
void IncrementProgressBar(bool bFlush, sal_Int32 nInc=1)
Definition: xmlexprt.cxx:5323
sal_Int32 nSourceStreamPos
Definition: xmlexprt.hxx:79
OUString sAttrValueType
Definition: xmlexprt.hxx:116
rtl::Reference< XMLPropertyHandlerFactory > xScPropHdlFactory
Definition: xmlexprt.hxx:84
void ExportExternalRefCacheStyles()
Definition: xmlexprt.cxx:879
OUString sElemTab
Definition: xmlexprt.hxx:122
virtual XMLPageExport * CreatePageExport() override
Definition: xmlexprt.cxx:5135
OUString sAttrColumnsRepeated
Definition: xmlexprt.hxx:114
static void FillFieldGroup(ScOutlineArray *pFields, ScMyOpenCloseColumnRowGroup *pGroups)
Definition: xmlexprt.cxx:1650
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlexprt.cxx:5385
bool IsMatrix(const ScAddress &aCell, ScRange &aCellAddress, bool &bIsFirst) const
Definition: xmlexprt.cxx:2760
void SetSourceStream(const css::uno::Reference< css::io::XInputStream > &xNewStream)
Definition: xmlexprt.cxx:436
std::unique_ptr< sc::CompileFormulaContext > mpCompileFormulaCxt
Definition: xmlexprt.hxx:83
void WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex, const bool bIsVisible)
Definition: xmlexprt.cxx:752
void WriteExternalDataMapping()
Definition: xmlexprt.cxx:4115
sal_Int32 nProgressCount
Definition: xmlexprt.hxx:125
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &rProps) override
Definition: xmlexprt.cxx:5213
css::uno::Reference< css::io::XInputStream > xSourceStream
Definition: xmlexprt.hxx:78
bool IsCellEqual(const ScMyCell &aCell1, const ScMyCell &aCell2)
Definition: xmlexprt.cxx:3818
void WriteRowStartTag(const sal_Int32 nIndex, const sal_Int32 nEmptyRows, bool bHidden, bool bFiltered)
Definition: xmlexprt.cxx:1357
OUString sAttrStyleName
Definition: xmlexprt.hxx:113
void GetColumnRowHeader(bool &bHasColumnHeader, ScRange &aColumnHeaderRange, bool &bHasRowHeader, ScRange &aRowHeaderRange, OUString &rPrintRanges) const
Definition: xmlexprt.cxx:1622
virtual void ExportFontDecls_() override
Definition: xmlexprt.cxx:661
std::unique_ptr< ScMyDefaultStyles > pDefaults
Definition: xmlexprt.hxx:105
void WriteTheLabelRanges(const css::uno::Reference< css::sheet::XSpreadsheetDocument > &xSpreadDoc)
Definition: xmlexprt.cxx:4062
static bool IsEditCell(const ScMyCell &rCell)
Definition: xmlexprt.cxx:3813
virtual void GetViewSettings(css::uno::Sequence< css::beans::PropertyValue > &rProps) override
Definition: xmlexprt.cxx:5185
void collectAutoStyles() override
Definition: xmlexprt.cxx:2228
std::unique_ptr< ScRowStyles > pRowStyles
Definition: xmlexprt.hxx:98
void WriteNamedExpressions()
Definition: xmlexprt.cxx:4107
rtl::Reference< XMLPropertySetMapper > xRowStylesPropertySetMapper
Definition: xmlexprt.hxx:87
rtl::Reference< SvXMLExportPropertyMapper > xRowStylesExportPropertySetMapper
Definition: xmlexprt.hxx:91
void WriteExternalDataTransformations(const std::vector< std::shared_ptr< sc::DataTransformation > > &aDataTransformations)
Definition: xmlexprt.cxx:4145
void WriteTableSource()
Definition: xmlexprt.cxx:3959
void AddStyleFromCells(const css::uno::Reference< css::beans::XPropertySet > &xProperties, const css::uno::Reference< css::sheet::XSpreadsheet > &xTable, sal_Int32 nTable, const OUString *pOldName)
Definition: xmlexprt.cxx:1996
void ExportShape(const css::uno::Reference< css::drawing::XShape > &xShape, css::awt::Point *pPoint)
Definition: xmlexprt.cxx:3368
std::unique_ptr< ScMyOpenCloseColumnRowGroup > pGroupRows
Definition: xmlexprt.hxx:104
void SetSharedData(std::unique_ptr< ScMySharedData > pTemp)
Definition: xmlexprt.cxx:5447
ScXMLExport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLExportFlags nExportFlag)
Definition: xmlexprt.cxx:346
void WriteExternalRefCaches()
Definition: xmlexprt.cxx:4906
void FillColumnRowGroups()
Definition: xmlexprt.cxx:1670
virtual void SAL_CALL cancel() override
Definition: xmlexprt.cxx:5425
void OpenHeaderRows()
Definition: xmlexprt.cxx:1379
void WriteScenario()
Definition: xmlexprt.cxx:4028
void WriteDataStream()
Definition: xmlexprt.cxx:4443
const rtl::Reference< XMLPropertySetMapper > & GetCellStylesPropertySetMapper() const
Definition: xmlexprt.hxx:245
void WriteShapes(const ScMyCell &rMyCell)
Definition: xmlexprt.cxx:3465
void CloseRow(const sal_Int32 nRow)
Definition: xmlexprt.cxx:1518
virtual void SetBodyAttributes() override
Definition: xmlexprt.cxx:1687
void OpenHeaderColumn()
Definition: xmlexprt.cxx:774
void WriteAreaLink(const ScMyCell &rMyCell)
Definition: xmlexprt.cxx:3657
void ExportConditionalFormat(SCTAB nTab)
Definition: xmlexprt.cxx:4616
std::unique_ptr< ScMyMergedRangesContainer > pMergedRangesContainer
Definition: xmlexprt.hxx:108
OUString sAttrName
Definition: xmlexprt.hxx:112
std::unique_ptr< ScXMLEditAttributeMap > mpEditAttrMap
Definition: xmlexprt.hxx:81
rtl::Reference< SvXMLExportPropertyMapper > xCellStylesExportPropertySetMapper
Definition: xmlexprt.hxx:89
void OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, const sal_Int32 nRepeatRow, ScXMLCachedRowAttrAccess &rRowAttr)
Definition: xmlexprt.cxx:1435
void WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex, const sal_Int32 nIndex, const bool bIsAutoStyle, const bool bIsVisible)
Definition: xmlexprt.cxx:733
bool GetMerged(const css::table::CellRangeAddress *pCellRange, const css::uno::Reference< css::sheet::XSpreadsheet > &xTable)
Definition: xmlexprt.cxx:2712
void CollectSharedData(SCTAB &nTableCount, sal_Int32 &nShapesCount)
Definition: xmlexprt.cxx:484
css::uno::Reference< css::sheet::XSpreadsheet > xCurrentTable
Definition: xmlexprt.hxx:76
void GetChangeTrackViewSettings(css::uno::Sequence< css::beans::PropertyValue > &rProps)
Definition: xmlexprt.cxx:5140
virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &aDescriptor) override
Definition: xmlexprt.cxx:5414
const ScXMLEditAttributeMap & GetEditAttributeMap() const
Definition: xmlexprt.cxx:1852
OUString sElemP
Definition: xmlexprt.hxx:123
bool bHasRowHeader
Definition: xmlexprt.hxx:127
void CopySourceStream(sal_Int32 nStartOffset, sal_Int32 nEndOffset, sal_Int32 &rNewStart, sal_Int32 &rNewEnd)
Definition: xmlexprt.cxx:1812
ScRange aRowHeaderRange
Definition: xmlexprt.hxx:102
std::unique_ptr< ScRowFormatRanges > pRowFormatRanges
Definition: xmlexprt.hxx:100
std::unique_ptr< ScMyValidationsContainer > pValidationsContainer
Definition: xmlexprt.hxx:109
rtl::Reference< SvXMLExportPropertyMapper > xColumnStylesExportPropertySetMapper
Definition: xmlexprt.hxx:90
ScDocument * pDoc
Definition: xmlexprt.hxx:75
static sal_Int16 GetMeasureUnit()
Definition: xmlexprt.cxx:338
void WriteMultiLineFormulaResult(const ScFormulaCell *pCell)
Definition: xmlexprt.cxx:3332
std::unique_ptr< ScMyOpenCloseColumnRowGroup > pGroupColumns
Definition: xmlexprt.hxx:103
OUString sElemCoveredCell
Definition: xmlexprt.hxx:119
void WriteTable(sal_Int32 nTable, const css::uno::Reference< css::sheet::XSpreadsheet > &xTable)
Definition: xmlexprt.cxx:2789
void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow, const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet)
Definition: xmlexprt.cxx:1540
OUString sElemCol
Definition: xmlexprt.hxx:120
virtual void ExportStyles_(bool bUsed) override
Definition: xmlexprt.cxx:1963
void CollectShapesAutoStyles(SCTAB nTableCount)
Definition: xmlexprt.cxx:567
void CollectUserDefinedNamespaces(const SfxItemPool *pPool, sal_uInt16 nAttrib)
Definition: xmlexprt.cxx:5292
virtual ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID) override
Definition: xmlexprt.cxx:5333
rtl::Reference< XMLPropertySetMapper > xTableStylesPropertySetMapper
Definition: xmlexprt.hxx:88
const SfxItemPool & GetItemPool() const
bool IsMirroredX() const
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
bool IsResizeProtect() const
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
virtual std::unique_ptr< SdrObjGeoData > GetGeoData() const
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
virtual const tools::Rectangle & GetSnapRect() const
virtual void SetGeoData(const SdrObjGeoData &rGeo)
virtual SdrObjKind GetObjIdentifier() const
virtual void NbcMove(const Size &rSiz)
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const
sal_uInt32 GetFormatIndex(NfIndexTableOffset, LanguageType eLnge=LANGUAGE_DONTKNOW)
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
const OUString & GetPrefix(sal_uInt16 i) const
sal_uInt16 GetNextNamespaceIndex(sal_uInt16 nIdx) const
sal_uInt16 GetAttrCount() const
sal_uInt16 GetFirstNamespaceIndex() const
const OUString & GetNamespace(sal_uInt16 i) const
const SvXMLNamespaceMap & GetNamespaceMap() const
ProgressBarHelper * GetProgressBarHelper()
virtual void DisposingModel()
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
virtual ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void ExportStyles_(bool bUsed)
OUString GetRelativeReference(const OUString &rValue)
XMLEventExport & GetEventExport()
void StartElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSOutside)
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
void Characters(const OUString &rChars)
bool mbAutoStylesCollected
SvXMLExportFlags getExportFlags() const
css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier()
void collectDataStyles(bool bFromUsedStyles)
SvXMLNamespaceMap & GetNamespaceMap_()
virtual void exportDataStyles()
rtl::Reference< SchXMLExportHelper > const & GetChartExport()
const css::uno::Reference< css::frame::XModel > & GetModel() const
virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &aDescriptor) override
virtual void ExportMeta_()
rtl::Reference< XMLFontAutoStylePool > const & GetFontAutoStylePool()
virtual void SAL_CALL cancel() override
virtual void ExportFontDecls_()
rtl::Reference< XMLPageExport > const & GetPageExport()
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
virtual void exportAutoDataStyles()
const css::uno::Reference< css::xml::sax::XDocumentHandler > & GetDocHandler() const
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
rtl::Reference< XMLShapeExport > const & GetShapeExport()
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
OUString EncodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
void CheckAttrList()
virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat=false)
virtual void collectAutoStyles()
rtl::Reference< xmloff::OFormLayerXMLExport > const & GetFormExport()
const SvXMLUnitConverter & GetMM100UnitConverter() const
const OUString & GetOrigFileName() const
void EndElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSInside)
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
void convertDateTime(OUStringBuffer &rBuffer, const double &fDateTime, bool const bAddTimeIf0AM=false)
static void convertPropertySet(css::uno::Sequence< css::beans::PropertyValue > &rProps, const css::uno::Reference< css::beans::XPropertySet > &aProperties, const std::initializer_list< std::u16string_view > *pOmitFalseValues=nullptr)
static sal_Int16 GetMeasureUnit(FieldUnit const nFieldUnit)
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual sal_Int32 GetClassId() const
FontFamily GetFamily() const
FontPitch GetPitch() const
const OUString & GetStyleName() const
rtl_TextEncoding GetCharSet() const
const OUString & GetFamilyName() const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
const OUString & GetTargetFrame() const
const OUString & GetURL() const
void ExportExt(css::uno::Reference< css::container::XNameAccess > const &xAccess)
sal_Int16 GetCellType(const sal_Int32 nNumberFormat, OUString &sCurrency, bool &bIsStandard)
void SetNumberFormatAttributes(const sal_Int32 nNumberFormat, const double &rValue, bool bExportValue=true, sal_uInt16 nNamespace=XML_NAMESPACE_OFFICE, bool bExportCurrencySymbol=true)
static SvXMLExportPropertyMapper * CreateShapePropMapper(SvXMLExport &rExport)
static SvXMLExportPropertyMapper * CreateCharExtPropMapper(SvXMLExport &rExport)
static SvXMLExportPropertyMapper * CreateParaExtPropMapper(SvXMLExport &rExport)
static void encode(OUStringBuffer &aStrBuffer, const css::uno::Sequence< sal_Int8 > &aPass)
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static bool convertBool(bool &rBool, std::u16string_view rString)
MoveType GetMove() const
Definition: datastream.hxx:79
const OUString & GetURL() const
Definition: datastream.hxx:78
bool IsRefreshOnEmptyLine() const
Definition: datastream.hxx:80
ScRange GetRange() const
Definition: datastream.cxx:339
DataStream * getDataStream()
Iterate through all edit text cells in a given sheet.
const EditTextObject * next()
const EditTextObject * first()
const std::vector< ExternalDataSource > & getDataSources() const
static double getUpdateFrequency()
Handle the export of sparkline groups and sparklines.
const SvBaseLinks & GetLinks() const
const OUString & getString() const
constexpr tools::Long Top() const
constexpr Point TopLeft() const
tools::Long getOpenHeight() const
constexpr tools::Long Right() const
constexpr Point TopRight() const
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
T * get() const
bool is() const
constexpr ::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
@ COLORSCALE_MAX
Definition: colorscale.hxx:35
@ COLORSCALE_VALUE
Definition: colorscale.hxx:37
@ COLORSCALE_FORMULA
Definition: colorscale.hxx:39
@ COLORSCALE_PERCENT
Definition: colorscale.hxx:38
@ COLORSCALE_PERCENTILE
Definition: colorscale.hxx:36
@ COLORSCALE_AUTO
Definition: colorscale.hxx:33
@ COLORSCALE_MIN
Definition: colorscale.hxx:34
int nCount
ScDetectiveObjType
Definition: detfunc.hxx:39
@ SC_DETOBJ_TOOTHERTAB
Definition: detfunc.hxx:43
@ SC_DETOBJ_CIRCLE
Definition: detfunc.hxx:44
@ SC_DETOBJ_ARROW
Definition: detfunc.hxx:41
#define TOOLS_WARN_EXCEPTION(area, stream)
URL aURL
OString sFormula
float u
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SvxKerningItem > EE_CHAR_KERNING(EE_CHAR_START+12)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxAutoKernItem > EE_CHAR_PAIRKERNING(EE_CHAR_START+11)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_PARA_XMLATTRIBS(EE_PARA_START+1)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxEmphasisMarkItem > EE_CHAR_EMPHASISMARK(EE_CHAR_START+25)
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
constexpr TypedWhichId< SvxCharScaleWidthItem > EE_CHAR_FONTWIDTH(EE_CHAR_START+3)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_CHAR_XMLATTRIBS(EE_CHAR_START+28)
constexpr TypedWhichId< SvxWordLineModeItem > EE_CHAR_WLM(EE_CHAR_START+13)
constexpr TypedWhichId< SvxCharReliefItem > EE_CHAR_RELIEF(EE_CHAR_START+26)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
EmbeddedObjectRef * pObject
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME
FieldUnit
OUString sName
@ CELLTYPE_EDIT
Definition: global.hxx:277
@ CELLTYPE_STRING
Definition: global.hxx:275
@ CELLTYPE_FORMULA
Definition: global.hxx:276
constexpr SdrLayerID SC_LAYER_HIDDEN(4)
constexpr SdrLayerID SC_LAYER_INTERN(2)
constexpr SdrLayerID SC_LAYER_BACK(1)
ScScenarioFlags
Definition: global.hxx:226
Sequence< PropertyValue > aArguments
sal_Int32 nIndex
OUString aName
void * p
#define LANGUAGE_SYSTEM
SvBaseLink * pLink
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
aBuf
std::unique_ptr< sal_Int32[]> pData
RttiCompleteObjectLocator col
OUString getHashURI(ScPasswordHash eHash)
Reference< XComponentContext > getProcessComponentContext()
ScCondFormatDateType
Definition: conditio.hxx:485
svDouble
svString
int i
constexpr OUStringLiteral implementationName
const sal_uInt16 XML_NAMESPACE_UNKNOWN_FLAG
bool isAlienExcelDoc(SfxObjectShell const &rDocShell)
DATETIME_TRANSFORMATION_TYPE
std::vector< tools::SvRef< SvBaseLink > > SvBaseLinks
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
XML_TABLE_NAME
XML_COLUMN_TEXT_TRANSFORMATION
XML_COLLAPSE
XML_SPREADSHEET
XML_COLUMN_REPLACENULL_TRANSFORMATION
XML_LAST_ROW_SPANNED
XML_AXIS_POSITION
XML_INSERTION_POSITION
XML_TABLE_ROW
XML_COVERED_TABLE_CELL
XML_CUSTOM_ICONSET
XML_TARGET_CELL_ADDRESS
XML_DATA_BAR
XML_STATUS
XML_STEPS
XML_DAY_OF_YEAR
XML_TABLE_COLUMN_GROUP
XML_PRECISION
XML_EMPTY_LINE_REFRESH
XML_CONSOLIDATION
XML_ENABLE
XML_DATA_STREAM_SOURCE
XML_FILTER
XML_END_OF_YEAR
XML_COLUMN_REMOVE_TRANSFORMATION
XML_TABLE
XML_ICON_SET_TYPE
XML_DATE_VALUE
XML_NP_PRESENTATION
XML_COLUMN_SORT_TRANSFORMATION
XML_CELL_RANGE_ADDRESS
XML_CREATOR
XML_NAMED_EXPRESSION
XML_SOURCE_CELL_RANGE_ADDRESSES
XML_COLUMN
XML_CONTENT_VALIDATION_NAME
XML_PRINT_RANGE
XML_DATABASE_NAME
XML_NULL_YEAR
XML_HREF
XML_COPY_BACK
XML_EXPONENTIAL
XML_CASE_SENSITIVE
XML_MARKED_INVALID
XML_MODE
XML_MIN
XML_MIN_LENGTH
XML_REPEAT_ROW
XML_ROW
XML_SELECT_UNPROTECTED_CELLS
XML_NAMED_EXPRESSIONS
XML_RANGE_USABLE_AS
XML_COPY_STYLES
XML_DISPLAY
XML_TRUE
XML_DISPLAY_BORDER
XML_NUMBER_MATRIX_COLUMNS_SPANNED
XML_DATA_TRANSFORMATIONS
XML_STRUCTURE_PROTECTED
XML_TABLE_PROTECTION
XML_TABLE_PROPERTIES
XML_TABLE_COLUMN
XML_REPLACE_STRING
XML_VISIBILITY
XML_DAY
XML_DATE_STRING
XML_FUNCTION
XML_AUTOMATIC_FIND_LABELS
XML_USE_WILDCARDS
XML_HOUR
XML_MAXIMUM_DIFFERENCE
XML_AVERAGE
XML_COLOR_SCALE
XML_MAX
XML_CONDITION
XML_DEFAULT_CELL_STYLE_NAME
XML_FAMILY
XML_FILTER_OPTIONS
XML_SEPARATOR
XML_DELETE_COLUMNS
XML_ITERATION
XML_BORDER_COLOR
XML_PRECISION_AS_SHOWN
XML_HIGHLIGHTED_RANGE
XML_REFRESH_DELAY
XML_ID
XML_INSERT_COLUMNS
XML_SUM
XML_COLUMN_NUMBER_TRANSFORMATION
XML_SHOW_VALUE
XML_TABLE_ROW_GROUP
XML_MERGE_STRING
XML_LABEL_RANGE
XML_POSITIVE_COLOR
XML_PROTECTION_KEY_DIGEST_ALGORITHM
XML_DETECTIVE
XML_FLOAT
XML_COLUMN_SPLIT_TRANSFORMATION
XML_TABLE_HEADER_COLUMNS
XML_APPLY_STYLE_NAME
XML_SCENARIO
XML_EXPRESSION
XML_FORMULA
XML_IS_ACTIVE
XML_SECONDS
XML_TOP
XML_SIMPLE
XML_GRADIENT
XML_CASEMAP_LOWERCASE
XML_STRING
XML_STYLE
XML_DAY_OF_WEEK
XML_NEGATIVE_COLOR
XML_CUBE
XML_PROTECTION_KEY_DIGEST_ALGORITHM_2
XML_CONTAINS_ERROR
XML_PRINT_RANGES
XML_VALUE
XML_DATE_IS
XML_COMMENT
XML_FALSE
XML_STRING_VALUE
XML_STYLE_NAME
XML_CUSTOM_ICONSET_NAME
XML_DATA_CELL_RANGE_ADDRESS
XML_MONTH_NAME
XML_N_OFFICE_EXT
XML_USE_LABEL
XML_MINUTE
XML_END_CELL_ADDRESS
XML_COLUMN_MERGE_TRANSFORMATION
XML_END_X
XML_INDEX
XML_NAME
XML_TARGET_RANGE_ADDRESS
XML_ROUND_DOWN
XML_LOG_10
XML_TIME
XML_P
XML_END_OF_MONTH
XML_CELL_RANGE_SOURCE
XML_NUMBER_COLUMNS_SPANNED
XML_DELETE_ROWS
XML_NUMBER_ROWS_SPANNED
XML_TABLE_HEADER_ROWS
XML_YEAR
XML_VALUE_TYPE
XML_NUMBER_ROWS_REPEATED
XML_COLUMN_AGGREGATE_TRANSFORMATION
XML_ZINDEX
XML_END_Y
XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL
XML_NUMBER_COLUMNS_REPEATED
XML_LABEL_CELL_RANGE_ADDRESS
XML_EVEN
XML_PROTECTION_KEY
XML_LAST_COLUMN_SPANNED
XML_COLOR_SCALE_ENTRY
XML_ICON_SET
XML_CONDITIONAL_FORMAT
XML_MONTH
XML_NOTIFY_ON_UPDATE_OF_RANGES
XML_PRINT
XML_TABLE_SOURCE
XML_FILTER_NAME
XML_DATA_MAPPING
XML_N_PRESENTATION
XML_DATE
XML_ROUND_UP
XML_COPY_FORMULAS
XML_COLUMN_DATETIME_TRANSFORMATION
XML_SHAPES
XML_OPERATION
XML_SQUARE
XML_SCENARIO_RANGES
XML_PROTECTED
XML_DIRECTION
XML_NP_OFFICE_EXT
XML_TRIM
XML_CASEMAP_CAPITALIZE
XML_ORIENTATION
XML_LINK_TO_SOURCE_DATA
XML_LOG
XML_START_OF_YEAR
XML_ODD
XML_BASE_CELL_ADDRESS
XML_CONDITIONAL_FORMATS
XML_TABLE_CELL
XML_END_OF_QUARTER
XML_NUMBER_MATRIX_ROWS_SPANNED
XML_INSERT_ROWS
XML_REPEAT_COLUMN
XML_COPY_RESULTS_ONLY
XML_START_OF_QUARTER
XML_CALCULATION_SETTINGS
XML_NULL_DATE
XML_USE_REGULAR_EXPRESSIONS
XML_DATA_MAPPINGS
XML_MAX_LENGTH
XML_SELECT_PROTECTED_CELLS
XML_PROVIDER
XML_CUSTOM
XML_NAMED_RANGE
XML_COLOR
XML_FORMATTING_ENTRY
XML_AXIS_COLOR
XML_LABEL_RANGES
XML_ROUND
XML_SIGN
XML_SQUARE_ROOT
XML_START_OF_MONTH
XML_QUARTER
XML_BOTH
XML_ABS
XML_CUSTOM_ICONSET_INDEX
XML_DATA_FREQUENCY
XML_BOTTOM
XML_CASEMAP_UPPERCASE
XML_TYPE
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
constexpr TypedWhichId< SvXMLAttrContainerItem > ATTR_USERDEF(122)
#define SEF_DEFAULT
sal_uInt16 nDataAreaCount
Definition: global.hxx:908
std::unique_ptr< ScArea[]> pDataAreas
Definition: global.hxx:909
ScSubTotalFunc eFunction
Definition: global.hxx:907
Color maAxisColor
Color of the axis if used Default color is black.
Definition: colorscale.hxx:145
std::optional< Color > mxNegativeColor
Specifies the color for negative values.
Definition: colorscale.hxx:140
std::unique_ptr< ScColorScaleEntry, o3tl::default_delete< ScColorScaleEntry > > mpLowerLimit
Definition: colorscale.hxx:185
databar::ScAxisPosition meAxisPosition
Paint negative values into the same direction as positive values If false we will set the mid point a...
Definition: colorscale.hxx:167
double mnMinLength
Minimal length of a databar in percent of cell length Value has to be in the range [0,...
Definition: colorscale.hxx:172
double mnMaxLength
Maximal length of a databar in percent of cell length Value has to be in the range (0,...
Definition: colorscale.hxx:177
Color maPositiveColor
Color for all Positive Values and if mbNeg == false also for negative ones.
Definition: colorscale.hxx:134
bool mbNeg
Use different color for negative values.
Definition: colorscale.hxx:159
bool mbGradient
Paint the bars with gradient.
Definition: colorscale.hxx:152
bool mbOnlyBar
If TRUE we only show the bar and not the value.
Definition: colorscale.hxx:182
std::unique_ptr< ScColorScaleEntry, o3tl::default_delete< ScColorScaleEntry > > mpUpperLimit
Definition: colorscale.hxx:184
Source document meta-data container.
OUString maRelativeName
file name created from the relative name.
std::map< sal_uInt64, OUString > maIDToName
Definition: sheetdata.hxx:177
ScIconSetType eIconSetType
Definition: colorscale.hxx:340
std::vector< std::pair< ScIconSetType, sal_Int32 > > maCustomVector
Definition: colorscale.hxx:351
ScPostIt * pNote
sal_Int32 nStyleIndex
ScRange aMergeRange
sal_Int32 nValidationIndex
ScRefCellValue maBaseCell
ScMyDetectiveObjVec aDetectiveObjVec
ScMyShapeList aShapeList
ScMyAreaLink aAreaLink
ScRange aMatrixRange
ScMyDetectiveOpVec aDetectiveOpVec
css::table::CellContentType nType
sal_Int32 nNumberFormat
ScAddress maCellAddress
css::uno::Reference< css::drawing::XDrawPage > xDrawPage
sal_Int32 nEndX
css::uno::Reference< css::drawing::XShape > xShape
ScAddress aEndAddress
sal_Int32 nEndY
ScAddress aAddress
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
ScFormulaCell * getFormula() const
Definition: cellvalue.hxx:137
const EditTextObject * getEditText() const
Definition: cellvalue.hxx:136
double getDouble() const
Definition: cellvalue.hxx:134
OUString getString(const ScDocument *pDoc) const
Retrieve string value.
Definition: cellvalue.cxx:657
CellType getType() const
Definition: cellvalue.hxx:133
std::vector< const SfxPoolItem * > maAttributes
sal_Int32 mnParagraph
sal_Int32 mnStart
Reference< XModel > xModel
constexpr TypedWhichId< SvXMLAttrContainerItem > SDRATTR_XMLATTRIBUTES(SDRATTR_MISC_FIRST+22)
ScPasswordHash
@ PASSHASH_XL
@ PASSHASH_UNSPECIFIED
@ PASSHASH_SHA1
@ PASSHASH_SHA256
@ COLUMN_HEADER
Definition: tabview.hxx:59
@ ROW_HEADER
Definition: tabview.hxx:60
unsigned char sal_Bool
sal_uInt16 sal_Unicode
signed char sal_Int8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
constexpr OUStringLiteral SC_UNO_CALCASSHOWN
Definition: unonames.hxx:512
constexpr OUStringLiteral SC_UNO_ITERCOUNT
Definition: unonames.hxx:516
constexpr OUStringLiteral SC_UNO_NULLDATE
Definition: unonames.hxx:521
constexpr OUStringLiteral SC_UNO_SHEETLINKS
Definition: unonames.hxx:47
constexpr OUStringLiteral SC_UNONAME_NUMFMT
Definition: unonames.hxx:109
constexpr OUStringLiteral SC_UNO_ITEREPSILON
Definition: unonames.hxx:518
constexpr OUStringLiteral SC_UNO_IGNORECASE
Definition: unonames.hxx:515
constexpr OUStringLiteral SC_UNO_LOOKUPLABELS
Definition: unonames.hxx:519
constexpr OUStringLiteral SC_UNO_COLLABELRNG
Definition: unonames.hxx:42
constexpr OUStringLiteral SC_UNO_WILDCARDSENABLED
Definition: unonames.hxx:525
constexpr OUStringLiteral SC_UNO_REGEXENABLED
Definition: unonames.hxx:524
constexpr OUStringLiteral SC_UNONAME_FILTER
Definition: unonames.hxx:375
constexpr OUStringLiteral SC_UNONAME_REFDELAY
Definition: unonames.hxx:379
constexpr OUStringLiteral SC_UNONAME_LINKURL
Definition: unonames.hxx:377
constexpr OUStringLiteral SC_UNONAME_FILTOPT
Definition: unonames.hxx:376
constexpr OUStringLiteral SC_UNO_MATCHWHOLE
Definition: unonames.hxx:520
constexpr OUStringLiteral SC_UNO_ROWLABELRNG
Definition: unonames.hxx:46
constexpr OUStringLiteral SC_UNO_ITERENABLED
Definition: unonames.hxx:517
std::unique_ptr< char[]> aBuffer
@ TABLE
Definition: xmldpimp.hxx:43
#define XMLERROR_CANCEL
#define XMLERROR_FLAG_SEVERE
SvXMLExportFlags
#define SC_SHOW_CHANGES_BY_RANGES_LIST
Definition: xmlexprt.cxx:183
#define SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME
Definition: xmlexprt.cxx:177
#define SC_SHOW_CHANGES_BY_COMMENT
Definition: xmlexprt.cxx:180
#define SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME
Definition: xmlexprt.cxx:176
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLStylesExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:262
#define SC_SHOW_CHANGES_BY_RANGES
Definition: xmlexprt.cxx:182
#define SC_VIEWCHANGES_COUNT
Definition: xmlexprt.cxx:170
constexpr OUStringLiteral SC_LAYERID
not found in unonames.hxx
Definition: xmlexprt.cxx:168
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLMetaExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:256
#define SC_SHOW_REJECTED_CHANGES
Definition: xmlexprt.cxx:173
static uno::Any lcl_GetEnumerated(uno::Reference< container::XEnumerationAccess > const &xEnumAccess, sal_Int32 nIndex)
Definition: xmlexprt.cxx:2207
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisMetaExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:286
#define SC_SHOW_CHANGES_BY_COMMENT_TEXT
Definition: xmlexprt.cxx:181
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:280
#define SC_SHOW_CHANGES
Definition: xmlexprt.cxx:171
#define SC_SHOW_CHANGES_BY_AUTHOR
Definition: xmlexprt.cxx:178
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLSettingsExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:274
#define SC_SHOW_CHANGES_BY_AUTHOR_NAME
Definition: xmlexprt.cxx:179
#define SC_SHOW_CHANGES_BY_DATETIME_MODE
Definition: xmlexprt.cxx:175
#define SC_SHOW_CHANGES_BY_DATETIME
Definition: xmlexprt.cxx:174
#define SC_SHOW_ACCEPTED_CHANGES
Definition: xmlexprt.cxx:172
static bool lcl_CopyStreamElement(const uno::Reference< io::XInputStream > &xInput, const uno::Reference< io::XOutputStream > &xOutput, sal_Int32 nCount)
Definition: xmlexprt.cxx:1743
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisContentExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:298
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisSettingsExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:304
static void lcl_SkipBytesInBlocks(const uno::Reference< io::XInputStream > &xInput, sal_Int32 nBytesToSkip)
Definition: xmlexprt.cxx:1792
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLOasisStylesExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:292
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:250
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_XMLContentExporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlexprt.cxx:268
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_META
constexpr sal_uInt16 XML_NAMESPACE_OFFICE_EXT
constexpr sal_uInt16 XML_NAMESPACE_DC
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_OOOC
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_OF
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr sal_uInt16 XML_NAMESPACE_CALC_EXT
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
constexpr sal_uInt16 XML_NAMESPACE_STYLE
const XMLPropertyMapEntry aXMLScTableStylesProperties[]
Definition: xmlstyle.cxx:179
const XMLPropertyMapEntry aXMLScRowStylesProperties[]
Definition: xmlstyle.cxx:145
const XMLPropertyMapEntry aXMLScFromXLSRowStylesProperties[]
Definition: xmlstyle.cxx:153
const XMLPropertyMapEntry aXMLScColumnStylesProperties[]
Definition: xmlstyle.cxx:121
const XMLPropertyMapEntry aXMLScCellStylesProperties[]
Definition: xmlstyle.cxx:65
#define CTF_SC_NUMBERFORMAT
Definition: xmlstyle.hxx:75
#define CTF_SC_CELLSTYLE
Definition: xmlstyle.hxx:80
#define CTF_SC_VALIDATION
Definition: xmlstyle.hxx:81
NF_DATE_SYS_DDMMYYYY