1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlexprt.cxx,v $
10 * $Revision: 1.213.94.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // INCLUDE ---------------------------------------------------------------
36 #include <svx/eeitem.hxx>
38 #include "xmlexprt.hxx"
39 #include "XMLConverter.hxx"
40 #include "xmlstyle.hxx"
41 #include "unonames.hxx"
42 #include "document.hxx"
43 #include "olinetab.hxx"
44 #include "cellsuno.hxx"
46 #include "rangenam.hxx"
47 #include "XMLTableMasterPageExport.hxx"
48 #include "drwlayer.hxx"
49 #include "XMLExportDataPilot.hxx"
50 #include "XMLExportDatabaseRanges.hxx"
51 #include "XMLExportDDELinks.hxx"
52 #include "XMLExportIterator.hxx"
53 #include "XMLColumnRowGroupExport.hxx"
54 #include "XMLStylesExportHelper.hxx"
55 #include "XMLChangeTrackingExportHelper.hxx"
56 #include "docoptio.hxx"
57 #include "XMLExportSharedData.hxx"
58 #include "chgviset.hxx"
60 #include "chartlis.hxx"
61 #include "unoguard.hxx"
62 #include "scitems.hxx"
63 #include "docpool.hxx"
64 #include "userdat.hxx"
65 #include "dociter.hxx"
66 #include "chgtrack.hxx"
67 #include "rangeutl.hxx"
68 #include "convuno.hxx"
70 #include "externalrefmgr.hxx"
71 #include "tabprotection.hxx"
73 #include <xmloff/xmltoken.hxx>
74 #include <xmloff/xmlnmspe.hxx>
75 #include <xmloff/xmluconv.hxx>
76 #include <xmloff/nmspmap.hxx>
77 #include <xmloff/families.hxx>
78 #include <xmloff/numehelp.hxx>
79 #include <xmloff/xmluconv.hxx>
80 #include <xmloff/txtparae.hxx>
81 #include <xmloff/xmlcnitm.hxx>
83 #include <rtl/ustring.hxx>
85 #include <tools/debug.hxx>
86 #include <rtl/math.hxx>
87 #include <svtools/zforlist.hxx>
88 #include <svx/unoshape.hxx>
89 #include <comphelper/extract.hxx>
90 #include <svx/eeitem.hxx>
91 #include <toolkit/helper/convert.hxx>
92 #include <svx/svdobj.hxx>
93 #include <svx/svdocapt.hxx>
94 #include <svx/outlobj.hxx>
95 #include <svx/svditer.hxx>
96 #include <svx/svdpage.hxx>
98 #include <comphelper/processfactory.hxx>
99 #include <com/sun/star/sheet/XUsedAreaCursor.hpp>
100 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
101 #include <com/sun/star/sheet/XAreaLinks.hpp>
102 #include <com/sun/star/sheet/XAreaLink.hpp>
103 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
104 #include <com/sun/star/table/XColumnRowRange.hpp>
105 #include <com/sun/star/sheet/XPrintAreas.hpp>
106 #include <com/sun/star/container/XNamed.hpp>
107 #include <com/sun/star/util/XProtectable.hpp>
108 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
109 #include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp>
110 #include <com/sun/star/sheet/XCellRangesQuery.hpp>
111 #include <com/sun/star/sheet/CellFlags.hpp>
112 #include <com/sun/star/util/XMergeable.hpp>
113 #include <com/sun/star/sheet/XArrayFormulaRange.hpp>
114 #include <com/sun/star/text/XText.hpp>
115 #include <com/sun/star/sheet/XLabelRanges.hpp>
116 #include <com/sun/star/sheet/XLabelRange.hpp>
117 #include <com/sun/star/sheet/XNamedRanges.hpp>
118 #include <com/sun/star/sheet/XNamedRange.hpp>
119 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
120 #include <com/sun/star/sheet/NamedRangeFlag.hpp>
121 #include <com/sun/star/container/XNamed.hpp>
122 #include <com/sun/star/sheet/XSheetLinkable.hpp>
123 #include <com/sun/star/form/XFormsSupplier2.hpp>
125 #include <com/sun/star/chart2/XChartDocument.hpp>
126 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
127 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
129 #include <com/sun/star/document/XDocumentProperties.hpp>
130 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
132 #include <sfx2/objsh.hxx>
136 //! not found in unonames.hxx
137 #define SC_STANDARDFORMAT "StandardFormat"
138 #define SC_LAYERID "LayerID"
140 #define SC_DEFAULT_TABLE_COUNT 3
141 #define SC_VIEWCHANGES_COUNT 13
142 #define SC_SHOW_CHANGES 0
143 #define SC_SHOW_ACCEPTED_CHANGES 1
144 #define SC_SHOW_REJECTED_CHANGES 2
145 #define SC_SHOW_CHANGES_BY_DATETIME 3
146 #define SC_SHOW_CHANGES_BY_DATETIME_MODE 4
147 #define SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME 5
148 #define SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME 6
149 #define SC_SHOW_CHANGES_BY_AUTHOR 7
150 #define SC_SHOW_CHANGES_BY_AUTHOR_NAME 8
151 #define SC_SHOW_CHANGES_BY_COMMENT 9
152 #define SC_SHOW_CHANGES_BY_COMMENT_TEXT 10
153 #define SC_SHOW_CHANGES_BY_RANGES 11
154 #define SC_SHOW_CHANGES_BY_RANGES_LIST 12
157 using namespace formula
;
158 using namespace com::sun::star
;
159 using namespace xmloff::token
;
162 //----------------------------------------------------------------------------
166 OUString
lcl_RangeSequenceToString(
167 const uno::Sequence
< OUString
> & rRanges
,
168 const uno::Reference
< chart2::data::XRangeXMLConversion
> & xFormatConverter
)
170 OUStringBuffer aResult
;
171 const sal_Int32
nMaxIndex( rRanges
.getLength() - 1 );
172 const sal_Unicode
cSep( sal_Char(' '));
173 for( sal_Int32 i
=0; i
<=nMaxIndex
; ++i
)
175 OUString
aRange( rRanges
[i
] );
176 if( xFormatConverter
.is())
177 aRange
= xFormatConverter
->convertRangeToXML( aRange
);
178 aResult
.append( aRange
);
180 aResult
.append( cSep
);
182 return aResult
.makeStringAndClear();
184 } // anonymous namespace
186 //----------------------------------------------------------------------------
188 OUString SAL_CALL
ScXMLOOoExport_getImplementationName() throw()
190 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLExporter" ) );
193 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOOoExport_getSupportedServiceNames() throw()
195 const rtl::OUString
aServiceName( ScXMLOOoExport_getImplementationName() );
196 return uno::Sequence
< rtl::OUString
>( &aServiceName
, 1 );
199 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_createInstance(
200 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
203 // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_ALL);
204 return (cppu::OWeakObject
*)new ScXMLExport( rSMgr
, EXPORT_ALL
);
207 OUString SAL_CALL
ScXMLOOoExport_Meta_getImplementationName() throw()
209 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLMetaExporter" ) );
212 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOOoExport_Meta_getSupportedServiceNames() throw()
214 const rtl::OUString
aServiceName( ScXMLOOoExport_Meta_getImplementationName() );
215 return uno::Sequence
< rtl::OUString
> ( &aServiceName
, 1 );
218 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Meta_createInstance(
219 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
222 // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_META);
223 return (cppu::OWeakObject
*)new ScXMLExport( rSMgr
, EXPORT_META
);
226 OUString SAL_CALL
ScXMLOOoExport_Styles_getImplementationName() throw()
228 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLStylesExporter" ) );
231 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOOoExport_Styles_getSupportedServiceNames() throw()
233 const rtl::OUString
aServiceName( ScXMLOOoExport_Styles_getImplementationName() );
234 return uno::Sequence
< rtl::OUString
> ( &aServiceName
, 1 );
237 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Styles_createInstance(
238 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
241 // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS);
242 return (cppu::OWeakObject
*)new ScXMLExport( rSMgr
, EXPORT_STYLES
|EXPORT_MASTERSTYLES
|EXPORT_AUTOSTYLES
|EXPORT_FONTDECLS
);
245 OUString SAL_CALL
ScXMLOOoExport_Content_getImplementationName() throw()
247 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLContentExporter" ) );
250 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOOoExport_Content_getSupportedServiceNames() throw()
252 const rtl::OUString
aServiceName( ScXMLOOoExport_Content_getImplementationName() );
253 return uno::Sequence
< rtl::OUString
> ( &aServiceName
, 1 );
256 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Content_createInstance(
257 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
260 // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS);
261 return (cppu::OWeakObject
*)new ScXMLExport( rSMgr
, EXPORT_AUTOSTYLES
|EXPORT_CONTENT
|EXPORT_SCRIPTS
|EXPORT_FONTDECLS
);
264 OUString SAL_CALL
ScXMLOOoExport_Settings_getImplementationName() throw()
266 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLSettingsExporter" ) );
269 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOOoExport_Settings_getSupportedServiceNames() throw()
271 const rtl::OUString
aServiceName( ScXMLOOoExport_Settings_getImplementationName() );
272 return uno::Sequence
< rtl::OUString
> ( &aServiceName
, 1 );
275 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOOoExport_Settings_createInstance(
276 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
279 // return (cppu::OWeakObject*)new ScXMLExport(EXPORT_SETTINGS);
280 return (cppu::OWeakObject
*)new ScXMLExport( rSMgr
, EXPORT_SETTINGS
);
285 OUString SAL_CALL
ScXMLOasisExport_getImplementationName() throw()
287 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisExporter" ) );
290 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOasisExport_getSupportedServiceNames() throw()
292 const rtl::OUString
aServiceName( ScXMLOasisExport_getImplementationName() );
293 const uno::Sequence
< rtl::OUString
> aSeq( &aServiceName
, 1 );
297 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_createInstance(
298 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
300 return (cppu::OWeakObject
*)new ScXMLExport(rSMgr
, EXPORT_ALL
|EXPORT_OASIS
);
303 OUString SAL_CALL
ScXMLOasisExport_Meta_getImplementationName() throw()
305 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisMetaExporter" ) );
308 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOasisExport_Meta_getSupportedServiceNames() throw()
310 const rtl::OUString
aServiceName( ScXMLOasisExport_Meta_getImplementationName() );
311 const uno::Sequence
< rtl::OUString
> aSeq( &aServiceName
, 1 );
315 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Meta_createInstance(
316 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
318 return (cppu::OWeakObject
*)new ScXMLExport(rSMgr
, EXPORT_META
|EXPORT_OASIS
);
321 OUString SAL_CALL
ScXMLOasisExport_Styles_getImplementationName() throw()
323 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisStylesExporter" ) );
326 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOasisExport_Styles_getSupportedServiceNames() throw()
328 const rtl::OUString
aServiceName( ScXMLOasisExport_Styles_getImplementationName() );
329 const uno::Sequence
< rtl::OUString
> aSeq( &aServiceName
, 1 );
333 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Styles_createInstance(
334 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
336 return (cppu::OWeakObject
*)new ScXMLExport(rSMgr
, EXPORT_STYLES
|EXPORT_MASTERSTYLES
|EXPORT_AUTOSTYLES
|EXPORT_FONTDECLS
|EXPORT_OASIS
);
339 OUString SAL_CALL
ScXMLOasisExport_Content_getImplementationName() throw()
341 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisContentExporter" ) );
344 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOasisExport_Content_getSupportedServiceNames() throw()
346 const rtl::OUString
aServiceName( ScXMLOasisExport_Content_getImplementationName() );
347 const uno::Sequence
< rtl::OUString
> aSeq( &aServiceName
, 1 );
351 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Content_createInstance(
352 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
354 return (cppu::OWeakObject
*)new ScXMLExport(rSMgr
, EXPORT_AUTOSTYLES
|EXPORT_CONTENT
|EXPORT_SCRIPTS
|EXPORT_FONTDECLS
|EXPORT_OASIS
);
357 OUString SAL_CALL
ScXMLOasisExport_Settings_getImplementationName() throw()
359 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.XMLOasisSettingsExporter" ) );
362 uno::Sequence
< rtl::OUString
> SAL_CALL
ScXMLOasisExport_Settings_getSupportedServiceNames() throw()
364 const rtl::OUString
aServiceName( ScXMLOasisExport_Settings_getImplementationName() );
365 const uno::Sequence
< rtl::OUString
> aSeq( &aServiceName
, 1 );
369 uno::Reference
< uno::XInterface
> SAL_CALL
ScXMLOasisExport_Settings_createInstance(
370 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
) throw( uno::Exception
)
372 return (cppu::OWeakObject
*)new ScXMLExport(rSMgr
, EXPORT_SETTINGS
|EXPORT_OASIS
);
374 //----------------------------------------------------------------------------
376 class ScXMLShapeExport
: public XMLShapeExport
379 ScXMLShapeExport(SvXMLExport
& rExp
) : XMLShapeExport(rExp
) {}
382 /** is called before a shape element for the given XShape is exported */
383 virtual void onExport( const uno::Reference
< drawing::XShape
>& xShape
);
386 ScXMLShapeExport::~ScXMLShapeExport()
390 void ScXMLShapeExport::onExport( const uno::Reference
< drawing::XShape
>& xShape
)
392 uno::Reference
< beans::XPropertySet
> xShapeProp( xShape
, uno::UNO_QUERY
);
393 if( xShapeProp
.is() )
395 sal_Int16 nLayerID
= 0;
396 if( (xShapeProp
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_LAYERID
))) >>= nLayerID
) && (nLayerID
== SC_LAYER_BACK
) )
397 GetExport().AddAttribute(XML_NAMESPACE_TABLE
, XML_TABLE_BACKGROUND
, XML_TRUE
);
401 //----------------------------------------------------------------------------
403 sal_Int16
ScXMLExport::GetFieldUnit()
405 com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySet
> xProperties(
406 comphelper::getProcessServiceFactory()->createInstance(
407 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" )) ),
408 com::sun::star::uno::UNO_QUERY
);
409 if (xProperties
.is())
411 sal_Int16 nFieldUnit
= 0;
412 if (xProperties
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Metric"))) >>= nFieldUnit
)
420 ScXMLExport::ScXMLExport(
421 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
422 const sal_uInt16 nExportFlag
)
423 : SvXMLExport( xServiceFactory
, SvXMLUnitConverter::GetMapUnit(GetFieldUnit()), XML_SPREADSHEET
, nExportFlag
),
425 pNumberFormatAttributesExportHelper(NULL
),
430 pRowFormatRanges(NULL
),
432 pGroupColumns (NULL
),
435 pChartListener(NULL
),
437 pMergedRangesContainer(NULL
),
438 pValidationsContainer(NULL
),
440 pChangeTrackingExportHelper(NULL
),
441 sLayerID(RTL_CONSTASCII_USTRINGPARAM( SC_LAYERID
)),
442 sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape")),
446 bHasRowHeader(sal_False
),
447 bRowHeaderOpen(sal_False
),
448 mbShowProgress( sal_False
)
450 if (getExportFlags() & EXPORT_CONTENT
)
452 pGroupColumns
= new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_COLUMN_GROUP
);
453 pGroupRows
= new ScMyOpenCloseColumnRowGroup(*this, XML_TABLE_ROW_GROUP
);
454 pColumnStyles
= new ScColumnStyles();
455 pRowStyles
= new ScRowStyles();
456 pRowFormatRanges
= new ScRowFormatRanges();
457 pMergedRangesContainer
= new ScMyMergedRangesContainer();
458 pValidationsContainer
= new ScMyValidationsContainer();
459 pCellsItr
= new ScMyNotEmptyCellsIterator(*this);
460 pDefaults
= new ScMyDefaultStyles();
462 pCellStyles
= new ScFormatRangeStyles();
464 // document is not set here - create ScChangeTrackingExportHelper later
466 xScPropHdlFactory
= new XMLScPropHdlFactory
;
467 xCellStylesPropertySetMapper
= new XMLPropertySetMapper((XMLPropertyMapEntry
*)aXMLScCellStylesProperties
, xScPropHdlFactory
);
468 xColumnStylesPropertySetMapper
= new XMLPropertySetMapper((XMLPropertyMapEntry
*)aXMLScColumnStylesProperties
, xScPropHdlFactory
);
469 xRowStylesPropertySetMapper
= new XMLPropertySetMapper((XMLPropertyMapEntry
*)aXMLScRowStylesProperties
, xScPropHdlFactory
);
470 xTableStylesPropertySetMapper
= new XMLPropertySetMapper((XMLPropertyMapEntry
*)aXMLScTableStylesProperties
, xScPropHdlFactory
);
471 xCellStylesExportPropertySetMapper
= new ScXMLCellExportPropertyMapper(xCellStylesPropertySetMapper
);
472 xCellStylesExportPropertySetMapper
->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
473 xColumnStylesExportPropertySetMapper
= new ScXMLColumnExportPropertyMapper(xColumnStylesPropertySetMapper
);
474 xRowStylesExportPropertySetMapper
= new ScXMLRowExportPropertyMapper(xRowStylesPropertySetMapper
);
475 xTableStylesExportPropertySetMapper
= new ScXMLTableExportPropertyMapper(xTableStylesPropertySetMapper
);
477 GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_CELL
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME
)),
478 xCellStylesExportPropertySetMapper
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX
)));
479 GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_COLUMN
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME
)),
480 xColumnStylesExportPropertySetMapper
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX
)));
481 GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_ROW
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME
)),
482 xRowStylesExportPropertySetMapper
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX
)));
483 GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_TABLE
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME
)),
484 xTableStylesExportPropertySetMapper
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX
)));
486 if( (getExportFlags() & (EXPORT_STYLES
|EXPORT_AUTOSTYLES
|EXPORT_MASTERSTYLES
|EXPORT_CONTENT
) ) != 0 )
488 // This name is reserved for the external ref cache tables. This
489 // should not conflict with user-defined styles since this name is
490 // used for a table style which is not available in the UI.
491 sExternalRefTabStyleName
= rtl::OUString::createFromAscii("ta_extref");
492 GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_TABLE
, sExternalRefTabStyleName
);
494 sAttrName
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_NAME
));
495 sAttrStyleName
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_STYLE_NAME
));
496 sAttrColumnsRepeated
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_NUMBER_COLUMNS_REPEATED
));
497 sAttrFormula
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_FORMULA
));
498 sAttrStringValue
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE
, GetXMLToken(XML_STRING_VALUE
));
499 sAttrValueType
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE
, GetXMLToken(XML_VALUE_TYPE
));
500 sElemCell
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_TABLE_CELL
));
501 sElemCoveredCell
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_COVERED_TABLE_CELL
));
502 sElemCol
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_TABLE_COLUMN
));
503 sElemRow
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_TABLE_ROW
));
504 sElemTab
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE
, GetXMLToken(XML_TABLE
));
505 sElemP
= GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TEXT
, GetXMLToken(XML_P
));
510 ScXMLExport::~ScXMLExport()
513 delete pGroupColumns
;
517 delete pColumnStyles
;
522 if (pRowFormatRanges
)
523 delete pRowFormatRanges
;
524 if (pMergedRangesContainer
)
525 delete pMergedRangesContainer
;
526 if (pValidationsContainer
)
527 delete pValidationsContainer
;
528 if (pChangeTrackingExportHelper
)
529 delete pChangeTrackingExportHelper
;
531 delete pChartListener
;
536 if (pNumberFormatAttributesExportHelper
)
537 delete pNumberFormatAttributesExportHelper
;
540 sal_Int32
ScXMLExport::GetNumberFormatStyleIndex(sal_Int32 nNumFmt
) const
542 NumberFormatIndexMap::const_iterator itr
= aNumFmtIndexMap
.find(nNumFmt
);
543 if (itr
== aNumFmtIndexMap
.end())
549 sal_Bool
ScXMLExport::HasDrawPages(uno::Reference
<sheet::XSpreadsheetDocument
>& xDoc
)
551 uno::Reference
<beans::XPropertySet
> xDocProps( xDoc
, uno::UNO_QUERY
);
552 return (xDocProps
.is() && ::cppu::any2bool( xDocProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_HASDRAWPAGES
))) ));
555 void ScXMLExport::CollectSharedData(sal_Int32
& nTableCount
, sal_Int32
& nShapesCount
, const sal_Int32 nCellCount
)
559 uno::Reference
<sheet::XSpreadsheetDocument
> xSpreadDoc( GetModel(), uno::UNO_QUERY
);
560 if ( xSpreadDoc
.is())
562 uno::Reference
<container::XIndexAccess
> xIndex( xSpreadDoc
->getSheets(), uno::UNO_QUERY
);
565 nTableCount
= xIndex
->getCount();
567 CreateSharedData(nTableCount
);
568 pCellStyles
->AddNewTable(nTableCount
- 1);
569 if (HasDrawPages(xSpreadDoc
))
571 rtl::OUString
sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
572 for (SCTAB nTable
= 0; nTable
< nTableCount
; ++nTable
)
574 nCurrentTable
= sal::static_int_cast
<sal_uInt16
>( nTable
);
575 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(xIndex
->getByIndex(nTable
), uno::UNO_QUERY
);
576 if (xDrawPageSupplier
.is())
578 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPageSupplier
->getDrawPage());
579 ScMyDrawPage aDrawPage
;
580 aDrawPage
.bHasForms
= sal_False
;
581 aDrawPage
.xDrawPage
.set(xDrawPage
);
582 pSharedData
->AddDrawPage(aDrawPage
, nTable
);
583 uno::Reference
<container::XIndexAccess
> xShapesIndex (xDrawPage
, uno::UNO_QUERY
);
584 if (xShapesIndex
.is())
586 sal_Int32
nShapes(xShapesIndex
->getCount());
587 for (sal_Int32 nShape
= 0; nShape
< nShapes
; ++nShape
)
589 uno::Reference
<drawing::XShape
> xShape(xShapesIndex
->getByIndex(nShape
), uno::UNO_QUERY
);
592 uno::Reference
< beans::XPropertySet
> xShapeProp( xShape
, uno::UNO_QUERY
);
593 if( xShapeProp
.is() )
595 sal_Int16 nLayerID
= 0;
596 if( xShapeProp
->getPropertyValue(sLayerID
) >>= nLayerID
)
598 if( (nLayerID
== SC_LAYER_INTERN
) || (nLayerID
== SC_LAYER_HIDDEN
) )
599 CollectInternalShape( xShape
);
603 SvxShape
* pShapeImp(SvxShape::getImplementation(xShape
));
606 SdrObject
*pSdrObj(pShapeImp
->GetSdrObject());
609 if (ScDrawLayer::GetAnchor(pSdrObj
) == SCA_CELL
)
614 awt::Point
aPoint(xShape
->getPosition());
615 awt::Size
aSize(xShape
->getSize());
616 rtl::OUString
sType(xShape
->getShapeType());
617 Rectangle
aRectangle(aPoint
.X
, aPoint
.Y
, aPoint
.X
+ aSize
.Width
, aPoint
.Y
+ aSize
.Height
);
618 if ( sType
.equals(sCaptionShape
) )
620 awt::Point aRelativeCaptionPoint
;
621 xShapeProp
->getPropertyValue( sCaptionPoint
) >>= aRelativeCaptionPoint
;
622 Point
aCoreRelativeCaptionPoint(aRelativeCaptionPoint
.X
, aRelativeCaptionPoint
.Y
);
623 Point
aCoreAbsoluteCaptionPoint(aPoint
.X
, aPoint
.Y
);
624 aCoreAbsoluteCaptionPoint
+= aCoreRelativeCaptionPoint
;
625 aRectangle
.Union(Rectangle(aCoreAbsoluteCaptionPoint
, aCoreAbsoluteCaptionPoint
));
627 ScRange
aRange(pDoc
->GetRange(static_cast<SCTAB
>(nTable
), aRectangle
));
629 aMyShape
.aAddress
= aRange
.aStart
;
630 aMyShape
.aEndAddress
= aRange
.aEnd
;
631 aMyShape
.xShape
= xShape
;
632 pSharedData
->AddNewShape(aMyShape
);
633 pSharedData
->SetLastColumn(nTable
, aRange
.aStart
.Col());
634 pSharedData
->SetLastRow(nTable
, aRange
.aStart
.Row());
638 pSharedData
->AddTableShape(nTable
, xShape
);
653 sal_Int32
nRef(nCellCount
+ (2 * nTableCount
) + (2 * nShapesCount
));
654 GetProgressBarHelper()->SetReference(nRef
);
655 GetProgressBarHelper()->SetValue(0);
658 void ScXMLExport::CollectShapesAutoStyles(const sal_Int32 nTableCount
)
660 // #i84077# To avoid compiler warnings about uninitialized aShapeItr,
661 // it's initialized using this dummy list. The iterator contains shapes
662 // from all sheets, so it can't be declared inside the nTable loop where
664 ScMyShapeList aDummyInitList
;
666 pSharedData
->SortShapesContainer();
667 pSharedData
->SortNoteShapes();
668 const ScMyShapeList
* pShapeList(NULL
);
669 ScMyShapeList::const_iterator aShapeItr
= aDummyInitList
.end();
670 if (pSharedData
->GetShapesContainer())
672 pShapeList
= pSharedData
->GetShapesContainer()->GetShapes();
673 aShapeItr
= pShapeList
->begin();
675 if (pSharedData
->HasDrawPage())
677 for (SCTAB nTable
= 0; nTable
< nTableCount
; ++nTable
)
679 uno::Reference
<drawing::XDrawPage
> xDrawPage(pSharedData
->GetDrawPage(nTable
));
680 uno::Reference
<drawing::XShapes
> xShapes (xDrawPage
, uno::UNO_QUERY
);
684 GetShapeExport()->seekShapes(xShapes
);
685 uno::Reference
< form::XFormsSupplier2
> xFormsSupplier( xDrawPage
, uno::UNO_QUERY
);
686 if( xFormsSupplier
.is() && xFormsSupplier
->hasForms() )
688 GetFormExport()->examineForms(xDrawPage
);
689 pSharedData
->SetDrawPageHasForms(nTable
, sal_True
);
691 ScMyTableShapes
* pTableShapes(pSharedData
->GetTableShapes());
694 ScMyTableXShapes::iterator
aItr((*pTableShapes
)[nTable
].begin());
695 ScMyTableXShapes::iterator
aEndItr((*pTableShapes
)[nTable
].end());
696 while (aItr
!= aEndItr
)
698 GetShapeExport()->collectShapeAutoStyles(*aItr
);
699 IncrementProgressBar(sal_False
);
705 ScMyShapeList::const_iterator
aEndItr(pShapeList
->end());
706 while (aShapeItr
!= aEndItr
&& (static_cast<sal_Int32
>(aShapeItr
->aAddress
.Tab()) == nTable
))
708 GetShapeExport()->collectShapeAutoStyles(aShapeItr
->xShape
);
709 IncrementProgressBar(sal_False
);
713 const ScMyNoteShapeList
* pNoteShapes
= NULL
;
714 ScMyNoteShapeList::const_iterator aNoteShapeItr
;
715 ScMyNoteShapeList::const_iterator aNoteShapeEndItr
;
716 if (pSharedData
->GetNoteShapes())
718 pNoteShapes
= pSharedData
->GetNoteShapes()->GetNotes();
721 aNoteShapeItr
= pNoteShapes
->begin();
722 aNoteShapeEndItr
= pNoteShapes
->end();
727 while (aNoteShapeItr
!= aNoteShapeEndItr
)
729 if (static_cast<sal_Int32
>(aNoteShapeItr
->aPos
.Tab()) == nTable
)
730 GetShapeExport()->collectShapeAutoStyles(aNoteShapeItr
->xShape
);
737 pSharedData
->SortNoteShapes(); // sort twice, because some more shapes are added
740 void ScXMLExport::_ExportMeta()
742 sal_Int32
nCellCount(pDoc
? pDoc
->GetCellCount() : 0);
743 sal_Int32
nTableCount(0);
744 sal_Int32
nShapesCount(0);
745 GetAutoStylePool()->ClearEntries();
746 CollectSharedData(nTableCount
, nShapesCount
, nCellCount
);
748 uno::Sequence
<beans::NamedValue
> stats(3);
749 stats
[0] = beans::NamedValue(::rtl::OUString::createFromAscii("TableCount"),
750 uno::makeAny(nTableCount
));
751 stats
[1] = beans::NamedValue(::rtl::OUString::createFromAscii("CellCount"),
752 uno::makeAny(nCellCount
));
753 stats
[2] = beans::NamedValue(::rtl::OUString::createFromAscii("ObjectCount"),
754 uno::makeAny(nShapesCount
));
756 // update document statistics at the model
757 uno::Reference
<document::XDocumentPropertiesSupplier
> xPropSup(GetModel(),
758 uno::UNO_QUERY_THROW
);
759 uno::Reference
<document::XDocumentProperties
> xDocProps(
760 xPropSup
->getDocumentProperties());
761 if (xDocProps
.is()) {
762 xDocProps
->setDocumentStatistics(stats
);
765 // export document properties
766 SvXMLExport::_ExportMeta();
769 void ScXMLExport::_ExportFontDecls()
771 GetFontAutoStylePool(); // make sure the pool is created
772 SvXMLExport::_ExportFontDecls();
775 table::CellRangeAddress
ScXMLExport::GetEndAddress(uno::Reference
<sheet::XSpreadsheet
>& xTable
, const sal_Int32
/* nTable */)
777 table::CellRangeAddress aCellAddress
;
778 uno::Reference
<sheet::XSheetCellCursor
> xCursor(xTable
->createCursor());
779 uno::Reference
<sheet::XUsedAreaCursor
> xUsedArea (xCursor
, uno::UNO_QUERY
);
780 uno::Reference
<sheet::XCellRangeAddressable
> xCellAddress (xCursor
, uno::UNO_QUERY
);
781 if (xUsedArea
.is() && xCellAddress
.is())
783 xUsedArea
->gotoEndOfUsedArea(sal_True
);
784 aCellAddress
= xCellAddress
->getRangeAddress();
789 void ScXMLExport::GetAreaLinks( uno::Reference
< sheet::XSpreadsheetDocument
>& xSpreadDoc
,
790 ScMyAreaLinksContainer
& rAreaLinks
)
792 uno::Reference
< beans::XPropertySet
> xPropSet( xSpreadDoc
, uno::UNO_QUERY
);
793 if( !xPropSet
.is() ) return;
795 uno::Reference
< container::XIndexAccess
> xLinksIAccess( xPropSet
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_AREALINKS
) ) ), uno::UNO_QUERY
);
796 if( xLinksIAccess
.is() )
798 const OUString
sFilter( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_FILTER
) );
799 const OUString
sFilterOpt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_FILTOPT
) );
800 const OUString
sURL( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_LINKURL
) );
801 const OUString
sRefresh( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_REFDELAY
) );
803 sal_Int32
nCount(xLinksIAccess
->getCount());
804 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; ++nIndex
)
806 uno::Reference
< sheet::XAreaLink
> xAreaLink(xLinksIAccess
->getByIndex( nIndex
), uno::UNO_QUERY
);
809 ScMyAreaLink aAreaLink
;
810 aAreaLink
.aDestRange
= xAreaLink
->getDestArea();
811 aAreaLink
.sSourceStr
= xAreaLink
->getSourceArea();
812 uno::Reference
< beans::XPropertySet
> xLinkProp( xAreaLink
, uno::UNO_QUERY
);
815 xLinkProp
->getPropertyValue( sFilter
) >>= aAreaLink
.sFilter
;
816 xLinkProp
->getPropertyValue( sFilterOpt
) >>= aAreaLink
.sFilterOptions
;
817 xLinkProp
->getPropertyValue( sURL
) >>= aAreaLink
.sURL
;
818 xLinkProp
->getPropertyValue( sRefresh
) >>= aAreaLink
.nRefresh
;
820 rAreaLinks
.AddNewAreaLink( aAreaLink
);
827 // core implementation
828 void ScXMLExport::GetDetectiveOpList( ScMyDetectiveOpContainer
& rDetOp
)
832 ScDetOpList
* pOpList(pDoc
->GetDetOpList());
835 sal_uInt32
nCount(pOpList
->Count());
836 for( sal_uInt32 nIndex
= 0; nIndex
< nCount
; ++nIndex
)
838 ScDetOpData
* pDetData(pOpList
->GetObject( static_cast<USHORT
>(nIndex
) ));
841 const ScAddress
& rDetPos
= pDetData
->GetPos();
842 SCTAB nTab
= rDetPos
.Tab();
843 if ( nTab
< pDoc
->GetTableCount() )
845 rDetOp
.AddOperation( pDetData
->GetOperation(), rDetPos
, nIndex
);
847 // #123981# cells with detective operations are written even if empty
848 pSharedData
->SetLastColumn( nTab
, rDetPos
.Col() );
849 pSharedData
->SetLastRow( nTab
, rDetPos
.Row() );
858 void ScXMLExport::WriteSingleColumn(const sal_Int32 nRepeatColumns
, const sal_Int32 nStyleIndex
,
859 const sal_Int32 nIndex
, const sal_Bool bIsAutoStyle
, const sal_Bool bIsVisible
)
862 AddAttribute(sAttrStyleName
, *pColumnStyles
->GetStyleNameByIndex(nStyleIndex
));
864 AddAttribute(XML_NAMESPACE_TABLE
, XML_VISIBILITY
, XML_COLLAPSE
);
865 if (nRepeatColumns
> 1)
867 OUString
sOUEndCol(OUString::valueOf(static_cast <sal_Int32
> (nRepeatColumns
)));
868 AddAttribute(sAttrColumnsRepeated
, sOUEndCol
);
871 AddAttribute(XML_NAMESPACE_TABLE
, XML_DEFAULT_CELL_STYLE_NAME
, *pCellStyles
->GetStyleNameByIndex(nIndex
, bIsAutoStyle
));
872 SvXMLElementExport
aElemC(*this, sElemCol
, sal_True
, sal_True
);
875 void ScXMLExport::WriteColumn(const sal_Int32 nColumn
, const sal_Int32 nRepeatColumns
,
876 const sal_Int32 nStyleIndex
, const sal_Bool bIsVisible
)
878 sal_Int32
nRepeat(1);
879 sal_Int32
nPrevIndex((*pDefaults
->GetColDefaults())[nColumn
].nIndex
);
880 sal_Bool
bPrevAutoStyle((*pDefaults
->GetColDefaults())[nColumn
].bIsAutoStyle
);
881 for (sal_Int32 i
= nColumn
+ 1; i
< nColumn
+ nRepeatColumns
; ++i
)
883 if (((*pDefaults
->GetColDefaults())[i
].nIndex
!= nPrevIndex
) ||
884 ((*pDefaults
->GetColDefaults())[i
].bIsAutoStyle
!= bPrevAutoStyle
))
886 WriteSingleColumn(nRepeat
, nStyleIndex
, nPrevIndex
, bPrevAutoStyle
, bIsVisible
);
887 nPrevIndex
= (*pDefaults
->GetColDefaults())[i
].nIndex
;
888 bPrevAutoStyle
= (*pDefaults
->GetColDefaults())[i
].bIsAutoStyle
;
894 WriteSingleColumn(nRepeat
, nStyleIndex
, nPrevIndex
, bPrevAutoStyle
, bIsVisible
);
897 void ScXMLExport::OpenHeaderColumn()
899 StartElement( XML_NAMESPACE_TABLE
, XML_TABLE_HEADER_COLUMNS
, sal_True
);
902 void ScXMLExport::CloseHeaderColumn()
904 EndElement(XML_NAMESPACE_TABLE
, XML_TABLE_HEADER_COLUMNS
, sal_True
);
907 void ScXMLExport::ExportColumns(const sal_Int32 nTable
, const table::CellRangeAddress
& aColumnHeaderRange
, const sal_Bool bHasColumnHeader
)
909 sal_Int32
nColsRepeated (1);
910 rtl::OUString sParent
;
912 sal_Int32
nPrevColumn(0);
913 sal_Bool
bPrevIsVisible (sal_True
);
914 sal_Bool
bWasHeader (sal_False
);
915 sal_Bool
bIsHeader (sal_False
);
916 sal_Bool
bIsClosed (sal_True
);
917 sal_Bool
bIsFirst (sal_False
);
918 sal_Int32
nPrevIndex (-1);
920 for (nColumn
= 0; nColumn
<= pSharedData
->GetLastColumn(nTable
); ++nColumn
)
923 sal_Bool
bIsVisible(sal_True
);
924 nIndex
= pColumnStyles
->GetStyleNameIndex(nTable
, nColumn
, bIsVisible
);
926 bIsHeader
= bHasColumnHeader
&& (aColumnHeaderRange
.StartColumn
<= nColumn
) && (nColumn
<= aColumnHeaderRange
.EndColumn
);
927 if (bIsHeader
!= bWasHeader
)
931 bIsFirst
= sal_False
;
934 WriteColumn(nPrevColumn
, nColsRepeated
, nPrevIndex
, bPrevIsVisible
);
935 if (pGroupColumns
->IsGroupEnd(nColumn
- 1))
936 pGroupColumns
->CloseGroups(nColumn
- 1);
938 bPrevIsVisible
= bIsVisible
;
940 nPrevColumn
= nColumn
;
943 if(pGroupColumns
->IsGroupStart(nColumn
))
944 pGroupColumns
->OpenGroups(nColumn
);
946 bWasHeader
= sal_True
;
947 bIsClosed
= sal_False
;
951 WriteColumn(nPrevColumn
, nColsRepeated
, nPrevIndex
, bPrevIsVisible
);
953 if (pGroupColumns
->IsGroupEnd(nColumn
- 1))
954 pGroupColumns
->CloseGroups(nColumn
- 1);
955 if(pGroupColumns
->IsGroupStart(nColumn
))
956 pGroupColumns
->OpenGroups(nColumn
);
957 bPrevIsVisible
= bIsVisible
;
959 nPrevColumn
= nColumn
;
961 bWasHeader
= sal_False
;
962 bIsClosed
= sal_True
;
965 else if (nColumn
== 0)
967 if (pGroupColumns
->IsGroupStart(nColumn
))
968 pGroupColumns
->OpenGroups(nColumn
);
969 bPrevIsVisible
= bIsVisible
;
973 else if ((bIsVisible
== bPrevIsVisible
) && (nIndex
== nPrevIndex
) &&
974 !pGroupColumns
->IsGroupStart(nColumn
) && !pGroupColumns
->IsGroupEnd(nColumn
- 1))
978 bIsFirst
= sal_False
;
979 WriteColumn(nPrevColumn
, nColsRepeated
, nPrevIndex
, bPrevIsVisible
);
980 if (pGroupColumns
->IsGroupEnd(nColumn
- 1))
984 pGroupColumns
->CloseGroups(nColumn
- 1);
988 if (pGroupColumns
->IsGroupStart(nColumn
))
992 pGroupColumns
->OpenGroups(nColumn
);
996 bPrevIsVisible
= bIsVisible
;
998 nPrevColumn
= nColumn
;
1002 //if (nColsRepeated > 1 || bIsFirst)
1003 WriteColumn(nPrevColumn
, nColsRepeated
, nPrevIndex
, bPrevIsVisible
);
1005 CloseHeaderColumn();
1006 if (pGroupColumns
->IsGroupEnd(nColumn
- 1))
1007 pGroupColumns
->CloseGroups(nColumn
- 1);
1010 void ScXMLExport::ExportExternalRefCacheStyles()
1012 sal_Int32 nEntryIndex
= GetCellStylesPropertySetMapper()->FindEntryIndex(
1013 "NumberFormat", XML_NAMESPACE_STYLE
, OUString::createFromAscii("data-style-name"));
1015 if (nEntryIndex
< 0)
1016 // No entry index for the number format is found.
1019 ScExternalRefManager
* pRefMgr
= pDoc
->GetExternalRefManager();
1020 if (!pRefMgr
->hasExternalData())
1021 // No external reference data cached.
1024 // Export each unique number format used in the external ref cache.
1025 vector
<sal_uInt32
> aNumFmts
;
1026 pRefMgr
->getAllCachedNumberFormats(aNumFmts
);
1027 const OUString aDefaultStyle
= OUString::createFromAscii("Default").intern();
1028 for (vector
<sal_uInt32
>::const_iterator itr
= aNumFmts
.begin(), itrEnd
= aNumFmts
.end();
1029 itr
!= itrEnd
; ++itr
)
1031 sal_Int32 nNumFmt
= static_cast<sal_Int32
>(*itr
);
1033 addDataStyle(nNumFmt
);
1037 vector
<XMLPropertyState
> aProps
;
1038 aProps
.push_back(XMLPropertyState(nEntryIndex
, aVal
));
1039 aVal
<<= aDefaultStyle
;
1040 aProps
.push_back(XMLPropertyState(nEntryIndex
, aVal
));
1044 if (GetAutoStylePool()->Add(aName
, XML_STYLE_FAMILY_TABLE_CELL
, aDefaultStyle
, aProps
))
1046 OUString
* pTemp(new OUString(aName
));
1047 if (!pCellStyles
->AddStyleName(pTemp
, nIndex
, true))
1053 nIndex
= pCellStyles
->GetIndexOfStyleName(
1054 aName
, OUString::createFromAscii(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX
), bIsAuto
);
1057 // store the number format to index mapping for later use.
1058 aNumFmtIndexMap
.insert(NumberFormatIndexMap::value_type(nNumFmt
, nIndex
));
1062 void ScXMLExport::WriteRowContent()
1064 ScMyRowFormatRange aRange
;
1065 sal_Int32
nIndex(-1);
1067 sal_Int32
nPrevCol(0);
1070 sal_Int32
nPrevValidationIndex(-1);
1071 sal_Bool
bIsAutoStyle(sal_True
);
1072 sal_Bool
bIsFirst(sal_True
);
1073 while (pRowFormatRanges
->GetNext(aRange
))
1076 DBG_ASSERT(bIsFirst
|| (!bIsFirst
&& (nPrevCol
+ nCols
== aRange
.nStartColumn
)), "here are some columns missing");
1080 nIndex
= aRange
.nIndex
;
1081 nPrevValidationIndex
= aRange
.nValidationIndex
;
1082 bIsAutoStyle
= aRange
.bIsAutoStyle
;
1083 nCols
= aRange
.nRepeatColumns
;
1084 bIsFirst
= sal_False
;
1086 nPrevCol
= aRange
.nStartColumn
;
1091 if (((aRange
.nIndex
== nIndex
&& aRange
.bIsAutoStyle
== bIsAutoStyle
) ||
1092 (aRange
.nIndex
== nIndex
&& nIndex
== -1)) &&
1093 nPrevValidationIndex
== aRange
.nValidationIndex
)
1094 nCols
+= aRange
.nRepeatColumns
;
1098 AddAttribute(sAttrStyleName
, *pCellStyles
->GetStyleNameByIndex(nIndex
, bIsAutoStyle
));
1099 if (nPrevValidationIndex
> -1)
1100 AddAttribute(XML_NAMESPACE_TABLE
, XML_CONTENT_VALIDATION_NAME
, pValidationsContainer
->GetValidationName(nPrevValidationIndex
));
1103 rtl::OUStringBuffer aBuf
;
1104 GetMM100UnitConverter().convertNumber(aBuf
, nCols
);
1105 AddAttribute(sAttrColumnsRepeated
, aBuf
.makeStringAndClear());
1107 SvXMLElementExport
aElemC(*this, sElemCell
, sal_True
, sal_True
);
1108 nIndex
= aRange
.nIndex
;
1109 bIsAutoStyle
= aRange
.bIsAutoStyle
;
1110 nCols
= aRange
.nRepeatColumns
;
1111 nPrevValidationIndex
= aRange
.nValidationIndex
;
1113 nPrevCol
= aRange
.nStartColumn
;
1120 table::CellAddress aCellAddress
;
1122 AddAttribute(sAttrStyleName
, *pCellStyles
->GetStyleNameByIndex(nIndex
, bIsAutoStyle
));
1123 if (nPrevValidationIndex
> -1)
1124 AddAttribute(XML_NAMESPACE_TABLE
, XML_CONTENT_VALIDATION_NAME
, pValidationsContainer
->GetValidationName(nPrevValidationIndex
));
1127 rtl::OUStringBuffer aBuf
;
1128 GetMM100UnitConverter().convertNumber(aBuf
, nCols
);
1129 AddAttribute(sAttrColumnsRepeated
, aBuf
.makeStringAndClear());
1131 SvXMLElementExport
aElemC(*this, sElemCell
, sal_True
, sal_True
);
1135 void ScXMLExport::WriteRowStartTag(sal_Int32 nRow
, const sal_Int32 nIndex
,
1136 const sal_Int8 nFlag
, const sal_Int32 nEqualRows
)
1138 AddAttribute(sAttrStyleName
, *pRowStyles
->GetStyleNameByIndex(nIndex
));
1140 if (nFlag
& CR_HIDDEN
)
1142 if (nFlag
& CR_FILTERED
)
1143 AddAttribute(XML_NAMESPACE_TABLE
, XML_VISIBILITY
, XML_FILTER
);
1145 AddAttribute(XML_NAMESPACE_TABLE
, XML_VISIBILITY
, XML_COLLAPSE
);
1149 rtl::OUStringBuffer aBuf
;
1150 GetMM100UnitConverter().convertNumber(aBuf
, nEqualRows
);
1151 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_ROWS_REPEATED
, aBuf
.makeStringAndClear());
1154 const ScMyDefaultStyleList
& rRowDefaults
= *pDefaults
->GetRowDefaults();
1155 if ( nRow
>= sal::static_int_cast
<sal_Int32
>( rRowDefaults
.size() ) )
1157 // #123981# used to happen with detective operations - if there are more cases, use the last row's style
1158 DBG_ERRORFILE("WriteRowStartTag: not enough defaults");
1159 nRow
= rRowDefaults
.size() - 1;
1161 sal_Int32
nCellStyleIndex(rRowDefaults
[nRow
].nIndex
);
1162 if (nCellStyleIndex
!= -1)
1163 AddAttribute(XML_NAMESPACE_TABLE
, XML_DEFAULT_CELL_STYLE_NAME
,
1164 *pCellStyles
->GetStyleNameByIndex(nCellStyleIndex
,
1165 (*pDefaults
->GetRowDefaults())[nRow
].bIsAutoStyle
));
1166 StartElement( sElemRow
, sal_True
);
1169 void ScXMLExport::OpenHeaderRows()
1171 StartElement( XML_NAMESPACE_TABLE
, XML_TABLE_HEADER_ROWS
, sal_True
);
1172 bRowHeaderOpen
= sal_True
;
1175 void ScXMLExport::CloseHeaderRows()
1177 EndElement(XML_NAMESPACE_TABLE
, XML_TABLE_HEADER_ROWS
, sal_True
);
1180 void ScXMLExport::OpenNewRow(const sal_Int32 nIndex
, const sal_Int8 nFlag
, const sal_Int32 nStartRow
, const sal_Int32 nEqualRows
)
1182 nOpenRow
= nStartRow
;
1183 if (pGroupRows
->IsGroupStart(nStartRow
))
1185 if (bHasRowHeader
&& bRowHeaderOpen
)
1187 pGroupRows
->OpenGroups(nStartRow
);
1188 if (bHasRowHeader
&& bRowHeaderOpen
)
1191 if (bHasRowHeader
&& !bRowHeaderOpen
&& nStartRow
>= aRowHeaderRange
.StartRow
&& nStartRow
<= aRowHeaderRange
.EndRow
)
1193 if (nStartRow
== aRowHeaderRange
.StartRow
)
1196 if (aRowHeaderRange
.EndRow
< nStartRow
+ nEqualRows
- 1)
1197 nEquals
= aRowHeaderRange
.EndRow
- nStartRow
+ 1;
1199 nEquals
= nEqualRows
;
1200 WriteRowStartTag(nStartRow
, nIndex
, nFlag
, nEquals
);
1201 nOpenRow
= nStartRow
+ nEquals
- 1;
1202 if (nEquals
< nEqualRows
)
1204 CloseRow(nStartRow
+ nEquals
- 1);
1205 WriteRowStartTag(nStartRow
, nIndex
, nFlag
, nEqualRows
- nEquals
);
1206 nOpenRow
= nStartRow
+ nEqualRows
- 1;
1210 WriteRowStartTag(nStartRow
, nIndex
, nFlag
, nEqualRows
);
1213 void ScXMLExport::OpenAndCloseRow(const sal_Int32 nIndex
, const sal_Int8 nFlag
,
1214 const sal_Int32 nStartRow
, const sal_Int32 nEqualRows
)
1216 OpenNewRow(nIndex
, nFlag
, nStartRow
, nEqualRows
);
1218 CloseRow(nStartRow
+ nEqualRows
- 1);
1219 pRowFormatRanges
->Clear();
1222 void ScXMLExport::OpenRow(const sal_Int32 nTable
, const sal_Int32 nStartRow
, const sal_Int32 nRepeatRow
)
1226 sal_Int32
nPrevIndex(0), nIndex
;
1227 sal_Int8
nPrevFlag(0);
1229 sal_Int32
nEqualRows(1);
1230 sal_Int32
nEndRow(nStartRow
+ nRepeatRow
);
1232 for (nRow
= nStartRow
; nRow
< nEndRow
; ++nRow
)
1234 if (nRow
== nStartRow
)
1236 nPrevIndex
= pRowStyles
->GetStyleNameIndex(nTable
, nRow
);
1238 nPrevFlag
= (pDoc
->GetRowFlags(static_cast<SCROW
>(nRow
), static_cast<SCTAB
>(nTable
))) & (CR_HIDDEN
| CR_FILTERED
);
1242 nIndex
= pRowStyles
->GetStyleNameIndex(nTable
, nRow
);
1244 nFlag
= (pDoc
->GetRowFlags(static_cast<SCROW
>(nRow
), static_cast<SCTAB
>(nTable
))) & (CR_HIDDEN
| CR_FILTERED
);
1245 if (nIndex
== nPrevIndex
&& nFlag
== nPrevFlag
&&
1246 !(bHasRowHeader
&& ((nRow
== aRowHeaderRange
.StartRow
) || (nRow
- 1 == aRowHeaderRange
.EndRow
))) &&
1247 !(pGroupRows
->IsGroupStart(nRow
)) &&
1248 !(pGroupRows
->IsGroupEnd(nRow
- 1)))
1254 ScRowFormatRanges
* pTempRowFormatRanges
= new ScRowFormatRanges(pRowFormatRanges
);
1255 OpenAndCloseRow(nPrevIndex
, nPrevFlag
, nRow
- nEqualRows
, nEqualRows
);
1256 delete pRowFormatRanges
;
1257 pRowFormatRanges
= pTempRowFormatRanges
;
1260 OpenAndCloseRow(nPrevIndex
, nPrevFlag
, nRow
- nEqualRows
, nEqualRows
);
1262 nPrevIndex
= nIndex
;
1267 OpenNewRow(nPrevIndex
, nPrevFlag
, nRow
- nEqualRows
, nEqualRows
);
1271 sal_Int32 nIndex
= pRowStyles
->GetStyleNameIndex(nTable
, nStartRow
);
1274 nFlag
= (pDoc
->GetRowFlags(static_cast<SCROW
>(nStartRow
), static_cast<SCTAB
>(nTable
))) & (CR_HIDDEN
| CR_FILTERED
);
1275 OpenNewRow(nIndex
, nFlag
, nStartRow
, 1);
1277 nOpenRow
= nStartRow
+ nRepeatRow
- 1;
1280 void ScXMLExport::CloseRow(const sal_Int32 nRow
)
1284 EndElement(sElemRow
, sal_True
);
1285 if (bHasRowHeader
&& nRow
== aRowHeaderRange
.EndRow
)
1288 bRowHeaderOpen
= sal_False
;
1290 if (pGroupRows
->IsGroupEnd(nRow
))
1292 if (bHasRowHeader
&& bRowHeaderOpen
)
1294 pGroupRows
->CloseGroups(nRow
);
1295 if (bHasRowHeader
&& bRowHeaderOpen
)
1302 void ScXMLExport::ExportFormatRanges(const sal_Int32 nStartCol
, const sal_Int32 nStartRow
,
1303 const sal_Int32 nEndCol
, const sal_Int32 nEndRow
, const sal_Int32 nSheet
)
1305 pRowFormatRanges
->Clear();
1306 if (nStartRow
== nEndRow
)
1308 pCellStyles
->GetFormatRanges(nStartCol
, nEndCol
, nStartRow
, nSheet
, pRowFormatRanges
);
1309 if (nOpenRow
== - 1)
1310 OpenRow(nSheet
, nStartRow
, 1);
1312 pRowFormatRanges
->Clear();
1318 pCellStyles
->GetFormatRanges(nStartCol
, pSharedData
->GetLastColumn(nSheet
), nStartRow
, nSheet
, pRowFormatRanges
);
1320 CloseRow(nStartRow
);
1322 sal_Int32
nTotalRows(nEndRow
- nStartRow
+ 1 - 1);
1323 while (nRows
< nTotalRows
)
1325 pRowFormatRanges
->Clear();
1326 pCellStyles
->GetFormatRanges(0, pSharedData
->GetLastColumn(nSheet
), nStartRow
+ nRows
, nSheet
, pRowFormatRanges
);
1327 sal_Int32 nMaxRows
= pRowFormatRanges
->GetMaxRows();
1328 DBG_ASSERT(nMaxRows
, "something wents wrong");
1329 if (nMaxRows
>= nTotalRows
- nRows
)
1331 OpenRow(nSheet
, nStartRow
+ nRows
, nTotalRows
- nRows
);
1332 nRows
+= nTotalRows
- nRows
;
1336 OpenRow(nSheet
, nStartRow
+ nRows
, nMaxRows
);
1339 if (!pRowFormatRanges
->GetSize())
1340 pCellStyles
->GetFormatRanges(0, pSharedData
->GetLastColumn(nSheet
), nStartRow
+ nRows
, nSheet
, pRowFormatRanges
);
1342 CloseRow(nStartRow
+ nRows
- 1);
1344 if (nTotalRows
== 1)
1345 CloseRow(nStartRow
);
1346 OpenRow(nSheet
, nEndRow
, 1);
1347 pRowFormatRanges
->Clear();
1348 pCellStyles
->GetFormatRanges(0, nEndCol
, nEndRow
, nSheet
, pRowFormatRanges
);
1354 sal_Int32
nTotalRows(nEndRow
- nStartRow
+ 1 - 1);
1355 while (nRows
< nTotalRows
)
1357 pCellStyles
->GetFormatRanges(0, pSharedData
->GetLastColumn(nSheet
), nStartRow
+ nRows
, nSheet
, pRowFormatRanges
);
1358 sal_Int32 nMaxRows
= pRowFormatRanges
->GetMaxRows();
1359 if (nMaxRows
>= nTotalRows
- nRows
)
1361 OpenRow(nSheet
, nStartRow
+ nRows
, nTotalRows
- nRows
);
1362 nRows
+= nTotalRows
- nRows
;
1366 OpenRow(nSheet
, nStartRow
+ nRows
, nMaxRows
);
1369 if (!pRowFormatRanges
->GetSize())
1370 pCellStyles
->GetFormatRanges(0, pSharedData
->GetLastColumn(nSheet
), nStartRow
+ nRows
, nSheet
, pRowFormatRanges
);
1372 CloseRow(nStartRow
+ nRows
- 1);
1374 OpenRow(nSheet
, nEndRow
, 1);
1375 pRowFormatRanges
->Clear();
1376 pCellStyles
->GetFormatRanges(0, nEndCol
, nEndRow
, nSheet
, pRowFormatRanges
);
1382 void ScXMLExport::GetColumnRowHeader(sal_Bool
& rHasColumnHeader
, table::CellRangeAddress
& rColumnHeaderRange
,
1383 sal_Bool
& rHasRowHeader
, table::CellRangeAddress
& rRowHeaderRange
,
1384 rtl::OUString
& rPrintRanges
) const
1386 uno::Reference
<sheet::XPrintAreas
> xPrintAreas (xCurrentTable
, uno::UNO_QUERY
);
1387 if (xPrintAreas
.is())
1389 rHasRowHeader
= xPrintAreas
->getPrintTitleRows();
1390 rHasColumnHeader
= xPrintAreas
->getPrintTitleColumns();
1391 rRowHeaderRange
= xPrintAreas
->getTitleRows();
1392 rColumnHeaderRange
= xPrintAreas
->getTitleColumns();
1393 uno::Sequence
< table::CellRangeAddress
> aRangeList( xPrintAreas
->getPrintAreas() );
1394 ScRangeStringConverter::GetStringFromRangeList( rPrintRanges
, aRangeList
, pDoc
, FormulaGrammar::CONV_OOO
);
1398 void ScXMLExport::FillFieldGroup(ScOutlineArray
* pFields
, ScMyOpenCloseColumnRowGroup
* pGroups
)
1400 sal_Int32
nDepth(pFields
->GetDepth());
1401 for(sal_Int32 i
= 0; i
< nDepth
; ++i
)
1403 sal_Int32 nFields
= pFields
->GetCount(static_cast<USHORT
>(i
));
1404 for (sal_Int32 j
= 0; j
< nFields
; ++j
)
1406 ScMyColumnRowGroup aGroup
;
1407 ScOutlineEntry
* pEntry(pFields
->GetEntry(static_cast<USHORT
>(i
), static_cast<USHORT
>(j
)));
1408 aGroup
.nField
= pEntry
->GetStart();
1409 aGroup
.nLevel
= static_cast<sal_Int16
>(i
);
1410 aGroup
.bDisplay
= !(pEntry
->IsHidden());
1411 pGroups
->AddGroup(aGroup
, pEntry
->GetEnd());
1418 void ScXMLExport::FillColumnRowGroups()
1422 ScOutlineTable
* pOutlineTable
= pDoc
->GetOutlineTable( static_cast<SCTAB
>(nCurrentTable
), sal_False
);
1425 ScOutlineArray
* pCols(pOutlineTable
->GetColArray());
1426 ScOutlineArray
* pRows(pOutlineTable
->GetRowArray());
1428 FillFieldGroup(pCols
, pGroupColumns
);
1430 FillFieldGroup(pRows
, pGroupRows
);
1431 pSharedData
->SetLastColumn(nCurrentTable
, pGroupColumns
->GetLast());
1432 pSharedData
->SetLastRow(nCurrentTable
, pGroupRows
->GetLast());
1437 void ScXMLExport::SetBodyAttributes()
1439 if (pDoc
&& pDoc
->IsDocProtected())
1441 AddAttribute(XML_NAMESPACE_TABLE
, XML_STRUCTURE_PROTECTED
, XML_TRUE
);
1442 rtl::OUStringBuffer aBuffer
;
1443 uno::Sequence
<sal_Int8
> aPassHash
;
1444 ScPasswordHash eHashUsed
= PASSHASH_UNSPECIFIED
;
1445 const ScDocProtection
* p
= pDoc
->GetDocProtection();
1448 if (p
->hasPasswordHash(PASSHASH_SHA1
))
1450 aPassHash
= p
->getPasswordHash(PASSHASH_SHA1
);
1451 eHashUsed
= PASSHASH_SHA1
;
1453 else if (p
->hasPasswordHash(PASSHASH_XL
, PASSHASH_SHA1
))
1455 aPassHash
= p
->getPasswordHash(PASSHASH_XL
, PASSHASH_SHA1
);
1456 eHashUsed
= PASSHASH_XL
;
1459 SvXMLUnitConverter::encodeBase64(aBuffer
, aPassHash
);
1460 if (aBuffer
.getLength())
1462 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY
, aBuffer
.makeStringAndClear());
1463 if (eHashUsed
== PASSHASH_XL
)
1465 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY_DIGEST_ALGORITHM
,
1466 ScPassHashHelper::getHashURI(PASSHASH_XL
));
1467 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2
,
1468 ScPassHashHelper::getHashURI(PASSHASH_SHA1
));
1470 else if (eHashUsed
== PASSHASH_SHA1
)
1471 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY_DIGEST_ALGORITHM
,
1472 ScPassHashHelper::getHashURI(PASSHASH_SHA1
));
1477 void ScXMLExport::_ExportContent()
1482 sal_Int32
nTableCount(0);
1483 sal_Int32
nShapesCount(0);
1484 sal_Int32
nCellCount(pDoc
? pDoc
->GetCellCount() : 0);
1485 CollectSharedData(nTableCount
, nShapesCount
, nCellCount
);
1486 DBG_ERROR("no shared data setted");
1488 ScXMLExportDatabaseRanges
aExportDatabaseRanges(*this);
1489 if (!GetModel().is())
1492 uno::Reference
<sheet::XSpreadsheetDocument
> xSpreadDoc( GetModel(), uno::UNO_QUERY
);
1493 if ( !xSpreadDoc
.is() )
1496 uno::Reference
<container::XIndexAccess
> xIndex( xSpreadDoc
->getSheets(), uno::UNO_QUERY
);
1499 //_GetNamespaceMap().ClearQNamesCache();
1500 pChangeTrackingExportHelper
->CollectAndWriteChanges();
1501 WriteCalculationSettings(xSpreadDoc
);
1502 sal_Int32
nTableCount(xIndex
->getCount());
1503 ScMyAreaLinksContainer aAreaLinks
;
1504 GetAreaLinks( xSpreadDoc
, aAreaLinks
);
1505 ScMyEmptyDatabaseRangesContainer
aEmptyRanges(aExportDatabaseRanges
.GetEmptyDatabaseRanges());
1506 ScMyDetectiveOpContainer aDetectiveOpContainer
;
1507 GetDetectiveOpList( aDetectiveOpContainer
);
1509 pCellStyles
->Sort();
1510 pMergedRangesContainer
->Sort();
1511 pSharedData
->GetDetectiveObjContainer()->Sort();
1514 pCellsItr
->SetShapes( pSharedData
->GetShapesContainer() );
1515 pCellsItr
->SetNoteShapes( pSharedData
->GetNoteShapes() );
1516 pCellsItr
->SetMergedRanges( pMergedRangesContainer
);
1517 pCellsItr
->SetAreaLinks( &aAreaLinks
);
1518 pCellsItr
->SetEmptyDatabaseRanges( &aEmptyRanges
);
1519 pCellsItr
->SetDetectiveObj( pSharedData
->GetDetectiveObjContainer() );
1520 pCellsItr
->SetDetectiveOp( &aDetectiveOpContainer
);
1522 if (nTableCount
> 0)
1523 pValidationsContainer
->WriteValidations(*this);
1524 WriteTheLabelRanges( xSpreadDoc
);
1525 for (sal_Int32 nTable
= 0; nTable
< nTableCount
; ++nTable
)
1527 uno::Reference
<sheet::XSpreadsheet
> xTable(xIndex
->getByIndex(nTable
), uno::UNO_QUERY
);
1530 xCurrentTable
.set(xTable
);
1531 xCurrentTableCellRange
.set(xTable
, uno::UNO_QUERY
);
1532 uno::Reference
<container::XNamed
> xName (xTable
, uno::UNO_QUERY
);
1535 nCurrentTable
= sal::static_int_cast
<sal_uInt16
>( nTable
);
1536 rtl::OUString
sOUTableName(xName
->getName());
1537 AddAttribute(sAttrName
, sOUTableName
);
1538 AddAttribute(sAttrStyleName
, aTableStyles
[nTable
]);
1539 uno::Reference
<util::XProtectable
> xProtectable (xTable
, uno::UNO_QUERY
);
1540 ScTableProtection
* pProtect
= NULL
;
1541 if (xProtectable
.is() && xProtectable
->isProtected())
1543 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTED
, XML_TRUE
);
1546 pProtect
= pDoc
->GetTabProtection(static_cast<SCTAB
>(nTable
));
1549 rtl::OUStringBuffer aBuffer
;
1550 ScPasswordHash eHashUsed
= PASSHASH_UNSPECIFIED
;
1551 if (pProtect
->hasPasswordHash(PASSHASH_SHA1
))
1553 SvXMLUnitConverter::encodeBase64(aBuffer
, pProtect
->getPasswordHash(PASSHASH_SHA1
));
1554 eHashUsed
= PASSHASH_SHA1
;
1556 else if (pProtect
->hasPasswordHash(PASSHASH_XL
, PASSHASH_SHA1
))
1558 // Double-hash this by SHA1 on top of the legacy xls hash.
1559 uno::Sequence
<sal_Int8
> aHash
= pProtect
->getPasswordHash(PASSHASH_XL
, PASSHASH_SHA1
);
1560 SvXMLUnitConverter::encodeBase64(aBuffer
, aHash
);
1561 eHashUsed
= PASSHASH_XL
;
1563 if (aBuffer
.getLength())
1565 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY
, aBuffer
.makeStringAndClear());
1566 if (eHashUsed
== PASSHASH_XL
)
1568 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY_DIGEST_ALGORITHM
,
1569 ScPassHashHelper::getHashURI(PASSHASH_XL
));
1570 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY_DIGEST_ALGORITHM_2
,
1571 ScPassHashHelper::getHashURI(PASSHASH_SHA1
));
1573 else if (eHashUsed
== PASSHASH_SHA1
)
1574 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTION_KEY_DIGEST_ALGORITHM
,
1575 ScPassHashHelper::getHashURI(PASSHASH_SHA1
));
1581 rtl::OUString sPrintRanges
;
1582 table::CellRangeAddress aColumnHeaderRange
;
1583 sal_Bool bHasColumnHeader
;
1584 GetColumnRowHeader(bHasColumnHeader
, aColumnHeaderRange
, bHasRowHeader
, aRowHeaderRange
, sPrintRanges
);
1585 if( sPrintRanges
.getLength() )
1586 AddAttribute( XML_NAMESPACE_TABLE
, XML_PRINT_RANGES
, sPrintRanges
);
1587 else if (!pDoc
->IsPrintEntireSheet(static_cast<SCTAB
>(nTable
)))
1588 AddAttribute( XML_NAMESPACE_TABLE
, XML_PRINT
, XML_FALSE
);
1589 SvXMLElementExport
aElemT(*this, sElemTab
, sal_True
, sal_True
);
1591 if (pProtect
&& pProtect
->isProtected())
1593 if (pProtect
->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS
))
1594 AddAttribute(XML_NAMESPACE_TABLE
, XML_SELECT_PROTECTED_CELLS
, XML_TRUE
);
1595 if (pProtect
->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS
))
1596 AddAttribute(XML_NAMESPACE_TABLE
, XML_SELECT_UNPROTECTED_CELLS
, XML_TRUE
);
1598 rtl::OUString aElemName
= GetNamespaceMap().GetQNameByKey(
1599 XML_NAMESPACE_TABLE
, GetXMLToken(XML_TABLE_PROTECTION
));
1601 SvXMLElementExport
aElemProtected(*this, aElemName
, true, true);
1607 uno::Reference
<drawing::XDrawPage
> xDrawPage
;
1608 if (pSharedData
->HasForm(nTable
, xDrawPage
) && xDrawPage
.is())
1610 ::xmloff::OOfficeFormsExport
aForms(*this);
1611 GetFormExport()->exportForms( xDrawPage
);
1612 sal_Bool
bRet(GetFormExport()->seekPage( xDrawPage
));
1613 DBG_ASSERT( bRet
, "OFormLayerXMLExport::seekPage failed!" );
1614 (void)bRet
; // avoid warning in product version
1616 if (pSharedData
->HasDrawPage())
1618 GetShapeExport()->seekShapes(uno::Reference
<drawing::XShapes
>(pSharedData
->GetDrawPage(nTable
), uno::UNO_QUERY
));
1621 table::CellRangeAddress
aRange(GetEndAddress(xTable
, nTable
));
1622 pSharedData
->SetLastColumn(nTable
, aRange
.EndColumn
);
1623 pSharedData
->SetLastRow(nTable
, aRange
.EndRow
);
1624 pCellsItr
->SetCurrentTable(static_cast<SCTAB
>(nTable
), xCurrentTable
);
1625 pGroupColumns
->NewTable();
1626 pGroupRows
->NewTable();
1627 FillColumnRowGroups();
1628 if (bHasColumnHeader
)
1629 pSharedData
->SetLastColumn(nTable
, aColumnHeaderRange
.EndColumn
);
1630 bRowHeaderOpen
= sal_False
;
1632 pSharedData
->SetLastRow(nTable
, aRowHeaderRange
.EndRow
);
1633 pDefaults
->FillDefaultStyles(nTable
, pSharedData
->GetLastRow(nTable
),
1634 pSharedData
->GetLastColumn(nTable
), pCellStyles
, pDoc
);
1635 pRowFormatRanges
->SetRowDefaults(pDefaults
->GetRowDefaults());
1636 pRowFormatRanges
->SetColDefaults(pDefaults
->GetColDefaults());
1637 pCellStyles
->SetRowDefaults(pDefaults
->GetRowDefaults());
1638 pCellStyles
->SetColDefaults(pDefaults
->GetColDefaults());
1639 ExportColumns(nTable
, aColumnHeaderRange
, bHasColumnHeader
);
1640 sal_Bool
bIsFirst(sal_True
);
1641 sal_Int32
nEqualCells(0);
1644 while(pCellsItr
->GetNext(aCell
, pCellStyles
))
1648 ExportFormatRanges(0, 0, aCell
.aCellAddress
.Column
- 1, aCell
.aCellAddress
.Row
, nTable
);
1650 bIsFirst
= sal_False
;
1654 if ((aPrevCell
.aCellAddress
.Row
== aCell
.aCellAddress
.Row
) &&
1655 (aPrevCell
.aCellAddress
.Column
+ nEqualCells
+ 1 == aCell
.aCellAddress
.Column
))
1657 if(IsCellEqual(aPrevCell
, aCell
))
1661 SetRepeatAttribute(nEqualCells
);
1662 WriteCell(aPrevCell
);
1669 SetRepeatAttribute(nEqualCells
);
1670 WriteCell(aPrevCell
);
1671 ExportFormatRanges(aPrevCell
.aCellAddress
.Column
+ nEqualCells
+ 1, aPrevCell
.aCellAddress
.Row
,
1672 aCell
.aCellAddress
.Column
- 1, aCell
.aCellAddress
.Row
, nTable
);
1680 SetRepeatAttribute(nEqualCells
);
1681 WriteCell(aPrevCell
);
1682 ExportFormatRanges(aPrevCell
.aCellAddress
.Column
+ nEqualCells
+ 1, aPrevCell
.aCellAddress
.Row
,
1683 pSharedData
->GetLastColumn(nTable
), pSharedData
->GetLastRow(nTable
), nTable
);
1686 ExportFormatRanges(0, 0, pSharedData
->GetLastColumn(nTable
), pSharedData
->GetLastRow(nTable
), nTable
);
1687 CloseRow(pSharedData
->GetLastRow(nTable
));
1691 IncrementProgressBar(sal_False
);
1694 WriteExternalRefCaches();
1695 WriteNamedExpressions(xSpreadDoc
);
1696 aExportDatabaseRanges
.WriteDatabaseRanges(xSpreadDoc
);
1697 ScXMLExportDataPilot
aExportDataPilot(*this);
1698 aExportDataPilot
.WriteDataPilots(xSpreadDoc
);
1699 WriteConsolidation();
1700 ScXMLExportDDELinks
aExportDDELinks(*this);
1701 aExportDDELinks
.WriteDDELinks(xSpreadDoc
);
1702 IncrementProgressBar(sal_True
, 0);
1703 GetProgressBarHelper()->SetValue(GetProgressBarHelper()->GetReference());
1706 void ScXMLExport::_ExportStyles( sal_Bool bUsed
)
1710 sal_Int32
nTableCount(0);
1711 sal_Int32
nShapesCount(0);
1712 sal_Int32
nCellCount(pDoc
? pDoc
->GetCellCount() : 0);
1713 CollectSharedData(nTableCount
, nShapesCount
, nCellCount
);
1714 //DBG_ERROR("no shared data setted");
1716 ScXMLStyleExport
aStylesExp(*this, rtl::OUString(), GetAutoStylePool().get());
1717 if (GetModel().is())
1719 uno::Reference
<lang::XMultiServiceFactory
> xMultiServiceFactory(GetModel(), uno::UNO_QUERY
);
1720 if (xMultiServiceFactory
.is())
1722 uno::Reference
<beans::XPropertySet
> xProperties(xMultiServiceFactory
->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.Defaults"))), uno::UNO_QUERY
);
1723 if (xProperties
.is())
1724 aStylesExp
.exportDefaultStyle(xProperties
, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME
)), xCellStylesExportPropertySetMapper
);
1725 if (pSharedData
->HasShapes())
1727 GetShapeExport()->ExportGraphicDefaults();
1728 /* xInterface = xMultiServiceFactory->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults")));
1729 uno::Reference <beans::XPropertySet> xDrawProperties(xInterface, uno::UNO_QUERY);
1730 if (xDrawProperties.is())
1731 aStylesExp.exportDefaultStyle(xDrawProperties, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), GetShapeExport()->CreateShapePropMapper(*this));*/
1734 uno::Reference
<style::XStyleFamiliesSupplier
> xStyleFamiliesSupplier (GetModel(), uno::UNO_QUERY
);
1735 if (xStyleFamiliesSupplier
.is())
1737 uno::Reference
<container::XNameAccess
> xStylesFamilies(xStyleFamiliesSupplier
->getStyleFamilies());
1738 if (xStylesFamilies
.is())
1740 uno::Reference
<container::XIndexAccess
> xCellStyles(xStylesFamilies
->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles"))), uno::UNO_QUERY
);
1741 if (xCellStyles
.is())
1743 sal_Int32
nCount(xCellStyles
->getCount());
1744 rtl::OUString
sNumberFormat(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT
));
1745 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
1747 uno::Reference
<beans::XPropertySet
> xCellProperties(xCellStyles
->getByIndex(i
), uno::UNO_QUERY
);
1748 if (xCellProperties
.is())
1750 sal_Int32 nNumberFormat
= 0;
1751 if (xCellProperties
->getPropertyValue(sNumberFormat
) >>= nNumberFormat
)
1752 addDataStyle(nNumberFormat
);
1761 aStylesExp
.exportStyleFamily(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles")),
1762 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME
)), xCellStylesExportPropertySetMapper
, FALSE
, XML_STYLE_FAMILY_TABLE_CELL
);
1764 SvXMLExport::_ExportStyles(bUsed
);
1767 void ScXMLExport::_ExportAutoStyles()
1769 if (GetModel().is())
1771 uno::Reference
<sheet::XSpreadsheetDocument
> xSpreadDoc( GetModel(), uno::UNO_QUERY
);
1772 if ( xSpreadDoc
.is() )
1774 uno::Reference
<container::XIndexAccess
> xIndex( xSpreadDoc
->getSheets(), uno::UNO_QUERY
);
1777 if (getExportFlags() & EXPORT_CONTENT
)
1779 ExportExternalRefCacheStyles();
1783 sal_Int32
nTableCount(0);
1784 sal_Int32
nShapesCount(0);
1785 sal_Int32
nCellCount(pDoc
? pDoc
->GetCellCount() : 0);
1786 CollectSharedData(nTableCount
, nShapesCount
, nCellCount
);
1787 //DBG_ERROR("no shared data setted");
1789 rtl::OUString
SC_SCOLUMNPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX
));
1790 rtl::OUString
SC_SROWPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX
));
1791 rtl::OUString
SC_SCELLPREFIX(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX
));
1792 rtl::OUString
SC_NUMBERFORMAT(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT
));
1793 sal_Int32
nTableCount(xIndex
->getCount());
1794 pCellStyles
->AddNewTable(nTableCount
- 1);
1795 CollectShapesAutoStyles(nTableCount
);
1796 for (sal_Int32 nTable
= 0; nTable
< nTableCount
; ++nTable
)
1798 uno::Reference
<sheet::XSpreadsheet
> xTable(xIndex
->getByIndex(nTable
), uno::UNO_QUERY
);
1801 uno::Reference
<beans::XPropertySet
> xTableProperties(xTable
, uno::UNO_QUERY
);
1802 if (xTableProperties
.is())
1804 std::vector
<XMLPropertyState
> xPropStates(xTableStylesExportPropertySetMapper
->Filter(xTableProperties
));
1805 if(xPropStates
.size())
1807 rtl::OUString sParent
;
1808 rtl::OUString sName
;
1809 GetAutoStylePool()->Add(sName
, XML_STYLE_FAMILY_TABLE_TABLE
, sParent
, xPropStates
);
1810 aTableStyles
.push_back(sName
);
1813 uno::Reference
<sheet::XUniqueCellFormatRangesSupplier
> xCellFormatRanges ( xTableProperties
, uno::UNO_QUERY
);
1814 if ( xCellFormatRanges
.is() )
1816 uno::Reference
<container::XIndexAccess
> xFormatRangesIndex(xCellFormatRanges
->getUniqueCellFormatRanges());
1817 if (xFormatRangesIndex
.is())
1819 sal_Int32
nFormatRangesCount(xFormatRangesIndex
->getCount());
1820 GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nFormatRangesCount
);
1821 for (sal_Int32 nFormatRange
= 0; nFormatRange
< nFormatRangesCount
; ++nFormatRange
)
1823 uno::Reference
< sheet::XSheetCellRanges
> xCellRanges(xFormatRangesIndex
->getByIndex(nFormatRange
), uno::UNO_QUERY
);
1824 if (xCellRanges
.is())
1826 uno::Reference
<beans::XPropertySet
> xProperties (xCellRanges
, uno::UNO_QUERY
);
1827 if (xProperties
.is())
1829 rtl::OUString sStyleName
;
1830 sal_Int32
nNumberFormat(-1);
1831 sal_Int32
nValidationIndex(-1);
1832 std::vector
< XMLPropertyState
> xPropStates(xCellStylesExportPropertySetMapper
->Filter( xProperties
));
1833 std::vector
< XMLPropertyState
>::iterator
aItr(xPropStates
.begin());
1834 std::vector
< XMLPropertyState
>::iterator
aEndItr(xPropStates
.end());
1835 sal_Int32
nCount(0);
1836 while (aItr
!= aEndItr
)
1838 if (aItr
->mnIndex
!= -1)
1840 switch (xCellStylesPropertySetMapper
->GetEntryContextId(aItr
->mnIndex
))
1842 case CTF_SC_VALIDATION
:
1844 pValidationsContainer
->AddValidation(aItr
->maValue
, nValidationIndex
);
1845 // this is not very slow, because it is most the last property or
1846 // if it is not the last property it is the property before the last property,
1847 // so in the worst case only one property has to be copied, but in the best case no
1848 // property has to be copied
1849 aItr
= xPropStates
.erase(aItr
);
1850 aEndItr
= xPropStates
.end(); // #120346# old aEndItr is invalidated!
1853 case CTF_SC_CELLSTYLE
:
1855 aItr
->maValue
>>= sStyleName
;
1861 case CTF_SC_NUMBERFORMAT
:
1863 if (aItr
->maValue
>>= nNumberFormat
)
1864 addDataStyle(nNumberFormat
);
1883 if (nCount
== 1) // this is the CellStyle and should be removed if alone
1884 xPropStates
.clear();
1885 if (nNumberFormat
== -1)
1886 xProperties
->getPropertyValue(SC_NUMBERFORMAT
) >>= nNumberFormat
;
1887 if (sStyleName
.getLength())
1889 if (xPropStates
.size())
1892 rtl::OUString sName
;
1893 sal_Bool
bIsAutoStyle(sal_True
);
1894 if (GetAutoStylePool()->Add(sName
, XML_STYLE_FAMILY_TABLE_CELL
, sStyleName
, xPropStates
))
1896 rtl::OUString
* pTemp(new rtl::OUString(sName
));
1897 if (!pCellStyles
->AddStyleName(pTemp
, nIndex
))
1901 nIndex
= pCellStyles
->GetIndexOfStyleName(sName
, SC_SCELLPREFIX
, bIsAutoStyle
);
1902 uno::Sequence
<table::CellRangeAddress
> aAddresses(xCellRanges
->getRangeAddresses());
1903 table::CellRangeAddress
* pAddresses(aAddresses
.getArray());
1904 sal_Bool
bGetMerge(sal_True
);
1905 for (sal_Int32 i
= 0; i
< aAddresses
.getLength(); ++i
, ++pAddresses
)
1907 pSharedData
->SetLastColumn(nTable
, pAddresses
->EndColumn
);
1908 pSharedData
->SetLastRow(nTable
, pAddresses
->EndRow
);
1909 pCellStyles
->AddRangeStyleName(*pAddresses
, nIndex
, bIsAutoStyle
, nValidationIndex
, nNumberFormat
);
1911 bGetMerge
= GetMerged(pAddresses
, xTable
);
1916 rtl::OUString
* pTemp(new rtl::OUString(EncodeStyleName(sStyleName
)));
1917 sal_Int32
nIndex(0);
1918 if (!pCellStyles
->AddStyleName(pTemp
, nIndex
, sal_False
))
1923 uno::Sequence
<table::CellRangeAddress
> aAddresses(xCellRanges
->getRangeAddresses());
1924 table::CellRangeAddress
* pAddresses(aAddresses
.getArray());
1925 sal_Bool
bGetMerge(sal_True
);
1926 for (sal_Int32 i
= 0; i
< aAddresses
.getLength(); ++i
, ++pAddresses
)
1929 bGetMerge
= GetMerged(pAddresses
, xTable
);
1930 pCellStyles
->AddRangeStyleName(*pAddresses
, nIndex
, sal_False
, nValidationIndex
, nNumberFormat
);
1931 if (!sStyleName
.equalsAsciiL("Default", 7) || nValidationIndex
!= -1)
1933 pSharedData
->SetLastColumn(nTable
, pAddresses
->EndColumn
);
1934 pSharedData
->SetLastRow(nTable
, pAddresses
->EndRow
);
1939 IncrementProgressBar(sal_False
);
1945 uno::Reference
<table::XColumnRowRange
> xColumnRowRange (xTableProperties
, uno::UNO_QUERY
);
1946 if (xColumnRowRange
.is())
1950 pDoc
->SyncColRowFlags();
1951 uno::Reference
<table::XTableColumns
> xTableColumns(xColumnRowRange
->getColumns());
1952 if (xTableColumns
.is())
1954 sal_Int32
nColumns(pDoc
->GetLastChangedCol(sal::static_int_cast
<SCTAB
>(nTable
)));
1955 pSharedData
->SetLastColumn(nTable
, nColumns
);
1956 table::CellRangeAddress
aCellAddress(GetEndAddress(xTable
, nTable
));
1957 if (aCellAddress
.EndColumn
> nColumns
)
1960 pColumnStyles
->AddNewTable(nTable
, aCellAddress
.EndColumn
);
1962 // else if (nColumns < MAXCOL)
1963 // pColumnStyles->AddNewTable(nTable, ++nColumns);
1965 pColumnStyles
->AddNewTable(nTable
, nColumns
);
1966 sal_Int32 nColumn
= 0;
1967 while (/*nColumn <= nColumns && */nColumn
<= MAXCOL
)
1969 sal_Int32
nIndex(-1);
1970 sal_Bool
bIsVisible(sal_True
);
1971 uno::Reference
<beans::XPropertySet
> xColumnProperties(xTableColumns
->getByIndex(nColumn
), uno::UNO_QUERY
);
1972 if (xColumnProperties
.is())
1974 std::vector
<XMLPropertyState
> xPropStates(xColumnStylesExportPropertySetMapper
->Filter(xColumnProperties
));
1975 if(xPropStates
.size())
1977 std::vector
< XMLPropertyState
>::iterator
aItr(xPropStates
.begin());
1978 std::vector
< XMLPropertyState
>::iterator
aEndItr(xPropStates
.end());
1979 while (aItr
!= aEndItr
)
1981 if (xColumnStylesPropertySetMapper
->GetEntryContextId(aItr
->mnIndex
) == CTF_SC_ISVISIBLE
)
1983 aItr
->maValue
>>= bIsVisible
;
1988 rtl::OUString sParent
;
1989 rtl::OUString sName
;
1990 if (GetAutoStylePool()->Add(sName
, XML_STYLE_FAMILY_TABLE_COLUMN
, sParent
, xPropStates
))
1992 rtl::OUString
* pTemp(new rtl::OUString(sName
));
1993 nIndex
= pColumnStyles
->AddStyleName(pTemp
);
1996 nIndex
= pColumnStyles
->GetIndexOfStyleName(sName
, SC_SCOLUMNPREFIX
);
1997 pColumnStyles
->AddFieldStyleName(nTable
, nColumn
, nIndex
, bIsVisible
);
2000 sal_Int32
nOld(nColumn
);
2001 nColumn
= pDoc
->GetNextDifferentChangedCol(sal::static_int_cast
<SCTAB
>(nTable
), static_cast<SCCOL
>(nColumn
));
2002 for (sal_Int32 i
= nOld
+ 1; i
< nColumn
; ++i
)
2003 pColumnStyles
->AddFieldStyleName(nTable
, i
, nIndex
, bIsVisible
);
2005 if (aCellAddress
.EndColumn
> nColumns
)
2007 sal_Bool
bIsVisible(sal_True
);
2008 sal_Int32
nIndex(pColumnStyles
->GetStyleNameIndex(nTable
, nColumns
, bIsVisible
));
2009 for (sal_Int32 i
= nColumns
+ 1; i
<= aCellAddress
.EndColumn
; ++i
)
2010 pColumnStyles
->AddFieldStyleName(nTable
, i
, nIndex
, bIsVisible
);
2013 uno::Reference
<table::XTableRows
> xTableRows(xColumnRowRange
->getRows());
2014 if (xTableRows
.is())
2016 sal_Int32
nRows(pDoc
->GetLastChangedRow(sal::static_int_cast
<SCTAB
>(nTable
)));
2017 pSharedData
->SetLastRow(nTable
, nRows
);
2018 table::CellRangeAddress
aCellAddress(GetEndAddress(xTable
, nTable
));
2019 if (aCellAddress
.EndRow
> nRows
)
2022 pRowStyles
->AddNewTable(nTable
, aCellAddress
.EndRow
);
2024 // else if (nRows < MAXROW)
2025 // pRowStyles->AddNewTable(nTable, ++nRows);
2027 pRowStyles
->AddNewTable(nTable
, nRows
);
2029 while (nRow
<= nRows
&& nRow
<= MAXROW
)
2031 sal_Int32 nIndex
= 0;
2032 uno::Reference
<beans::XPropertySet
> xRowProperties(xTableRows
->getByIndex(nRow
), uno::UNO_QUERY
);
2033 if(xRowProperties
.is())
2035 std::vector
<XMLPropertyState
> xPropStates(xRowStylesExportPropertySetMapper
->Filter(xRowProperties
));
2036 if(xPropStates
.size())
2038 rtl::OUString sParent
;
2039 rtl::OUString sName
;
2040 if (GetAutoStylePool()->Add(sName
, XML_STYLE_FAMILY_TABLE_ROW
, sParent
, xPropStates
))
2042 rtl::OUString
* pTemp(new rtl::OUString(sName
));
2043 nIndex
= pRowStyles
->AddStyleName(pTemp
);
2046 nIndex
= pRowStyles
->GetIndexOfStyleName(sName
, SC_SROWPREFIX
);
2047 pRowStyles
->AddFieldStyleName(nTable
, nRow
, nIndex
);
2050 sal_Int32
nOld(nRow
);
2051 nRow
= pDoc
->GetNextDifferentChangedRow(sal::static_int_cast
<SCTAB
>(nTable
), static_cast<SCROW
>(nRow
), false);
2052 for (sal_Int32 i
= nOld
+ 1; i
< nRow
; ++i
)
2053 pRowStyles
->AddFieldStyleName(nTable
, i
, nIndex
);
2055 if (aCellAddress
.EndRow
> nRows
)
2057 sal_Int32
nIndex(pRowStyles
->GetStyleNameIndex(nTable
, nRows
));
2058 for (sal_Int32 i
= nRows
+ 1; i
<= aCellAddress
.EndRow
; ++i
)
2059 pRowStyles
->AddFieldStyleName(nTable
, i
, nIndex
);
2064 uno::Reference
<sheet::XCellRangesQuery
> xCellRangesQuery (xTableProperties
, uno::UNO_QUERY
);
2065 if (xCellRangesQuery
.is())
2067 uno::Reference
<sheet::XSheetCellRanges
> xSheetCellRanges(xCellRangesQuery
->queryContentCells(sheet::CellFlags::FORMATTED
));
2068 uno::Reference
<sheet::XSheetOperation
> xSheetOperation(xSheetCellRanges
, uno::UNO_QUERY
);
2069 if (xSheetCellRanges
.is() && xSheetOperation
.is())
2071 sal_uInt32
nCount(sal_uInt32(xSheetOperation
->computeFunction(sheet::GeneralFunction_COUNT
)));
2072 uno::Reference
<container::XEnumerationAccess
> xCellsAccess(xSheetCellRanges
->getCells());
2073 if (xCellsAccess
.is())
2075 GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCount
);
2076 uno::Reference
<container::XEnumeration
> xCells(xCellsAccess
->createEnumeration());
2079 sal_uInt32
nCount2(0);
2080 while (xCells
->hasMoreElements())
2082 uno::Reference
<text::XText
> xText(xCells
->nextElement(), uno::UNO_QUERY
);
2084 GetTextParagraphExport()->collectTextAutoStyles(xText
, sal_False
, sal_False
);
2086 IncrementProgressBar(sal_False
);
2088 if(nCount2
> nCount
)
2089 GetProgressBarHelper()->SetReference(GetProgressBarHelper()->GetReference() + nCount2
- nCount
);
2095 IncrementProgressBar(sal_False
);
2097 pChangeTrackingExportHelper
->CollectAutoStyles();
2099 GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN
,
2100 GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2101 GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW
,
2102 GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2103 GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE
,
2104 GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2105 exportAutoDataStyles();
2106 GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL
,
2107 GetDocHandler(), GetMM100UnitConverter(), GetNamespaceMap());
2109 GetShapeExport()->exportAutoStyles();
2110 GetFormExport()->exportAutoStyles( );
2113 // Special table style for the external ref cache tables.
2114 AddAttribute(XML_NAMESPACE_STYLE
, XML_NAME
, sExternalRefTabStyleName
);
2115 AddAttribute(XML_NAMESPACE_STYLE
, XML_FAMILY
, XML_TABLE
);
2116 SvXMLElementExport
aElemStyle(*this, XML_NAMESPACE_STYLE
, XML_STYLE
, sal_True
, sal_True
);
2117 AddAttribute(XML_NAMESPACE_TABLE
, XML_DISPLAY
, XML_FALSE
);
2118 SvXMLElementExport
aElemStyleTabProps(*this, XML_NAMESPACE_STYLE
, XML_TABLE_PROPERTIES
, sal_True
, sal_True
);
2121 if (getExportFlags() & EXPORT_MASTERSTYLES
)
2123 GetPageExport()->collectAutoStyles(sal_True
);
2124 GetPageExport()->exportAutoStyles();
2127 // #i30251#; only write Text Styles once
2129 if ((getExportFlags() & EXPORT_CONTENT
) || (getExportFlags() & EXPORT_MASTERSTYLES
))
2130 GetTextParagraphExport()->exportTextAutoStyles();
2136 void ScXMLExport::_ExportMasterStyles()
2138 GetPageExport()->exportMasterStyles( sal_True
);
2141 void ScXMLExport::CollectInternalShape( uno::Reference
< drawing::XShape
> xShape
)
2143 // detective objects and notes
2144 if( SvxShape
* pShapeImp
= SvxShape::getImplementation( xShape
) )
2146 if( SdrObject
* pObject
= pShapeImp
->GetSdrObject() )
2148 // collect note caption objects from all layers (internal or hidden)
2149 if( ScDrawObjData
* pCaptData
= ScDrawLayer::GetNoteCaptionData( pObject
, static_cast< SCTAB
>( nCurrentTable
) ) )
2151 pSharedData
->AddNoteObj( xShape
, pCaptData
->maStart
);
2153 // #i60851# When the file is saved while editing a new note,
2154 // the cell is still empty -> last column/row must be updated
2155 DBG_ASSERT( pCaptData
->maStart
.Tab() == nCurrentTable
, "invalid table in object data" );
2156 pSharedData
->SetLastColumn( nCurrentTable
, pCaptData
->maStart
.Col() );
2157 pSharedData
->SetLastRow( nCurrentTable
, pCaptData
->maStart
.Row() );
2159 // other objects from internal layer only (detective)
2160 else if( pObject
->GetLayer() == SC_LAYER_INTERN
)
2162 ScDetectiveFunc
aDetFunc( pDoc
, static_cast<SCTAB
>(nCurrentTable
) );
2163 ScAddress aPosition
;
2164 ScRange aSourceRange
;
2166 ScDetectiveObjType eObjType
= aDetFunc
.GetDetectiveObjectType(
2167 pObject
, nCurrentTable
, aPosition
, aSourceRange
, bRedLine
);
2168 pSharedData
->GetDetectiveObjContainer()->AddObject( eObjType
, static_cast<SCTAB
>(nCurrentTable
), aPosition
, aSourceRange
, bRedLine
);
2174 //UNUSED2008-05 sal_Bool ScXMLExport::GetMerge (const uno::Reference <sheet::XSpreadsheet>& xTable,
2175 //UNUSED2008-05 const sal_Int32 nCol, const sal_Int32 nRow,
2176 //UNUSED2008-05 table::CellRangeAddress& aCellAddress)
2178 //UNUSED2008-05 uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xTable->getCellRangeByPosition(nCol, nRow, nCol, nRow), uno::UNO_QUERY);
2179 //UNUSED2008-05 if (xSheetCellRange.is())
2181 //UNUSED2008-05 uno::Reference<sheet::XSheetCellCursor> xCursor(xTable->createCursorByRange(xSheetCellRange));
2182 //UNUSED2008-05 if (xCursor.is())
2184 //UNUSED2008-05 uno::Reference<sheet::XCellRangeAddressable> xCellAddress (xCursor, uno::UNO_QUERY);
2185 //UNUSED2008-05 xCursor->collapseToMergedArea();
2186 //UNUSED2008-05 aCellAddress = xCellAddress->getRangeAddress();
2187 //UNUSED2008-05 return sal_True;
2190 //UNUSED2008-05 return sal_False;
2193 sal_Bool
ScXMLExport::GetMerged (const table::CellRangeAddress
* pCellAddress
,
2194 const uno::Reference
<sheet::XSpreadsheet
>& xTable
)
2196 sal_Bool
bReady(sal_False
);
2197 sal_Int32
nRow(pCellAddress
->StartRow
);
2198 sal_Int32
nCol(pCellAddress
->StartColumn
);
2199 sal_Int32
nEndRow(pCellAddress
->EndRow
);
2200 sal_Int32
nEndCol(pCellAddress
->EndColumn
);
2201 sal_Bool
bRowInc(nEndRow
> nRow
);
2202 while(!bReady
&& nRow
<= nEndRow
&& nCol
<= nEndCol
)
2204 uno::Reference
<sheet::XSheetCellRange
> xSheetCellRange(xTable
->getCellRangeByPosition(nCol
, nRow
, nCol
, nRow
), uno::UNO_QUERY
);
2205 if (xSheetCellRange
.is())
2207 uno::Reference
<sheet::XSheetCellCursor
> xCursor(xTable
->createCursorByRange(xSheetCellRange
));
2210 uno::Reference
<sheet::XCellRangeAddressable
> xCellAddress (xCursor
, uno::UNO_QUERY
);
2211 xCursor
->collapseToMergedArea();
2212 table::CellRangeAddress
aCellAddress2(xCellAddress
->getRangeAddress());
2213 if ((aCellAddress2
.EndRow
> nRow
||
2214 aCellAddress2
.EndColumn
> nCol
) &&
2215 aCellAddress2
.StartRow
== nRow
&&
2216 aCellAddress2
.StartColumn
== nCol
)
2218 pMergedRangesContainer
->AddRange(aCellAddress2
);
2219 pSharedData
->SetLastColumn(aCellAddress2
.Sheet
, aCellAddress2
.EndColumn
);
2220 pSharedData
->SetLastRow(aCellAddress2
.Sheet
, aCellAddress2
.EndRow
);
2234 DBG_ASSERT(!(!bReady
&& nEndRow
> nRow
&& nEndCol
> nCol
), "should not be possible");
2238 //UNUSED2008-05 sal_Bool ScXMLExport::IsMatrix (const uno::Reference <table::XCellRange>& xCellRange,
2239 //UNUSED2008-05 const uno::Reference <sheet::XSpreadsheet>& xTable,
2240 //UNUSED2008-05 const sal_Int32 nCol, const sal_Int32 nRow,
2241 //UNUSED2008-05 table::CellRangeAddress& aCellAddress, sal_Bool& bIsFirst) const
2243 //UNUSED2008-05 bIsFirst = sal_False;
2244 //UNUSED2008-05 uno::Reference <sheet::XArrayFormulaRange> xArrayFormulaRange (xCellRange->getCellRangeByPosition(nCol,nRow,nCol,nRow), uno::UNO_QUERY);
2245 //UNUSED2008-05 if (xArrayFormulaRange.is())
2247 //UNUSED2008-05 rtl::OUString sArrayFormula(xArrayFormulaRange->getArrayFormula());
2248 //UNUSED2008-05 if (sArrayFormula.getLength())
2250 //UNUSED2008-05 uno::Reference<sheet::XSheetCellRange> xMatrixSheetCellRange (xArrayFormulaRange, uno::UNO_QUERY);
2251 //UNUSED2008-05 if (xMatrixSheetCellRange.is())
2253 //UNUSED2008-05 uno::Reference<sheet::XSheetCellCursor> xMatrixSheetCursor(xTable->createCursorByRange(xMatrixSheetCellRange));
2254 //UNUSED2008-05 if (xMatrixSheetCursor.is())
2256 //UNUSED2008-05 xMatrixSheetCursor->collapseToCurrentArray();
2257 //UNUSED2008-05 uno::Reference<sheet::XCellRangeAddressable> xMatrixCellAddress (xMatrixSheetCursor, uno::UNO_QUERY);
2258 //UNUSED2008-05 if (xMatrixCellAddress.is())
2260 //UNUSED2008-05 aCellAddress = xMatrixCellAddress->getRangeAddress();
2261 //UNUSED2008-05 if ((aCellAddress.StartColumn == nCol && aCellAddress.StartRow == nRow) &&
2262 //UNUSED2008-05 (aCellAddress.EndColumn > nCol || aCellAddress.EndRow > nRow))
2264 //UNUSED2008-05 bIsFirst = sal_True;
2265 //UNUSED2008-05 return sal_True;
2267 //UNUSED2008-05 else if (aCellAddress.StartColumn != nCol || aCellAddress.StartRow != nRow ||
2268 //UNUSED2008-05 aCellAddress.EndColumn != nCol || aCellAddress.EndRow != nRow)
2269 //UNUSED2008-05 return sal_True;
2270 //UNUSED2008-05 else
2272 //UNUSED2008-05 bIsFirst = sal_True;
2273 //UNUSED2008-05 return sal_True;
2280 //UNUSED2008-05 return sal_False;
2283 sal_Bool
ScXMLExport::IsMatrix (const ScAddress
& aCell
,
2284 table::CellRangeAddress
& aCellAddress
, sal_Bool
& bIsFirst
) const
2286 bIsFirst
= sal_False
;
2288 ScRange aMatrixRange
;
2290 if (pDoc
&& pDoc
->GetMatrixFormulaRange(aCell
, aMatrixRange
))
2292 ScUnoConversion::FillApiRange( aCellAddress
, aMatrixRange
);
2293 if ((aCellAddress
.StartColumn
== aCell
.Col() && aCellAddress
.StartRow
== aCell
.Row()) &&
2294 (aCellAddress
.EndColumn
> aCell
.Col() || aCellAddress
.EndRow
> aCell
.Row()))
2296 bIsFirst
= sal_True
;
2299 else if (aCellAddress
.StartColumn
!= aCell
.Col() || aCellAddress
.StartRow
!= aCell
.Row() ||
2300 aCellAddress
.EndColumn
!= aCell
.Col() || aCellAddress
.EndRow
!= aCell
.Row())
2304 bIsFirst
= sal_True
;
2311 /* uno::Reference <sheet::XArrayFormulaRange> xArrayFormulaRange (xCell, uno::UNO_QUERY);
2312 if (xArrayFormulaRange.is())
2314 rtl::OUString sArrayFormula(xArrayFormulaRange->getArrayFormula());
2315 if (sArrayFormula.getLength())
2317 uno::Reference<sheet::XSheetCellRange> xMatrixSheetCellRange (xCell, uno::UNO_QUERY);
2318 if (xMatrixSheetCellRange.is())
2320 uno::Reference<sheet::XSheetCellCursor> xMatrixSheetCursor(xTable->createCursorByRange(xMatrixSheetCellRange));
2321 if (xMatrixSheetCursor.is())
2323 xMatrixSheetCursor->collapseToCurrentArray();
2324 uno::Reference<sheet::XCellRangeAddressable> xMatrixCellAddress (xMatrixSheetCursor, uno::UNO_QUERY);
2325 if (xMatrixCellAddress.is())
2327 aCellAddress = xMatrixCellAddress->getRangeAddress();
2328 if ((aCellAddress.StartColumn == nCol && aCellAddress.StartRow == nRow) &&
2329 (aCellAddress.EndColumn > nCol || aCellAddress.EndRow > nRow))
2331 bIsFirst = sal_True;
2334 else if (aCellAddress.StartColumn != nCol || aCellAddress.StartRow != nRow ||
2335 aCellAddress.EndColumn != nCol || aCellAddress.EndRow != nRow)
2339 bIsFirst = sal_True;
2350 sal_Bool
ScXMLExport::GetCellText (ScMyCell
& rMyCell
, const ScAddress
& aPos
) const
2352 if (rMyCell
.bHasStringValue
)
2356 /* if (!rMyCell.bHasXText)
2358 rMyCell.xText.set(xCurrentTableCellRange->getCellByPosition(rMyCell.aCellAddress.Column, rMyCell.aCellAddress.Row), uno::UNO_QUERY);
2359 rMyCell.bHasXText = sal_True;
2361 // if (rMyCell.xText.is())
2363 rMyCell
.sStringValue
= ScCellObj::GetOutputString_Impl(pDoc
, aPos
);
2364 rMyCell
.bHasStringValue
= sal_True
;
2365 rMyCell
.sPhoneticText
= ScCellObj::GetOutputPhoneticString_Impl(pDoc
, aPos
);
2366 rMyCell
.bHasPhonetic
= sal_True
;
2372 void ScXMLExport::WriteRubyText (ScMyCell
& rMyCell
)
2374 if ( !rMyCell
.sPhoneticText
.getLength() )
2376 StartElement( XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
2377 StartElement( XML_NAMESPACE_TEXT
, XML_RUBY_BASE
, sal_False
);
2378 Characters( rMyCell
.sStringValue
);
2379 EndElement( XML_NAMESPACE_TEXT
, XML_RUBY_BASE
, sal_False
);
2380 StartElement( XML_NAMESPACE_TEXT
, XML_RUBY_TEXT
, sal_False
);
2381 Characters( rMyCell
.sPhoneticText
);
2382 EndElement( XML_NAMESPACE_TEXT
, XML_RUBY_TEXT
, sal_False
);
2383 EndElement( XML_NAMESPACE_TEXT
, XML_RUBY
, sal_False
);
2386 void ScXMLExport::WriteCell (ScMyCell
& aCell
)
2389 ScUnoConversion::FillScAddress( aCellPos
, aCell
.aCellAddress
);
2390 if (aCell
.nStyleIndex
!= -1)
2391 AddAttribute(sAttrStyleName
, *pCellStyles
->GetStyleNameByIndex(aCell
.nStyleIndex
, aCell
.bIsAutoStyle
));
2392 if (aCell
.nValidationIndex
> -1)
2393 AddAttribute(XML_NAMESPACE_TABLE
, XML_CONTENT_VALIDATION_NAME
, pValidationsContainer
->GetValidationName(aCell
.nValidationIndex
));
2394 sal_Bool
bIsMatrix(aCell
.bIsMatrixBase
|| aCell
.bIsMatrixCovered
);
2395 sal_Bool
bIsFirstMatrixCell(aCell
.bIsMatrixBase
);
2396 if (bIsFirstMatrixCell
)
2398 sal_Int32
nColumns(aCell
.aMatrixRange
.EndColumn
- aCell
.aMatrixRange
.StartColumn
+ 1);
2399 sal_Int32
nRows(aCell
.aMatrixRange
.EndRow
- aCell
.aMatrixRange
.StartRow
+ 1);
2400 rtl::OUStringBuffer sColumns
;
2401 rtl::OUStringBuffer sRows
;
2402 SvXMLUnitConverter::convertNumber(sColumns
, nColumns
);
2403 SvXMLUnitConverter::convertNumber(sRows
, nRows
);
2404 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_MATRIX_COLUMNS_SPANNED
, sColumns
.makeStringAndClear());
2405 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_MATRIX_ROWS_SPANNED
, sRows
.makeStringAndClear());
2407 sal_Bool
bIsEmpty(sal_False
);
2408 switch (aCell
.nType
)
2410 case table::CellContentType_EMPTY
:
2412 bIsEmpty
= sal_True
;
2415 case table::CellContentType_VALUE
:
2417 if (!aCell
.bHasDoubleValue
)
2419 aCell
.fValue
= pDoc
->GetValue( aCellPos
);
2420 aCell
.bHasDoubleValue
= sal_True
;
2422 GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2423 aCell
.nNumberFormat
, aCell
.fValue
);
2426 case table::CellContentType_TEXT
:
2428 if (GetCellText(aCell
, aCellPos
))
2430 rtl::OUString
sFormula(ScCellObj::GetInputString_Impl(pDoc
, aCellPos
, TRUE
));
2431 if (sFormula
[0] == '\'')
2432 sFormula
= sFormula
.copy(1);
2433 GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2434 sFormula
, aCell
.sStringValue
, sal_True
, sal_True
);
2438 case table::CellContentType_FORMULA
:
2440 ScBaseCell
* pBaseCell
= pDoc
? pDoc
->GetCell(aCellPos
) : NULL
;
2441 if (pBaseCell
&& pBaseCell
->GetCellType() == CELLTYPE_FORMULA
)
2443 rtl::OUStringBuffer sFormula
;
2444 ScFormulaCell
* pFormulaCell((ScFormulaCell
*) pBaseCell
);
2445 if (!bIsMatrix
|| (bIsMatrix
&& bIsFirstMatrixCell
))
2447 const formula::FormulaGrammar::Grammar eGrammar
= pDoc
->GetStorageGrammar();
2448 sal_uInt16 nNamespacePrefix
= (eGrammar
== formula::FormulaGrammar::GRAM_ODFF
? XML_NAMESPACE_OF
: XML_NAMESPACE_OOOC
);
2449 pFormulaCell
->GetFormula(sFormula
, eGrammar
);
2450 rtl::OUString
sOUFormula(sFormula
.makeStringAndClear());
2453 AddAttribute(sAttrFormula
, GetNamespaceMap().GetQNameByKey( nNamespacePrefix
, sOUFormula
, sal_False
));
2457 AddAttribute(sAttrFormula
, GetNamespaceMap().GetQNameByKey( nNamespacePrefix
, sOUFormula
.copy(1, sOUFormula
.getLength() - 2), sal_False
));
2460 if (pFormulaCell
->IsValue())
2462 sal_Bool bIsStandard
;
2463 rtl::OUString sCurrency
;
2464 GetNumberFormatAttributesExportHelper()->GetCellType(aCell
.nNumberFormat
, sCurrency
, bIsStandard
);
2468 GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2469 pFormulaCell
->GetStandardFormat(*pDoc
->GetFormatTable(), 0),
2470 pDoc
->GetValue( aCellPos
));
2473 GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
2474 aCell
.nNumberFormat
, pDoc
->GetValue( aCellPos
));
2478 if (GetCellText(aCell
, aCellPos
))
2479 if (aCell
.sStringValue
.getLength())
2481 AddAttribute(sAttrValueType
, XML_STRING
);
2482 AddAttribute(sAttrStringValue
, aCell
.sStringValue
);
2490 // added to avoid warnings
2493 rtl::OUString
* pCellString(&sElemCell
);
2494 if (aCell
.bIsCovered
)
2496 pCellString
= &sElemCoveredCell
;
2500 if (aCell
.bIsMergedBase
)
2502 sal_Int32
nColumns(aCell
.aMergeRange
.EndColumn
- aCell
.aMergeRange
.StartColumn
+ 1);
2503 sal_Int32
nRows(aCell
.aMergeRange
.EndRow
- aCell
.aMergeRange
.StartRow
+ 1);
2504 rtl::OUStringBuffer sColumns
;
2505 rtl::OUStringBuffer sRows
;
2506 SvXMLUnitConverter::convertNumber(sColumns
, nColumns
);
2507 SvXMLUnitConverter::convertNumber(sRows
, nRows
);
2508 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_COLUMNS_SPANNED
, sColumns
.makeStringAndClear());
2509 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_ROWS_SPANNED
, sRows
.makeStringAndClear());
2512 SvXMLElementExport
aElemC(*this, *pCellString
, sal_True
, sal_True
);
2514 WriteAreaLink(aCell
);
2515 WriteAnnotation(aCell
);
2516 WriteDetective(aCell
);
2518 sal_Bool bEditCell
= sal_False
;
2522 if ((aCell
.nType
== table::CellContentType_TEXT
&& IsEditCell(aCell
)) ||
2523 (aCell
.nType
== table::CellContentType_FORMULA
&& IsMultiLineFormulaCell(aCell
)))
2525 bEditCell
= sal_True
;
2526 uno::Reference
<text::XText
> xText(xCurrentTableCellRange
->getCellByPosition(aCell
.aCellAddress
.Column
, aCell
.aCellAddress
.Row
), uno::UNO_QUERY
);
2528 GetTextParagraphExport()->exportText(xText
, sal_False
, sal_False
);
2529 if (GetCellText( aCell
, aCellPos
) && aCell
.sPhoneticText
.getLength())
2530 WriteRubyText( aCell
);
2534 SvXMLElementExport
aElemP(*this, sElemP
, sal_True
, sal_False
);
2535 sal_Bool
bPrevCharWasSpace(sal_True
);
2536 if (GetCellText(aCell
, aCellPos
))
2538 if ( aCell
.sPhoneticText
.getLength() )
2539 WriteRubyText( aCell
);
2541 GetTextParagraphExport()->exportText( aCell
.sStringValue
, bPrevCharWasSpace
);
2547 IncrementProgressBar(bEditCell
);
2550 void ScXMLExport::ExportShape(const uno::Reference
< drawing::XShape
>& xShape
, awt::Point
* pPoint
)
2552 uno::Reference
< beans::XPropertySet
> xShapeProps ( xShape
, uno::UNO_QUERY
);
2553 //BM sal_Bool bMemChart(sal_False); // das muss man jetzt umbenennen :-)
2554 bool bIsChart( false );
2555 rtl::OUString
sPropCLSID (RTL_CONSTASCII_USTRINGPARAM("CLSID"));
2556 rtl::OUString
sPropModel (RTL_CONSTASCII_USTRINGPARAM("Model"));
2557 rtl::OUString
sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName"));
2558 if (xShapeProps
.is())
2560 sal_Int32 nZOrder
= 0;
2561 if (xShapeProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZOrder"))) >>= nZOrder
)
2563 rtl::OUStringBuffer sBuffer
;
2564 GetMM100UnitConverter().convertNumber(sBuffer
, nZOrder
);
2565 AddAttribute(XML_NAMESPACE_DRAW
, XML_ZINDEX
, sBuffer
.makeStringAndClear());
2567 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo
= xShapeProps
->getPropertySetInfo();
2568 if( xPropSetInfo
->hasPropertyByName( sPropCLSID
) )
2570 rtl::OUString sCLSID
;
2571 if (xShapeProps
->getPropertyValue( sPropCLSID
) >>= sCLSID
)
2573 if ( sCLSID
.equalsIgnoreAsciiCase(GetChartExport()->getChartCLSID()) )
2576 uno::Reference
< frame::XModel
> xChartModel
;
2577 if( ( xShapeProps
->getPropertyValue( sPropModel
) >>= xChartModel
) &&
2580 uno::Reference
< chart2::XChartDocument
> xChartDoc( xChartModel
, uno::UNO_QUERY
);
2581 uno::Reference
< chart2::data::XDataReceiver
> xReceiver( xChartModel
, uno::UNO_QUERY
);
2582 if( xChartDoc
.is() && xReceiver
.is() &&
2583 ! xChartDoc
->hasInternalDataProvider())
2585 // we have a chart that gets its data from Calc
2587 uno::Sequence
< ::rtl::OUString
> aRepresentations(
2588 xReceiver
->getUsedRangeRepresentations());
2589 SvXMLAttributeList
* pAttrList
= 0;
2590 if(aRepresentations
.getLength())
2592 // add the ranges used by the chart to the shape
2593 // element to be able to start listening after
2594 // load (when the chart is not yet loaded)
2595 uno::Reference
< chart2::data::XRangeXMLConversion
> xRangeConverter( xChartDoc
->getDataProvider(), uno::UNO_QUERY
);
2596 ::rtl::OUString
sRanges( lcl_RangeSequenceToString( aRepresentations
, xRangeConverter
));
2597 pAttrList
= new SvXMLAttributeList();
2598 pAttrList
->AddAttribute(
2599 GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW
, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES
) ), sRanges
);
2601 GetShapeExport()->exportShape(xShape
, SEF_EXPORT_NO_CHART_DATA
| SEF_DEFAULT
, pPoint
, pAttrList
);
2605 //BM rtl::OUString sOUName;
2606 //BM xShapeProps->getPropertyValue(sPersistName) >>= sOUName;
2607 //BM String sName(sOUName);
2608 //BM if (!pChartListener)
2610 //BM String aEmptyString;
2611 //BM ScRange aRange;
2612 //BM pChartListener = new ScChartListener ( aEmptyString, GetDocument(), aRange );
2614 //BM if(pChartListener)
2616 //BM USHORT nIndex(0);
2617 //BM pChartListener->SetString( sName );
2618 //BM if ( GetDocument() && GetDocument()->GetChartListenerCollection()->Search( pChartListener, nIndex ) )
2620 //BM const ScRangeListRef& rRangeListRef(((ScChartListener*)
2621 //BM (GetDocument()->GetChartListenerCollection()->
2622 //BM At( nIndex )))->GetRangeList());
2623 //BM if (rRangeListRef.Is())
2625 //BM bMemChart = sal_True;
2626 //BM rtl::OUString sRanges;
2627 //BM ScRangeStringConverter::GetStringFromRangeList(sRanges, rRangeListRef, GetDocument());
2628 //BM SvXMLAttributeList* pAttrList = NULL;
2629 //BM if (sRanges.getLength())
2631 //BM pAttrList = new SvXMLAttributeList();
2632 //BM pAttrList->AddAttribute(
2633 //BM GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges );
2635 //BM GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList);
2640 //BM bMemChart = sal_True;
2641 //BM SvXMLAttributeList* pAttrList = new SvXMLAttributeList();
2642 //BM pAttrList->AddAttribute(
2643 //BM GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), rtl::OUString() );
2644 //BM GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint, pAttrList);
2648 /* SchMemChart* pMemChart = pDoc->FindChartData(sName);
2649 if (pMemChart && pMemChart->GetSeriesAddresses().getLength())
2651 bMemChart = sal_True;
2652 rtl::OUString sRanges(pMemChart->getXMLStringForChartRange());
2653 if (sRanges.getLength())
2654 AddAttribute(XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES, sRanges);
2655 GetShapeExport()->exportShape(xShape, SEF_EXPORT_NO_CHART_DATA | SEF_DEFAULT, pPoint);
2663 // #i66550 HLINK_FOR_SHAPES
2664 rtl::OUString sHlink
;
2665 uno::Reference
< beans::XPropertySet
> xProps( xShape
, uno::UNO_QUERY
);
2667 xProps
->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_HYPERLINK
) ) ) >>= sHlink
;
2669 std::auto_ptr
< SvXMLElementExport
> pDrawA
;
2670 // enlose shapes with <draw:a> element only if sHlink contains something
2671 if ( sHlink
.getLength() > 0 )
2673 // need to get delete the attributes that are pre-loaded
2674 // for the shape export ( otherwise they will become
2675 // attributes of the draw:a element ) This *shouldn't*
2676 // affect performance adversely as there are only a
2677 // couple of attributes involved
2678 uno::Reference
< xml::sax::XAttributeList
> xSaveAttribs( new SvXMLAttributeList( GetAttrList() ) );
2681 AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
2682 AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sHlink
);
2683 pDrawA
.reset( new SvXMLElementExport( *this, XML_NAMESPACE_DRAW
, XML_A
, sal_False
, sal_False
) );
2684 // Attribute list has been cleared by previous operation
2685 // re-add pre-loaded attributes
2686 AddAttributeList( xSaveAttribs
);
2688 GetShapeExport()->exportShape(xShape
, SEF_DEFAULT
, pPoint
);
2690 IncrementProgressBar(sal_False
);
2693 void ScXMLExport::WriteShapes(const ScMyCell
& rMyCell
)
2695 if( rMyCell
.bHasShape
&& !rMyCell
.aShapeList
.empty() && pDoc
)
2698 Rectangle aRec
= pDoc
->GetMMRect(static_cast<SCCOL
>(rMyCell
.aCellAddress
.Column
), static_cast<SCROW
>(rMyCell
.aCellAddress
.Row
),
2699 static_cast<SCCOL
>(rMyCell
.aCellAddress
.Column
), static_cast<SCROW
>(rMyCell
.aCellAddress
.Row
), static_cast<SCTAB
>(rMyCell
.aCellAddress
.Sheet
));
2700 BOOL
bNegativePage(pDoc
->IsNegativePage(rMyCell
.aCellAddress
.Sheet
));
2702 aPoint
.X
= aRec
.Right();
2704 aPoint
.X
= aRec
.Left();
2705 aPoint
.Y
= aRec
.Top();
2706 ScMyShapeList::const_iterator aItr
= rMyCell
.aShapeList
.begin();
2707 ScMyShapeList::const_iterator
aEndItr(rMyCell
.aShapeList
.end());
2708 while (aItr
!= aEndItr
)
2710 if (aItr
->xShape
.is())
2713 aPoint
.X
= 2 * aItr
->xShape
->getPosition().X
+ aItr
->xShape
->getSize().Width
- aPoint
.X
;
2714 if ( !aItr
->xShape
->getShapeType().equals(sCaptionShape
) )
2716 awt::Point aEndPoint
;
2717 Rectangle
aEndRec(pDoc
->GetMMRect(aItr
->aEndAddress
.Col(), aItr
->aEndAddress
.Row(),
2718 aItr
->aEndAddress
.Col(), aItr
->aEndAddress
.Row(), aItr
->aEndAddress
.Tab()));
2719 rtl::OUString sEndAddress
;
2720 ScRangeStringConverter::GetStringFromAddress(sEndAddress
, aItr
->aEndAddress
, pDoc
, FormulaGrammar::CONV_OOO
);
2721 AddAttribute(XML_NAMESPACE_TABLE
, XML_END_CELL_ADDRESS
, sEndAddress
);
2723 aEndPoint
.X
= -aEndRec
.Right();
2725 aEndPoint
.X
= aEndRec
.Left();
2726 aEndPoint
.Y
= aEndRec
.Top();
2727 awt::Point
aStartPoint(aItr
->xShape
->getPosition());
2728 awt::Size
aSize(aItr
->xShape
->getSize());
2731 nEndX
= -aStartPoint
.X
- aEndPoint
.X
;
2733 nEndX
= aStartPoint
.X
+ aSize
.Width
- aEndPoint
.X
;
2734 sal_Int32
nEndY(aStartPoint
.Y
+ aSize
.Height
- aEndPoint
.Y
);
2735 rtl::OUStringBuffer sBuffer
;
2736 GetMM100UnitConverter().convertMeasure(sBuffer
, nEndX
);
2737 AddAttribute(XML_NAMESPACE_TABLE
, XML_END_X
, sBuffer
.makeStringAndClear());
2738 GetMM100UnitConverter().convertMeasure(sBuffer
, nEndY
);
2739 AddAttribute(XML_NAMESPACE_TABLE
, XML_END_Y
, sBuffer
.makeStringAndClear());
2741 ExportShape(aItr
->xShape
, &aPoint
);
2748 void ScXMLExport::WriteTableShapes()
2750 ScMyTableShapes
* pTableShapes(pSharedData
->GetTableShapes());
2751 if (pTableShapes
&& !(*pTableShapes
)[nCurrentTable
].empty())
2753 DBG_ASSERT(pTableShapes
->size() > static_cast<size_t>(nCurrentTable
), "wrong Table");
2754 SvXMLElementExport
aShapesElem(*this, XML_NAMESPACE_TABLE
, XML_SHAPES
, sal_True
, sal_False
);
2755 ScMyTableXShapes::iterator
aItr((*pTableShapes
)[nCurrentTable
].begin());
2756 ScMyTableXShapes::iterator
aEndItr((*pTableShapes
)[nCurrentTable
].end());
2757 while (aItr
!= aEndItr
)
2761 if (pDoc
->IsNegativePage(static_cast<SCTAB
>(nCurrentTable
)))
2763 awt::Point
aPoint((*aItr
)->getPosition());
2764 awt::Size
aSize((*aItr
)->getSize());
2765 aPoint
.X
+= aPoint
.X
+ aSize
.Width
;
2767 ExportShape(*aItr
, &aPoint
);
2770 ExportShape(*aItr
, NULL
);
2772 aItr
= (*pTableShapes
)[nCurrentTable
].erase(aItr
);
2777 void ScXMLExport::WriteAreaLink( const ScMyCell
& rMyCell
)
2779 if( rMyCell
.bHasAreaLink
)
2781 const ScMyAreaLink
& rAreaLink
= rMyCell
.aAreaLink
;
2782 AddAttribute( XML_NAMESPACE_TABLE
, XML_NAME
, rAreaLink
.sSourceStr
);
2783 AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, GetRelativeReference(rAreaLink
.sURL
) );
2784 AddAttribute( XML_NAMESPACE_TABLE
, XML_FILTER_NAME
, rAreaLink
.sFilter
);
2785 if( rAreaLink
.sFilterOptions
.getLength() )
2786 AddAttribute( XML_NAMESPACE_TABLE
, XML_FILTER_OPTIONS
, rAreaLink
.sFilterOptions
);
2787 OUStringBuffer sValue
;
2788 SvXMLUnitConverter::convertNumber( sValue
, rAreaLink
.GetColCount() );
2789 AddAttribute( XML_NAMESPACE_TABLE
, XML_LAST_COLUMN_SPANNED
, sValue
.makeStringAndClear() );
2790 SvXMLUnitConverter::convertNumber( sValue
, rAreaLink
.GetRowCount() );
2791 AddAttribute( XML_NAMESPACE_TABLE
, XML_LAST_ROW_SPANNED
, sValue
.makeStringAndClear() );
2792 if( rAreaLink
.nRefresh
)
2794 SvXMLUnitConverter::convertTime( sValue
, (double)rAreaLink
.nRefresh
/ 86400 );
2795 AddAttribute( XML_NAMESPACE_TABLE
, XML_REFRESH_DELAY
, sValue
.makeStringAndClear() );
2797 SvXMLElementExport
aElem( *this, XML_NAMESPACE_TABLE
, XML_CELL_RANGE_SOURCE
, sal_True
, sal_True
);
2801 void ScXMLExport::exportAnnotationMeta( const uno::Reference
< drawing::XShape
>& xShape
)
2803 if (pCurrentCell
&& pCurrentCell
->xNoteShape
.is() && pCurrentCell
->xNoteShape
.get() == xShape
.get() && pCurrentCell
->xAnnotation
.is())
2805 rtl::OUString
sAuthor(pCurrentCell
->xAnnotation
->getAuthor());
2806 if (sAuthor
.getLength())
2808 SvXMLElementExport
aCreatorElem( *this, XML_NAMESPACE_DC
,
2809 XML_CREATOR
, sal_True
,
2811 Characters(sAuthor
);
2814 String
aDate(pCurrentCell
->xAnnotation
->getDate());
2817 SvNumberFormatter
* pNumForm
= pDoc
->GetFormatTable();
2819 sal_uInt32 nfIndex
= pNumForm
->GetFormatIndex(NF_DATE_SYS_DDMMYYYY
, LANGUAGE_SYSTEM
);
2820 if (pNumForm
->IsNumberFormat(aDate
, nfIndex
, fDate
))
2822 rtl::OUStringBuffer sBuf
;
2823 GetMM100UnitConverter().convertDateTime(sBuf
, fDate
,sal_True
);
2824 SvXMLElementExport
aDateElem( *this, XML_NAMESPACE_DC
,
2827 Characters(sBuf
.makeStringAndClear());
2831 SvXMLElementExport
aDateElem( *this, XML_NAMESPACE_META
,
2832 XML_DATE_STRING
, sal_True
,
2834 Characters(rtl::OUString(aDate
));
2839 SvXMLElementExport
aDateElem( *this, XML_NAMESPACE_META
,
2840 XML_DATE_STRING
, sal_True
,
2842 Characters(rtl::OUString(aDate
));
2847 void ScXMLExport::WriteAnnotation(ScMyCell
& rMyCell
)
2849 if( rMyCell
.bHasAnnotation
&& rMyCell
.xAnnotation
.is())
2851 /* rtl::OUString sAuthor(rMyCell.xAnnotation->getAuthor());
2852 if (sAuthor.getLength())
2854 SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC,
2855 XML_CREATOR, sal_True,
2857 rtl::OUString sAuthor(sAuthor);
2858 Characters(sAuthor);
2861 String aDate(rMyCell.xAnnotation->getDate());
2864 SvNumberFormatter* pNumForm(pDoc->GetFormatTable());
2866 sal_uInt32 nfIndex = pNumForm->GetFormatIndex(NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM);
2867 if (pNumForm->IsNumberFormat(aDate, nfIndex, fDate))
2869 rtl::OUStringBuffer sBuf;
2870 GetMM100UnitConverter().convertDateTime(sBuf, fDate);
2871 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC,
2874 Characters(sBuf.makeStringAndClear());
2878 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_META,
2879 XML_DATE_STRING, sal_True,
2881 Characters(rtl::OUString(aDate));
2886 SvXMLElementExport aDateElem( *this, XML_NAMESPACE_META,
2887 XML_DATE_STRING, sal_True,
2889 Characters(rtl::OUString(aDate));
2892 if (rMyCell
.xAnnotation
->getIsVisible())
2893 AddAttribute(XML_NAMESPACE_OFFICE
, XML_DISPLAY
, XML_TRUE
);
2895 pCurrentCell
= &rMyCell
;
2897 if(rMyCell
.xNoteShape
.is())
2898 GetShapeExport()->exportShape(rMyCell
.xNoteShape
, SEF_DEFAULT
|SEF_EXPORT_ANNOTATION
, NULL
);
2900 pCurrentCell
= NULL
;
2902 rMyCell
.xNoteShape
.clear();
2906 void ScXMLExport::WriteDetective( const ScMyCell
& rMyCell
)
2908 if( rMyCell
.bHasDetectiveObj
|| rMyCell
.bHasDetectiveOp
)
2910 const ScMyDetectiveObjVec
& rObjVec
= rMyCell
.aDetectiveObjVec
;
2911 const ScMyDetectiveOpVec
& rOpVec
= rMyCell
.aDetectiveOpVec
;
2912 sal_Int32
nObjCount(rObjVec
.size());
2913 sal_Int32
nOpCount(rOpVec
.size());
2914 if( nObjCount
|| nOpCount
)
2916 SvXMLElementExport
aDetElem( *this, XML_NAMESPACE_TABLE
, XML_DETECTIVE
, sal_True
, sal_True
);
2918 ScMyDetectiveObjVec::const_iterator
aObjItr(rObjVec
.begin());
2919 ScMyDetectiveObjVec::const_iterator
aEndObjItr(rObjVec
.end());
2920 while(aObjItr
!= aEndObjItr
)
2922 if (aObjItr
->eObjType
!= SC_DETOBJ_CIRCLE
)
2924 if( (aObjItr
->eObjType
== SC_DETOBJ_ARROW
) || (aObjItr
->eObjType
== SC_DETOBJ_TOOTHERTAB
))
2926 ScRangeStringConverter::GetStringFromRange( sString
, aObjItr
->aSourceRange
, pDoc
, FormulaGrammar::CONV_OOO
);
2927 AddAttribute( XML_NAMESPACE_TABLE
, XML_CELL_RANGE_ADDRESS
, sString
);
2929 ScXMLConverter::GetStringFromDetObjType( sString
, aObjItr
->eObjType
);
2930 AddAttribute( XML_NAMESPACE_TABLE
, XML_DIRECTION
, sString
);
2931 if( aObjItr
->bHasError
)
2932 AddAttribute( XML_NAMESPACE_TABLE
, XML_CONTAINS_ERROR
, XML_TRUE
);
2935 AddAttribute( XML_NAMESPACE_TABLE
, XML_MARKED_INVALID
, XML_TRUE
);
2936 SvXMLElementExport
aRangeElem( *this, XML_NAMESPACE_TABLE
, XML_HIGHLIGHTED_RANGE
, sal_True
, sal_True
);
2939 OUStringBuffer aBuffer
;
2940 ScMyDetectiveOpVec::const_iterator
aOpItr(rOpVec
.begin());
2941 ScMyDetectiveOpVec::const_iterator
aEndOpItr(rOpVec
.end());
2942 while(aOpItr
!= aEndOpItr
)
2945 ScXMLConverter::GetStringFromDetOpType( sOpString
, aOpItr
->eOpType
);
2946 AddAttribute( XML_NAMESPACE_TABLE
, XML_NAME
, sOpString
);
2947 SvXMLUnitConverter::convertNumber( aBuffer
, aOpItr
->nIndex
);
2948 AddAttribute( XML_NAMESPACE_TABLE
, XML_INDEX
, aBuffer
.makeStringAndClear() );
2949 SvXMLElementExport
aRangeElem( *this, XML_NAMESPACE_TABLE
, XML_OPERATION
, sal_True
, sal_True
);
2956 void ScXMLExport::SetRepeatAttribute (const sal_Int32 nEqualCellCount
)
2958 if (nEqualCellCount
> 0)
2960 sal_Int32
nTemp(nEqualCellCount
+ 1);
2961 OUString
sOUEqualCellCount(OUString::valueOf(nTemp
));
2962 AddAttribute(sAttrColumnsRepeated
, sOUEqualCellCount
);
2963 IncrementProgressBar(sal_False
, nEqualCellCount
);
2967 sal_Bool
ScXMLExport::IsCellTypeEqual (const ScMyCell
& aCell1
, const ScMyCell
& aCell2
) const
2969 return (aCell1
.nType
== aCell2
.nType
);
2972 sal_Bool
ScXMLExport::IsEditCell(const com::sun::star::table::CellAddress
& aAddress
, ScMyCell
* pMyCell
) const
2974 ScAddress
aCoreAddress(static_cast<SCCOL
>(aAddress
.Column
),
2975 static_cast<SCROW
>(aAddress
.Row
),
2976 static_cast<SCTAB
>(aAddress
.Sheet
));
2977 ScBaseCell
* pBaseCell
= GetDocument() ? GetDocument()->GetCell(aCoreAddress
) : NULL
;
2979 pMyCell
->pBaseCell
= pBaseCell
;
2982 return (pBaseCell
->GetCellType() == CELLTYPE_EDIT
);
2986 //UNUSED2008-05 sal_Bool ScXMLExport::IsEditCell(const com::sun::star::uno::Reference <com::sun::star::table::XCell>& xCell) const
2988 //UNUSED2008-05 uno::Reference<sheet::XCellAddressable> xAddressable (xCell, uno::UNO_QUERY);
2989 //UNUSED2008-05 if ( xAddressable.is() )
2990 //UNUSED2008-05 return IsEditCell(xAddressable->getCellAddress());
2991 //UNUSED2008-05 return sal_False;
2994 sal_Bool
ScXMLExport::IsEditCell(ScMyCell
& rCell
) const
2996 if (rCell
.bKnowWhetherIsEditCell
)
2997 return rCell
.bIsEditCell
;
3000 rCell
.bIsEditCell
= IsEditCell(rCell
.aCellAddress
, &rCell
);
3001 rCell
.bKnowWhetherIsEditCell
= sal_True
;
3002 return rCell
.bIsEditCell
;
3006 sal_Bool
ScXMLExport::IsMultiLineFormulaCell(ScMyCell
& rCell
)
3008 if (rCell
.pBaseCell
)
3010 if (rCell
.pBaseCell
->GetCellType() != CELLTYPE_FORMULA
)
3013 return static_cast<ScFormulaCell
*>(rCell
.pBaseCell
)->IsMultilineResult();
3016 ScAddress
aAddr(static_cast<SCCOL
>(rCell
.aCellAddress
.Column
),
3017 static_cast<SCROW
>(rCell
.aCellAddress
.Row
),
3018 static_cast<SCTAB
>(rCell
.aCellAddress
.Sheet
));
3019 ScBaseCell
* pBaseCell
= pDoc
? pDoc
->GetCell(aAddr
) : NULL
;
3023 rCell
.pBaseCell
= pBaseCell
;
3024 if (rCell
.pBaseCell
->GetCellType() != CELLTYPE_FORMULA
)
3027 return static_cast<ScFormulaCell
*>(rCell
.pBaseCell
)->IsMultilineResult();
3030 //UNUSED2008-05 sal_Bool ScXMLExport::IsAnnotationEqual(const uno::Reference<table::XCell>& /* xCell1 */,
3031 //UNUSED2008-05 const uno::Reference<table::XCell>& /* xCell2 */)
3033 //UNUSED2008-05 // no longer compareable, because the position and size and other attributes can also differ
3035 //UNUSED2008-05 /* uno::Reference<sheet::XSheetAnnotationAnchor> xSheetAnnotationAnchor1(xCell1, uno::UNO_QUERY);
3036 //UNUSED2008-05 uno::Reference<sheet::XSheetAnnotationAnchor> xSheetAnnotationAnchor2(xCell2, uno::UNO_QUERY);
3037 //UNUSED2008-05 if (xSheetAnnotationAnchor1.is() && xSheetAnnotationAnchor2.is())
3039 //UNUSED2008-05 uno::Reference <sheet::XSheetAnnotation> xSheetAnnotation1(xSheetAnnotationAnchor1->getAnnotation());
3040 //UNUSED2008-05 uno::Reference <sheet::XSheetAnnotation> xSheetAnnotation2(xSheetAnnotationAnchor2->getAnnotation());
3041 //UNUSED2008-05 uno::Reference<text::XSimpleText> xSimpleText1(xSheetAnnotation1, uno::UNO_QUERY);
3042 //UNUSED2008-05 uno::Reference<text::XSimpleText> xSimpleText2(xSheetAnnotation2, uno::UNO_QUERY);
3043 //UNUSED2008-05 if (xSheetAnnotation1.is() && xSimpleText1.is() &&
3044 //UNUSED2008-05 xSheetAnnotation2.is() && xSimpleText2.is())
3046 //UNUSED2008-05 rtl::OUString sText1(xSimpleText1->getString());
3047 //UNUSED2008-05 rtl::OUString sText2(xSimpleText2->getString());
3048 //UNUSED2008-05 sal_Int32 nLength1(sText1.getLength());
3049 //UNUSED2008-05 sal_Int32 nLength2(sText2.getLength());
3050 //UNUSED2008-05 if (nLength1 && nLength2)
3051 //UNUSED2008-05 if (sText1 == sText2 &&
3052 //UNUSED2008-05 xSheetAnnotation1->getAuthor() == xSheetAnnotation2->getAuthor() &&
3053 //UNUSED2008-05 xSheetAnnotation1->getDate() == xSheetAnnotation2->getDate() &&
3054 //UNUSED2008-05 xSheetAnnotation1->getIsVisible() == xSheetAnnotation2->getIsVisible())
3055 //UNUSED2008-05 return sal_True;
3056 //UNUSED2008-05 else
3057 //UNUSED2008-05 return sal_False;
3058 //UNUSED2008-05 else
3059 //UNUSED2008-05 if (nLength1 || nLength2)
3060 //UNUSED2008-05 return sal_False;
3061 //UNUSED2008-05 else
3062 //UNUSED2008-05 return sal_True;
3065 //UNUSED2008-05 return sal_False;
3068 sal_Bool
ScXMLExport::IsCellEqual (ScMyCell
& aCell1
, ScMyCell
& aCell2
)
3070 ScAddress aCellPos1
;
3071 ScUnoConversion::FillScAddress( aCellPos1
, aCell1
.aCellAddress
);
3072 ScAddress aCellPos2
;
3073 ScUnoConversion::FillScAddress( aCellPos2
, aCell2
.aCellAddress
);
3074 sal_Bool bIsEqual
= sal_False
;
3075 if( !aCell1
.bIsMergedBase
&& !aCell2
.bIsMergedBase
&&
3076 aCell1
.bIsCovered
== aCell2
.bIsCovered
&&
3077 !aCell1
.bIsMatrixBase
&& !aCell2
.bIsMatrixBase
&&
3078 aCell1
.bIsMatrixCovered
== aCell2
.bIsMatrixCovered
&&
3079 aCell1
.bHasAnnotation
== aCell2
.bHasAnnotation
&&
3080 !aCell1
.bHasShape
&& !aCell2
.bHasShape
&&
3081 aCell1
.bHasAreaLink
== aCell2
.bHasAreaLink
&&
3082 !aCell1
.bHasDetectiveObj
&& !aCell2
.bHasDetectiveObj
)
3084 if( (aCell1
.bHasAreaLink
&&
3085 (aCell1
.aAreaLink
.GetColCount() == 1) &&
3086 (aCell2
.aAreaLink
.GetColCount() == 1) &&
3087 aCell1
.aAreaLink
.Compare( aCell2
.aAreaLink
) ) ||
3088 !aCell1
.bHasAreaLink
)
3090 if (!aCell1
.bHasAnnotation
|| (aCell1
.bHasAnnotation
&& sal_False
/*IsAnnotationEqual(aCell1.xCell, aCell2.xCell)*/)) // no longer compareable
3092 if (((aCell1
.nStyleIndex
== aCell2
.nStyleIndex
) && ((aCell1
.bIsAutoStyle
== aCell2
.bIsAutoStyle
) ||
3093 (aCell1
.nStyleIndex
== aCell2
.nStyleIndex
)) && (aCell1
.nStyleIndex
== -1)) &&
3094 (aCell1
.nValidationIndex
== aCell2
.nValidationIndex
) &&
3095 IsCellTypeEqual(aCell1
, aCell2
))
3097 switch ( aCell1
.nType
)
3099 case table::CellContentType_EMPTY
:
3101 bIsEqual
= sal_True
;
3104 case table::CellContentType_VALUE
:
3106 if(!aCell1
.bHasDoubleValue
)
3108 aCell1
.fValue
= pDoc
->GetValue( aCellPos1
);
3109 aCell1
.bHasDoubleValue
= sal_True
;
3111 if (!aCell2
.bHasDoubleValue
)
3113 aCell2
.fValue
= pDoc
->GetValue( aCellPos2
);
3114 aCell2
.bHasDoubleValue
= sal_True
;
3116 // #i29101# number format may be different from column default styles,
3117 // but can lead to different value types, so it must also be compared
3118 bIsEqual
= (aCell1
.nNumberFormat
== aCell2
.nNumberFormat
) &&
3119 (aCell1
.fValue
== aCell2
.fValue
);
3122 case table::CellContentType_TEXT
:
3124 if (IsEditCell(aCell1
) || IsEditCell(aCell2
))
3125 bIsEqual
= sal_False
;
3128 if (GetCellText(aCell1
, aCellPos1
) && GetCellText(aCell2
, aCellPos2
))
3130 bIsEqual
= (aCell1
.sStringValue
== aCell2
.sStringValue
) &&
3131 (ScCellObj::GetInputString_Impl(pDoc
, aCellPos1
, TRUE
) == ScCellObj::GetInputString_Impl(pDoc
, aCellPos2
, TRUE
));
3134 bIsEqual
= sal_False
;
3138 case table::CellContentType_FORMULA
:
3140 bIsEqual
= sal_False
;
3145 bIsEqual
= sal_False
;
3156 void ScXMLExport::WriteCalculationSettings(const uno::Reference
<sheet::XSpreadsheetDocument
>& xSpreadDoc
)
3158 uno::Reference
<beans::XPropertySet
> xPropertySet(xSpreadDoc
, uno::UNO_QUERY
);
3159 if (xPropertySet
.is())
3161 sal_Bool
bCalcAsShown (::cppu::any2bool( xPropertySet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_CALCASSHOWN
))) ));
3162 sal_Bool
bIgnoreCase (::cppu::any2bool( xPropertySet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_IGNORECASE
))) ));
3163 sal_Bool
bLookUpLabels (::cppu::any2bool( xPropertySet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_LOOKUPLABELS
))) ));
3164 sal_Bool
bMatchWholeCell (::cppu::any2bool( xPropertySet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_MATCHWHOLE
))) ));
3165 sal_Bool
bUseRegularExpressions (::cppu::any2bool( xPropertySet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_REGEXENABLED
))) ));
3166 sal_Bool
bIsIterationEnabled (::cppu::any2bool( xPropertySet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERENABLED
))) ));
3167 sal_uInt16
nYear2000 (pDoc
? pDoc
->GetDocOptions().GetYear2000() : 0);
3168 sal_Int32
nIterationCount(100);
3169 xPropertySet
->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITERCOUNT
))) >>= nIterationCount
;
3170 double fIterationEpsilon
= 0;
3171 xPropertySet
->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ITEREPSILON
))) >>= fIterationEpsilon
;
3172 util::Date aNullDate
;
3173 xPropertySet
->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NULLDATE
))) >>= aNullDate
;
3174 if (bCalcAsShown
|| bIgnoreCase
|| !bLookUpLabels
|| !bMatchWholeCell
|| !bUseRegularExpressions
||
3175 bIsIterationEnabled
|| nIterationCount
!= 100 || !::rtl::math::approxEqual(fIterationEpsilon
, 0.001) ||
3176 aNullDate
.Day
!= 30 || aNullDate
.Month
!= 12 || aNullDate
.Year
!= 1899 || nYear2000
!= 1930)
3179 AddAttribute(XML_NAMESPACE_TABLE
, XML_CASE_SENSITIVE
, XML_FALSE
);
3181 AddAttribute(XML_NAMESPACE_TABLE
, XML_PRECISION_AS_SHOWN
, XML_TRUE
);
3182 if (!bMatchWholeCell
)
3183 AddAttribute(XML_NAMESPACE_TABLE
, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL
, XML_FALSE
);
3185 AddAttribute(XML_NAMESPACE_TABLE
, XML_AUTOMATIC_FIND_LABELS
, XML_FALSE
);
3186 if (!bUseRegularExpressions
)
3187 AddAttribute(XML_NAMESPACE_TABLE
, XML_USE_REGULAR_EXPRESSIONS
, XML_FALSE
);
3188 if (nYear2000
!= 1930)
3190 rtl::OUStringBuffer sBuffer
;
3191 GetMM100UnitConverter().convertNumber(sBuffer
, nYear2000
);
3192 AddAttribute(XML_NAMESPACE_TABLE
, XML_NULL_YEAR
, sBuffer
.makeStringAndClear());
3194 SvXMLElementExport
aCalcSettings(*this, XML_NAMESPACE_TABLE
, XML_CALCULATION_SETTINGS
, sal_True
, sal_True
);
3196 if (aNullDate
.Day
!= 30 || aNullDate
.Month
!= 12 || aNullDate
.Year
!= 1899)
3198 rtl::OUStringBuffer sDate
;
3199 GetMM100UnitConverter().convertDateTime(sDate
, 0.0, aNullDate
);
3200 AddAttribute(XML_NAMESPACE_TABLE
, XML_DATE_VALUE
, sDate
.makeStringAndClear());
3201 SvXMLElementExport
aElemNullDate(*this, XML_NAMESPACE_TABLE
, XML_NULL_DATE
, sal_True
, sal_True
);
3203 if (bIsIterationEnabled
|| nIterationCount
!= 100 || !::rtl::math::approxEqual(fIterationEpsilon
, 0.001))
3205 rtl::OUStringBuffer sBuffer
;
3206 if (bIsIterationEnabled
)
3207 AddAttribute(XML_NAMESPACE_TABLE
, XML_STATUS
, XML_ENABLE
);
3208 if (nIterationCount
!= 100)
3210 GetMM100UnitConverter().convertNumber(sBuffer
, nIterationCount
);
3211 AddAttribute(XML_NAMESPACE_TABLE
, XML_STEPS
, sBuffer
.makeStringAndClear());
3213 if (!::rtl::math::approxEqual(fIterationEpsilon
, 0.001))
3215 GetMM100UnitConverter().convertDouble(sBuffer
, fIterationEpsilon
);
3216 AddAttribute(XML_NAMESPACE_TABLE
, XML_MAXIMUM_DIFFERENCE
, sBuffer
.makeStringAndClear());
3218 SvXMLElementExport
aElemIteration(*this, XML_NAMESPACE_TABLE
, XML_ITERATION
, sal_True
, sal_True
);
3225 void ScXMLExport::WriteTableSource()
3227 uno::Reference
<sheet::XSheetLinkable
> xLinkable (xCurrentTable
, uno::UNO_QUERY
);
3228 if (xLinkable
.is() && GetModel().is())
3230 sheet::SheetLinkMode
nMode (xLinkable
->getLinkMode());
3231 if (nMode
!= sheet::SheetLinkMode_NONE
)
3233 rtl::OUString
sLink (xLinkable
->getLinkUrl());
3234 uno::Reference
<beans::XPropertySet
> xProps (GetModel(), uno::UNO_QUERY
);
3237 uno::Reference
<container::XIndexAccess
> xIndex(xProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETLINKS
))), uno::UNO_QUERY
);
3240 sal_Int32
nCount(xIndex
->getCount());
3243 sal_Bool
bFound(sal_False
);
3244 uno::Reference
<beans::XPropertySet
> xLinkProps
;
3245 for (sal_Int32 i
= 0; (i
< nCount
) && !bFound
; ++i
)
3247 xLinkProps
.set(xIndex
->getByIndex(i
), uno::UNO_QUERY
);
3248 if (xLinkProps
.is())
3250 rtl::OUString sNewLink
;
3251 if (xLinkProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_LINKURL
))) >>= sNewLink
)
3252 bFound
= sLink
.equals(sNewLink
);
3255 if (bFound
&& xLinkProps
.is())
3257 rtl::OUString sFilter
;
3258 rtl::OUString sFilterOptions
;
3259 rtl::OUString
sTableName (xLinkable
->getLinkSheetName());
3260 sal_Int32
nRefresh(0);
3261 xLinkProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FILTER
))) >>= sFilter
;
3262 xLinkProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_FILTOPT
))) >>= sFilterOptions
;
3263 xLinkProps
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_REFDELAY
))) >>= nRefresh
;
3264 if (sLink
.getLength())
3266 AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
, GetRelativeReference(sLink
));
3267 if (sTableName
.getLength())
3268 AddAttribute(XML_NAMESPACE_TABLE
, XML_TABLE_NAME
, sTableName
);
3269 if (sFilter
.getLength())
3270 AddAttribute(XML_NAMESPACE_TABLE
, XML_FILTER_NAME
, sFilter
);
3271 if (sFilterOptions
.getLength())
3272 AddAttribute(XML_NAMESPACE_TABLE
, XML_FILTER_OPTIONS
, sFilterOptions
);
3273 if (nMode
!= sheet::SheetLinkMode_NORMAL
)
3274 AddAttribute(XML_NAMESPACE_TABLE
, XML_MODE
, XML_COPY_RESULTS_ONLY
);
3277 rtl::OUStringBuffer sBuffer
;
3278 SvXMLUnitConverter::convertTime( sBuffer
, (double)nRefresh
/ 86400 );
3279 AddAttribute( XML_NAMESPACE_TABLE
, XML_REFRESH_DELAY
, sBuffer
.makeStringAndClear() );
3281 SvXMLElementExport
aSourceElem(*this, XML_NAMESPACE_TABLE
, XML_TABLE_SOURCE
, sal_True
, sal_True
);
3291 // core implementation
3292 void ScXMLExport::WriteScenario()
3294 if (pDoc
&& pDoc
->IsScenario(static_cast<SCTAB
>(nCurrentTable
)))
3299 pDoc
->GetScenarioData(static_cast<SCTAB
>(nCurrentTable
), sComment
, aColor
, nFlags
);
3300 if (!(nFlags
& SC_SCENARIO_SHOWFRAME
))
3301 AddAttribute(XML_NAMESPACE_TABLE
, XML_DISPLAY_BORDER
, XML_FALSE
);
3302 rtl::OUStringBuffer aBuffer
;
3303 SvXMLUnitConverter::convertColor(aBuffer
, aColor
);
3304 AddAttribute(XML_NAMESPACE_TABLE
, XML_BORDER_COLOR
, aBuffer
.makeStringAndClear());
3305 if (!(nFlags
& SC_SCENARIO_TWOWAY
))
3306 AddAttribute(XML_NAMESPACE_TABLE
, XML_COPY_BACK
, XML_FALSE
);
3307 if (!(nFlags
& SC_SCENARIO_ATTRIB
))
3308 AddAttribute(XML_NAMESPACE_TABLE
, XML_COPY_STYLES
, XML_FALSE
);
3309 if (nFlags
& SC_SCENARIO_VALUE
)
3310 AddAttribute(XML_NAMESPACE_TABLE
, XML_COPY_FORMULAS
, XML_FALSE
);
3311 if (nFlags
& SC_SCENARIO_PROTECT
)
3312 AddAttribute(XML_NAMESPACE_TABLE
, XML_PROTECTED
, XML_TRUE
);
3313 SvXMLUnitConverter::convertBool(aBuffer
, pDoc
->IsActiveScenario(static_cast<SCTAB
>(nCurrentTable
)));
3314 AddAttribute(XML_NAMESPACE_TABLE
, XML_IS_ACTIVE
, aBuffer
.makeStringAndClear());
3315 const ScRangeList
* pRangeList
= pDoc
->GetScenarioRanges(static_cast<SCTAB
>(nCurrentTable
));
3316 rtl::OUString sRangeListStr
;
3317 ScRangeStringConverter::GetStringFromRangeList( sRangeListStr
, pRangeList
, pDoc
, FormulaGrammar::CONV_OOO
);
3318 AddAttribute(XML_NAMESPACE_TABLE
, XML_SCENARIO_RANGES
, sRangeListStr
);
3320 AddAttribute(XML_NAMESPACE_TABLE
, XML_COMMENT
, rtl::OUString(sComment
));
3321 SvXMLElementExport
aElem(*this, XML_NAMESPACE_TABLE
, XML_SCENARIO
, sal_True
, sal_True
);
3325 void ScXMLExport::WriteTheLabelRanges( const uno::Reference
< sheet::XSpreadsheetDocument
>& xSpreadDoc
)
3327 uno::Reference
< beans::XPropertySet
> xDocProp( xSpreadDoc
, uno::UNO_QUERY
);
3328 if( !xDocProp
.is() ) return;
3330 sal_Int32
nCount(0);
3331 uno::Reference
< container::XIndexAccess
> xColRangesIAccess(xDocProp
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLLABELRNG
) ) ), uno::UNO_QUERY
);
3332 if( xColRangesIAccess
.is() )
3333 nCount
+= xColRangesIAccess
->getCount();
3335 uno::Reference
< container::XIndexAccess
> xRowRangesIAccess(xDocProp
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ROWLABELRNG
) ) ), uno::UNO_QUERY
);
3336 if( xRowRangesIAccess
.is() )
3337 nCount
+= xRowRangesIAccess
->getCount();
3341 SvXMLElementExport
aElem( *this, XML_NAMESPACE_TABLE
, XML_LABEL_RANGES
, sal_True
, sal_True
);
3342 WriteLabelRanges( xColRangesIAccess
, sal_True
);
3343 WriteLabelRanges( xRowRangesIAccess
, sal_False
);
3347 void ScXMLExport::WriteLabelRanges( const uno::Reference
< container::XIndexAccess
>& xRangesIAccess
, sal_Bool bColumn
)
3349 if( !xRangesIAccess
.is() ) return;
3351 sal_Int32
nCount(xRangesIAccess
->getCount());
3352 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; ++nIndex
)
3354 uno::Reference
< sheet::XLabelRange
> xRange(xRangesIAccess
->getByIndex( nIndex
), uno::UNO_QUERY
);
3358 table::CellRangeAddress
aCellRange( xRange
->getLabelArea() );
3359 ScRangeStringConverter::GetStringFromRange( sRangeStr
, aCellRange
, pDoc
, FormulaGrammar::CONV_OOO
);
3360 AddAttribute( XML_NAMESPACE_TABLE
, XML_LABEL_CELL_RANGE_ADDRESS
, sRangeStr
);
3361 aCellRange
= xRange
->getDataArea();
3362 ScRangeStringConverter::GetStringFromRange( sRangeStr
, aCellRange
, pDoc
, FormulaGrammar::CONV_OOO
);
3363 AddAttribute( XML_NAMESPACE_TABLE
, XML_DATA_CELL_RANGE_ADDRESS
, sRangeStr
);
3364 AddAttribute( XML_NAMESPACE_TABLE
, XML_ORIENTATION
, bColumn
? XML_COLUMN
: XML_ROW
);
3365 SvXMLElementExport
aElem( *this, XML_NAMESPACE_TABLE
, XML_LABEL_RANGE
, sal_True
, sal_True
);
3370 void ScXMLExport::WriteNamedExpressions(const com::sun::star::uno::Reference
<com::sun::star::sheet::XSpreadsheetDocument
>& xSpreadDoc
)
3372 uno::Reference
<beans::XPropertySet
> xPropertySet (xSpreadDoc
, uno::UNO_QUERY
);
3373 if (xPropertySet
.is())
3375 uno::Reference
<sheet::XNamedRanges
> xNamedRanges(xPropertySet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NAMEDRANGES
))), uno::UNO_QUERY
);
3377 if (xNamedRanges
.is())
3379 uno::Sequence
<rtl::OUString
> aRangesNames(xNamedRanges
->getElementNames());
3380 sal_Int32
nNamedRangesCount(aRangesNames
.getLength());
3381 if (nNamedRangesCount
> 0)
3385 ScRangeName
* pNamedRanges(pDoc
->GetRangeName());
3386 SvXMLElementExport
aElemNEs(*this, XML_NAMESPACE_TABLE
, XML_NAMED_EXPRESSIONS
, sal_True
, sal_True
);
3387 for (sal_Int32 i
= 0; i
< nNamedRangesCount
; ++i
)
3390 rtl::OUString
sNamedRange(aRangesNames
[i
]);
3391 uno::Reference
<sheet::XNamedRange
> xNamedRange(xNamedRanges
->getByName(sNamedRange
), uno::UNO_QUERY
);
3392 if (xNamedRange
.is())
3394 uno::Reference
<container::XNamed
> xNamed (xNamedRange
, uno::UNO_QUERY
);
3395 uno::Reference
<sheet::XCellRangeReferrer
> xCellRangeReferrer (xNamedRange
, uno::UNO_QUERY
);
3396 if (xNamed
.is() && xCellRangeReferrer
.is())
3398 rtl::OUString
sOUName(xNamed
->getName());
3399 AddAttribute(sAttrName
, sOUName
);
3401 OUString sOUBaseCellAddress
;
3402 ScRangeStringConverter::GetStringFromAddress( sOUBaseCellAddress
,
3403 xNamedRange
->getReferencePosition(), pDoc
, FormulaGrammar::CONV_OOO
, ' ', sal_False
, SCA_ABS_3D
);
3404 AddAttribute(XML_NAMESPACE_TABLE
, XML_BASE_CELL_ADDRESS
, sOUBaseCellAddress
);
3406 sal_uInt16 nRangeIndex
;
3407 String
sName(sOUName
);
3408 pNamedRanges
->SearchName(sName
, nRangeIndex
);
3409 ScRangeData
* pNamedRange((*pNamedRanges
)[nRangeIndex
]); //should get directly and not with ScDocument
3411 pNamedRange
->GetSymbol(sContent
, pDoc
->GetStorageGrammar());
3412 rtl::OUString
sOUTempContent(sContent
);
3413 uno::Reference
<table::XCellRange
> xCellRange(xCellRangeReferrer
->getReferredCells());
3416 rtl::OUString
sOUContent(sOUTempContent
.copy(1, sOUTempContent
.getLength() - 2));
3417 AddAttribute(XML_NAMESPACE_TABLE
, XML_CELL_RANGE_ADDRESS
, sOUContent
);
3418 sal_Int32
nRangeType(xNamedRange
->getType());
3419 rtl::OUStringBuffer sBufferRangeType
;
3420 if ((nRangeType
& sheet::NamedRangeFlag::COLUMN_HEADER
) == sheet::NamedRangeFlag::COLUMN_HEADER
)
3421 sBufferRangeType
.append(GetXMLToken(XML_REPEAT_COLUMN
));
3422 if ((nRangeType
& sheet::NamedRangeFlag::ROW_HEADER
) == sheet::NamedRangeFlag::ROW_HEADER
)
3424 if (sBufferRangeType
.getLength() > 0)
3425 sBufferRangeType
.appendAscii(" ");
3426 sBufferRangeType
.append(GetXMLToken(XML_REPEAT_ROW
));
3428 if ((nRangeType
& sheet::NamedRangeFlag::FILTER_CRITERIA
) == sheet::NamedRangeFlag::FILTER_CRITERIA
)
3430 if (sBufferRangeType
.getLength() > 0)
3431 sBufferRangeType
.appendAscii(" ");
3432 sBufferRangeType
.append(GetXMLToken(XML_FILTER
));
3434 if ((nRangeType
& sheet::NamedRangeFlag::PRINT_AREA
) == sheet::NamedRangeFlag::PRINT_AREA
)
3436 if (sBufferRangeType
.getLength() > 0)
3437 sBufferRangeType
.appendAscii(" ");
3438 sBufferRangeType
.append(GetXMLToken(XML_PRINT_RANGE
));
3440 rtl::OUString sRangeType
= sBufferRangeType
.makeStringAndClear();
3441 if (sRangeType
.getLength())
3442 AddAttribute(XML_NAMESPACE_TABLE
, XML_RANGE_USABLE_AS
, sRangeType
);
3443 SvXMLElementExport
aElemNR(*this, XML_NAMESPACE_TABLE
, XML_NAMED_RANGE
, sal_True
, sal_True
);
3447 AddAttribute(XML_NAMESPACE_TABLE
, XML_EXPRESSION
, sOUTempContent
);
3448 SvXMLElementExport
aElemNE(*this, XML_NAMESPACE_TABLE
, XML_NAMED_EXPRESSION
, sal_True
, sal_True
);
3459 void ScXMLExport::WriteExternalRefCaches()
3464 ScExternalRefManager
* pRefMgr
= pDoc
->GetExternalRefManager();
3465 pRefMgr
->resetSrcFileData(GetOrigFileName());
3466 sal_uInt16 nCount
= pRefMgr
->getExternalFileCount();
3467 for (sal_uInt16 nFileId
= 0; nFileId
< nCount
; ++nFileId
)
3469 const String
* pUrl
= pRefMgr
->getExternalFileName(nFileId
);
3473 vector
<String
> aTabNames
;
3474 pRefMgr
->getAllCachedTableNames(nFileId
, aTabNames
);
3475 if (aTabNames
.empty())
3478 for (vector
<String
>::const_iterator itr
= aTabNames
.begin(), itrEnd
= aTabNames
.end();
3479 itr
!= itrEnd
; ++itr
)
3481 ScExternalRefCache::TableTypeRef pTable
= pRefMgr
->getCacheTable(nFileId
, *itr
, false);
3482 if (!pTable
.get() || !pTable
->isReferenced())
3485 OUStringBuffer aBuf
;
3486 aBuf
.append(sal_Unicode('\''));
3488 aBuf
.append(sal_Unicode('\''));
3489 aBuf
.append(sal_Unicode('#'));
3491 AddAttribute(XML_NAMESPACE_TABLE
, XML_NAME
, aBuf
.makeStringAndClear());
3492 AddAttribute(XML_NAMESPACE_TABLE
, XML_PRINT
, GetXMLToken(XML_FALSE
));
3493 AddAttribute(XML_NAMESPACE_TABLE
, XML_STYLE_NAME
, sExternalRefTabStyleName
);
3494 SvXMLElementExport
aElemTable(*this, XML_NAMESPACE_TABLE
, XML_TABLE
, sal_True
, sal_True
);
3496 const ScExternalRefManager::SrcFileData
* pExtFileData
= pRefMgr
->getExternalFileData(nFileId
);
3500 if (pExtFileData
->maRelativeName
.Len())
3501 aRelUrl
= pExtFileData
->maRelativeName
;
3503 aRelUrl
= GetRelativeReference(pExtFileData
->maRelativeName
);
3504 AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
, aRelUrl
);
3505 AddAttribute(XML_NAMESPACE_TABLE
, XML_TABLE_NAME
, *itr
);
3506 if (pExtFileData
->maFilterName
.Len())
3507 AddAttribute(XML_NAMESPACE_TABLE
, XML_FILTER_NAME
, pExtFileData
->maFilterName
);
3508 if (pExtFileData
->maFilterOptions
.Len())
3509 AddAttribute(XML_NAMESPACE_TABLE
, XML_FILTER_OPTIONS
, pExtFileData
->maFilterOptions
);
3510 AddAttribute(XML_NAMESPACE_TABLE
, XML_MODE
, XML_COPY_RESULTS_ONLY
);
3512 SvXMLElementExport
aElemTableSource(*this, XML_NAMESPACE_TABLE
, XML_TABLE_SOURCE
, sal_True
, sal_True
);
3515 // Determine maximum column count of used area, for repeated cells.
3516 SCCOL nMaxColsUsed
= 1; // assume that there is at least one cell somewhere..
3517 vector
<SCROW
> aRows
;
3518 pTable
->getAllRows(aRows
);
3519 for (vector
<SCROW
>::const_iterator itrRow
= aRows
.begin(), itrRowEnd
= aRows
.end();
3520 itrRow
!= itrRowEnd
; ++itrRow
)
3522 SCROW nRow
= *itrRow
;
3523 vector
<SCCOL
> aCols
;
3524 pTable
->getAllCols(nRow
, aCols
);
3527 SCCOL nCol
= aCols
.back();
3528 if (nMaxColsUsed
<= nCol
)
3529 nMaxColsUsed
= nCol
+ 1;
3533 // Write cache content for this table.
3535 bool bFirstRow
= true;
3536 for (vector
<SCROW
>::const_iterator itrRow
= aRows
.begin(), itrRowEnd
= aRows
.end();
3537 itrRow
!= itrRowEnd
; ++itrRow
)
3539 SCROW nRow
= *itrRow
;
3546 OUStringBuffer aVal
;
3548 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_ROWS_REPEATED
, aVal
.makeStringAndClear());
3550 SvXMLElementExport
aElemRow(*this, XML_NAMESPACE_TABLE
, XML_TABLE_ROW
, sal_True
, sal_True
);
3551 OUStringBuffer aVal
;
3552 aVal
.append(static_cast<sal_Int32
>(nMaxColsUsed
));
3553 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_COLUMNS_REPEATED
, aVal
.makeStringAndClear());
3554 SvXMLElementExport
aElemCell(*this, XML_NAMESPACE_TABLE
, XML_TABLE_CELL
, sal_True
, sal_True
);
3559 SCROW nRowGap
= nRow
- nLastRow
;
3564 OUStringBuffer aVal
;
3565 aVal
.append(static_cast<sal_Int32
>(nRowGap
-1));
3566 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_ROWS_REPEATED
, aVal
.makeStringAndClear());
3568 SvXMLElementExport
aElemRow(*this, XML_NAMESPACE_TABLE
, XML_TABLE_ROW
, sal_True
, sal_True
);
3569 OUStringBuffer aVal
;
3570 aVal
.append(static_cast<sal_Int32
>(nMaxColsUsed
));
3571 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_COLUMNS_REPEATED
, aVal
.makeStringAndClear());
3572 SvXMLElementExport
aElemCell(*this, XML_NAMESPACE_TABLE
, XML_TABLE_CELL
, sal_True
, sal_True
);
3575 SvXMLElementExport
aElemRow(*this, XML_NAMESPACE_TABLE
, XML_TABLE_ROW
, sal_True
, sal_True
);
3577 vector
<SCCOL
> aCols
;
3578 pTable
->getAllCols(nRow
, aCols
);
3580 bool bFirstCol
= true;
3581 for (vector
<SCCOL
>::const_iterator itrCol
= aCols
.begin(), itrColEnd
= aCols
.end();
3582 itrCol
!= itrColEnd
; ++itrCol
)
3584 SCCOL nCol
= *itrCol
;
3591 OUStringBuffer aVal
;
3592 aVal
.append(static_cast<sal_Int32
>(nCol
));
3593 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_COLUMNS_REPEATED
, aVal
.makeStringAndClear());
3595 SvXMLElementExport
aElemCell(*this, XML_NAMESPACE_TABLE
, XML_TABLE_CELL
, sal_True
, sal_True
);
3600 SCCOL nColGap
= nCol
- nLastCol
;
3605 OUStringBuffer aVal
;
3606 aVal
.append(static_cast<sal_Int32
>(nColGap
-1));
3607 AddAttribute(XML_NAMESPACE_TABLE
, XML_NUMBER_COLUMNS_REPEATED
, aVal
.makeStringAndClear());
3609 SvXMLElementExport
aElemCell(*this, XML_NAMESPACE_TABLE
, XML_TABLE_CELL
, sal_True
, sal_True
);
3613 // Write out this cell.
3614 sal_uInt32 nNumFmt
= 0;
3615 ScExternalRefCache::TokenRef pToken
= pTable
->getCell(nCol
, nRow
, &nNumFmt
);
3619 sal_Int32 nIndex
= GetNumberFormatStyleIndex(nNumFmt
);
3622 const OUString aStyleName
= *pCellStyles
->GetStyleNameByIndex(nIndex
, true);
3623 AddAttribute(XML_NAMESPACE_TABLE
, XML_STYLE_NAME
, aStyleName
);
3626 switch(pToken
->GetType())
3630 AddAttribute(XML_NAMESPACE_OFFICE
, XML_VALUE_TYPE
, XML_FLOAT
);
3631 OUStringBuffer aVal
;
3632 aVal
.append(pToken
->GetDouble());
3633 aStrVal
= aVal
.makeStringAndClear();
3634 AddAttribute(XML_NAMESPACE_OFFICE
, XML_VALUE
, aStrVal
);
3639 AddAttribute(XML_NAMESPACE_OFFICE
, XML_VALUE_TYPE
, XML_STRING
);
3640 aStrVal
= pToken
->GetString();
3647 SvXMLElementExport
aElemCell(*this, XML_NAMESPACE_TABLE
, XML_TABLE_CELL
, sal_True
, sal_True
);
3648 SvXMLElementExport
aElemText(*this, XML_NAMESPACE_TEXT
, XML_P
, sal_True
, sal_False
);
3649 Characters(aStrVal
);
3661 // core implementation
3662 void ScXMLExport::WriteConsolidation()
3666 const ScConsolidateParam
* pCons(pDoc
->GetConsolidateDlgData());
3671 ScXMLConverter::GetStringFromFunction( sStrData
, pCons
->eFunction
);
3672 AddAttribute( XML_NAMESPACE_TABLE
, XML_FUNCTION
, sStrData
);
3674 sStrData
= OUString();
3675 for( sal_Int32 nIndex
= 0; nIndex
< pCons
->nDataAreaCount
; ++nIndex
)
3676 ScRangeStringConverter::GetStringFromArea( sStrData
, *pCons
->ppDataAreas
[ nIndex
], pDoc
, FormulaGrammar::CONV_OOO
, sal_True
);
3677 AddAttribute( XML_NAMESPACE_TABLE
, XML_SOURCE_CELL_RANGE_ADDRESSES
, sStrData
);
3679 ScRangeStringConverter::GetStringFromAddress( sStrData
, ScAddress( pCons
->nCol
, pCons
->nRow
, pCons
->nTab
), pDoc
, FormulaGrammar::CONV_OOO
);
3680 AddAttribute( XML_NAMESPACE_TABLE
, XML_TARGET_CELL_ADDRESS
, sStrData
);
3682 if( pCons
->bByCol
&& !pCons
->bByRow
)
3683 AddAttribute( XML_NAMESPACE_TABLE
, XML_USE_LABEL
, XML_COLUMN
);
3684 else if( !pCons
->bByCol
&& pCons
->bByRow
)
3685 AddAttribute( XML_NAMESPACE_TABLE
, XML_USE_LABEL
, XML_ROW
);
3686 else if( pCons
->bByCol
&& pCons
->bByRow
)
3687 AddAttribute( XML_NAMESPACE_TABLE
, XML_USE_LABEL
, XML_BOTH
);
3689 if( pCons
->bReferenceData
)
3690 AddAttribute( XML_NAMESPACE_TABLE
, XML_LINK_TO_SOURCE_DATA
, XML_TRUE
);
3692 SvXMLElementExport
aElem( *this, XML_NAMESPACE_TABLE
, XML_CONSOLIDATION
, sal_True
, sal_True
);
3697 SvXMLAutoStylePoolP
* ScXMLExport::CreateAutoStylePool()
3699 return new ScXMLAutoStylePoolP(*this);
3702 XMLPageExport
* ScXMLExport::CreatePageExport()
3704 return new XMLTableMasterPageExport( *this );
3707 void ScXMLExport::GetChangeTrackViewSettings(uno::Sequence
<beans::PropertyValue
>& rProps
)
3709 ScChangeViewSettings
* pViewSettings(GetDocument() ? GetDocument()->GetChangeViewSettings() : NULL
);
3712 sal_Int32
nChangePos(rProps
.getLength());
3713 rProps
.realloc(nChangePos
+ 1);
3714 beans::PropertyValue
* pProps(rProps
.getArray());
3717 uno::Sequence
<beans::PropertyValue
> aChangeProps(SC_VIEWCHANGES_COUNT
);
3718 beans::PropertyValue
* pChangeProps(aChangeProps
.getArray());
3721 pChangeProps
[SC_SHOW_CHANGES
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChanges"));
3722 pChangeProps
[SC_SHOW_CHANGES
].Value
<<= pViewSettings
->ShowChanges();
3723 pChangeProps
[SC_SHOW_ACCEPTED_CHANGES
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowAcceptedChanges"));
3724 pChangeProps
[SC_SHOW_ACCEPTED_CHANGES
].Value
<<= pViewSettings
->IsShowAccepted();
3725 pChangeProps
[SC_SHOW_REJECTED_CHANGES
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowRejectedChanges"));
3726 pChangeProps
[SC_SHOW_REJECTED_CHANGES
].Value
<<= pViewSettings
->IsShowRejected();
3727 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetime"));
3728 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME
].Value
<<= pViewSettings
->HasDate();
3729 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME_MODE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeMode"));
3730 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME_MODE
].Value
<<= static_cast<sal_Int16
>(pViewSettings
->GetTheDateMode());
3731 util::DateTime aDateTime
;
3732 ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings
->GetTheFirstDateTime(), aDateTime
);
3733 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeFirstDatetime"));
3734 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME
].Value
<<= aDateTime
;
3735 ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings
->GetTheLastDateTime(), aDateTime
);
3736 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByDatetimeSecondDatetime"));
3737 pChangeProps
[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME
].Value
<<= aDateTime
;
3738 pChangeProps
[SC_SHOW_CHANGES_BY_AUTHOR
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByAuthor"));
3739 pChangeProps
[SC_SHOW_CHANGES_BY_AUTHOR
].Value
<<= pViewSettings
->HasAuthor();
3740 pChangeProps
[SC_SHOW_CHANGES_BY_AUTHOR_NAME
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByAuthorName"));
3741 pChangeProps
[SC_SHOW_CHANGES_BY_AUTHOR_NAME
].Value
<<= rtl::OUString (pViewSettings
->GetTheAuthorToShow());
3742 pChangeProps
[SC_SHOW_CHANGES_BY_COMMENT
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByComment"));
3743 pChangeProps
[SC_SHOW_CHANGES_BY_COMMENT
].Value
<<= pViewSettings
->HasComment();
3744 pChangeProps
[SC_SHOW_CHANGES_BY_COMMENT_TEXT
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByCommentText"));
3745 pChangeProps
[SC_SHOW_CHANGES_BY_COMMENT_TEXT
].Value
<<= rtl::OUString (pViewSettings
->GetTheComment());
3746 pChangeProps
[SC_SHOW_CHANGES_BY_RANGES
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByRanges"));
3747 pChangeProps
[SC_SHOW_CHANGES_BY_RANGES
].Value
<<= pViewSettings
->HasRange();
3748 rtl::OUString sRangeList
;
3749 ScRangeStringConverter::GetStringFromRangeList(sRangeList
, &(pViewSettings
->GetTheRangeList()), GetDocument(), FormulaGrammar::CONV_OOO
);
3750 pChangeProps
[SC_SHOW_CHANGES_BY_RANGES_LIST
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowChangesByRangesList"));
3751 pChangeProps
[SC_SHOW_CHANGES_BY_RANGES_LIST
].Value
<<= sRangeList
;
3753 pProps
[nChangePos
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TrackedChangesViewSettings"));
3754 pProps
[nChangePos
].Value
<<= aChangeProps
;
3760 void ScXMLExport::GetViewSettings(uno::Sequence
<beans::PropertyValue
>& rProps
)
3763 beans::PropertyValue
* pProps(rProps
.getArray());
3766 if (GetModel().is())
3768 ScModelObj
* pDocObj(ScModelObj::getImplementation( GetModel() ));
3771 SfxObjectShell
* pEmbeddedObj
= pDocObj
->GetEmbeddedObject();
3774 Rectangle
aRect(pEmbeddedObj
->GetVisArea());
3776 pProps
[i
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaTop"));
3777 pProps
[i
].Value
<<= static_cast<sal_Int32
>(aRect
.getY());
3778 pProps
[++i
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaLeft"));
3779 pProps
[i
].Value
<<= static_cast<sal_Int32
>(aRect
.getX());
3780 pProps
[++i
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaWidth"));
3781 pProps
[i
].Value
<<= static_cast<sal_Int32
>(aRect
.getWidth());
3782 pProps
[++i
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleAreaHeight"));
3783 pProps
[i
].Value
<<= static_cast<sal_Int32
>(aRect
.getHeight());
3788 GetChangeTrackViewSettings(rProps
);
3791 void ScXMLExport::GetConfigurationSettings(uno::Sequence
<beans::PropertyValue
>& rProps
)
3793 if (GetModel().is())
3795 uno::Reference
<lang::XMultiServiceFactory
> xMultiServiceFactory(GetModel(), uno::UNO_QUERY
);
3796 if (xMultiServiceFactory
.is())
3798 uno::Reference
<beans::XPropertySet
> xProperties(xMultiServiceFactory
->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.SpreadsheetSettings"))), uno::UNO_QUERY
);
3799 if (xProperties
.is())
3800 SvXMLUnitConverter::convertPropertySet(rProps
, xProperties
);
3801 if (GetDocument() && GetDocument()->GetChangeTrack() && GetDocument()->GetChangeTrack()->IsProtected())
3803 rtl::OUStringBuffer aBuffer
;
3804 SvXMLUnitConverter::encodeBase64(aBuffer
, GetDocument()->GetChangeTrack()->GetProtection());
3805 if (aBuffer
.getLength())
3807 sal_Int32
nCount(rProps
.getLength());
3808 rProps
.realloc(nCount
+ 1);
3809 rProps
[nCount
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TrackedChangesProtectionKey"));
3810 rProps
[nCount
].Value
<<= aBuffer
.makeStringAndClear();
3817 XMLShapeExport
* ScXMLExport::CreateShapeExport()
3819 return new ScXMLShapeExport(*this);
3822 void ScXMLExport::CreateSharedData(const sal_Int32 nTableCount
)
3824 pSharedData
= new ScMySharedData(nTableCount
);
3827 XMLNumberFormatAttributesExportHelper
* ScXMLExport::GetNumberFormatAttributesExportHelper()
3829 if (!pNumberFormatAttributesExportHelper
)
3830 pNumberFormatAttributesExportHelper
= new XMLNumberFormatAttributesExportHelper(GetNumberFormatsSupplier(), *this );
3831 return pNumberFormatAttributesExportHelper
;
3834 void ScXMLExport::CollectUserDefinedNamespaces(const SfxItemPool
* pPool
, sal_uInt16 nAttrib
)
3836 const SfxPoolItem
* pItem
;
3837 sal_uInt16
nItems(pPool
->GetItemCount( nAttrib
));
3838 for( sal_uInt16 i
= 0; i
< nItems
; ++i
)
3840 if( 0 != (pItem
= pPool
->GetItem( nAttrib
, i
) ) )
3842 const SvXMLAttrContainerItem
*pUnknown((const SvXMLAttrContainerItem
*)pItem
);
3843 if( (pUnknown
->GetAttrCount() > 0) )
3845 sal_uInt16
nIdx(pUnknown
->GetFirstNamespaceIndex());
3846 while( USHRT_MAX
!= nIdx
)
3848 if( (XML_NAMESPACE_UNKNOWN_FLAG
& nIdx
) != 0 )
3850 const OUString
& rPrefix
= pUnknown
->GetPrefix( nIdx
);
3851 // Add namespace declaration for unknown attributes if
3852 // there aren't existing ones for the prefix used by the
3854 _GetNamespaceMap().Add( rPrefix
,
3855 pUnknown
->GetNamespace( nIdx
),
3856 XML_NAMESPACE_UNKNOWN
);
3858 nIdx
= pUnknown
->GetNextNamespaceIndex( nIdx
);
3864 // #i66550# needed for 'presentation:event-listener' element for URLs in shapes
3865 _GetNamespaceMap().Add(
3866 GetXMLToken( XML_NP_PRESENTATION
),
3867 GetXMLToken( XML_N_PRESENTATION
),
3868 XML_NAMESPACE_PRESENTATION
);
3871 void ScXMLExport::IncrementProgressBar(sal_Bool bEditCell
, sal_Int32 nInc
)
3873 nProgressCount
+= nInc
;
3874 if (bEditCell
|| nProgressCount
> 100)
3876 GetProgressBarHelper()->Increment(nProgressCount
);
3881 sal_uInt32
ScXMLExport::exportDoc( enum XMLTokenEnum eClass
)
3883 if( (getExportFlags() & (EXPORT_FONTDECLS
|EXPORT_STYLES
|
3884 EXPORT_MASTERSTYLES
|EXPORT_CONTENT
)) != 0 )
3888 CollectUserDefinedNamespaces(GetDocument()->GetPool(), ATTR_USERDEF
);
3889 CollectUserDefinedNamespaces(GetDocument()->GetEditPool(), EE_PARA_XMLATTRIBS
);
3890 CollectUserDefinedNamespaces(GetDocument()->GetEditPool(), EE_CHAR_XMLATTRIBS
);
3891 ScDrawLayer
* pDrawLayer
= GetDocument()->GetDrawLayer();
3894 CollectUserDefinedNamespaces(&pDrawLayer
->GetItemPool(), EE_PARA_XMLATTRIBS
);
3895 CollectUserDefinedNamespaces(&pDrawLayer
->GetItemPool(), EE_CHAR_XMLATTRIBS
);
3896 CollectUserDefinedNamespaces(&pDrawLayer
->GetItemPool(), SDRATTR_XMLATTRIBUTES
);
3900 return SvXMLExport::exportDoc( eClass
);
3904 void SAL_CALL
ScXMLExport::setSourceDocument( const uno::Reference
<lang::XComponent
>& xComponent
)
3905 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
3908 SvXMLExport::setSourceDocument( xComponent
);
3910 pDoc
= ScXMLConverter::GetScDocument( GetModel() );
3911 DBG_ASSERT( pDoc
, "ScXMLExport::setSourceDocument - no ScDocument!" );
3913 throw lang::IllegalArgumentException();
3915 // create ScChangeTrackingExportHelper after document is known
3916 pChangeTrackingExportHelper
= new ScChangeTrackingExportHelper(*this);
3918 // Set the document's storage grammar corresponding to the ODF version that
3919 // is to be written.
3920 SvtSaveOptions::ODFDefaultVersion meODFDefaultVersion
= getDefaultVersion();
3921 switch (meODFDefaultVersion
)
3923 // ODF 1.0 and 1.1 use GRAM_PODF, everything later or unspecified GRAM_ODFF
3924 case SvtSaveOptions::ODFVER_010
:
3925 case SvtSaveOptions::ODFVER_011
:
3926 pDoc
->SetStorageGrammar( formula::FormulaGrammar::GRAM_PODF
);
3929 pDoc
->SetStorageGrammar( formula::FormulaGrammar::GRAM_ODFF
);
3934 sal_Bool SAL_CALL
ScXMLExport::filter( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aDescriptor
)
3935 throw(::com::sun::star::uno::RuntimeException
)
3939 pDoc
->DisableIdle(TRUE
);
3940 sal_Bool
bReturn(SvXMLExport::filter(aDescriptor
));
3942 pDoc
->DisableIdle(FALSE
);
3946 void SAL_CALL
ScXMLExport::cancel()
3947 throw(::com::sun::star::uno::RuntimeException
)
3951 pDoc
->DisableIdle(FALSE
);
3952 SvXMLExport::cancel();
3956 void SAL_CALL
ScXMLExport::initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
3957 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
3960 SvXMLExport::initialize(aArguments
);
3964 ::rtl::OUString SAL_CALL
ScXMLExport::getImplementationName( )
3965 throw(::com::sun::star::uno::RuntimeException
)
3969 sal_uInt16 nFlags
= getExportFlags();
3970 if (nFlags
& EXPORT_OASIS
)
3972 nFlags
|= EXPORT_OASIS
;
3976 return ScXMLOasisExport_getImplementationName();
3977 case (EXPORT_STYLES
|EXPORT_MASTERSTYLES
|EXPORT_AUTOSTYLES
|EXPORT_FONTDECLS
):
3978 return ScXMLOasisExport_Styles_getImplementationName();
3979 case (EXPORT_AUTOSTYLES
|EXPORT_CONTENT
|EXPORT_SCRIPTS
|EXPORT_FONTDECLS
):
3980 return ScXMLOasisExport_Content_getImplementationName();
3982 return ScXMLOasisExport_Meta_getImplementationName();
3983 case EXPORT_SETTINGS
:
3984 return ScXMLOasisExport_Settings_getImplementationName();
3986 // generic name for 'unknown' cases
3987 return ScXMLOasisExport_getImplementationName();
3995 return ScXMLOOoExport_getImplementationName();
3996 case (EXPORT_STYLES
|EXPORT_MASTERSTYLES
|EXPORT_AUTOSTYLES
|EXPORT_FONTDECLS
):
3997 return ScXMLOOoExport_Styles_getImplementationName();
3998 case (EXPORT_AUTOSTYLES
|EXPORT_CONTENT
|EXPORT_SCRIPTS
|EXPORT_FONTDECLS
):
3999 return ScXMLOOoExport_Content_getImplementationName();
4001 return ScXMLOOoExport_Meta_getImplementationName();
4002 case EXPORT_SETTINGS
:
4003 return ScXMLOOoExport_Settings_getImplementationName();
4005 // generic name for 'unknown' cases
4006 return ScXMLOOoExport_getImplementationName();
4009 return SvXMLExport::getImplementationName();
4012 sal_Bool SAL_CALL
ScXMLExport::supportsService( const ::rtl::OUString
& ServiceName
)
4013 throw(::com::sun::star::uno::RuntimeException
)
4016 return SvXMLExport::supportsService( ServiceName
);
4019 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
ScXMLExport::getSupportedServiceNames( )
4020 throw(::com::sun::star::uno::RuntimeException
)
4023 return SvXMLExport::getSupportedServiceNames();
4027 sal_Int64 SAL_CALL
ScXMLExport::getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
)
4028 throw(::com::sun::star::uno::RuntimeException
)
4031 return SvXMLExport::getSomething(aIdentifier
);
4034 void ScXMLExport::DisposingModel()
4036 SvXMLExport::DisposingModel();