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