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

Generated by: LCOV version 1.10