Line data Source code
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 <editeng/eeitem.hxx>
21 :
22 : #include "xmlexprt.hxx"
23 : #include "XMLConverter.hxx"
24 : #include "xmlstyle.hxx"
25 : #include "unonames.hxx"
26 : #include "document.hxx"
27 : #include "olinetab.hxx"
28 : #include "cellsuno.hxx"
29 : #include "cell.hxx"
30 : #include "rangenam.hxx"
31 : #include "XMLTableMasterPageExport.hxx"
32 : #include "drwlayer.hxx"
33 : #include "XMLExportDataPilot.hxx"
34 : #include "XMLExportDatabaseRanges.hxx"
35 : #include "XMLExportDDELinks.hxx"
36 : #include "XMLExportIterator.hxx"
37 : #include "XMLColumnRowGroupExport.hxx"
38 : #include "XMLStylesExportHelper.hxx"
39 : #include "XMLChangeTrackingExportHelper.hxx"
40 : #include "sheetdata.hxx"
41 : #include "docoptio.hxx"
42 : #include "XMLExportSharedData.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 "dociter.hxx"
51 : #include "chgtrack.hxx"
52 : #include "rangeutl.hxx"
53 : #include "convuno.hxx"
54 : #include "postit.hxx"
55 : #include "externalrefmgr.hxx"
56 : #include "editutil.hxx"
57 : #include "tabprotection.hxx"
58 : #include "cachedattraccess.hxx"
59 : #include "colorscale.hxx"
60 : #include "conditio.hxx"
61 :
62 : #include <xmloff/xmltoken.hxx>
63 : #include <xmloff/xmlnmspe.hxx>
64 : #include <xmloff/xmluconv.hxx>
65 : #include <xmloff/nmspmap.hxx>
66 : #include <xmloff/families.hxx>
67 : #include <xmloff/numehelp.hxx>
68 : #include <xmloff/txtparae.hxx>
69 : #include <xmloff/xmlcnitm.hxx>
70 : #include <xmloff/xmlerror.hxx>
71 : #include <xmloff/XMLEventExport.hxx>
72 :
73 : #include <sax/tools/converter.hxx>
74 :
75 : #include <rtl/ustring.hxx>
76 :
77 : #include "tools/color.hxx"
78 : #include <rtl/math.hxx>
79 : #include <svl/zforlist.hxx>
80 : #include <svx/unoshape.hxx>
81 : #include <comphelper/extract.hxx>
82 : #include <toolkit/helper/convert.hxx>
83 : #include <svx/svdobj.hxx>
84 : #include <svx/svdocapt.hxx>
85 : #include <editeng/outlobj.hxx>
86 : #include <svx/svditer.hxx>
87 : #include <svx/svdpage.hxx>
88 :
89 : #include <comphelper/processfactory.hxx>
90 : #include <com/sun/star/sheet/XUsedAreaCursor.hpp>
91 : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
92 : #include <com/sun/star/sheet/XAreaLinks.hpp>
93 : #include <com/sun/star/sheet/XAreaLink.hpp>
94 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
95 : #include <com/sun/star/table/XColumnRowRange.hpp>
96 : #include <com/sun/star/sheet/XPrintAreas.hpp>
97 : #include <com/sun/star/container/XNamed.hpp>
98 : #include <com/sun/star/util/XProtectable.hpp>
99 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
100 : #include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp>
101 : #include <com/sun/star/sheet/XCellRangesQuery.hpp>
102 : #include <com/sun/star/sheet/CellFlags.hpp>
103 : #include <com/sun/star/util/XMergeable.hpp>
104 : #include <com/sun/star/sheet/XArrayFormulaRange.hpp>
105 : #include <com/sun/star/text/XText.hpp>
106 : #include <com/sun/star/sheet/XLabelRanges.hpp>
107 : #include <com/sun/star/sheet/XLabelRange.hpp>
108 : #include <com/sun/star/sheet/XNamedRanges.hpp>
109 : #include <com/sun/star/sheet/XNamedRange.hpp>
110 : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
111 : #include <com/sun/star/sheet/NamedRangeFlag.hpp>
112 : #include <com/sun/star/sheet/XSheetLinkable.hpp>
113 : #include <com/sun/star/form/XFormsSupplier2.hpp>
114 : #include <com/sun/star/io/XActiveDataSource.hpp>
115 : #include <com/sun/star/io/XSeekable.hpp>
116 : #include <com/sun/star/beans/XPropertySet.hpp>
117 :
118 : #include <com/sun/star/chart2/XChartDocument.hpp>
119 : #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
120 : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
121 :
122 : #include <com/sun/star/document/XDocumentProperties.hpp>
123 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
124 :
125 : #include "XMLCodeNameProvider.hxx"
126 :
127 : #include <sfx2/objsh.hxx>
128 :
129 : #include <vector>
130 : #include <vbahelper/vbaaccesshelper.hxx>
131 :
132 : //! not found in unonames.hxx
133 : #define SC_LAYERID "LayerID"
134 :
135 : #define SC_VIEWCHANGES_COUNT 13
136 : #define SC_SHOW_CHANGES 0
137 : #define SC_SHOW_ACCEPTED_CHANGES 1
138 : #define SC_SHOW_REJECTED_CHANGES 2
139 : #define SC_SHOW_CHANGES_BY_DATETIME 3
140 : #define SC_SHOW_CHANGES_BY_DATETIME_MODE 4
141 : #define SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME 5
142 : #define SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME 6
143 : #define SC_SHOW_CHANGES_BY_AUTHOR 7
144 : #define SC_SHOW_CHANGES_BY_AUTHOR_NAME 8
145 : #define SC_SHOW_CHANGES_BY_COMMENT 9
146 : #define SC_SHOW_CHANGES_BY_COMMENT_TEXT 10
147 : #define SC_SHOW_CHANGES_BY_RANGES 11
148 : #define SC_SHOW_CHANGES_BY_RANGES_LIST 12
149 :
150 : using namespace formula;
151 : using namespace com::sun::star;
152 : using namespace xmloff::token;
153 : using ::std::vector;
154 : using ::rtl::OUString;
155 : using ::rtl::OUStringBuffer;
156 : using ::com::sun::star::uno::Reference;
157 : using ::com::sun::star::uno::UNO_QUERY;
158 :
159 : //----------------------------------------------------------------------------
160 :
161 : namespace
162 : {
163 0 : OUString lcl_RangeSequenceToString(
164 : const uno::Sequence< OUString > & rRanges,
165 : const uno::Reference< chart2::data::XRangeXMLConversion > & xFormatConverter )
166 : {
167 0 : OUStringBuffer aResult;
168 0 : const sal_Int32 nMaxIndex( rRanges.getLength() - 1 );
169 0 : const sal_Unicode cSep( sal_Char(' '));
170 0 : for( sal_Int32 i=0; i<=nMaxIndex; ++i )
171 : {
172 0 : OUString aRange( rRanges[i] );
173 0 : if( xFormatConverter.is())
174 0 : aRange = xFormatConverter->convertRangeToXML( aRange );
175 0 : aResult.append( aRange );
176 0 : if( i < nMaxIndex )
177 0 : aResult.append( cSep );
178 0 : }
179 0 : return aResult.makeStringAndClear();
180 : }
181 :
182 0 : OUString lcl_GetRawString( ScDocument* pDoc, const ScAddress& rPos )
183 : {
184 : // return text/edit cell string content, with line feeds in edit cells
185 :
186 0 : String aVal; // document uses tools-strings
187 0 : if (pDoc)
188 : {
189 0 : ScBaseCell* pCell = pDoc->GetCell( rPos );
190 0 : if (pCell)
191 : {
192 0 : CellType eType = pCell->GetCellType();
193 0 : if ( eType == CELLTYPE_STRING )
194 0 : aVal = static_cast<ScStringCell*>(pCell)->GetString(); // string cell: content
195 0 : else if ( eType == CELLTYPE_EDIT )
196 : {
197 : // edit cell: text with line breaks
198 0 : const EditTextObject* pData = static_cast<ScEditCell*>(pCell)->GetData();
199 0 : if (pData)
200 : {
201 0 : EditEngine& rEngine = pDoc->GetEditEngine();
202 0 : rEngine.SetText( *pData );
203 0 : aVal = rEngine.GetText( LINEEND_LF );
204 : }
205 : }
206 : }
207 : }
208 0 : return aVal;
209 : }
210 : } // anonymous namespace
211 :
212 : //----------------------------------------------------------------------------
213 :
214 20 : OUString SAL_CALL ScXMLOOoExport_getImplementationName() throw()
215 : {
216 20 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLExporter" ) );
217 : }
218 :
219 0 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_getSupportedServiceNames() throw()
220 : {
221 0 : const rtl::OUString aServiceName( ScXMLOOoExport_getImplementationName() );
222 0 : return uno::Sequence< rtl::OUString >( &aServiceName, 1 );
223 : }
224 :
225 0 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_createInstance(
226 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
227 : {
228 0 : return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_ALL );
229 : }
230 :
231 20 : OUString SAL_CALL ScXMLOOoExport_Meta_getImplementationName() throw()
232 : {
233 20 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLMetaExporter" ) );
234 : }
235 :
236 0 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Meta_getSupportedServiceNames() throw()
237 : {
238 0 : const rtl::OUString aServiceName( ScXMLOOoExport_Meta_getImplementationName() );
239 0 : return uno::Sequence< rtl::OUString > ( &aServiceName, 1 );
240 : }
241 :
242 0 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Meta_createInstance(
243 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
244 : {
245 0 : return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_META );
246 : }
247 :
248 20 : OUString SAL_CALL ScXMLOOoExport_Styles_getImplementationName() throw()
249 : {
250 20 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLStylesExporter" ) );
251 : }
252 :
253 0 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Styles_getSupportedServiceNames() throw()
254 : {
255 0 : const rtl::OUString aServiceName( ScXMLOOoExport_Styles_getImplementationName() );
256 0 : return uno::Sequence< rtl::OUString > ( &aServiceName, 1 );
257 : }
258 :
259 0 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Styles_createInstance(
260 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
261 : {
262 0 : return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS);
263 : }
264 :
265 20 : OUString SAL_CALL ScXMLOOoExport_Content_getImplementationName() throw()
266 : {
267 20 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLContentExporter" ) );
268 : }
269 :
270 0 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Content_getSupportedServiceNames() throw()
271 : {
272 0 : const rtl::OUString aServiceName( ScXMLOOoExport_Content_getImplementationName() );
273 0 : return uno::Sequence< rtl::OUString > ( &aServiceName, 1 );
274 : }
275 :
276 0 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Content_createInstance(
277 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
278 : {
279 0 : return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS);
280 : }
281 :
282 20 : OUString SAL_CALL ScXMLOOoExport_Settings_getImplementationName() throw()
283 : {
284 20 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLSettingsExporter" ) );
285 : }
286 :
287 0 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Settings_getSupportedServiceNames() throw()
288 : {
289 0 : const rtl::OUString aServiceName( ScXMLOOoExport_Settings_getImplementationName() );
290 0 : return uno::Sequence< rtl::OUString > ( &aServiceName, 1 );
291 : }
292 :
293 0 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Settings_createInstance(
294 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
295 : {
296 0 : return (cppu::OWeakObject*)new ScXMLExport( rSMgr, EXPORT_SETTINGS );
297 : }
298 :
299 : // Oasis Filter
300 :
301 20 : OUString SAL_CALL ScXMLOasisExport_getImplementationName() throw()
302 : {
303 20 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisExporter" ) );
304 : }
305 :
306 0 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_getSupportedServiceNames() throw()
307 : {
308 0 : const rtl::OUString aServiceName( ScXMLOasisExport_getImplementationName() );
309 0 : const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
310 0 : return aSeq;
311 : }
312 :
313 0 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_createInstance(
314 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
315 : {
316 0 : return (cppu::OWeakObject*)new ScXMLExport(rSMgr, EXPORT_ALL|EXPORT_OASIS);
317 : }
318 :
319 22 : OUString SAL_CALL ScXMLOasisExport_Meta_getImplementationName() throw()
320 : {
321 22 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisMetaExporter" ) );
322 : }
323 :
324 1 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Meta_getSupportedServiceNames() throw()
325 : {
326 1 : const rtl::OUString aServiceName( ScXMLOasisExport_Meta_getImplementationName() );
327 1 : const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
328 1 : return aSeq;
329 : }
330 :
331 2 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Meta_createInstance(
332 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
333 : {
334 2 : return (cppu::OWeakObject*)new ScXMLExport(rSMgr, EXPORT_META|EXPORT_OASIS);
335 : }
336 :
337 22 : OUString SAL_CALL ScXMLOasisExport_Styles_getImplementationName() throw()
338 : {
339 22 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisStylesExporter" ) );
340 : }
341 :
342 1 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Styles_getSupportedServiceNames() throw()
343 : {
344 1 : const rtl::OUString aServiceName( ScXMLOasisExport_Styles_getImplementationName() );
345 1 : const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
346 1 : return aSeq;
347 : }
348 :
349 2 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Styles_createInstance(
350 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
351 : {
352 2 : return (cppu::OWeakObject*)new ScXMLExport(rSMgr, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS|EXPORT_OASIS);
353 : }
354 :
355 22 : OUString SAL_CALL ScXMLOasisExport_Content_getImplementationName() throw()
356 : {
357 22 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisContentExporter" ) );
358 : }
359 :
360 1 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Content_getSupportedServiceNames() throw()
361 : {
362 1 : const rtl::OUString aServiceName( ScXMLOasisExport_Content_getImplementationName() );
363 1 : const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
364 1 : return aSeq;
365 : }
366 :
367 2 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Content_createInstance(
368 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
369 : {
370 2 : return (cppu::OWeakObject*)new ScXMLExport(rSMgr, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS|EXPORT_OASIS);
371 : }
372 :
373 22 : OUString SAL_CALL ScXMLOasisExport_Settings_getImplementationName() throw()
374 : {
375 22 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisSettingsExporter" ) );
376 : }
377 :
378 1 : uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Settings_getSupportedServiceNames() throw()
379 : {
380 1 : const rtl::OUString aServiceName( ScXMLOasisExport_Settings_getImplementationName() );
381 1 : const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
382 1 : return aSeq;
383 : }
384 :
385 2 : uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Settings_createInstance(
386 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
387 : {
388 2 : return (cppu::OWeakObject*)new ScXMLExport(rSMgr, EXPORT_SETTINGS|EXPORT_OASIS);
389 : }
390 : //----------------------------------------------------------------------------
391 :
392 : class ScXMLShapeExport : public XMLShapeExport
393 : {
394 : public:
395 4 : ScXMLShapeExport(SvXMLExport& rExp) : XMLShapeExport(rExp) {}
396 : ~ScXMLShapeExport();
397 :
398 : /** is called before a shape element for the given XShape is exported */
399 : virtual void onExport( const uno::Reference < drawing::XShape >& xShape );
400 : };
401 :
402 8 : ScXMLShapeExport::~ScXMLShapeExport()
403 : {
404 8 : }
405 :
406 0 : void ScXMLShapeExport::onExport( const uno::Reference < drawing::XShape >& xShape )
407 : {
408 0 : uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY );
409 0 : if( xShapeProp.is() )
410 : {
411 0 : sal_Int16 nLayerID = 0;
412 0 : if( (xShapeProp->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_LAYERID ))) >>= nLayerID) && (nLayerID == SC_LAYER_BACK) )
413 0 : GetExport().AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_BACKGROUND, XML_TRUE);
414 0 : }
415 0 : }
416 :
417 : //----------------------------------------------------------------------------
418 :
419 8 : sal_Int16 ScXMLExport::GetFieldUnit()
420 : {
421 : com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xProperties(
422 16 : comphelper::getProcessServiceFactory()->createInstance(
423 8 : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" )) ),
424 8 : com::sun::star::uno::UNO_QUERY);
425 8 : if (xProperties.is())
426 : {
427 8 : sal_Int16 nFieldUnit = 0;
428 8 : if (xProperties->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Metric"))) >>= nFieldUnit)
429 8 : return nFieldUnit;
430 : }
431 0 : return 0;
432 : }
433 :
434 :
435 : // #110680#
436 8 : ScXMLExport::ScXMLExport(
437 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
438 : const sal_uInt16 nExportFlag)
439 8 : : SvXMLExport( SvXMLUnitConverter::GetMeasureUnit(GetFieldUnit()),
440 : xServiceFactory, XML_SPREADSHEET, nExportFlag ),
441 : pDoc(NULL),
442 : nSourceStreamPos(0),
443 : pNumberFormatAttributesExportHelper(NULL),
444 : pSharedData(NULL),
445 : pColumnStyles(NULL),
446 : pRowStyles(NULL),
447 : pCellStyles(NULL),
448 : pRowFormatRanges(NULL),
449 : aTableStyles(),
450 : pGroupColumns (NULL),
451 : pGroupRows (NULL),
452 : pDefaults(NULL),
453 : pChartListener(NULL),
454 : pCurrentCell(NULL),
455 : pMergedRangesContainer(NULL),
456 : pValidationsContainer(NULL),
457 : pCellsItr(NULL),
458 : pChangeTrackingExportHelper(NULL),
459 : sLayerID(RTL_CONSTASCII_USTRINGPARAM( SC_LAYERID )),
460 : sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape")),
461 : nOpenRow(-1),
462 : nProgressCount(0),
463 : nCurrentTable(0),
464 : bHasRowHeader(false),
465 : bRowHeaderOpen(false),
466 16 : mbShowProgress( false )
467 : {
468 8 : if (getExportFlags() & EXPORT_CONTENT)
469 : {
470 2 : pGroupColumns = new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_COLUMN_GROUP);
471 2 : pGroupRows = new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_ROW_GROUP);
472 2 : pColumnStyles = new ScColumnStyles();
473 2 : pRowStyles = new ScRowStyles();
474 2 : pRowFormatRanges = new ScRowFormatRanges();
475 2 : pMergedRangesContainer = new ScMyMergedRangesContainer();
476 2 : pValidationsContainer = new ScMyValidationsContainer();
477 2 : pCellsItr = new ScMyNotEmptyCellsIterator(*this);
478 2 : pDefaults = new ScMyDefaultStyles();
479 : }
480 8 : pCellStyles = new ScFormatRangeStyles();
481 :
482 : // document is not set here - create ScChangeTrackingExportHelper later
483 :
484 8 : xScPropHdlFactory = new XMLScPropHdlFactory;
485 8 : xCellStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScCellStylesProperties, xScPropHdlFactory);
486 8 : xColumnStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScColumnStylesProperties, xScPropHdlFactory);
487 8 : xRowStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScRowStylesProperties, xScPropHdlFactory);
488 8 : xTableStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScTableStylesProperties, xScPropHdlFactory);
489 8 : xCellStylesExportPropertySetMapper = new ScXMLCellExportPropertyMapper(xCellStylesPropertySetMapper);
490 8 : xCellStylesExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
491 8 : xColumnStylesExportPropertySetMapper = new ScXMLColumnExportPropertyMapper(xColumnStylesPropertySetMapper);
492 8 : xRowStylesExportPropertySetMapper = new ScXMLRowExportPropertyMapper(xRowStylesPropertySetMapper);
493 8 : xTableStylesExportPropertySetMapper = new ScXMLTableExportPropertyMapper(xTableStylesPropertySetMapper);
494 :
495 : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_CELL, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)),
496 8 : xCellStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX)));
497 : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_COLUMN, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME)),
498 8 : xColumnStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX)));
499 : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_ROW, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME)),
500 8 : xRowStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX)));
501 : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_TABLE, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME)),
502 8 : xTableStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX)));
503 :
504 8 : if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
505 : {
506 : // This name is reserved for the external ref cache tables. This
507 : // should not conflict with user-defined styles since this name is
508 : // used for a table style which is not available in the UI.
509 4 : sExternalRefTabStyleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ta_extref"));
510 4 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_TABLE, sExternalRefTabStyleName);
511 :
512 4 : sAttrName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NAME));
513 4 : sAttrStyleName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME));
514 4 : sAttrColumnsRepeated = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_NUMBER_COLUMNS_REPEATED));
515 4 : sAttrFormula = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_FORMULA));
516 4 : sAttrStringValue = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_STRING_VALUE));
517 4 : sAttrValueType = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE_TYPE));
518 4 : sElemCell = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE_CELL));
519 4 : sElemCoveredCell = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_COVERED_TABLE_CELL));
520 4 : sElemCol = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE_COLUMN));
521 4 : sElemRow = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE_ROW));
522 4 : sElemTab = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE));
523 4 : sElemP = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TEXT, GetXMLToken(XML_P));
524 : }
525 8 : }
526 :
527 :
528 24 : ScXMLExport::~ScXMLExport()
529 : {
530 8 : delete pGroupColumns;
531 8 : delete pGroupRows;
532 8 : delete pColumnStyles;
533 8 : delete pRowStyles;
534 8 : delete pCellStyles;
535 8 : delete pRowFormatRanges;
536 8 : delete pMergedRangesContainer;
537 8 : delete pValidationsContainer;
538 8 : delete pChangeTrackingExportHelper;
539 8 : delete pChartListener;
540 8 : delete pCellsItr;
541 8 : delete pDefaults;
542 8 : delete pNumberFormatAttributesExportHelper;
543 16 : }
544 :
545 0 : void ScXMLExport::SetSourceStream( const uno::Reference<io::XInputStream>& xNewStream )
546 : {
547 0 : xSourceStream = xNewStream;
548 :
549 0 : if ( xSourceStream.is() )
550 : {
551 : // make sure it's a plain UTF-8 stream as written by OOo itself
552 :
553 0 : const sal_Char pXmlHeader[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
554 0 : sal_Int32 nLen = strlen(pXmlHeader);
555 :
556 0 : uno::Sequence<sal_Int8> aFileStart(nLen);
557 0 : sal_Int32 nRead = xSourceStream->readBytes( aFileStart, nLen );
558 :
559 0 : if ( nRead != nLen || memcmp( aFileStart.getConstArray(), pXmlHeader, nLen ) != 0 )
560 : {
561 : // invalid - ignore stream, save normally
562 0 : xSourceStream.clear();
563 : }
564 : else
565 : {
566 : // keep track of the bytes already read
567 0 : nSourceStreamPos = nRead;
568 :
569 0 : const ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetModel())->GetSheetSaveData();
570 0 : if (pSheetData)
571 : {
572 : // add the loaded namespaces to the name space map
573 :
574 0 : if ( !pSheetData->AddLoadedNamespaces( _GetNamespaceMap() ) )
575 : {
576 : // conflicts in the namespaces - ignore the stream, save normally
577 0 : xSourceStream.clear();
578 : }
579 : }
580 0 : }
581 : }
582 0 : }
583 :
584 0 : sal_Int32 ScXMLExport::GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const
585 : {
586 0 : NumberFormatIndexMap::const_iterator itr = aNumFmtIndexMap.find(nNumFmt);
587 0 : if (itr == aNumFmtIndexMap.end())
588 0 : return -1;
589 :
590 0 : return itr->second;
591 : }
592 :
593 : namespace {
594 :
595 : /**
596 : * Update the progress bar state when an instance of this class goes out of
597 : * scope.
598 : */
599 : class ProgressBarUpdater
600 : {
601 : ProgressBarHelper& mrHelper;
602 : const sal_Int32& mrTableCount;
603 : const sal_Int32& mrShapesCount;
604 : const sal_Int32 mnCellCount;
605 : public:
606 : ProgressBarUpdater(ProgressBarHelper& rHelper,
607 : const sal_Int32& rTableCount, const sal_Int32& rShapesCount,
608 : const sal_Int32 nCellCount) :
609 : mrHelper(rHelper),
610 : mrTableCount(rTableCount),
611 : mrShapesCount(rShapesCount),
612 : mnCellCount(nCellCount) {}
613 :
614 : ~ProgressBarUpdater()
615 : {
616 : sal_Int32 nRef = mnCellCount + (2 * mrTableCount) + (2 * mrShapesCount);
617 : mrHelper.SetReference(nRef);
618 : mrHelper.SetValue(0);
619 : }
620 : };
621 :
622 : }
623 :
624 2 : void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount)
625 : {
626 2 : if (!GetModel().is())
627 : return;
628 :
629 2 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(GetModel(), uno::UNO_QUERY);
630 2 : if (!xSpreadDoc.is())
631 : return;
632 :
633 2 : uno::Reference<container::XIndexAccess> xIndex(xSpreadDoc->getSheets(), uno::UNO_QUERY);
634 2 : if (!xIndex.is())
635 : return;
636 :
637 2 : nTableCount = xIndex->getCount();
638 2 : if (!pSharedData)
639 2 : CreateSharedData(nTableCount);
640 :
641 2 : pCellStyles->AddNewTable(nTableCount - 1);
642 :
643 4 : for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
644 : {
645 2 : pDoc->GetNotes(nTable)->CreateAllNoteCaptions(nTable);
646 2 : nCurrentTable = sal::static_int_cast<sal_uInt16>(nTable);
647 2 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY);
648 2 : if (!xDrawPageSupplier.is())
649 0 : continue;
650 :
651 2 : uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage());
652 2 : ScMyDrawPage aDrawPage;
653 2 : aDrawPage.bHasForms = false;
654 2 : aDrawPage.xDrawPage.set(xDrawPage);
655 2 : pSharedData->AddDrawPage(aDrawPage, nTable);
656 2 : uno::Reference<container::XIndexAccess> xShapesIndex(xDrawPage, uno::UNO_QUERY);
657 2 : if (!xShapesIndex.is())
658 0 : continue;
659 :
660 2 : sal_Int32 nShapes = xShapesIndex->getCount();
661 2 : for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape)
662 : {
663 0 : uno::Reference<drawing::XShape> xShape(xShapesIndex->getByIndex(nShape), uno::UNO_QUERY);
664 0 : if (!xShape.is())
665 0 : continue;
666 :
667 0 : uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
668 0 : if (!xShapeProp.is())
669 0 : continue;
670 :
671 0 : sal_Int16 nLayerID = 0;
672 0 : bool bExtracted = xShapeProp->getPropertyValue(sLayerID) >>= nLayerID;
673 0 : if (!bExtracted)
674 0 : continue;
675 :
676 0 : if ((nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN))
677 : {
678 0 : CollectInternalShape(xShape);
679 0 : continue;
680 : }
681 :
682 0 : ++nShapesCount;
683 :
684 0 : SvxShape* pShapeImp = SvxShape::getImplementation(xShape);
685 0 : if (!pShapeImp)
686 0 : continue;
687 :
688 0 : SdrObject* pSdrObj = pShapeImp->GetSdrObject();
689 0 : if (!pSdrObj)
690 0 : continue;
691 :
692 0 : if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj))
693 : {
694 0 : ScMyShape aMyShape;
695 0 : aMyShape.aAddress = pAnchor->maStart;
696 0 : aMyShape.aEndAddress = pAnchor->maEnd;
697 0 : aMyShape.nEndX = pAnchor->maEndOffset.X();
698 0 : aMyShape.nEndY = pAnchor->maEndOffset.Y();
699 0 : aMyShape.xShape = xShape;
700 0 : pSharedData->AddNewShape(aMyShape);
701 0 : pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col());
702 0 : pSharedData->SetLastRow(nTable, pAnchor->maStart.Row());
703 : }
704 : else
705 0 : pSharedData->AddTableShape(nTable, xShape);
706 0 : }
707 4 : }
708 : }
709 :
710 2 : void ScXMLExport::CollectShapesAutoStyles(const sal_Int32 nTableCount)
711 : {
712 : // #i84077# To avoid compiler warnings about uninitialized aShapeItr,
713 : // it's initialized using this dummy list. The iterator contains shapes
714 : // from all sheets, so it can't be declared inside the nTable loop where
715 : // it is used.
716 2 : ScMyShapeList aDummyInitList;
717 :
718 2 : pSharedData->SortShapesContainer();
719 2 : pSharedData->SortNoteShapes();
720 2 : const ScMyShapeList* pShapeList(NULL);
721 2 : ScMyShapeList::const_iterator aShapeItr = aDummyInitList.end();
722 2 : if (pSharedData->GetShapesContainer())
723 : {
724 0 : pShapeList = pSharedData->GetShapesContainer()->GetShapes();
725 0 : aShapeItr = pShapeList->begin();
726 : }
727 2 : if (pSharedData->HasDrawPage())
728 : {
729 4 : for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
730 : {
731 2 : uno::Reference<drawing::XDrawPage> xDrawPage(pSharedData->GetDrawPage(nTable));
732 2 : uno::Reference<drawing::XShapes> xShapes (xDrawPage, uno::UNO_QUERY);
733 :
734 2 : if (xShapes.is())
735 : {
736 2 : GetShapeExport()->seekShapes(xShapes);
737 2 : uno::Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, uno::UNO_QUERY );
738 2 : if( xFormsSupplier.is() && xFormsSupplier->hasForms() )
739 : {
740 0 : GetFormExport()->examineForms(xDrawPage);
741 0 : pSharedData->SetDrawPageHasForms(nTable, true);
742 : }
743 2 : ScMyTableShapes* pTableShapes(pSharedData->GetTableShapes());
744 2 : if (pTableShapes)
745 : {
746 0 : ScMyTableXShapes::iterator aItr((*pTableShapes)[nTable].begin());
747 0 : ScMyTableXShapes::iterator aEndItr((*pTableShapes)[nTable].end());
748 0 : while (aItr != aEndItr)
749 : {
750 0 : GetShapeExport()->collectShapeAutoStyles(*aItr);
751 0 : IncrementProgressBar(false);
752 0 : ++aItr;
753 : }
754 : }
755 2 : if (pShapeList)
756 : {
757 0 : ScMyShapeList::const_iterator aEndItr(pShapeList->end());
758 0 : while (aShapeItr != aEndItr && (static_cast<sal_Int32>(aShapeItr->aAddress.Tab()) == nTable))
759 : {
760 0 : GetShapeExport()->collectShapeAutoStyles(aShapeItr->xShape);
761 0 : IncrementProgressBar(false);
762 0 : ++aShapeItr;
763 : }
764 : }
765 2 : const ScMyNoteShapeList* pNoteShapes = NULL;
766 2 : ScMyNoteShapeList::const_iterator aNoteShapeItr;
767 2 : ScMyNoteShapeList::const_iterator aNoteShapeEndItr;
768 2 : if (pSharedData->GetNoteShapes())
769 : {
770 0 : pNoteShapes = pSharedData->GetNoteShapes()->GetNotes();
771 0 : if (pNoteShapes)
772 : {
773 0 : aNoteShapeItr = pNoteShapes->begin();
774 0 : aNoteShapeEndItr = pNoteShapes->end();
775 : }
776 : }
777 2 : if (pNoteShapes)
778 : {
779 0 : while (aNoteShapeItr != aNoteShapeEndItr)
780 : {
781 0 : if (static_cast<sal_Int32>(aNoteShapeItr->aPos.Tab()) == nTable)
782 0 : GetShapeExport()->collectShapeAutoStyles(aNoteShapeItr->xShape);
783 0 : ++aNoteShapeItr;
784 : }
785 2 : }
786 : }
787 2 : }
788 : }
789 2 : pSharedData->SortNoteShapes(); // sort twice, because some more shapes are added
790 2 : }
791 :
792 2 : void ScXMLExport::_ExportMeta()
793 : {
794 2 : sal_Int32 nCellCount(pDoc ? pDoc->GetCellCount() : 0);
795 2 : sal_Int32 nTableCount(0);
796 2 : sal_Int32 nShapesCount(0);
797 2 : GetAutoStylePool()->ClearEntries();
798 2 : CollectSharedData(nTableCount, nShapesCount);
799 :
800 2 : uno::Sequence<beans::NamedValue> stats(3);
801 2 : stats[0] = beans::NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableCount")),
802 4 : uno::makeAny(nTableCount));
803 2 : stats[1] = beans::NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellCount")),
804 4 : uno::makeAny(nCellCount));
805 2 : stats[2] = beans::NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ObjectCount")),
806 4 : uno::makeAny(nShapesCount));
807 :
808 : // update document statistics at the model
809 2 : uno::Reference<document::XDocumentPropertiesSupplier> xPropSup(GetModel(),
810 2 : uno::UNO_QUERY_THROW);
811 : uno::Reference<document::XDocumentProperties> xDocProps(
812 2 : xPropSup->getDocumentProperties());
813 2 : if (xDocProps.is()) {
814 2 : xDocProps->setDocumentStatistics(stats);
815 : }
816 :
817 : // export document properties
818 2 : SvXMLExport::_ExportMeta();
819 2 : }
820 :
821 4 : void ScXMLExport::_ExportFontDecls()
822 : {
823 4 : GetFontAutoStylePool(); // make sure the pool is created
824 4 : SvXMLExport::_ExportFontDecls();
825 4 : }
826 :
827 4 : table::CellRangeAddress ScXMLExport::GetEndAddress(const uno::Reference<sheet::XSpreadsheet>& xTable, const sal_Int32 /* nTable */)
828 : {
829 4 : table::CellRangeAddress aCellAddress;
830 4 : uno::Reference<sheet::XSheetCellCursor> xCursor(xTable->createCursor());
831 4 : uno::Reference<sheet::XUsedAreaCursor> xUsedArea (xCursor, uno::UNO_QUERY);
832 4 : uno::Reference<sheet::XCellRangeAddressable> xCellAddress (xCursor, uno::UNO_QUERY);
833 4 : if (xUsedArea.is() && xCellAddress.is())
834 : {
835 4 : xUsedArea->gotoEndOfUsedArea(true);
836 4 : aCellAddress = xCellAddress->getRangeAddress();
837 : }
838 4 : return aCellAddress;
839 : }
840 :
841 2 : void ScXMLExport::GetAreaLinks( uno::Reference< sheet::XSpreadsheetDocument>& xSpreadDoc,
842 : ScMyAreaLinksContainer& rAreaLinks )
843 : {
844 2 : uno::Reference< beans::XPropertySet > xPropSet( xSpreadDoc, uno::UNO_QUERY );
845 4 : if( !xPropSet.is() ) return;
846 :
847 2 : uno::Reference< container::XIndexAccess > xLinksIAccess( xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_AREALINKS ) ) ), uno::UNO_QUERY);
848 2 : if( xLinksIAccess.is() )
849 : {
850 2 : const OUString sFilter( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_FILTER ) );
851 2 : const OUString sFilterOpt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_FILTOPT ) );
852 2 : const OUString sURL( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_LINKURL ) );
853 2 : const OUString sRefresh( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_REFDELAY ) );
854 :
855 2 : sal_Int32 nCount(xLinksIAccess->getCount());
856 2 : for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
857 : {
858 0 : uno::Reference< sheet::XAreaLink > xAreaLink(xLinksIAccess->getByIndex( nIndex ), uno::UNO_QUERY);
859 0 : if( xAreaLink.is() )
860 : {
861 0 : ScMyAreaLink aAreaLink;
862 0 : aAreaLink.aDestRange = xAreaLink->getDestArea();
863 0 : aAreaLink.sSourceStr = xAreaLink->getSourceArea();
864 0 : uno::Reference< beans::XPropertySet > xLinkProp( xAreaLink, uno::UNO_QUERY );
865 0 : if( xLinkProp.is() )
866 : {
867 0 : xLinkProp->getPropertyValue( sFilter ) >>= aAreaLink.sFilter;
868 0 : xLinkProp->getPropertyValue( sFilterOpt ) >>= aAreaLink.sFilterOptions;
869 0 : xLinkProp->getPropertyValue( sURL ) >>= aAreaLink.sURL;
870 0 : xLinkProp->getPropertyValue( sRefresh ) >>= aAreaLink.nRefresh;
871 : }
872 0 : rAreaLinks.AddNewAreaLink( aAreaLink );
873 : }
874 2 : }
875 : }
876 2 : rAreaLinks.Sort();
877 : }
878 :
879 : // core implementation
880 2 : void ScXMLExport::GetDetectiveOpList( ScMyDetectiveOpContainer& rDetOp )
881 : {
882 2 : if (pDoc)
883 : {
884 2 : ScDetOpList* pOpList(pDoc->GetDetOpList());
885 2 : if( pOpList )
886 : {
887 0 : size_t nCount = pOpList->Count();
888 0 : for (size_t nIndex = 0; nIndex < nCount; ++nIndex )
889 : {
890 0 : const ScDetOpData* pDetData = pOpList->GetObject( nIndex);
891 0 : if( pDetData )
892 : {
893 0 : const ScAddress& rDetPos = pDetData->GetPos();
894 0 : SCTAB nTab = rDetPos.Tab();
895 0 : if ( nTab < pDoc->GetTableCount() )
896 : {
897 0 : rDetOp.AddOperation( pDetData->GetOperation(), rDetPos, static_cast<sal_uInt32>( nIndex) );
898 :
899 : // cells with detective operations are written even if empty
900 0 : pSharedData->SetLastColumn( nTab, rDetPos.Col() );
901 0 : pSharedData->SetLastRow( nTab, rDetPos.Row() );
902 : }
903 : }
904 : }
905 0 : rDetOp.Sort();
906 : }
907 : }
908 2 : }
909 :
910 2 : void ScXMLExport::WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex,
911 : const sal_Int32 nIndex, const bool bIsAutoStyle, const bool bIsVisible)
912 : {
913 2 : CheckAttrList();
914 2 : AddAttribute(sAttrStyleName, *pColumnStyles->GetStyleNameByIndex(nStyleIndex));
915 2 : if (!bIsVisible)
916 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_COLLAPSE);
917 2 : if (nRepeatColumns > 1)
918 : {
919 0 : OUString sOUEndCol(OUString::valueOf(static_cast <sal_Int32> (nRepeatColumns)));
920 0 : AddAttribute(sAttrColumnsRepeated, sOUEndCol);
921 : }
922 2 : if (nIndex != -1)
923 2 : AddAttribute(XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME, *pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle));
924 2 : SvXMLElementExport aElemC(*this, sElemCol, true, true);
925 2 : }
926 :
927 2 : void ScXMLExport::WriteColumn(const sal_Int32 nColumn, const sal_Int32 nRepeatColumns,
928 : const sal_Int32 nStyleIndex, const bool bIsVisible)
929 : {
930 2 : sal_Int32 nRepeat(1);
931 2 : sal_Int32 nPrevIndex((*pDefaults->GetColDefaults())[nColumn].nIndex);
932 2 : bool bPrevAutoStyle((*pDefaults->GetColDefaults())[nColumn].bIsAutoStyle);
933 2 : for (sal_Int32 i = nColumn + 1; i < nColumn + nRepeatColumns; ++i)
934 : {
935 0 : if (((*pDefaults->GetColDefaults())[i].nIndex != nPrevIndex) ||
936 0 : ((*pDefaults->GetColDefaults())[i].bIsAutoStyle != bPrevAutoStyle))
937 : {
938 0 : WriteSingleColumn(nRepeat, nStyleIndex, nPrevIndex, bPrevAutoStyle, bIsVisible);
939 0 : nPrevIndex = (*pDefaults->GetColDefaults())[i].nIndex;
940 0 : bPrevAutoStyle = (*pDefaults->GetColDefaults())[i].bIsAutoStyle;
941 0 : nRepeat = 1;
942 : }
943 : else
944 0 : ++nRepeat;
945 : }
946 2 : WriteSingleColumn(nRepeat, nStyleIndex, nPrevIndex, bPrevAutoStyle, bIsVisible);
947 2 : }
948 :
949 0 : void ScXMLExport::OpenHeaderColumn()
950 : {
951 0 : StartElement( XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, true );
952 0 : }
953 :
954 0 : void ScXMLExport::CloseHeaderColumn()
955 : {
956 0 : EndElement(XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, true);
957 0 : }
958 :
959 2 : void ScXMLExport::ExportColumns(const sal_Int32 nTable, const table::CellRangeAddress& aColumnHeaderRange, const bool bHasColumnHeader)
960 : {
961 2 : sal_Int32 nColsRepeated (1);
962 2 : rtl::OUString sParent;
963 : sal_Int32 nIndex;
964 2 : sal_Int32 nPrevColumn(0);
965 2 : bool bPrevIsVisible (true);
966 2 : bool bWasHeader (false);
967 2 : bool bIsHeader (false);
968 2 : bool bIsClosed (true);
969 2 : sal_Int32 nPrevIndex (-1);
970 : sal_Int32 nColumn;
971 4 : for (nColumn = 0; nColumn <= pSharedData->GetLastColumn(nTable); ++nColumn)
972 : {
973 2 : CheckAttrList();
974 2 : bool bIsVisible(true);
975 2 : nIndex = pColumnStyles->GetStyleNameIndex(nTable, nColumn, bIsVisible);
976 :
977 2 : bIsHeader = bHasColumnHeader && (aColumnHeaderRange.StartColumn <= nColumn) && (nColumn <= aColumnHeaderRange.EndColumn);
978 2 : if (bIsHeader != bWasHeader)
979 : {
980 0 : if (bIsHeader)
981 : {
982 0 : if (nColumn > 0)
983 : {
984 0 : WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
985 0 : if (pGroupColumns->IsGroupEnd(nColumn - 1))
986 0 : pGroupColumns->CloseGroups(nColumn - 1);
987 : }
988 0 : bPrevIsVisible = bIsVisible;
989 0 : nPrevIndex = nIndex;
990 0 : nPrevColumn = nColumn;
991 0 : nColsRepeated = 1;
992 0 : if(pGroupColumns->IsGroupStart(nColumn))
993 0 : pGroupColumns->OpenGroups(nColumn);
994 0 : OpenHeaderColumn();
995 0 : bWasHeader = true;
996 0 : bIsClosed = false;
997 : }
998 : else
999 : {
1000 0 : WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
1001 0 : CloseHeaderColumn();
1002 0 : if (pGroupColumns->IsGroupEnd(nColumn - 1))
1003 0 : pGroupColumns->CloseGroups(nColumn - 1);
1004 0 : if(pGroupColumns->IsGroupStart(nColumn))
1005 0 : pGroupColumns->OpenGroups(nColumn);
1006 0 : bPrevIsVisible = bIsVisible;
1007 0 : nPrevIndex = nIndex;
1008 0 : nPrevColumn = nColumn;
1009 0 : nColsRepeated = 1;
1010 0 : bWasHeader = false;
1011 0 : bIsClosed = true;
1012 : }
1013 : }
1014 2 : else if (nColumn == 0)
1015 : {
1016 2 : if (pGroupColumns->IsGroupStart(nColumn))
1017 0 : pGroupColumns->OpenGroups(nColumn);
1018 2 : bPrevIsVisible = bIsVisible;
1019 2 : nPrevIndex = nIndex;
1020 : }
1021 0 : else if ((bIsVisible == bPrevIsVisible) && (nIndex == nPrevIndex) &&
1022 0 : !pGroupColumns->IsGroupStart(nColumn) && !pGroupColumns->IsGroupEnd(nColumn - 1))
1023 0 : ++nColsRepeated;
1024 : else
1025 : {
1026 0 : WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
1027 0 : if (pGroupColumns->IsGroupEnd(nColumn - 1))
1028 : {
1029 0 : if (bIsHeader)
1030 0 : CloseHeaderColumn();
1031 0 : pGroupColumns->CloseGroups(nColumn - 1);
1032 0 : if (bIsHeader)
1033 0 : OpenHeaderColumn();
1034 : }
1035 0 : if (pGroupColumns->IsGroupStart(nColumn))
1036 : {
1037 0 : if (bIsHeader)
1038 0 : CloseHeaderColumn();
1039 0 : pGroupColumns->OpenGroups(nColumn);
1040 0 : if (bIsHeader)
1041 0 : OpenHeaderColumn();
1042 : }
1043 0 : bPrevIsVisible = bIsVisible;
1044 0 : nPrevIndex = nIndex;
1045 0 : nPrevColumn = nColumn;
1046 0 : nColsRepeated = 1;
1047 : }
1048 : }
1049 2 : WriteColumn(nPrevColumn, nColsRepeated, nPrevIndex, bPrevIsVisible);
1050 2 : if (!bIsClosed)
1051 0 : CloseHeaderColumn();
1052 2 : if (pGroupColumns->IsGroupEnd(nColumn - 1))
1053 0 : pGroupColumns->CloseGroups(nColumn - 1);
1054 2 : }
1055 :
1056 2 : void ScXMLExport::ExportExternalRefCacheStyles()
1057 : {
1058 : sal_Int32 nEntryIndex = GetCellStylesPropertySetMapper()->FindEntryIndex(
1059 2 : "NumberFormat", XML_NAMESPACE_STYLE, OUString(RTL_CONSTASCII_USTRINGPARAM("data-style-name")));
1060 :
1061 2 : if (nEntryIndex < 0)
1062 : // No entry index for the number format is found.
1063 : return;
1064 :
1065 2 : ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
1066 2 : if (!pRefMgr->hasExternalData())
1067 : // No external reference data cached.
1068 : return;
1069 :
1070 : // Export each unique number format used in the external ref cache.
1071 0 : vector<sal_uInt32> aNumFmts;
1072 0 : pRefMgr->getAllCachedNumberFormats(aNumFmts);
1073 0 : const OUString aDefaultStyle = OUString(RTL_CONSTASCII_USTRINGPARAM("Default")).intern();
1074 0 : for (vector<sal_uInt32>::const_iterator itr = aNumFmts.begin(), itrEnd = aNumFmts.end();
1075 : itr != itrEnd; ++itr)
1076 : {
1077 0 : sal_Int32 nNumFmt = static_cast<sal_Int32>(*itr);
1078 :
1079 0 : addDataStyle(nNumFmt);
1080 :
1081 0 : uno::Any aVal;
1082 0 : aVal <<= nNumFmt;
1083 0 : vector<XMLPropertyState> aProps;
1084 0 : aProps.push_back(XMLPropertyState(nEntryIndex, aVal));
1085 0 : aVal <<= aDefaultStyle;
1086 0 : aProps.push_back(XMLPropertyState(nEntryIndex, aVal));
1087 :
1088 0 : OUString aName;
1089 : sal_Int32 nIndex;
1090 0 : if (GetAutoStylePool()->Add(aName, XML_STYLE_FAMILY_TABLE_CELL, aDefaultStyle, aProps))
1091 : {
1092 0 : OUString* pTemp(new OUString(aName));
1093 0 : if (!pCellStyles->AddStyleName(pTemp, nIndex, true))
1094 0 : delete pTemp;
1095 : }
1096 : else
1097 : {
1098 : bool bIsAuto;
1099 : nIndex = pCellStyles->GetIndexOfStyleName(
1100 0 : aName, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX)), bIsAuto);
1101 : }
1102 :
1103 : // store the number format to index mapping for later use.
1104 0 : aNumFmtIndexMap.insert(NumberFormatIndexMap::value_type(nNumFmt, nIndex));
1105 0 : }
1106 : }
1107 :
1108 4 : void ScXMLExport::WriteRowContent()
1109 : {
1110 4 : ScMyRowFormatRange aRange;
1111 4 : sal_Int32 nIndex(-1);
1112 : #if OSL_DEBUG_LEVEL > 0
1113 : sal_Int32 nPrevCol(0);
1114 : #endif
1115 4 : sal_Int32 nCols(0);
1116 4 : sal_Int32 nPrevValidationIndex(-1);
1117 4 : bool bIsAutoStyle(true);
1118 4 : bool bIsFirst(true);
1119 8 : while (pRowFormatRanges->GetNext(aRange))
1120 : {
1121 : #if OSL_DEBUG_LEVEL > 0
1122 : OSL_ENSURE(bIsFirst || (!bIsFirst && (nPrevCol + nCols == aRange.nStartColumn)), "here are some columns missing");
1123 : #endif
1124 0 : if (bIsFirst)
1125 : {
1126 0 : nIndex = aRange.nIndex;
1127 0 : nPrevValidationIndex = aRange.nValidationIndex;
1128 0 : bIsAutoStyle = aRange.bIsAutoStyle;
1129 0 : nCols = aRange.nRepeatColumns;
1130 0 : bIsFirst = false;
1131 : #if OSL_DEBUG_LEVEL > 0
1132 : nPrevCol = aRange.nStartColumn;
1133 : #endif
1134 : }
1135 : else
1136 : {
1137 0 : if (((aRange.nIndex == nIndex && aRange.bIsAutoStyle == bIsAutoStyle) ||
1138 : (aRange.nIndex == nIndex && nIndex == -1)) &&
1139 : nPrevValidationIndex == aRange.nValidationIndex)
1140 0 : nCols += aRange.nRepeatColumns;
1141 : else
1142 : {
1143 0 : if (nIndex != -1)
1144 0 : AddAttribute(sAttrStyleName, *pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle));
1145 0 : if (nPrevValidationIndex > -1)
1146 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(nPrevValidationIndex));
1147 0 : if (nCols > 1)
1148 : {
1149 0 : rtl::OUStringBuffer aBuf;
1150 0 : ::sax::Converter::convertNumber(aBuf, nCols);
1151 0 : AddAttribute(sAttrColumnsRepeated, aBuf.makeStringAndClear());
1152 : }
1153 0 : SvXMLElementExport aElemC(*this, sElemCell, true, true);
1154 0 : nIndex = aRange.nIndex;
1155 0 : bIsAutoStyle = aRange.bIsAutoStyle;
1156 0 : nCols = aRange.nRepeatColumns;
1157 0 : nPrevValidationIndex = aRange.nValidationIndex;
1158 : #if OSL_DEBUG_LEVEL > 0
1159 : nPrevCol = aRange.nStartColumn;
1160 : #endif
1161 : }
1162 : }
1163 : }
1164 4 : if (!bIsFirst)
1165 : {
1166 0 : table::CellAddress aCellAddress;
1167 0 : if (nIndex != -1)
1168 0 : AddAttribute(sAttrStyleName, *pCellStyles->GetStyleNameByIndex(nIndex, bIsAutoStyle));
1169 0 : if (nPrevValidationIndex > -1)
1170 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(nPrevValidationIndex));
1171 0 : if (nCols > 1)
1172 : {
1173 0 : rtl::OUStringBuffer aBuf;
1174 0 : ::sax::Converter::convertNumber(aBuf, nCols);
1175 0 : AddAttribute(sAttrColumnsRepeated, aBuf.makeStringAndClear());
1176 : }
1177 0 : SvXMLElementExport aElemC(*this, sElemCell, true, true);
1178 : }
1179 4 : }
1180 :
1181 2 : void ScXMLExport::WriteRowStartTag(
1182 : sal_Int32 nRow, const sal_Int32 nIndex, const sal_Int32 nEqualRows,
1183 : bool bHidden, bool bFiltered)
1184 : {
1185 2 : AddAttribute(sAttrStyleName, *pRowStyles->GetStyleNameByIndex(nIndex));
1186 2 : if (bHidden)
1187 : {
1188 0 : if (bFiltered)
1189 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_FILTER);
1190 : else
1191 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_VISIBILITY, XML_COLLAPSE);
1192 : }
1193 2 : if (nEqualRows > 1)
1194 : {
1195 0 : rtl::OUStringBuffer aBuf;
1196 0 : ::sax::Converter::convertNumber(aBuf, nEqualRows);
1197 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aBuf.makeStringAndClear());
1198 : }
1199 :
1200 2 : const ScMyDefaultStyleList& rRowDefaults = *pDefaults->GetRowDefaults();
1201 2 : if ( nRow >= sal::static_int_cast<sal_Int32>( rRowDefaults.size() ) )
1202 : {
1203 : // used to happen with detective operations - if there are more cases, use the last row's style
1204 : OSL_FAIL("WriteRowStartTag: not enough defaults");
1205 0 : nRow = rRowDefaults.size() - 1;
1206 : }
1207 2 : sal_Int32 nCellStyleIndex(rRowDefaults[nRow].nIndex);
1208 2 : if (nCellStyleIndex != -1)
1209 : AddAttribute(XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME,
1210 : *pCellStyles->GetStyleNameByIndex(nCellStyleIndex,
1211 0 : (*pDefaults->GetRowDefaults())[nRow].bIsAutoStyle));
1212 2 : StartElement( sElemRow, true);
1213 2 : }
1214 :
1215 0 : void ScXMLExport::OpenHeaderRows()
1216 : {
1217 0 : StartElement( XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, true);
1218 0 : bRowHeaderOpen = true;
1219 0 : }
1220 :
1221 0 : void ScXMLExport::CloseHeaderRows()
1222 : {
1223 0 : EndElement(XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, true);
1224 0 : }
1225 :
1226 2 : void ScXMLExport::OpenNewRow(
1227 : const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEqualRows,
1228 : bool bHidden, bool bFiltered)
1229 : {
1230 2 : nOpenRow = nStartRow;
1231 2 : if (pGroupRows->IsGroupStart(nStartRow))
1232 : {
1233 0 : if (bHasRowHeader && bRowHeaderOpen)
1234 0 : CloseHeaderRows();
1235 0 : pGroupRows->OpenGroups(nStartRow);
1236 0 : if (bHasRowHeader && bRowHeaderOpen)
1237 0 : OpenHeaderRows();
1238 : }
1239 2 : if (bHasRowHeader && !bRowHeaderOpen && nStartRow >= aRowHeaderRange.StartRow && nStartRow <= aRowHeaderRange.EndRow)
1240 : {
1241 0 : if (nStartRow == aRowHeaderRange.StartRow)
1242 0 : OpenHeaderRows();
1243 : sal_Int32 nEquals;
1244 0 : if (aRowHeaderRange.EndRow < nStartRow + nEqualRows - 1)
1245 0 : nEquals = aRowHeaderRange.EndRow - nStartRow + 1;
1246 : else
1247 0 : nEquals = nEqualRows;
1248 0 : WriteRowStartTag(nStartRow, nIndex, nEquals, bHidden, bFiltered);
1249 0 : nOpenRow = nStartRow + nEquals - 1;
1250 0 : if (nEquals < nEqualRows)
1251 : {
1252 0 : CloseRow(nStartRow + nEquals - 1);
1253 0 : WriteRowStartTag(nStartRow, nIndex, nEqualRows - nEquals, bHidden, bFiltered);
1254 0 : nOpenRow = nStartRow + nEqualRows - 1;
1255 0 : }
1256 : }
1257 : else
1258 2 : WriteRowStartTag(nStartRow, nIndex, nEqualRows, bHidden, bFiltered);
1259 2 : }
1260 :
1261 0 : void ScXMLExport::OpenAndCloseRow(
1262 : const sal_Int32 nIndex, const sal_Int32 nStartRow, const sal_Int32 nEqualRows,
1263 : bool bHidden, bool bFiltered)
1264 : {
1265 0 : OpenNewRow(nIndex, nStartRow, nEqualRows, bHidden, bFiltered);
1266 0 : WriteRowContent();
1267 0 : CloseRow(nStartRow + nEqualRows - 1);
1268 0 : pRowFormatRanges->Clear();
1269 0 : }
1270 :
1271 2 : void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, const sal_Int32 nRepeatRow, ScXMLCachedRowAttrAccess& rRowAttr)
1272 : {
1273 2 : if (nRepeatRow > 1)
1274 : {
1275 0 : sal_Int32 nPrevIndex(0), nIndex;
1276 0 : bool bPrevHidden = false;
1277 0 : bool bPrevFiltered = false;
1278 0 : bool bHidden = false;
1279 0 : bool bFiltered = false;
1280 0 : sal_Int32 nEqualRows(1);
1281 0 : sal_Int32 nEndRow(nStartRow + nRepeatRow);
1282 : sal_Int32 nRow;
1283 0 : for (nRow = nStartRow; nRow < nEndRow; ++nRow)
1284 : {
1285 0 : if (nRow == nStartRow)
1286 : {
1287 0 : nPrevIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
1288 0 : if (pDoc)
1289 : {
1290 0 : bPrevHidden = rRowAttr.rowHidden(nTable, nRow);
1291 0 : bPrevFiltered = rRowAttr.rowFiltered(nTable, nRow);
1292 : }
1293 : }
1294 : else
1295 : {
1296 0 : nIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
1297 0 : if (pDoc)
1298 : {
1299 0 : bHidden = rRowAttr.rowHidden(nTable, nRow);
1300 0 : bFiltered = rRowAttr.rowFiltered(nTable, nRow);
1301 : }
1302 0 : if (nIndex == nPrevIndex && bHidden == bPrevHidden && bFiltered == bPrevFiltered &&
1303 0 : !(bHasRowHeader && ((nRow == aRowHeaderRange.StartRow) || (nRow - 1 == aRowHeaderRange.EndRow))) &&
1304 0 : !(pGroupRows->IsGroupStart(nRow)) &&
1305 0 : !(pGroupRows->IsGroupEnd(nRow - 1)))
1306 0 : ++nEqualRows;
1307 : else
1308 : {
1309 0 : if (nRow < nEndRow)
1310 : {
1311 0 : ScRowFormatRanges* pTempRowFormatRanges = new ScRowFormatRanges(pRowFormatRanges);
1312 0 : OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
1313 0 : delete pRowFormatRanges;
1314 0 : pRowFormatRanges = pTempRowFormatRanges;
1315 : }
1316 : else
1317 0 : OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
1318 0 : nEqualRows = 1;
1319 0 : nPrevIndex = nIndex;
1320 0 : bPrevHidden = bHidden;
1321 0 : bPrevFiltered = bFiltered;
1322 : }
1323 : }
1324 : }
1325 0 : OpenNewRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered);
1326 : }
1327 : else
1328 : {
1329 2 : sal_Int32 nIndex = pRowStyles->GetStyleNameIndex(nTable, nStartRow);
1330 2 : bool bHidden = false;
1331 2 : bool bFiltered = false;
1332 2 : if (pDoc)
1333 : {
1334 2 : bHidden = rRowAttr.rowHidden(nTable, nStartRow);
1335 2 : bFiltered = rRowAttr.rowFiltered(nTable, nStartRow);
1336 : }
1337 2 : OpenNewRow(nIndex, nStartRow, 1, bHidden, bFiltered);
1338 : }
1339 2 : nOpenRow = nStartRow + nRepeatRow - 1;
1340 2 : }
1341 :
1342 2 : void ScXMLExport::CloseRow(const sal_Int32 nRow)
1343 : {
1344 2 : if (nOpenRow > -1)
1345 : {
1346 2 : EndElement(sElemRow, true);
1347 2 : if (bHasRowHeader && nRow == aRowHeaderRange.EndRow)
1348 : {
1349 0 : CloseHeaderRows();
1350 0 : bRowHeaderOpen = false;
1351 : }
1352 2 : if (pGroupRows->IsGroupEnd(nRow))
1353 : {
1354 0 : if (bHasRowHeader && bRowHeaderOpen)
1355 0 : CloseHeaderRows();
1356 0 : pGroupRows->CloseGroups(nRow);
1357 0 : if (bHasRowHeader && bRowHeaderOpen)
1358 0 : OpenHeaderRows();
1359 : }
1360 : }
1361 2 : nOpenRow = -1;
1362 2 : }
1363 :
1364 4 : void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
1365 : const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet)
1366 : {
1367 4 : pRowFormatRanges->Clear();
1368 4 : ScXMLCachedRowAttrAccess aRowAttr(pDoc);
1369 4 : if (nStartRow == nEndRow)
1370 : {
1371 4 : pCellStyles->GetFormatRanges(nStartCol, nEndCol, nStartRow, nSheet, pRowFormatRanges);
1372 4 : if (nOpenRow == - 1)
1373 2 : OpenRow(nSheet, nStartRow, 1, aRowAttr);
1374 4 : WriteRowContent();
1375 4 : pRowFormatRanges->Clear();
1376 : }
1377 : else
1378 : {
1379 0 : if (nOpenRow > -1)
1380 : {
1381 0 : pCellStyles->GetFormatRanges(nStartCol, pSharedData->GetLastColumn(nSheet), nStartRow, nSheet, pRowFormatRanges);
1382 0 : WriteRowContent();
1383 0 : CloseRow(nStartRow);
1384 0 : sal_Int32 nRows(1);
1385 0 : sal_Int32 nTotalRows(nEndRow - nStartRow + 1 - 1);
1386 0 : while (nRows < nTotalRows)
1387 : {
1388 0 : pRowFormatRanges->Clear();
1389 0 : pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
1390 0 : sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows();
1391 : OSL_ENSURE(nMaxRows, "something wents wrong");
1392 0 : if (nMaxRows >= nTotalRows - nRows)
1393 : {
1394 0 : OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows, aRowAttr);
1395 0 : nRows += nTotalRows - nRows;
1396 : }
1397 : else
1398 : {
1399 0 : OpenRow(nSheet, nStartRow + nRows, nMaxRows, aRowAttr);
1400 0 : nRows += nMaxRows;
1401 : }
1402 0 : if (!pRowFormatRanges->GetSize())
1403 0 : pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
1404 0 : WriteRowContent();
1405 0 : CloseRow(nStartRow + nRows - 1);
1406 : }
1407 0 : if (nTotalRows == 1)
1408 0 : CloseRow(nStartRow);
1409 0 : OpenRow(nSheet, nEndRow, 1, aRowAttr);
1410 0 : pRowFormatRanges->Clear();
1411 0 : pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges);
1412 0 : WriteRowContent();
1413 : }
1414 : else
1415 : {
1416 0 : sal_Int32 nRows(0);
1417 0 : sal_Int32 nTotalRows(nEndRow - nStartRow + 1 - 1);
1418 0 : while (nRows < nTotalRows)
1419 : {
1420 0 : pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
1421 0 : sal_Int32 nMaxRows = pRowFormatRanges->GetMaxRows();
1422 0 : if (nMaxRows >= nTotalRows - nRows)
1423 : {
1424 0 : OpenRow(nSheet, nStartRow + nRows, nTotalRows - nRows, aRowAttr);
1425 0 : nRows += nTotalRows - nRows;
1426 : }
1427 : else
1428 : {
1429 0 : OpenRow(nSheet, nStartRow + nRows, nMaxRows, aRowAttr);
1430 0 : nRows += nMaxRows;
1431 : }
1432 0 : if (!pRowFormatRanges->GetSize())
1433 0 : pCellStyles->GetFormatRanges(0, pSharedData->GetLastColumn(nSheet), nStartRow + nRows, nSheet, pRowFormatRanges);
1434 0 : WriteRowContent();
1435 0 : CloseRow(nStartRow + nRows - 1);
1436 : }
1437 0 : OpenRow(nSheet, nEndRow, 1, aRowAttr);
1438 0 : pRowFormatRanges->Clear();
1439 0 : pCellStyles->GetFormatRanges(0, nEndCol, nEndRow, nSheet, pRowFormatRanges);
1440 0 : WriteRowContent();
1441 : }
1442 : }
1443 4 : }
1444 :
1445 2 : void ScXMLExport::GetColumnRowHeader(bool& rHasColumnHeader, table::CellRangeAddress& rColumnHeaderRange,
1446 : bool& rHasRowHeader, table::CellRangeAddress& rRowHeaderRange,
1447 : rtl::OUString& rPrintRanges) const
1448 : {
1449 2 : uno::Reference <sheet::XPrintAreas> xPrintAreas (xCurrentTable, uno::UNO_QUERY);
1450 2 : if (xPrintAreas.is())
1451 : {
1452 2 : rHasRowHeader = xPrintAreas->getPrintTitleRows();
1453 2 : rHasColumnHeader = xPrintAreas->getPrintTitleColumns();
1454 2 : rRowHeaderRange = xPrintAreas->getTitleRows();
1455 2 : rColumnHeaderRange = xPrintAreas->getTitleColumns();
1456 2 : uno::Sequence< table::CellRangeAddress > aRangeList( xPrintAreas->getPrintAreas() );
1457 2 : ScRangeStringConverter::GetStringFromRangeList( rPrintRanges, aRangeList, pDoc, FormulaGrammar::CONV_OOO );
1458 2 : }
1459 2 : }
1460 :
1461 0 : void ScXMLExport::FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRowGroup* pGroups)
1462 : {
1463 0 : size_t nDepth = pFields->GetDepth();
1464 0 : for (size_t i = 0; i < nDepth; ++i)
1465 : {
1466 0 : size_t nFields = pFields->GetCount(i);
1467 0 : for (size_t j = 0; j < nFields; ++j)
1468 : {
1469 0 : ScMyColumnRowGroup aGroup;
1470 0 : const ScOutlineEntry* pEntry = pFields->GetEntry(i, j);
1471 0 : aGroup.nField = pEntry->GetStart();
1472 0 : aGroup.nLevel = static_cast<sal_Int16>(i);
1473 0 : aGroup.bDisplay = !(pEntry->IsHidden());
1474 0 : pGroups->AddGroup(aGroup, pEntry->GetEnd());
1475 : }
1476 : }
1477 0 : if (nDepth)
1478 0 : pGroups->Sort();
1479 0 : }
1480 :
1481 2 : void ScXMLExport::FillColumnRowGroups()
1482 : {
1483 2 : if (pDoc)
1484 : {
1485 2 : ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable( static_cast<SCTAB>(nCurrentTable), false );
1486 2 : if(pOutlineTable)
1487 : {
1488 0 : ScOutlineArray* pCols(pOutlineTable->GetColArray());
1489 0 : ScOutlineArray* pRows(pOutlineTable->GetRowArray());
1490 0 : if (pCols)
1491 0 : FillFieldGroup(pCols, pGroupColumns);
1492 0 : if (pRows)
1493 0 : FillFieldGroup(pRows, pGroupRows);
1494 0 : pSharedData->SetLastColumn(nCurrentTable, pGroupColumns->GetLast());
1495 0 : pSharedData->SetLastRow(nCurrentTable, pGroupRows->GetLast());
1496 : }
1497 : }
1498 2 : }
1499 :
1500 2 : void ScXMLExport::SetBodyAttributes()
1501 : {
1502 2 : if (pDoc && pDoc->IsDocProtected())
1503 : {
1504 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_STRUCTURE_PROTECTED, XML_TRUE);
1505 0 : rtl::OUStringBuffer aBuffer;
1506 0 : uno::Sequence<sal_Int8> aPassHash;
1507 0 : ScPasswordHash eHashUsed = PASSHASH_UNSPECIFIED;
1508 0 : const ScDocProtection* p = pDoc->GetDocProtection();
1509 0 : if (p)
1510 : {
1511 0 : if (p->hasPasswordHash(PASSHASH_SHA1))
1512 : {
1513 0 : aPassHash = p->getPasswordHash(PASSHASH_SHA1);
1514 0 : eHashUsed = PASSHASH_SHA1;
1515 : }
1516 0 : else if (p->hasPasswordHash(PASSHASH_XL, PASSHASH_SHA1))
1517 : {
1518 0 : aPassHash = p->getPasswordHash(PASSHASH_XL, PASSHASH_SHA1);
1519 0 : eHashUsed = PASSHASH_XL;
1520 : }
1521 : }
1522 0 : ::sax::Converter::encodeBase64(aBuffer, aPassHash);
1523 0 : if (aBuffer.getLength())
1524 : {
1525 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear());
1526 0 : if ( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
1527 : {
1528 0 : if (eHashUsed == PASSHASH_XL)
1529 : {
1530 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
1531 0 : ScPassHashHelper::getHashURI(PASSHASH_XL));
1532 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
1533 0 : ScPassHashHelper::getHashURI(PASSHASH_SHA1));
1534 : }
1535 0 : else if (eHashUsed == PASSHASH_SHA1)
1536 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
1537 0 : ScPassHashHelper::getHashURI(PASSHASH_SHA1));
1538 : }
1539 0 : }
1540 : }
1541 2 : }
1542 :
1543 0 : static bool lcl_CopyStreamElement( const uno::Reference< io::XInputStream >& xInput,
1544 : const uno::Reference< io::XOutputStream >& xOutput,
1545 : sal_Int32 nCount )
1546 : {
1547 0 : const sal_Int32 nBufSize = 16*1024;
1548 0 : uno::Sequence<sal_Int8> aSequence(nBufSize);
1549 :
1550 0 : sal_Int32 nRemaining = nCount;
1551 0 : bool bFirst = true;
1552 :
1553 0 : while ( nRemaining > 0 )
1554 : {
1555 0 : sal_Int32 nRead = xInput->readBytes( aSequence, std::min( nRemaining, nBufSize ) );
1556 0 : if (bFirst)
1557 : {
1558 : // safety check: Make sure the copied part actually points to the start of an element
1559 0 : if ( nRead < 1 || aSequence[0] != static_cast<sal_Int8>('<') )
1560 : {
1561 0 : return false; // abort and set an error
1562 : }
1563 0 : bFirst = false;
1564 : }
1565 0 : if (nRead == nRemaining)
1566 : {
1567 : // safety check: Make sure the copied part also ends at the end of an element
1568 0 : if ( aSequence[nRead-1] != static_cast<sal_Int8>('>') )
1569 : {
1570 0 : return false; // abort and set an error
1571 : }
1572 : }
1573 :
1574 0 : if ( nRead == nBufSize )
1575 : {
1576 0 : xOutput->writeBytes( aSequence );
1577 0 : nRemaining -= nRead;
1578 : }
1579 : else
1580 : {
1581 0 : if ( nRead > 0 )
1582 : {
1583 0 : uno::Sequence<sal_Int8> aTempBuf( aSequence.getConstArray(), nRead );
1584 0 : xOutput->writeBytes( aTempBuf );
1585 : }
1586 0 : nRemaining = 0;
1587 : }
1588 : }
1589 0 : return true; // successful
1590 : }
1591 :
1592 0 : static void lcl_SkipBytesInBlocks( const uno::Reference< io::XInputStream >& xInput, sal_Int32 nBytesToSkip )
1593 : {
1594 : // skipBytes in zip stream is implemented as reading.
1595 : // For now, split into several calls to avoid allocating a large buffer.
1596 : // Later, skipBytes should be changed.
1597 :
1598 0 : const sal_Int32 nMaxSize = 32*1024;
1599 :
1600 0 : if ( nBytesToSkip > 0 )
1601 : {
1602 0 : sal_Int32 nRemaining = nBytesToSkip;
1603 0 : while ( nRemaining > 0 )
1604 : {
1605 0 : sal_Int32 nSkip = std::min( nRemaining, nMaxSize );
1606 0 : xInput->skipBytes( nSkip );
1607 0 : nRemaining -= nSkip;
1608 : }
1609 : }
1610 0 : }
1611 :
1612 0 : void ScXMLExport::CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset, sal_Int32& rNewStart, sal_Int32& rNewEnd )
1613 : {
1614 0 : uno::Reference<xml::sax::XDocumentHandler> xHandler = GetDocHandler();
1615 0 : uno::Reference<io::XActiveDataSource> xDestSource( xHandler, uno::UNO_QUERY );
1616 0 : if ( xDestSource.is() )
1617 : {
1618 0 : uno::Reference<io::XOutputStream> xDestStream = xDestSource->getOutputStream();
1619 0 : uno::Reference<io::XSeekable> xDestSeek( xDestStream, uno::UNO_QUERY );
1620 0 : if ( xDestSeek.is() )
1621 : {
1622 : // temporary: set same stream again to clear buffer
1623 0 : xDestSource->setOutputStream( xDestStream );
1624 :
1625 0 : if ( getExportFlags() & EXPORT_PRETTY )
1626 : {
1627 0 : const rtl::OString aOutStr("\n ");
1628 0 : uno::Sequence<sal_Int8> aOutSeq( (sal_Int8*)aOutStr.getStr(), aOutStr.getLength() );
1629 0 : xDestStream->writeBytes( aOutSeq );
1630 : }
1631 :
1632 0 : rNewStart = (sal_Int32)xDestSeek->getPosition();
1633 :
1634 0 : if ( nStartOffset > nSourceStreamPos )
1635 0 : lcl_SkipBytesInBlocks( xSourceStream, nStartOffset - nSourceStreamPos );
1636 :
1637 0 : if ( !lcl_CopyStreamElement( xSourceStream, xDestStream, nEndOffset - nStartOffset ) )
1638 : {
1639 : // If copying went wrong, set an error.
1640 : // ScXMLImportWrapper then resets all stream flags, so the next save attempt will use normal saving.
1641 :
1642 0 : uno::Sequence<OUString> aEmptySeq;
1643 0 : SetError(XMLERROR_CANCEL|XMLERROR_FLAG_SEVERE, aEmptySeq);
1644 : }
1645 0 : nSourceStreamPos = nEndOffset;
1646 :
1647 0 : rNewEnd = (sal_Int32)xDestSeek->getPosition();
1648 0 : }
1649 0 : }
1650 0 : }
1651 :
1652 2 : void ScXMLExport::_ExportContent()
1653 : {
1654 2 : nCurrentTable = 0;
1655 2 : if (!pSharedData)
1656 : {
1657 0 : sal_Int32 nTableCount(0);
1658 0 : sal_Int32 nShapesCount(0);
1659 0 : CollectSharedData(nTableCount, nShapesCount);
1660 : OSL_FAIL("no shared data setted");
1661 : }
1662 2 : ScXMLExportDatabaseRanges aExportDatabaseRanges(*this);
1663 2 : if (!GetModel().is())
1664 : return;
1665 :
1666 2 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
1667 2 : if ( !xSpreadDoc.is() )
1668 : return;
1669 :
1670 2 : ScSheetSaveData* pSheetData = ScModelObj::getImplementation(xSpreadDoc)->GetSheetSaveData();
1671 2 : if (pSheetData)
1672 2 : pSheetData->ResetSaveEntries();
1673 :
1674 2 : uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
1675 2 : if ( xIndex.is() )
1676 : {
1677 : //_GetNamespaceMap().ClearQNamesCache();
1678 2 : pChangeTrackingExportHelper->CollectAndWriteChanges();
1679 2 : WriteCalculationSettings(xSpreadDoc);
1680 2 : sal_Int32 nTableCount(xIndex->getCount());
1681 2 : ScMyAreaLinksContainer aAreaLinks;
1682 2 : GetAreaLinks( xSpreadDoc, aAreaLinks );
1683 2 : ScMyEmptyDatabaseRangesContainer aEmptyRanges(aExportDatabaseRanges.GetEmptyDatabaseRanges());
1684 2 : ScMyDetectiveOpContainer aDetectiveOpContainer;
1685 2 : GetDetectiveOpList( aDetectiveOpContainer );
1686 :
1687 2 : pCellStyles->Sort();
1688 2 : pMergedRangesContainer->Sort();
1689 2 : pSharedData->GetDetectiveObjContainer()->Sort();
1690 :
1691 2 : pCellsItr->Clear();
1692 2 : pCellsItr->SetShapes( pSharedData->GetShapesContainer() );
1693 2 : pCellsItr->SetNoteShapes( pSharedData->GetNoteShapes() );
1694 2 : pCellsItr->SetMergedRanges( pMergedRangesContainer );
1695 2 : pCellsItr->SetAreaLinks( &aAreaLinks );
1696 2 : pCellsItr->SetEmptyDatabaseRanges( &aEmptyRanges );
1697 2 : pCellsItr->SetDetectiveObj( pSharedData->GetDetectiveObjContainer() );
1698 2 : pCellsItr->SetDetectiveOp( &aDetectiveOpContainer );
1699 :
1700 2 : if (nTableCount > 0)
1701 2 : pValidationsContainer->WriteValidations(*this);
1702 2 : WriteTheLabelRanges( xSpreadDoc );
1703 4 : for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable)
1704 : {
1705 2 : sal_Int32 nStartOffset = -1;
1706 2 : sal_Int32 nEndOffset = -1;
1707 2 : if (pSheetData && pDoc && pDoc->IsStreamValid((SCTAB)nTable) && !pDoc->GetChangeTrack())
1708 0 : pSheetData->GetStreamPos( nTable, nStartOffset, nEndOffset );
1709 :
1710 2 : if ( nStartOffset >= 0 && nEndOffset >= 0 && xSourceStream.is() )
1711 : {
1712 0 : sal_Int32 nNewStart = -1;
1713 0 : sal_Int32 nNewEnd = -1;
1714 0 : CopySourceStream( nStartOffset, nEndOffset, nNewStart, nNewEnd );
1715 :
1716 : // store position of copied sheet in output
1717 0 : pSheetData->AddSavePos( nTable, nNewStart, nNewEnd );
1718 :
1719 : // skip iterator entries for this sheet
1720 0 : pCellsItr->SkipTable(static_cast<SCTAB>(nTable));
1721 : }
1722 : else
1723 : {
1724 2 : uno::Reference<sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
1725 2 : WriteTable(nTable, xTable);
1726 : }
1727 2 : IncrementProgressBar(false);
1728 2 : }
1729 : }
1730 2 : WriteExternalRefCaches();
1731 2 : WriteNamedExpressions();
1732 2 : aExportDatabaseRanges.WriteDatabaseRanges();
1733 2 : ScXMLExportDataPilot aExportDataPilot(*this);
1734 2 : aExportDataPilot.WriteDataPilots(xSpreadDoc);
1735 2 : WriteConsolidation();
1736 2 : ScXMLExportDDELinks aExportDDELinks(*this);
1737 2 : aExportDDELinks.WriteDDELinks(xSpreadDoc);
1738 2 : IncrementProgressBar(true, 0);
1739 2 : GetProgressBarHelper()->SetValue(GetProgressBarHelper()->GetReference());
1740 : }
1741 :
1742 2 : void ScXMLExport::_ExportStyles( sal_Bool bUsed )
1743 : {
1744 2 : if (!pSharedData)
1745 : {
1746 0 : sal_Int32 nTableCount(0);
1747 0 : sal_Int32 nShapesCount(0);
1748 0 : CollectSharedData(nTableCount, nShapesCount);
1749 : }
1750 2 : ScXMLStyleExport aStylesExp(*this, rtl::OUString(), GetAutoStylePool().get());
1751 2 : if (GetModel().is())
1752 : {
1753 2 : uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
1754 2 : if (xMultiServiceFactory.is())
1755 : {
1756 2 : uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.Defaults"))), uno::UNO_QUERY);
1757 2 : if (xProperties.is())
1758 2 : aStylesExp.exportDefaultStyle(xProperties, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)), xCellStylesExportPropertySetMapper);
1759 2 : if (pSharedData->HasShapes())
1760 : {
1761 0 : GetShapeExport()->ExportGraphicDefaults();
1762 2 : }
1763 : }
1764 2 : uno::Reference <style::XStyleFamiliesSupplier> xStyleFamiliesSupplier (GetModel(), uno::UNO_QUERY);
1765 2 : if (xStyleFamiliesSupplier.is())
1766 : {
1767 2 : uno::Reference <container::XNameAccess> xStylesFamilies(xStyleFamiliesSupplier->getStyleFamilies());
1768 2 : if (xStylesFamilies.is())
1769 : {
1770 2 : uno::Reference <container::XIndexAccess> xCellStyles(xStylesFamilies->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles"))), uno::UNO_QUERY);
1771 2 : if (xCellStyles.is())
1772 : {
1773 2 : sal_Int32 nCount(xCellStyles->getCount());
1774 2 : rtl::OUString sNumberFormat(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT));
1775 12 : for (sal_Int32 i = 0; i < nCount; ++i)
1776 : {
1777 10 : uno::Reference <beans::XPropertySet> xCellProperties(xCellStyles->getByIndex(i), uno::UNO_QUERY);
1778 10 : if (xCellProperties.is())
1779 : {
1780 10 : sal_Int32 nNumberFormat = 0;
1781 10 : if (xCellProperties->getPropertyValue(sNumberFormat) >>= nNumberFormat)
1782 10 : addDataStyle(nNumberFormat);
1783 : }
1784 12 : }
1785 2 : }
1786 2 : }
1787 2 : }
1788 : }
1789 2 : exportDataStyles();
1790 :
1791 : aStylesExp.exportStyleFamily(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles")),
1792 2 : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)), xCellStylesExportPropertySetMapper, false, XML_STYLE_FAMILY_TABLE_CELL);
1793 :
1794 2 : SvXMLExport::_ExportStyles(bUsed);
1795 2 : }
1796 :
1797 2 : void ScXMLExport::AddStyleFromCells(const uno::Reference<beans::XPropertySet>& xProperties,
1798 : const uno::Reference<sheet::XSpreadsheet>& xTable,
1799 : sal_Int32 nTable, const rtl::OUString* pOldName)
1800 : {
1801 : //! pass xCellRanges instead
1802 2 : uno::Reference<sheet::XSheetCellRanges> xCellRanges( xProperties, uno::UNO_QUERY );
1803 :
1804 2 : rtl::OUString SC_SCELLPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX));
1805 2 : rtl::OUString SC_NUMBERFORMAT(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT));
1806 :
1807 2 : rtl::OUString sStyleName;
1808 2 : sal_Int32 nNumberFormat(-1);
1809 2 : sal_Int32 nValidationIndex(-1);
1810 2 : std::vector< XMLPropertyState > xPropStates(xCellStylesExportPropertySetMapper->Filter( xProperties ));
1811 2 : std::vector< XMLPropertyState >::iterator aItr(xPropStates.begin());
1812 2 : std::vector< XMLPropertyState >::iterator aEndItr(xPropStates.end());
1813 2 : sal_Int32 nCount(0);
1814 6 : while (aItr != aEndItr)
1815 : {
1816 2 : if (aItr->mnIndex != -1)
1817 : {
1818 2 : switch (xCellStylesPropertySetMapper->GetEntryContextId(aItr->mnIndex))
1819 : {
1820 : case CTF_SC_VALIDATION :
1821 : {
1822 0 : pValidationsContainer->AddValidation(aItr->maValue, nValidationIndex);
1823 : // this is not very slow, because it is most the last property or
1824 : // if it is not the last property it is the property before the last property,
1825 : // so in the worst case only one property has to be copied, but in the best case no
1826 : // property has to be copied
1827 0 : aItr = xPropStates.erase(aItr);
1828 0 : aEndItr = xPropStates.end(); // old aEndItr is invalidated!
1829 : }
1830 0 : break;
1831 : case CTF_SC_CELLSTYLE :
1832 : {
1833 2 : aItr->maValue >>= sStyleName;
1834 2 : aItr->mnIndex = -1;
1835 2 : ++aItr;
1836 2 : ++nCount;
1837 : }
1838 2 : break;
1839 : case CTF_SC_NUMBERFORMAT :
1840 : {
1841 0 : if (aItr->maValue >>= nNumberFormat)
1842 0 : addDataStyle(nNumberFormat);
1843 0 : ++aItr;
1844 0 : ++nCount;
1845 : }
1846 0 : break;
1847 : default:
1848 : {
1849 0 : ++aItr;
1850 0 : ++nCount;
1851 : }
1852 0 : break;
1853 : }
1854 : }
1855 : else
1856 : {
1857 0 : ++aItr;
1858 0 : ++nCount;
1859 : }
1860 : }
1861 2 : if (nCount == 1) // this is the CellStyle and should be removed if alone
1862 2 : xPropStates.clear();
1863 2 : if (nNumberFormat == -1)
1864 2 : xProperties->getPropertyValue(SC_NUMBERFORMAT) >>= nNumberFormat;
1865 2 : if (!sStyleName.isEmpty())
1866 : {
1867 2 : if (!xPropStates.empty())
1868 : {
1869 : sal_Int32 nIndex;
1870 0 : if (pOldName)
1871 : {
1872 0 : if (GetAutoStylePool()->AddNamed(*pOldName, XML_STYLE_FAMILY_TABLE_CELL, sStyleName, xPropStates))
1873 : {
1874 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_CELL, *pOldName);
1875 : // add to pCellStyles, so the name is found for normal sheets
1876 0 : rtl::OUString* pTemp(new rtl::OUString(*pOldName));
1877 0 : if (!pCellStyles->AddStyleName(pTemp, nIndex))
1878 0 : delete pTemp;
1879 : }
1880 : }
1881 : else
1882 : {
1883 0 : rtl::OUString sName;
1884 0 : bool bIsAutoStyle(true);
1885 0 : if (GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_CELL, sStyleName, xPropStates))
1886 : {
1887 0 : rtl::OUString* pTemp(new rtl::OUString(sName));
1888 0 : if (!pCellStyles->AddStyleName(pTemp, nIndex))
1889 0 : delete pTemp;
1890 : }
1891 : else
1892 0 : nIndex = pCellStyles->GetIndexOfStyleName(sName, SC_SCELLPREFIX, bIsAutoStyle);
1893 :
1894 0 : uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
1895 0 : table::CellRangeAddress* pAddresses(aAddresses.getArray());
1896 0 : bool bGetMerge(true);
1897 0 : for (sal_Int32 i = 0; i < aAddresses.getLength(); ++i, ++pAddresses)
1898 : {
1899 0 : pSharedData->SetLastColumn(nTable, pAddresses->EndColumn);
1900 0 : pSharedData->SetLastRow(nTable, pAddresses->EndRow);
1901 0 : pCellStyles->AddRangeStyleName(*pAddresses, nIndex, bIsAutoStyle, nValidationIndex, nNumberFormat);
1902 0 : if (bGetMerge)
1903 0 : bGetMerge = GetMerged(pAddresses, xTable);
1904 0 : }
1905 : }
1906 : }
1907 : else
1908 : {
1909 2 : rtl::OUString* pTemp(new rtl::OUString(EncodeStyleName(sStyleName)));
1910 2 : sal_Int32 nIndex(0);
1911 2 : if (!pCellStyles->AddStyleName(pTemp, nIndex, false))
1912 : {
1913 0 : delete pTemp;
1914 0 : pTemp = NULL;
1915 : }
1916 2 : if ( !pOldName )
1917 : {
1918 2 : uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
1919 2 : table::CellRangeAddress* pAddresses(aAddresses.getArray());
1920 2 : bool bGetMerge(true);
1921 4 : for (sal_Int32 i = 0; i < aAddresses.getLength(); ++i, ++pAddresses)
1922 : {
1923 2 : if (bGetMerge)
1924 2 : bGetMerge = GetMerged(pAddresses, xTable);
1925 2 : pCellStyles->AddRangeStyleName(*pAddresses, nIndex, false, nValidationIndex, nNumberFormat);
1926 2 : if (!sStyleName.equalsAsciiL("Default", 7) || nValidationIndex != -1)
1927 : {
1928 0 : pSharedData->SetLastColumn(nTable, pAddresses->EndColumn);
1929 0 : pSharedData->SetLastRow(nTable, pAddresses->EndRow);
1930 : }
1931 2 : }
1932 : }
1933 : }
1934 2 : }
1935 2 : }
1936 :
1937 2 : void ScXMLExport::AddStyleFromColumn(const uno::Reference<beans::XPropertySet>& xColumnProperties,
1938 : const rtl::OUString* pOldName, sal_Int32& rIndex, bool& rIsVisible)
1939 : {
1940 2 : rtl::OUString SC_SCOLUMNPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX));
1941 :
1942 2 : std::vector<XMLPropertyState> xPropStates(xColumnStylesExportPropertySetMapper->Filter(xColumnProperties));
1943 2 : if(!xPropStates.empty())
1944 : {
1945 2 : std::vector< XMLPropertyState >::iterator aItr(xPropStates.begin());
1946 2 : std::vector< XMLPropertyState >::iterator aEndItr(xPropStates.end());
1947 6 : while (aItr != aEndItr)
1948 : {
1949 4 : if (xColumnStylesPropertySetMapper->GetEntryContextId(aItr->mnIndex) == CTF_SC_ISVISIBLE)
1950 : {
1951 2 : aItr->maValue >>= rIsVisible;
1952 2 : break;
1953 : }
1954 2 : ++aItr;
1955 : }
1956 :
1957 2 : rtl::OUString sParent;
1958 2 : if (pOldName)
1959 : {
1960 0 : if (GetAutoStylePool()->AddNamed(*pOldName, XML_STYLE_FAMILY_TABLE_COLUMN, sParent, xPropStates))
1961 : {
1962 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_COLUMN, *pOldName);
1963 : // add to pColumnStyles, so the name is found for normal sheets
1964 0 : rtl::OUString* pTemp(new rtl::OUString(*pOldName));
1965 0 : rIndex = pColumnStyles->AddStyleName(pTemp);
1966 : }
1967 : }
1968 : else
1969 : {
1970 2 : rtl::OUString sName;
1971 2 : if (GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_COLUMN, sParent, xPropStates))
1972 : {
1973 2 : rtl::OUString* pTemp(new rtl::OUString(sName));
1974 2 : rIndex = pColumnStyles->AddStyleName(pTemp);
1975 : }
1976 : else
1977 0 : rIndex = pColumnStyles->GetIndexOfStyleName(sName, SC_SCOLUMNPREFIX);
1978 2 : }
1979 2 : }
1980 2 : }
1981 :
1982 2 : void ScXMLExport::AddStyleFromRow(const uno::Reference<beans::XPropertySet>& xRowProperties,
1983 : const rtl::OUString* pOldName, sal_Int32& rIndex)
1984 : {
1985 2 : rtl::OUString SC_SROWPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX));
1986 :
1987 2 : std::vector<XMLPropertyState> xPropStates(xRowStylesExportPropertySetMapper->Filter(xRowProperties));
1988 2 : if(!xPropStates.empty())
1989 : {
1990 2 : rtl::OUString sParent;
1991 2 : if (pOldName)
1992 : {
1993 0 : if (GetAutoStylePool()->AddNamed(*pOldName, XML_STYLE_FAMILY_TABLE_ROW, sParent, xPropStates))
1994 : {
1995 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_ROW, *pOldName);
1996 : // add to pRowStyles, so the name is found for normal sheets
1997 0 : rtl::OUString* pTemp(new rtl::OUString(*pOldName));
1998 0 : rIndex = pRowStyles->AddStyleName(pTemp);
1999 : }
2000 : }
2001 : else
2002 : {
2003 2 : rtl::OUString sName;
2004 2 : if (GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_ROW, sParent, xPropStates))
2005 : {
2006 2 : rtl::OUString* pTemp(new rtl::OUString(sName));
2007 2 : rIndex = pRowStyles->AddStyleName(pTemp);
2008 : }
2009 : else
2010 0 : rIndex = pRowStyles->GetIndexOfStyleName(sName, SC_SROWPREFIX);
2011 2 : }
2012 2 : }
2013 2 : }
2014 :
2015 0 : static uno::Any lcl_GetEnumerated( uno::Reference<container::XEnumerationAccess> xEnumAccess, sal_Int32 nIndex )
2016 : {
2017 0 : uno::Any aRet;
2018 0 : uno::Reference<container::XEnumeration> xEnum( xEnumAccess->createEnumeration() );
2019 : try
2020 : {
2021 0 : sal_Int32 nSkip = nIndex;
2022 0 : while ( nSkip > 0 )
2023 : {
2024 0 : (void) xEnum->nextElement();
2025 0 : --nSkip;
2026 : }
2027 0 : aRet = xEnum->nextElement();
2028 : }
2029 0 : catch (container::NoSuchElementException&)
2030 : {
2031 : // leave aRet empty
2032 : }
2033 0 : return aRet;
2034 : }
2035 :
2036 4 : void ScXMLExport::_ExportAutoStyles()
2037 : {
2038 4 : if (!GetModel().is())
2039 : return;
2040 :
2041 4 : Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
2042 4 : if (!xSpreadDoc.is())
2043 : return;
2044 :
2045 4 : Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
2046 4 : if (!xIndex.is())
2047 : return;
2048 :
2049 4 : if (getExportFlags() & EXPORT_CONTENT)
2050 : {
2051 : // re-create automatic styles with old names from stored data
2052 2 : ScSheetSaveData* pSheetData = ScModelObj::getImplementation(xSpreadDoc)->GetSheetSaveData();
2053 2 : if (pSheetData && pDoc)
2054 : {
2055 : // formulas have to be calculated now, to detect changed results
2056 : // (during normal save, they will be calculated anyway)
2057 2 : SCTAB nTabCount = pDoc->GetTableCount();
2058 4 : for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
2059 2 : if (pDoc->IsStreamValid(nTab))
2060 : {
2061 0 : ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
2062 0 : ScBaseCell* pCell = aIter.GetFirst();
2063 0 : while (pCell)
2064 : {
2065 0 : if (pCell->GetCellType() == CELLTYPE_FORMULA)
2066 0 : static_cast<ScFormulaCell*>(pCell)->IsValue(); // interpret if dirty
2067 0 : pCell = aIter.GetNext();
2068 : }
2069 : }
2070 :
2071 : // stored cell styles
2072 2 : const std::vector<ScCellStyleEntry>& rCellEntries = pSheetData->GetCellStyles();
2073 2 : std::vector<ScCellStyleEntry>::const_iterator aCellIter = rCellEntries.begin();
2074 2 : std::vector<ScCellStyleEntry>::const_iterator aCellEnd = rCellEntries.end();
2075 4 : while (aCellIter != aCellEnd)
2076 : {
2077 0 : ScAddress aPos = aCellIter->maCellPos;
2078 0 : sal_Int32 nTable = aPos.Tab();
2079 0 : bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2080 0 : if (bCopySheet)
2081 : {
2082 0 : Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2083 : Reference <beans::XPropertySet> xProperties(
2084 0 : xTable->getCellByPosition( aPos.Col(), aPos.Row() ), uno::UNO_QUERY );
2085 :
2086 0 : AddStyleFromCells(xProperties, xTable, nTable, &aCellIter->maName);
2087 : }
2088 0 : ++aCellIter;
2089 : }
2090 :
2091 : // stored column styles
2092 2 : const std::vector<ScCellStyleEntry>& rColumnEntries = pSheetData->GetColumnStyles();
2093 2 : std::vector<ScCellStyleEntry>::const_iterator aColumnIter = rColumnEntries.begin();
2094 2 : std::vector<ScCellStyleEntry>::const_iterator aColumnEnd = rColumnEntries.end();
2095 4 : while (aColumnIter != aColumnEnd)
2096 : {
2097 0 : ScAddress aPos = aColumnIter->maCellPos;
2098 0 : sal_Int32 nTable = aPos.Tab();
2099 0 : bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2100 0 : if (bCopySheet)
2101 : {
2102 0 : Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2103 0 : Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
2104 0 : Reference<beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex( aPos.Col() ), uno::UNO_QUERY);
2105 :
2106 0 : sal_Int32 nIndex(-1);
2107 0 : bool bIsVisible(true);
2108 0 : AddStyleFromColumn( xColumnProperties, &aColumnIter->maName, nIndex, bIsVisible );
2109 : }
2110 0 : ++aColumnIter;
2111 : }
2112 :
2113 : // stored row styles
2114 2 : const std::vector<ScCellStyleEntry>& rRowEntries = pSheetData->GetRowStyles();
2115 2 : std::vector<ScCellStyleEntry>::const_iterator aRowIter = rRowEntries.begin();
2116 2 : std::vector<ScCellStyleEntry>::const_iterator aRowEnd = rRowEntries.end();
2117 4 : while (aRowIter != aRowEnd)
2118 : {
2119 0 : ScAddress aPos = aRowIter->maCellPos;
2120 0 : sal_Int32 nTable = aPos.Tab();
2121 0 : bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2122 0 : if (bCopySheet)
2123 : {
2124 0 : Reference<table::XColumnRowRange> xColumnRowRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2125 0 : Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
2126 0 : Reference<beans::XPropertySet> xRowProperties(xTableRows->getByIndex( aPos.Row() ), uno::UNO_QUERY);
2127 :
2128 0 : sal_Int32 nIndex(-1);
2129 0 : AddStyleFromRow( xRowProperties, &aRowIter->maName, nIndex );
2130 : }
2131 0 : ++aRowIter;
2132 : }
2133 :
2134 : // stored table styles
2135 2 : const std::vector<ScCellStyleEntry>& rTableEntries = pSheetData->GetTableStyles();
2136 2 : std::vector<ScCellStyleEntry>::const_iterator aTableIter = rTableEntries.begin();
2137 2 : std::vector<ScCellStyleEntry>::const_iterator aTableEnd = rTableEntries.end();
2138 4 : while (aTableIter != aTableEnd)
2139 : {
2140 0 : ScAddress aPos = aTableIter->maCellPos;
2141 0 : sal_Int32 nTable = aPos.Tab();
2142 0 : bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2143 0 : if (bCopySheet)
2144 : {
2145 : //! separate method AddStyleFromTable needed?
2146 0 : Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2147 0 : if (xTableProperties.is())
2148 : {
2149 0 : std::vector<XMLPropertyState> xPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties));
2150 0 : rtl::OUString sParent;
2151 0 : rtl::OUString sName( aTableIter->maName );
2152 0 : GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TABLE_TABLE, sParent, xPropStates);
2153 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_TABLE, sName);
2154 0 : }
2155 : }
2156 0 : ++aTableIter;
2157 : }
2158 :
2159 : // stored styles for notes
2160 :
2161 2 : UniReference<SvXMLExportPropertyMapper> xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this );
2162 2 : GetShapeExport(); // make sure the graphics styles family is added
2163 :
2164 2 : const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles();
2165 2 : std::vector<ScNoteStyleEntry>::const_iterator aNoteIter = rNoteEntries.begin();
2166 2 : std::vector<ScNoteStyleEntry>::const_iterator aNoteEnd = rNoteEntries.end();
2167 4 : while (aNoteIter != aNoteEnd)
2168 : {
2169 0 : ScAddress aPos = aNoteIter->maCellPos;
2170 0 : SCTAB nTable = aPos.Tab();
2171 0 : bool bCopySheet = pDoc->IsStreamValid( nTable );
2172 0 : if (bCopySheet)
2173 : {
2174 : //! separate method AddStyleFromNote needed?
2175 :
2176 0 : ScPostIt* pNote = pDoc->GetNotes( nTable )->findByAddress(aPos);
2177 : OSL_ENSURE( pNote, "note not found" );
2178 0 : if (pNote)
2179 : {
2180 0 : SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
2181 : // all uno shapes are created anyway in CollectSharedData
2182 0 : Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY );
2183 0 : if (xShapeProperties.is())
2184 : {
2185 0 : if ( !aNoteIter->maStyleName.isEmpty() )
2186 : {
2187 0 : std::vector<XMLPropertyState> xPropStates(xShapeMapper->Filter(xShapeProperties));
2188 0 : rtl::OUString sParent;
2189 0 : rtl::OUString sName( aNoteIter->maStyleName );
2190 0 : GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sParent, xPropStates);
2191 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_SD_GRAPHICS_ID, sName);
2192 : }
2193 0 : if ( !aNoteIter->maTextStyle.isEmpty() )
2194 : {
2195 : std::vector<XMLPropertyState> xPropStates(
2196 0 : GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(xShapeProperties));
2197 0 : rtl::OUString sParent;
2198 0 : rtl::OUString sName( aNoteIter->maTextStyle );
2199 0 : GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates);
2200 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName);
2201 : }
2202 0 : }
2203 : }
2204 : }
2205 0 : ++aNoteIter;
2206 : }
2207 :
2208 : // note paragraph styles
2209 :
2210 2 : UniReference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper();
2211 :
2212 2 : const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles();
2213 2 : std::vector<ScTextStyleEntry>::const_iterator aNoteParaIter = rNoteParaEntries.begin();
2214 2 : std::vector<ScTextStyleEntry>::const_iterator aNoteParaEnd = rNoteParaEntries.end();
2215 4 : while (aNoteParaIter != aNoteParaEnd)
2216 : {
2217 0 : ScAddress aPos = aNoteParaIter->maCellPos;
2218 0 : SCTAB nTable = aPos.Tab();
2219 0 : bool bCopySheet = pDoc->IsStreamValid( nTable );
2220 0 : if (bCopySheet)
2221 : {
2222 0 : ScPostIt* pNote = pDoc->GetNotes(nTable)->findByAddress( aPos );
2223 : OSL_ENSURE( pNote, "note not found" );
2224 0 : if (pNote)
2225 : {
2226 0 : SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
2227 0 : Reference<container::XEnumerationAccess> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
2228 : Reference<beans::XPropertySet> xParaProp(
2229 0 : lcl_GetEnumerated( xCellText, aNoteParaIter->maSelection.nStartPara ), uno::UNO_QUERY );
2230 0 : if ( xParaProp.is() )
2231 : {
2232 0 : std::vector<XMLPropertyState> xPropStates(xParaPropMapper->Filter(xParaProp));
2233 0 : rtl::OUString sParent;
2234 0 : rtl::OUString sName( aNoteParaIter->maName );
2235 0 : GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates);
2236 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName);
2237 0 : }
2238 : }
2239 : }
2240 0 : ++aNoteParaIter;
2241 : }
2242 :
2243 : // note text styles
2244 :
2245 2 : UniReference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this );
2246 :
2247 2 : const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles();
2248 2 : std::vector<ScTextStyleEntry>::const_iterator aNoteTextIter = rNoteTextEntries.begin();
2249 2 : std::vector<ScTextStyleEntry>::const_iterator aNoteTextEnd = rNoteTextEntries.end();
2250 4 : while (aNoteTextIter != aNoteTextEnd)
2251 : {
2252 0 : ScAddress aPos = aNoteTextIter->maCellPos;
2253 0 : SCTAB nTable = aPos.Tab();
2254 0 : bool bCopySheet = pDoc->IsStreamValid( nTable );
2255 0 : if (bCopySheet)
2256 : {
2257 0 : ScPostIt* pNote = pDoc->GetNotes(nTable)->findByAddress( aPos );
2258 : OSL_ENSURE( pNote, "note not found" );
2259 0 : if (pNote)
2260 : {
2261 0 : SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
2262 0 : Reference<text::XSimpleText> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
2263 0 : Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY);
2264 0 : ScDrawTextCursor* pCursor = ScDrawTextCursor::getImplementation( xCursorProp );
2265 0 : if (pCursor)
2266 : {
2267 0 : pCursor->SetSelection( aNoteTextIter->maSelection );
2268 :
2269 0 : std::vector<XMLPropertyState> xPropStates(xTextPropMapper->Filter(xCursorProp));
2270 0 : rtl::OUString sParent;
2271 0 : rtl::OUString sName( aNoteTextIter->maName );
2272 0 : GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates);
2273 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName);
2274 0 : }
2275 : }
2276 : }
2277 0 : ++aNoteTextIter;
2278 : }
2279 :
2280 : // stored text styles
2281 :
2282 2 : const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles();
2283 2 : std::vector<ScTextStyleEntry>::const_iterator aTextIter = rTextEntries.begin();
2284 2 : std::vector<ScTextStyleEntry>::const_iterator aTextEnd = rTextEntries.end();
2285 4 : while (aTextIter != aTextEnd)
2286 : {
2287 0 : ScAddress aPos = aTextIter->maCellPos;
2288 0 : sal_Int32 nTable = aPos.Tab();
2289 0 : bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
2290 0 : if (bCopySheet)
2291 : {
2292 : //! separate method AddStyleFromText needed?
2293 : //! cache sheet object
2294 :
2295 0 : Reference<table::XCellRange> xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2296 0 : Reference<text::XSimpleText> xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY);
2297 0 : Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY);
2298 0 : ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp );
2299 0 : if (pCursor)
2300 : {
2301 0 : pCursor->SetSelection( aTextIter->maSelection );
2302 :
2303 0 : std::vector<XMLPropertyState> xPropStates(xTextPropMapper->Filter(xCursorProp));
2304 0 : rtl::OUString sParent;
2305 0 : rtl::OUString sName( aTextIter->maName );
2306 0 : GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates);
2307 0 : GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName);
2308 0 : }
2309 : }
2310 0 : ++aTextIter;
2311 2 : }
2312 : }
2313 :
2314 2 : ExportExternalRefCacheStyles();
2315 :
2316 2 : if (!pSharedData)
2317 : {
2318 0 : sal_Int32 nTableCount(0);
2319 0 : sal_Int32 nShapesCount(0);
2320 0 : CollectSharedData(nTableCount, nShapesCount);
2321 : }
2322 2 : sal_Int32 nTableCount(xIndex->getCount());
2323 2 : pCellStyles->AddNewTable(nTableCount - 1);
2324 2 : CollectShapesAutoStyles(nTableCount);
2325 4 : for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable, IncrementProgressBar(false))
2326 : {
2327 2 : bool bUseStream = pSheetData && pDoc && pDoc->IsStreamValid((SCTAB)nTable) &&
2328 0 : pSheetData->HasStreamPos(nTable) && xSourceStream.is() &&
2329 4 : !pDoc->GetChangeTrack();
2330 :
2331 2 : Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
2332 2 : if (!xTable.is())
2333 0 : continue;
2334 :
2335 : // table styles array must be complete, including copied tables - Add should find the stored style
2336 2 : Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
2337 2 : if (xTableProperties.is())
2338 : {
2339 2 : std::vector<XMLPropertyState> xPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties));
2340 2 : if(!xPropStates.empty())
2341 : {
2342 2 : rtl::OUString sParent;
2343 2 : rtl::OUString sName;
2344 2 : GetAutoStylePool()->Add(sName, XML_STYLE_FAMILY_TABLE_TABLE, sParent, xPropStates);
2345 2 : aTableStyles.push_back(sName);
2346 2 : }
2347 : }
2348 :
2349 2 : if (bUseStream)
2350 0 : continue;
2351 :
2352 : // collect other auto-styles only for non-copied sheets
2353 2 : Reference<sheet::XUniqueCellFormatRangesSupplier> xCellFormatRanges ( xTable, uno::UNO_QUERY );
2354 2 : if ( xCellFormatRanges.is() )
2355 : {
2356 2 : Reference<container::XIndexAccess> xFormatRangesIndex(xCellFormatRanges->getUniqueCellFormatRanges());
2357 2 : if (xFormatRangesIndex.is())
2358 : {
2359 2 : sal_Int32 nFormatRangesCount(xFormatRangesIndex->getCount());
2360 2 : GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nFormatRangesCount);
2361 4 : for (sal_Int32 nFormatRange = 0; nFormatRange < nFormatRangesCount; ++nFormatRange)
2362 : {
2363 2 : Reference< sheet::XSheetCellRanges> xCellRanges(xFormatRangesIndex->getByIndex(nFormatRange), uno::UNO_QUERY);
2364 2 : if (xCellRanges.is())
2365 : {
2366 2 : Reference <beans::XPropertySet> xProperties (xCellRanges, uno::UNO_QUERY);
2367 2 : if (xProperties.is())
2368 : {
2369 2 : AddStyleFromCells(xProperties, xTable, nTable, NULL);
2370 2 : IncrementProgressBar(false);
2371 2 : }
2372 : }
2373 2 : }
2374 2 : }
2375 : }
2376 2 : Reference<table::XColumnRowRange> xColumnRowRange (xTable, uno::UNO_QUERY);
2377 2 : if (xColumnRowRange.is())
2378 : {
2379 2 : if (pDoc)
2380 : {
2381 2 : pDoc->SyncColRowFlags();
2382 2 : Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
2383 2 : if (xTableColumns.is())
2384 : {
2385 2 : sal_Int32 nColumns(pDoc->GetLastChangedCol(sal::static_int_cast<SCTAB>(nTable)));
2386 2 : pSharedData->SetLastColumn(nTable, nColumns);
2387 2 : table::CellRangeAddress aCellAddress(GetEndAddress(xTable, nTable));
2388 2 : if (aCellAddress.EndColumn > nColumns)
2389 : {
2390 0 : ++nColumns;
2391 0 : pColumnStyles->AddNewTable(nTable, aCellAddress.EndColumn);
2392 : }
2393 : else
2394 2 : pColumnStyles->AddNewTable(nTable, nColumns);
2395 2 : sal_Int32 nColumn = 0;
2396 6 : while (nColumn <= MAXCOL)
2397 : {
2398 2 : sal_Int32 nIndex(-1);
2399 2 : bool bIsVisible(true);
2400 2 : Reference <beans::XPropertySet> xColumnProperties(xTableColumns->getByIndex(nColumn), uno::UNO_QUERY);
2401 2 : if (xColumnProperties.is())
2402 : {
2403 2 : AddStyleFromColumn( xColumnProperties, NULL, nIndex, bIsVisible );
2404 2 : pColumnStyles->AddFieldStyleName(nTable, nColumn, nIndex, bIsVisible);
2405 : }
2406 2 : sal_Int32 nOld(nColumn);
2407 2 : nColumn = pDoc->GetNextDifferentChangedCol(sal::static_int_cast<SCTAB>(nTable), static_cast<SCCOL>(nColumn));
2408 2048 : for (sal_Int32 i = nOld + 1; i < nColumn; ++i)
2409 2046 : pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
2410 2 : }
2411 2 : if (aCellAddress.EndColumn > nColumns)
2412 : {
2413 0 : bool bIsVisible(true);
2414 0 : sal_Int32 nIndex(pColumnStyles->GetStyleNameIndex(nTable, nColumns, bIsVisible));
2415 0 : for (sal_Int32 i = nColumns + 1; i <= aCellAddress.EndColumn; ++i)
2416 0 : pColumnStyles->AddFieldStyleName(nTable, i, nIndex, bIsVisible);
2417 : }
2418 : }
2419 2 : Reference<table::XTableRows> xTableRows(xColumnRowRange->getRows());
2420 2 : if (xTableRows.is())
2421 : {
2422 2 : sal_Int32 nRows(pDoc->GetLastChangedRow(sal::static_int_cast<SCTAB>(nTable)));
2423 2 : pSharedData->SetLastRow(nTable, nRows);
2424 :
2425 2 : pRowStyles->AddNewTable(nTable, MAXROW);
2426 2 : sal_Int32 nRow = 0;
2427 6 : while (nRow <= MAXROW)
2428 : {
2429 2 : sal_Int32 nIndex = 0;
2430 2 : Reference <beans::XPropertySet> xRowProperties(xTableRows->getByIndex(nRow), uno::UNO_QUERY);
2431 2 : if(xRowProperties.is())
2432 : {
2433 2 : AddStyleFromRow( xRowProperties, NULL, nIndex );
2434 2 : pRowStyles->AddFieldStyleName(nTable, nRow, nIndex);
2435 : }
2436 2 : sal_Int32 nOld(nRow);
2437 2 : nRow = pDoc->GetNextDifferentChangedRow(sal::static_int_cast<SCTAB>(nTable), static_cast<SCROW>(nRow), false);
2438 2 : if (nRow > nOld + 1)
2439 2 : pRowStyles->AddFieldStyleName(nTable, nOld + 1, nIndex, nRow - 1);
2440 2 : }
2441 2 : }
2442 : }
2443 : }
2444 2 : Reference<sheet::XCellRangesQuery> xCellRangesQuery (xTable, uno::UNO_QUERY);
2445 2 : if (xCellRangesQuery.is())
2446 : {
2447 2 : Reference<sheet::XSheetCellRanges> xSheetCellRanges(xCellRangesQuery->queryContentCells(sheet::CellFlags::FORMATTED));
2448 2 : Reference<sheet::XSheetOperation> xSheetOperation(xSheetCellRanges, uno::UNO_QUERY);
2449 2 : if (xSheetCellRanges.is() && xSheetOperation.is())
2450 : {
2451 2 : sal_uInt32 nCount(sal_uInt32(xSheetOperation->computeFunction(sheet::GeneralFunction_COUNT)));
2452 2 : Reference<container::XEnumerationAccess> xCellsAccess(xSheetCellRanges->getCells());
2453 2 : if (xCellsAccess.is())
2454 : {
2455 2 : GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCount);
2456 2 : Reference<container::XEnumeration> xCells(xCellsAccess->createEnumeration());
2457 2 : if (xCells.is())
2458 : {
2459 2 : sal_uInt32 nCount2(0);
2460 4 : while (xCells->hasMoreElements())
2461 : {
2462 0 : Reference<text::XText> xText(xCells->nextElement(), uno::UNO_QUERY);
2463 0 : if (xText.is())
2464 0 : GetTextParagraphExport()->collectTextAutoStyles(xText, false, false);
2465 0 : ++nCount2;
2466 0 : IncrementProgressBar(false);
2467 0 : }
2468 2 : if(nCount2 > nCount)
2469 0 : GetProgressBarHelper()->SetReference(GetProgressBarHelper()->GetReference() + nCount2 - nCount);
2470 2 : }
2471 2 : }
2472 2 : }
2473 : }
2474 2 : }
2475 2 : pChangeTrackingExportHelper->CollectAutoStyles();
2476 :
2477 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN,
2478 2 : GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2479 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW,
2480 2 : GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2481 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE,
2482 2 : GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2483 2 : exportAutoDataStyles();
2484 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL,
2485 2 : GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2486 :
2487 2 : GetShapeExport()->exportAutoStyles();
2488 2 : GetFormExport()->exportAutoStyles( );
2489 :
2490 2 : if (pDoc)
2491 : {
2492 2 : ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
2493 : // #i100879# write the table style for cached tables only if there are cached tables
2494 : // (same logic as in ExportExternalRefCacheStyles)
2495 2 : if (pRefMgr->hasExternalData())
2496 : {
2497 : // Special table style for the external ref cache tables.
2498 0 : AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, sExternalRefTabStyleName);
2499 0 : AddAttribute(XML_NAMESPACE_STYLE, XML_FAMILY, XML_TABLE);
2500 0 : SvXMLElementExport aElemStyle(*this, XML_NAMESPACE_STYLE, XML_STYLE, true, true);
2501 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE);
2502 0 : SvXMLElementExport aElemStyleTabProps(*this, XML_NAMESPACE_STYLE, XML_TABLE_PROPERTIES, true, true);
2503 : }
2504 : }
2505 : }
2506 :
2507 4 : if (getExportFlags() & EXPORT_MASTERSTYLES)
2508 : {
2509 2 : GetPageExport()->collectAutoStyles(true);
2510 2 : GetPageExport()->exportAutoStyles();
2511 : }
2512 :
2513 : // #i30251#; only write Text Styles once
2514 :
2515 4 : if ((getExportFlags() & EXPORT_CONTENT) || (getExportFlags() & EXPORT_MASTERSTYLES))
2516 4 : GetTextParagraphExport()->exportTextAutoStyles();
2517 : }
2518 :
2519 2 : void ScXMLExport::_ExportMasterStyles()
2520 : {
2521 2 : GetPageExport()->exportMasterStyles( true );
2522 2 : }
2523 :
2524 0 : void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > xShape )
2525 : {
2526 : // detective objects and notes
2527 0 : if( SvxShape* pShapeImp = SvxShape::getImplementation( xShape ) )
2528 : {
2529 0 : if( SdrObject* pObject = pShapeImp->GetSdrObject() )
2530 : {
2531 : // collect note caption objects from all layers (internal or hidden)
2532 0 : if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, static_cast< SCTAB >( nCurrentTable ) ) )
2533 : {
2534 0 : pSharedData->AddNoteObj( xShape, pCaptData->maStart );
2535 :
2536 : // #i60851# When the file is saved while editing a new note,
2537 : // the cell is still empty -> last column/row must be updated
2538 : OSL_ENSURE( pCaptData->maStart.Tab() == nCurrentTable, "invalid table in object data" );
2539 0 : pSharedData->SetLastColumn( nCurrentTable, pCaptData->maStart.Col() );
2540 0 : pSharedData->SetLastRow( nCurrentTable, pCaptData->maStart.Row() );
2541 : }
2542 : // other objects from internal layer only (detective)
2543 0 : else if( pObject->GetLayer() == SC_LAYER_INTERN )
2544 : {
2545 0 : ScDetectiveFunc aDetFunc( pDoc, static_cast<SCTAB>(nCurrentTable) );
2546 0 : ScAddress aPosition;
2547 0 : ScRange aSourceRange;
2548 : bool bRedLine;
2549 : ScDetectiveObjType eObjType = aDetFunc.GetDetectiveObjectType(
2550 0 : pObject, nCurrentTable, aPosition, aSourceRange, bRedLine );
2551 0 : pSharedData->GetDetectiveObjContainer()->AddObject( eObjType, static_cast<SCTAB>(nCurrentTable), aPosition, aSourceRange, bRedLine );
2552 : }
2553 : }
2554 : }
2555 0 : }
2556 :
2557 2 : bool ScXMLExport::GetMerged (const table::CellRangeAddress* pCellAddress,
2558 : const uno::Reference <sheet::XSpreadsheet>& xTable)
2559 : {
2560 2 : bool bReady(false);
2561 2 : sal_Int32 nRow(pCellAddress->StartRow);
2562 2 : sal_Int32 nCol(pCellAddress->StartColumn);
2563 2 : sal_Int32 nEndRow(pCellAddress->EndRow);
2564 2 : sal_Int32 nEndCol(pCellAddress->EndColumn);
2565 2 : bool bRowInc(nEndRow > nRow);
2566 6 : while(!bReady && nRow <= nEndRow && nCol <= nEndCol)
2567 : {
2568 2 : uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xTable->getCellRangeByPosition(nCol, nRow, nCol, nRow), uno::UNO_QUERY);
2569 2 : if (xSheetCellRange.is())
2570 : {
2571 2 : uno::Reference<sheet::XSheetCellCursor> xCursor(xTable->createCursorByRange(xSheetCellRange));
2572 2 : if(xCursor.is())
2573 : {
2574 2 : uno::Reference<sheet::XCellRangeAddressable> xCellAddress (xCursor, uno::UNO_QUERY);
2575 2 : xCursor->collapseToMergedArea();
2576 2 : table::CellRangeAddress aCellAddress2(xCellAddress->getRangeAddress());
2577 2 : if ((aCellAddress2.EndRow > nRow ||
2578 : aCellAddress2.EndColumn > nCol) &&
2579 : aCellAddress2.StartRow == nRow &&
2580 : aCellAddress2.StartColumn == nCol)
2581 : {
2582 0 : pMergedRangesContainer->AddRange(aCellAddress2);
2583 0 : pSharedData->SetLastColumn(aCellAddress2.Sheet, aCellAddress2.EndColumn);
2584 0 : pSharedData->SetLastRow(aCellAddress2.Sheet, aCellAddress2.EndRow);
2585 : }
2586 : else
2587 2 : bReady = true;
2588 2 : }
2589 : }
2590 2 : if (!bReady)
2591 : {
2592 0 : if (bRowInc)
2593 0 : ++nRow;
2594 : else
2595 0 : ++nCol;
2596 : }
2597 2 : }
2598 : OSL_ENSURE(!(!bReady && nEndRow > nRow && nEndCol > nCol), "should not be possible");
2599 2 : return !bReady;
2600 : }
2601 :
2602 0 : bool ScXMLExport::IsMatrix (const ScAddress& aCell,
2603 : table::CellRangeAddress& aCellAddress, bool& bIsFirst) const
2604 : {
2605 0 : bIsFirst = false;
2606 :
2607 0 : ScRange aMatrixRange;
2608 :
2609 0 : if (pDoc && pDoc->GetMatrixFormulaRange(aCell, aMatrixRange))
2610 : {
2611 0 : ScUnoConversion::FillApiRange( aCellAddress, aMatrixRange );
2612 0 : if ((aCellAddress.StartColumn == aCell.Col() && aCellAddress.StartRow == aCell.Row()) &&
2613 0 : (aCellAddress.EndColumn > aCell.Col() || aCellAddress.EndRow > aCell.Row()))
2614 : {
2615 0 : bIsFirst = true;
2616 0 : return true;
2617 : }
2618 0 : else if (aCellAddress.StartColumn != aCell.Col() || aCellAddress.StartRow != aCell.Row() ||
2619 0 : aCellAddress.EndColumn != aCell.Col() || aCellAddress.EndRow != aCell.Row())
2620 0 : return true;
2621 : else
2622 : {
2623 0 : bIsFirst = true;
2624 0 : return true;
2625 : }
2626 : }
2627 :
2628 0 : return false;
2629 : }
2630 :
2631 2 : bool ScXMLExport::GetCellText (ScMyCell& rMyCell, const ScAddress& aPos) const
2632 : {
2633 2 : if (rMyCell.bHasStringValue)
2634 0 : return true;
2635 : else
2636 : {
2637 2 : rMyCell.sStringValue = ScCellObj::GetOutputString_Impl(pDoc, aPos);
2638 2 : rMyCell.bHasStringValue = true;
2639 2 : return true;
2640 : }
2641 : }
2642 :
2643 2 : void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadsheet>& xTable)
2644 : {
2645 2 : if (!xTable.is())
2646 : return;
2647 :
2648 2 : xCurrentTable.set(xTable);
2649 2 : xCurrentTableCellRange.set(xTable, uno::UNO_QUERY);
2650 2 : uno::Reference<container::XNamed> xName (xTable, uno::UNO_QUERY );
2651 2 : if (!xName.is())
2652 : return;
2653 :
2654 2 : nCurrentTable = sal::static_int_cast<sal_uInt16>( nTable );
2655 2 : rtl::OUString sOUTableName(xName->getName());
2656 2 : AddAttribute(sAttrName, sOUTableName);
2657 2 : AddAttribute(sAttrStyleName, aTableStyles[nTable]);
2658 :
2659 2 : uno::Reference<util::XProtectable> xProtectable (xTable, uno::UNO_QUERY);
2660 2 : ScTableProtection* pProtect = NULL;
2661 2 : if (xProtectable.is() && xProtectable->isProtected())
2662 : {
2663 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE);
2664 0 : if (pDoc)
2665 : {
2666 0 : pProtect = pDoc->GetTabProtection(nTable);
2667 0 : if (pProtect)
2668 : {
2669 0 : rtl::OUStringBuffer aBuffer;
2670 0 : ScPasswordHash eHashUsed = PASSHASH_UNSPECIFIED;
2671 0 : if (pProtect->hasPasswordHash(PASSHASH_SHA1))
2672 : {
2673 : ::sax::Converter::encodeBase64(aBuffer,
2674 0 : pProtect->getPasswordHash(PASSHASH_SHA1));
2675 0 : eHashUsed = PASSHASH_SHA1;
2676 : }
2677 0 : else if (pProtect->hasPasswordHash(PASSHASH_XL, PASSHASH_SHA1))
2678 : {
2679 : // Double-hash this by SHA1 on top of the legacy xls hash.
2680 0 : uno::Sequence<sal_Int8> aHash = pProtect->getPasswordHash(PASSHASH_XL, PASSHASH_SHA1);
2681 0 : ::sax::Converter::encodeBase64(aBuffer, aHash);
2682 0 : eHashUsed = PASSHASH_XL;
2683 : }
2684 0 : if (aBuffer.getLength())
2685 : {
2686 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear());
2687 0 : if ( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
2688 : {
2689 0 : if (eHashUsed == PASSHASH_XL)
2690 : {
2691 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
2692 0 : ScPassHashHelper::getHashURI(PASSHASH_XL));
2693 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2,
2694 0 : ScPassHashHelper::getHashURI(PASSHASH_SHA1));
2695 : }
2696 0 : else if (eHashUsed == PASSHASH_SHA1)
2697 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY_DIGEST_ALGORITHM,
2698 0 : ScPassHashHelper::getHashURI(PASSHASH_SHA1));
2699 : }
2700 0 : }
2701 : }
2702 : }
2703 : }
2704 2 : rtl::OUString sPrintRanges;
2705 2 : table::CellRangeAddress aColumnHeaderRange;
2706 : bool bHasColumnHeader;
2707 2 : GetColumnRowHeader(bHasColumnHeader, aColumnHeaderRange, bHasRowHeader, aRowHeaderRange, sPrintRanges);
2708 2 : if( !sPrintRanges.isEmpty() )
2709 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT_RANGES, sPrintRanges );
2710 2 : else if (!pDoc->IsPrintEntireSheet(static_cast<SCTAB>(nTable)))
2711 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_PRINT, XML_FALSE);
2712 2 : SvXMLElementExport aElemT(*this, sElemTab, true, true);
2713 :
2714 2 : if (pProtect && pProtect->isProtected())
2715 : {
2716 0 : if (pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS))
2717 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_SELECT_PROTECTED_CELLS, XML_TRUE);
2718 0 : if (pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS))
2719 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_SELECT_UNPROTECTED_CELLS, XML_TRUE);
2720 :
2721 0 : rtl::OUString aElemName = GetNamespaceMap().GetQNameByKey(
2722 0 : XML_NAMESPACE_TABLE, GetXMLToken(XML_TABLE_PROTECTION));
2723 :
2724 0 : SvXMLElementExport aElemProtected(*this, aElemName, true, true);
2725 : }
2726 :
2727 2 : CheckAttrList();
2728 :
2729 2 : if ( pDoc && pDoc->GetSheetEvents( static_cast<SCTAB>(nTable) ) &&
2730 0 : getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
2731 : {
2732 : // store sheet events
2733 0 : uno::Reference<document::XEventsSupplier> xSupplier(xTable, uno::UNO_QUERY);
2734 0 : uno::Reference<container::XNameAccess> xEvents(xSupplier->getEvents(), uno::UNO_QUERY);
2735 0 : GetEventExport().ExportExt( xEvents );
2736 : }
2737 :
2738 2 : WriteTableSource();
2739 2 : WriteScenario();
2740 2 : uno::Reference<drawing::XDrawPage> xDrawPage;
2741 2 : if (pSharedData->HasForm(nTable, xDrawPage) && xDrawPage.is())
2742 : {
2743 0 : ::xmloff::OOfficeFormsExport aForms(*this);
2744 0 : GetFormExport()->exportForms( xDrawPage );
2745 0 : bool bRet(GetFormExport()->seekPage( xDrawPage ));
2746 : OSL_ENSURE( bRet, "OFormLayerXMLExport::seekPage failed!" );
2747 0 : (void)bRet; // avoid warning in product version
2748 : }
2749 2 : if (pSharedData->HasDrawPage())
2750 : {
2751 2 : GetShapeExport()->seekShapes(uno::Reference<drawing::XShapes>(pSharedData->GetDrawPage(nTable), uno::UNO_QUERY));
2752 2 : WriteTableShapes();
2753 : }
2754 2 : table::CellRangeAddress aRange(GetEndAddress(xTable, nTable));
2755 2 : pSharedData->SetLastColumn(nTable, aRange.EndColumn);
2756 2 : pSharedData->SetLastRow(nTable, aRange.EndRow);
2757 2 : pCellsItr->SetCurrentTable(static_cast<SCTAB>(nTable), xCurrentTable);
2758 2 : pGroupColumns->NewTable();
2759 2 : pGroupRows->NewTable();
2760 2 : FillColumnRowGroups();
2761 2 : if (bHasColumnHeader)
2762 0 : pSharedData->SetLastColumn(nTable, aColumnHeaderRange.EndColumn);
2763 2 : bRowHeaderOpen = sal_False;
2764 2 : if (bHasRowHeader)
2765 0 : pSharedData->SetLastRow(nTable, aRowHeaderRange.EndRow);
2766 : pDefaults->FillDefaultStyles(nTable, pSharedData->GetLastRow(nTable),
2767 2 : pSharedData->GetLastColumn(nTable), pCellStyles, pDoc);
2768 2 : pRowFormatRanges->SetRowDefaults(pDefaults->GetRowDefaults());
2769 2 : pRowFormatRanges->SetColDefaults(pDefaults->GetColDefaults());
2770 2 : pCellStyles->SetRowDefaults(pDefaults->GetRowDefaults());
2771 2 : pCellStyles->SetColDefaults(pDefaults->GetColDefaults());
2772 2 : ExportColumns(nTable, aColumnHeaderRange, bHasColumnHeader);
2773 2 : bool bIsFirst(true);
2774 2 : sal_Int32 nEqualCells(0);
2775 2 : ScMyCell aCell;
2776 2 : ScMyCell aPrevCell;
2777 6 : while(pCellsItr->GetNext(aCell, pCellStyles))
2778 : {
2779 2 : if (bIsFirst)
2780 : {
2781 2 : ExportFormatRanges(0, 0, aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable);
2782 2 : aPrevCell = aCell;
2783 2 : bIsFirst = sal_False;
2784 : }
2785 : else
2786 : {
2787 0 : if ((aPrevCell.aCellAddress.Row == aCell.aCellAddress.Row) &&
2788 : (aPrevCell.aCellAddress.Column + nEqualCells + 1 == aCell.aCellAddress.Column))
2789 : {
2790 0 : if(IsCellEqual(aPrevCell, aCell))
2791 0 : ++nEqualCells;
2792 : else
2793 : {
2794 0 : WriteCell(aPrevCell, nEqualCells);
2795 0 : nEqualCells = 0;
2796 0 : aPrevCell = aCell;
2797 : }
2798 : }
2799 : else
2800 : {
2801 0 : WriteCell(aPrevCell, nEqualCells);
2802 : ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row,
2803 0 : aCell.aCellAddress.Column - 1, aCell.aCellAddress.Row, nTable);
2804 0 : nEqualCells = 0;
2805 0 : aPrevCell = aCell;
2806 : }
2807 : }
2808 : }
2809 2 : if (!bIsFirst)
2810 : {
2811 2 : WriteCell(aPrevCell, nEqualCells);
2812 : ExportFormatRanges(aPrevCell.aCellAddress.Column + nEqualCells + 1, aPrevCell.aCellAddress.Row,
2813 2 : pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable);
2814 : }
2815 : else
2816 0 : ExportFormatRanges(0, 0, pSharedData->GetLastColumn(nTable), pSharedData->GetLastRow(nTable), nTable);
2817 :
2818 2 : CloseRow(pSharedData->GetLastRow(nTable));
2819 2 : nEqualCells = 0;
2820 :
2821 2 : if (pDoc)
2822 : {
2823 : // Export sheet-local named ranges.
2824 2 : ScRangeName* pRangeName = pDoc->GetRangeName(nTable);
2825 2 : if (pRangeName && !pRangeName->empty())
2826 : {
2827 0 : WriteNamedRange(pRangeName);
2828 : }
2829 :
2830 2 : if(getDefaultVersion() > SvtSaveOptions::ODFVER_012)
2831 : {
2832 : //export new conditional format information
2833 2 : ExportConditionalFormat(nTable);
2834 : }
2835 :
2836 2 : }
2837 : }
2838 :
2839 2 : void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
2840 : {
2841 : // nEqualCellCount is the number of additional cells
2842 2 : SetRepeatAttribute(nEqualCellCount, (aCell.nType != table::CellContentType_EMPTY));
2843 :
2844 2 : ScAddress aCellPos;
2845 2 : ScUnoConversion::FillScAddress( aCellPos, aCell.aCellAddress );
2846 2 : if (aCell.nStyleIndex != -1)
2847 0 : AddAttribute(sAttrStyleName, *pCellStyles->GetStyleNameByIndex(aCell.nStyleIndex, aCell.bIsAutoStyle));
2848 2 : if (aCell.nValidationIndex > -1)
2849 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION_NAME, pValidationsContainer->GetValidationName(aCell.nValidationIndex));
2850 2 : bool bIsMatrix(aCell.bIsMatrixBase || aCell.bIsMatrixCovered);
2851 2 : bool bIsFirstMatrixCell(aCell.bIsMatrixBase);
2852 2 : if (bIsFirstMatrixCell)
2853 : {
2854 0 : sal_Int32 nColumns(aCell.aMatrixRange.EndColumn - aCell.aMatrixRange.StartColumn + 1);
2855 0 : sal_Int32 nRows(aCell.aMatrixRange.EndRow - aCell.aMatrixRange.StartRow + 1);
2856 0 : rtl::OUStringBuffer sColumns;
2857 0 : rtl::OUStringBuffer sRows;
2858 0 : ::sax::Converter::convertNumber(sColumns, nColumns);
2859 0 : ::sax::Converter::convertNumber(sRows, nRows);
2860 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_COLUMNS_SPANNED, sColumns.makeStringAndClear());
2861 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_MATRIX_ROWS_SPANNED, sRows.makeStringAndClear());
2862 : }
2863 2 : bool bIsEmpty(false);
2864 2 : switch (aCell.nType)
2865 : {
2866 : case table::CellContentType_EMPTY :
2867 : {
2868 0 : bIsEmpty = true;
2869 : }
2870 0 : break;
2871 : case table::CellContentType_VALUE :
2872 : {
2873 2 : if (!aCell.bHasDoubleValue)
2874 : {
2875 2 : aCell.fValue = pDoc->GetValue( aCellPos );
2876 2 : aCell.bHasDoubleValue = true;
2877 : }
2878 : GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2879 2 : aCell.nNumberFormat, aCell.fValue);
2880 : }
2881 2 : break;
2882 : case table::CellContentType_TEXT :
2883 : {
2884 0 : if (GetCellText(aCell, aCellPos))
2885 : {
2886 0 : rtl::OUString sFormula(lcl_GetRawString(pDoc, aCellPos));
2887 : GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2888 0 : sFormula, aCell.sStringValue, true, true);
2889 : }
2890 : }
2891 0 : break;
2892 : case table::CellContentType_FORMULA :
2893 : {
2894 0 : ScBaseCell* pBaseCell = pDoc ? pDoc->GetCell(aCellPos) : NULL;
2895 0 : if (pBaseCell && pBaseCell->GetCellType() == CELLTYPE_FORMULA)
2896 : {
2897 0 : rtl::OUStringBuffer sFormula;
2898 0 : ScFormulaCell* pFormulaCell((ScFormulaCell*) pBaseCell);
2899 0 : if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell))
2900 : {
2901 0 : const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
2902 0 : sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
2903 0 : pFormulaCell->GetFormula(sFormula, eGrammar);
2904 0 : rtl::OUString sOUFormula(sFormula.makeStringAndClear());
2905 0 : if (!bIsMatrix)
2906 : {
2907 0 : AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula, false ));
2908 : }
2909 : else
2910 : {
2911 0 : AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula.copy(1, sOUFormula.getLength() - 2), false ));
2912 0 : }
2913 : }
2914 0 : if (pFormulaCell->IsValue())
2915 : {
2916 : bool bIsStandard;
2917 0 : rtl::OUString sCurrency;
2918 0 : GetNumberFormatAttributesExportHelper()->GetCellType(aCell.nNumberFormat, sCurrency, bIsStandard);
2919 0 : if (bIsStandard)
2920 : {
2921 0 : if (pDoc)
2922 : GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2923 0 : pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
2924 0 : pDoc->GetValue( aCellPos ));
2925 : }
2926 : else
2927 : {
2928 0 : if (pDoc)
2929 : GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2930 0 : aCell.nNumberFormat, pDoc->GetValue( aCellPos ));
2931 0 : }
2932 : }
2933 : else
2934 : {
2935 0 : if (GetCellText(aCell, aCellPos))
2936 0 : if (!aCell.sStringValue.isEmpty())
2937 : {
2938 0 : AddAttribute(sAttrValueType, XML_STRING);
2939 0 : AddAttribute(sAttrStringValue, aCell.sStringValue);
2940 : }
2941 0 : }
2942 : }
2943 : }
2944 0 : break;
2945 : default:
2946 : {
2947 : // added to avoid warnings
2948 : }
2949 : }
2950 2 : rtl::OUString* pCellString(&sElemCell);
2951 2 : if (aCell.bIsCovered)
2952 : {
2953 0 : pCellString = &sElemCoveredCell;
2954 : }
2955 : else
2956 : {
2957 2 : if (aCell.bIsMergedBase)
2958 : {
2959 0 : sal_Int32 nColumns(aCell.aMergeRange.EndColumn - aCell.aMergeRange.StartColumn + 1);
2960 0 : sal_Int32 nRows(aCell.aMergeRange.EndRow - aCell.aMergeRange.StartRow + 1);
2961 0 : rtl::OUStringBuffer sColumns;
2962 0 : rtl::OUStringBuffer sRows;
2963 0 : ::sax::Converter::convertNumber(sColumns, nColumns);
2964 0 : ::sax::Converter::convertNumber(sRows, nRows);
2965 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, sColumns.makeStringAndClear());
2966 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, sRows.makeStringAndClear());
2967 : }
2968 : }
2969 2 : SvXMLElementExport aElemC(*this, *pCellString, true, true);
2970 2 : CheckAttrList();
2971 2 : WriteAreaLink(aCell);
2972 2 : WriteAnnotation(aCell);
2973 2 : WriteDetective(aCell);
2974 :
2975 2 : bool bEditCell = false;
2976 :
2977 2 : if (!bIsEmpty)
2978 : {
2979 2 : if ((aCell.nType == table::CellContentType_TEXT && IsEditCell(aCell)) ||
2980 0 : (aCell.nType == table::CellContentType_FORMULA && IsMultiLineFormulaCell(aCell)))
2981 : {
2982 0 : bEditCell = true;
2983 0 : uno::Reference<text::XText> xText(xCurrentTableCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row), uno::UNO_QUERY);
2984 0 : if ( xText.is())
2985 0 : GetTextParagraphExport()->exportText(xText, false, false);
2986 : }
2987 : else
2988 : {
2989 2 : SvXMLElementExport aElemP(*this, sElemP, true, false);
2990 2 : bool bPrevCharWasSpace(true);
2991 2 : if (GetCellText(aCell, aCellPos))
2992 2 : GetTextParagraphExport()->exportText(aCell.sStringValue, bPrevCharWasSpace);
2993 : }
2994 : }
2995 2 : WriteShapes(aCell);
2996 2 : if (!bIsEmpty)
2997 2 : IncrementProgressBar(bEditCell);
2998 2 : }
2999 :
3000 0 : void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, awt::Point* pPoint)
3001 : {
3002 0 : uno::Reference < beans::XPropertySet > xShapeProps ( xShape, uno::UNO_QUERY );
3003 0 : bool bIsChart( false );
3004 0 : rtl::OUString sPropCLSID (RTL_CONSTASCII_USTRINGPARAM("CLSID"));
3005 0 : rtl::OUString sPropModel (RTL_CONSTASCII_USTRINGPARAM("Model"));
3006 0 : rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName"));
3007 0 : if (xShapeProps.is())
3008 : {
3009 0 : sal_Int32 nZOrder = 0;
3010 0 : if (xShapeProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZOrder"))) >>= nZOrder)
3011 : {
3012 0 : rtl::OUStringBuffer sBuffer;
3013 0 : ::sax::Converter::convertNumber(sBuffer, nZOrder);
3014 0 : AddAttribute(XML_NAMESPACE_DRAW, XML_ZINDEX, sBuffer.makeStringAndClear());
3015 : }
3016 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xShapeProps->getPropertySetInfo();
3017 0 : if( xPropSetInfo->hasPropertyByName( sPropCLSID ) )
3018 : {
3019 0 : rtl::OUString sCLSID;
3020 0 : if (xShapeProps->getPropertyValue( sPropCLSID ) >>= sCLSID)
3021 : {
3022 0 : if ( sCLSID.equalsIgnoreAsciiCase(GetChartExport()->getChartCLSID()) )
3023 : {
3024 : // we have a chart
3025 0 : ::rtl::OUString sRanges;
3026 0 : if ( pDoc )
3027 : {
3028 0 : ::rtl::OUString aChartName;
3029 0 : xShapeProps->getPropertyValue( sPersistName ) >>= aChartName;
3030 0 : ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection();
3031 0 : if (pCollection)
3032 : {
3033 0 : ScChartListener* pListener = pCollection->findByName(aChartName);
3034 0 : if (pListener)
3035 : {
3036 0 : const ScRangeListRef& rRangeList = pListener->GetRangeList();
3037 0 : if ( rRangeList.Is() )
3038 : {
3039 0 : ScRangeStringConverter::GetStringFromRangeList( sRanges, rRangeList, pDoc, FormulaGrammar::CONV_OOO );
3040 0 : if ( !sRanges.isEmpty() )
3041 : {
3042 0 : bIsChart = true;
3043 0 : SvXMLAttributeList* pAttrList = new SvXMLAttributeList();
3044 0 : if ( pAttrList )
3045 : {
3046 : pAttrList->AddAttribute(
3047 0 : GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges );
3048 : }
3049 0 : GetShapeExport()->exportShape( xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList );
3050 : }
3051 0 : }
3052 : }
3053 0 : }
3054 : }
3055 :
3056 0 : if ( sRanges.isEmpty() )
3057 : {
3058 0 : uno::Reference< frame::XModel > xChartModel;
3059 0 : if( ( xShapeProps->getPropertyValue( sPropModel ) >>= xChartModel ) &&
3060 0 : xChartModel.is())
3061 : {
3062 0 : uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY );
3063 0 : uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartModel, uno::UNO_QUERY );
3064 0 : if( xChartDoc.is() && xReceiver.is() &&
3065 0 : ! xChartDoc->hasInternalDataProvider())
3066 : {
3067 : // we have a chart that gets its data from Calc
3068 0 : bIsChart = true;
3069 : uno::Sequence< ::rtl::OUString > aRepresentations(
3070 0 : xReceiver->getUsedRangeRepresentations());
3071 0 : SvXMLAttributeList* pAttrList = 0;
3072 0 : if(aRepresentations.getLength())
3073 : {
3074 : // add the ranges used by the chart to the shape
3075 : // element to be able to start listening after
3076 : // load (when the chart is not yet loaded)
3077 0 : uno::Reference< chart2::data::XRangeXMLConversion > xRangeConverter( xChartDoc->getDataProvider(), uno::UNO_QUERY );
3078 0 : sRanges = lcl_RangeSequenceToString( aRepresentations, xRangeConverter );
3079 0 : pAttrList = new SvXMLAttributeList();
3080 : pAttrList->AddAttribute(
3081 0 : GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges );
3082 : }
3083 0 : GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList);
3084 0 : }
3085 0 : }
3086 0 : }
3087 : }
3088 0 : }
3089 0 : }
3090 : }
3091 0 : if (!bIsChart)
3092 : {
3093 : // #i66550 HLINK_FOR_SHAPES
3094 0 : rtl::OUString sHlink;
3095 0 : uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
3096 0 : if ( xProps.is() )
3097 0 : xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_HYPERLINK ) ) ) >>= sHlink;
3098 :
3099 0 : std::auto_ptr< SvXMLElementExport > pDrawA;
3100 : // enlose shapes with <draw:a> element only if sHlink contains something
3101 0 : if ( !sHlink.isEmpty() )
3102 : {
3103 : // need to get delete the attributes that are pre-loaded
3104 : // for the shape export ( otherwise they will become
3105 : // attributes of the draw:a element ) This *shouldn't*
3106 : // affect performance adversely as there are only a
3107 : // couple of attributes involved
3108 0 : uno::Reference< xml::sax::XAttributeList > xSaveAttribs( new SvXMLAttributeList( GetAttrList() ) );
3109 0 : ClearAttrList();
3110 : // Add Hlink
3111 0 : AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3112 0 : AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sHlink);
3113 0 : pDrawA.reset( new SvXMLElementExport( *this, XML_NAMESPACE_DRAW, XML_A, false, false ) );
3114 : // Attribute list has been cleared by previous operation
3115 : // re-add pre-loaded attributes
3116 0 : AddAttributeList( xSaveAttribs );
3117 : }
3118 0 : GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint);
3119 : }
3120 0 : IncrementProgressBar(false);
3121 0 : }
3122 :
3123 2 : void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
3124 : {
3125 2 : if( rMyCell.bHasShape && !rMyCell.aShapeList.empty() && pDoc )
3126 : {
3127 0 : awt::Point aPoint;
3128 : Rectangle aRec = pDoc->GetMMRect(static_cast<SCCOL>(rMyCell.aCellAddress.Column), static_cast<SCROW>(rMyCell.aCellAddress.Row),
3129 0 : static_cast<SCCOL>(rMyCell.aCellAddress.Column), static_cast<SCROW>(rMyCell.aCellAddress.Row), static_cast<SCTAB>(rMyCell.aCellAddress.Sheet));
3130 0 : bool bNegativePage(pDoc->IsNegativePage(rMyCell.aCellAddress.Sheet));
3131 0 : if (bNegativePage)
3132 0 : aPoint.X = aRec.Right();
3133 : else
3134 0 : aPoint.X = aRec.Left();
3135 0 : aPoint.Y = aRec.Top();
3136 0 : ScMyShapeList::const_iterator aItr = rMyCell.aShapeList.begin();
3137 0 : ScMyShapeList::const_iterator aEndItr(rMyCell.aShapeList.end());
3138 0 : while (aItr != aEndItr)
3139 : {
3140 0 : if (aItr->xShape.is())
3141 : {
3142 0 : if (bNegativePage)
3143 0 : aPoint.X = 2 * aItr->xShape->getPosition().X + aItr->xShape->getSize().Width - aPoint.X;
3144 0 : if ( !aItr->xShape->getShapeType().equals(sCaptionShape) )
3145 : {
3146 0 : rtl::OUString sEndAddress;
3147 0 : ScRangeStringConverter::GetStringFromAddress(sEndAddress, aItr->aEndAddress, pDoc, FormulaGrammar::CONV_OOO);
3148 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_END_CELL_ADDRESS, sEndAddress);
3149 0 : rtl::OUStringBuffer sBuffer;
3150 0 : GetMM100UnitConverter().convertMeasureToXML(
3151 0 : sBuffer, aItr->nEndX);
3152 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_END_X, sBuffer.makeStringAndClear());
3153 0 : GetMM100UnitConverter().convertMeasureToXML(
3154 0 : sBuffer, aItr->nEndY);
3155 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_END_Y, sBuffer.makeStringAndClear());
3156 : }
3157 0 : ExportShape(aItr->xShape, &aPoint);
3158 : }
3159 0 : ++aItr;
3160 : }
3161 : }
3162 2 : }
3163 :
3164 2 : void ScXMLExport::WriteTableShapes()
3165 : {
3166 2 : ScMyTableShapes* pTableShapes(pSharedData->GetTableShapes());
3167 2 : if (pTableShapes && !(*pTableShapes)[nCurrentTable].empty())
3168 : {
3169 : OSL_ENSURE(pTableShapes->size() > static_cast<size_t>(nCurrentTable), "wrong Table");
3170 0 : SvXMLElementExport aShapesElem(*this, XML_NAMESPACE_TABLE, XML_SHAPES, true, false);
3171 0 : ScMyTableXShapes::iterator aItr((*pTableShapes)[nCurrentTable].begin());
3172 0 : ScMyTableXShapes::iterator aEndItr((*pTableShapes)[nCurrentTable].end());
3173 0 : while (aItr != aEndItr)
3174 : {
3175 0 : if (aItr->is())
3176 : {
3177 0 : if (pDoc->IsNegativePage(static_cast<SCTAB>(nCurrentTable)))
3178 : {
3179 0 : awt::Point aPoint((*aItr)->getPosition());
3180 0 : awt::Size aSize((*aItr)->getSize());
3181 0 : aPoint.X += aPoint.X + aSize.Width;
3182 0 : aPoint.Y = 0;
3183 0 : ExportShape(*aItr, &aPoint);
3184 : }
3185 : else
3186 0 : ExportShape(*aItr, NULL);
3187 : }
3188 0 : aItr = (*pTableShapes)[nCurrentTable].erase(aItr);
3189 0 : }
3190 : }
3191 2 : }
3192 :
3193 2 : void ScXMLExport::WriteAreaLink( const ScMyCell& rMyCell )
3194 : {
3195 2 : if( rMyCell.bHasAreaLink )
3196 : {
3197 0 : const ScMyAreaLink& rAreaLink = rMyCell.aAreaLink;
3198 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, rAreaLink.sSourceStr );
3199 0 : AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3200 0 : AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetRelativeReference(rAreaLink.sURL) );
3201 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_FILTER_NAME, rAreaLink.sFilter );
3202 0 : if( !rAreaLink.sFilterOptions.isEmpty() )
3203 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, rAreaLink.sFilterOptions );
3204 0 : OUStringBuffer sValue;
3205 0 : ::sax::Converter::convertNumber( sValue, rAreaLink.GetColCount() );
3206 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_LAST_COLUMN_SPANNED, sValue.makeStringAndClear() );
3207 0 : ::sax::Converter::convertNumber( sValue, rAreaLink.GetRowCount() );
3208 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_LAST_ROW_SPANNED, sValue.makeStringAndClear() );
3209 0 : if( rAreaLink.nRefresh )
3210 : {
3211 : ::sax::Converter::convertDuration( sValue,
3212 0 : (double)rAreaLink.nRefresh / 86400 );
3213 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sValue.makeStringAndClear() );
3214 : }
3215 0 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_CELL_RANGE_SOURCE, true, true );
3216 : }
3217 2 : }
3218 :
3219 0 : void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape >& xShape)
3220 : {
3221 0 : if (pCurrentCell && pCurrentCell->xNoteShape.is() && pCurrentCell->xNoteShape.get() == xShape.get() && pCurrentCell->xAnnotation.is())
3222 : {
3223 0 : rtl::OUString sAuthor(pCurrentCell->xAnnotation->getAuthor());
3224 0 : if (!sAuthor.isEmpty())
3225 : {
3226 : SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC,
3227 : XML_CREATOR, true,
3228 0 : false );
3229 0 : Characters(sAuthor);
3230 : }
3231 :
3232 0 : String aDate(pCurrentCell->xAnnotation->getDate());
3233 0 : if (pDoc)
3234 : {
3235 0 : SvNumberFormatter* pNumForm = pDoc->GetFormatTable();
3236 : double fDate;
3237 0 : sal_uInt32 nfIndex = pNumForm->GetFormatIndex(NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM);
3238 0 : if (pNumForm->IsNumberFormat(aDate, nfIndex, fDate))
3239 : {
3240 0 : rtl::OUStringBuffer sBuf;
3241 0 : GetMM100UnitConverter().convertDateTime(sBuf, fDate,true);
3242 : SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC,
3243 : XML_DATE, true,
3244 0 : false );
3245 0 : Characters(sBuf.makeStringAndClear());
3246 : }
3247 : else
3248 : {
3249 : SvXMLElementExport aDateElem( *this, XML_NAMESPACE_META,
3250 : XML_DATE_STRING, true,
3251 0 : false );
3252 0 : Characters(rtl::OUString(aDate));
3253 : }
3254 : }
3255 : else
3256 : {
3257 : SvXMLElementExport aDateElem( *this, XML_NAMESPACE_META,
3258 : XML_DATE_STRING, true,
3259 0 : false );
3260 0 : Characters(rtl::OUString(aDate));
3261 0 : }
3262 : }
3263 0 : }
3264 :
3265 2 : void ScXMLExport::WriteAnnotation(ScMyCell& rMyCell)
3266 : {
3267 2 : if( rMyCell.bHasAnnotation && rMyCell.xAnnotation.is())
3268 : {
3269 :
3270 0 : if (rMyCell.xAnnotation->getIsVisible())
3271 0 : AddAttribute(XML_NAMESPACE_OFFICE, XML_DISPLAY, XML_TRUE);
3272 :
3273 0 : pCurrentCell = &rMyCell;
3274 :
3275 0 : if(rMyCell.xNoteShape.is())
3276 0 : GetShapeExport()->exportShape(rMyCell.xNoteShape, SEF_DEFAULT|SEF_EXPORT_ANNOTATION, NULL);
3277 :
3278 0 : pCurrentCell = NULL;
3279 :
3280 0 : rMyCell.xNoteShape.clear();
3281 : }
3282 2 : }
3283 :
3284 2 : void ScXMLExport::WriteDetective( const ScMyCell& rMyCell )
3285 : {
3286 2 : if( rMyCell.bHasDetectiveObj || rMyCell.bHasDetectiveOp )
3287 : {
3288 0 : const ScMyDetectiveObjVec& rObjVec = rMyCell.aDetectiveObjVec;
3289 0 : const ScMyDetectiveOpVec& rOpVec = rMyCell.aDetectiveOpVec;
3290 0 : sal_Int32 nObjCount(rObjVec.size());
3291 0 : sal_Int32 nOpCount(rOpVec.size());
3292 0 : if( nObjCount || nOpCount )
3293 : {
3294 0 : SvXMLElementExport aDetElem( *this, XML_NAMESPACE_TABLE, XML_DETECTIVE, true, true );
3295 0 : OUString sString;
3296 0 : ScMyDetectiveObjVec::const_iterator aObjItr(rObjVec.begin());
3297 0 : ScMyDetectiveObjVec::const_iterator aEndObjItr(rObjVec.end());
3298 0 : while(aObjItr != aEndObjItr)
3299 : {
3300 0 : if (aObjItr->eObjType != SC_DETOBJ_CIRCLE)
3301 : {
3302 0 : if( (aObjItr->eObjType == SC_DETOBJ_ARROW) || (aObjItr->eObjType == SC_DETOBJ_TOOTHERTAB))
3303 : {
3304 0 : ScRangeStringConverter::GetStringFromRange( sString, aObjItr->aSourceRange, pDoc, FormulaGrammar::CONV_OOO );
3305 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sString );
3306 : }
3307 0 : ScXMLConverter::GetStringFromDetObjType( sString, aObjItr->eObjType );
3308 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_DIRECTION, sString );
3309 0 : if( aObjItr->bHasError )
3310 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_CONTAINS_ERROR, XML_TRUE );
3311 : }
3312 : else
3313 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_MARKED_INVALID, XML_TRUE );
3314 0 : SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_HIGHLIGHTED_RANGE, true, true );
3315 0 : ++aObjItr;
3316 0 : }
3317 0 : OUStringBuffer aBuffer;
3318 0 : ScMyDetectiveOpVec::const_iterator aOpItr(rOpVec.begin());
3319 0 : ScMyDetectiveOpVec::const_iterator aEndOpItr(rOpVec.end());
3320 0 : while(aOpItr != aEndOpItr)
3321 : {
3322 0 : OUString sOpString;
3323 0 : ScXMLConverter::GetStringFromDetOpType( sOpString, aOpItr->eOpType );
3324 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, sOpString );
3325 0 : ::sax::Converter::convertNumber( aBuffer, aOpItr->nIndex );
3326 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_INDEX, aBuffer.makeStringAndClear() );
3327 0 : SvXMLElementExport aRangeElem( *this, XML_NAMESPACE_TABLE, XML_OPERATION, true, true );
3328 0 : ++aOpItr;
3329 0 : }
3330 : }
3331 : }
3332 2 : }
3333 :
3334 2 : void ScXMLExport::SetRepeatAttribute(sal_Int32 nEqualCellCount, bool bIncProgress)
3335 : {
3336 : // nEqualCellCount is additional cells, so the attribute value is nEqualCellCount+1
3337 2 : if (nEqualCellCount > 0)
3338 : {
3339 0 : sal_Int32 nTemp(nEqualCellCount + 1);
3340 0 : OUString sOUEqualCellCount(OUString::valueOf(nTemp));
3341 0 : AddAttribute(sAttrColumnsRepeated, sOUEqualCellCount);
3342 0 : if (bIncProgress)
3343 0 : IncrementProgressBar(sal_False, nEqualCellCount);
3344 : }
3345 2 : }
3346 :
3347 0 : bool ScXMLExport::IsCellTypeEqual (const ScMyCell& aCell1, const ScMyCell& aCell2) const
3348 : {
3349 0 : return (aCell1.nType == aCell2.nType);
3350 : }
3351 :
3352 0 : bool ScXMLExport::IsEditCell(const com::sun::star::table::CellAddress& aAddress, ScMyCell* pMyCell) const
3353 : {
3354 : ScAddress aCoreAddress(static_cast<SCCOL>(aAddress.Column),
3355 : static_cast<SCROW>(aAddress.Row),
3356 0 : static_cast<SCTAB>(aAddress.Sheet));
3357 0 : ScBaseCell* pBaseCell = GetDocument() ? GetDocument()->GetCell(aCoreAddress) : NULL;
3358 0 : if (pMyCell)
3359 0 : pMyCell->pBaseCell = pBaseCell;
3360 :
3361 0 : if (pBaseCell)
3362 0 : return (pBaseCell->GetCellType() == CELLTYPE_EDIT);
3363 0 : return false;
3364 : }
3365 :
3366 0 : bool ScXMLExport::IsEditCell(ScMyCell& rCell) const
3367 : {
3368 0 : if (rCell.bKnowWhetherIsEditCell)
3369 0 : return rCell.bIsEditCell;
3370 : else
3371 : {
3372 0 : rCell.bIsEditCell = IsEditCell(rCell.aCellAddress, &rCell);
3373 0 : rCell.bKnowWhetherIsEditCell = true;
3374 0 : return rCell.bIsEditCell;
3375 : }
3376 : }
3377 :
3378 0 : bool ScXMLExport::IsMultiLineFormulaCell(ScMyCell& rCell) const
3379 : {
3380 0 : if (rCell.pBaseCell)
3381 : {
3382 0 : if (rCell.pBaseCell->GetCellType() != CELLTYPE_FORMULA)
3383 0 : return false;
3384 :
3385 0 : return static_cast<ScFormulaCell*>(rCell.pBaseCell)->IsMultilineResult();
3386 : }
3387 :
3388 : ScAddress aAddr(static_cast<SCCOL>(rCell.aCellAddress.Column),
3389 : static_cast<SCROW>(rCell.aCellAddress.Row),
3390 0 : static_cast<SCTAB>(rCell.aCellAddress.Sheet));
3391 0 : ScBaseCell* pBaseCell = pDoc ? pDoc->GetCell(aAddr) : NULL;
3392 0 : if (!pBaseCell)
3393 0 : return false;
3394 :
3395 0 : rCell.pBaseCell = pBaseCell;
3396 0 : if (rCell.pBaseCell->GetCellType() != CELLTYPE_FORMULA)
3397 0 : return false;
3398 :
3399 0 : return static_cast<ScFormulaCell*>(rCell.pBaseCell)->IsMultilineResult();
3400 : }
3401 :
3402 0 : bool ScXMLExport::IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2)
3403 : {
3404 0 : ScAddress aCellPos1;
3405 0 : ScUnoConversion::FillScAddress( aCellPos1, aCell1.aCellAddress );
3406 0 : ScAddress aCellPos2;
3407 0 : ScUnoConversion::FillScAddress( aCellPos2, aCell2.aCellAddress );
3408 0 : bool bIsEqual = false;
3409 0 : if( !aCell1.bIsMergedBase && !aCell2.bIsMergedBase &&
3410 : aCell1.bIsCovered == aCell2.bIsCovered &&
3411 0 : !aCell1.bIsMatrixBase && !aCell2.bIsMatrixBase &&
3412 : aCell1.bIsMatrixCovered == aCell2.bIsMatrixCovered &&
3413 : aCell1.bHasAnnotation == aCell2.bHasAnnotation &&
3414 0 : !aCell1.bHasShape && !aCell2.bHasShape &&
3415 : aCell1.bHasAreaLink == aCell2.bHasAreaLink &&
3416 0 : !aCell1.bHasDetectiveObj && !aCell2.bHasDetectiveObj)
3417 : {
3418 0 : if( (aCell1.bHasAreaLink &&
3419 0 : (aCell1.aAreaLink.GetColCount() == 1) &&
3420 0 : (aCell2.aAreaLink.GetColCount() == 1) &&
3421 0 : aCell1.aAreaLink.Compare( aCell2.aAreaLink ) ) ||
3422 0 : !aCell1.bHasAreaLink )
3423 : {
3424 0 : if (!aCell1.bHasAnnotation || (aCell1.bHasAnnotation && false/*IsAnnotationEqual(aCell1.xCell, aCell2.xCell)*/)) // no longer compareable
3425 : {
3426 0 : if ((((aCell1.nStyleIndex == aCell2.nStyleIndex) && (aCell1.bIsAutoStyle == aCell2.bIsAutoStyle)) ||
3427 : ((aCell1.nStyleIndex == aCell2.nStyleIndex) && (aCell1.nStyleIndex == -1))) &&
3428 : (aCell1.nValidationIndex == aCell2.nValidationIndex) &&
3429 0 : IsCellTypeEqual(aCell1, aCell2))
3430 : {
3431 0 : switch ( aCell1.nType )
3432 : {
3433 : case table::CellContentType_EMPTY :
3434 : {
3435 0 : bIsEqual = true;
3436 : }
3437 0 : break;
3438 : case table::CellContentType_VALUE :
3439 : {
3440 0 : if(!aCell1.bHasDoubleValue)
3441 : {
3442 0 : aCell1.fValue = pDoc->GetValue( aCellPos1 );
3443 0 : aCell1.bHasDoubleValue = true;
3444 : }
3445 0 : if (!aCell2.bHasDoubleValue)
3446 : {
3447 0 : aCell2.fValue = pDoc->GetValue( aCellPos2 );
3448 0 : aCell2.bHasDoubleValue = true;
3449 : }
3450 : // #i29101# number format may be different from column default styles,
3451 : // but can lead to different value types, so it must also be compared
3452 : bIsEqual = (aCell1.nNumberFormat == aCell2.nNumberFormat) &&
3453 0 : (aCell1.fValue == aCell2.fValue);
3454 : }
3455 0 : break;
3456 : case table::CellContentType_TEXT :
3457 : {
3458 0 : if (IsEditCell(aCell1) || IsEditCell(aCell2))
3459 0 : bIsEqual = false;
3460 : else
3461 : {
3462 0 : if (GetCellText(aCell1, aCellPos1) && GetCellText(aCell2, aCellPos2))
3463 : {
3464 0 : bIsEqual = (aCell1.sStringValue == aCell2.sStringValue) &&
3465 0 : (lcl_GetRawString(pDoc, aCellPos1) == lcl_GetRawString(pDoc, aCellPos2));
3466 : }
3467 : else
3468 0 : bIsEqual = false;
3469 : }
3470 : }
3471 0 : break;
3472 : case table::CellContentType_FORMULA :
3473 : {
3474 0 : bIsEqual = false;
3475 : }
3476 0 : break;
3477 : default :
3478 : {
3479 0 : bIsEqual = false;
3480 : }
3481 0 : break;
3482 : }
3483 : }
3484 : }
3485 : }
3486 : }
3487 0 : return bIsEqual;
3488 : }
3489 :
3490 2 : void ScXMLExport::WriteCalculationSettings(const uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc)
3491 : {
3492 2 : uno::Reference<beans::XPropertySet> xPropertySet(xSpreadDoc, uno::UNO_QUERY);
3493 2 : if (xPropertySet.is())
3494 : {
3495 2 : bool bCalcAsShown (::cppu::any2bool( xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_CALCASSHOWN))) ));
3496 2 : bool bIgnoreCase (::cppu::any2bool( xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_IGNORECASE))) ));
3497 2 : bool bLookUpLabels (::cppu::any2bool( xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_LOOKUPLABELS))) ));
3498 2 : bool bMatchWholeCell (::cppu::any2bool( xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_MATCHWHOLE))) ));
3499 2 : bool bUseRegularExpressions (::cppu::any2bool( xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_REGEXENABLED))) ));
3500 2 : bool bIsIterationEnabled (::cppu::any2bool( xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERENABLED))) ));
3501 2 : sal_uInt16 nYear2000 (pDoc ? pDoc->GetDocOptions().GetYear2000() : 0);
3502 2 : sal_Int32 nIterationCount(100);
3503 2 : xPropertySet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERCOUNT))) >>= nIterationCount;
3504 2 : double fIterationEpsilon = 0;
3505 2 : xPropertySet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITEREPSILON))) >>= fIterationEpsilon;
3506 2 : util::Date aNullDate;
3507 2 : xPropertySet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NULLDATE))) >>= aNullDate;
3508 4 : if (bCalcAsShown || bIgnoreCase || !bLookUpLabels || !bMatchWholeCell || !bUseRegularExpressions ||
3509 2 : bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001) ||
3510 : aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 || nYear2000 != 1930)
3511 : {
3512 0 : if (bIgnoreCase)
3513 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_FALSE);
3514 0 : if (bCalcAsShown)
3515 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_PRECISION_AS_SHOWN, XML_TRUE);
3516 0 : if (!bMatchWholeCell)
3517 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL, XML_FALSE);
3518 0 : if (!bLookUpLabels)
3519 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_AUTOMATIC_FIND_LABELS, XML_FALSE);
3520 0 : if (!bUseRegularExpressions)
3521 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_USE_REGULAR_EXPRESSIONS, XML_FALSE);
3522 0 : if (nYear2000 != 1930)
3523 : {
3524 0 : rtl::OUStringBuffer sBuffer;
3525 0 : ::sax::Converter::convertNumber(sBuffer, nYear2000);
3526 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, sBuffer.makeStringAndClear());
3527 : }
3528 0 : SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, true, true);
3529 : {
3530 0 : if (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899)
3531 : {
3532 0 : rtl::OUStringBuffer sDate;
3533 0 : GetMM100UnitConverter().convertDateTime(sDate, 0.0, aNullDate);
3534 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_VALUE, sDate.makeStringAndClear());
3535 0 : SvXMLElementExport aElemNullDate(*this, XML_NAMESPACE_TABLE, XML_NULL_DATE, true, true);
3536 : }
3537 0 : if (bIsIterationEnabled || nIterationCount != 100 || !::rtl::math::approxEqual(fIterationEpsilon, 0.001))
3538 : {
3539 0 : rtl::OUStringBuffer sBuffer;
3540 0 : if (bIsIterationEnabled)
3541 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_STATUS, XML_ENABLE);
3542 0 : if (nIterationCount != 100)
3543 : {
3544 : ::sax::Converter::convertNumber(sBuffer,
3545 0 : nIterationCount);
3546 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_STEPS, sBuffer.makeStringAndClear());
3547 : }
3548 0 : if (!::rtl::math::approxEqual(fIterationEpsilon, 0.001))
3549 : {
3550 : ::sax::Converter::convertDouble(sBuffer,
3551 0 : fIterationEpsilon);
3552 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_MAXIMUM_DIFFERENCE, sBuffer.makeStringAndClear());
3553 : }
3554 0 : SvXMLElementExport aElemIteration(*this, XML_NAMESPACE_TABLE, XML_ITERATION, true, true);
3555 : }
3556 0 : }
3557 : }
3558 2 : }
3559 2 : }
3560 :
3561 2 : void ScXMLExport::WriteTableSource()
3562 : {
3563 2 : uno::Reference <sheet::XSheetLinkable> xLinkable (xCurrentTable, uno::UNO_QUERY);
3564 2 : if (xLinkable.is() && GetModel().is())
3565 : {
3566 2 : sheet::SheetLinkMode nMode (xLinkable->getLinkMode());
3567 2 : if (nMode != sheet::SheetLinkMode_NONE)
3568 : {
3569 0 : rtl::OUString sLink (xLinkable->getLinkUrl());
3570 0 : uno::Reference <beans::XPropertySet> xProps (GetModel(), uno::UNO_QUERY);
3571 0 : if (xProps.is())
3572 : {
3573 0 : uno::Reference <container::XIndexAccess> xIndex(xProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETLINKS))), uno::UNO_QUERY);
3574 0 : if (xIndex.is())
3575 : {
3576 0 : sal_Int32 nCount(xIndex->getCount());
3577 0 : if (nCount)
3578 : {
3579 0 : bool bFound(false);
3580 0 : uno::Reference <beans::XPropertySet> xLinkProps;
3581 0 : for (sal_Int32 i = 0; (i < nCount) && !bFound; ++i)
3582 : {
3583 0 : xLinkProps.set(xIndex->getByIndex(i), uno::UNO_QUERY);
3584 0 : if (xLinkProps.is())
3585 : {
3586 0 : rtl::OUString sNewLink;
3587 0 : if (xLinkProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_LINKURL))) >>= sNewLink)
3588 0 : bFound = sLink.equals(sNewLink);
3589 : }
3590 : }
3591 0 : if (bFound && xLinkProps.is())
3592 : {
3593 0 : rtl::OUString sFilter;
3594 0 : rtl::OUString sFilterOptions;
3595 0 : rtl::OUString sTableName (xLinkable->getLinkSheetName());
3596 0 : sal_Int32 nRefresh(0);
3597 0 : xLinkProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FILTER))) >>= sFilter;
3598 0 : xLinkProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FILTOPT))) >>= sFilterOptions;
3599 0 : xLinkProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_REFDELAY))) >>= nRefresh;
3600 0 : if (!sLink.isEmpty())
3601 : {
3602 0 : AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
3603 0 : AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetRelativeReference(sLink));
3604 0 : if (!sTableName.isEmpty())
3605 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, sTableName);
3606 0 : if (!sFilter.isEmpty())
3607 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_FILTER_NAME, sFilter);
3608 0 : if (!sFilterOptions.isEmpty())
3609 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, sFilterOptions);
3610 0 : if (nMode != sheet::SheetLinkMode_NORMAL)
3611 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_MODE, XML_COPY_RESULTS_ONLY);
3612 0 : if( nRefresh )
3613 : {
3614 0 : rtl::OUStringBuffer sBuffer;
3615 : ::sax::Converter::convertDuration( sBuffer,
3616 0 : (double)nRefresh / 86400 );
3617 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sBuffer.makeStringAndClear() );
3618 : }
3619 0 : SvXMLElementExport aSourceElem(*this, XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, true, true);
3620 0 : }
3621 0 : }
3622 : }
3623 0 : }
3624 0 : }
3625 : }
3626 2 : }
3627 2 : }
3628 :
3629 : // core implementation
3630 2 : void ScXMLExport::WriteScenario()
3631 : {
3632 2 : if (pDoc && pDoc->IsScenario(static_cast<SCTAB>(nCurrentTable)))
3633 : {
3634 0 : rtl::OUString sComment;
3635 0 : Color aColor;
3636 : sal_uInt16 nFlags;
3637 0 : pDoc->GetScenarioData(static_cast<SCTAB>(nCurrentTable), sComment, aColor, nFlags);
3638 0 : if (!(nFlags & SC_SCENARIO_SHOWFRAME))
3639 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_BORDER, XML_FALSE);
3640 0 : rtl::OUStringBuffer aBuffer;
3641 0 : ::sax::Converter::convertColor(aBuffer, aColor.GetColor());
3642 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_BORDER_COLOR, aBuffer.makeStringAndClear());
3643 0 : if (!(nFlags & SC_SCENARIO_TWOWAY))
3644 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_COPY_BACK, XML_FALSE);
3645 0 : if (!(nFlags & SC_SCENARIO_ATTRIB))
3646 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_COPY_STYLES, XML_FALSE);
3647 0 : if (nFlags & SC_SCENARIO_VALUE)
3648 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_COPY_FORMULAS, XML_FALSE);
3649 0 : if (nFlags & SC_SCENARIO_PROTECT)
3650 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE);
3651 : ::sax::Converter::convertBool(aBuffer,
3652 0 : pDoc->IsActiveScenario(static_cast<SCTAB>(nCurrentTable)));
3653 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_IS_ACTIVE, aBuffer.makeStringAndClear());
3654 0 : const ScRangeList* pRangeList = pDoc->GetScenarioRanges(static_cast<SCTAB>(nCurrentTable));
3655 0 : rtl::OUString sRangeListStr;
3656 0 : ScRangeStringConverter::GetStringFromRangeList( sRangeListStr, pRangeList, pDoc, FormulaGrammar::CONV_OOO );
3657 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_SCENARIO_RANGES, sRangeListStr);
3658 0 : if (!sComment.isEmpty())
3659 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_COMMENT, sComment);
3660 0 : SvXMLElementExport aElem(*this, XML_NAMESPACE_TABLE, XML_SCENARIO, sal_True, sal_True);
3661 : }
3662 2 : }
3663 :
3664 2 : void ScXMLExport::WriteTheLabelRanges( const uno::Reference< sheet::XSpreadsheetDocument >& xSpreadDoc )
3665 : {
3666 2 : uno::Reference< beans::XPropertySet > xDocProp( xSpreadDoc, uno::UNO_QUERY );
3667 4 : if( !xDocProp.is() ) return;
3668 :
3669 2 : sal_Int32 nCount(0);
3670 2 : uno::Reference< container::XIndexAccess > xColRangesIAccess(xDocProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLLABELRNG ) ) ), uno::UNO_QUERY);
3671 2 : if( xColRangesIAccess.is() )
3672 2 : nCount += xColRangesIAccess->getCount();
3673 :
3674 2 : uno::Reference< container::XIndexAccess > xRowRangesIAccess(xDocProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ROWLABELRNG ) ) ), uno::UNO_QUERY);
3675 2 : if( xRowRangesIAccess.is() )
3676 2 : nCount += xRowRangesIAccess->getCount();
3677 :
3678 2 : if( nCount )
3679 : {
3680 0 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGES, true, true );
3681 0 : WriteLabelRanges( xColRangesIAccess, true );
3682 0 : WriteLabelRanges( xRowRangesIAccess, false );
3683 2 : }
3684 : }
3685 :
3686 0 : void ScXMLExport::WriteLabelRanges( const uno::Reference< container::XIndexAccess >& xRangesIAccess, bool bColumn )
3687 : {
3688 0 : if( !xRangesIAccess.is() ) return;
3689 :
3690 0 : sal_Int32 nCount(xRangesIAccess->getCount());
3691 0 : for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
3692 : {
3693 0 : uno::Reference< sheet::XLabelRange > xRange(xRangesIAccess->getByIndex( nIndex ), uno::UNO_QUERY);
3694 0 : if( xRange.is() )
3695 : {
3696 0 : OUString sRangeStr;
3697 0 : table::CellRangeAddress aCellRange( xRange->getLabelArea() );
3698 0 : ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, pDoc, FormulaGrammar::CONV_OOO );
3699 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_LABEL_CELL_RANGE_ADDRESS, sRangeStr );
3700 0 : aCellRange = xRange->getDataArea();
3701 0 : ScRangeStringConverter::GetStringFromRange( sRangeStr, aCellRange, pDoc, FormulaGrammar::CONV_OOO );
3702 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_DATA_CELL_RANGE_ADDRESS, sRangeStr );
3703 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_ORIENTATION, bColumn ? XML_COLUMN : XML_ROW );
3704 0 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_LABEL_RANGE, true, true );
3705 : }
3706 0 : }
3707 : }
3708 :
3709 2 : void ScXMLExport::WriteNamedExpressions()
3710 : {
3711 2 : if (!pDoc)
3712 2 : return;
3713 2 : ScRangeName* pNamedRanges = pDoc->GetRangeName();
3714 2 : WriteNamedRange(pNamedRanges);
3715 : }
3716 :
3717 2 : void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
3718 : {
3719 : //write a global or local ScRangeName
3720 2 : SvXMLElementExport aElemNEs(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSIONS, true, true);
3721 2 : for (ScRangeName::iterator it = pRangeName->begin(); it != pRangeName->end(); ++it)
3722 : {
3723 0 : AddAttribute(sAttrName, it->second->GetName());
3724 :
3725 0 : rtl::OUString sBaseCellAddress;
3726 0 : ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, it->second->GetPos(), pDoc,
3727 0 : FormulaGrammar::CONV_OOO, ' ', false, SCA_ABS_3D);
3728 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sBaseCellAddress);
3729 :
3730 0 : String sSymbol;
3731 0 : it->second->GetSymbol(sSymbol, pDoc->GetStorageGrammar());
3732 0 : rtl::OUString sTempSymbol(sSymbol);
3733 0 : ScRange aRange;
3734 0 : if (it->second->IsReference(aRange))
3735 : {
3736 :
3737 0 : rtl::OUString sContent(sTempSymbol.copy(1, sTempSymbol.getLength() -2 ));
3738 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sContent);
3739 :
3740 0 : sal_Int32 nRangeType = it->second->GetUnoType();
3741 0 : rtl::OUStringBuffer sBufferRangeType;
3742 0 : if ((nRangeType & sheet::NamedRangeFlag::COLUMN_HEADER) == sheet::NamedRangeFlag::COLUMN_HEADER)
3743 0 : sBufferRangeType.append(GetXMLToken(XML_REPEAT_COLUMN));
3744 0 : if ((nRangeType & sheet::NamedRangeFlag::ROW_HEADER) == sheet::NamedRangeFlag::ROW_HEADER)
3745 : {
3746 0 : if (sBufferRangeType.getLength() > 0)
3747 0 : sBufferRangeType.appendAscii(" ");
3748 0 : sBufferRangeType.append(GetXMLToken(XML_REPEAT_ROW));
3749 : }
3750 0 : if ((nRangeType & sheet::NamedRangeFlag::FILTER_CRITERIA) == sheet::NamedRangeFlag::FILTER_CRITERIA)
3751 : {
3752 0 : if (sBufferRangeType.getLength() > 0)
3753 0 : sBufferRangeType.appendAscii(" ");
3754 0 : sBufferRangeType.append(GetXMLToken(XML_FILTER));
3755 : }
3756 0 : if ((nRangeType & sheet::NamedRangeFlag::PRINT_AREA) == sheet::NamedRangeFlag::PRINT_AREA)
3757 : {
3758 0 : if (sBufferRangeType.getLength() > 0)
3759 0 : sBufferRangeType.appendAscii(" ");
3760 0 : sBufferRangeType.append(GetXMLToken(XML_PRINT_RANGE));
3761 : }
3762 0 : rtl::OUString sRangeType = sBufferRangeType.makeStringAndClear();
3763 0 : if (!sRangeType.isEmpty())
3764 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_RANGE_USABLE_AS, sRangeType);
3765 0 : SvXMLElementExport aElemNR(*this, XML_NAMESPACE_TABLE, XML_NAMED_RANGE, true, true);
3766 :
3767 : }
3768 : else
3769 : {
3770 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_EXPRESSION, sTempSymbol);
3771 0 : SvXMLElementExport aElemNE(*this, XML_NAMESPACE_TABLE, XML_NAMED_EXPRESSION, true, true);
3772 : }
3773 2 : }
3774 2 : }
3775 :
3776 : namespace {
3777 :
3778 0 : rtl::OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry, bool bFirst = true)
3779 : {
3780 0 : switch(rEntry.GetType())
3781 : {
3782 : case COLORSCALE_MIN:
3783 0 : return rtl::OUString("minimum");
3784 : case COLORSCALE_MAX:
3785 0 : return rtl::OUString("maximum");
3786 : case COLORSCALE_PERCENT:
3787 0 : return rtl::OUString("percent");
3788 : case COLORSCALE_PERCENTILE:
3789 0 : return rtl::OUString("percentile");
3790 : case COLORSCALE_FORMULA:
3791 0 : return rtl::OUString("formula");
3792 : case COLORSCALE_VALUE:
3793 0 : return rtl::OUString("number");
3794 : case COLORSCALE_AUTO:
3795 : // only important for data bars
3796 0 : if(bFirst)
3797 0 : return rtl::OUString("auto-minimum");
3798 : else
3799 0 : return rtl::OUString("auto-maximum");
3800 : }
3801 0 : return rtl::OUString();
3802 : }
3803 :
3804 0 : rtl::OUString getIconSetName(ScIconSetType eType)
3805 : {
3806 0 : const char* pName = NULL;
3807 0 : ScIconSetMap* pMap = ScIconSetFormat::getIconSetMap();
3808 0 : for(;pMap->pName;++pMap)
3809 : {
3810 0 : if(pMap->eType == eType)
3811 : {
3812 0 : pName = pMap->pName;
3813 0 : break;
3814 : }
3815 : }
3816 : assert(pName);
3817 0 : return rtl::OUString::createFromAscii(pName);
3818 : }
3819 :
3820 : }
3821 :
3822 2 : void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
3823 : {
3824 2 : ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(nTab);
3825 2 : if(pCondFormatList)
3826 : {
3827 2 : if(pCondFormatList && !pCondFormatList->size())
3828 2 : return;
3829 :
3830 0 : SvXMLElementExport aElementCondFormats(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMATS, true, true);
3831 :
3832 0 : if(pCondFormatList)
3833 : {
3834 0 : for(ScConditionalFormatList::const_iterator itr = pCondFormatList->begin();
3835 0 : itr != pCondFormatList->end(); ++itr)
3836 : {
3837 0 : rtl::OUString sRanges;
3838 0 : const ScRangeList& rRangeList = itr->GetRange();
3839 0 : ScRangeStringConverter::GetStringFromRangeList( sRanges, &rRangeList, pDoc, formula::FormulaGrammar::CONV_ODF );
3840 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TARGET_RANGE_ADDRESS, sRanges);
3841 0 : SvXMLElementExport aElementCondFormat(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMAT, true, true);
3842 0 : size_t nEntries = itr->size();
3843 0 : for(size_t i = 0; i < nEntries; ++i)
3844 : {
3845 0 : const ScFormatEntry* pFormatEntry = itr->GetEntry(i);
3846 0 : if(pFormatEntry->GetType()==condformat::CONDITION)
3847 : {
3848 0 : const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry);
3849 0 : rtl::OUStringBuffer aCond;
3850 0 : ScAddress aPos = pEntry->GetSrcPos();
3851 0 : switch(pEntry->GetOperation())
3852 : {
3853 : case SC_COND_EQUAL:
3854 0 : aCond.append('=');
3855 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3856 0 : break;
3857 : case SC_COND_LESS:
3858 0 : aCond.append('<');
3859 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3860 0 : break;
3861 : case SC_COND_GREATER:
3862 0 : aCond.append('>');
3863 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3864 0 : break;
3865 : case SC_COND_EQLESS:
3866 0 : aCond.append("<=");
3867 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3868 0 : break;
3869 : case SC_COND_EQGREATER:
3870 0 : aCond.append(">=");
3871 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3872 0 : break;
3873 : case SC_COND_NOTEQUAL:
3874 0 : aCond.append("!=");
3875 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3876 0 : break;
3877 : case SC_COND_BETWEEN:
3878 0 : aCond.append(rtl::OUString("between("));
3879 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3880 0 : aCond.append(',');
3881 0 : aCond.append(pEntry->GetExpression(aPos, 1, 0, formula::FormulaGrammar::GRAM_ODFF));
3882 0 : aCond.append(')');
3883 0 : break;
3884 : case SC_COND_NOTBETWEEN:
3885 0 : aCond.append(rtl::OUString("not-between("));
3886 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3887 0 : aCond.append(',');
3888 0 : aCond.append(pEntry->GetExpression(aPos, 1, 0, formula::FormulaGrammar::GRAM_ODFF));
3889 0 : aCond.append(')');
3890 0 : break;
3891 : case SC_COND_DUPLICATE:
3892 0 : aCond.append("duplicate");
3893 0 : break;
3894 : case SC_COND_NOTDUPLICATE:
3895 0 : aCond.append("unique");
3896 0 : break;
3897 : case SC_COND_DIRECT:
3898 0 : aCond.append("formula-is(");
3899 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3900 0 : aCond.append(')');
3901 0 : break;
3902 : case SC_COND_TOP10:
3903 0 : aCond.append("top-elements(");
3904 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3905 0 : aCond.append(")");
3906 0 : break;
3907 : case SC_COND_BOTTOM10:
3908 0 : aCond.append("bottom-elements(");
3909 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3910 0 : aCond.append(")");
3911 0 : break;
3912 : case SC_COND_TOP_PERCENT:
3913 0 : aCond.append("top-percent(");
3914 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3915 0 : aCond.append(")");
3916 0 : break;
3917 : case SC_COND_BOTTOM_PERCENT:
3918 0 : aCond.append("bottom-percent(");
3919 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3920 0 : aCond.append(")");
3921 0 : break;
3922 : case SC_COND_ERROR:
3923 0 : aCond.append("is-error");
3924 0 : break;
3925 : case SC_COND_NOERROR:
3926 0 : aCond.append("is-no-error");
3927 0 : break;
3928 : case SC_COND_BEGINS_WITH:
3929 0 : aCond.append("begins-with(");
3930 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3931 0 : aCond.append(")");
3932 0 : break;
3933 : case SC_COND_ENDS_WITH:
3934 0 : aCond.append("ends-with(");
3935 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3936 0 : aCond.append(")");
3937 0 : break;
3938 : case SC_COND_CONTAINS_TEXT:
3939 0 : aCond.append("contains-text(");
3940 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3941 0 : aCond.append(")");
3942 0 : break;
3943 : case SC_COND_NOT_CONTAINS_TEXT:
3944 0 : aCond.append("not-contains-text(");
3945 0 : aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
3946 0 : aCond.append(")");
3947 0 : break;
3948 : case SC_COND_NONE:
3949 0 : continue;
3950 : default:
3951 : SAL_WARN("sc", "unimplemented conditional format export");
3952 : }
3953 0 : rtl::OUString sStyle = pEntry->GetStyle();
3954 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_APPLY_STYLE_NAME, sStyle);
3955 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, aCond.makeStringAndClear());
3956 :
3957 0 : rtl::OUString sBaseAddress;
3958 0 : ScRangeStringConverter::GetStringFromAddress( sBaseAddress, aPos, pDoc,formula::FormulaGrammar::CONV_ODF );
3959 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_BASE_CELL_ADDRESS, sBaseAddress);
3960 0 : SvXMLElementExport aElementCondEntry(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITION, true, true);
3961 : }
3962 0 : else if(pFormatEntry->GetType() == condformat::COLORSCALE)
3963 : {
3964 0 : SvXMLElementExport aElementColorScale(*this, XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE, true, true);
3965 0 : const ScColorScaleFormat& mrColorScale = static_cast<const ScColorScaleFormat&>(*pFormatEntry);
3966 0 : for(ScColorScaleFormat::const_iterator it = mrColorScale.begin();
3967 0 : it != mrColorScale.end(); ++it)
3968 : {
3969 0 : if(it->GetType() == COLORSCALE_FORMULA)
3970 : {
3971 0 : rtl::OUString sFormula = it->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
3972 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
3973 : }
3974 : else
3975 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, rtl::OUString::valueOf(it->GetValue()));
3976 :
3977 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*it));
3978 0 : rtl::OUStringBuffer aBuffer;
3979 0 : ::sax::Converter::convertColor(aBuffer, it->GetColor().GetColor());
3980 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLOR, aBuffer.makeStringAndClear());
3981 0 : SvXMLElementExport aElementColorScaleEntry(*this, XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE_ENTRY, true, true);
3982 0 : }
3983 : }
3984 0 : else if(pFormatEntry->GetType() == condformat::DATABAR)
3985 : {
3986 0 : const ScDataBarFormatData* pFormatData = static_cast<const ScDataBarFormat&>(*pFormatEntry).GetDataBarData();
3987 0 : if(!pFormatData->mbGradient)
3988 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_GRADIENT, XML_FALSE);
3989 0 : if(pFormatData->mbOnlyBar)
3990 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_SHOW_VALUE, XML_FALSE);
3991 :
3992 0 : if(pFormatData->mbNeg)
3993 : {
3994 0 : if(pFormatData->mpNegativeColor)
3995 : {
3996 0 : rtl::OUStringBuffer aBuffer;
3997 0 : ::sax::Converter::convertColor(aBuffer, pFormatData->mpNegativeColor->GetColor());
3998 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_NEGATIVE_COLOR, aBuffer.makeStringAndClear());
3999 : }
4000 : else
4001 : {
4002 0 : rtl::OUStringBuffer aBuffer;
4003 0 : ::sax::Converter::convertColor(aBuffer, Color(COL_LIGHTRED).GetColor());
4004 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_NEGATIVE_COLOR, aBuffer.makeStringAndClear());
4005 : }
4006 : }
4007 :
4008 0 : if(pFormatData->meAxisPosition != databar::AUTOMATIC)
4009 : {
4010 0 : if(pFormatData->meAxisPosition == databar::NONE)
4011 : {
4012 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_AXIS_POSITION, rtl::OUString("none"));
4013 : }
4014 : else
4015 : {
4016 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_AXIS_POSITION, rtl::OUString("middle"));
4017 : }
4018 : }
4019 :
4020 0 : rtl::OUStringBuffer aBuffer;
4021 0 : ::sax::Converter::convertColor(aBuffer, pFormatData->maPositiveColor.GetColor());
4022 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_POSITIVE_COLOR, aBuffer.makeStringAndClear());
4023 :
4024 0 : aBuffer = rtl::OUStringBuffer();
4025 0 : ::sax::Converter::convertColor(aBuffer, pFormatData->maAxisColor.GetColor());
4026 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_AXIS_COLOR, aBuffer.makeStringAndClear());
4027 0 : SvXMLElementExport aElementDataBar(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, true, true);
4028 :
4029 : {
4030 0 : if(pFormatData->mpLowerLimit->GetType() == COLORSCALE_FORMULA)
4031 : {
4032 0 : rtl::OUString sFormula = pFormatData->mpLowerLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
4033 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
4034 : }
4035 : else
4036 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, rtl::OUString::valueOf(pFormatData->mpLowerLimit->GetValue()));
4037 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpLowerLimit, true));
4038 0 : SvXMLElementExport aElementDataBarEntryLower(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
4039 : }
4040 :
4041 : {
4042 0 : if(pFormatData->mpUpperLimit->GetType() == COLORSCALE_FORMULA)
4043 : {
4044 0 : rtl::OUString sFormula = pFormatData->mpUpperLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
4045 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
4046 : }
4047 : else
4048 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, rtl::OUString::valueOf(pFormatData->mpUpperLimit->GetValue()));
4049 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpUpperLimit, false));
4050 0 : SvXMLElementExport aElementDataBarEntryUpper(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
4051 0 : }
4052 : }
4053 0 : else if(pFormatEntry->GetType() == condformat::ICONSET)
4054 : {
4055 0 : const ScIconSetFormat& mrIconSet = static_cast<const ScIconSetFormat&>(*pFormatEntry);
4056 0 : rtl::OUString aIconSetName = getIconSetName(mrIconSet.GetIconSetData()->eIconSetType);
4057 0 : AddAttribute( XML_NAMESPACE_CALC_EXT, XML_ICON_SET_TYPE, aIconSetName );
4058 0 : SvXMLElementExport aElementColorScale(*this, XML_NAMESPACE_CALC_EXT, XML_ICON_SET, true, true);
4059 0 : for(ScIconSetFormat::const_iterator it = mrIconSet.begin();
4060 0 : it != mrIconSet.end(); ++it)
4061 : {
4062 0 : if(it->GetType() == COLORSCALE_FORMULA)
4063 : {
4064 0 : rtl::OUString sFormula = it->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
4065 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
4066 : }
4067 : else
4068 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, rtl::OUString::valueOf(it->GetValue()));
4069 :
4070 0 : AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*it));
4071 0 : SvXMLElementExport aElementColorScaleEntry(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
4072 0 : }
4073 : }
4074 : }
4075 0 : }
4076 0 : }
4077 : }
4078 : }
4079 :
4080 2 : void ScXMLExport::WriteExternalRefCaches()
4081 : {
4082 2 : if (!pDoc)
4083 2 : return;
4084 :
4085 2 : ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
4086 2 : pRefMgr->resetSrcFileData(GetOrigFileName());
4087 2 : sal_uInt16 nCount = pRefMgr->getExternalFileCount();
4088 2 : for (sal_uInt16 nFileId = 0; nFileId < nCount; ++nFileId)
4089 : {
4090 0 : const OUString* pUrl = pRefMgr->getExternalFileName(nFileId);
4091 0 : if (!pUrl)
4092 0 : continue;
4093 :
4094 0 : vector<OUString> aTabNames;
4095 0 : pRefMgr->getAllCachedTableNames(nFileId, aTabNames);
4096 0 : if (aTabNames.empty())
4097 0 : continue;
4098 :
4099 0 : for (vector<OUString>::const_iterator itr = aTabNames.begin(), itrEnd = aTabNames.end();
4100 : itr != itrEnd; ++itr)
4101 : {
4102 0 : ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, *itr, false);
4103 0 : if (!pTable.get() || !pTable->isReferenced())
4104 0 : continue;
4105 :
4106 0 : OUStringBuffer aBuf;
4107 0 : aBuf.append(sal_Unicode('\''));
4108 0 : aBuf.append(*pUrl);
4109 0 : aBuf.append(sal_Unicode('\''));
4110 0 : aBuf.append(sal_Unicode('#'));
4111 0 : aBuf.append(*itr);
4112 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aBuf.makeStringAndClear());
4113 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_PRINT, GetXMLToken(XML_FALSE));
4114 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, sExternalRefTabStyleName);
4115 0 : SvXMLElementExport aElemTable(*this, XML_NAMESPACE_TABLE, XML_TABLE, true, true);
4116 : {
4117 0 : const ScExternalRefManager::SrcFileData* pExtFileData = pRefMgr->getExternalFileData(nFileId);
4118 0 : if (pExtFileData)
4119 : {
4120 0 : OUString aRelUrl;
4121 0 : if (!pExtFileData->maRelativeName.isEmpty())
4122 0 : aRelUrl = pExtFileData->maRelativeName;
4123 : else
4124 0 : aRelUrl = GetRelativeReference(pExtFileData->maRelativeName);
4125 0 : AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
4126 0 : AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aRelUrl);
4127 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, *itr);
4128 0 : if (!pExtFileData->maFilterName.isEmpty())
4129 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_FILTER_NAME, pExtFileData->maFilterName);
4130 0 : if (!pExtFileData->maFilterOptions.isEmpty())
4131 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_FILTER_OPTIONS, pExtFileData->maFilterOptions);
4132 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_MODE, XML_COPY_RESULTS_ONLY);
4133 : }
4134 0 : SvXMLElementExport aElemTableSource(*this, XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, true, true);
4135 : }
4136 :
4137 : // Determine maximum column count of used area, for repeated cells.
4138 0 : SCCOL nMaxColsUsed = 1; // assume that there is at least one cell somewhere..
4139 0 : vector<SCROW> aRows;
4140 0 : pTable->getAllRows(aRows);
4141 0 : for (vector<SCROW>::const_iterator itrRow = aRows.begin(), itrRowEnd = aRows.end();
4142 : itrRow != itrRowEnd; ++itrRow)
4143 : {
4144 0 : SCROW nRow = *itrRow;
4145 0 : vector<SCCOL> aCols;
4146 0 : pTable->getAllCols(nRow, aCols);
4147 0 : if (!aCols.empty())
4148 : {
4149 0 : SCCOL nCol = aCols.back();
4150 0 : if (nMaxColsUsed <= nCol)
4151 0 : nMaxColsUsed = nCol + 1;
4152 : }
4153 0 : }
4154 :
4155 : // Column definitions have to be present to make a valid file
4156 : {
4157 0 : if (nMaxColsUsed > 1)
4158 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
4159 0 : OUString::valueOf(static_cast<sal_Int32>(nMaxColsUsed)));
4160 0 : SvXMLElementExport aElemColumn(*this, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, true, true);
4161 : }
4162 :
4163 : // Write cache content for this table.
4164 0 : SCROW nLastRow = 0;
4165 0 : bool bFirstRow = true;
4166 0 : for (vector<SCROW>::const_iterator itrRow = aRows.begin(), itrRowEnd = aRows.end();
4167 : itrRow != itrRowEnd; ++itrRow)
4168 : {
4169 0 : SCROW nRow = *itrRow;
4170 0 : if (bFirstRow)
4171 : {
4172 0 : if (nRow > 0)
4173 : {
4174 0 : if (nRow > 1)
4175 : {
4176 0 : OUStringBuffer aVal;
4177 0 : aVal.append(nRow);
4178 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal.makeStringAndClear());
4179 : }
4180 0 : SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
4181 0 : OUStringBuffer aVal;
4182 0 : aVal.append(static_cast<sal_Int32>(nMaxColsUsed));
4183 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
4184 0 : SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
4185 : }
4186 : }
4187 : else
4188 : {
4189 0 : SCROW nRowGap = nRow - nLastRow;
4190 0 : if (nRowGap > 1)
4191 : {
4192 0 : if (nRowGap > 2)
4193 : {
4194 0 : OUStringBuffer aVal;
4195 0 : aVal.append(static_cast<sal_Int32>(nRowGap-1));
4196 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal.makeStringAndClear());
4197 : }
4198 0 : SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
4199 0 : OUStringBuffer aVal;
4200 0 : aVal.append(static_cast<sal_Int32>(nMaxColsUsed));
4201 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
4202 0 : SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
4203 : }
4204 : }
4205 0 : SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true);
4206 :
4207 0 : vector<SCCOL> aCols;
4208 0 : pTable->getAllCols(nRow, aCols);
4209 0 : SCCOL nLastCol = 0;
4210 0 : bool bFirstCol = true;
4211 0 : for (vector<SCCOL>::const_iterator itrCol = aCols.begin(), itrColEnd = aCols.end();
4212 : itrCol != itrColEnd; ++itrCol)
4213 : {
4214 0 : SCCOL nCol = *itrCol;
4215 0 : if (bFirstCol)
4216 : {
4217 0 : if (nCol > 0)
4218 : {
4219 0 : if (nCol > 1)
4220 : {
4221 0 : OUStringBuffer aVal;
4222 0 : aVal.append(static_cast<sal_Int32>(nCol));
4223 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
4224 : }
4225 0 : SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
4226 : }
4227 : }
4228 : else
4229 : {
4230 0 : SCCOL nColGap = nCol - nLastCol;
4231 0 : if (nColGap > 1)
4232 : {
4233 0 : if (nColGap > 2)
4234 : {
4235 0 : OUStringBuffer aVal;
4236 0 : aVal.append(static_cast<sal_Int32>(nColGap-1));
4237 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear());
4238 : }
4239 0 : SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
4240 : }
4241 : }
4242 :
4243 : // Write out this cell.
4244 0 : sal_uInt32 nNumFmt = 0;
4245 0 : ScExternalRefCache::TokenRef pToken = pTable->getCell(nCol, nRow, &nNumFmt);
4246 0 : OUString aStrVal;
4247 0 : if (pToken.get())
4248 : {
4249 0 : sal_Int32 nIndex = GetNumberFormatStyleIndex(nNumFmt);
4250 0 : if (nIndex >= 0)
4251 : {
4252 0 : const OUString aStyleName = *pCellStyles->GetStyleNameByIndex(nIndex, true);
4253 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_STYLE_NAME, aStyleName);
4254 : }
4255 :
4256 0 : switch(pToken->GetType())
4257 : {
4258 : case svDouble:
4259 : {
4260 0 : AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT);
4261 0 : OUStringBuffer aVal;
4262 0 : aVal.append(pToken->GetDouble());
4263 0 : aStrVal = aVal.makeStringAndClear();
4264 0 : AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, aStrVal);
4265 : }
4266 0 : break;
4267 : case svString:
4268 : {
4269 0 : AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING);
4270 0 : aStrVal = pToken->GetString();
4271 : }
4272 0 : break;
4273 : default:
4274 : ;
4275 : }
4276 : }
4277 0 : SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true);
4278 0 : SvXMLElementExport aElemText(*this, XML_NAMESPACE_TEXT, XML_P, true, false);
4279 0 : Characters(aStrVal);
4280 :
4281 0 : nLastCol = nCol;
4282 0 : bFirstCol = false;
4283 0 : }
4284 0 : nLastRow = nRow;
4285 0 : bFirstRow = false;
4286 0 : }
4287 0 : }
4288 0 : }
4289 : }
4290 :
4291 : // core implementation
4292 2 : void ScXMLExport::WriteConsolidation()
4293 : {
4294 2 : if (pDoc)
4295 : {
4296 2 : const ScConsolidateParam* pCons(pDoc->GetConsolidateDlgData());
4297 2 : if( pCons )
4298 : {
4299 0 : OUString sStrData;
4300 :
4301 0 : ScXMLConverter::GetStringFromFunction( sStrData, pCons->eFunction );
4302 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_FUNCTION, sStrData );
4303 :
4304 0 : sStrData = OUString();
4305 0 : for( sal_Int32 nIndex = 0; nIndex < pCons->nDataAreaCount; ++nIndex )
4306 0 : ScRangeStringConverter::GetStringFromArea( sStrData, *pCons->ppDataAreas[ nIndex ], pDoc, FormulaGrammar::CONV_OOO, true );
4307 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES, sStrData );
4308 :
4309 0 : ScRangeStringConverter::GetStringFromAddress( sStrData, ScAddress( pCons->nCol, pCons->nRow, pCons->nTab ), pDoc, FormulaGrammar::CONV_OOO );
4310 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_TARGET_CELL_ADDRESS, sStrData );
4311 :
4312 0 : if( pCons->bByCol && !pCons->bByRow )
4313 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_COLUMN );
4314 0 : else if( !pCons->bByCol && pCons->bByRow )
4315 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_ROW );
4316 0 : else if( pCons->bByCol && pCons->bByRow )
4317 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_USE_LABEL, XML_BOTH );
4318 :
4319 0 : if( pCons->bReferenceData )
4320 0 : AddAttribute( XML_NAMESPACE_TABLE, XML_LINK_TO_SOURCE_DATA, XML_TRUE );
4321 :
4322 0 : SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_CONSOLIDATION, true, true );
4323 : }
4324 : }
4325 2 : }
4326 :
4327 8 : SvXMLAutoStylePoolP* ScXMLExport::CreateAutoStylePool()
4328 : {
4329 8 : return new ScXMLAutoStylePoolP(*this);
4330 : }
4331 :
4332 2 : XMLPageExport* ScXMLExport::CreatePageExport()
4333 : {
4334 2 : return new XMLTableMasterPageExport( *this );
4335 : }
4336 :
4337 2 : void ScXMLExport::GetChangeTrackViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
4338 : {
4339 2 : ScChangeViewSettings* pViewSettings(GetDocument() ? GetDocument()->GetChangeViewSettings() : NULL);
4340 2 : if (pViewSettings)
4341 : {
4342 0 : sal_Int32 nChangePos(rProps.getLength());
4343 0 : rProps.realloc(nChangePos + 1);
4344 0 : beans::PropertyValue* pProps(rProps.getArray());
4345 0 : if (pProps)
4346 : {
4347 0 : uno::Sequence<beans::PropertyValue> aChangeProps(SC_VIEWCHANGES_COUNT);
4348 0 : beans::PropertyValue* pChangeProps(aChangeProps.getArray());
4349 0 : if (pChangeProps)
4350 : {
4351 0 : pChangeProps[SC_SHOW_CHANGES].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChanges"));
4352 0 : pChangeProps[SC_SHOW_CHANGES].Value <<= pViewSettings->ShowChanges();
4353 0 : pChangeProps[SC_SHOW_ACCEPTED_CHANGES].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowAcceptedChanges"));
4354 0 : pChangeProps[SC_SHOW_ACCEPTED_CHANGES].Value <<= pViewSettings->IsShowAccepted();
4355 0 : pChangeProps[SC_SHOW_REJECTED_CHANGES].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowRejectedChanges"));
4356 0 : pChangeProps[SC_SHOW_REJECTED_CHANGES].Value <<= pViewSettings->IsShowRejected();
4357 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetime"));
4358 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME].Value <<= pViewSettings->HasDate();
4359 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeMode"));
4360 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Value <<= static_cast<sal_Int16>(pViewSettings->GetTheDateMode());
4361 0 : util::DateTime aDateTime;
4362 0 : ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings->GetTheFirstDateTime(), aDateTime);
4363 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeFirstDatetime"));
4364 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Value <<= aDateTime;
4365 0 : ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings->GetTheLastDateTime(), aDateTime);
4366 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeSecondDatetime"));
4367 0 : pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Value <<= aDateTime;
4368 0 : pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByAuthor"));
4369 0 : pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Value <<= pViewSettings->HasAuthor();
4370 0 : pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR_NAME].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByAuthorName"));
4371 0 : pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR_NAME].Value <<= rtl::OUString (pViewSettings->GetTheAuthorToShow());
4372 0 : pChangeProps[SC_SHOW_CHANGES_BY_COMMENT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByComment"));
4373 0 : pChangeProps[SC_SHOW_CHANGES_BY_COMMENT].Value <<= pViewSettings->HasComment();
4374 0 : pChangeProps[SC_SHOW_CHANGES_BY_COMMENT_TEXT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByCommentText"));
4375 0 : pChangeProps[SC_SHOW_CHANGES_BY_COMMENT_TEXT].Value <<= rtl::OUString (pViewSettings->GetTheComment());
4376 0 : pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByRanges"));
4377 0 : pChangeProps[SC_SHOW_CHANGES_BY_RANGES].Value <<= pViewSettings->HasRange();
4378 0 : rtl::OUString sRangeList;
4379 0 : ScRangeStringConverter::GetStringFromRangeList(sRangeList, &(pViewSettings->GetTheRangeList()), GetDocument(), FormulaGrammar::CONV_OOO);
4380 0 : pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByRangesList"));
4381 0 : pChangeProps[SC_SHOW_CHANGES_BY_RANGES_LIST].Value <<= sRangeList;
4382 :
4383 0 : pProps[nChangePos].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TrackedChangesViewSettings"));
4384 0 : pProps[nChangePos].Value <<= aChangeProps;
4385 0 : }
4386 : }
4387 : }
4388 2 : }
4389 :
4390 2 : void ScXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
4391 : {
4392 2 : rProps.realloc(4);
4393 2 : beans::PropertyValue* pProps(rProps.getArray());
4394 2 : if(pProps)
4395 : {
4396 2 : if (GetModel().is())
4397 : {
4398 2 : ScModelObj* pDocObj(ScModelObj::getImplementation( GetModel() ));
4399 2 : if (pDocObj)
4400 : {
4401 2 : SfxObjectShell* pEmbeddedObj = pDocObj->GetEmbeddedObject();
4402 2 : if (pEmbeddedObj)
4403 : {
4404 2 : Rectangle aRect(pEmbeddedObj->GetVisArea());
4405 2 : sal_uInt16 i(0);
4406 2 : pProps[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaTop"));
4407 2 : pProps[i].Value <<= static_cast<sal_Int32>(aRect.getY());
4408 2 : pProps[++i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaLeft"));
4409 2 : pProps[i].Value <<= static_cast<sal_Int32>(aRect.getX());
4410 2 : pProps[++i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaWidth"));
4411 2 : pProps[i].Value <<= static_cast<sal_Int32>(aRect.getWidth());
4412 2 : pProps[++i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaHeight"));
4413 2 : pProps[i].Value <<= static_cast<sal_Int32>(aRect.getHeight());
4414 : }
4415 : }
4416 : }
4417 : }
4418 2 : GetChangeTrackViewSettings(rProps);
4419 2 : }
4420 :
4421 :
4422 :
4423 :
4424 2 : void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)
4425 : {
4426 2 : if (GetModel().is())
4427 : {
4428 2 : uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
4429 2 : if (xMultiServiceFactory.is())
4430 : {
4431 2 : uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.SpreadsheetSettings"))), uno::UNO_QUERY);
4432 2 : if (xProperties.is())
4433 2 : SvXMLUnitConverter::convertPropertySet(rProps, xProperties);
4434 :
4435 2 : sal_Int32 nPropsToAdd = 0;
4436 2 : rtl::OUStringBuffer aTrackedChangesKey;
4437 2 : if (GetDocument() && GetDocument()->GetChangeTrack() && GetDocument()->GetChangeTrack()->IsProtected())
4438 : {
4439 : ::sax::Converter::encodeBase64(aTrackedChangesKey,
4440 0 : GetDocument()->GetChangeTrack()->GetProtection());
4441 0 : if (aTrackedChangesKey.getLength())
4442 0 : ++nPropsToAdd;
4443 : }
4444 :
4445 2 : bool bVBACompat = false;
4446 2 : uno::Reference <container::XNameAccess> xCodeNameAccess;
4447 : OSL_ENSURE( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" );
4448 2 : if( pDoc && pDoc->IsInVBAMode() )
4449 : {
4450 : // VBA compatibility mode
4451 0 : bVBACompat = true;
4452 0 : ++nPropsToAdd;
4453 : // code names
4454 0 : xCodeNameAccess = new XMLCodeNameProvider( pDoc );
4455 0 : if( xCodeNameAccess->hasElements() )
4456 0 : ++nPropsToAdd;
4457 : else
4458 0 : xCodeNameAccess.clear();
4459 : }
4460 :
4461 2 : if( nPropsToAdd > 0 )
4462 : {
4463 0 : sal_Int32 nCount(rProps.getLength());
4464 0 : rProps.realloc(nCount + nPropsToAdd);
4465 0 : if (aTrackedChangesKey.getLength())
4466 : {
4467 0 : rProps[nCount].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TrackedChangesProtectionKey"));
4468 0 : rProps[nCount].Value <<= aTrackedChangesKey.makeStringAndClear();
4469 0 : ++nCount;
4470 : }
4471 0 : if( bVBACompat )
4472 : {
4473 0 : rProps[nCount].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VBACompatibilityMode"));
4474 0 : rProps[nCount].Value <<= bVBACompat;
4475 0 : ++nCount;
4476 : }
4477 0 : if( xCodeNameAccess.is() )
4478 : {
4479 0 : rProps[nCount].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScriptConfiguration"));
4480 0 : rProps[nCount].Value <<= xCodeNameAccess;
4481 0 : ++nCount;
4482 : }
4483 2 : }
4484 2 : }
4485 : }
4486 2 : }
4487 :
4488 4 : XMLShapeExport* ScXMLExport::CreateShapeExport()
4489 : {
4490 4 : return new ScXMLShapeExport(*this);
4491 : }
4492 :
4493 2 : void ScXMLExport::CreateSharedData(const sal_Int32 nTableCount)
4494 : {
4495 2 : pSharedData = new ScMySharedData(nTableCount);
4496 2 : }
4497 :
4498 2 : XMLNumberFormatAttributesExportHelper* ScXMLExport::GetNumberFormatAttributesExportHelper()
4499 : {
4500 2 : if (!pNumberFormatAttributesExportHelper)
4501 2 : pNumberFormatAttributesExportHelper = new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier(), *this );
4502 2 : return pNumberFormatAttributesExportHelper;
4503 : }
4504 :
4505 24 : void ScXMLExport::CollectUserDefinedNamespaces(const SfxItemPool* pPool, sal_uInt16 nAttrib)
4506 : {
4507 : const SfxPoolItem* pItem;
4508 24 : sal_uInt32 nItems(pPool->GetItemCount2( nAttrib ));
4509 24 : for( sal_uInt32 i = 0; i < nItems; ++i )
4510 : {
4511 0 : if( 0 != (pItem = pPool->GetItem2( nAttrib, i ) ) )
4512 : {
4513 0 : const SvXMLAttrContainerItem *pUnknown((const SvXMLAttrContainerItem *)pItem);
4514 0 : if( (pUnknown->GetAttrCount() > 0) )
4515 : {
4516 0 : sal_uInt16 nIdx(pUnknown->GetFirstNamespaceIndex());
4517 0 : while( USHRT_MAX != nIdx )
4518 : {
4519 0 : if( (XML_NAMESPACE_UNKNOWN_FLAG & nIdx) != 0 )
4520 : {
4521 0 : const OUString& rPrefix = pUnknown->GetPrefix( nIdx );
4522 : // Add namespace declaration for unknown attributes if
4523 : // there aren't existing ones for the prefix used by the
4524 : // attibutes
4525 0 : _GetNamespaceMap().Add( rPrefix,
4526 0 : pUnknown->GetNamespace( nIdx ),
4527 0 : XML_NAMESPACE_UNKNOWN );
4528 : }
4529 0 : nIdx = pUnknown->GetNextNamespaceIndex( nIdx );
4530 : }
4531 : }
4532 : }
4533 : }
4534 :
4535 : // #i66550# needed for 'presentation:event-listener' element for URLs in shapes
4536 24 : _GetNamespaceMap().Add(
4537 24 : GetXMLToken( XML_NP_PRESENTATION ),
4538 24 : GetXMLToken( XML_N_PRESENTATION ),
4539 24 : XML_NAMESPACE_PRESENTATION );
4540 24 : }
4541 :
4542 10 : void ScXMLExport::IncrementProgressBar(bool bEditCell, sal_Int32 nInc)
4543 : {
4544 10 : nProgressCount += nInc;
4545 10 : if (bEditCell || nProgressCount > 100)
4546 : {
4547 2 : GetProgressBarHelper()->Increment(nProgressCount);
4548 2 : nProgressCount = 0;
4549 : }
4550 10 : }
4551 :
4552 8 : sal_uInt32 ScXMLExport::exportDoc( enum XMLTokenEnum eClass )
4553 : {
4554 8 : if( (getExportFlags() & (EXPORT_FONTDECLS|EXPORT_STYLES|
4555 : EXPORT_MASTERSTYLES|EXPORT_CONTENT)) != 0 )
4556 : {
4557 4 : if (GetDocument())
4558 : {
4559 : // if source doc was Excel then
4560 4 : uno::Reference< frame::XModel > xModel = GetModel();
4561 4 : if ( xModel.is() )
4562 : {
4563 4 : uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY );
4564 4 : SfxObjectShell* pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel.is() ? xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()) : 0 );
4565 4 : if ( pFoundShell && ooo::vba::isAlienExcelDoc( *pFoundShell ) )
4566 : {
4567 0 : xRowStylesPropertySetMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLScFromXLSRowStylesProperties, xScPropHdlFactory);
4568 0 : xRowStylesExportPropertySetMapper = new ScXMLRowExportPropertyMapper(xRowStylesPropertySetMapper);
4569 : GetAutoStylePool()->SetFamilyPropSetMapper( XML_STYLE_FAMILY_TABLE_ROW,
4570 0 : xRowStylesExportPropertySetMapper );
4571 4 : }
4572 : }
4573 4 : CollectUserDefinedNamespaces(GetDocument()->GetPool(), ATTR_USERDEF);
4574 4 : CollectUserDefinedNamespaces(GetDocument()->GetEditPool(), EE_PARA_XMLATTRIBS);
4575 4 : CollectUserDefinedNamespaces(GetDocument()->GetEditPool(), EE_CHAR_XMLATTRIBS);
4576 4 : ScDrawLayer* pDrawLayer = GetDocument()->GetDrawLayer();
4577 4 : if (pDrawLayer)
4578 : {
4579 4 : CollectUserDefinedNamespaces(&pDrawLayer->GetItemPool(), EE_PARA_XMLATTRIBS);
4580 4 : CollectUserDefinedNamespaces(&pDrawLayer->GetItemPool(), EE_CHAR_XMLATTRIBS);
4581 4 : CollectUserDefinedNamespaces(&pDrawLayer->GetItemPool(), SDRATTR_XMLATTRIBUTES);
4582 : }
4583 :
4584 : // sheet events use officeooo namespace
4585 6 : if( (getExportFlags() & EXPORT_CONTENT) != 0 &&
4586 2 : getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
4587 : {
4588 2 : bool bAnySheetEvents = false;
4589 2 : SCTAB nTabCount = pDoc->GetTableCount();
4590 4 : for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
4591 2 : if (pDoc->GetSheetEvents(nTab))
4592 0 : bAnySheetEvents = true;
4593 2 : if (bAnySheetEvents)
4594 0 : _GetNamespaceMap().Add(
4595 0 : GetXMLToken( XML_NP_OFFICE_EXT ),
4596 0 : GetXMLToken( XML_N_OFFICE_EXT ),
4597 0 : XML_NAMESPACE_OFFICE_EXT );
4598 4 : }
4599 : }
4600 : }
4601 8 : return SvXMLExport::exportDoc( eClass );
4602 : }
4603 :
4604 : // XExporter
4605 8 : void SAL_CALL ScXMLExport::setSourceDocument( const uno::Reference<lang::XComponent>& xComponent )
4606 : throw(lang::IllegalArgumentException, uno::RuntimeException)
4607 : {
4608 8 : SolarMutexGuard aGuard;
4609 8 : SvXMLExport::setSourceDocument( xComponent );
4610 :
4611 8 : pDoc = ScXMLConverter::GetScDocument( GetModel() );
4612 : OSL_ENSURE( pDoc, "ScXMLExport::setSourceDocument - no ScDocument!" );
4613 8 : if (!pDoc)
4614 0 : throw lang::IllegalArgumentException();
4615 :
4616 : // create ScChangeTrackingExportHelper after document is known
4617 8 : pChangeTrackingExportHelper = new ScChangeTrackingExportHelper(*this);
4618 :
4619 : // Set the document's storage grammar corresponding to the ODF version that
4620 : // is to be written.
4621 8 : SvtSaveOptions::ODFDefaultVersion meODFDefaultVersion = getDefaultVersion();
4622 8 : switch (meODFDefaultVersion)
4623 : {
4624 : // ODF 1.0 and 1.1 use GRAM_PODF, everything later or unspecified GRAM_ODFF
4625 : case SvtSaveOptions::ODFVER_010:
4626 : case SvtSaveOptions::ODFVER_011:
4627 0 : pDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_PODF);
4628 0 : break;
4629 : default:
4630 8 : pDoc->SetStorageGrammar( formula::FormulaGrammar::GRAM_ODFF);
4631 8 : }
4632 8 : }
4633 :
4634 : // XFilter
4635 8 : sal_Bool SAL_CALL ScXMLExport::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
4636 : throw(::com::sun::star::uno::RuntimeException)
4637 : {
4638 8 : SolarMutexGuard aGuard;
4639 8 : if (pDoc)
4640 8 : pDoc->DisableIdle(true);
4641 8 : bool bReturn(SvXMLExport::filter(aDescriptor));
4642 8 : if (pDoc)
4643 8 : pDoc->DisableIdle(false);
4644 8 : return bReturn;
4645 : }
4646 :
4647 0 : void SAL_CALL ScXMLExport::cancel()
4648 : throw(::com::sun::star::uno::RuntimeException)
4649 : {
4650 0 : SolarMutexGuard aGuard;
4651 0 : if (pDoc)
4652 0 : pDoc->DisableIdle(false);
4653 0 : SvXMLExport::cancel();
4654 0 : }
4655 :
4656 : // XInitialization
4657 8 : void SAL_CALL ScXMLExport::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
4658 : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
4659 : {
4660 8 : SolarMutexGuard aGuard;
4661 8 : SvXMLExport::initialize(aArguments);
4662 8 : }
4663 :
4664 : // XServiceInfo
4665 0 : ::rtl::OUString SAL_CALL ScXMLExport::getImplementationName( )
4666 : throw(::com::sun::star::uno::RuntimeException)
4667 : {
4668 0 : SolarMutexGuard aGuard;
4669 :
4670 0 : sal_uInt16 nFlags = getExportFlags();
4671 0 : if (nFlags & EXPORT_OASIS)
4672 : {
4673 0 : nFlags |= EXPORT_OASIS;
4674 0 : switch( nFlags )
4675 : {
4676 : case EXPORT_ALL:
4677 0 : return ScXMLOasisExport_getImplementationName();
4678 : case (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS):
4679 0 : return ScXMLOasisExport_Styles_getImplementationName();
4680 : case (EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS):
4681 0 : return ScXMLOasisExport_Content_getImplementationName();
4682 : case EXPORT_META:
4683 0 : return ScXMLOasisExport_Meta_getImplementationName();
4684 : case EXPORT_SETTINGS:
4685 0 : return ScXMLOasisExport_Settings_getImplementationName();
4686 : default:
4687 : // generic name for 'unknown' cases
4688 0 : return ScXMLOasisExport_getImplementationName();
4689 : }
4690 : }
4691 : else
4692 : {
4693 0 : switch( nFlags )
4694 : {
4695 : case EXPORT_ALL:
4696 0 : return ScXMLOOoExport_getImplementationName();
4697 : case (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS):
4698 0 : return ScXMLOOoExport_Styles_getImplementationName();
4699 : case (EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS):
4700 0 : return ScXMLOOoExport_Content_getImplementationName();
4701 : case EXPORT_META:
4702 0 : return ScXMLOOoExport_Meta_getImplementationName();
4703 : case EXPORT_SETTINGS:
4704 0 : return ScXMLOOoExport_Settings_getImplementationName();
4705 : default:
4706 : // generic name for 'unknown' cases
4707 0 : return ScXMLOOoExport_getImplementationName();
4708 : }
4709 0 : }
4710 : }
4711 :
4712 0 : sal_Bool SAL_CALL ScXMLExport::supportsService( const ::rtl::OUString& ServiceName )
4713 : throw(::com::sun::star::uno::RuntimeException)
4714 : {
4715 0 : SolarMutexGuard aGuard;
4716 0 : return SvXMLExport::supportsService( ServiceName );
4717 : }
4718 :
4719 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ScXMLExport::getSupportedServiceNames( )
4720 : throw(::com::sun::star::uno::RuntimeException)
4721 : {
4722 0 : SolarMutexGuard aGuard;
4723 0 : return SvXMLExport::getSupportedServiceNames();
4724 : }
4725 :
4726 : // XUnoTunnel
4727 8 : sal_Int64 SAL_CALL ScXMLExport::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
4728 : throw(::com::sun::star::uno::RuntimeException)
4729 : {
4730 8 : SolarMutexGuard aGuard;
4731 8 : return SvXMLExport::getSomething(aIdentifier);
4732 : }
4733 :
4734 0 : void ScXMLExport::DisposingModel()
4735 : {
4736 0 : SvXMLExport::DisposingModel();
4737 0 : pDoc = NULL;
4738 0 : xCurrentTable = 0;
4739 15 : }
4740 :
4741 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|