LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/reportdesign/source/filter/xml - xmlExport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 944 0.0 %
Date: 2013-07-09 Functions: 0 66 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10