Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "xmlExport.hxx"
30 : : #include "xmlAutoStyle.hxx"
31 : : #include <xmloff/ProgressBarHelper.hxx>
32 : : #include <comphelper/sequence.hxx>
33 : : #include <xmloff/xmltoken.hxx>
34 : : #include <xmloff/txtimp.hxx>
35 : : #include <xmloff/xmlnmspe.hxx>
36 : : #include <xmloff/xmluconv.hxx>
37 : : #include <xmloff/nmspmap.hxx>
38 : : #include <comphelper/types.hxx>
39 : : #include "xmlEnums.hxx"
40 : : #include <xmloff/nmspmap.hxx>
41 : : #include <xmloff/xmluconv.hxx>
42 : : #include <xmloff/txtprmap.hxx>
43 : : #include <xmloff/numehelp.hxx>
44 : : #include "xmlHelper.hxx"
45 : : #include "xmlstrings.hrc"
46 : : #include "xmlPropertyHandler.hxx"
47 : : #include <sax/tools/converter.hxx>
48 : : #include <com/sun/star/awt/ImagePosition.hpp>
49 : : #include <com/sun/star/util/NumberFormat.hpp>
50 : : #include <com/sun/star/util/MeasureUnit.hpp>
51 : : #include <com/sun/star/style/ParagraphAdjust.hpp>
52 : : #include <com/sun/star/awt/TextAlign.hpp>
53 : : #include <com/sun/star/report/GroupOn.hpp>
54 : : #include <com/sun/star/report/XFixedText.hpp>
55 : : #include <com/sun/star/report/XImageControl.hpp>
56 : : #include <com/sun/star/report/XShape.hpp>
57 : : #include <com/sun/star/drawing/XShape.hpp>
58 : : #include <com/sun/star/drawing/XShapes.hpp>
59 : : #include <com/sun/star/report/XFunction.hpp>
60 : : #include <com/sun/star/awt/FontDescriptor.hpp>
61 : : #include <com/sun/star/text/TextContentAnchorType.hpp>
62 : : #include <com/sun/star/table/BorderLine.hpp>
63 : : #include <com/sun/star/report/XFixedLine.hpp>
64 : : #include <com/sun/star/frame/XController.hpp>
65 : : #include "RptDef.hxx"
66 : : // for locking SolarMutex: svapp + mutex
67 : : #include <vcl/svapp.hxx>
68 : : #include <osl/mutex.hxx>
69 : : #include <sal/macros.h>
70 : :
71 : : #include <boost/bind.hpp>
72 : :
73 : : //--------------------------------------------------------------------------
74 : : namespace rptxml
75 : : {
76 : : using namespace xmloff;
77 : : using namespace comphelper;
78 : : using namespace ::com::sun::star;
79 : : using namespace ::com::sun::star::report;
80 : : using namespace ::com::sun::star::uno;
81 : : using namespace ::com::sun::star::util;
82 : : using namespace ::com::sun::star::xml;
83 : :
84 : : //---------------------------------------------------------------------
85 : 0 : Reference< XInterface > ORptExportHelper::create(Reference< XComponentContext > const & xContext)
86 : : {
87 [ # # ][ # # ]: 0 : return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_SETTINGS ));
[ # # ][ # # ]
88 : : }
89 : : //---------------------------------------------------------------------
90 : 6 : ::rtl::OUString ORptExportHelper::getImplementationName_Static( ) throw (RuntimeException)
91 : : {
92 : 6 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.XMLSettingsExporter"));
93 : : }
94 : : //---------------------------------------------------------------------
95 : 0 : Sequence< ::rtl::OUString > ORptExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
96 : : {
97 : 0 : Sequence< ::rtl::OUString > aSupported(1);
98 [ # # ][ # # ]: 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
99 : 0 : return aSupported;
100 : : }
101 : : //---------------------------------------------------------------------
102 : 0 : Reference< XInterface > ORptContentExportHelper::create(Reference< XComponentContext > const & xContext)
103 : : {
104 [ # # ][ # # ]: 0 : return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_CONTENT ));
[ # # ][ # # ]
105 : : }
106 : : //---------------------------------------------------------------------
107 : 6 : ::rtl::OUString ORptContentExportHelper::getImplementationName_Static( ) throw (RuntimeException)
108 : : {
109 : 6 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.XMLContentExporter"));
110 : : }
111 : : //---------------------------------------------------------------------
112 : 0 : Sequence< ::rtl::OUString > ORptContentExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
113 : : {
114 : 0 : Sequence< ::rtl::OUString > aSupported(1);
115 [ # # ][ # # ]: 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
116 : 0 : return aSupported;
117 : : }
118 : :
119 : : //---------------------------------------------------------------------
120 : 0 : Reference< XInterface > ORptStylesExportHelper::create(Reference< XComponentContext > const & xContext)
121 : : {
122 : 0 : return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES |
123 [ # # ][ # # ]: 0 : EXPORT_FONTDECLS|EXPORT_OASIS ));
[ # # ][ # # ]
124 : : }
125 : : //---------------------------------------------------------------------
126 : 6 : ::rtl::OUString ORptStylesExportHelper::getImplementationName_Static( ) throw (RuntimeException)
127 : : {
128 : 6 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.XMLStylesExporter"));
129 : : }
130 : : //---------------------------------------------------------------------
131 : 0 : Sequence< ::rtl::OUString > ORptStylesExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
132 : : {
133 : 0 : Sequence< ::rtl::OUString > aSupported(1);
134 [ # # ][ # # ]: 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
135 : 0 : return aSupported;
136 : : }
137 : :
138 : : //---------------------------------------------------------------------
139 : 0 : Reference< XInterface > ORptMetaExportHelper::create(Reference< XComponentContext > const & xContext)
140 : : {
141 [ # # ][ # # ]: 0 : return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_META ));
[ # # ][ # # ]
142 : : }
143 : : //---------------------------------------------------------------------
144 : 6 : ::rtl::OUString ORptMetaExportHelper::getImplementationName_Static( ) throw (RuntimeException)
145 : : {
146 : 6 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.XMLMetaExporter"));
147 : : }
148 : : //---------------------------------------------------------------------
149 : 0 : Sequence< ::rtl::OUString > ORptMetaExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
150 : : {
151 : 0 : Sequence< ::rtl::OUString > aSupported(1);
152 [ # # ][ # # ]: 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
153 : 0 : return aSupported;
154 : : }
155 : :
156 : : //---------------------------------------------------------------------
157 : 0 : Reference< XInterface > ODBFullExportHelper::create(Reference< XComponentContext > const & xContext)
158 : : {
159 [ # # ][ # # ]: 0 : return static_cast< XServiceInfo* >(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY),EXPORT_ALL));
[ # # ][ # # ]
160 : : }
161 : : //---------------------------------------------------------------------
162 : 6 : ::rtl::OUString ODBFullExportHelper::getImplementationName_Static( ) throw (RuntimeException)
163 : : {
164 : 6 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.XMLFullExporter"));
165 : : }
166 : : //---------------------------------------------------------------------
167 : 0 : Sequence< ::rtl::OUString > ODBFullExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
168 : : {
169 : 0 : Sequence< ::rtl::OUString > aSupported(1);
170 [ # # ][ # # ]: 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
171 : 0 : return aSupported;
172 : : }
173 : :
174 : : //---------------------------------------------------------------------
175 : :
176 [ # # ]: 0 : class OSpecialHanldeXMLExportPropertyMapper : public SvXMLExportPropertyMapper
177 : : {
178 : : public:
179 : 0 : OSpecialHanldeXMLExportPropertyMapper(const UniReference< XMLPropertySetMapper >& rMapper) : SvXMLExportPropertyMapper(rMapper )
180 : : {
181 : 0 : }
182 : : /** this method is called for every item that has the
183 : : MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
184 : 0 : virtual void handleSpecialItem(
185 : : SvXMLAttributeList& /*rAttrList*/,
186 : : const XMLPropertyState& /*rProperty*/,
187 : : const SvXMLUnitConverter& /*rUnitConverter*/,
188 : : const SvXMLNamespaceMap& /*rNamespaceMap*/,
189 : : const ::std::vector< XMLPropertyState >* /*pProperties*/ = 0,
190 : : sal_uInt32 /*nIdx*/ = 0 ) const
191 : : {
192 : : // nothing to do here
193 : 0 : }
194 : : };
195 : : // -----------------------------------------------------------------------------
196 : 0 : void lcl_adjustColumnSpanOverRows(ORptExport::TSectionsGrid& _rGrid)
197 : : {
198 : 0 : ORptExport::TSectionsGrid::iterator aSectionIter = _rGrid.begin();
199 : 0 : ORptExport::TSectionsGrid::iterator aSectionEnd = _rGrid.end();
200 [ # # ]: 0 : for (;aSectionIter != aSectionEnd ; ++aSectionIter)
201 : : {
202 : 0 : ORptExport::TGrid::iterator aRowIter = aSectionIter->second.begin();
203 : 0 : ORptExport::TGrid::iterator aRowEnd = aSectionIter->second.end();
204 [ # # ][ # # ]: 0 : for (; aRowIter != aRowEnd; ++aRowIter)
205 : : {
206 [ # # ]: 0 : if ( aRowIter->first )
207 : : {
208 : 0 : ::std::vector< ORptExport::TCell >::iterator aColIter = aRowIter->second.begin();
209 : 0 : ::std::vector< ORptExport::TCell >::iterator aColEnd = aRowIter->second.end();
210 [ # # ][ # # ]: 0 : for (; aColIter != aColEnd; ++aColIter)
211 : : {
212 [ # # ]: 0 : if ( aColIter->nRowSpan > 1 )
213 : : {
214 : 0 : sal_Int32 nColSpan = aColIter->nColSpan;
215 [ # # ]: 0 : sal_Int32 nColIndex = aColIter - aRowIter->second.begin();
216 [ # # ]: 0 : for (sal_Int32 i = 1; i < aColIter->nRowSpan; ++i)
217 : : {
218 [ # # ]: 0 : (aRowIter+i)->second[nColIndex].nColSpan = nColSpan;
219 : : }
220 : : }
221 : : }
222 : : }
223 : : }
224 : : }
225 : 0 : }
226 : : // -----------------------------------------------------------------------------
227 : 0 : ORptExport::ORptExport(const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nExportFlag)
228 : : : SvXMLExport( util::MeasureUnit::MM_100TH, _rxMSF, XML_REPORT, EXPORT_OASIS)
229 [ # # ][ # # ]: 0 : ,m_bAllreadyFilled(sal_False)
[ # # ][ # # ]
[ # # ][ # # ]
230 : : {
231 : 0 : setExportFlags( EXPORT_OASIS | nExportFlag);
232 [ # # ]: 0 : GetMM100UnitConverter().SetCoreMeasureUnit(MAP_100TH_MM);
233 [ # # ]: 0 : GetMM100UnitConverter().SetXMLMeasureUnit(MAP_CM);
234 : :
235 : : // (getExportFlags() & EXPORT_CONTENT) != 0 ? : XML_N_OOO
236 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE ), XML_NAMESPACE_OFFICE );
[ # # ]
237 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
[ # # ]
238 : :
239 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_RPT), GetXMLToken(XML_N_RPT), XML_NAMESPACE_REPORT );
[ # # ]
240 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG );
[ # # ]
241 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_FORM), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM );
[ # # ]
242 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
[ # # ]
243 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_TEXT), GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT );
[ # # ]
244 : :
245 : :
246 [ # # ]: 0 : if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 )
247 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
[ # # ]
248 : :
249 [ # # ]: 0 : if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 )
250 : : {
251 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
[ # # ]
252 : : }
253 [ # # ]: 0 : if( (getExportFlags() & EXPORT_SETTINGS) != 0 )
254 : : {
255 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
[ # # ]
256 : : }
257 : :
258 [ # # ]: 0 : if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 )
259 : : {
260 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
[ # # ]
261 : : }
262 : : // RDFa: needed for content and header/footer styles
263 [ # # ]: 0 : if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
264 : : {
265 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_XHTML),GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
[ # # ]
266 : : }
267 : : // GRDDL: to convert RDFa and meta.xml to RDF
268 [ # # ]: 0 : if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
269 : : {
270 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_GRDDL),GetXMLToken(XML_N_GRDDL), XML_NAMESPACE_GRDDL );
[ # # ]
271 : : }
272 : :
273 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
[ # # ]
274 [ # # ][ # # ]: 0 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_NUMBER), GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
[ # # ]
275 : :
276 [ # # ][ # # ]: 0 : m_sTableStyle = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_STYLE_NAME) );
277 [ # # ][ # # ]: 0 : m_sColumnStyle = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TABLE, GetXMLToken(XML_COLUMN) );
278 [ # # ][ # # ]: 0 : m_sCellStyle = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_REPORT, GetXMLToken(XML_STYLE_NAME) );
279 : :
280 : :
281 [ # # ][ # # ]: 0 : m_xPropHdlFactory = new OXMLRptPropHdlFactory();
[ # # ]
282 [ # # ][ # # ]: 0 : UniReference < XMLPropertyHandlerFactory> xFac = new ::xmloff::OControlPropertyHandlerFactory();
[ # # ]
283 [ # # ][ # # ]: 0 : UniReference < XMLPropertySetMapper > xTableStylesPropertySetMapper1 = new XMLPropertySetMapper(OXMLHelper::GetTableStyleProps(),xFac);
[ # # ][ # # ]
284 [ # # ][ # # ]: 0 : UniReference < XMLPropertySetMapper > xTableStylesPropertySetMapper2 = new XMLTextPropertySetMapper(TEXT_PROP_MAP_TABLE_DEFAULTS );
[ # # ]
285 [ # # ][ # # ]: 0 : xTableStylesPropertySetMapper1->AddMapperEntry(xTableStylesPropertySetMapper2);
286 : :
287 [ # # ][ # # ]: 0 : m_xTableStylesExportPropertySetMapper = new SvXMLExportPropertyMapper(xTableStylesPropertySetMapper1);
[ # # ]
288 : :
289 [ # # ][ # # ]: 0 : m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylePropertyMap();
[ # # ]
290 [ # # ][ # # ]: 0 : m_xCellStylesExportPropertySetMapper = new OSpecialHanldeXMLExportPropertyMapper(m_xCellStylesPropertySetMapper);
[ # # ]
291 [ # # ][ # # ]: 0 : m_xCellStylesExportPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this));
[ # # ][ # # ]
[ # # ]
292 : :
293 [ # # ][ # # ]: 0 : UniReference < XMLPropertySetMapper > xColumnStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetColumnStyleProps(), m_xPropHdlFactory);
[ # # ][ # # ]
294 [ # # ][ # # ]: 0 : m_xColumnStylesExportPropertySetMapper = new OSpecialHanldeXMLExportPropertyMapper(xColumnStylesPropertySetMapper);
[ # # ]
295 : :
296 [ # # ][ # # ]: 0 : UniReference < XMLPropertySetMapper > xRowStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetRowStyleProps(), m_xPropHdlFactory);
[ # # ][ # # ]
297 [ # # ][ # # ]: 0 : m_xRowStylesExportPropertySetMapper = new OSpecialHanldeXMLExportPropertyMapper(xRowStylesPropertySetMapper);
[ # # ]
298 : :
299 [ # # ][ # # ]: 0 : UniReference < XMLPropertySetMapper > xPropMapper(new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA ));
[ # # ]
300 [ # # ][ # # ]: 0 : m_xParaPropMapper = new OSpecialHanldeXMLExportPropertyMapper( xPropMapper);
[ # # ]
301 : :
302 [ # # ]: 0 : ::rtl::OUString sFamily( GetXMLToken(XML_PARAGRAPH) );
303 : 0 : ::rtl::OUString aPrefix( 'P');
304 : : GetAutoStylePool()->AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily,
305 [ # # ][ # # ]: 0 : m_xParaPropMapper, aPrefix );
[ # # ][ # # ]
306 : :
307 : : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_CELL, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME)),
308 [ # # ][ # # ]: 0 : m_xCellStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX)));
[ # # ][ # # ]
[ # # ][ # # ]
309 : : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_COLUMN, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME)),
310 [ # # ][ # # ]: 0 : m_xColumnStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX)));
[ # # ][ # # ]
[ # # ][ # # ]
311 : : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_ROW, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME)),
312 [ # # ][ # # ]: 0 : m_xRowStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX)));
[ # # ][ # # ]
[ # # ][ # # ]
313 : : GetAutoStylePool()->AddFamily(XML_STYLE_FAMILY_TABLE_TABLE, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME)),
314 [ # # ][ # # ]: 0 : m_xTableStylesExportPropertySetMapper, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX)));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
315 : 0 : }
316 : : // -----------------------------------------------------------------------------
317 : 0 : Reference< XInterface > ORptExport::create(Reference< XComponentContext > const & xContext)
318 : : {
319 [ # # ][ # # ]: 0 : return *(new ORptExport(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY)));
[ # # ]
320 : : }
321 : :
322 : : // -----------------------------------------------------------------------------
323 : 6 : ::rtl::OUString ORptExport::getImplementationName_Static( ) throw(uno::RuntimeException)
324 : : {
325 : 6 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ExportFilter"));
326 : : }
327 : :
328 : : //--------------------------------------------------------------------------
329 : 0 : ::rtl::OUString SAL_CALL ORptExport::getImplementationName( ) throw(uno::RuntimeException)
330 : : {
331 : 0 : return getImplementationName_Static();
332 : : }
333 : : //--------------------------------------------------------------------------
334 : 0 : uno::Sequence< ::rtl::OUString > ORptExport::getSupportedServiceNames_Static( ) throw(uno::RuntimeException)
335 : : {
336 : 0 : uno::Sequence< ::rtl::OUString > aServices(1);
337 [ # # ][ # # ]: 0 : aServices.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
338 : :
339 : 0 : return aServices;
340 : : }
341 : : //--------------------------------------------------------------------------
342 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL ORptExport::getSupportedServiceNames( ) throw(uno::RuntimeException)
343 : : {
344 : 0 : return getSupportedServiceNames_Static();
345 : : }
346 : : //------------------------------------------------------------------------------
347 : 0 : sal_Bool SAL_CALL ORptExport::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException )
348 : : {
349 [ # # ]: 0 : return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
350 : : }
351 : : // -----------------------------------------------------------------------------
352 : 0 : void ORptExport::exportFunctions(const Reference<XIndexAccess>& _xFunctions)
353 : : {
354 : 0 : const sal_Int32 nCount = _xFunctions->getCount();
355 [ # # ]: 0 : for (sal_Int32 i = 0; i< nCount; ++i)
356 : : {
357 [ # # ][ # # ]: 0 : uno::Reference< report::XFunction> xFunction(_xFunctions->getByIndex(i),uno::UNO_QUERY_THROW);
[ # # ]
358 : : OSL_ENSURE(xFunction.is(),"Function object is NULL!");
359 [ # # ]: 0 : exportFunction(xFunction);
360 : 0 : }
361 : 0 : }
362 : : // -----------------------------------------------------------------------------
363 : 0 : void ORptExport::exportFunction(const uno::Reference< XFunction>& _xFunction)
364 : : {
365 [ # # ][ # # ]: 0 : exportFormula(XML_FORMULA,_xFunction->getFormula());
[ # # ]
366 [ # # ][ # # ]: 0 : beans::Optional< ::rtl::OUString> aInitial = _xFunction->getInitialFormula();
367 [ # # ][ # # ]: 0 : if ( aInitial.IsPresent && !aInitial.Value.isEmpty() )
[ # # ]
368 [ # # ]: 0 : exportFormula(XML_INITIAL_FORMULA ,aInitial.Value );
369 [ # # ][ # # ]: 0 : AddAttribute( XML_NAMESPACE_REPORT, XML_NAME , _xFunction->getName() );
[ # # ]
370 [ # # ][ # # ]: 0 : if ( _xFunction->getPreEvaluated() )
[ # # ]
371 [ # # ]: 0 : AddAttribute( XML_NAMESPACE_REPORT, XML_PRE_EVALUATED , XML_TRUE );
372 [ # # ][ # # ]: 0 : if ( _xFunction->getDeepTraversing() )
[ # # ]
373 [ # # ]: 0 : AddAttribute( XML_NAMESPACE_REPORT, XML_DEEP_TRAVERSING , XML_TRUE );
374 : :
375 [ # # ][ # # ]: 0 : SvXMLElementExport aFunction(*this,XML_NAMESPACE_REPORT, XML_FUNCTION, sal_True, sal_True);
376 : 0 : }
377 : : // -----------------------------------------------------------------------------
378 : 0 : void ORptExport::exportMasterDetailFields(const Reference<XReportComponent>& _xReportComponet)
379 : : {
380 [ # # ][ # # ]: 0 : const uno::Sequence< ::rtl::OUString> aMasterFields = _xReportComponet->getMasterFields();
381 [ # # ]: 0 : if ( aMasterFields.getLength() )
382 : : {
383 [ # # ]: 0 : SvXMLElementExport aElement(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS, sal_True, sal_True);
384 [ # # ][ # # ]: 0 : const uno::Sequence< ::rtl::OUString> aDetailFields = _xReportComponet->getDetailFields();
385 : :
386 : : OSL_ENSURE(aDetailFields.getLength() == aMasterFields.getLength(),"not equal length for master and detail fields!");
387 : :
388 : 0 : const ::rtl::OUString* pDetailFieldsIter = aDetailFields.getConstArray();
389 : 0 : const ::rtl::OUString* pIter = aMasterFields.getConstArray();
390 : 0 : const ::rtl::OUString* pEnd = pIter + aMasterFields.getLength();
391 [ # # ]: 0 : for(;pIter != pEnd;++pIter,++pDetailFieldsIter)
392 : : {
393 [ # # ]: 0 : AddAttribute( XML_NAMESPACE_REPORT, XML_MASTER , *pIter );
394 [ # # ]: 0 : if ( !pDetailFieldsIter->isEmpty() )
395 [ # # ]: 0 : AddAttribute( XML_NAMESPACE_REPORT, XML_DETAIL , *pDetailFieldsIter );
396 [ # # ]: 0 : SvXMLElementExport aPair(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELD, sal_True, sal_True);
397 [ # # ][ # # ]: 0 : }
[ # # ]
398 [ # # ]: 0 : }
399 : 0 : }
400 : : // -----------------------------------------------------------------------------
401 : 0 : void ORptExport::exportReport(const Reference<XReportDefinition>& _xReportDefinition)
402 : : {
403 [ # # ]: 0 : if ( _xReportDefinition.is() )
404 : : {
405 [ # # ][ # # ]: 0 : exportFunctions(_xReportDefinition->getFunctions().get());
[ # # ][ # # ]
406 [ # # ]: 0 : exportGroupsExpressionAsFunction(_xReportDefinition->getGroups());
407 : :
408 [ # # ]: 0 : if ( _xReportDefinition->getReportHeaderOn() )
409 : : {
410 [ # # ]: 0 : SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_HEADER, sal_True, sal_True);
411 [ # # ][ # # ]: 0 : exportSection(_xReportDefinition->getReportHeader());
[ # # ][ # # ]
412 : : }
413 [ # # ]: 0 : if ( _xReportDefinition->getPageHeaderOn() )
414 : : {
415 : 0 : ::rtl::OUStringBuffer sValue;
416 [ # # ][ # # ]: 0 : sal_uInt16 nRet = _xReportDefinition->getPageHeaderOption();
417 [ # # ]: 0 : const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions();
418 [ # # ][ # # ]: 0 : if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) )
419 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear());
420 : :
421 [ # # ]: 0 : SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_HEADER, sal_True, sal_True);
422 [ # # ][ # # ]: 0 : exportSection(_xReportDefinition->getPageHeader(),true);
[ # # ][ # # ]
423 : : }
424 : :
425 : 0 : exportGroup(_xReportDefinition,0);
426 : :
427 [ # # ]: 0 : if ( _xReportDefinition->getPageFooterOn() )
428 : : {
429 : 0 : ::rtl::OUStringBuffer sValue;
430 [ # # ][ # # ]: 0 : sal_uInt16 nRet = _xReportDefinition->getPageFooterOption();
431 [ # # ]: 0 : const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions();
432 [ # # ][ # # ]: 0 : if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) )
433 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear());
434 [ # # ]: 0 : SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_FOOTER, sal_True, sal_True);
435 [ # # ][ # # ]: 0 : exportSection(_xReportDefinition->getPageFooter(),true);
[ # # ][ # # ]
436 : : }
437 [ # # ]: 0 : if ( _xReportDefinition->getReportFooterOn() )
438 : : {
439 [ # # ]: 0 : SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_FOOTER, sal_True, sal_True);
440 [ # # ][ # # ]: 0 : exportSection(_xReportDefinition->getReportFooter());
[ # # ][ # # ]
441 : : }
442 : : }
443 : 0 : }
444 : : // -----------------------------------------------------------------------------
445 : 0 : void ORptExport::exportComponent(const Reference<XReportComponent>& _xReportComponent)
446 : : {
447 : : OSL_ENSURE(_xReportComponent.is(),"No component interface!");
448 [ # # ]: 0 : if ( !_xReportComponent.is() )
449 : 0 : return;
450 : :
451 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_DRAW, XML_NAME,_xReportComponent->getName());
[ # # ]
452 : :
453 [ # # ][ # # ]: 0 : SvXMLElementExport aElem(*this,XML_NAMESPACE_REPORT, XML_REPORT_COMPONENT, sal_False, sal_False);
454 : : }
455 : : // -----------------------------------------------------------------------------
456 : 0 : void ORptExport::exportFormatConditions(const Reference<XReportControlModel>& _xReportElement)
457 : : {
458 : : OSL_ENSURE(_xReportElement.is(),"_xReportElement is NULL -> GPF");
459 [ # # ][ # # ]: 0 : ::rtl::OUString sDataField = convertFormula(_xReportElement->getDataField());
460 [ # # ][ # # ]: 0 : const sal_Int32 nCount = _xReportElement->getCount();
461 : : try
462 : : {
463 [ # # ]: 0 : for (sal_Int32 i = 0; i < nCount ; ++i)
464 : : {
465 [ # # ][ # # ]: 0 : uno::Reference< report::XFormatCondition > xCond(_xReportElement->getByIndex(i),uno::UNO_QUERY);
[ # # ]
466 [ # # ][ # # ]: 0 : if ( !xCond->getEnabled() )
[ # # ]
467 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_ENABLED,XML_FALSE);
468 : :
469 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_FORMULA,xCond->getFormula());
[ # # ]
470 : :
471 [ # # ][ # # ]: 0 : exportStyleName(xCond.get(),GetAttrList(),m_sCellStyle);
[ # # ]
472 [ # # ]: 0 : SvXMLElementExport aElem(*this,XML_NAMESPACE_REPORT, XML_FORMAT_CONDITION, sal_True, sal_True);
473 [ # # ][ # # ]: 0 : }
474 : : }
475 [ # # ]: 0 : catch(uno::Exception&)
476 : : {
477 : : OSL_FAIL("Can not access format condition!");
478 : 0 : }
479 : 0 : }
480 : : // -----------------------------------------------------------------------------
481 : 0 : void ORptExport::exportReportElement(const Reference<XReportControlModel>& _xReportElement)
482 : : {
483 : : OSL_ENSURE(_xReportElement.is(),"_xReportElement is NULL -> GPF");
484 [ # # ][ # # ]: 0 : if ( _xReportElement->getPrintWhenGroupChange() )
[ # # ]
485 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_PRINT_ONLY_WHEN_GROUP_CHANGE, XML_TRUE );
486 : :
487 [ # # ][ # # ]: 0 : if ( !_xReportElement->getPrintRepeatedValues() )
[ # # ]
488 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_PRINT_REPEATED_VALUES,XML_FALSE);
489 : :
490 [ # # ]: 0 : SvXMLElementExport aElem(*this,XML_NAMESPACE_REPORT, XML_REPORT_ELEMENT, sal_True, sal_True);
491 [ # # ][ # # ]: 0 : if ( _xReportElement->getCount() )
[ # # ]
492 : : {
493 [ # # ]: 0 : exportFormatConditions(_xReportElement);
494 : : }
495 : :
496 [ # # ][ # # ]: 0 : ::rtl::OUString sExpr = _xReportElement->getConditionalPrintExpression();
497 [ # # ]: 0 : if ( !sExpr.isEmpty() )
498 : : {
499 [ # # ]: 0 : exportFormula(XML_FORMULA,sExpr);
500 [ # # ][ # # ]: 0 : SvXMLElementExport aPrintExpr(*this,XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION, sal_True, sal_True);
501 : : }
502 : :
503 : : // only export when parent exists
504 [ # # ][ # # ]: 0 : uno::Reference< report::XSection> xParent(_xReportElement->getParent(),uno::UNO_QUERY);
[ # # ]
505 [ # # ]: 0 : if ( xParent.is() )
506 [ # # ][ # # ]: 0 : exportComponent(_xReportElement.get());
[ # # ][ # # ]
507 : 0 : }
508 : : // -----------------------------------------------------------------------------
509 : 0 : void lcl_calculate(const ::std::vector<sal_Int32>& _aPosX,const ::std::vector<sal_Int32>& _aPosY,ORptExport::TGrid& _rColumns)
510 : : {
511 : 0 : sal_Int32 nCountX = _aPosX.size() - 1;
512 : 0 : sal_Int32 nCountY = _aPosY.size() - 1;
513 [ # # ]: 0 : for (sal_Int32 j = 0; j < nCountY; ++j)
514 : : {
515 : 0 : sal_Int32 nHeight = _aPosY[j+1] - _aPosY[j];
516 [ # # ]: 0 : if ( nHeight )
517 [ # # ]: 0 : for (sal_Int32 i = 0; i < nCountX ; ++i)
518 : : {
519 [ # # ][ # # ]: 0 : _rColumns[j].second[i] = ORptExport::TCell(_aPosX[i+1] - _aPosX[i],nHeight,1,1);
[ # # ][ # # ]
[ # # ]
520 : 0 : _rColumns[j].second[i].bSet = sal_True;
521 : : }
522 : : }
523 : 0 : }
524 : : // -----------------------------------------------------------------------------
525 : 0 : void ORptExport::collectStyleNames(sal_Int32 _nFamily,const ::std::vector< sal_Int32>& _aSize, ORptExport::TStringVec& _rStyleNames)
526 : : {
527 [ # # ]: 0 : ::std::vector< XMLPropertyState > aPropertyStates;
528 [ # # ]: 0 : aPropertyStates.push_back(XMLPropertyState(0));
529 : 0 : ::std::vector<sal_Int32>::const_iterator aIter = _aSize.begin();
530 [ # # ]: 0 : ::std::vector<sal_Int32>::const_iterator aIter2 = aIter + 1;
531 : 0 : ::std::vector<sal_Int32>::const_iterator aEnd = _aSize.end();
532 [ # # ][ # # ]: 0 : for (;aIter2 != aEnd ; ++aIter,++aIter2)
[ # # ][ # # ]
533 : : {
534 [ # # ][ # # ]: 0 : sal_Int32 nValue = static_cast<sal_Int32>(*aIter2 - *aIter);
535 [ # # ]: 0 : aPropertyStates[0].maValue <<= nValue;
536 [ # # ][ # # ]: 0 : _rStyleNames.push_back(GetAutoStylePool()->Add(_nFamily, aPropertyStates ));
[ # # ][ # # ]
[ # # ]
537 : 0 : }
538 : 0 : }
539 : : // -----------------------------------------------------------------------------
540 : 0 : void ORptExport::exportSectionAutoStyle(const Reference<XSection>& _xProp)
541 : : {
542 : : OSL_ENSURE(_xProp != NULL,"Section is NULL -> GPF");
543 [ # # ]: 0 : exportAutoStyle(_xProp);
544 : :
545 [ # # ][ # # ]: 0 : Reference<XReportDefinition> xReport = _xProp->getReportDefinition();
546 [ # # ][ # # ]: 0 : const awt::Size aSize = rptui::getStyleProperty<awt::Size>(xReport,PROPERTY_PAPERSIZE);
547 [ # # ][ # # ]: 0 : const sal_Int32 nOffset = rptui::getStyleProperty<sal_Int32>(xReport,PROPERTY_LEFTMARGIN);
548 [ # # ][ # # ]: 0 : const sal_Int32 nCount = _xProp->getCount();
549 : :
550 [ # # ]: 0 : ::std::vector<sal_Int32> aColumnPos;
551 [ # # ]: 0 : aColumnPos.reserve(2*(nCount + 1));
552 [ # # ]: 0 : aColumnPos.push_back(nOffset);
553 [ # # ][ # # ]: 0 : aColumnPos.push_back(aSize.Width - rptui::getStyleProperty<sal_Int32>(xReport,PROPERTY_RIGHTMARGIN));
[ # # ]
554 : :
555 [ # # ]: 0 : ::std::vector<sal_Int32> aRowPos;
556 [ # # ]: 0 : aRowPos.reserve(2*(nCount + 1));
557 [ # # ]: 0 : aRowPos.push_back(0);
558 [ # # ][ # # ]: 0 : aRowPos.push_back(_xProp->getHeight());
[ # # ]
559 : :
560 : : sal_Int32 i;
561 [ # # ]: 0 : for (i = 0 ; i< nCount ; ++i)
562 : : {
563 [ # # ][ # # ]: 0 : Reference<XReportComponent> xReportElement(_xProp->getByIndex(i),uno::UNO_QUERY);
[ # # ]
564 [ # # ]: 0 : uno::Reference< XShape> xShape(xReportElement,uno::UNO_QUERY);
565 [ # # ]: 0 : if ( xShape.is() )
566 : 0 : continue;
567 : : OSL_ENSURE( xReportElement.is(),"NULL Element in Section!" );
568 [ # # ]: 0 : if ( !xReportElement.is() )
569 : 0 : continue;
570 [ # # ][ # # ]: 0 : sal_Int32 nX = xReportElement->getPositionX();
571 [ # # ]: 0 : aColumnPos.push_back(nX);
572 [ # # ]: 0 : Reference<XFixedLine> xFixedLine(xReportElement,uno::UNO_QUERY);
573 [ # # ][ # # ]: 0 : if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical
[ # # ][ # # ]
[ # # ]
574 : : {
575 [ # # ][ # # ]: 0 : sal_Int32 nWidth = static_cast<sal_Int32>(xReportElement->getWidth()*0.5);
576 : 0 : nX += nWidth;
577 [ # # ]: 0 : aColumnPos.push_back(nX);
578 [ # # ][ # # ]: 0 : nX += xReportElement->getWidth() - nWidth;
579 : : }
580 : : else
581 [ # # ][ # # ]: 0 : nX += xReportElement->getWidth();
582 [ # # ]: 0 : aColumnPos.push_back(nX); // --nX why?
583 : :
584 [ # # ][ # # ]: 0 : sal_Int32 nY = xReportElement->getPositionY();
585 [ # # ]: 0 : aRowPos.push_back(nY);
586 [ # # ][ # # ]: 0 : nY += xReportElement->getHeight();
587 [ # # ]: 0 : aRowPos.push_back(nY); // --nY why?
588 [ # # ][ # # ]: 0 : }
589 : :
590 [ # # ]: 0 : ::std::sort(aColumnPos.begin(),aColumnPos.end(),::std::less<sal_Int32>());
591 [ # # ][ # # ]: 0 : aColumnPos.erase(::std::unique(aColumnPos.begin(),aColumnPos.end()),aColumnPos.end());
592 : :
593 [ # # ]: 0 : ::std::sort(aRowPos.begin(),aRowPos.end(),::std::less<sal_Int32>());
594 [ # # ][ # # ]: 0 : aRowPos.erase(::std::unique(aRowPos.begin(),aRowPos.end()),aRowPos.end());
595 : :
596 : : TSectionsGrid::iterator aInsert = m_aSectionsGrid.insert(
597 : : TSectionsGrid::value_type(
598 [ # # ]: 0 : _xProp.get(),
599 : 0 : TGrid(aRowPos.size() - 1,TGrid::value_type(sal_False,TRow(aColumnPos.size() - 1)))
600 : : )
601 [ # # ][ # # ]: 0 : ).first;
[ # # ][ # # ]
[ # # ]
602 [ # # ]: 0 : lcl_calculate(aColumnPos,aRowPos,aInsert->second);
603 : :
604 [ # # ][ # # ]: 0 : TGridStyleMap::iterator aPos = m_aColumnStyleNames.insert(TGridStyleMap::value_type(_xProp.get(),TStringVec())).first;
[ # # ][ # # ]
[ # # ]
605 [ # # ]: 0 : collectStyleNames(XML_STYLE_FAMILY_TABLE_COLUMN,aColumnPos,aPos->second);
606 [ # # ][ # # ]: 0 : aPos = m_aRowStyleNames.insert(TGridStyleMap::value_type(_xProp.get(),TStringVec())).first;
[ # # ][ # # ]
[ # # ]
607 [ # # ]: 0 : collectStyleNames(XML_STYLE_FAMILY_TABLE_ROW,aRowPos,aPos->second);
608 : :
609 : 0 : sal_Int32 x1 = 0;
610 : 0 : sal_Int32 y1 = 0;
611 : 0 : sal_Int32 x2 = 0;
612 : 0 : sal_Int32 y2 = 0;
613 : 0 : sal_Int32 xi = 0;
614 : 0 : sal_Int32 yi = 0;
615 : 0 : bool isOverlap = false;
616 : :
617 [ # # ]: 0 : for (i = 0 ; i< nCount ; ++i)
618 : : {
619 [ # # ][ # # ]: 0 : Reference<XReportComponent> xReportElement(_xProp->getByIndex(i),uno::UNO_QUERY);
[ # # ]
620 [ # # ]: 0 : uno::Reference< XShape> xShape(xReportElement,uno::UNO_QUERY);
621 [ # # ]: 0 : if ( xShape.is() )
622 : 0 : continue;
623 [ # # ][ # # ]: 0 : sal_Int32 nPos = xReportElement->getPositionX();
624 [ # # ][ # # ]: 0 : x1 = (::std::find(aColumnPos.begin(),aColumnPos.end(),nPos) - aColumnPos.begin());
625 [ # # ]: 0 : Reference<XFixedLine> xFixedLine(xReportElement,uno::UNO_QUERY);
626 [ # # ][ # # ]: 0 : if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical
[ # # ][ # # ]
[ # # ]
627 [ # # ][ # # ]: 0 : nPos += static_cast<sal_Int32>(xReportElement->getWidth()*0.5);
628 : : else
629 [ # # ][ # # ]: 0 : nPos += xReportElement->getWidth(); // -1 why
630 [ # # ][ # # ]: 0 : x2 = (::std::find(aColumnPos.begin(),aColumnPos.end(),nPos) - aColumnPos.begin());
631 : :
632 [ # # ][ # # ]: 0 : nPos = xReportElement->getPositionY();
633 [ # # ][ # # ]: 0 : y1 = (::std::find(aRowPos.begin(),aRowPos.end(),nPos) - aRowPos.begin());
634 [ # # ][ # # ]: 0 : nPos += xReportElement->getHeight(); // -1 why?
635 [ # # ][ # # ]: 0 : y2 = (::std::find(aRowPos.begin(),aRowPos.end(),nPos) - aRowPos.begin());
636 : :
637 : 0 : isOverlap = false;
638 : 0 : yi = y1;
639 [ # # ][ # # ]: 0 : while(yi < y2 && !isOverlap) // find overlapping controls
[ # # ]
640 : : {
641 : 0 : xi = x1;
642 [ # # ][ # # ]: 0 : while(xi < x2 && !isOverlap)
[ # # ]
643 : : {
644 [ # # ]: 0 : if ( aInsert->second[yi].second[xi].xElement.is() )
645 : : {
646 : 0 : isOverlap = true;
647 : : }
648 : 0 : ++xi;
649 : : }
650 : 0 : ++yi;
651 : : }
652 : :
653 [ # # ]: 0 : if (!isOverlap)
654 : : {
655 : 0 : yi = y1;
656 [ # # ]: 0 : while(yi < y2)
657 : : {
658 : 0 : xi = x1;
659 [ # # ]: 0 : while(xi < x2)
660 : : {
661 [ # # ][ # # ]: 0 : aInsert->second[yi].second[xi] = TCell();
[ # # ]
662 : 0 : ++xi;
663 : : }
664 : 0 : aInsert->second[yi].first = sal_True;
665 : 0 : ++yi;
666 : : }
667 : :
668 [ # # ][ # # ]: 0 : if (x2 - x1 != 0 && y2 - y1 != 0)
669 : : {
670 [ # # ][ # # ]: 0 : awt::Size aElementSize = xReportElement->getSize();
671 [ # # ][ # # ]: 0 : if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical
[ # # ][ # # ]
[ # # ]
672 [ # # ][ # # ]: 0 : aElementSize.Width = static_cast<sal_Int32>(xFixedLine->getWidth()*0.5);
673 : :
674 : 0 : sal_Int32 nColSpan = x2 - x1;
675 : 0 : sal_Int32 nRowSpan = y2 - y1;
676 : 0 : aInsert->second[y1].second[x1] =
677 : : TCell(
678 : : aElementSize.Width , // -1 why?
679 : : aElementSize.Height, // -1 why?
680 : : nColSpan,
681 : : nRowSpan,
682 : : xReportElement
683 [ # # # # ]: 0 : );
[ # # ]
684 : : }
685 : : }
686 [ # # ][ # # ]: 0 : }
687 : :
688 [ # # ]: 0 : lcl_adjustColumnSpanOverRows(m_aSectionsGrid);
689 [ # # ]: 0 : exportReportComponentAutoStyles(_xProp);
690 : 0 : }
691 : : // -----------------------------------------------------------------------------
692 : 0 : void ORptExport::exportReportComponentAutoStyles(const Reference<XSection>& _xProp)
693 : : {
694 : 0 : const sal_Int32 nCount = _xProp->getCount();
695 [ # # ]: 0 : for (sal_Int32 i = 0 ; i< nCount ; ++i)
696 : : {
697 [ # # ][ # # ]: 0 : const Reference<XReportComponent> xReportElement(_xProp->getByIndex(i),uno::UNO_QUERY);
[ # # ]
698 [ # # ]: 0 : const Reference< report::XShape > xShape(xReportElement,uno::UNO_QUERY);
699 [ # # ]: 0 : if ( xShape.is() )
700 : : {
701 [ # # ]: 0 : UniReference< XMLShapeExport > xShapeExport = GetShapeExport();
702 [ # # ][ # # ]: 0 : xShapeExport->seekShapes(_xProp.get());
[ # # ][ # # ]
703 [ # # ]: 0 : SolarMutexGuard aGuard;
704 [ # # ][ # # ]: 0 : xShapeExport->collectShapeAutoStyles(xShape.get());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
705 : : }
706 : : else
707 : : {
708 [ # # ][ # # ]: 0 : exportAutoStyle(xReportElement.get());
[ # # ]
709 : :
710 [ # # ]: 0 : Reference<XFormattedField> xFormattedField(xReportElement,uno::UNO_QUERY);
711 [ # # ]: 0 : if ( xFormattedField.is() )
712 : : {
713 : : try
714 : : {
715 [ # # ][ # # ]: 0 : const sal_Int32 nFormatCount = xFormattedField->getCount();
716 [ # # ]: 0 : for (sal_Int32 j = 0; j < nFormatCount ; ++j)
717 : : {
718 [ # # ][ # # ]: 0 : uno::Reference< report::XFormatCondition > xCond(xFormattedField->getByIndex(j),uno::UNO_QUERY);
[ # # ]
719 [ # # ][ # # ]: 0 : exportAutoStyle(xCond.get(),xFormattedField);
[ # # ]
720 [ # # ]: 0 : }
721 : : }
722 [ # # ]: 0 : catch(uno::Exception&)
723 : : {
724 : : OSL_FAIL("Can not access format condition!");
725 : : }
726 : 0 : }
727 : : }
728 : 0 : }
729 : 0 : }
730 : : // -----------------------------------------------------------------------------
731 : 0 : void ORptExport::exportSection(const Reference<XSection>& _xSection,bool bHeader)
732 : : {
733 : : OSL_ENSURE(_xSection.is(),"Section is NULL -> GPF");
734 : 0 : ::rtl::OUStringBuffer sValue;
735 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_TABLE, XML_NAME,_xSection->getName());
[ # # ]
736 : :
737 [ # # ][ # # ]: 0 : if ( !_xSection->getVisible() )
[ # # ]
738 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_VISIBLE,XML_FALSE);
739 : :
740 [ # # ]: 0 : if ( !bHeader )
741 : : {
742 [ # # ][ # # ]: 0 : sal_uInt16 nRet = _xSection->getForceNewPage();
743 [ # # ]: 0 : const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetForceNewPageOptions();
744 [ # # ][ # # ]: 0 : if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) )
745 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_FORCE_NEW_PAGE,sValue.makeStringAndClear());
746 : :
747 [ # # ][ # # ]: 0 : nRet = _xSection->getNewRowOrCol();
748 [ # # ][ # # ]: 0 : if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) )
749 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_FORCE_NEW_COLUMN,sValue.makeStringAndClear());
750 [ # # ][ # # ]: 0 : if ( _xSection->getKeepTogether() )
[ # # ]
751 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER, XML_TRUE );
752 : : }
753 : :
754 [ # # ][ # # ]: 0 : exportStyleName(_xSection.get(),GetAttrList(),m_sTableStyle);
[ # # ]
755 : :
756 : : /// TODO export as table layout
757 [ # # ]: 0 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True);
758 : :
759 [ # # ][ # # ]: 0 : ::rtl::OUString sExpr = _xSection->getConditionalPrintExpression();
760 [ # # ]: 0 : if ( !sExpr.isEmpty() )
761 : : {
762 [ # # ]: 0 : exportFormula(XML_FORMULA,sExpr);
763 [ # # ][ # # ]: 0 : SvXMLElementExport aPrintExpr(*this,XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION, sal_True, sal_False);
764 : : }
765 : :
766 [ # # ][ # # ]: 0 : exportContainer(_xSection);
767 : 0 : }
768 : : // -----------------------------------------------------------------------------
769 : 0 : void ORptExport::exportTableColumns(const Reference< XSection>& _xSection)
770 : : {
771 [ # # ]: 0 : SvXMLElementExport aColumns(*this,XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, sal_True, sal_True);
772 [ # # ][ # # ]: 0 : TGridStyleMap::iterator aColFind = m_aColumnStyleNames.find(_xSection.get());
[ # # ][ # # ]
773 : : OSL_ENSURE(aColFind != m_aColumnStyleNames.end(),"ORptExport::exportTableColumns: Section not found in m_aColumnStyleNames!");
774 [ # # ]: 0 : if ( aColFind == m_aColumnStyleNames.end() )
775 : 0 : return;
776 : :
777 : 0 : TStringVec::iterator aColIter = aColFind->second.begin();
778 : 0 : TStringVec::iterator aColEnd = aColFind->second.end();
779 [ # # ][ # # ]: 0 : for (; aColIter != aColEnd; ++aColIter)
780 : : {
781 [ # # ]: 0 : AddAttribute( m_sTableStyle,*aColIter );
782 [ # # ]: 0 : SvXMLElementExport aColumn(*this,XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True);
783 [ # # ][ # # ]: 0 : }
[ # # ]
784 : : }
785 : : // -----------------------------------------------------------------------------
786 : 0 : void ORptExport::exportContainer(const Reference< XSection>& _xSection)
787 : : {
788 : : OSL_ENSURE(_xSection.is(),"Section is NULL -> GPF");
789 : :
790 [ # # ]: 0 : exportTableColumns(_xSection);
791 : :
792 [ # # ][ # # ]: 0 : TSectionsGrid::iterator aFind = m_aSectionsGrid.find(_xSection.get());
[ # # ][ # # ]
793 : : OSL_ENSURE(aFind != m_aSectionsGrid.end(),"ORptExport::exportContainer: Section not found in grid!");
794 [ # # ]: 0 : if ( aFind == m_aSectionsGrid.end() )
795 : 0 : return;
796 : 0 : TGrid::iterator aRowIter = aFind->second.begin();
797 : 0 : TGrid::iterator aRowEnd = aFind->second.end();
798 : :
799 : 0 : sal_Int32 nEmptyCellColSpan = 0;
800 [ # # ][ # # ]: 0 : TGridStyleMap::iterator aRowFind = m_aRowStyleNames.find(_xSection.get());
[ # # ][ # # ]
801 : 0 : TStringVec::iterator aHeightIter = aRowFind->second.begin();
802 : : OSL_ENSURE(aRowFind->second.size() == aFind->second.size(),"Different count for rows");
803 : :
804 : 0 : bool bShapeHandled = false;
805 [ # # ]: 0 : ::std::map<sal_Int32,sal_Int32> aRowSpan;
806 [ # # ][ # # ]: 0 : for (sal_Int32 j = 0; aRowIter != aRowEnd; ++aRowIter,++j,++aHeightIter)
807 : : {
808 [ # # ]: 0 : AddAttribute( m_sTableStyle,*aHeightIter );
809 [ # # ]: 0 : SvXMLElementExport aRow(*this,XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True);
810 [ # # ]: 0 : if ( aRowIter->first )
811 : : {
812 : 0 : ::std::vector< TCell >::iterator aColIter = aRowIter->second.begin();
813 : 0 : ::std::vector< TCell >::iterator aColEnd = aRowIter->second.end();
814 : 0 : nEmptyCellColSpan = 0;
815 [ # # ][ # # ]: 0 : for (; aColIter != aColEnd; ++aColIter)
816 : : {
817 : 0 : sal_Bool bCoveredCell = sal_False;
818 : 0 : sal_Int32 nColSpan = 0;
819 [ # # ]: 0 : sal_Int32 nColIndex = aColIter - aRowIter->second.begin();
820 [ # # ]: 0 : ::std::map<sal_Int32,sal_Int32>::iterator aRowSpanFind = aRowSpan.find(nColIndex);
821 [ # # ][ # # ]: 0 : if ( aRowSpanFind != aRowSpan.end() )
822 : : {
823 : 0 : nColSpan = 1;
824 [ # # ][ # # ]: 0 : if ( !--(aRowSpanFind->second) )
825 [ # # ]: 0 : aRowSpan.erase(aRowSpanFind);
826 : :
827 [ # # ]: 0 : if ( aColIter->nColSpan > 1 )
828 : 0 : nColSpan += aColIter->nColSpan - 1;
829 : :
830 : 0 : bCoveredCell = sal_True;
831 [ # # ]: 0 : aColIter = aColIter + (aColIter->nColSpan - 1);
832 : : }
833 [ # # ]: 0 : else if ( aColIter->bSet )
834 : : {
835 [ # # ]: 0 : if ( nEmptyCellColSpan > 0 )
836 : : {
837 [ # # ][ # # ]: 0 : AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nEmptyCellColSpan) );
838 : 0 : bCoveredCell = sal_True;
839 : 0 : nColSpan = nEmptyCellColSpan - 1;
840 : 0 : nEmptyCellColSpan = 0;
841 : : }
842 : 0 : sal_Int32 nSpan = aColIter->nColSpan;
843 [ # # ]: 0 : if ( nSpan > 1 )
844 : : {
845 [ # # ][ # # ]: 0 : AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nSpan) );
846 : 0 : nColSpan = nSpan - 1;
847 : 0 : bCoveredCell = sal_True;
848 : : }
849 : 0 : nSpan = aColIter->nRowSpan;
850 [ # # ]: 0 : if ( nSpan > 1 )
851 : : {
852 [ # # ][ # # ]: 0 : AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_ROWS_SPANNED,implConvertNumber(nSpan) );
853 [ # # ]: 0 : aRowSpan[nColIndex] = nSpan - 1;
854 : : }
855 [ # # ]: 0 : if ( aColIter->xElement.is() )
856 [ # # ][ # # ]: 0 : exportStyleName(aColIter->xElement.get(),GetAttrList(),m_sTableStyle);
[ # # ]
857 : :
858 : : // start <table:table-cell>
859 [ # # ]: 0 : Reference<XFormattedField> xFormattedField(aColIter->xElement,uno::UNO_QUERY);
860 [ # # ]: 0 : if ( xFormattedField.is() )
861 : : {
862 [ # # ][ # # ]: 0 : sal_Int32 nFormatKey = xFormattedField->getFormatKey();
863 [ # # ]: 0 : if ( 0 != nFormatKey )
864 : : {
865 [ # # ]: 0 : XMLNumberFormatAttributesExportHelper aHelper(GetNumberFormatsSupplier(),*this);
866 : 0 : bool bIsStandard = false;
867 : 0 : ::rtl::OUString sEmpty;
868 [ # # ][ # # ]: 0 : if ( util::NumberFormat::TEXT == aHelper.GetCellType(nFormatKey,bIsStandard) )
869 [ # # ]: 0 : aHelper.SetNumberFormatAttributes(sEmpty, sEmpty);
870 : : else
871 [ # # ][ # # ]: 0 : aHelper.SetNumberFormatAttributes(nFormatKey, 0.0,sal_False);
872 : : }
873 : : }
874 [ # # ]: 0 : SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_False);
875 : :
876 [ # # ]: 0 : if ( aColIter->xElement.is() )
877 : : {
878 : : // start <text:p>
879 [ # # ]: 0 : SvXMLElementExport aParagraphContent(*this,XML_NAMESPACE_TEXT, XML_P, sal_True,sal_False);
880 [ # # ]: 0 : Reference<XServiceInfo> xElement(aColIter->xElement,uno::UNO_QUERY);
881 : 0 : Reference<XReportComponent> xReportComponent = aColIter->xElement;
882 : :
883 [ # # ]: 0 : if ( !bShapeHandled )
884 : : {
885 : 0 : bShapeHandled = true;
886 [ # # ]: 0 : exportShapes(_xSection,false);
887 : : }
888 [ # # ]: 0 : uno::Reference< XShape > xShape(xElement,uno::UNO_QUERY);
889 [ # # ]: 0 : uno::Reference< XFixedLine > xFixedLine(xElement,uno::UNO_QUERY);
890 [ # # ][ # # ]: 0 : if ( !xShape.is() && !xFixedLine.is() )
[ # # ]
891 : : {
892 [ # # ]: 0 : Reference<XReportControlModel> xReportElement(xElement,uno::UNO_QUERY);
893 [ # # ]: 0 : Reference<XReportDefinition> xReportDefinition(xElement,uno::UNO_QUERY);
894 [ # # ]: 0 : Reference< XImageControl > xImage(xElement,uno::UNO_QUERY);
895 [ # # ]: 0 : Reference<XSection> xSection(xElement,uno::UNO_QUERY);
896 : :
897 : 0 : XMLTokenEnum eToken = XML_SECTION;
898 : 0 : sal_Bool bExportData = sal_False;
899 [ # # ][ # # ]: 0 : if ( xElement->supportsService(SERVICE_FIXEDTEXT) )
[ # # ][ # # ]
900 : : {
901 : 0 : eToken = XML_FIXED_CONTENT;
902 : : }
903 [ # # ][ # # ]: 0 : else if ( xElement->supportsService(SERVICE_FORMATTEDFIELD) )
[ # # ][ # # ]
904 : : {
905 : 0 : eToken = XML_FORMATTED_TEXT;
906 : 0 : bExportData = sal_True;
907 : : }
908 [ # # ][ # # ]: 0 : else if ( xElement->supportsService(SERVICE_IMAGECONTROL) )
[ # # ][ # # ]
909 : : {
910 : 0 : eToken = XML_IMAGE;
911 [ # # ][ # # ]: 0 : ::rtl::OUString sTargetLocation = xImage->getImageURL();
912 [ # # ]: 0 : if ( !sTargetLocation.isEmpty() )
913 : : {
914 [ # # ]: 0 : sTargetLocation = GetRelativeReference(sTargetLocation);
915 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_FORM, XML_IMAGE_DATA,sTargetLocation);
916 : : }
917 : 0 : bExportData = sal_True;
918 : 0 : ::rtl::OUStringBuffer sValue;
919 [ # # ]: 0 : const SvXMLEnumMapEntry* aXML_ImageScaleEnumMap = OXMLHelper::GetImageScaleOptions();
920 [ # # ][ # # ]: 0 : if ( SvXMLUnitConverter::convertEnum( sValue, xImage->getScaleMode(),aXML_ImageScaleEnumMap ) )
[ # # ][ # # ]
921 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_SCALE, sValue.makeStringAndClear() );
922 : : }
923 [ # # ]: 0 : else if ( xReportDefinition.is() )
924 : : {
925 : 0 : eToken = XML_SUB_DOCUMENT;
926 : : }
927 : 0 : else if ( xSection.is() )
928 : : {
929 : : }
930 : :
931 : 0 : bool bPageSet = false;
932 [ # # ]: 0 : if ( bExportData )
933 : : {
934 [ # # ][ # # ]: 0 : bPageSet = exportFormula(XML_FORMULA,xReportElement->getDataField());
[ # # ]
935 [ # # ]: 0 : if ( bPageSet )
936 : 0 : eToken = XML_FIXED_CONTENT;
937 [ # # ]: 0 : else if ( eToken == XML_IMAGE )
938 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_PRESERVE_IRI, xImage->getPreserveIRI() ? XML_TRUE : XML_FALSE );
[ # # ][ # # ]
939 : : }
940 : :
941 : : //if ( !bPageSet )
942 : : {
943 : : // start <report:eToken>
944 [ # # ]: 0 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_REPORT, eToken, sal_False, sal_False);
945 [ # # ]: 0 : if ( eToken == XML_FIXED_CONTENT )
946 [ # # ]: 0 : exportParagraph(xReportElement);
947 [ # # ]: 0 : if ( xReportElement.is() )
948 [ # # ]: 0 : exportReportElement(xReportElement);
949 : :
950 [ # # ][ # # ]: 0 : if ( eToken == XML_GROUP && xSection.is() )
[ # # ]
951 [ # # ]: 0 : exportContainer(xSection);
952 [ # # ][ # # ]: 0 : else if ( eToken == XML_SUB_DOCUMENT && xReportDefinition.is() )
[ # # ]
953 : : {
954 [ # # ]: 0 : SvXMLElementExport aOfficeElement( *this, XML_NAMESPACE_OFFICE, XML_BODY,sal_True, sal_True );
955 : : SvXMLElementExport aElem( *this, sal_True,
956 : : XML_NAMESPACE_OFFICE, XML_REPORT,
957 [ # # ]: 0 : sal_True, sal_True );
958 : :
959 [ # # ]: 0 : exportReportAttributes(xReportDefinition);
960 [ # # ][ # # ]: 0 : exportReport(xReportDefinition);
[ # # ]
961 : : }
962 [ # # ]: 0 : else if ( xSection.is() )
963 [ # # ][ # # ]: 0 : exportSection(xSection);
964 : 0 : }
965 [ # # ]: 0 : }
966 : : }
967 [ # # ]: 0 : else if ( !bShapeHandled )
968 : : {
969 : 0 : bShapeHandled = true;
970 [ # # ]: 0 : exportShapes(_xSection);
971 : : }
972 [ # # ][ # # ]: 0 : aColIter = aColIter + (aColIter->nColSpan - 1);
973 : : }
974 : : else
975 : 0 : ++nEmptyCellColSpan;
976 [ # # ]: 0 : if ( bCoveredCell )
977 : : {
978 [ # # ]: 0 : for (sal_Int32 k = 0; k < nColSpan; ++k)
979 : : {
980 [ # # ]: 0 : SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, sal_True, sal_True);
981 [ # # ]: 0 : }
982 : :
983 : : }
984 : : }
985 [ # # ]: 0 : if ( nEmptyCellColSpan )
986 : : {
987 : : {
988 [ # # ][ # # ]: 0 : AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nEmptyCellColSpan) );
989 [ # # ]: 0 : SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True);
990 [ # # ]: 0 : if ( !bShapeHandled )
991 : : {
992 : 0 : bShapeHandled = true;
993 [ # # ]: 0 : exportShapes(_xSection);
994 [ # # ]: 0 : }
995 : : }
996 [ # # ]: 0 : for (sal_Int32 k = 0; k < nEmptyCellColSpan; ++k)
997 : : {
998 [ # # ]: 0 : SvXMLElementExport aCoveredCell(*this,XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, sal_True, sal_True);
999 [ # # ]: 0 : }
1000 : 0 : nEmptyCellColSpan = 0;
1001 : : }
1002 : : }
1003 : : else
1004 : : { // empty rows
1005 : 0 : nEmptyCellColSpan = aRowIter->second.size();
1006 [ # # ]: 0 : if ( nEmptyCellColSpan )
1007 : : {
1008 : : {
1009 [ # # ][ # # ]: 0 : AddAttribute( XML_NAMESPACE_TABLE,XML_NUMBER_COLUMNS_SPANNED,implConvertNumber(nEmptyCellColSpan) );
1010 [ # # ]: 0 : SvXMLElementExport aCell(*this,XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True);
1011 [ # # ]: 0 : if ( !bShapeHandled )
1012 : : {
1013 : 0 : bShapeHandled = true;
1014 [ # # ]: 0 : exportShapes(_xSection);
1015 [ # # ]: 0 : }
1016 : : }
1017 [ # # ]: 0 : for (sal_Int32 k = 1; k < nEmptyCellColSpan; ++k)
1018 : : {
1019 [ # # ]: 0 : SvXMLElementExport aCoveredCell(*this,XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL, sal_True, sal_True);
1020 [ # # ]: 0 : }
1021 : 0 : nEmptyCellColSpan = 0;
1022 : : }
1023 : : }
1024 [ # # ]: 0 : }
1025 : : }
1026 : : // -----------------------------------------------------------------------------
1027 : 0 : ::rtl::OUString ORptExport::convertFormula(const ::rtl::OUString& _sFormula)
1028 : : {
1029 : 0 : ::rtl::OUString sFormula = _sFormula;
1030 [ # # ]: 0 : if ( _sFormula.equalsAsciiL("rpt:",4) )
1031 : 0 : sFormula = ::rtl::OUString();
1032 : 0 : return sFormula;
1033 : : }
1034 : : // -----------------------------------------------------------------------------
1035 : 0 : bool ORptExport::exportFormula(enum ::xmloff::token::XMLTokenEnum eName,const ::rtl::OUString& _sFormula)
1036 : : {
1037 : 0 : const ::rtl::OUString sFieldData = convertFormula(_sFormula);
1038 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()"));
[ # # ][ # # ]
1039 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()"));
[ # # ][ # # ]
1040 : 0 : sal_Int32 nPageNumberIndex = sFieldData.indexOf(s_sPageNumber);
1041 : 0 : sal_Int32 nPageCountIndex = sFieldData.indexOf(s_sPageCount);
1042 [ # # ][ # # ]: 0 : bool bRet = nPageNumberIndex != -1 || nPageCountIndex != -1;
1043 [ # # ]: 0 : if ( !bRet )
1044 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, eName,sFieldData);
1045 : :
1046 : 0 : return bRet;
1047 : : }
1048 : : // -----------------------------------------------------------------------------
1049 : 0 : void ORptExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt,const ::rtl::OUString& _sName)
1050 : : {
1051 [ # # ]: 0 : Reference<XPropertySet> xFind(_xProp);
1052 [ # # ]: 0 : TPropertyStyleMap::iterator aFind = m_aAutoStyleNames.find(xFind);
1053 [ # # ]: 0 : if ( aFind != m_aAutoStyleNames.end() )
1054 : : {
1055 : : _rAtt.AddAttribute( _sName,
1056 [ # # ]: 0 : aFind->second );
1057 [ # # ]: 0 : m_aAutoStyleNames.erase(aFind);
1058 : 0 : }
1059 : 0 : }
1060 : : // -----------------------------------------------------------------------------
1061 : 0 : sal_Bool ORptExport::exportGroup(const Reference<XReportDefinition>& _xReportDefinition,sal_Int32 _nPos,sal_Bool _bExportAutoStyle)
1062 : : {
1063 : 0 : sal_Bool bGroupExported = sal_False;
1064 [ # # ]: 0 : if ( _xReportDefinition.is() )
1065 : : {
1066 [ # # ][ # # ]: 0 : Reference< XGroups > xGroups = _xReportDefinition->getGroups();
1067 [ # # ]: 0 : if ( xGroups.is() )
1068 : : {
1069 [ # # ][ # # ]: 0 : sal_Int32 nCount = xGroups->getCount();
1070 [ # # ][ # # ]: 0 : if ( _nPos >= 0 && _nPos < nCount )
1071 : : {
1072 : 0 : bGroupExported = sal_True;
1073 [ # # ][ # # ]: 0 : Reference<XGroup> xGroup(xGroups->getByIndex(_nPos),uno::UNO_QUERY);
[ # # ]
1074 : : OSL_ENSURE(xGroup.is(),"No Group prepare for GPF");
1075 [ # # ]: 0 : if ( _bExportAutoStyle )
1076 : : {
1077 [ # # ][ # # ]: 0 : if ( xGroup->getHeaderOn() )
[ # # ]
1078 [ # # ][ # # ]: 0 : exportSectionAutoStyle(xGroup->getHeader());
[ # # ]
1079 [ # # ]: 0 : exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle);
1080 [ # # ][ # # ]: 0 : if ( xGroup->getFooterOn() )
[ # # ]
1081 [ # # ][ # # ]: 0 : exportSectionAutoStyle(xGroup->getFooter());
[ # # ]
1082 : : }
1083 : : else
1084 : : {
1085 [ # # ][ # # ]: 0 : if ( xGroup->getSortAscending() )
[ # # ]
1086 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_SORT_ASCENDING, XML_TRUE );
1087 : :
1088 [ # # ][ # # ]: 0 : if ( xGroup->getStartNewColumn() )
[ # # ]
1089 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_START_NEW_COLUMN, XML_TRUE);
1090 [ # # ][ # # ]: 0 : if ( xGroup->getResetPageNumber() )
[ # # ]
1091 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER, XML_TRUE );
1092 : :
1093 [ # # ][ # # ]: 0 : ::rtl::OUString sExpression = xGroup->getExpression();
1094 [ # # ]: 0 : if ( !sExpression.isEmpty() )
1095 : : {
1096 [ # # ][ # # ]: 0 : static ::rtl::OUString s_sQuote(RTL_CONSTASCII_USTRINGPARAM("\"\""));
[ # # ][ # # ]
1097 : 0 : sal_Int32 nIndex = sExpression.indexOf('"');
1098 [ # # ]: 0 : while ( nIndex > -1 )
1099 : : {
1100 : 0 : sExpression = sExpression.replaceAt(nIndex,1,s_sQuote);
1101 : 0 : nIndex = sExpression.indexOf('"',nIndex+2);
1102 : : }
1103 [ # # ]: 0 : ::rtl::OUString sFormula(RTL_CONSTASCII_USTRINGPARAM("rpt:HASCHANGED(\""));
1104 : :
1105 [ # # ]: 0 : TGroupFunctionMap::iterator aGroupFind = m_aGroupFunctionMap.find(xGroup);
1106 [ # # ]: 0 : if ( aGroupFind != m_aGroupFunctionMap.end() )
1107 [ # # ][ # # ]: 0 : sExpression = aGroupFind->second->getName();
1108 : 0 : sFormula += sExpression;
1109 [ # # ]: 0 : sFormula += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\")"));
1110 : 0 : sExpression = sFormula;
1111 : : }
1112 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION,sExpression);
1113 [ # # ][ # # ]: 0 : sal_Int16 nRet = xGroup->getKeepTogether();
1114 : 0 : ::rtl::OUStringBuffer sValue;
1115 [ # # ]: 0 : const SvXMLEnumMapEntry* aXML_KeepTogetherEnumMap = OXMLHelper::GetKeepTogetherOptions();
1116 [ # # ][ # # ]: 0 : if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_KeepTogetherEnumMap ) )
1117 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER,sValue.makeStringAndClear());
1118 : :
1119 [ # # ]: 0 : SvXMLElementExport aGroup(*this,XML_NAMESPACE_REPORT, XML_GROUP, sal_True, sal_True);
1120 [ # # ][ # # ]: 0 : exportFunctions(xGroup->getFunctions().get());
[ # # ][ # # ]
[ # # ][ # # ]
1121 [ # # ][ # # ]: 0 : if ( xGroup->getHeaderOn() )
[ # # ]
1122 : : {
1123 [ # # ][ # # ]: 0 : Reference<XSection> xSection = xGroup->getHeader();
1124 [ # # ][ # # ]: 0 : if ( xSection->getRepeatSection() )
[ # # ]
1125 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE );
1126 [ # # ]: 0 : SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_HEADER, sal_True, sal_True);
1127 [ # # ][ # # ]: 0 : exportSection(xSection);
1128 : : }
1129 [ # # ]: 0 : exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle);
1130 [ # # ][ # # ]: 0 : if ( xGroup->getFooterOn() )
[ # # ]
1131 : : {
1132 [ # # ][ # # ]: 0 : Reference<XSection> xSection = xGroup->getFooter();
1133 [ # # ][ # # ]: 0 : if ( xSection->getRepeatSection() )
[ # # ]
1134 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE );
1135 [ # # ]: 0 : SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_FOOTER, sal_True, sal_True);
1136 [ # # ][ # # ]: 0 : exportSection(xSection);
1137 [ # # ]: 0 : }
1138 : 0 : }
1139 : : }
1140 [ # # ]: 0 : else if ( _bExportAutoStyle )
1141 : : {
1142 [ # # ][ # # ]: 0 : exportSectionAutoStyle(_xReportDefinition->getDetail());
[ # # ]
1143 : : }
1144 : : else
1145 : : {
1146 [ # # ]: 0 : SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_DETAIL, sal_True, sal_True);
1147 [ # # ][ # # ]: 0 : exportSection(_xReportDefinition->getDetail());
[ # # ][ # # ]
1148 : : }
1149 : 0 : }
1150 : : }
1151 : 0 : return bGroupExported;
1152 : : }
1153 : : // -----------------------------------------------------------------------------
1154 : 0 : void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormattedField>& _xParentFormattedField)
1155 : : {
1156 [ # # ]: 0 : const uno::Reference<report::XReportControlFormat> xFormat(_xProp,uno::UNO_QUERY);
1157 [ # # ]: 0 : if ( xFormat.is() )
1158 : : {
1159 : : try
1160 : : {
1161 [ # # ][ # # ]: 0 : const awt::FontDescriptor aFont = xFormat->getFontDescriptor();
1162 : : OSL_ENSURE(!aFont.Name.isEmpty(),"No Font Name !");
1163 [ # # ][ # # ]: 0 : GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,aFont.Family,aFont.Pitch,aFont.CharSet );
[ # # ][ # # ]
[ # # ]
1164 : : }
1165 [ # # ]: 0 : catch(beans::UnknownPropertyException&)
1166 : : {
1167 : : // not interested in
1168 : : }
1169 : : }
1170 [ # # ]: 0 : const uno::Reference< report::XShape> xShape(_xProp,uno::UNO_QUERY);
1171 [ # # ]: 0 : if ( xShape.is() )
1172 : : {
1173 [ # # ][ # # ]: 0 : ::std::vector< XMLPropertyState > aPropertyStates( m_xParaPropMapper->Filter(_xProp) );
[ # # ]
1174 [ # # ]: 0 : if ( !aPropertyStates.empty() )
1175 [ # # ][ # # ]: 0 : m_aAutoStyleNames.insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, aPropertyStates )));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1176 : : }
1177 [ # # ][ # # ]: 0 : ::std::vector< XMLPropertyState > aPropertyStates( m_xCellStylesExportPropertySetMapper->Filter(_xProp) );
[ # # ]
1178 [ # # ]: 0 : Reference<XFixedLine> xFixedLine(_xProp,uno::UNO_QUERY);
1179 [ # # ]: 0 : if ( xFixedLine.is() )
1180 : : {
1181 [ # # ]: 0 : uno::Reference<beans::XPropertySet> xBorderProp = OXMLHelper::createBorderPropertySet();
1182 : 0 : table::BorderLine aValue;
1183 : 0 : aValue.Color = COL_BLACK;
1184 : 0 : aValue.InnerLineWidth = aValue.LineDistance = 0;
1185 : 0 : aValue.OuterLineWidth = 2;
1186 : :
1187 [ # # ][ # # ]: 0 : awt::Point aPos = xFixedLine->getPosition();
1188 [ # # ][ # # ]: 0 : awt::Size aSize = xFixedLine->getSize();
1189 [ # # ][ # # ]: 0 : sal_Int32 nSectionHeight = xFixedLine->getSection()->getHeight();
[ # # ][ # # ]
1190 : :
1191 : 0 : ::rtl::OUString sBorderProp;
1192 [ # # ]: 0 : ::std::vector< ::rtl::OUString> aProps;
1193 [ # # ][ # # ]: 0 : if ( xFixedLine->getOrientation() == 1 ) // vertical
[ # # ]
1194 : : {
1195 : : // check if border should be left
1196 [ # # ]: 0 : if ( !aPos.X )
1197 : : {
1198 [ # # ]: 0 : sBorderProp = PROPERTY_BORDERLEFT;
1199 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERRIGHT));
1200 : : }
1201 : : else
1202 : : {
1203 [ # # ]: 0 : sBorderProp = PROPERTY_BORDERRIGHT;
1204 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERLEFT));
1205 : : }
1206 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERTOP));
1207 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERBOTTOM));
1208 : : }
1209 : : else // horizontal
1210 : : {
1211 : : // check if border should be bottom
1212 [ # # ]: 0 : if ( (aPos.Y + aSize.Height) == nSectionHeight )
1213 : : {
1214 [ # # ]: 0 : sBorderProp = PROPERTY_BORDERBOTTOM;
1215 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERTOP));
1216 : : }
1217 : : else
1218 : : {
1219 [ # # ]: 0 : sBorderProp = PROPERTY_BORDERTOP;
1220 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERBOTTOM));
1221 : : }
1222 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERRIGHT));
1223 [ # # ][ # # ]: 0 : aProps.push_back(static_cast<const rtl::OUString&>(PROPERTY_BORDERLEFT));
1224 : : }
1225 : :
1226 [ # # ][ # # ]: 0 : xBorderProp->setPropertyValue(sBorderProp,uno::makeAny(aValue));
[ # # ]
1227 : :
1228 : 0 : aValue.Color = aValue.OuterLineWidth = 0;
1229 : 0 : uno::Any aEmpty;
1230 [ # # ]: 0 : aEmpty <<= aValue;
1231 : : ::std::for_each(aProps.begin(),aProps.end(),
1232 [ # # ][ # # ]: 0 : ::boost::bind(&beans::XPropertySet::setPropertyValue,xBorderProp,_1,aEmpty));
[ # # ][ # # ]
1233 : :
1234 [ # # ][ # # ]: 0 : ::std::vector< XMLPropertyState > aBorderStates(m_xCellStylesExportPropertySetMapper->Filter(xBorderProp));
1235 [ # # ][ # # ]: 0 : ::std::copy(aBorderStates.begin(),aBorderStates.end(),::std::back_inserter(aPropertyStates));
1236 : : }
1237 : : else
1238 : : {
1239 [ # # ]: 0 : const Reference<XFormattedField> xFormattedField(_xProp,uno::UNO_QUERY);
1240 [ # # ][ # # ]: 0 : if ( (_xParentFormattedField.is() || xFormattedField.is()) && !aPropertyStates.empty() )
[ # # ][ # # ]
1241 : : {
1242 : 0 : sal_Int32 nNumberFormat = 0;
1243 [ # # ]: 0 : if ( _xParentFormattedField.is() )
1244 [ # # ][ # # ]: 0 : nNumberFormat = _xParentFormattedField->getFormatKey();
1245 : : else
1246 [ # # ][ # # ]: 0 : nNumberFormat = xFormattedField->getFormatKey();
1247 : : {
1248 [ # # ][ # # ]: 0 : sal_Int32 nStyleMapIndex = m_xCellStylesExportPropertySetMapper->getPropertySetMapper()->FindEntryIndex( CTF_RPT_NUMBERFORMAT );
[ # # ]
1249 [ # # ]: 0 : addDataStyle(nNumberFormat);
1250 [ # # ][ # # ]: 0 : XMLPropertyState aNumberStyleState( nStyleMapIndex, uno::makeAny( getDataStyleName(nNumberFormat) ) );
1251 [ # # ]: 0 : aPropertyStates.push_back( aNumberStyleState );
1252 : : }
1253 : 0 : }
1254 : : }
1255 : :
1256 [ # # ]: 0 : if ( !aPropertyStates.empty() )
1257 [ # # ][ # # ]: 0 : m_aAutoStyleNames.insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( XML_STYLE_FAMILY_TABLE_CELL, aPropertyStates )));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1258 : 0 : }
1259 : : // -----------------------------------------------------------------------------
1260 : 0 : void ORptExport::exportAutoStyle(const Reference<XSection>& _xProp)
1261 : : {
1262 [ # # ][ # # ]: 0 : ::std::vector< XMLPropertyState > aPropertyStates( m_xTableStylesExportPropertySetMapper->Filter(_xProp.get()) );
[ # # ][ # # ]
[ # # ]
1263 [ # # ]: 0 : if ( !aPropertyStates.empty() )
1264 [ # # ][ # # ]: 0 : m_aAutoStyleNames.insert( TPropertyStyleMap::value_type(_xProp.get(),GetAutoStylePool()->Add( XML_STYLE_FAMILY_TABLE_TABLE, aPropertyStates )));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1265 : 0 : }
1266 : : // -----------------------------------------------------------------------------
1267 : 0 : void ORptExport::SetBodyAttributes()
1268 : : {
1269 [ # # ]: 0 : Reference<XReportDefinition> xProp(getReportDefinition());
1270 [ # # ]: 0 : exportReportAttributes(xProp);
1271 : 0 : }
1272 : : // -----------------------------------------------------------------------------
1273 : 0 : void ORptExport::exportReportAttributes(const Reference<XReportDefinition>& _xReport)
1274 : : {
1275 [ # # ]: 0 : if ( _xReport.is() )
1276 : : {
1277 : 0 : ::rtl::OUStringBuffer sValue;
1278 [ # # ]: 0 : const SvXMLEnumMapEntry* aXML_CommnadTypeEnumMap = OXMLHelper::GetCommandTypeOptions();
1279 [ # # ][ # # ]: 0 : if ( SvXMLUnitConverter::convertEnum( sValue, static_cast<sal_uInt16>(_xReport->getCommandType()),aXML_CommnadTypeEnumMap ) )
[ # # ][ # # ]
1280 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND_TYPE,sValue.makeStringAndClear());
1281 : :
1282 [ # # ][ # # ]: 0 : ::rtl::OUString sComamnd = _xReport->getCommand();
1283 [ # # ]: 0 : if ( !sComamnd.isEmpty() )
1284 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND, sComamnd);
1285 : :
1286 [ # # ][ # # ]: 0 : ::rtl::OUString sFilter( _xReport->getFilter() );
1287 [ # # ]: 0 : if ( !sFilter.isEmpty() )
1288 [ # # ]: 0 : AddAttribute( XML_NAMESPACE_REPORT, XML_FILTER, sFilter );
1289 : :
1290 [ # # ][ # # ]: 0 : AddAttribute(XML_NAMESPACE_OFFICE, XML_MIMETYPE,_xReport->getMimeType());
[ # # ]
1291 : :
1292 [ # # ][ # # ]: 0 : sal_Bool bEscapeProcessing( _xReport->getEscapeProcessing() );
1293 [ # # ]: 0 : if ( !bEscapeProcessing )
1294 [ # # ][ # # ]: 0 : AddAttribute( XML_NAMESPACE_REPORT, XML_ESCAPE_PROCESSING, ::xmloff::token::GetXMLToken( XML_FALSE ) );
1295 : :
1296 [ # # ][ # # ]: 0 : ::rtl::OUString sName = _xReport->getCaption();
1297 [ # # ]: 0 : if ( !sName.isEmpty() )
1298 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_OFFICE, XML_CAPTION,sName);
1299 [ # # ][ # # ]: 0 : sName = _xReport->getName();
1300 [ # # ]: 0 : if ( !sName.isEmpty() )
1301 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_DRAW, XML_NAME,sName);
1302 : : }
1303 : 0 : }
1304 : : // -----------------------------------------------------------------------------
1305 : 0 : void ORptExport::_ExportContent()
1306 : : {
1307 [ # # ]: 0 : exportReport(getReportDefinition());
1308 : 0 : }
1309 : : // -----------------------------------------------------------------------------
1310 : 0 : void ORptExport::_ExportMasterStyles()
1311 : : {
1312 [ # # ][ # # ]: 0 : GetPageExport()->exportMasterStyles( sal_True );
1313 : 0 : }
1314 : : // -----------------------------------------------------------------------------
1315 : 0 : void ORptExport::collectComponentStyles()
1316 : : {
1317 [ # # ]: 0 : if ( m_bAllreadyFilled )
1318 : 0 : return;
1319 : :
1320 : 0 : m_bAllreadyFilled = sal_True;
1321 [ # # ]: 0 : Reference<XReportDefinition> xProp(getReportDefinition());
1322 [ # # ]: 0 : if ( xProp.is() )
1323 : : {
1324 [ # # ][ # # ]: 0 : uno::Reference< report::XSection> xParent(xProp->getParent(),uno::UNO_QUERY);
[ # # ]
1325 [ # # ]: 0 : if ( xParent.is() )
1326 [ # # ][ # # ]: 0 : exportAutoStyle(xProp.get());
[ # # ]
1327 : :
1328 [ # # ][ # # ]: 0 : if ( xProp->getReportHeaderOn() )
[ # # ]
1329 [ # # ][ # # ]: 0 : exportSectionAutoStyle(xProp->getReportHeader());
[ # # ]
1330 [ # # ][ # # ]: 0 : if ( xProp->getPageHeaderOn() )
[ # # ]
1331 [ # # ][ # # ]: 0 : exportSectionAutoStyle(xProp->getPageHeader());
[ # # ]
1332 : :
1333 [ # # ]: 0 : exportGroup(xProp,0,sal_True);
1334 : :
1335 [ # # ][ # # ]: 0 : if ( xProp->getPageFooterOn() )
[ # # ]
1336 [ # # ][ # # ]: 0 : exportSectionAutoStyle(xProp->getPageFooter());
[ # # ]
1337 [ # # ][ # # ]: 0 : if ( xProp->getReportFooterOn() )
[ # # ]
1338 [ # # ][ # # ]: 0 : exportSectionAutoStyle(xProp->getReportFooter());
[ # # ]
1339 : 0 : }
1340 : : }
1341 : : // -----------------------------------------------------------------------------
1342 : 0 : void ORptExport::_ExportAutoStyles()
1343 : : {
1344 : : // there are no styles that require their own autostyles
1345 [ # # ]: 0 : if ( getExportFlags() & EXPORT_CONTENT )
1346 : : {
1347 : 0 : collectComponentStyles();
1348 : : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE
1349 : 0 : ,GetDocHandler()
1350 : 0 : ,GetMM100UnitConverter()
1351 : 0 : ,GetNamespaceMap()
1352 [ # # ][ # # ]: 0 : );
1353 : : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN
1354 : 0 : ,GetDocHandler()
1355 : 0 : ,GetMM100UnitConverter()
1356 : 0 : ,GetNamespaceMap()
1357 [ # # ][ # # ]: 0 : );
1358 : : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW
1359 : 0 : ,GetDocHandler()
1360 : 0 : ,GetMM100UnitConverter()
1361 : 0 : ,GetNamespaceMap()
1362 [ # # ][ # # ]: 0 : );
1363 : :
1364 : : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL
1365 : 0 : ,GetDocHandler()
1366 : 0 : ,GetMM100UnitConverter()
1367 : 0 : ,GetNamespaceMap()
1368 [ # # ][ # # ]: 0 : );
1369 : :
1370 : 0 : exportDataStyles();
1371 [ # # ][ # # ]: 0 : GetShapeExport()->exportAutoStyles();
1372 : : }
1373 : : // exported in _ExportMasterStyles
1374 [ # # ]: 0 : if( (getExportFlags() & EXPORT_MASTERSTYLES) != 0 )
1375 [ # # ][ # # ]: 0 : GetPageExport()->collectAutoStyles( sal_False );
1376 [ # # ]: 0 : if( (getExportFlags() & EXPORT_MASTERSTYLES) != 0 )
1377 [ # # ][ # # ]: 0 : GetPageExport()->exportAutoStyles();
1378 : 0 : }
1379 : : // -----------------------------------------------------------------------------
1380 : 0 : void ORptExport::_ExportStyles(sal_Bool bUsed)
1381 : : {
1382 : 0 : SvXMLExport::_ExportStyles(bUsed);
1383 : :
1384 : : // write draw:style-name for object graphic-styles
1385 [ # # ][ # # ]: 0 : GetShapeExport()->ExportGraphicDefaults();
1386 : 0 : }
1387 : : // -----------------------------------------------------------------------------
1388 : 0 : sal_uInt32 ORptExport::exportDoc(enum ::xmloff::token::XMLTokenEnum eClass)
1389 : : {
1390 : 0 : return SvXMLExport::exportDoc( eClass );
1391 : : }
1392 : : // -----------------------------------------------------------------------------
1393 : 0 : ::rtl::OUString ORptExport::implConvertNumber(sal_Int32 _nValue)
1394 : : {
1395 : 0 : ::rtl::OUStringBuffer aBuffer;
1396 [ # # ]: 0 : ::sax::Converter::convertNumber(aBuffer, _nValue);
1397 [ # # ]: 0 : return aBuffer.makeStringAndClear();
1398 : : }
1399 : : // -----------------------------------------------------------------------------
1400 : 0 : UniReference < XMLPropertySetMapper > ORptExport::GetCellStylePropertyMapper() const
1401 : : {
1402 : 0 : return m_xCellStylesPropertySetMapper;
1403 : : }
1404 : : // -----------------------------------------------------------------------------
1405 : 0 : SvXMLAutoStylePoolP* ORptExport::CreateAutoStylePool()
1406 : : {
1407 [ # # ]: 0 : return new OXMLAutoStylePoolP(*this);
1408 : : }
1409 : : // -----------------------------------------------------------------------------
1410 : 0 : void SAL_CALL ORptExport::setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException)
1411 : : {
1412 : 0 : m_xReportDefinition.set(xDoc,UNO_QUERY_THROW);
1413 : : OSL_ENSURE(m_xReportDefinition.is(),"DataSource is NULL!");
1414 : :
1415 : 0 : SvXMLExport::setSourceDocument(xDoc);
1416 : 0 : }
1417 : : // -----------------------------------------------------------------------------
1418 : 0 : void ORptExport::_ExportFontDecls()
1419 : : {
1420 : 0 : GetFontAutoStylePool(); // make sure the pool is created
1421 : 0 : collectComponentStyles();
1422 : 0 : SvXMLExport::_ExportFontDecls();
1423 : 0 : }
1424 : : // -----------------------------------------------------------------------------
1425 : 0 : void ORptExport::exportParagraph(const Reference< XReportControlModel >& _xReportElement)
1426 : : {
1427 : : OSL_PRECOND(_xReportElement.is(),"Element is null!");
1428 : : // start <text:p>
1429 [ # # ]: 0 : SvXMLElementExport aParagraphContent(*this,XML_NAMESPACE_TEXT, XML_P, sal_False, sal_False);
1430 [ # # ][ # # ]: 0 : if ( Reference<XFormattedField>(_xReportElement,uno::UNO_QUERY).is() )
1431 : : {
1432 [ # # ][ # # ]: 0 : ::rtl::OUString sFieldData = _xReportElement->getDataField();
1433 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()"));
[ # # ][ # # ]
1434 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()"));
[ # # ][ # # ]
1435 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sReportPrefix(RTL_CONSTASCII_USTRINGPARAM("rpt:"));
[ # # ][ # # ]
1436 : 0 : sFieldData = sFieldData.copy(s_sReportPrefix.getLength(),sFieldData.getLength() - s_sReportPrefix.getLength());
1437 : 0 : sal_Int32 nPageNumberIndex = sFieldData.indexOf(s_sPageNumber);
1438 [ # # ]: 0 : if ( nPageNumberIndex != -1 )
1439 : : {
1440 : 0 : sal_Int32 nIndex = 0;
1441 [ # # ]: 0 : do
1442 : : {
1443 : 0 : ::rtl::OUString sToken = sFieldData.getToken( 0, '&', nIndex );
1444 : 0 : sToken = sToken.trim();
1445 [ # # ]: 0 : if ( !sToken.isEmpty() )
1446 : : {
1447 [ # # ]: 0 : if ( sToken == s_sPageNumber )
1448 : : {
1449 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sCurrent(RTL_CONSTASCII_USTRINGPARAM("current"));
[ # # ][ # # ]
1450 [ # # ]: 0 : AddAttribute(XML_NAMESPACE_TEXT, XML_SELECT_PAGE, s_sCurrent );
1451 [ # # ]: 0 : SvXMLElementExport aPageNumber(*this,XML_NAMESPACE_TEXT, XML_PAGE_NUMBER, sal_False, sal_False);
1452 [ # # ][ # # ]: 0 : Characters(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1")));
[ # # ]
1453 : : }
1454 [ # # ]: 0 : else if ( sToken == s_sPageCount )
1455 : : {
1456 [ # # ]: 0 : SvXMLElementExport aPageNumber(*this,XML_NAMESPACE_TEXT, XML_PAGE_COUNT, sal_False, sal_False);
1457 [ # # ][ # # ]: 0 : Characters(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1")));
[ # # ]
1458 : : }
1459 : : else
1460 : : {
1461 : :
1462 [ # # ][ # # ]: 0 : if ( sToken.indexOf('"') == 0 && sToken.lastIndexOf('"') == sToken.getLength()-1 )
[ # # ]
1463 : 0 : sToken = sToken.copy(1,sToken.getLength()-2);
1464 : :
1465 : 0 : bool bPrevCharIsSpace = false;
1466 [ # # ][ # # ]: 0 : GetTextParagraphExport()->exportText(sToken,bPrevCharIsSpace);
[ # # ][ # # ]
1467 : : }
1468 : 0 : }
1469 : : }
1470 : : while ( nIndex >= 0 );
1471 : 0 : }
1472 : : }
1473 [ # # ]: 0 : Reference< XFixedText > xFT(_xReportElement,UNO_QUERY);
1474 [ # # ]: 0 : if ( xFT.is() )
1475 : : {
1476 [ # # ][ # # ]: 0 : ::rtl::OUString sExpr = xFT->getLabel();
1477 : 0 : bool bPrevCharIsSpace = false;
1478 [ # # ][ # # ]: 0 : GetTextParagraphExport()->exportText(sExpr,bPrevCharIsSpace);
[ # # ][ # # ]
1479 [ # # ]: 0 : }
1480 : 0 : }
1481 : : // -----------------------------------------------------------------------------
1482 : 0 : XMLShapeExport* ORptExport::CreateShapeExport()
1483 : : {
1484 [ # # ]: 0 : XMLShapeExport* pShapeExport = new XMLShapeExport( *this, XMLTextParagraphExport::CreateShapeExtPropMapper( *this ) );
1485 : 0 : return pShapeExport;
1486 : : }
1487 : : // -----------------------------------------------------------------------------
1488 : 0 : void ORptExport::exportShapes(const Reference< XSection>& _xSection,bool _bAddParagraph)
1489 : : {
1490 [ # # ]: 0 : UniReference< XMLShapeExport > xShapeExport = GetShapeExport();
1491 [ # # ][ # # ]: 0 : xShapeExport->seekShapes(_xSection.get());
[ # # ][ # # ]
1492 [ # # ][ # # ]: 0 : const sal_Int32 nCount = _xSection->getCount();
1493 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1494 : 0 : ::std::auto_ptr<SvXMLElementExport> pParagraphContent;
1495 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1496 [ # # ]: 0 : if ( _bAddParagraph )
1497 [ # # ][ # # ]: 0 : pParagraphContent.reset(new SvXMLElementExport(*this,XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False));
1498 : :
1499 : 0 : awt::Point aRefPoint;
1500 [ # # ][ # # ]: 0 : aRefPoint.X = rptui::getStyleProperty<sal_Int32>(_xSection->getReportDefinition(),PROPERTY_LEFTMARGIN);
[ # # ][ # # ]
1501 [ # # ]: 0 : for (sal_Int32 i = 0; i < nCount; ++i)
1502 : : {
1503 [ # # ][ # # ]: 0 : uno::Reference< XShape > xShape(_xSection->getByIndex(i),uno::UNO_QUERY);
[ # # ]
1504 [ # # ]: 0 : if ( xShape.is() )
1505 : : {
1506 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1507 : 0 : ::std::auto_ptr<SvXMLElementExport> pSubDocument;
1508 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1509 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel> xModel(xShape->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model"))),uno::UNO_QUERY);
[ # # ][ # # ]
1510 [ # # ]: 0 : if ( xModel.is() ) // special handling for chart object
1511 : : {
1512 [ # # ][ # # ]: 0 : pSubDocument.reset(new SvXMLElementExport(*this,XML_NAMESPACE_REPORT, XML_SUB_DOCUMENT, sal_False, sal_False));
1513 [ # # ][ # # ]: 0 : exportMasterDetailFields(xShape.get());
[ # # ]
1514 [ # # ][ # # ]: 0 : exportReportElement(xShape.get());
[ # # ]
1515 : : }
1516 : :
1517 [ # # ]: 0 : AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, XML_PARAGRAPH );
1518 [ # # ][ # # ]: 0 : xShapeExport->exportShape(xShape.get(),SEF_DEFAULT|SEF_EXPORT_NO_WS,&aRefPoint);
[ # # ][ # # ]
[ # # ][ # # ]
1519 : : }
1520 [ # # ][ # # ]: 0 : }
1521 : 0 : }
1522 : : // -----------------------------------------------------------------------------
1523 : 0 : void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xGroups)
1524 : : {
1525 [ # # ]: 0 : if ( _xGroups.is() )
1526 : : {
1527 [ # # ][ # # ]: 0 : uno::Reference< XFunctions> xFunctions = _xGroups->getReportDefinition()->getFunctions();
[ # # ][ # # ]
1528 [ # # ][ # # ]: 0 : const sal_Int32 nCount = _xGroups->getCount();
1529 [ # # ]: 0 : for (sal_Int32 i = 0; i < nCount; ++i)
1530 : : {
1531 [ # # ][ # # ]: 0 : uno::Reference< XGroup> xGroup(_xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
[ # # ]
1532 [ # # ][ # # ]: 0 : const ::sal_Int16 nGroupOn = xGroup->getGroupOn();
1533 [ # # ]: 0 : if ( nGroupOn != report::GroupOn::DEFAULT )
1534 : : {
1535 [ # # ][ # # ]: 0 : uno::Reference< XFunction> xFunction = xFunctions->createFunction();
1536 : 0 : ::rtl::OUString sFunction,sPrefix,sPostfix;
1537 [ # # ][ # # ]: 0 : ::rtl::OUString sExpression = xGroup->getExpression();
1538 : 0 : ::rtl::OUString sFunctionName;
1539 [ # # # # : 0 : switch(nGroupOn)
# # # # #
# ]
1540 : : {
1541 : : case report::GroupOn::PREFIX_CHARACTERS:
1542 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LEFT"));
1543 [ # # ][ # # ]: 0 : sPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";")) + ::rtl::OUString::valueOf(xGroup->getGroupInterval());
[ # # ]
1544 : 0 : break;
1545 : : case report::GroupOn::YEAR:
1546 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("YEAR"));
1547 : 0 : break;
1548 : : case report::GroupOn::QUARTAL:
1549 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INT((MONTH"));
1550 [ # # ]: 0 : sPostfix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-1)/3)+1"));
1551 [ # # ]: 0 : sFunctionName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QUARTAL_")) + sExpression;
1552 : 0 : break;
1553 : : case report::GroupOn::MONTH:
1554 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MONTH"));
1555 : 0 : break;
1556 : : case report::GroupOn::WEEK:
1557 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WEEK"));
1558 : 0 : break;
1559 : : case report::GroupOn::DAY:
1560 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DAY"));
1561 : 0 : break;
1562 : : case report::GroupOn::HOUR:
1563 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HOUR"));
1564 : 0 : break;
1565 : : case report::GroupOn::MINUTE:
1566 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MINUTE"));
1567 : 0 : break;
1568 : : case report::GroupOn::INTERVAL:
1569 : : {
1570 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INT"));
1571 [ # # ][ # # ]: 0 : uno::Reference< XFunction> xCountFunction = xFunctions->createFunction();
1572 [ # # ][ # # ]: 0 : xCountFunction->setInitialFormula(beans::Optional< ::rtl::OUString>(sal_True,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:1"))));
[ # # ]
1573 [ # # ]: 0 : ::rtl::OUString sCountName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_count_")) + sExpression;
1574 [ # # ][ # # ]: 0 : xCountFunction->setName(sCountName);
1575 [ # # ][ # # ]: 0 : xCountFunction->setFormula(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[")) + sCountName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("] + 1")));
[ # # ][ # # ]
1576 [ # # ]: 0 : exportFunction(xCountFunction);
1577 : 0 : sExpression = sCountName;
1578 [ # # ][ # # ]: 0 : sPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" / ")) + ::rtl::OUString::valueOf(xGroup->getGroupInterval());
[ # # ]
1579 [ # # ]: 0 : sFunctionName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression;
1580 : : }
1581 : 0 : break;
1582 : : default:
1583 : : ;
1584 : : }
1585 [ # # ]: 0 : if ( sFunctionName.isEmpty() )
1586 [ # # ]: 0 : sFunctionName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression;
1587 [ # # ]: 0 : if ( !sFunction.isEmpty() )
1588 : : {
1589 : 0 : sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'};
1590 [ # # ]: 0 : for(sal_uInt32 j= 0; j < sizeof(pReplaceChars)/sizeof(pReplaceChars[0]);++j)
1591 : 0 : sFunctionName = sFunctionName.replace(pReplaceChars[j],'_');
1592 : :
1593 [ # # ][ # # ]: 0 : xFunction->setName(sFunctionName);
1594 [ # # ]: 0 : sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + sFunction;
1595 [ # # ]: 0 : sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("(["));
1596 : 0 : sFunction += sExpression;
1597 [ # # ]: 0 : sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("]"));
1598 : :
1599 [ # # ]: 0 : if ( !sPrefix.isEmpty() )
1600 : 0 : sFunction += sPrefix;
1601 [ # # ]: 0 : sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
1602 [ # # ]: 0 : if ( !sPostfix.isEmpty() )
1603 : 0 : sFunction += sPostfix;
1604 [ # # ][ # # ]: 0 : xFunction->setFormula(sFunction);
1605 [ # # ]: 0 : exportFunction(xFunction);
1606 [ # # ][ # # ]: 0 : m_aGroupFunctionMap.insert(TGroupFunctionMap::value_type(xGroup,xFunction));
[ # # ]
1607 : 0 : }
1608 : : }
1609 : 0 : }
1610 : : }
1611 : 0 : }
1612 : :
1613 : : // -----------------------------------------------------------------------------
1614 [ + - ][ + - ]: 18 : }// rptxml
1615 : : // -----------------------------------------------------------------------------
1616 : :
1617 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|