LCOV - code coverage report
Current view: top level - reportdesign/source/core/api - ReportDefinition.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 3 1447 0.2 %
Date: 2014-11-03 Functions: 3 221 1.4 %
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 <sal/config.h>
      21             : 
      22             : #include <vector>
      23             : 
      24             : #include "ReportDefinition.hxx"
      25             : 
      26             : #include "FixedLine.hxx"
      27             : #include "FixedText.hxx"
      28             : #include "FormattedField.hxx"
      29             : #include "Functions.hxx"
      30             : #include "Groups.hxx"
      31             : #include "ImageControl.hxx"
      32             : #include "ReportComponent.hxx"
      33             : #include "ReportHelperImpl.hxx"
      34             : #include "RptDef.hxx"
      35             : #include "RptModel.hxx"
      36             : #include "Section.hxx"
      37             : #include "Shape.hxx"
      38             : #include "Tools.hxx"
      39             : #include "UndoEnv.hxx"
      40             : #include "core_resource.hrc"
      41             : #include "core_resource.hxx"
      42             : #include "corestrings.hrc"
      43             : 
      44             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      45             : #include <com/sun/star/beans/XMultiPropertyStates.hpp>
      46             : #include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
      47             : #include <com/sun/star/document/DocumentProperties.hpp>
      48             : #include <com/sun/star/document/IndexedPropertyValues.hpp>
      49             : #include <com/sun/star/document/EventObject.hpp>
      50             : #include <com/sun/star/document/XEventListener.hpp>
      51             : #include <com/sun/star/document/XExporter.hpp>
      52             : #include <com/sun/star/document/XFilter.hpp>
      53             : #include <com/sun/star/document/XImporter.hpp>
      54             : #include <com/sun/star/embed/Aspects.hpp>
      55             : #include <com/sun/star/embed/ElementModes.hpp>
      56             : #include <com/sun/star/embed/EmbedMapUnits.hpp>
      57             : #include <com/sun/star/embed/EntryInitModes.hpp>
      58             : #include <com/sun/star/embed/XEmbedPersist.hpp>
      59             : #include <com/sun/star/embed/XTransactedObject.hpp>
      60             : #include <com/sun/star/embed/StorageFactory.hpp>
      61             : #include <com/sun/star/frame/Desktop.hpp>
      62             : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      63             : #include <com/sun/star/frame/XComponentLoader.hpp>
      64             : #include <com/sun/star/io/XActiveDataSource.hpp>
      65             : #include <com/sun/star/io/XSeekable.hpp>
      66             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      67             : #include <com/sun/star/report/GroupKeepTogether.hpp>
      68             : #include <com/sun/star/report/ReportPrintOption.hpp>
      69             : #include <com/sun/star/report/XFunction.hpp>
      70             : #include <com/sun/star/sdb/CommandType.hpp>
      71             : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
      72             : #include <com/sun/star/style/GraphicLocation.hpp>
      73             : #include <com/sun/star/style/NumberingType.hpp>
      74             : #include <com/sun/star/style/PageStyleLayout.hpp>
      75             : #include <com/sun/star/style/XStyle.hpp>
      76             : #include <com/sun/star/table/BorderLine2.hpp>
      77             : #include <com/sun/star/table/ShadowFormat.hpp>
      78             : #include <com/sun/star/task/InteractionHandler.hpp>
      79             : #include <com/sun/star/task/XStatusIndicator.hpp>
      80             : #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
      81             : #include <com/sun/star/ui/UIConfigurationManager.hpp>
      82             : #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
      83             : #include <com/sun/star/util/NumberFormatsSupplier.hpp>
      84             : #include <com/sun/star/xml/AttributeData.hpp>
      85             : #include <com/sun/star/xml/sax/Writer.hpp>
      86             : 
      87             : #include <comphelper/broadcasthelper.hxx>
      88             : #include <comphelper/documentconstants.hxx>
      89             : #include <comphelper/genericpropertyset.hxx>
      90             : #include <unotools/mediadescriptor.hxx>
      91             : #include <comphelper/mimeconfighelper.hxx>
      92             : #include <comphelper/namecontainer.hxx>
      93             : #include <comphelper/namedvaluecollection.hxx>
      94             : #include <comphelper/numberedcollection.hxx>
      95             : #include <comphelper/proparrhlp.hxx>
      96             : #include <comphelper/property.hxx>
      97             : #include <comphelper/propertysetinfo.hxx>
      98             : #include <comphelper/propertystatecontainer.hxx>
      99             : #include <comphelper/seqstream.hxx>
     100             : #include <comphelper/sequence.hxx>
     101             : #include <comphelper/storagehelper.hxx>
     102             : #include <comphelper/uno3.hxx>
     103             : #include <connectivity/CommonTools.hxx>
     104             : #include <connectivity/dbconversion.hxx>
     105             : #include <connectivity/dbtools.hxx>
     106             : #include <cppuhelper/exc_hlp.hxx>
     107             : #include <cppuhelper/interfacecontainer.h>
     108             : #include <cppuhelper/supportsservice.hxx>
     109             : #include <dbaccess/dbaundomanager.hxx>
     110             : #include <editeng/paperinf.hxx>
     111             : #include <framework/titlehelper.hxx>
     112             : #include <salhelper/thread.hxx>
     113             : #include <svl/itempool.hxx>
     114             : #include <svl/undo.hxx>
     115             : #include <svx/svdlayer.hxx>
     116             : #include <svx/unofill.hxx>
     117             : #include <svx/xmleohlp.hxx>
     118             : #include <svx/xmlgrhlp.hxx>
     119             : #include <tools/debug.hxx>
     120             : #include <tools/diagnose_ex.h>
     121             : #include <unotools/moduleoptions.hxx>
     122             : #include <unotools/saveopt.hxx>
     123             : #include <unotools/streamwrap.hxx>
     124             : #include <vcl/svapp.hxx>
     125             : #include <vcl/virdev.hxx>
     126             : 
     127             : #include <boost/bind.hpp>
     128             : #include <boost/mem_fn.hpp>
     129             : #include <boost/noncopyable.hpp>
     130             : #include <boost/utility.hpp>
     131             : 
     132             : //  page styles
     133             : #define SC_UNO_PAGE_LEFTBORDER      "LeftBorder"
     134             : #define SC_UNO_PAGE_RIGHTBORDER     "RightBorder"
     135             : #define SC_UNO_PAGE_BOTTBORDER      "BottomBorder"
     136             : #define SC_UNO_PAGE_TOPBORDER       "TopBorder"
     137             : #define SC_UNO_PAGE_LEFTBRDDIST     "LeftBorderDistance"
     138             : #define SC_UNO_PAGE_RIGHTBRDDIST    "RightBorderDistance"
     139             : #define SC_UNO_PAGE_BOTTBRDDIST     "BottomBorderDistance"
     140             : #define SC_UNO_PAGE_TOPBRDDIST      "TopBorderDistance"
     141             : #define SC_UNO_PAGE_BORDERDIST      "BorderDistance"
     142             : #define SC_UNO_PAGE_SHADOWFORM      "ShadowFormat"
     143             : #define SC_UNO_PAGE_PAPERTRAY       "PrinterPaperTray"
     144             : #define SC_UNO_PAGE_SCALEVAL        "PageScale"
     145             : #define SC_UNO_PAGE_SCALETOPAG      "ScaleToPages"
     146             : #define SC_UNO_PAGE_SCALETOX        "ScaleToPagesX"
     147             : #define SC_UNO_PAGE_SCALETOY        "ScaleToPagesY"
     148             : #define SC_UNO_PAGE_HDRBACKCOL      "HeaderBackColor"
     149             : #define SC_UNO_PAGE_HDRBACKTRAN     "HeaderBackTransparent"
     150             : #define SC_UNO_PAGE_HDRGRFFILT      "HeaderBackGraphicFilter"
     151             : #define SC_UNO_PAGE_HDRGRFLOC       "HeaderBackGraphicLocation"
     152             : #define SC_UNO_PAGE_HDRGRFURL       "HeaderBackGraphicURL"
     153             : #define SC_UNO_PAGE_HDRLEFTBOR      "HeaderLeftBorder"
     154             : #define SC_UNO_PAGE_HDRRIGHTBOR     "HeaderRightBorder"
     155             : #define SC_UNO_PAGE_HDRBOTTBOR      "HeaderBottomBorder"
     156             : #define SC_UNO_PAGE_HDRTOPBOR       "HeaderTopBorder"
     157             : #define SC_UNO_PAGE_HDRLEFTBDIS     "HeaderLeftBorderDistance"
     158             : #define SC_UNO_PAGE_HDRRIGHTBDIS    "HeaderRightBorderDistance"
     159             : #define SC_UNO_PAGE_HDRBOTTBDIS     "HeaderBottomBorderDistance"
     160             : #define SC_UNO_PAGE_HDRTOPBDIS      "HeaderTopBorderDistance"
     161             : #define SC_UNO_PAGE_HDRBRDDIST      "HeaderBorderDistance"
     162             : #define SC_UNO_PAGE_HDRSHADOW       "HeaderShadowFormat"
     163             : #define SC_UNO_PAGE_HDRLEFTMAR      "HeaderLeftMargin"
     164             : #define SC_UNO_PAGE_HDRRIGHTMAR     "HeaderRightMargin"
     165             : #define SC_UNO_PAGE_HDRBODYDIST     "HeaderBodyDistance"
     166             : #define SC_UNO_PAGE_HDRHEIGHT       "HeaderHeight"
     167             : #define SC_UNO_PAGE_HDRON           "HeaderIsOn"
     168             : #define SC_UNO_PAGE_HDRDYNAMIC      "HeaderIsDynamicHeight"
     169             : #define SC_UNO_PAGE_HDRSHARED       "HeaderIsShared"
     170             : #define SC_UNO_PAGE_FTRBACKCOL      "FooterBackColor"
     171             : #define SC_UNO_PAGE_FTRBACKTRAN     "FooterBackTransparent"
     172             : #define SC_UNO_PAGE_FTRGRFFILT      "FooterBackGraphicFilter"
     173             : #define SC_UNO_PAGE_FTRGRFLOC       "FooterBackGraphicLocation"
     174             : #define SC_UNO_PAGE_FTRGRFURL       "FooterBackGraphicURL"
     175             : #define SC_UNO_PAGE_FTRLEFTBOR      "FooterLeftBorder"
     176             : #define SC_UNO_PAGE_FTRRIGHTBOR     "FooterRightBorder"
     177             : #define SC_UNO_PAGE_FTRBOTTBOR      "FooterBottomBorder"
     178             : #define SC_UNO_PAGE_FTRTOPBOR       "FooterTopBorder"
     179             : #define SC_UNO_PAGE_FTRLEFTBDIS     "FooterLeftBorderDistance"
     180             : #define SC_UNO_PAGE_FTRRIGHTBDIS    "FooterRightBorderDistance"
     181             : #define SC_UNO_PAGE_FTRBOTTBDIS     "FooterBottomBorderDistance"
     182             : #define SC_UNO_PAGE_FTRTOPBDIS      "FooterTopBorderDistance"
     183             : #define SC_UNO_PAGE_FTRBRDDIST      "FooterBorderDistance"
     184             : #define SC_UNO_PAGE_FTRSHADOW       "FooterShadowFormat"
     185             : #define SC_UNO_PAGE_FTRLEFTMAR      "FooterLeftMargin"
     186             : #define SC_UNO_PAGE_FTRRIGHTMAR     "FooterRightMargin"
     187             : #define SC_UNO_PAGE_FTRBODYDIST     "FooterBodyDistance"
     188             : #define SC_UNO_PAGE_FTRHEIGHT       "FooterHeight"
     189             : #define SC_UNO_PAGE_FTRON           "FooterIsOn"
     190             : #define SC_UNO_PAGE_FTRDYNAMIC      "FooterIsDynamicHeight"
     191             : #define SC_UNO_PAGE_FTRSHARED       "FooterIsShared"
     192             : 
     193             : namespace reportdesign
     194             : {
     195             :     using namespace com::sun::star;
     196             :     using namespace comphelper;
     197             :     using namespace rptui;
     198             : 
     199           0 : void lcl_setModelReadOnly(const uno::Reference< embed::XStorage >& _xStorage,::boost::shared_ptr<rptui::OReportModel>& _rModel)
     200             : {
     201           0 :     uno::Reference<beans::XPropertySet> xProp(_xStorage,uno::UNO_QUERY);
     202           0 :     sal_Int32 nOpenMode = embed::ElementModes::READ;
     203           0 :     if ( xProp.is() )
     204           0 :         xProp->getPropertyValue("OpenMode") >>= nOpenMode;
     205             : 
     206           0 :     _rModel->SetReadOnly((nOpenMode & embed::ElementModes::WRITE) != embed::ElementModes::WRITE);
     207           0 : }
     208           0 : void lcl_stripLoadArguments( utl::MediaDescriptor& _rDescriptor, uno::Sequence< beans::PropertyValue >& _rArgs )
     209             : {
     210           0 :     _rDescriptor.erase( OUString( "StatusIndicator" ) );
     211           0 :     _rDescriptor.erase( OUString( "InteractionHandler" ) );
     212           0 :     _rDescriptor.erase( OUString( "Model" ) );
     213           0 :     _rDescriptor >> _rArgs;
     214           0 : }
     215             : 
     216           0 : void lcl_extractAndStartStatusIndicator( const utl::MediaDescriptor& _rDescriptor, uno::Reference< task::XStatusIndicator >& _rxStatusIndicator,
     217             :     uno::Sequence< uno::Any >& _rCallArgs )
     218             : {
     219             :     try
     220             :     {
     221           0 :         _rxStatusIndicator = _rDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STATUSINDICATOR(), _rxStatusIndicator );
     222           0 :         if ( _rxStatusIndicator.is() )
     223             :         {
     224           0 :             _rxStatusIndicator->start( OUString(), (sal_Int32)1000000 );
     225             : 
     226           0 :             sal_Int32 nLength = _rCallArgs.getLength();
     227           0 :             _rCallArgs.realloc( nLength + 1 );
     228           0 :             _rCallArgs[ nLength ] <<= _rxStatusIndicator;
     229             :         }
     230             :     }
     231           0 :     catch (const uno::Exception&)
     232             :     {
     233             :         OSL_FAIL( "lcl_extractAndStartStatusIndicator: caught an exception!" );
     234             :     }
     235           0 : }
     236             : 
     237             : typedef ::comphelper::OPropertyStateContainer       OStyle_PBASE;
     238             : class OStyle;
     239             : typedef ::comphelper::OPropertyArrayUsageHelper <   OStyle
     240             :                                                 >   OStyle_PABASE;
     241             : typedef ::cppu::WeakImplHelper2< style::XStyle, beans::XMultiPropertyStates> TStyleBASE;
     242             : 
     243             : class OStyle :   public ::comphelper::OMutexAndBroadcastHelper
     244             :                 ,public TStyleBASE
     245             :                 ,public OStyle_PBASE
     246             :                 ,public OStyle_PABASE
     247             : {
     248             :     awt::Size m_aSize;
     249             : 
     250             : protected:
     251             :     void getPropertyDefaultByHandle( sal_Int32 _nHandle, uno::Any& _rDefault ) const SAL_OVERRIDE;
     252           0 :     virtual ~OStyle(){}
     253             : public:
     254             :     OStyle();
     255             : 
     256             : 
     257             :     DECLARE_XINTERFACE( )
     258             : 
     259             :     // XPropertySet
     260             :     com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo>  SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     261             :     ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
     262             :     ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
     263             : 
     264             :     // XStyle
     265             :     sal_Bool SAL_CALL isUserDefined(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     266             :     sal_Bool SAL_CALL isInUse(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     267             :     OUString SAL_CALL getParentStyle(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     268             :     void SAL_CALL setParentStyle( const OUString& aParentStyle ) throw (container::NoSuchElementException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     269             : 
     270             :     // XNamed
     271             :     OUString SAL_CALL getName(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     272             :     void SAL_CALL setName( const OUString& aName ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     273             : 
     274             :     // XMultiPropertyState
     275           0 :     uno::Sequence< beans::PropertyState > SAL_CALL getPropertyStates( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception) SAL_OVERRIDE
     276             :     {
     277           0 :         return OStyle_PBASE::getPropertyStates(aPropertyNames);
     278             :     }
     279             :     void SAL_CALL setAllPropertiesToDefault(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     280             :     void SAL_CALL setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     281             :     uno::Sequence< uno::Any > SAL_CALL getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     282             : };
     283             : 
     284           0 : OStyle::OStyle()
     285             : :OStyle_PBASE(m_aBHelper)
     286           0 : ,m_aSize(21000,29700)
     287             : {
     288           0 :     const ::Size aDefaultSize = SvxPaperInfo::GetDefaultPaperSize( MAP_100TH_MM );
     289           0 :     m_aSize.Height = aDefaultSize.Height();
     290           0 :     m_aSize.Width = aDefaultSize.Width();
     291             : 
     292           0 :     const style::GraphicLocation eGraphicLocation = style::GraphicLocation_NONE;
     293           0 :     const sal_Bool bFalse = sal_False;
     294           0 :     const sal_Bool bTrue = sal_True;
     295           0 :     const sal_Int32 nMargin = 2000;
     296             :     //const sal_Int32 nColor = COL_WHITE;
     297           0 :     const sal_Int32 nTransparent = COL_TRANSPARENT;
     298           0 :     const sal_Int32 nZero = 0;
     299           0 :     const sal_Int16 n16Zero = 0;
     300           0 :     const sal_Int16 nNummeringType = style::NumberingType::ARABIC;
     301           0 :     const OUString sName("Default");
     302           0 :     const OUString sEmpty;
     303           0 :     const table::BorderLine2 eBorderLine(0,0,0,0,0,0);
     304           0 :     const table::ShadowFormat eShadowFormat(table::ShadowLocation_NONE,0,0,0);
     305           0 :     const style::PageStyleLayout ePageStyleLayout = style::PageStyleLayout_ALL;
     306           0 :     const sal_Int32 nBound = beans::PropertyAttribute::BOUND;
     307           0 :     const sal_Int32 nMayBeVoid = beans::PropertyAttribute::MAYBEVOID;
     308             : 
     309           0 :     sal_Int32 i = 0;
     310           0 :     registerPropertyNoMember( PROPERTY_NAME, ++i, nBound, cppu::UnoType<OUString>::get(), &sName );
     311             : 
     312           0 :     registerPropertyNoMember(PROPERTY_BACKCOLOR,                    ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nTransparent);
     313             : 
     314           0 :     registerPropertyNoMember(PROPERTY_BACKGRAPHICLOCATION,  ++i,nBound, cppu::UnoType<style::GraphicLocation>::get(), &eGraphicLocation);
     315           0 :     registerPropertyNoMember(PROPERTY_BACKTRANSPARENT,  ++i,nBound,::getBooleanCppuType() ,&bTrue);
     316           0 :     registerPropertyNoMember(SC_UNO_PAGE_BORDERDIST,  ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     317           0 :     registerPropertyNoMember(SC_UNO_PAGE_BOTTBORDER,  ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     318           0 :     registerPropertyNoMember(SC_UNO_PAGE_BOTTBRDDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     319           0 :     registerPropertyNoMember(PROPERTY_BOTTOMMARGIN, ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nMargin);
     320           0 :     registerPropertyNoMember("DisplayName",       ++i,nBound, cppu::UnoType<OUString>::get(), &sEmpty);
     321           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRBACKCOL,  ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nTransparent);
     322           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRGRFFILT,  ++i,nBound, cppu::UnoType<OUString>::get(), &sEmpty);
     323           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRGRFLOC,   ++i,nBound, cppu::UnoType<style::GraphicLocation>::get(), &eGraphicLocation);
     324           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRGRFURL,   ++i,nBound, cppu::UnoType<OUString>::get(), &sEmpty);
     325           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRBACKTRAN, ++i,nBound,::getBooleanCppuType() ,&bTrue);
     326           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRBODYDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     327           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRBRDDIST,  ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     328           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBOR,  ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     329           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRBOTTBDIS, ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     330           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRHEIGHT,   ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     331           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRDYNAMIC,  ++i,nBound,::getBooleanCppuType() ,&bFalse);
     332           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRON,       ++i,nBound,::getBooleanCppuType() ,&bFalse);
     333           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRSHARED,   ++i,nBound,::getBooleanCppuType() ,&bFalse);
     334           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBOR,  ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     335           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTBDIS, ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     336           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRLEFTMAR,  ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     337           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBOR, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     338           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTBDIS,++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     339           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRRIGHTMAR, ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     340           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRSHADOW,   ++i,nBound, cppu::UnoType<table::ShadowFormat>::get(), &eShadowFormat);
     341           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBOR,   ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     342           0 :     registerPropertyNoMember(SC_UNO_PAGE_FTRTOPBDIS,  ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     343             : 
     344           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRBACKCOL,  ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nTransparent);
     345           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRGRFFILT,  ++i,nBound|nMayBeVoid, cppu::UnoType<OUString>::get(), &sEmpty);
     346           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRGRFLOC,   ++i,nBound|nMayBeVoid, cppu::UnoType<style::GraphicLocation>::get(), &eGraphicLocation);
     347           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRGRFURL,   ++i,nBound|nMayBeVoid, cppu::UnoType<OUString>::get(), &sEmpty);
     348           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRBACKTRAN, ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bTrue);
     349           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRBODYDIST, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     350           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRBRDDIST,  ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     351           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBOR,  ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     352           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRBOTTBDIS, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     353           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRHEIGHT,   ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     354           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRDYNAMIC,  ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bFalse);
     355           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRON,       ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bFalse);
     356           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRSHARED,   ++i,nBound|nMayBeVoid,::getBooleanCppuType() ,&bFalse);
     357           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBOR,  ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     358           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTBDIS, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     359           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRLEFTMAR,  ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     360           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBOR, ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     361           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTBDIS,++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     362           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRRIGHTMAR, ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     363           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRSHADOW,   ++i,nBound|nMayBeVoid, cppu::UnoType<table::ShadowFormat>::get(), &eShadowFormat);
     364           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBOR,   ++i,nBound|nMayBeVoid, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     365           0 :     registerPropertyNoMember(SC_UNO_PAGE_HDRTOPBDIS,  ++i,nBound|nMayBeVoid, cppu::UnoType<sal_Int32>::get(), &nZero);
     366             : 
     367           0 :     registerProperty(PROPERTY_HEIGHT,       ++i,nBound,&m_aSize.Height,     ::cppu::UnoType<sal_Int32>::get() );
     368           0 :     registerPropertyNoMember(PROPERTY_ISLANDSCAPE,                  ++i,nBound,         ::getBooleanCppuType() ,&bFalse);
     369           0 :     registerPropertyNoMember(SC_UNO_PAGE_LEFTBORDER,  ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     370           0 :     registerPropertyNoMember(SC_UNO_PAGE_LEFTBRDDIST, ++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     371           0 :     registerPropertyNoMember(PROPERTY_LEFTMARGIN,   ++i,beans::PropertyAttribute::BOUND,        ::cppu::UnoType<sal_Int32>::get(), &nMargin);
     372           0 :     registerPropertyNoMember(PROPERTY_NUMBERINGTYPE,                ++i,nBound, cppu::UnoType<sal_Int16>::get(), &nNummeringType);
     373           0 :     registerPropertyNoMember(SC_UNO_PAGE_SCALEVAL,    ++i,nBound, cppu::UnoType<sal_Int16>::get(), &n16Zero);
     374           0 :     registerPropertyNoMember(PROPERTY_PAGESTYLELAYOUT,              ++i,nBound, cppu::UnoType<style::PageStyleLayout>::get(), &ePageStyleLayout);
     375           0 :     const OUString sPaperTray("[From printer settings]");
     376           0 :     registerPropertyNoMember(SC_UNO_PAGE_PAPERTRAY,   ++i,nBound, cppu::UnoType<OUString>::get(), &sPaperTray);
     377           0 :     registerPropertyNoMember(SC_UNO_PAGE_RIGHTBORDER, ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     378           0 :     registerPropertyNoMember(SC_UNO_PAGE_RIGHTBRDDIST,++i,nBound, cppu::UnoType<sal_Int32>::get(), &nZero);
     379           0 :     registerPropertyNoMember(PROPERTY_RIGHTMARGIN,  ++i,beans::PropertyAttribute::BOUND,::cppu::UnoType<sal_Int32>::get(), &nMargin);
     380           0 :     registerPropertyNoMember(SC_UNO_PAGE_SCALETOPAG,  ++i,nBound, cppu::UnoType<sal_Int16>::get(), &n16Zero);
     381           0 :     registerPropertyNoMember(SC_UNO_PAGE_SCALETOX,    ++i,nBound, cppu::UnoType<sal_Int16>::get(), &n16Zero);
     382           0 :     registerPropertyNoMember(SC_UNO_PAGE_SCALETOY,    ++i,nBound, cppu::UnoType<sal_Int16>::get(), &n16Zero);
     383           0 :     registerPropertyNoMember(SC_UNO_PAGE_SHADOWFORM,  ++i,nBound, cppu::UnoType<table::ShadowFormat>::get(), &eShadowFormat);
     384           0 :     registerProperty(PROPERTY_PAPERSIZE,                    ++i,beans::PropertyAttribute::BOUND,&m_aSize, cppu::UnoType<awt::Size>::get() );
     385           0 :     registerPropertyNoMember(SC_UNO_PAGE_TOPBORDER,   ++i,nBound, cppu::UnoType<table::BorderLine2>::get(), &eBorderLine);
     386           0 :     registerPropertyNoMember(SC_UNO_PAGE_TOPBRDDIST,  ++i,nBound,::cppu::UnoType<sal_Int32>::get(), &nZero);
     387           0 :     registerPropertyNoMember(PROPERTY_TOPMARGIN,    ++i,nBound,::cppu::UnoType<sal_Int32>::get(), &nMargin);
     388           0 :     uno::Reference< container::XNameContainer> xAttribs = ::comphelper::NameContainer_createInstance(cppu::UnoType<xml::AttributeData>::get());
     389           0 :     registerPropertyNoMember("UserDefinedAttributes",     ++i,nBound, cppu::UnoType<container::XNameContainer>::get(), &xAttribs);
     390           0 :     registerProperty(PROPERTY_WIDTH,        ++i,nBound,&m_aSize.Width, cppu::UnoType<sal_Int32>::get() );
     391           0 :     registerPropertyNoMember("PrinterName",               ++i,nBound, cppu::UnoType<OUString>::get(), &sEmpty);
     392           0 :     uno::Sequence<sal_Int8> aSe;
     393           0 :     registerPropertyNoMember("PrinterSetup",              ++i,nBound,::getCppuType((const uno::Sequence<sal_Int8>*)0),&aSe);
     394             : 
     395             : 
     396           0 : }
     397             : 
     398           0 : IMPLEMENT_FORWARD_XINTERFACE2(OStyle,TStyleBASE,OStyle_PBASE)
     399             : 
     400           0 : uno::Reference< beans::XPropertySetInfo>  SAL_CALL OStyle::getPropertySetInfo() throw(uno::RuntimeException, std::exception)
     401             : {
     402           0 :     return createPropertySetInfo( getInfoHelper() );
     403             : }
     404             : 
     405           0 : void OStyle::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, uno::Any& /*_rDefault*/ ) const
     406             : {
     407           0 : }
     408             : 
     409           0 : ::cppu::IPropertyArrayHelper& OStyle::getInfoHelper()
     410             : {
     411           0 :     return *const_cast<OStyle*>(this)->getArrayHelper();
     412             : }
     413             : 
     414           0 : ::cppu::IPropertyArrayHelper* OStyle::createArrayHelper( ) const
     415             : {
     416           0 :     uno::Sequence< beans::Property > aProps;
     417           0 :     describeProperties(aProps);
     418           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     419             : }
     420             : 
     421             : // XStyle
     422           0 : sal_Bool SAL_CALL OStyle::isUserDefined(  ) throw (uno::RuntimeException, std::exception)
     423             : {
     424           0 :     return sal_False;
     425             : }
     426             : 
     427           0 : sal_Bool SAL_CALL OStyle::isInUse(  ) throw (uno::RuntimeException, std::exception)
     428             : {
     429           0 :     return sal_True;
     430             : }
     431             : 
     432           0 : OUString SAL_CALL OStyle::getParentStyle(  ) throw (uno::RuntimeException, std::exception)
     433             : {
     434           0 :     return OUString();
     435             : }
     436             : 
     437           0 : void SAL_CALL OStyle::setParentStyle( const OUString& /*aParentStyle*/ ) throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
     438             : {
     439           0 : }
     440             : 
     441             : // XNamed
     442           0 : OUString SAL_CALL OStyle::getName(  ) throw (uno::RuntimeException, std::exception)
     443             : {
     444           0 :     OUString sName;
     445           0 :     getPropertyValue(PROPERTY_NAME) >>= sName;
     446           0 :     return sName;
     447             : }
     448             : 
     449           0 : void SAL_CALL OStyle::setName( const OUString& aName ) throw (uno::RuntimeException, std::exception)
     450             : {
     451           0 :     setPropertyValue(PROPERTY_NAME,uno::makeAny(aName));
     452           0 : }
     453             : 
     454           0 : void SAL_CALL OStyle::setAllPropertiesToDefault(  ) throw (uno::RuntimeException, std::exception)
     455             : {
     456           0 : }
     457             : 
     458           0 : void SAL_CALL OStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     459             : {
     460           0 :     const OUString* pIter = aPropertyNames.getConstArray();
     461           0 :     const OUString* pEnd   = pIter + aPropertyNames.getLength();
     462           0 :     for(;pIter != pEnd;++pIter)
     463           0 :         setPropertyToDefault(*pIter);
     464           0 : }
     465             : 
     466           0 : uno::Sequence< uno::Any > SAL_CALL OStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     467             : {
     468           0 :     uno::Sequence< uno::Any > aRet(aPropertyNames.getLength());
     469           0 :     const OUString* pIter = aPropertyNames.getConstArray();
     470           0 :     const OUString* pEnd   = pIter + aPropertyNames.getLength();
     471           0 :     for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
     472           0 :         aRet[i] = getPropertyDefault(*pIter);
     473           0 :     return aRet;
     474             : }
     475             : 
     476             : namespace
     477             : {
     478             :     class FactoryLoader : public salhelper::Thread
     479             :     {
     480             :         OUString                          m_sMimeType;
     481             :         uno::Reference< uno::XComponentContext > m_xContext;
     482             :     public:
     483           0 :         FactoryLoader(const OUString& _sMimeType,uno::Reference< uno::XComponentContext > const & _xContext)
     484             :             :Thread("FactoryLoader")
     485             :             ,m_sMimeType(_sMimeType)
     486           0 :             ,m_xContext(_xContext)
     487           0 :         {}
     488             : 
     489             :     private:
     490           0 :         virtual ~FactoryLoader(){}
     491             : 
     492             :         virtual void execute() SAL_OVERRIDE;
     493             :      };
     494             : 
     495           0 :     void FactoryLoader::execute()
     496             :     {
     497             :         try
     498             :         {
     499           0 :             uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(m_xContext);
     500           0 :             uno::Reference<frame::XComponentLoader> xFrameLoad(xDesktop,uno::UNO_QUERY);
     501           0 :             OUString sTarget("_blank");
     502           0 :             sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
     503           0 :             uno::Reference< frame::XFrame> xFrame = xDesktop->findFrame(sTarget,nFrameSearchFlag);
     504           0 :             xFrameLoad.set(xFrame,uno::UNO_QUERY);
     505             : 
     506           0 :             if ( xFrameLoad.is() )
     507             :             {
     508           0 :                 uno::Sequence < beans::PropertyValue > aArgs( 3);
     509           0 :                 sal_Int32 nLen = 0;
     510           0 :                 aArgs[nLen].Name = "AsTemplate";
     511           0 :                 aArgs[nLen++].Value <<= sal_False;
     512             : 
     513           0 :                 aArgs[nLen].Name = "ReadOnly";
     514           0 :                 aArgs[nLen++].Value <<= sal_True;
     515             : 
     516           0 :                 aArgs[nLen].Name = "Hidden";
     517           0 :                 aArgs[nLen++].Value <<= sal_True;
     518             : 
     519           0 :                 ::comphelper::MimeConfigurationHelper aHelper(m_xContext);
     520           0 :                 SvtModuleOptions aModuleOptions;
     521           0 :                 uno::Reference< frame::XModel > xModel(xFrameLoad->loadComponentFromURL(
     522             :                     aModuleOptions.GetFactoryEmptyDocumentURL( SvtModuleOptions::ClassifyFactoryByServiceName( aHelper.GetDocServiceNameFromMediaType(m_sMimeType) )),
     523             :                     OUString(), // empty frame name
     524             :                     0,
     525             :                     aArgs
     526           0 :                     ),uno::UNO_QUERY);
     527           0 :                 ::comphelper::disposeComponent(xModel);
     528           0 :             }
     529             :         }
     530           0 :         catch (const uno::Exception&)
     531             :         {
     532             :             DBG_UNHANDLED_EXCEPTION();
     533             :         }
     534           0 :     }
     535             : }
     536             : 
     537             : struct OReportDefinitionImpl
     538             : {
     539             :     uno::WeakReference< uno::XInterface >                   m_xParent;
     540             :     ::cppu::OInterfaceContainerHelper                       m_aStorageChangeListeners;
     541             :     ::cppu::OInterfaceContainerHelper                       m_aCloseListener;
     542             :     ::cppu::OInterfaceContainerHelper                       m_aModifyListeners;
     543             :     ::cppu::OInterfaceContainerHelper                       m_aDocEventListeners;
     544             :     ::std::vector< uno::Reference< frame::XController> >    m_aControllers;
     545             :     uno::Sequence< beans::PropertyValue >                   m_aArgs;
     546             : 
     547             :     uno::Reference< report::XGroups >                       m_xGroups;
     548             :     uno::Reference< report::XSection>                       m_xReportHeader;
     549             :     uno::Reference< report::XSection>                       m_xReportFooter;
     550             :     uno::Reference< report::XSection>                       m_xPageHeader;
     551             :     uno::Reference< report::XSection>                       m_xPageFooter;
     552             :     uno::Reference< report::XSection>                       m_xDetail;
     553             :     uno::Reference< embed::XStorage >                       m_xStorage;
     554             :     uno::Reference< frame::XController >                    m_xCurrentController;
     555             :     uno::Reference< container::XIndexAccess >               m_xViewData;
     556             :     uno::Reference< container::XNameAccess >                m_xStyles;
     557             :     uno::Reference< container::XNameAccess>                 m_xXMLNamespaceMap;
     558             :     uno::Reference< container::XNameAccess>                 m_xGradientTable;
     559             :     uno::Reference< container::XNameAccess>                 m_xHatchTable;
     560             :     uno::Reference< container::XNameAccess>                 m_xBitmapTable;
     561             :     uno::Reference< container::XNameAccess>                 m_xTransparencyGradientTable;
     562             :     uno::Reference< container::XNameAccess>                 m_xDashTable;
     563             :     uno::Reference< container::XNameAccess>                 m_xMarkerTable;
     564             :     uno::Reference< report::XFunctions >                    m_xFunctions;
     565             :     uno::Reference< ui::XUIConfigurationManager2>           m_xUIConfigurationManager;
     566             :     uno::Reference< util::XNumberFormatsSupplier>           m_xNumberFormatsSupplier;
     567             :     uno::Reference< sdbc::XConnection>                      m_xActiveConnection;
     568             :     uno::Reference< frame::XTitle >                         m_xTitleHelper;
     569             :     uno::Reference< frame::XUntitledNumbers >               m_xNumberedControllers;
     570             :     uno::Reference< document::XDocumentProperties >         m_xDocumentProperties;
     571             : 
     572             :     ::boost::shared_ptr< ::comphelper::EmbeddedObjectContainer>
     573             :                                                             m_pObjectContainer;
     574             :     ::boost::shared_ptr<rptui::OReportModel>                m_pReportModel;
     575             :     ::rtl::Reference< ::dbaui::UndoManager >                m_pUndoManager;
     576             :     std::vector< rtl::Reference<salhelper::Thread> >        m_aFactoryLoaders;
     577             :     OUString                                         m_sCaption;
     578             :     OUString                                         m_sCommand;
     579             :     OUString                                         m_sFilter;
     580             :     OUString                                         m_sMimeType;
     581             :     OUString                                         m_sIdentifier;
     582             :     OUString                                         m_sDataSourceName;
     583             :     awt::Size                                               m_aVisualAreaSize;
     584             :     ::sal_Int64                                             m_nAspect;
     585             :     ::sal_Int16                                             m_nGroupKeepTogether;
     586             :     ::sal_Int16                                             m_nPageHeaderOption;
     587             :     ::sal_Int16                                             m_nPageFooterOption;
     588             :     ::sal_Int32                                             m_nCommandType;
     589             :     bool                                                    m_bControllersLocked;
     590             :     bool                                                    m_bModified;
     591             :     bool                                                    m_bEscapeProcessing;
     592             :     bool                                                    m_bSetModifiedEnabled;
     593             : 
     594           0 :     OReportDefinitionImpl(::osl::Mutex& _aMutex)
     595             :     :m_aStorageChangeListeners(_aMutex)
     596             :     ,m_aCloseListener(_aMutex)
     597             :     ,m_aModifyListeners(_aMutex)
     598             :     ,m_aDocEventListeners(_aMutex)
     599             :     ,m_sMimeType(MIMETYPE_OASIS_OPENDOCUMENT_TEXT)
     600             :     ,m_sIdentifier(SERVICE_REPORTDEFINITION)
     601             :     // default visual area is 8 x 7 cm
     602             :     ,m_aVisualAreaSize( 8000, 7000 )
     603             :     ,m_nAspect(embed::Aspects::MSOLE_CONTENT)
     604             :     ,m_nGroupKeepTogether(0)
     605             :     ,m_nPageHeaderOption(0)
     606             :     ,m_nPageFooterOption(0)
     607             :     ,m_nCommandType(sdb::CommandType::TABLE)
     608             :     ,m_bControllersLocked(false)
     609             :     ,m_bModified(false)
     610             :     ,m_bEscapeProcessing(true)
     611           0 :     ,m_bSetModifiedEnabled( true )
     612           0 :     {}
     613             : 
     614           0 :     OReportDefinitionImpl(::osl::Mutex& _aMutex,const OReportDefinitionImpl& _aCopy)
     615             :     :m_aStorageChangeListeners(_aMutex)
     616             :     ,m_aCloseListener(_aMutex)
     617             :     ,m_aModifyListeners(_aMutex)
     618             :     ,m_aDocEventListeners(_aMutex)
     619             :     ,m_sMimeType(_aCopy.m_sMimeType)
     620             :     ,m_sIdentifier(_aCopy.m_sIdentifier)
     621             :     ,m_aVisualAreaSize(_aCopy.m_aVisualAreaSize)
     622             :     ,m_nAspect(_aCopy.m_nAspect)
     623             :     ,m_nGroupKeepTogether(_aCopy.m_nGroupKeepTogether)
     624             :     ,m_nPageHeaderOption(_aCopy.m_nPageHeaderOption)
     625             :     ,m_nPageFooterOption(_aCopy.m_nPageFooterOption)
     626             :     ,m_nCommandType(_aCopy.m_nCommandType)
     627             :     ,m_bControllersLocked(_aCopy.m_bControllersLocked)
     628             :     ,m_bModified(_aCopy.m_bModified)
     629             :     ,m_bEscapeProcessing(_aCopy.m_bEscapeProcessing)
     630           0 :     ,m_bSetModifiedEnabled(_aCopy.m_bSetModifiedEnabled)
     631           0 :     {}
     632             :     ~OReportDefinitionImpl();
     633             : };
     634             : 
     635           0 : OReportDefinitionImpl::~OReportDefinitionImpl()
     636             : {
     637           0 : }
     638             : 
     639           0 : OReportDefinition::OReportDefinition(uno::Reference< uno::XComponentContext > const & _xContext)
     640             : : ReportDefinitionBase(m_aMutex)
     641             : ,ReportDefinitionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< OUString >())
     642           0 : ,m_aProps(new OReportComponentProperties(_xContext))
     643           0 : ,m_pImpl(new OReportDefinitionImpl(m_aMutex))
     644             : {
     645           0 :     m_aProps->m_sName  = RPT_RESSTRING(RID_STR_REPORT,m_aProps->m_xContext->getServiceManager());
     646           0 :     osl_atomic_increment(&m_refCount);
     647             :     {
     648           0 :         init();
     649           0 :         m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext);
     650           0 :         m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext);
     651           0 :         m_pImpl->m_xDetail->setName(RPT_RESSTRING(RID_STR_DETAIL,m_aProps->m_xContext->getServiceManager()));
     652             :     }
     653           0 :     osl_atomic_decrement( &m_refCount );
     654           0 : }
     655             : 
     656           0 : OReportDefinition::OReportDefinition(uno::Reference< uno::XComponentContext > const & _xContext
     657             :                                      ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
     658             :                                      ,uno::Reference< drawing::XShape >& _xShape)
     659             : : ReportDefinitionBase(m_aMutex)
     660             : ,ReportDefinitionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< OUString >())
     661           0 : ,m_aProps(new OReportComponentProperties(_xContext))
     662           0 : ,m_pImpl(new OReportDefinitionImpl(m_aMutex))
     663             : {
     664           0 :     m_aProps->m_sName  = RPT_RESSTRING(RID_STR_REPORT,m_aProps->m_xContext->getServiceManager());
     665           0 :     m_aProps->m_xFactory = _xFactory;
     666           0 :     osl_atomic_increment(&m_refCount);
     667             :     {
     668           0 :         m_aProps->setShape(_xShape,this,m_refCount);
     669           0 :         init();
     670           0 :         m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext);
     671           0 :         m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext);
     672           0 :         m_pImpl->m_xDetail->setName(RPT_RESSTRING(RID_STR_DETAIL,m_aProps->m_xContext->getServiceManager()));
     673             :     }
     674           0 :     osl_atomic_decrement( &m_refCount );
     675           0 : }
     676             : 
     677           0 : OReportDefinition::OReportDefinition(const OReportDefinition& _rCopy)
     678             : : cppu::BaseMutex()
     679             : ,ReportDefinitionBase(m_aMutex)
     680           0 : ,ReportDefinitionPropertySet(_rCopy.m_aProps->m_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< OUString >())
     681             : ,comphelper::IEmbeddedHelper()
     682           0 : ,m_aProps(new OReportComponentProperties(*_rCopy.m_aProps))
     683           0 : ,m_pImpl(new OReportDefinitionImpl(m_aMutex,*_rCopy.m_pImpl))
     684             : {
     685           0 :     osl_atomic_increment(&m_refCount);
     686             :     {
     687           0 :         init();
     688           0 :         OGroups* pGroups = new OGroups(this,m_aProps->m_xContext);
     689           0 :         m_pImpl->m_xGroups = pGroups;
     690           0 :         pGroups->copyGroups(_rCopy.m_pImpl->m_xGroups);
     691           0 :         m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext);
     692           0 :         OSection::lcl_copySection(_rCopy.m_pImpl->m_xDetail,m_pImpl->m_xDetail);
     693             : 
     694           0 :         setPageHeaderOn(_rCopy.m_pImpl->m_xPageHeader.is());
     695           0 :         setPageFooterOn(_rCopy.m_pImpl->m_xPageFooter.is());
     696           0 :         setReportHeaderOn(_rCopy.m_pImpl->m_xReportHeader.is());
     697           0 :         setReportFooterOn(_rCopy.m_pImpl->m_xReportFooter.is());
     698           0 :         OSection::lcl_copySection(_rCopy.m_pImpl->m_xPageHeader,m_pImpl->m_xPageHeader);
     699           0 :         OSection::lcl_copySection(_rCopy.m_pImpl->m_xPageFooter,m_pImpl->m_xPageFooter);
     700           0 :         OSection::lcl_copySection(_rCopy.m_pImpl->m_xReportHeader,m_pImpl->m_xReportHeader);
     701           0 :         OSection::lcl_copySection(_rCopy.m_pImpl->m_xReportFooter,m_pImpl->m_xReportFooter);
     702             :     }
     703           0 :     osl_atomic_decrement( &m_refCount );
     704           0 : }
     705             : 
     706           0 : OReportDefinition::~OReportDefinition()
     707             : {
     708           0 :     if ( !ReportDefinitionBase::rBHelper.bInDispose && !ReportDefinitionBase::rBHelper.bDisposed )
     709             :     {
     710           0 :         acquire();
     711           0 :         dispose();
     712             :     }
     713           0 : }
     714             : 
     715           0 : IMPLEMENT_FORWARD_REFCOUNT( OReportDefinition, ReportDefinitionBase )
     716           0 : void OReportDefinition::init()
     717             : {
     718             :     try
     719             :     {
     720             :         static bool s_bFirstTime = true;
     721           0 :         if ( s_bFirstTime )
     722             :         {
     723           0 :             s_bFirstTime = false;
     724           0 :             const uno::Sequence< OUString > aMimeTypes = getAvailableMimeTypes();
     725           0 :             const OUString* pIter = aMimeTypes.getConstArray();
     726           0 :             const OUString* pEnd  = pIter + aMimeTypes.getLength();
     727           0 :             for ( ; pIter != pEnd; ++pIter )
     728             :             {
     729           0 :                 rtl::Reference<salhelper::Thread> xCreatorThread = new FactoryLoader(*pIter,m_aProps->m_xContext);
     730           0 :                 m_pImpl->m_aFactoryLoaders.push_back(xCreatorThread);
     731           0 :                 xCreatorThread->launch();
     732           0 :             }
     733             :         }
     734             : 
     735           0 :         m_pImpl->m_pReportModel.reset(new OReportModel(this));
     736           0 :         m_pImpl->m_pReportModel->GetItemPool().FreezeIdRanges();
     737           0 :         m_pImpl->m_pReportModel->SetScaleUnit( MAP_100TH_MM );
     738           0 :         SdrLayerAdmin& rAdmin = m_pImpl->m_pReportModel->GetLayerAdmin();
     739           0 :         rAdmin.NewStandardLayer(RPT_LAYER_FRONT);
     740           0 :         rAdmin.NewLayer(OUString("back"), RPT_LAYER_BACK);
     741           0 :         rAdmin.NewLayer(OUString("HiddenLayer"), RPT_LAYER_HIDDEN);
     742             : 
     743           0 :         m_pImpl->m_pUndoManager = new ::dbaui::UndoManager( *this, m_aMutex );
     744           0 :         m_pImpl->m_pReportModel->SetSdrUndoManager( &m_pImpl->m_pUndoManager->GetSfxUndoManager() );
     745             : 
     746           0 :         m_pImpl->m_xFunctions = new OFunctions(this,m_aProps->m_xContext);
     747           0 :         if ( !m_pImpl->m_xStorage.is() )
     748           0 :             m_pImpl->m_xStorage = ::comphelper::OStorageHelper::GetTemporaryStorage();
     749             : 
     750           0 :         uno::Reference<beans::XPropertySet> xStorProps(m_pImpl->m_xStorage,uno::UNO_QUERY);
     751           0 :         if ( xStorProps.is())
     752             :         {
     753           0 :             OUString sMediaType;
     754           0 :             xStorProps->getPropertyValue("MediaType") >>= sMediaType;
     755           0 :             if ( sMediaType.isEmpty() )
     756           0 :                 xStorProps->setPropertyValue("MediaType",uno::makeAny(MIMETYPE_OASIS_OPENDOCUMENT_REPORT));
     757             :         }
     758           0 :         m_pImpl->m_pObjectContainer.reset( new comphelper::EmbeddedObjectContainer(m_pImpl->m_xStorage , static_cast<cppu::OWeakObject*>(this) ) );
     759             :     }
     760           0 :     catch (const uno::Exception&)
     761             :     {
     762             :         DBG_UNHANDLED_EXCEPTION();
     763             :     }
     764           0 : }
     765             : 
     766           0 : void SAL_CALL OReportDefinition::dispose() throw(uno::RuntimeException, std::exception)
     767             : {
     768           0 :     ReportDefinitionPropertySet::dispose();
     769           0 :     cppu::WeakComponentImplHelperBase::dispose();
     770           0 : }
     771             : 
     772           0 : void SAL_CALL OReportDefinition::disposing()
     773             : {
     774           0 :     notifyEvent(OUString("OnUnload"));
     775             : 
     776           0 :     uno::Reference< frame::XModel > xHoldAlive( this );
     777             : 
     778           0 :     lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) );
     779           0 :     m_pImpl->m_aModifyListeners.disposeAndClear( aDisposeEvent );
     780           0 :     m_pImpl->m_aCloseListener.disposeAndClear( aDisposeEvent );
     781           0 :     m_pImpl->m_aDocEventListeners.disposeAndClear( aDisposeEvent );
     782           0 :     m_pImpl->m_aStorageChangeListeners.disposeAndClear( aDisposeEvent );
     783             : 
     784             :     // SYNCHRONIZED --->
     785             :     {
     786           0 :     SolarMutexGuard aSolarGuard;
     787           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
     788             : 
     789           0 :     m_pImpl->m_aControllers.clear();
     790             : 
     791           0 :     ::comphelper::disposeComponent(m_pImpl->m_xGroups);
     792           0 :     m_pImpl->m_xReportHeader.clear();
     793           0 :     m_pImpl->m_xReportFooter.clear();
     794           0 :     m_pImpl->m_xPageHeader.clear();
     795           0 :     m_pImpl->m_xPageFooter.clear();
     796           0 :     m_pImpl->m_xDetail.clear();
     797           0 :     ::comphelper::disposeComponent(m_pImpl->m_xFunctions);
     798             : 
     799             :     //::comphelper::disposeComponent(m_pImpl->m_xStorage);
     800             :         // don't dispose, this currently is the task of either the ref count going to
     801             :         // 0, or of the embedded object (if we're embedded, which is the only possible
     802             :         // case so far)
     803             :         // #i78366#
     804           0 :     m_pImpl->m_xStorage.clear();
     805           0 :     m_pImpl->m_xViewData.clear();
     806           0 :     m_pImpl->m_xCurrentController.clear();
     807           0 :     m_pImpl->m_xNumberFormatsSupplier.clear();
     808           0 :     m_pImpl->m_xStyles.clear();
     809           0 :     m_pImpl->m_xXMLNamespaceMap.clear();
     810           0 :     m_pImpl->m_xGradientTable.clear();
     811           0 :     m_pImpl->m_xHatchTable.clear();
     812           0 :     m_pImpl->m_xBitmapTable.clear();
     813           0 :     m_pImpl->m_xTransparencyGradientTable.clear();
     814           0 :     m_pImpl->m_xDashTable.clear();
     815           0 :     m_pImpl->m_xMarkerTable.clear();
     816           0 :     m_pImpl->m_xUIConfigurationManager.clear();
     817           0 :     m_pImpl->m_pReportModel.reset();
     818           0 :     m_pImpl->m_pObjectContainer.reset();
     819           0 :     m_pImpl->m_aArgs.realloc(0);
     820           0 :     m_pImpl->m_xTitleHelper.clear();
     821           0 :     m_pImpl->m_xNumberedControllers.clear();
     822             :     }
     823             :     // <--- SYNCHRONIZED
     824             : 
     825           0 :     SolarMutexReleaser rel;
     826           0 :     for (std::vector< rtl::Reference<salhelper::Thread> >::iterator i(
     827           0 :              m_pImpl->m_aFactoryLoaders.begin());
     828           0 :          i != m_pImpl->m_aFactoryLoaders.end(); ++i)
     829             :     {
     830           0 :         (*i)->join();
     831           0 :     }
     832           0 : }
     833             : 
     834             : 
     835          16 : OUString OReportDefinition::getImplementationName_Static(  ) throw(uno::RuntimeException)
     836             : {
     837          16 :     return OUString("com.sun.star.comp.report.OReportDefinition");
     838             : }
     839             : 
     840           0 : OUString SAL_CALL OReportDefinition::getImplementationName(  ) throw(uno::RuntimeException, std::exception)
     841             : {
     842           0 :     return getImplementationName_Static();
     843             : }
     844             : 
     845           0 : uno::Sequence< OUString > OReportDefinition::getSupportedServiceNames_Static(  ) throw(uno::RuntimeException)
     846             : {
     847           0 :     uno::Sequence< OUString > aServices(1);
     848           0 :     aServices.getArray()[0] = SERVICE_REPORTDEFINITION;
     849             : 
     850           0 :     return aServices;
     851             : }
     852             : 
     853           0 : uno::Sequence< OUString > SAL_CALL OReportDefinition::getSupportedServiceNames(  ) throw(uno::RuntimeException, std::exception)
     854             : {
     855             :     // first collect the services which are supported by our aggregate
     856           0 :     uno::Sequence< OUString > aSupported;
     857           0 :     if ( m_aProps->m_xServiceInfo.is() )
     858           0 :         aSupported = m_aProps->m_xServiceInfo->getSupportedServiceNames();
     859             : 
     860             :     // append our own service, if necessary
     861           0 :     if ( 0 == ::comphelper::findValue( aSupported, SERVICE_REPORTDEFINITION, true ).getLength() )
     862             :     {
     863           0 :         sal_Int32 nLen = aSupported.getLength();
     864           0 :         aSupported.realloc( nLen + 1 );
     865           0 :         aSupported[ nLen ] = SERVICE_REPORTDEFINITION;
     866             :     }
     867             : 
     868             :     // outta here
     869           0 :     return aSupported;
     870             : }
     871             : 
     872           0 : sal_Bool SAL_CALL OReportDefinition::supportsService( const OUString& _rServiceName ) throw(uno::RuntimeException, std::exception)
     873             : {
     874           0 :     return cppu::supportsService(this, _rServiceName);
     875             : }
     876             : 
     877           0 : uno::Any SAL_CALL OReportDefinition::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException, std::exception)
     878             : {
     879           0 :     uno::Any aReturn = ReportDefinitionBase::queryInterface(_rType);
     880           0 :     if ( !aReturn.hasValue() )
     881           0 :         aReturn = ReportDefinitionPropertySet::queryInterface(_rType);
     882             : 
     883           0 :     return aReturn.hasValue() ? aReturn : (m_aProps->m_xProxy.is() ? m_aProps->m_xProxy->queryAggregation(_rType) : aReturn);
     884             : }
     885           0 : uno::Sequence< uno::Type > SAL_CALL OReportDefinition::getTypes(  ) throw (uno::RuntimeException, std::exception)
     886             : {
     887           0 :     if ( m_aProps->m_xTypeProvider.is() )
     888             :         return ::comphelper::concatSequences(
     889             :             ReportDefinitionBase::getTypes(),
     890           0 :             m_aProps->m_xTypeProvider->getTypes()
     891           0 :         );
     892           0 :     return ReportDefinitionBase::getTypes();
     893             : }
     894             : 
     895           0 : uno::Reference< uno::XInterface > OReportDefinition::create(uno::Reference< uno::XComponentContext > const & xContext)
     896             : {
     897           0 :     return *(new OReportDefinition(xContext));
     898             : }
     899             : 
     900             : // XReportDefinition
     901           0 : OUString SAL_CALL OReportDefinition::getCaption() throw (uno::RuntimeException, std::exception)
     902             : {
     903           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     904           0 :     return m_pImpl->m_sCaption;
     905             : }
     906             : 
     907           0 : void SAL_CALL OReportDefinition::setCaption( const OUString& _caption ) throw (uno::RuntimeException, std::exception)
     908             : {
     909           0 :     set(PROPERTY_CAPTION,_caption,m_pImpl->m_sCaption);
     910           0 : }
     911             : 
     912           0 : ::sal_Int16 SAL_CALL OReportDefinition::getGroupKeepTogether() throw (uno::RuntimeException, std::exception)
     913             : {
     914           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     915           0 :     return m_pImpl->m_nGroupKeepTogether;
     916             : }
     917             : 
     918           0 : void SAL_CALL OReportDefinition::setGroupKeepTogether( ::sal_Int16 _groupkeeptogether ) throw (uno::RuntimeException, std::exception)
     919             : {
     920           0 :     if ( _groupkeeptogether < report::GroupKeepTogether::PER_PAGE || _groupkeeptogether > report::GroupKeepTogether::PER_COLUMN )
     921             :         throwIllegallArgumentException("com::sun::star::report::GroupKeepTogether"
     922             :                         ,*this
     923             :                         ,1
     924           0 :                         ,m_aProps->m_xContext);
     925           0 :     set(PROPERTY_GROUPKEEPTOGETHER,_groupkeeptogether,m_pImpl->m_nGroupKeepTogether);
     926           0 : }
     927             : 
     928           0 : ::sal_Int16 SAL_CALL OReportDefinition::getPageHeaderOption() throw (uno::RuntimeException, std::exception)
     929             : {
     930           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     931           0 :     return m_pImpl->m_nPageHeaderOption;
     932             : }
     933             : 
     934           0 : void SAL_CALL OReportDefinition::setPageHeaderOption( ::sal_Int16 _pageheaderoption ) throw (uno::RuntimeException, std::exception)
     935             : {
     936           0 :     if ( _pageheaderoption < report::ReportPrintOption::ALL_PAGES || _pageheaderoption > report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER )
     937             :         throwIllegallArgumentException("com::sun::star::report::ReportPrintOption"
     938             :                         ,*this
     939             :                         ,1
     940           0 :                         ,m_aProps->m_xContext);
     941           0 :     set(PROPERTY_PAGEHEADEROPTION,_pageheaderoption,m_pImpl->m_nPageHeaderOption);
     942           0 : }
     943             : 
     944           0 : ::sal_Int16 SAL_CALL OReportDefinition::getPageFooterOption() throw (uno::RuntimeException, std::exception)
     945             : {
     946           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     947           0 :     return m_pImpl->m_nPageFooterOption;
     948             : }
     949             : 
     950           0 : void SAL_CALL OReportDefinition::setPageFooterOption( ::sal_Int16 _pagefooteroption ) throw (uno::RuntimeException, std::exception)
     951             : {
     952           0 :     if ( _pagefooteroption < report::ReportPrintOption::ALL_PAGES || _pagefooteroption > report::ReportPrintOption::NOT_WITH_REPORT_HEADER_FOOTER )
     953             :         throwIllegallArgumentException("com::sun::star::report::ReportPrintOption"
     954             :                         ,*this
     955             :                         ,1
     956           0 :                         ,m_aProps->m_xContext);
     957           0 :     set(PROPERTY_PAGEFOOTEROPTION,_pagefooteroption,m_pImpl->m_nPageFooterOption);
     958           0 : }
     959             : 
     960           0 : OUString SAL_CALL OReportDefinition::getCommand() throw (uno::RuntimeException, std::exception)
     961             : {
     962           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     963           0 :     return m_pImpl->m_sCommand;
     964             : }
     965             : 
     966           0 : void SAL_CALL OReportDefinition::setCommand( const OUString& _command ) throw (uno::RuntimeException, std::exception)
     967             : {
     968           0 :     set(PROPERTY_COMMAND,_command,m_pImpl->m_sCommand);
     969           0 : }
     970             : 
     971           0 : ::sal_Int32 SAL_CALL OReportDefinition::getCommandType() throw (uno::RuntimeException, std::exception)
     972             : {
     973           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     974           0 :     return m_pImpl->m_nCommandType;
     975             : }
     976             : 
     977           0 : void SAL_CALL OReportDefinition::setCommandType( ::sal_Int32 _commandtype ) throw (uno::RuntimeException, std::exception)
     978             : {
     979           0 :     if ( _commandtype < sdb::CommandType::TABLE || _commandtype > sdb::CommandType::COMMAND )
     980             :         throwIllegallArgumentException("com::sun::star::sdb::CommandType"
     981             :                         ,*this
     982             :                         ,1
     983           0 :                         ,m_aProps->m_xContext);
     984           0 :     set(PROPERTY_COMMANDTYPE,_commandtype,m_pImpl->m_nCommandType);
     985           0 : }
     986             : 
     987           0 : OUString SAL_CALL OReportDefinition::getFilter() throw (uno::RuntimeException, std::exception)
     988             : {
     989           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     990           0 :     return m_pImpl->m_sFilter;
     991             : }
     992             : 
     993           0 : void SAL_CALL OReportDefinition::setFilter( const OUString& _filter ) throw (uno::RuntimeException, std::exception)
     994             : {
     995           0 :     set(PROPERTY_FILTER,_filter,m_pImpl->m_sFilter);
     996           0 : }
     997             : 
     998           0 : sal_Bool SAL_CALL OReportDefinition::getEscapeProcessing() throw (uno::RuntimeException, std::exception)
     999             : {
    1000           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1001           0 :     return m_pImpl->m_bEscapeProcessing;
    1002             : }
    1003             : 
    1004           0 : void SAL_CALL OReportDefinition::setEscapeProcessing( sal_Bool _escapeprocessing ) throw (uno::RuntimeException, std::exception)
    1005             : {
    1006           0 :     set(PROPERTY_ESCAPEPROCESSING,_escapeprocessing,m_pImpl->m_bEscapeProcessing);
    1007           0 : }
    1008             : 
    1009           0 : sal_Bool SAL_CALL OReportDefinition::getReportHeaderOn() throw (uno::RuntimeException, std::exception)
    1010             : {
    1011           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1012           0 :     return m_pImpl->m_xReportHeader.is();
    1013             : }
    1014             : 
    1015           0 : void SAL_CALL OReportDefinition::setReportHeaderOn( sal_Bool _reportheaderon ) throw (uno::RuntimeException, std::exception)
    1016             : {
    1017           0 :     if ( bool(_reportheaderon) != m_pImpl->m_xReportHeader.is() )
    1018             :     {
    1019           0 :         setSection(PROPERTY_REPORTHEADERON,_reportheaderon,RPT_RESSTRING(RID_STR_REPORT_HEADER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xReportHeader);
    1020             :     }
    1021           0 : }
    1022             : 
    1023           0 : sal_Bool SAL_CALL OReportDefinition::getReportFooterOn() throw (uno::RuntimeException, std::exception)
    1024             : {
    1025           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1026           0 :     return m_pImpl->m_xReportFooter.is();
    1027             : }
    1028             : 
    1029           0 : void SAL_CALL OReportDefinition::setReportFooterOn( sal_Bool _reportfooteron ) throw (uno::RuntimeException, std::exception)
    1030             : {
    1031           0 :     if ( bool(_reportfooteron) != m_pImpl->m_xReportFooter.is() )
    1032             :     {
    1033           0 :         setSection(PROPERTY_REPORTFOOTERON,_reportfooteron,RPT_RESSTRING(RID_STR_REPORT_FOOTER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xReportFooter);
    1034             :     }
    1035           0 : }
    1036             : 
    1037           0 : sal_Bool SAL_CALL OReportDefinition::getPageHeaderOn() throw (uno::RuntimeException, std::exception)
    1038             : {
    1039           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1040           0 :     return m_pImpl->m_xPageHeader.is();
    1041             : }
    1042             : 
    1043           0 : void SAL_CALL OReportDefinition::setPageHeaderOn( sal_Bool _pageheaderon ) throw (uno::RuntimeException, std::exception)
    1044             : {
    1045           0 :     if ( bool(_pageheaderon) != m_pImpl->m_xPageHeader.is() )
    1046             :     {
    1047           0 :         setSection(PROPERTY_PAGEHEADERON,_pageheaderon,RPT_RESSTRING(RID_STR_PAGE_HEADER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xPageHeader);
    1048             :     }
    1049           0 : }
    1050             : 
    1051           0 : sal_Bool SAL_CALL OReportDefinition::getPageFooterOn() throw (uno::RuntimeException, std::exception)
    1052             : {
    1053           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1054           0 :     return m_pImpl->m_xPageFooter.is();
    1055             : }
    1056             : 
    1057           0 : void SAL_CALL OReportDefinition::setPageFooterOn( sal_Bool _pagefooteron ) throw (uno::RuntimeException, std::exception)
    1058             : {
    1059           0 :     if ( bool(_pagefooteron) != m_pImpl->m_xPageFooter.is() )
    1060             :     {
    1061           0 :         setSection(PROPERTY_PAGEFOOTERON,_pagefooteron,RPT_RESSTRING(RID_STR_PAGE_FOOTER,m_aProps->m_xContext->getServiceManager()),m_pImpl->m_xPageFooter);
    1062             :     }
    1063           0 : }
    1064             : 
    1065           0 : uno::Reference< report::XGroups > SAL_CALL OReportDefinition::getGroups() throw (uno::RuntimeException, std::exception)
    1066             : {
    1067           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1068           0 :     return m_pImpl->m_xGroups;
    1069             : }
    1070             : 
    1071           0 : uno::Reference< report::XSection > SAL_CALL OReportDefinition::getReportHeader() throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
    1072             : {
    1073           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1074           0 :     if ( !m_pImpl->m_xReportHeader.is() )
    1075           0 :         throw container::NoSuchElementException();
    1076           0 :     return m_pImpl->m_xReportHeader;
    1077             : }
    1078             : 
    1079           0 : uno::Reference< report::XSection > SAL_CALL OReportDefinition::getPageHeader() throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
    1080             : {
    1081           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1082           0 :     if ( !m_pImpl->m_xPageHeader.is() )
    1083           0 :         throw container::NoSuchElementException();
    1084           0 :     return m_pImpl->m_xPageHeader;
    1085             : }
    1086             : 
    1087           0 : uno::Reference< report::XSection > SAL_CALL OReportDefinition::getDetail() throw (uno::RuntimeException, std::exception)
    1088             : {
    1089           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1090           0 :     return m_pImpl->m_xDetail;
    1091             : }
    1092             : 
    1093           0 : uno::Reference< report::XSection > SAL_CALL OReportDefinition::getPageFooter() throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
    1094             : {
    1095           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1096           0 :     if ( !m_pImpl->m_xPageFooter.is() )
    1097           0 :         throw container::NoSuchElementException();
    1098           0 :     return m_pImpl->m_xPageFooter;
    1099             : }
    1100             : 
    1101           0 : uno::Reference< report::XSection > SAL_CALL OReportDefinition::getReportFooter() throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
    1102             : {
    1103           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1104           0 :     if ( !m_pImpl->m_xReportFooter.is() )
    1105           0 :         throw container::NoSuchElementException();
    1106           0 :     return m_pImpl->m_xReportFooter;
    1107             : }
    1108             : 
    1109           0 : uno::Reference< document::XEventBroadcaster > SAL_CALL OReportDefinition::getEventBroadcaster(  ) throw (lang::DisposedException, uno::Exception, uno::RuntimeException, std::exception)
    1110             : {
    1111           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1112           0 :     return this;
    1113             : }
    1114             : 
    1115             : // XReportComponent
    1116           0 : REPORTCOMPONENT_MASTERDETAIL(OReportDefinition,*m_aProps)
    1117           0 : REPORTCOMPONENT_IMPL(OReportDefinition,*m_aProps)
    1118           0 : REPORTCOMPONENT_IMPL2(OReportDefinition,*m_aProps)
    1119             : 
    1120           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL OReportDefinition::getPropertySetInfo(  ) throw(uno::RuntimeException, std::exception)
    1121             : {
    1122           0 :     return ReportDefinitionPropertySet::getPropertySetInfo();
    1123             : }
    1124             : 
    1125           0 : void SAL_CALL OReportDefinition::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1126             : {
    1127           0 :     ReportDefinitionPropertySet::setPropertyValue( aPropertyName, aValue );
    1128           0 : }
    1129             : 
    1130           0 : uno::Any SAL_CALL OReportDefinition::getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1131             : {
    1132           0 :     return ReportDefinitionPropertySet::getPropertyValue( PropertyName);
    1133             : }
    1134             : 
    1135           0 : void SAL_CALL OReportDefinition::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1136             : {
    1137           0 :     ReportDefinitionPropertySet::addPropertyChangeListener( aPropertyName, xListener );
    1138           0 : }
    1139             : 
    1140           0 : void SAL_CALL OReportDefinition::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1141             : {
    1142           0 :     ReportDefinitionPropertySet::removePropertyChangeListener( aPropertyName, aListener );
    1143           0 : }
    1144             : 
    1145           0 : void SAL_CALL OReportDefinition::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1146             : {
    1147           0 :     ReportDefinitionPropertySet::addVetoableChangeListener( PropertyName, aListener );
    1148           0 : }
    1149             : 
    1150           0 : void SAL_CALL OReportDefinition::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1151             : {
    1152           0 :     ReportDefinitionPropertySet::removeVetoableChangeListener( PropertyName, aListener );
    1153           0 : }
    1154             : 
    1155             : // XChild
    1156           0 : uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::getParent(  ) throw (uno::RuntimeException, std::exception)
    1157             : {
    1158           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1159           0 :     uno::Reference< container::XChild > xChild;
    1160           0 :     comphelper::query_aggregation(m_aProps->m_xProxy,xChild);
    1161           0 :     if ( xChild.is() )
    1162           0 :         return xChild->getParent();
    1163           0 :     return m_pImpl->m_xParent;
    1164             : }
    1165             : 
    1166           0 : void SAL_CALL OReportDefinition::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException, std::exception)
    1167             : {
    1168           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1169           0 :     m_aProps->m_xParent = uno::Reference< container::XChild >(Parent,uno::UNO_QUERY);
    1170           0 :     m_pImpl->m_xParent = Parent;
    1171           0 :     uno::Reference< container::XChild > xChild;
    1172           0 :     comphelper::query_aggregation(m_aProps->m_xProxy,xChild);
    1173           0 :     if ( xChild.is() )
    1174           0 :         xChild->setParent(Parent);
    1175           0 : }
    1176             : 
    1177             : // XCloneable
    1178           0 : uno::Reference< util::XCloneable > SAL_CALL OReportDefinition::createClone(  ) throw (uno::RuntimeException, std::exception)
    1179             : {
    1180             :     OSL_FAIL("Not yet implemented correctly");
    1181           0 :     uno::Reference< report::XReportComponent> xSource = this;
    1182           0 :     uno::Reference< report::XReportDefinition> xSet(cloneObject(xSource,m_aProps->m_xFactory,SERVICE_REPORTDEFINITION),uno::UNO_QUERY_THROW);
    1183           0 :     return xSet.get();
    1184             : }
    1185             : 
    1186           0 : void OReportDefinition::setSection(  const OUString& _sProperty
    1187             :                             ,const bool& _bOn
    1188             :                             ,const OUString& _sName
    1189             :                             ,uno::Reference< report::XSection>& _member)
    1190             : {
    1191           0 :     BoundListeners l;
    1192             :     {
    1193           0 :         ::osl::MutexGuard aGuard(m_aMutex);
    1194           0 :         prepareSet(_sProperty, uno::makeAny(_member), uno::makeAny(_bOn), &l);
    1195           0 :         lcl_createSectionIfNeeded(_bOn ,this,_member,_sProperty == PROPERTY_PAGEHEADERON || _sProperty == PROPERTY_PAGEFOOTERON);
    1196           0 :         if ( _member.is() )
    1197           0 :             _member->setName(_sName);
    1198             :     }
    1199           0 :     l.notify();
    1200           0 : }
    1201             : 
    1202             : // XCloseBroadcaster
    1203           0 : void SAL_CALL OReportDefinition::addCloseListener( const uno::Reference< util::XCloseListener >& _xListener ) throw (uno::RuntimeException, std::exception)
    1204             : {
    1205           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1206           0 :     if ( _xListener.is() )
    1207           0 :         m_pImpl->m_aCloseListener.addInterface(_xListener);
    1208           0 : }
    1209             : 
    1210           0 : void SAL_CALL OReportDefinition::removeCloseListener( const uno::Reference< util::XCloseListener >& _xListener ) throw (uno::RuntimeException, std::exception)
    1211             : {
    1212           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1213           0 :     m_pImpl->m_aCloseListener.removeInterface(_xListener);
    1214           0 : }
    1215             : 
    1216             : // XCloseable
    1217           0 : void SAL_CALL OReportDefinition::close( sal_Bool _bDeliverOwnership ) throw (util::CloseVetoException, uno::RuntimeException, std::exception)
    1218             : {
    1219           0 :     SolarMutexGuard aSolarGuard;
    1220             : 
    1221           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    1222           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1223             :     // notify our container listeners
    1224           0 :     lang::EventObject aEvt( static_cast< ::cppu::OWeakObject* >( this ) );
    1225           0 :     aGuard.clear();
    1226           0 :     m_pImpl->m_aCloseListener.forEach<util::XCloseListener>(
    1227           0 :         ::boost::bind(&util::XCloseListener::queryClosing,_1,boost::cref(aEvt),boost::cref(_bDeliverOwnership)));
    1228           0 :     aGuard.reset();
    1229             : 
    1230             : 
    1231           0 :     ::std::vector< uno::Reference< frame::XController> > aCopy = m_pImpl->m_aControllers;
    1232           0 :     ::std::vector< uno::Reference< frame::XController> >::iterator aIter = aCopy.begin();
    1233           0 :     ::std::vector< uno::Reference< frame::XController> >::iterator aEnd = aCopy.end();
    1234           0 :     for (;aIter != aEnd ; ++aIter)
    1235             :     {
    1236           0 :         if ( aIter->is() )
    1237             :         {
    1238             :             try
    1239             :             {
    1240           0 :                 uno::Reference< util::XCloseable> xFrame( (*aIter)->getFrame(), uno::UNO_QUERY );
    1241           0 :                 if ( xFrame.is() )
    1242           0 :                     xFrame->close( _bDeliverOwnership );
    1243             :             }
    1244           0 :             catch (const util::CloseVetoException&) { throw; }
    1245           0 :             catch (const uno::Exception&)
    1246             :             {
    1247             :                 OSL_FAIL( "ODatabaseDocument::impl_closeControllerFrames: caught an unexpected exception!" );
    1248             :             }
    1249             :         }
    1250             :     }
    1251             : 
    1252           0 :     aGuard.clear();
    1253           0 :     m_pImpl->m_aCloseListener.notifyEach(&util::XCloseListener::notifyClosing,aEvt);
    1254           0 :     aGuard.reset();
    1255             : 
    1256           0 :     dispose();
    1257           0 : }
    1258             : 
    1259             : // XModel
    1260           0 : sal_Bool SAL_CALL OReportDefinition::attachResource( const OUString& /*_rURL*/, const uno::Sequence< beans::PropertyValue >& _aArguments ) throw (uno::RuntimeException, std::exception)
    1261             : {
    1262             :     // LLA: we had a deadlock problem in our context, so we get the SolarMutex earlier.
    1263           0 :     SolarMutexGuard aSolarGuard;
    1264             : 
    1265           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1266           0 :     ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
    1267           0 :     utl::MediaDescriptor aDescriptor( _aArguments );
    1268             : 
    1269           0 :     m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( false );
    1270             :     try
    1271             :     {
    1272           0 :         fillArgs(aDescriptor);
    1273           0 :         m_pImpl->m_pReportModel->SetModified(false);
    1274             :     }
    1275           0 :     catch (...)
    1276             :     {
    1277           0 :         m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( true );
    1278           0 :         throw;
    1279             :     }
    1280           0 :     m_pImpl->m_pUndoManager->GetSfxUndoManager().EnableUndo( true );
    1281           0 :     return sal_True;
    1282             : }
    1283             : 
    1284           0 : void OReportDefinition::fillArgs(utl::MediaDescriptor& _aDescriptor)
    1285             : {
    1286           0 :     uno::Sequence<beans::PropertyValue> aComponentData;
    1287           0 :     aComponentData = _aDescriptor.getUnpackedValueOrDefault("ComponentData",aComponentData);
    1288           0 :     if ( aComponentData.getLength() && (!m_pImpl->m_xActiveConnection.is() || !m_pImpl->m_xNumberFormatsSupplier.is()) )
    1289             :     {
    1290           0 :         ::comphelper::SequenceAsHashMap aComponentDataMap( aComponentData );
    1291           0 :         m_pImpl->m_xActiveConnection = aComponentDataMap.getUnpackedValueOrDefault("ActiveConnection",m_pImpl->m_xActiveConnection);
    1292           0 :         m_pImpl->m_xNumberFormatsSupplier = dbtools::getNumberFormats(m_pImpl->m_xActiveConnection);
    1293             :     }
    1294           0 :     if ( !m_pImpl->m_xNumberFormatsSupplier.is() )
    1295             :     {
    1296           0 :         m_pImpl->m_xNumberFormatsSupplier.set( util::NumberFormatsSupplier::createWithDefaultLocale( m_aProps->m_xContext ) );
    1297             :     }
    1298           0 :     lcl_stripLoadArguments( _aDescriptor, m_pImpl->m_aArgs );
    1299           0 :     OUString sCaption;
    1300           0 :     sCaption = _aDescriptor.getUnpackedValueOrDefault("DocumentTitle",sCaption);
    1301           0 :     setCaption(sCaption);
    1302           0 : }
    1303             : 
    1304           0 : OUString SAL_CALL OReportDefinition::getURL(  ) throw (uno::RuntimeException, std::exception)
    1305             : {
    1306           0 :     return OUString();
    1307             : }
    1308             : 
    1309           0 : uno::Sequence< beans::PropertyValue > SAL_CALL OReportDefinition::getArgs(  ) throw (uno::RuntimeException, std::exception)
    1310             : {
    1311           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1312           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1313           0 :     return m_pImpl->m_aArgs;
    1314             : }
    1315             : 
    1316           0 : void SAL_CALL OReportDefinition::connectController( const uno::Reference< frame::XController >& _xController ) throw (uno::RuntimeException, std::exception)
    1317             : {
    1318           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1319           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1320           0 :     m_pImpl->m_aControllers.push_back(_xController);
    1321             :     sal_Int32 nCount;
    1322           0 :     if ( _xController.is() && m_pImpl->m_xViewData.is() && ( nCount = m_pImpl->m_xViewData->getCount()) != 0)
    1323             :     {
    1324           0 :         _xController->restoreViewData(m_pImpl->m_xViewData->getByIndex(nCount - 1));
    1325           0 :     }
    1326           0 : }
    1327             : 
    1328           0 : void SAL_CALL OReportDefinition::disconnectController( const uno::Reference< frame::XController >& _xController ) throw (uno::RuntimeException, std::exception)
    1329             : {
    1330           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1331           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1332           0 :     ::std::vector< uno::Reference< frame::XController> >::iterator aFind = ::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController);
    1333           0 :     if ( aFind != m_pImpl->m_aControllers.end() )
    1334           0 :         m_pImpl->m_aControllers.erase(aFind);
    1335           0 :     if ( m_pImpl->m_xCurrentController == _xController )
    1336           0 :         m_pImpl->m_xCurrentController.clear();
    1337           0 : }
    1338             : 
    1339           0 : void SAL_CALL OReportDefinition::lockControllers(  ) throw (uno::RuntimeException, std::exception)
    1340             : {
    1341           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1342           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1343           0 :     m_pImpl->m_bControllersLocked = true;
    1344           0 : }
    1345             : 
    1346           0 : void SAL_CALL OReportDefinition::unlockControllers(  ) throw (uno::RuntimeException, std::exception)
    1347             : {
    1348           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1349           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1350           0 :     m_pImpl->m_bControllersLocked = false;
    1351           0 : }
    1352             : 
    1353           0 : sal_Bool SAL_CALL OReportDefinition::hasControllersLocked(  ) throw (uno::RuntimeException, std::exception)
    1354             : {
    1355           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1356           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1357           0 :     return m_pImpl->m_bControllersLocked;
    1358             : }
    1359             : 
    1360           0 : uno::Reference< frame::XController > SAL_CALL OReportDefinition::getCurrentController(  ) throw (uno::RuntimeException, std::exception)
    1361             : {
    1362           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1363           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1364           0 :     return m_pImpl->m_xCurrentController;
    1365             : }
    1366             : 
    1367           0 : void SAL_CALL OReportDefinition::setCurrentController( const uno::Reference< frame::XController >& _xController ) throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
    1368             : {
    1369           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1370           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1371           0 :     if ( ::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController) == m_pImpl->m_aControllers.end() )
    1372           0 :         throw container::NoSuchElementException();
    1373           0 :     m_pImpl->m_xCurrentController = _xController;
    1374           0 : }
    1375             : 
    1376           0 : uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::getCurrentSelection(  ) throw (uno::RuntimeException, std::exception)
    1377             : {
    1378           0 :     return uno::Reference< uno::XInterface >();
    1379             : }
    1380             : 
    1381           0 : void OReportDefinition::impl_loadFromStorage_nolck_throw( const uno::Reference< embed::XStorage >& _xStorageToLoadFrom,
    1382             :         const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor )
    1383             : {
    1384           0 :     m_pImpl->m_xStorage = _xStorageToLoadFrom;
    1385             : 
    1386           0 :     utl::MediaDescriptor aDescriptor( _aMediaDescriptor );
    1387           0 :     fillArgs(aDescriptor);
    1388           0 :     aDescriptor.createItemIfMissing(OUString("Storage"),uno::makeAny(_xStorageToLoadFrom));
    1389             : 
    1390           0 :     uno::Sequence< uno::Any > aDelegatorArguments(_aMediaDescriptor.getLength());
    1391           0 :     uno::Any* pIter = aDelegatorArguments.getArray();
    1392           0 :     uno::Any* pEnd  = pIter + aDelegatorArguments.getLength();
    1393           0 :     for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
    1394             :     {
    1395           0 :         *pIter <<= _aMediaDescriptor[i];
    1396             :     }
    1397           0 :     sal_Int32 nPos = aDelegatorArguments.getLength();
    1398           0 :     aDelegatorArguments.realloc(nPos+1);
    1399           0 :     beans::PropertyValue aPropVal;
    1400           0 :     aPropVal.Name = "Storage";
    1401           0 :     aPropVal.Value <<= _xStorageToLoadFrom;
    1402           0 :     aDelegatorArguments[nPos] <<= aPropVal;
    1403             : 
    1404           0 :     rptui::OXUndoEnvironment& rEnv = m_pImpl->m_pReportModel->GetUndoEnv();
    1405           0 :     rptui::OXUndoEnvironment::OUndoEnvLock aLock(rEnv);
    1406             :     {
    1407             :         uno::Reference< document::XFilter > xFilter(
    1408           0 :             m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(OUString("com.sun.star.comp.report.OReportFilter"),aDelegatorArguments,m_aProps->m_xContext),
    1409           0 :             uno::UNO_QUERY_THROW );
    1410             : 
    1411           0 :         uno::Reference< document::XImporter> xImporter(xFilter,uno::UNO_QUERY_THROW);
    1412           0 :         uno::Reference<XComponent> xComponent(static_cast<OWeakObject*>(this),uno::UNO_QUERY);
    1413           0 :         xImporter->setTargetDocument(xComponent);
    1414             : 
    1415           0 :         utl::MediaDescriptor aTemp;
    1416           0 :         aTemp << aDelegatorArguments;
    1417           0 :         xFilter->filter(aTemp.getAsConstPropertyValueList());
    1418             : 
    1419           0 :         lcl_setModelReadOnly(m_pImpl->m_xStorage,m_pImpl->m_pReportModel);
    1420           0 :         m_pImpl->m_pObjectContainer->SwitchPersistence(m_pImpl->m_xStorage);
    1421           0 :     }
    1422           0 : }
    1423             : 
    1424             : // XStorageBasedDocument
    1425           0 : void SAL_CALL OReportDefinition::loadFromStorage( const uno::Reference< embed::XStorage >& _xStorageToLoadFrom
    1426             :                                                  , const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor ) throw (lang::IllegalArgumentException, frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException, std::exception)
    1427             : {
    1428           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1429           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1430             : 
    1431           0 :     impl_loadFromStorage_nolck_throw( _xStorageToLoadFrom, _aMediaDescriptor );
    1432           0 : }
    1433             : 
    1434           0 : void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XStorage >& _xStorageToSaveTo, const uno::Sequence< beans::PropertyValue >& _aMediaDescriptor ) throw (lang::IllegalArgumentException, io::IOException, uno::Exception, uno::RuntimeException, std::exception)
    1435             : {
    1436           0 :     if ( !_xStorageToSaveTo.is() )
    1437           0 :         throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_aProps->m_xContext->getServiceManager()),*this,1);
    1438             : 
    1439           0 :     SolarMutexGuard aSolarGuard;
    1440           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1441           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1442             :     // create XStatusIndicator
    1443           0 :     uno::Reference<task::XStatusIndicator> xStatusIndicator;
    1444           0 :     uno::Sequence< uno::Any > aDelegatorArguments;
    1445           0 :     utl::MediaDescriptor aDescriptor( _aMediaDescriptor );
    1446           0 :     lcl_extractAndStartStatusIndicator( aDescriptor, xStatusIndicator, aDelegatorArguments );
    1447             : 
    1448             :     // properties
    1449           0 :     uno::Sequence < beans::PropertyValue > aProps;
    1450             : 
    1451             :     // export sub streams for package, else full stream into a file
    1452           0 :     bool bWarn = false, bErr = false;
    1453           0 :     OUString sWarnFile, sErrFile;
    1454             : 
    1455           0 :     uno::Reference< beans::XPropertySet> xProp(_xStorageToSaveTo,uno::UNO_QUERY);
    1456           0 :     if ( xProp.is() )
    1457             :     {
    1458           0 :         static const OUString sPropName("MediaType");
    1459           0 :         OUString sOldMediaType;
    1460           0 :         xProp->getPropertyValue(sPropName) >>= sOldMediaType;
    1461           0 :         if ( !xProp->getPropertyValue(sPropName).hasValue() || sOldMediaType.isEmpty() || MIMETYPE_OASIS_OPENDOCUMENT_REPORT != sOldMediaType )
    1462           0 :             xProp->setPropertyValue( sPropName, uno::makeAny(MIMETYPE_OASIS_OPENDOCUMENT_REPORT) );
    1463             :     }
    1464             : 
    1465             :     /** property map for export info set */
    1466             :     comphelper::PropertyMapEntry const aExportInfoMap[] =
    1467             :     {
    1468           0 :         { OUString("UsePrettyPrinting") , 0, cppu::UnoType<sal_Bool>::get(),          beans::PropertyAttribute::MAYBEVOID, 0 },
    1469           0 :         { OUString("StreamName")        , 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
    1470           0 :         { OUString("StreamRelPath")     , 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
    1471           0 :         { OUString("BaseURI")           , 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
    1472             :         { OUString(), 0, css::uno::Type(), 0, 0 }
    1473           0 :     };
    1474           0 :     uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
    1475             : 
    1476           0 :     SvtSaveOptions aSaveOpt;
    1477           0 :     xInfoSet->setPropertyValue("UsePrettyPrinting", uno::makeAny(aSaveOpt.IsPrettyPrinting()));
    1478           0 :     if ( aSaveOpt.IsSaveRelFSys() )
    1479             :     {
    1480           0 :         const OUString sVal( aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTBASEURL(),OUString()) );
    1481           0 :         xInfoSet->setPropertyValue("BaseURI", uno::makeAny(sVal));
    1482             :     }
    1483           0 :     const OUString sHierarchicalDocumentName( aDescriptor.getUnpackedValueOrDefault("HierarchicalDocumentName",OUString()) );
    1484           0 :     xInfoSet->setPropertyValue("StreamRelPath", uno::makeAny(sHierarchicalDocumentName));
    1485             : 
    1486             : 
    1487           0 :     sal_Int32 nArgsLen = aDelegatorArguments.getLength();
    1488           0 :     aDelegatorArguments.realloc(nArgsLen+1);
    1489           0 :     aDelegatorArguments[nArgsLen++] <<= xInfoSet;
    1490             : 
    1491           0 :      uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
    1492           0 :     uno::Reference< document::XGraphicObjectResolver >      xGrfResolver;
    1493           0 :     SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(_xStorageToSaveTo,GRAPHICHELPER_MODE_WRITE);
    1494           0 :     xGrfResolver = pGraphicHelper;
    1495           0 :     pGraphicHelper->release();
    1496           0 :     SvXMLEmbeddedObjectHelper* pEmbeddedObjectHelper = SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo,*this, EMBEDDEDOBJECTHELPER_MODE_WRITE );
    1497           0 :     xObjectResolver = pEmbeddedObjectHelper;
    1498           0 :     pEmbeddedObjectHelper->release();
    1499             : 
    1500           0 :     aDelegatorArguments.realloc(nArgsLen+2);
    1501           0 :     aDelegatorArguments[nArgsLen++] <<= xGrfResolver;
    1502           0 :     aDelegatorArguments[nArgsLen++] <<= xObjectResolver;
    1503             : 
    1504           0 :     uno::Reference<XComponent> xCom(static_cast<OWeakObject*>(this),uno::UNO_QUERY);
    1505           0 :     if( !bErr )
    1506             :     {
    1507           0 :         xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("settings.xml")));
    1508           0 :         if( !WriteThroughComponent(
    1509             :             xCom, "settings.xml",
    1510             :             "com.sun.star.comp.report.XMLSettingsExporter",
    1511           0 :             aDelegatorArguments, aProps, _xStorageToSaveTo ) )
    1512             :         {
    1513           0 :             if( !bWarn )
    1514             :             {
    1515           0 :                 bWarn = true;
    1516           0 :                 sWarnFile = "settings.xml";
    1517             :             }
    1518             :         }
    1519             :     }
    1520             : 
    1521           0 :     if( !bErr )
    1522             :     {
    1523           0 :         xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("meta.xml")));
    1524           0 :         if( !WriteThroughComponent(
    1525             :             xCom, "meta.xml",
    1526             :             "com.sun.star.comp.report.XMLMetaExporter",
    1527           0 :             aDelegatorArguments, aProps, _xStorageToSaveTo ) )
    1528             :         {
    1529           0 :             if( !bWarn )
    1530             :             {
    1531           0 :                 bWarn = true;
    1532           0 :                 sWarnFile = "meta.xml";
    1533             :             }
    1534             :         }
    1535             :     }
    1536             : 
    1537           0 :     if( !bErr )
    1538             :     {
    1539           0 :         xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("styles.xml")));
    1540           0 :         if( !WriteThroughComponent(
    1541             :             xCom, "styles.xml",
    1542             :             "com.sun.star.comp.report.XMLStylesExporter",
    1543           0 :             aDelegatorArguments, aProps, _xStorageToSaveTo ) )
    1544             :         {
    1545           0 :             if( !bWarn )
    1546             :             {
    1547           0 :                 bWarn = true;
    1548           0 :                 sWarnFile = "styles.xml";
    1549             :             }
    1550             :         }
    1551             :     }
    1552             : 
    1553           0 :     if ( !bErr )
    1554             :     {
    1555           0 :         xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml")));
    1556           0 :         if( !WriteThroughComponent(
    1557             :                 xCom, "content.xml",
    1558             :                 "com.sun.star.comp.report.ExportFilter",
    1559           0 :                 aDelegatorArguments, aProps, _xStorageToSaveTo ) )
    1560             :         {
    1561           0 :             bErr = true;
    1562           0 :             sErrFile = "content.xml";
    1563             :         }
    1564             :     }
    1565             : 
    1566           0 :     uno::Any aImage;
    1567           0 :     uno::Reference< embed::XVisualObject > xCurrentController(getCurrentController(),uno::UNO_QUERY);
    1568           0 :     if ( xCurrentController.is() )
    1569             :     {
    1570           0 :         xCurrentController->setVisualAreaSize(m_pImpl->m_nAspect,m_pImpl->m_aVisualAreaSize);
    1571           0 :         aImage = xCurrentController->getPreferredVisualRepresentation( m_pImpl->m_nAspect ).Data;
    1572             :     }
    1573           0 :     if ( aImage.hasValue() )
    1574             :     {
    1575           0 :         OUString sObject1("report");
    1576           0 :         OUString sPng("image/png");
    1577             : 
    1578           0 :         uno::Sequence<sal_Int8> aSeq;
    1579           0 :         aImage >>= aSeq;
    1580           0 :         uno::Reference<io::XInputStream> xStream = new ::comphelper::SequenceInputStream( aSeq );
    1581           0 :         m_pImpl->m_pObjectContainer->InsertGraphicStreamDirectly(xStream,sObject1,sPng);
    1582             :     }
    1583             : 
    1584           0 :     if ( !bErr )
    1585             :     {
    1586           0 :         bool bPersist = false;
    1587           0 :         if ( _xStorageToSaveTo == m_pImpl->m_xStorage )
    1588           0 :             bPersist = m_pImpl->m_pObjectContainer->StoreChildren(true,false);
    1589             :         else
    1590           0 :             bPersist = m_pImpl->m_pObjectContainer->StoreAsChildren(true,true,_xStorageToSaveTo);
    1591             : 
    1592           0 :         if( bPersist )
    1593           0 :             m_pImpl->m_pObjectContainer->SetPersistentEntries(m_pImpl->m_xStorage);
    1594             :         try
    1595             :         {
    1596           0 :             uno::Reference<embed::XTransactedObject> xTransact(_xStorageToSaveTo,uno::UNO_QUERY);
    1597           0 :             if ( xTransact.is() )
    1598           0 :                 xTransact->commit();
    1599             :         }
    1600           0 :         catch (const uno::Exception&)
    1601             :         {
    1602             :             OSL_FAIL("Exception Caught: Could not commit report storage!");
    1603           0 :             throw io::IOException();
    1604             :         }
    1605             : 
    1606           0 :         if ( _xStorageToSaveTo == m_pImpl->m_xStorage )
    1607           0 :             setModified(sal_False);
    1608             :     }
    1609           0 :     if ( xStatusIndicator.is() )
    1610           0 :         xStatusIndicator->end();
    1611           0 : }
    1612             : 
    1613           0 : void SAL_CALL OReportDefinition::switchToStorage( const uno::Reference< embed::XStorage >& _xStorage ) throw (lang::IllegalArgumentException, io::IOException, uno::Exception, uno::RuntimeException, std::exception)
    1614             : {
    1615           0 :     if ( !_xStorage.is() )
    1616           0 :         throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_aProps->m_xContext->getServiceManager()),*this,1);
    1617             :     {
    1618           0 :         ::osl::MutexGuard aGuard(m_aMutex);
    1619           0 :         ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1620           0 :         m_pImpl->m_xStorage = _xStorage;
    1621           0 :         lcl_setModelReadOnly(m_pImpl->m_xStorage,m_pImpl->m_pReportModel);
    1622           0 :         m_pImpl->m_pObjectContainer->SwitchPersistence(m_pImpl->m_xStorage);
    1623             :     }
    1624             :     // notify our container listeners
    1625           0 :     OWeakObject *weakObjectThis = static_cast<OWeakObject*>(this);
    1626           0 :     m_pImpl->m_aStorageChangeListeners.forEach<document::XStorageChangeListener>(
    1627           0 :             ::boost::bind(&document::XStorageChangeListener::notifyStorageChange,_1,boost::cref(weakObjectThis),boost::cref(_xStorage)));
    1628           0 : }
    1629             : 
    1630           0 : uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentStorage(  ) throw (io::IOException, uno::Exception, uno::RuntimeException, std::exception)
    1631             : {
    1632           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1633           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1634           0 :     return m_pImpl->m_xStorage;
    1635             : }
    1636             : 
    1637           0 : void SAL_CALL OReportDefinition::addStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw (uno::RuntimeException, std::exception)
    1638             : {
    1639           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1640           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1641           0 :     if ( xListener.is() )
    1642           0 :         m_pImpl->m_aStorageChangeListeners.addInterface(xListener);
    1643           0 : }
    1644             : 
    1645           0 : void SAL_CALL OReportDefinition::removeStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw (uno::RuntimeException, std::exception)
    1646             : {
    1647           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1648           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1649           0 :     m_pImpl->m_aStorageChangeListeners.removeInterface(xListener);
    1650           0 : }
    1651             : 
    1652           0 : bool OReportDefinition::WriteThroughComponent(
    1653             :     const uno::Reference<lang::XComponent> & xComponent,
    1654             :     const sal_Char* pStreamName,
    1655             :     const sal_Char* pServiceName,
    1656             :     const uno::Sequence<uno::Any> & rArguments,
    1657             :     const uno::Sequence<beans::PropertyValue> & rMediaDesc,
    1658             :     const uno::Reference<embed::XStorage>& _xStorageToSaveTo)
    1659             : {
    1660             :     OSL_ENSURE( NULL != pStreamName, "Need stream name!" );
    1661             :     OSL_ENSURE( NULL != pServiceName, "Need service name!" );
    1662             :     try
    1663             :     {
    1664           0 :         uno::Reference<embed::XStorage> xMyStorage = _xStorageToSaveTo;
    1665             :         // open stream
    1666           0 :         OUString sStreamName = OUString::createFromAscii( pStreamName );
    1667           0 :         uno::Reference<io::XStream> xStream = xMyStorage->openStreamElement( sStreamName,embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
    1668           0 :         if ( !xStream.is() )
    1669           0 :             return false;
    1670           0 :         uno::Reference<io::XOutputStream> xOutputStream = xStream->getOutputStream();
    1671             :         OSL_ENSURE(xOutputStream.is(), "Can't create output stream in package!");
    1672           0 :         if ( ! xOutputStream.is() )
    1673           0 :             return false;
    1674             : 
    1675           0 :         uno::Reference<beans::XPropertySet> xStreamProp(xOutputStream,uno::UNO_QUERY);
    1676             :         OSL_ENSURE(xStreamProp.is(),"No valid preoperty set for the output stream!");
    1677             : 
    1678           0 :         uno::Reference<io::XSeekable> xSeek(xStreamProp,uno::UNO_QUERY);
    1679           0 :         if ( xSeek.is() )
    1680             :         {
    1681             :             OSL_TRACE("Length of stream %i",(int)xSeek->getPosition());
    1682           0 :             xSeek->seek(0);
    1683             :         }
    1684             : 
    1685           0 :         OUString aPropName("MediaType");
    1686           0 :         OUString aMime("text/xml");
    1687           0 :         uno::Any aAny;
    1688           0 :         aAny <<= aMime;
    1689           0 :         xStreamProp->setPropertyValue( aPropName, aAny );
    1690             : 
    1691             :         // encrypt all streams
    1692           0 :         xStreamProp->setPropertyValue( "UseCommonStoragePasswordEncryption",
    1693           0 :                                        uno::makeAny( true ) );
    1694             : 
    1695             :         // set buffer and create outputstream
    1696             : 
    1697             :         // write the stuff
    1698             :         bool bRet = WriteThroughComponent(
    1699             :             xOutputStream, xComponent,
    1700           0 :             pServiceName, rArguments, rMediaDesc );
    1701             :         // finally, commit stream.
    1702           0 :         return bRet;
    1703             :     }
    1704           0 :     catch (const uno::Exception&)
    1705             :     {
    1706           0 :         throw;
    1707             :     }
    1708             : }
    1709             : 
    1710           0 : bool OReportDefinition::WriteThroughComponent(
    1711             :     const uno::Reference<io::XOutputStream> & xOutputStream,
    1712             :     const uno::Reference<lang::XComponent> & xComponent,
    1713             :     const sal_Char* pServiceName,
    1714             :     const uno::Sequence<uno::Any> & rArguments,
    1715             :     const uno::Sequence<beans::PropertyValue> & rMediaDesc)
    1716             : {
    1717             :     OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" );
    1718             :     OSL_ENSURE( xComponent.is(), "Need component!" );
    1719             :     OSL_ENSURE( NULL != pServiceName, "Need component name!" );
    1720             : 
    1721             :     // get component
    1722             :     uno::Reference< xml::sax::XWriter > xSaxWriter(
    1723           0 :         xml::sax::Writer::create(m_aProps->m_xContext) );
    1724             : 
    1725             :     // connect XML writer to output stream
    1726           0 :     xSaxWriter->setOutputStream( xOutputStream );
    1727             : 
    1728             :     // prepare arguments (prepend doc handler to given arguments)
    1729           0 :     uno::Sequence<uno::Any> aArgs( 1 + rArguments.getLength() );
    1730           0 :     aArgs[0] <<= xSaxWriter;
    1731           0 :     for(sal_Int32 i = 0; i < rArguments.getLength(); i++)
    1732           0 :         aArgs[i+1] = rArguments[i];
    1733             : 
    1734             :     // get filter component
    1735             :     uno::Reference< document::XExporter > xExporter(
    1736           0 :         m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
    1737           0 :             OUString::createFromAscii(pServiceName), aArgs,m_aProps->m_xContext), uno::UNO_QUERY);
    1738             :     OSL_ENSURE( xExporter.is(),
    1739             :             "can't instantiate export filter component" );
    1740           0 :     if( !xExporter.is() )
    1741           0 :         return false;
    1742             : 
    1743             :     // connect model and filter
    1744           0 :     xExporter->setSourceDocument( xComponent );
    1745             : 
    1746             :     // filter!
    1747           0 :     uno::Reference<document::XFilter> xFilter( xExporter, uno::UNO_QUERY );
    1748           0 :     return xFilter->filter( rMediaDesc );
    1749             : }
    1750             : 
    1751             : // XLoadable
    1752           0 : void SAL_CALL OReportDefinition::initNew(  ) throw (frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException, std::exception)
    1753             : {
    1754           0 :      setPageHeaderOn( sal_True );
    1755           0 :      setPageFooterOn( sal_True );
    1756           0 : }
    1757             : 
    1758           0 : void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue >& _rArguments ) throw (frame::DoubleInitializationException, io::IOException, uno::Exception, uno::RuntimeException, std::exception)
    1759             : {
    1760           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1761           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1762             : 
    1763             :     // TODO: this code is pretty similar to what happens in ODatabaseModelImpl::getOrCreateRootStorage,
    1764             :     //       perhaps we can share code here.
    1765             : 
    1766           0 :     ::comphelper::NamedValueCollection aArguments( _rArguments );
    1767             : 
    1768             :     // the source for the to-be-created storage: either an URL, or a stream
    1769           0 :     uno::Reference< io::XInputStream > xStream;
    1770           0 :     OUString sURL;
    1771             : 
    1772           0 :     if ( aArguments.has( "Stream" ) )
    1773             :     {
    1774           0 :         aArguments.get_ensureType( "Stream", xStream );
    1775           0 :         aArguments.remove( "Stream" );
    1776             :     }
    1777           0 :     else if ( aArguments.has( "InputStream" ) )
    1778             :     {
    1779           0 :         aArguments.get_ensureType( "InputStream", xStream );
    1780           0 :         aArguments.remove( "InputStream" );
    1781             :     }
    1782             : 
    1783           0 :     if ( aArguments.has( "FileName" ) )
    1784             :     {
    1785           0 :         aArguments.get_ensureType( "FileName", sURL );
    1786           0 :         aArguments.remove( "FileName" );
    1787             :     }
    1788           0 :     else if ( aArguments.has( "URL" ) )
    1789             :     {
    1790           0 :         aArguments.get_ensureType( "URL", sURL );
    1791           0 :         aArguments.remove( "URL" );
    1792             :     }
    1793             : 
    1794           0 :     uno::Any aStorageSource;
    1795           0 :     if ( xStream.is() )
    1796           0 :         aStorageSource <<= aStorageSource;
    1797           0 :     else if ( !sURL.isEmpty() )
    1798           0 :         aStorageSource <<= sURL;
    1799             :     else
    1800             :         throw lang::IllegalArgumentException(
    1801             :             OUString( "No input source (URL or InputStream) found." ),
    1802             :                 // TODO: resource
    1803             :             *this,
    1804             :             1
    1805           0 :         );
    1806             : 
    1807           0 :     uno::Reference< lang::XSingleServiceFactory > xStorageFactory( embed::StorageFactory::create( m_aProps->m_xContext ) );
    1808             : 
    1809             :     // open read-write per default, unless told otherwise in the MediaDescriptor
    1810           0 :     uno::Reference< embed::XStorage > xDocumentStorage;
    1811             :     const sal_Int32 nOpenModes[2] = {
    1812             :         embed::ElementModes::READWRITE,
    1813             :         embed::ElementModes::READ
    1814           0 :     };
    1815           0 :     size_t nFirstOpenMode = 0;
    1816           0 :     if ( aArguments.has( "ReadOnly" ) )
    1817             :     {
    1818           0 :         bool bReadOnly = false;
    1819           0 :         aArguments.get_ensureType( "ReadOnly", bReadOnly );
    1820           0 :         nFirstOpenMode = bReadOnly ? 1 : 0;
    1821             :     }
    1822           0 :     const size_t nLastOpenMode = sizeof( nOpenModes ) / sizeof( nOpenModes[0] ) - 1;
    1823           0 :     for ( size_t i=nFirstOpenMode; i <= nLastOpenMode; ++i )
    1824             :     {
    1825           0 :         uno::Sequence< uno::Any > aStorageCreationArgs(2);
    1826           0 :         aStorageCreationArgs[0] = aStorageSource;
    1827           0 :         aStorageCreationArgs[1] <<= nOpenModes[i];
    1828             : 
    1829             :         try
    1830             :         {
    1831           0 :             xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), uno::UNO_QUERY_THROW );
    1832             :         }
    1833           0 :         catch (const uno::Exception&)
    1834             :         {
    1835           0 :             if ( i == nLastOpenMode )
    1836             :                 throw lang::WrappedTargetException(
    1837             :                     OUString( "An error occurred while creating the document storage." ),
    1838             :                         // TODO: resource
    1839             :                     *this,
    1840             :                     ::cppu::getCaughtException()
    1841           0 :                 );
    1842             :         }
    1843           0 :     }
    1844             : 
    1845           0 :     if ( !xDocumentStorage.is() )
    1846             :     {
    1847           0 :         throw uno::RuntimeException();
    1848             :     }
    1849             : 
    1850           0 :     impl_loadFromStorage_nolck_throw( xDocumentStorage, aArguments.getPropertyValues() );
    1851             :     // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage
    1852             :     // ourself here, and perhaps this means we're also responsible for it ...?
    1853           0 : }
    1854             : 
    1855             : // XVisualObject
    1856           0 : void SAL_CALL OReportDefinition::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException, std::exception)
    1857             : {
    1858           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1859           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1860             :         bool bChanged =
    1861           0 :             (m_pImpl->m_aVisualAreaSize.Width != _aSize.Width ||
    1862           0 :              m_pImpl->m_aVisualAreaSize.Height != _aSize.Height);
    1863           0 :         m_pImpl->m_aVisualAreaSize = _aSize;
    1864           0 :         if( bChanged )
    1865           0 :             setModified( sal_True );
    1866           0 :     m_pImpl->m_nAspect = _nAspect;
    1867           0 : }
    1868             : 
    1869           0 : awt::Size SAL_CALL OReportDefinition::getVisualAreaSize( ::sal_Int64 /*_nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException, std::exception)
    1870             : {
    1871           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1872           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1873           0 :     return m_pImpl->m_aVisualAreaSize;
    1874             : }
    1875             : 
    1876           0 : embed::VisualRepresentation SAL_CALL OReportDefinition::getPreferredVisualRepresentation( ::sal_Int64 /*_nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException, std::exception)
    1877             : {
    1878           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1879           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1880           0 :     embed::VisualRepresentation aResult;
    1881           0 :     OUString sImageName("report");
    1882           0 :     OUString sMimeType;
    1883           0 :     uno::Reference<io::XInputStream> xStream = m_pImpl->m_pObjectContainer->GetGraphicStream(sImageName,&sMimeType);
    1884           0 :     if ( xStream.is() )
    1885             :     {
    1886           0 :         uno::Sequence<sal_Int8> aSeq;
    1887           0 :         xStream->readBytes(aSeq,xStream->available());
    1888           0 :         xStream->closeInput();
    1889           0 :         aResult.Data <<= aSeq;
    1890           0 :         aResult.Flavor.MimeType = sMimeType;
    1891           0 :         aResult.Flavor.DataType = ::getCppuType( &aSeq );
    1892             :     }
    1893             : 
    1894           0 :     return aResult;
    1895             : }
    1896             : 
    1897           0 : ::sal_Int32 SAL_CALL OReportDefinition::getMapUnit( ::sal_Int64 /*nAspect*/ ) throw (uno::Exception, uno::RuntimeException, std::exception)
    1898             : {
    1899           0 :     return embed::EmbedMapUnits::ONE_100TH_MM;
    1900             : }
    1901             : 
    1902             : // XModifiable
    1903           0 : sal_Bool SAL_CALL OReportDefinition::disableSetModified(  ) throw (uno::RuntimeException, std::exception)
    1904             : {
    1905           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1906           0 :     ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
    1907             : 
    1908           0 :     const bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled;
    1909           0 :     m_pImpl->m_bSetModifiedEnabled = false;
    1910           0 :     return bWasEnabled;
    1911             : }
    1912             : 
    1913           0 : sal_Bool SAL_CALL OReportDefinition::enableSetModified(  ) throw (uno::RuntimeException, std::exception)
    1914             : {
    1915           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1916           0 :     ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
    1917             : 
    1918           0 :     const bool bWasEnabled = m_pImpl->m_bSetModifiedEnabled;
    1919           0 :     m_pImpl->m_bSetModifiedEnabled = true;
    1920           0 :     return bWasEnabled;
    1921             : }
    1922             : 
    1923           0 : sal_Bool SAL_CALL OReportDefinition::isSetModifiedEnabled(  ) throw (uno::RuntimeException, std::exception)
    1924             : {
    1925           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1926           0 :     ::connectivity::checkDisposed( ReportDefinitionBase::rBHelper.bDisposed );
    1927             : 
    1928           0 :     return m_pImpl->m_bSetModifiedEnabled;
    1929             : }
    1930             : 
    1931             : // XModifiable
    1932           0 : sal_Bool SAL_CALL OReportDefinition::isModified(  ) throw (uno::RuntimeException, std::exception)
    1933             : {
    1934           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1935           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1936           0 :     return m_pImpl->m_bModified;
    1937             : }
    1938             : 
    1939           0 : void SAL_CALL OReportDefinition::setModified( sal_Bool _bModified ) throw (beans::PropertyVetoException, uno::RuntimeException, std::exception)
    1940             : {
    1941           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    1942           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1943             : 
    1944           0 :     if ( !m_pImpl->m_bSetModifiedEnabled )
    1945           0 :         return;
    1946             : 
    1947           0 :     if ( m_pImpl->m_pReportModel->IsReadOnly() && _bModified )
    1948           0 :         throw beans::PropertyVetoException();
    1949           0 :     if ( (m_pImpl->m_bModified ? 1 : 0) != _bModified )
    1950             :     {
    1951           0 :         m_pImpl->m_bModified = _bModified;
    1952           0 :         if ( ( m_pImpl->m_pReportModel->IsChanged() ? 1 : 0 ) != _bModified )
    1953           0 :             m_pImpl->m_pReportModel->SetChanged(_bModified);
    1954             : 
    1955           0 :         lang::EventObject aEvent(*this);
    1956           0 :         aGuard.clear();
    1957           0 :         m_pImpl->m_aModifyListeners.notifyEach(&util::XModifyListener::modified,aEvent);
    1958           0 :         notifyEvent(OUString("OnModifyChanged"));
    1959           0 :     }
    1960             : }
    1961             : 
    1962             : // XModifyBroadcaster
    1963           0 : void SAL_CALL OReportDefinition::addModifyListener( const uno::Reference< util::XModifyListener >& _xListener ) throw (uno::RuntimeException, std::exception)
    1964             : {
    1965           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1966           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1967           0 :     if ( _xListener.is() )
    1968           0 :         m_pImpl->m_aModifyListeners.addInterface(_xListener);
    1969           0 : }
    1970             : 
    1971           0 : void SAL_CALL OReportDefinition::removeModifyListener( const uno::Reference< util::XModifyListener >& _xListener ) throw (uno::RuntimeException, std::exception)
    1972             : {
    1973           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1974           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1975           0 :     m_pImpl->m_aModifyListeners.removeInterface(_xListener);
    1976           0 : }
    1977             : 
    1978           0 : void OReportDefinition::notifyEvent(const OUString& _sEventName)
    1979             : {
    1980             :     try
    1981             :     {
    1982           0 :         ::osl::ResettableMutexGuard aGuard(m_aMutex);
    1983           0 :         ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1984           0 :         document::EventObject aEvt(*this, _sEventName);
    1985           0 :         aGuard.clear();
    1986           0 :         m_pImpl->m_aDocEventListeners.notifyEach(&document::XEventListener::notifyEvent,aEvt);
    1987             :     }
    1988           0 :     catch (const uno::Exception&)
    1989             :     {
    1990             :     }
    1991           0 : }
    1992             : 
    1993             : // document::XEventBroadcaster
    1994           0 : void SAL_CALL OReportDefinition::addEventListener(const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException, std::exception)
    1995             : {
    1996           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    1997           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    1998           0 :     if ( _xListener.is() )
    1999           0 :         m_pImpl->m_aDocEventListeners.addInterface(_xListener);
    2000           0 : }
    2001             : 
    2002           0 : void SAL_CALL OReportDefinition::removeEventListener( const uno::Reference< document::XEventListener >& _xListener ) throw (uno::RuntimeException, std::exception)
    2003             : {
    2004           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2005           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2006           0 :     m_pImpl->m_aDocEventListeners.removeInterface(_xListener);
    2007           0 : }
    2008             : 
    2009             : // document::XEventListener
    2010           0 : void SAL_CALL OReportDefinition::notifyEvent( const document::EventObject& aEvent ) throw (uno::RuntimeException)
    2011             : {
    2012             :     // used only to forward external events (e.g. for doc creation) from the frame loader
    2013             :     // to the global event broadcaster and all other interested doc event listener.
    2014           0 :     notifyEvent(aEvent.EventName);
    2015           0 : }
    2016             : 
    2017             : // document::XViewDataSupplier
    2018           0 : uno::Reference< container::XIndexAccess > SAL_CALL OReportDefinition::getViewData(  ) throw (uno::RuntimeException, std::exception)
    2019             : {
    2020           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2021           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2022           0 :     if ( !m_pImpl->m_xViewData.is() )
    2023             :     {
    2024           0 :         m_pImpl->m_xViewData.set( document::IndexedPropertyValues::create(m_aProps->m_xContext), uno::UNO_QUERY);
    2025           0 :         uno::Reference< container::XIndexContainer > xContainer(m_pImpl->m_xViewData,uno::UNO_QUERY);
    2026           0 :         ::std::vector< uno::Reference< frame::XController> >::iterator aIter = m_pImpl->m_aControllers.begin();
    2027           0 :         ::std::vector< uno::Reference< frame::XController> >::iterator aEnd = m_pImpl->m_aControllers.end();
    2028           0 :         for (;aIter != aEnd ; ++aIter)
    2029             :         {
    2030           0 :             if ( aIter->is() )
    2031             :             {
    2032             :                 try
    2033             :                 {
    2034           0 :                     xContainer->insertByIndex(xContainer->getCount(),(*aIter)->getViewData());
    2035             :                 }
    2036           0 :                 catch (const uno::Exception&)
    2037             :                 {
    2038             :                 }
    2039             :             }
    2040           0 :         }
    2041             : 
    2042             :     }
    2043           0 :     return m_pImpl->m_xViewData;
    2044             : }
    2045             : 
    2046           0 : void SAL_CALL OReportDefinition::setViewData( const uno::Reference< container::XIndexAccess >& Data ) throw (uno::RuntimeException, std::exception)
    2047             : {
    2048           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2049           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2050           0 :     m_pImpl->m_xViewData = Data;
    2051           0 : }
    2052             : 
    2053           0 : uno::Reference< report::XFunctions > SAL_CALL OReportDefinition::getFunctions() throw (uno::RuntimeException, std::exception)
    2054             : {
    2055           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2056           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2057           0 :     return m_pImpl->m_xFunctions;
    2058             : }
    2059             : 
    2060           0 : uno::Reference< ui::XUIConfigurationManager > SAL_CALL OReportDefinition::getUIConfigurationManager(  ) throw (uno::RuntimeException, std::exception)
    2061             : {
    2062           0 :     return uno::Reference< ui::XUIConfigurationManager >( getUIConfigurationManager2(), uno::UNO_QUERY_THROW );
    2063             : }
    2064             : 
    2065           0 : uno::Reference< ui::XUIConfigurationManager2 > OReportDefinition::getUIConfigurationManager2(  ) throw (uno::RuntimeException)
    2066             : {
    2067           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2068           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2069             : 
    2070           0 :     if ( !m_pImpl->m_xUIConfigurationManager.is() )
    2071             :     {
    2072           0 :         m_pImpl->m_xUIConfigurationManager = ui::UIConfigurationManager::create(m_aProps->m_xContext);
    2073             : 
    2074           0 :         uno::Reference< embed::XStorage > xConfigStorage;
    2075             :         // initialize ui configuration manager with document substorage
    2076           0 :         m_pImpl->m_xUIConfigurationManager->setStorage( xConfigStorage );
    2077             :     }
    2078             : 
    2079           0 :     return m_pImpl->m_xUIConfigurationManager;
    2080             : }
    2081             : 
    2082           0 : uno::Reference< embed::XStorage > SAL_CALL OReportDefinition::getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) throw (uno::RuntimeException, std::exception)
    2083             : {
    2084           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2085           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2086           0 :     return m_pImpl->m_xStorage->openStorageElement(aStorageName, nMode);
    2087             : }
    2088             : 
    2089           0 : uno::Sequence< OUString > SAL_CALL OReportDefinition::getDocumentSubStoragesNames(  ) throw (io::IOException, uno::RuntimeException, std::exception)
    2090             : {
    2091           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2092           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2093           0 :     uno::Reference<container::XNameAccess> xNameAccess(m_pImpl->m_xStorage,uno::UNO_QUERY);
    2094           0 :     return xNameAccess.is() ? xNameAccess->getElementNames() : uno::Sequence< OUString >();
    2095             : }
    2096             : 
    2097           0 : OUString SAL_CALL OReportDefinition::getMimeType() throw (uno::RuntimeException, std::exception)
    2098             : {
    2099           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2100           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2101           0 :     return m_pImpl->m_sMimeType;
    2102             : }
    2103             : 
    2104           0 : void SAL_CALL OReportDefinition::setMimeType( const OUString& _mimetype ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    2105             : {
    2106           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2107           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2108           0 :     uno::Sequence< OUString > aList = getAvailableMimeTypes();
    2109           0 :     const OUString* pEnd = aList.getConstArray()+aList.getLength();
    2110           0 :     if ( ::std::find(aList.getConstArray(),pEnd,_mimetype) == pEnd )
    2111             :         throwIllegallArgumentException("getAvailableMimeTypes()"
    2112             :                         ,*this
    2113             :                         ,1
    2114           0 :                         ,m_aProps->m_xContext);
    2115           0 :     set(PROPERTY_MIMETYPE,_mimetype,m_pImpl->m_sMimeType);
    2116           0 : }
    2117             : 
    2118           0 : uno::Sequence< OUString > SAL_CALL OReportDefinition::getAvailableMimeTypes(  ) throw (lang::DisposedException, uno::Exception, uno::RuntimeException, std::exception)
    2119             : {
    2120           0 :     uno::Sequence< OUString > s_aList(2);
    2121           0 :     s_aList[0] = MIMETYPE_OASIS_OPENDOCUMENT_TEXT;
    2122           0 :     s_aList[1] = MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET;
    2123           0 :     return s_aList;
    2124             : }
    2125             : 
    2126             : // com::sun::star::XUnoTunnel
    2127           0 : sal_Int64 SAL_CALL OReportDefinition::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
    2128             : {
    2129           0 :     sal_Int64 nRet = 0;
    2130           0 :     if (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
    2131           0 :         nRet = reinterpret_cast<sal_Int64>(this);
    2132             :     else
    2133             :     {
    2134           0 :         uno::Reference< lang::XUnoTunnel> xUnoTunnel(m_pImpl->m_xNumberFormatsSupplier,uno::UNO_QUERY);
    2135           0 :         if ( xUnoTunnel.is() )
    2136           0 :             nRet = xUnoTunnel->getSomething(rId);
    2137             :     }
    2138           0 :     if ( !nRet )
    2139             :     {
    2140           0 :         uno::Reference< lang::XUnoTunnel> xTunnel;
    2141           0 :         ::comphelper::query_aggregation(m_aProps->m_xProxy,xTunnel);
    2142           0 :         if ( xTunnel.is() )
    2143           0 :             nRet = xTunnel->getSomething(rId);
    2144             :     }
    2145             : 
    2146           0 :     return nRet;
    2147             : }
    2148             : 
    2149           0 : uno::Sequence< sal_Int8 > SAL_CALL OReportDefinition::getImplementationId(  ) throw (uno::RuntimeException, std::exception)
    2150             : {
    2151           0 :     return css::uno::Sequence<sal_Int8>();
    2152             : }
    2153             : 
    2154           0 : uno::Sequence< sal_Int8 > OReportDefinition::getUnoTunnelImplementationId()
    2155             : {
    2156             :     static ::cppu::OImplementationId * pId = 0;
    2157           0 :     if (! pId)
    2158             :     {
    2159           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
    2160           0 :         if (! pId)
    2161             :         {
    2162           0 :             static ::cppu::OImplementationId aId;
    2163           0 :             pId = &aId;
    2164           0 :         }
    2165             :     }
    2166           0 :     return pId->getImplementationId();
    2167             : }
    2168             : 
    2169           0 : uno::Reference< uno::XComponentContext > OReportDefinition::getContext()
    2170             : {
    2171           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2172           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2173           0 :     return m_aProps->m_xContext;
    2174             : }
    2175             : 
    2176           0 : ::boost::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel() const
    2177             : {
    2178           0 :     return m_pImpl->m_pReportModel;
    2179             : }
    2180             : 
    2181           0 : ::boost::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel(const uno::Reference< report::XReportDefinition >& _xReportDefinition)
    2182             : {
    2183           0 :     ::boost::shared_ptr<rptui::OReportModel> pReportModel;
    2184           0 :     uno::Reference< lang::XUnoTunnel > xUT( _xReportDefinition, uno::UNO_QUERY );
    2185           0 :     if( xUT.is() )
    2186           0 :         pReportModel = reinterpret_cast<OReportDefinition*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( OReportDefinition::getUnoTunnelImplementationId())))->getSdrModel();
    2187           0 :     return pReportModel;
    2188             : }
    2189             : 
    2190           0 : uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWithArguments( const OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& _aArgs)
    2191             :     throw( uno::Exception, uno::RuntimeException, std::exception )
    2192             : {
    2193           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2194           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2195             : 
    2196           0 :     uno::Reference< uno::XInterface > xRet;
    2197           0 :     if ( aServiceSpecifier.startsWith( "com.sun.star.document.ImportEmbeddedObjectResolver") )
    2198             :     {
    2199           0 :         uno::Reference< embed::XStorage > xStorage;
    2200           0 :         const uno::Any* pIter = _aArgs.getConstArray();
    2201           0 :         const uno::Any* pEnd  = pIter + _aArgs.getLength();
    2202           0 :         for(;pIter != pEnd ;++pIter)
    2203             :         {
    2204           0 :             beans::NamedValue aValue;
    2205           0 :             *pIter >>= aValue;
    2206           0 :             if ( aValue.Name == "Storage" )
    2207           0 :                 aValue.Value >>= xStorage;
    2208           0 :         }
    2209           0 :         m_pImpl->m_pObjectContainer->SwitchPersistence(xStorage);
    2210           0 :         xRet = static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_READ ));
    2211             :     }
    2212           0 :     return xRet;
    2213             : }
    2214             : 
    2215           0 : uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( const OUString& aServiceSpecifier ) throw(uno::Exception, uno::RuntimeException, std::exception)
    2216             : {
    2217           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2218           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2219           0 :     uno::Reference< drawing::XShape > xShape;
    2220           0 :     if ( aServiceSpecifier.startsWith( "com.sun.star.report." ) )
    2221             :     {
    2222           0 :         if ( aServiceSpecifier == SERVICE_SHAPE )
    2223           0 :             xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.CustomShape"),uno::UNO_QUERY_THROW);
    2224           0 :         else if (   aServiceSpecifier == SERVICE_FORMATTEDFIELD
    2225           0 :             ||      aServiceSpecifier == SERVICE_FIXEDTEXT
    2226           0 :             ||      aServiceSpecifier == SERVICE_FIXEDLINE
    2227           0 :             ||      aServiceSpecifier == SERVICE_IMAGECONTROL )
    2228           0 :             xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.ControlShape"),uno::UNO_QUERY_THROW);
    2229             :         else
    2230           0 :             xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.OLE2Shape"),uno::UNO_QUERY_THROW);
    2231             :     }
    2232           0 :     else if ( aServiceSpecifier.startsWith( "com.sun.star.form.component." ) )
    2233             :     {
    2234           0 :         xShape.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier,m_aProps->m_xContext),uno::UNO_QUERY);
    2235             :     }
    2236           0 :     else if ( aServiceSpecifier == "com.sun.star.style.PageStyle" ||
    2237           0 :               aServiceSpecifier == "com.sun.star.style.FrameStyle" ||
    2238           0 :               aServiceSpecifier == "com.sun.star.style.GraphicStyle"
    2239             :               )
    2240             :     {
    2241           0 :         uno::Reference< style::XStyle> xStyle = new OStyle();
    2242           0 :         xStyle->setName("Default");
    2243           0 :         uno::Reference<beans::XPropertySet> xProp(xStyle,uno::UNO_QUERY);
    2244           0 :         OUString sTray;
    2245           0 :         xProp->getPropertyValue("PrinterPaperTray")>>= sTray;
    2246             : 
    2247           0 :         return xStyle.get();
    2248             :     }
    2249           0 :     else if ( aServiceSpecifier == "com.sun.star.document.Settings" )
    2250             :     {
    2251           0 :         uno::Reference<beans::XPropertySet> xProp = new OStyle();
    2252             : 
    2253           0 :         return xProp.get();
    2254             :     }
    2255           0 :     else if ( aServiceSpecifier == "com.sun.star.drawing.Defaults" )
    2256             :     {
    2257           0 :         uno::Reference<beans::XPropertySet> xProp = new OStyle();
    2258           0 :         return xProp.get();
    2259             :     }
    2260           0 :     else if ( aServiceSpecifier == "com.sun.star.drawing.GradientTable" )
    2261             :     {
    2262           0 :         if ( !m_pImpl->m_xGradientTable.is() )
    2263           0 :             m_pImpl->m_xGradientTable.set(SvxUnoGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
    2264           0 :         return m_pImpl->m_xGradientTable;
    2265             :     }
    2266           0 :     else if ( aServiceSpecifier == "com.sun.star.drawing.HatchTable" )
    2267             :     {
    2268           0 :         if ( !m_pImpl->m_xHatchTable.is() )
    2269           0 :             m_pImpl->m_xHatchTable.set(SvxUnoHatchTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
    2270           0 :         return m_pImpl->m_xHatchTable;
    2271             :     }
    2272           0 :     else if ( aServiceSpecifier == "com.sun.star.drawing.BitmapTable"  )
    2273             :     {
    2274           0 :         if ( !m_pImpl->m_xBitmapTable.is() )
    2275           0 :             m_pImpl->m_xBitmapTable.set(SvxUnoBitmapTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
    2276           0 :         return m_pImpl->m_xBitmapTable;
    2277             :     }
    2278           0 :     else if ( aServiceSpecifier == "com.sun.star.drawing.TransparencyGradientTable" )
    2279             :     {
    2280           0 :         if ( !m_pImpl->m_xTransparencyGradientTable.is() )
    2281           0 :             m_pImpl->m_xTransparencyGradientTable.set(SvxUnoTransGradientTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
    2282           0 :         return m_pImpl->m_xTransparencyGradientTable;
    2283             :     }
    2284           0 :     else if ( aServiceSpecifier == "com.sun.star.drawing.DashTable" )
    2285             :     {
    2286           0 :         if ( !m_pImpl->m_xDashTable.is() )
    2287           0 :             m_pImpl->m_xDashTable.set(SvxUnoDashTable_createInstance(m_pImpl->m_pReportModel.get()),uno::UNO_QUERY);
    2288           0 :         return m_pImpl->m_xDashTable;
    2289             :     }
    2290           0 :     else if( aServiceSpecifier == "com.sun.star.drawing.MarkerTable" )
    2291             :     {
    2292           0 :         if( !m_pImpl->m_xMarkerTable.is() )
    2293           0 :             m_pImpl->m_xMarkerTable.set(SvxUnoMarkerTable_createInstance( m_pImpl->m_pReportModel.get() ),uno::UNO_QUERY);
    2294           0 :         return m_pImpl->m_xMarkerTable;
    2295             :     }
    2296           0 :     else if ( aServiceSpecifier == "com.sun.star.document.ImportEmbeddedObjectResolver" )
    2297           0 :         return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_READ ));
    2298           0 :     else if ( aServiceSpecifier == "com.sun.star.document.ExportEmbeddedObjectResolver" )
    2299           0 :         return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, EMBEDDEDOBJECTHELPER_MODE_WRITE ));
    2300           0 :     else if ( aServiceSpecifier == "com.sun.star.document.ImportGraphicObjectResolver" )
    2301             :     {
    2302           0 :         SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,GRAPHICHELPER_MODE_WRITE);
    2303           0 :         uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(pGraphicHelper));
    2304           0 :         pGraphicHelper->release();
    2305           0 :         return xRet;
    2306             :     }
    2307           0 :     else if ( aServiceSpecifier == "com.sun.star.document.ExportGraphicObjectResolver" )
    2308             :     {
    2309           0 :         SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,GRAPHICHELPER_MODE_WRITE);
    2310           0 :         uno::Reference< uno::XInterface> xRet(static_cast< ::cppu::OWeakObject* >(pGraphicHelper));
    2311           0 :         pGraphicHelper->release();
    2312           0 :         return xRet;
    2313             :     }
    2314           0 :     else if ( aServiceSpecifier == "com.sun.star.chart2.data.DataProvider" )
    2315             :     {
    2316           0 :         uno::Reference<chart2::data::XDatabaseDataProvider> xDataProvider(chart2::data::DatabaseDataProvider::createWithConnection( m_aProps->m_xContext, m_pImpl->m_xActiveConnection ));
    2317           0 :         xDataProvider->setRowLimit(10);
    2318           0 :         uno::Reference< container::XChild > xChild(xDataProvider,uno::UNO_QUERY);
    2319           0 :         if ( xChild.is() )
    2320           0 :             xChild->setParent(*this);
    2321           0 :         return uno::Reference< uno::XInterface >(xDataProvider,uno::UNO_QUERY);
    2322             :     }
    2323           0 :     else if ( aServiceSpecifier == "com.sun.star.xml.NamespaceMap" )
    2324             :     {
    2325           0 :         if ( !m_pImpl->m_xXMLNamespaceMap.is() )
    2326           0 :             m_pImpl->m_xXMLNamespaceMap = comphelper::NameContainer_createInstance( cppu::UnoType<OUString>::get() ).get();
    2327           0 :         return m_pImpl->m_xXMLNamespaceMap;
    2328             :     }
    2329             :     else
    2330           0 :         xShape.set(SvxUnoDrawMSFactory::createInstance( aServiceSpecifier ),uno::UNO_QUERY_THROW);
    2331             : 
    2332           0 :     return m_pImpl->m_pReportModel->createShape(aServiceSpecifier,xShape);
    2333             : }
    2334             : 
    2335           0 : uno::Sequence< OUString > SAL_CALL OReportDefinition::getAvailableServiceNames(void) throw( uno::RuntimeException, std::exception )
    2336             : {
    2337             :     static const OUString aSvxComponentServiceNameList[] =
    2338             :     {
    2339             :         OUString("com.sun.star.form.component.FixedText"),
    2340             :         OUString("com.sun.star.form.component.DatabaseImageControl"),
    2341             :         OUString("com.sun.star.style.PageStyle"),
    2342             :         OUString("com.sun.star.style.GraphicStyle"),
    2343             :         OUString("com.sun.star.style.FrameStyle"),
    2344             :         OUString("com.sun.star.drawing.Defaults"),
    2345             :         OUString("com.sun.star.document.ImportEmbeddedObjectResolver"),
    2346             :         OUString("com.sun.star.document.ExportEmbeddedObjectResolver"),
    2347             :         OUString("com.sun.star.document.ImportGraphicObjectResolver"),
    2348             :         OUString("com.sun.star.document.ExportGraphicObjectResolver"),
    2349             :         OUString("com.sun.star.chart2.data.DataProvider"),
    2350             :         OUString("com.sun.star.xml.NamespaceMap"),
    2351             :         OUString("com.sun.star.document.Settings"),
    2352             :         OUString("com.sun.star.drawing.GradientTable"),
    2353             :         OUString("com.sun.star.drawing.HatchTable"),
    2354             :         OUString("com.sun.star.drawing.BitmapTable"),
    2355             :         OUString("com.sun.star.drawing.TransparencyGradientTable"),
    2356             :         OUString("com.sun.star.drawing.DashTable"),
    2357             :         OUString("com.sun.star.drawing.MarkerTable")
    2358           0 :     };
    2359             : 
    2360             :     static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] );
    2361             : 
    2362           0 :     uno::Sequence< OUString > aSeq( nSvxComponentServiceNameListCount );
    2363           0 :     OUString* pStrings = aSeq.getArray();
    2364           0 :     for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
    2365           0 :         pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
    2366             : 
    2367           0 :     uno::Sequence< OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
    2368           0 :     return concatServiceNames( aParentSeq, aSeq );
    2369             : }
    2370             : 
    2371             : // XShape
    2372           0 : awt::Point SAL_CALL OReportDefinition::getPosition(  ) throw (uno::RuntimeException, std::exception)
    2373             : {
    2374           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2375           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2376           0 :     if ( m_aProps->m_xShape.is() )
    2377           0 :         return m_aProps->m_xShape->getPosition();
    2378           0 :     return awt::Point(m_aProps->m_nPosX,m_aProps->m_nPosY);
    2379             : }
    2380             : 
    2381           0 : void SAL_CALL OReportDefinition::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException, std::exception)
    2382             : {
    2383           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2384           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2385           0 :     if ( m_aProps->m_xShape.is() )
    2386           0 :         m_aProps->m_xShape->setPosition(aPosition);
    2387           0 :     set(PROPERTY_POSITIONX,aPosition.X,m_aProps->m_nPosX);
    2388           0 :     set(PROPERTY_POSITIONY,aPosition.Y,m_aProps->m_nPosY);
    2389           0 : }
    2390             : 
    2391           0 : awt::Size SAL_CALL OReportDefinition::getSize(  ) throw (uno::RuntimeException, std::exception)
    2392             : {
    2393           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2394           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2395           0 :     if ( m_aProps->m_xShape.is() )
    2396           0 :         return m_aProps->m_xShape->getSize();
    2397           0 :     return awt::Size(m_aProps->m_nWidth,m_aProps->m_nHeight);
    2398             : }
    2399             : 
    2400           0 : void SAL_CALL OReportDefinition::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException, std::exception)
    2401             : {
    2402           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2403           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2404           0 :     if ( m_aProps->m_xShape.is() )
    2405           0 :         m_aProps->m_xShape->setSize(aSize);
    2406           0 :     set(PROPERTY_WIDTH,aSize.Width,m_aProps->m_nWidth);
    2407           0 :     set(PROPERTY_HEIGHT,aSize.Height,m_aProps->m_nHeight);
    2408           0 : }
    2409             : 
    2410             : 
    2411             : // XShapeDescriptor
    2412           0 : OUString SAL_CALL OReportDefinition::getShapeType(  ) throw (uno::RuntimeException, std::exception)
    2413             : {
    2414           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2415           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2416           0 :     if ( m_aProps->m_xShape.is() )
    2417           0 :         return m_aProps->m_xShape->getShapeType();
    2418           0 :    return OUString("com.sun.star.drawing.OLE2Shape");
    2419             : }
    2420             : 
    2421             : typedef ::cppu::WeakImplHelper2< container::XNameContainer,
    2422             :                              container::XIndexAccess
    2423             :                             > TStylesBASE;
    2424             : class OStylesHelper:
    2425             :     public cppu::BaseMutex, public TStylesBASE, private boost::noncopyable
    2426             : {
    2427             :     typedef ::std::map< OUString, uno::Any  , ::comphelper::UStringMixLess> TStyleElements;
    2428             :     TStyleElements                                  m_aElements;
    2429             :     ::std::vector<TStyleElements::iterator>         m_aElementsPos;
    2430             :     uno::Type                                       m_aType;
    2431             : 
    2432             : protected:
    2433           0 :     virtual ~OStylesHelper(){}
    2434             : public:
    2435           0 :     OStylesHelper(const uno::Type _aType = cppu::UnoType<container::XElementAccess>::get());
    2436             : 
    2437             :     // XNameContainer
    2438             :     virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException,lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2439             :     virtual void SAL_CALL removeByName( const OUString& Name ) throw(container::NoSuchElementException, lang::WrappedTargetException,uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2440             : 
    2441             :     // XNameReplace
    2442             :     virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException,lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2443             : 
    2444             :     // container::XElementAccess
    2445             :     virtual uno::Type SAL_CALL getElementType(  ) throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2446             :     virtual sal_Bool SAL_CALL hasElements(  ) throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2447             :     // container::XIndexAccess
    2448             :     virtual sal_Int32 SAL_CALL getCount(  ) throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2449             :     virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2450             : 
    2451             :     // container::XNameAccess
    2452             :     virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2453             :     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2454             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
    2455             : };
    2456             : 
    2457           0 : OStylesHelper::OStylesHelper(const uno::Type _aType)
    2458             : : cppu::BaseMutex()
    2459           0 : ,m_aType(_aType)
    2460             : {
    2461           0 : }
    2462             : ;
    2463             : 
    2464             : // container::XElementAccess
    2465           0 : uno::Type SAL_CALL OStylesHelper::getElementType(  ) throw(uno::RuntimeException, std::exception)
    2466             : {
    2467           0 :     return m_aType;
    2468             : }
    2469             : 
    2470           0 : sal_Bool SAL_CALL OStylesHelper::hasElements(  ) throw(uno::RuntimeException, std::exception)
    2471             : {
    2472           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2473           0 :     return !m_aElementsPos.empty();
    2474             : }
    2475             : 
    2476             : // container::XIndexAccess
    2477           0 : sal_Int32 SAL_CALL OStylesHelper::getCount(  ) throw(uno::RuntimeException, std::exception)
    2478             : {
    2479           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2480           0 :     return m_aElementsPos.size();
    2481             : }
    2482             : 
    2483           0 : uno::Any SAL_CALL OStylesHelper::getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2484             : {
    2485           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2486           0 :     if ( Index < 0 || Index >= static_cast<sal_Int32>(m_aElementsPos.size()) )
    2487           0 :         throw lang::IndexOutOfBoundsException();
    2488           0 :     return uno::makeAny(m_aElementsPos[Index]->second);
    2489             : }
    2490             : 
    2491             : // container::XNameAccess
    2492           0 : uno::Any SAL_CALL OStylesHelper::getByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2493             : {
    2494           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2495           0 :     TStyleElements::iterator aFind = m_aElements.find(aName);
    2496           0 :     if ( aFind == m_aElements.end() )
    2497           0 :         throw container::NoSuchElementException();
    2498           0 :     return uno::makeAny(aFind->second);
    2499             : }
    2500             : 
    2501           0 : uno::Sequence< OUString > SAL_CALL OStylesHelper::getElementNames(  ) throw(uno::RuntimeException, std::exception)
    2502             : {
    2503           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2504           0 :     uno::Sequence< OUString > aNameList(m_aElementsPos.size());
    2505             : 
    2506           0 :     OUString* pStringArray = aNameList.getArray();
    2507           0 :     ::std::vector<TStyleElements::iterator>::const_iterator aEnd = m_aElementsPos.end();
    2508           0 :     for(::std::vector<TStyleElements::iterator>::const_iterator aIter = m_aElementsPos.begin();         aIter != aEnd;++aIter,++pStringArray)
    2509           0 :         *pStringArray = (*aIter)->first;
    2510             : 
    2511           0 :     return aNameList;
    2512             : }
    2513             : 
    2514           0 : sal_Bool SAL_CALL OStylesHelper::hasByName( const OUString& aName ) throw(uno::RuntimeException, std::exception)
    2515             : {
    2516           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2517           0 :     return m_aElements.find(aName) != m_aElements.end();
    2518             : }
    2519             : 
    2520             : // XNameContainer
    2521           0 : void SAL_CALL OStylesHelper::insertByName( const OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException,lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2522             : {
    2523           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2524           0 :     if ( m_aElements.find(aName) != m_aElements.end() )
    2525           0 :         throw container::ElementExistException();
    2526             : 
    2527           0 :     if ( !aElement.isExtractableTo(m_aType) )
    2528           0 :         throw lang::IllegalArgumentException();
    2529             : 
    2530           0 :     m_aElementsPos.push_back(m_aElements.insert(TStyleElements::value_type(aName,aElement)).first);
    2531           0 : }
    2532             : 
    2533           0 : void SAL_CALL OStylesHelper::removeByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException,uno::RuntimeException, std::exception)
    2534             : {
    2535           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2536           0 :     TStyleElements::iterator aFind = m_aElements.find(aName);
    2537           0 :     if ( aFind != m_aElements.end() )
    2538           0 :         throw container::NoSuchElementException();
    2539           0 :     m_aElementsPos.erase(::std::find(m_aElementsPos.begin(),m_aElementsPos.end(),aFind));
    2540           0 :     m_aElements.erase(aFind);
    2541           0 : }
    2542             : 
    2543             : // XNameReplace
    2544           0 : void SAL_CALL OStylesHelper::replaceByName( const OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException,lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2545             : {
    2546           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2547           0 :     TStyleElements::iterator aFind = m_aElements.find(aName);
    2548           0 :     if ( aFind == m_aElements.end() )
    2549           0 :         throw container::NoSuchElementException();
    2550           0 :     if ( !aElement.isExtractableTo(m_aType) )
    2551           0 :         throw lang::IllegalArgumentException();
    2552           0 :     aFind->second = aElement;
    2553           0 : }
    2554             : 
    2555           0 : uno::Reference< container::XNameAccess > SAL_CALL OReportDefinition::getStyleFamilies(  ) throw (uno::RuntimeException, std::exception)
    2556             : {
    2557           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2558           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2559           0 :     if ( !m_pImpl->m_xStyles.is() )
    2560             :     {
    2561           0 :         m_pImpl->m_xStyles = new OStylesHelper();
    2562           0 :         uno::Reference< container::XNameContainer> xStyles(m_pImpl->m_xStyles,uno::UNO_QUERY);
    2563             : 
    2564           0 :         uno::Reference< container::XNameContainer> xPageStyles = new OStylesHelper(cppu::UnoType<style::XStyle>::get());
    2565           0 :         xStyles->insertByName(OUString("PageStyles"),uno::makeAny(xPageStyles));
    2566           0 :         uno::Reference< style::XStyle> xPageStyle(createInstance("com.sun.star.style.PageStyle"),uno::UNO_QUERY);
    2567           0 :         xPageStyles->insertByName(xPageStyle->getName(),uno::makeAny(xPageStyle));
    2568             : 
    2569           0 :         uno::Reference< container::XNameContainer> xFrameStyles = new OStylesHelper(cppu::UnoType<style::XStyle>::get());
    2570           0 :         xStyles->insertByName(OUString("FrameStyles"),uno::makeAny(xFrameStyles));
    2571           0 :         uno::Reference< style::XStyle> xFrameStyle(createInstance("com.sun.star.style.FrameStyle"),uno::UNO_QUERY);
    2572           0 :         xFrameStyles->insertByName(xFrameStyle->getName(),uno::makeAny(xFrameStyle));
    2573             : 
    2574           0 :         uno::Reference< container::XNameContainer> xGraphicStyles = new OStylesHelper(cppu::UnoType<style::XStyle>::get());
    2575           0 :         xStyles->insertByName(OUString("graphics"),uno::makeAny(xGraphicStyles));
    2576           0 :         uno::Reference< style::XStyle> xGraphicStyle(createInstance("com.sun.star.style.GraphicStyle"),uno::UNO_QUERY);
    2577           0 :         xGraphicStyles->insertByName(xGraphicStyle->getName(),uno::makeAny(xGraphicStyle));
    2578             :     }
    2579           0 :     return m_pImpl->m_xStyles;
    2580             : }
    2581           0 : OUString SAL_CALL  OReportDefinition::getIdentifier(  ) throw (uno::RuntimeException, std::exception)
    2582             : {
    2583           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2584           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2585           0 :     return m_pImpl->m_sIdentifier;
    2586             : }
    2587             : 
    2588           0 : void SAL_CALL OReportDefinition::setIdentifier( const OUString& Identifier ) throw (uno::RuntimeException, std::exception)
    2589             : {
    2590           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2591           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2592           0 :     m_pImpl->m_sIdentifier = Identifier;
    2593           0 : }
    2594             : 
    2595             : // XNumberFormatsSupplier
    2596           0 : uno::Reference< beans::XPropertySet > SAL_CALL OReportDefinition::getNumberFormatSettings(  ) throw (uno::RuntimeException, std::exception)
    2597             : {
    2598           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2599           0 :     if ( m_pImpl->m_xNumberFormatsSupplier.is() )
    2600           0 :         return m_pImpl->m_xNumberFormatsSupplier->getNumberFormatSettings();
    2601           0 :     return uno::Reference< beans::XPropertySet >();
    2602             : }
    2603             : 
    2604           0 : uno::Reference< util::XNumberFormats > SAL_CALL OReportDefinition::getNumberFormats(  ) throw (uno::RuntimeException, std::exception)
    2605             : {
    2606           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2607           0 :     if ( m_pImpl->m_xNumberFormatsSupplier.is() )
    2608           0 :         return m_pImpl->m_xNumberFormatsSupplier->getNumberFormats();
    2609           0 :     return uno::Reference< util::XNumberFormats >();
    2610             : }
    2611             : 
    2612           0 : ::comphelper::EmbeddedObjectContainer& OReportDefinition::getEmbeddedObjectContainer() const
    2613             : {
    2614           0 :     return *m_pImpl->m_pObjectContainer;
    2615             : }
    2616             : 
    2617           0 : uno::Reference< embed::XStorage > OReportDefinition::getStorage() const
    2618             : {
    2619           0 :     return m_pImpl->m_xStorage;
    2620             : }
    2621             : 
    2622           0 : uno::Reference< task::XInteractionHandler > OReportDefinition::getInteractionHandler() const
    2623             : {
    2624             :     uno::Reference< task::XInteractionHandler > xRet(
    2625           0 :         task::InteractionHandler::createWithParent(m_aProps->m_xContext, 0), uno::UNO_QUERY_THROW);
    2626           0 :     return xRet;
    2627             : }
    2628             : 
    2629           0 : uno::Reference< sdbc::XConnection > SAL_CALL OReportDefinition::getActiveConnection() throw (uno::RuntimeException, std::exception)
    2630             : {
    2631           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2632           0 :     return m_pImpl->m_xActiveConnection;
    2633             : }
    2634             : 
    2635           0 : void SAL_CALL OReportDefinition::setActiveConnection( const uno::Reference< sdbc::XConnection >& _activeconnection ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    2636             : {
    2637           0 :     if ( !_activeconnection.is() )
    2638           0 :         throw lang::IllegalArgumentException();
    2639           0 :     set(PROPERTY_ACTIVECONNECTION,_activeconnection,m_pImpl->m_xActiveConnection);
    2640           0 : }
    2641             : 
    2642           0 : OUString SAL_CALL OReportDefinition::getDataSourceName() throw (uno::RuntimeException, std::exception)
    2643             : {
    2644           0 :     osl::MutexGuard g(m_aMutex);
    2645           0 :     return m_pImpl->m_sDataSourceName;
    2646             : }
    2647             : 
    2648           0 : void SAL_CALL OReportDefinition::setDataSourceName(const OUString& the_value) throw (uno::RuntimeException, std::exception)
    2649             : {
    2650           0 :     set(PROPERTY_DATASOURCENAME,the_value,m_pImpl->m_sDataSourceName);
    2651           0 : }
    2652             : 
    2653           0 : bool OReportDefinition::isEnableSetModified() const
    2654             : {
    2655           0 :     return true;
    2656             : }
    2657             : 
    2658           0 : uno::Reference< frame::XTitle > OReportDefinition::impl_getTitleHelper_throw()
    2659             : {
    2660           0 :     SolarMutexGuard aSolarGuard;
    2661             : 
    2662           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2663           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2664             : 
    2665           0 :     if ( ! m_pImpl->m_xTitleHelper.is ())
    2666             :     {
    2667           0 :         uno::Reference< frame::XDesktop2 >    xDesktop = frame::Desktop::create(m_aProps->m_xContext);
    2668           0 :         uno::Reference< frame::XModel >       xThis(static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
    2669             : 
    2670           0 :         ::framework::TitleHelper* pHelper = new ::framework::TitleHelper( m_aProps->m_xContext );
    2671           0 :         m_pImpl->m_xTitleHelper = uno::Reference< frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
    2672           0 :         pHelper->setOwner                   (xThis   );
    2673           0 :         pHelper->connectWithUntitledNumbers (uno::Reference<frame::XUntitledNumbers>(xDesktop, uno::UNO_QUERY_THROW));
    2674             :     }
    2675             : 
    2676           0 :     return m_pImpl->m_xTitleHelper;
    2677             : }
    2678             : 
    2679           0 : uno::Reference< frame::XUntitledNumbers > OReportDefinition::impl_getUntitledHelper_throw()
    2680             : {
    2681           0 :     SolarMutexGuard aSolarGuard;
    2682             : 
    2683           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2684           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2685             : 
    2686           0 :     if ( ! m_pImpl->m_xNumberedControllers.is ())
    2687             :     {
    2688           0 :         uno::Reference< frame::XModel > xThis   (static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
    2689           0 :         ::comphelper::NumberedCollection*         pHelper = new ::comphelper::NumberedCollection();
    2690           0 :         m_pImpl->m_xNumberedControllers = uno::Reference< frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
    2691             : 
    2692           0 :         pHelper->setOwner          (xThis);
    2693           0 :         pHelper->setUntitledPrefix (OUString(" : "));
    2694             :     }
    2695             : 
    2696           0 :     return m_pImpl->m_xNumberedControllers;
    2697             : }
    2698             : 
    2699             : // css.frame.XTitle
    2700           0 : OUString SAL_CALL OReportDefinition::getTitle()
    2701             :     throw (uno::RuntimeException, std::exception)
    2702             : {
    2703             :     // SYNCHRONIZED ->
    2704           0 :     SolarMutexGuard aSolarGuard;
    2705             : 
    2706           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2707           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2708             : 
    2709           0 :     return impl_getTitleHelper_throw()->getTitle ();
    2710             : }
    2711             : 
    2712             : // css.frame.XTitle
    2713           0 : void SAL_CALL OReportDefinition::setTitle( const OUString& sTitle )
    2714             :     throw (uno::RuntimeException, std::exception)
    2715             : {
    2716             :     // SYNCHRONIZED ->
    2717           0 :     SolarMutexGuard aSolarGuard;
    2718             : 
    2719           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2720           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2721             : 
    2722           0 :     impl_getTitleHelper_throw()->setTitle (sTitle);
    2723           0 : }
    2724             : 
    2725             : // css.frame.XTitleChangeBroadcaster
    2726           0 : void SAL_CALL OReportDefinition::addTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
    2727             :     throw (uno::RuntimeException, std::exception)
    2728             : {
    2729             :     // SYNCHRONIZED ->
    2730           0 :     SolarMutexGuard aSolarGuard;
    2731             : 
    2732           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2733           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2734             : 
    2735           0 :     uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
    2736           0 :     if (xBroadcaster.is ())
    2737           0 :         xBroadcaster->addTitleChangeListener (xListener);
    2738           0 : }
    2739             : 
    2740             : // css.frame.XTitleChangeBroadcaster
    2741           0 : void SAL_CALL OReportDefinition::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
    2742             :     throw (uno::RuntimeException, std::exception)
    2743             : {
    2744             :     // SYNCHRONIZED ->
    2745           0 :     SolarMutexGuard aSolarGuard;
    2746             : 
    2747           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2748           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2749             : 
    2750           0 :     uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), uno::UNO_QUERY);
    2751           0 :     if (xBroadcaster.is ())
    2752           0 :         xBroadcaster->removeTitleChangeListener (xListener);
    2753           0 : }
    2754             : 
    2755             : // css.frame.XUntitledNumbers
    2756           0 : ::sal_Int32 SAL_CALL OReportDefinition::leaseNumber( const uno::Reference< uno::XInterface >& xComponent )
    2757             :     throw (lang::IllegalArgumentException,
    2758             :            uno::RuntimeException, std::exception         )
    2759             : {
    2760             :     // object already disposed?
    2761           0 :     SolarMutexGuard aSolarGuard;
    2762           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2763           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2764             : 
    2765           0 :     return impl_getUntitledHelper_throw()->leaseNumber (xComponent);
    2766             : }
    2767             : 
    2768             : // css.frame.XUntitledNumbers
    2769           0 : void SAL_CALL OReportDefinition::releaseNumber( ::sal_Int32 nNumber )
    2770             :     throw (lang::IllegalArgumentException,
    2771             :            uno::RuntimeException, std::exception         )
    2772             : {
    2773             :     // object already disposed?
    2774           0 :     SolarMutexGuard aSolarGuard;
    2775           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2776           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2777             : 
    2778           0 :     impl_getUntitledHelper_throw()->releaseNumber (nNumber);
    2779           0 : }
    2780             : 
    2781             : // css.frame.XUntitledNumbers
    2782           0 : void SAL_CALL OReportDefinition::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent )
    2783             :     throw (lang::IllegalArgumentException,
    2784             :            uno::RuntimeException, std::exception         )
    2785             : {
    2786             :     // object already disposed?
    2787           0 :     SolarMutexGuard aSolarGuard;
    2788           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2789           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2790             : 
    2791           0 :     impl_getUntitledHelper_throw()->releaseNumberForComponent (xComponent);
    2792           0 : }
    2793             : 
    2794             : // css.frame.XUntitledNumbers
    2795           0 : OUString SAL_CALL OReportDefinition::getUntitledPrefix()
    2796             :     throw (uno::RuntimeException, std::exception)
    2797             : {
    2798             :     // object already disposed?
    2799           0 :     SolarMutexGuard aSolarGuard;
    2800           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2801           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2802             : 
    2803           0 :     return impl_getUntitledHelper_throw()->getUntitledPrefix ();
    2804             : }
    2805             : 
    2806           0 : uno::Reference< document::XDocumentProperties > SAL_CALL OReportDefinition::getDocumentProperties(  ) throw (uno::RuntimeException, std::exception)
    2807             : {
    2808           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2809           0 :     ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed);
    2810           0 :     if ( !m_pImpl->m_xDocumentProperties.is() )
    2811             :     {
    2812           0 :         m_pImpl->m_xDocumentProperties.set(document::DocumentProperties::create(m_aProps->m_xContext));
    2813             :     }
    2814           0 :     return m_pImpl->m_xDocumentProperties;
    2815             : }
    2816             : 
    2817           0 : uno::Reference< uno::XComponentContext > OReportDefinition::getContext() const
    2818             : {
    2819           0 :     return m_aProps->m_xContext;
    2820             : }
    2821             : 
    2822           0 : uno::Any SAL_CALL OReportDefinition::getTransferData( const datatransfer::DataFlavor& aFlavor ) throw (datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException, std::exception)
    2823             : {
    2824           0 :     uno::Any aResult;
    2825           0 :     if( isDataFlavorSupported( aFlavor ) )
    2826             :     {
    2827             :         try
    2828             :         {
    2829           0 :             aResult <<= getPreferredVisualRepresentation(0).Data;
    2830             :         }
    2831           0 :         catch (const uno::Exception &)
    2832             :         {
    2833             :             DBG_UNHANDLED_EXCEPTION();
    2834             :         }
    2835             :     }
    2836             :     else
    2837             :     {
    2838           0 :         throw datatransfer::UnsupportedFlavorException(aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this ));
    2839             :     }
    2840             : 
    2841           0 :     return aResult;
    2842             : }
    2843             : 
    2844           0 : uno::Sequence< datatransfer::DataFlavor > SAL_CALL OReportDefinition::getTransferDataFlavors(  ) throw (uno::RuntimeException, std::exception)
    2845             : {
    2846           0 :     uno::Sequence< datatransfer::DataFlavor > aRet(1);
    2847             : 
    2848           0 :     aRet[0] = datatransfer::DataFlavor( OUString("image/png"),
    2849             :         OUString("PNG"),
    2850           0 :         ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
    2851             : 
    2852           0 :     return aRet;
    2853             : }
    2854             : 
    2855           0 : sal_Bool SAL_CALL OReportDefinition::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor ) throw (uno::RuntimeException, std::exception)
    2856             : {
    2857           0 :     return aFlavor.MimeType == "image/png";
    2858             : }
    2859             : 
    2860             : 
    2861           0 : uno::Reference< document::XUndoManager > SAL_CALL OReportDefinition::getUndoManager(  ) throw (uno::RuntimeException, std::exception)
    2862             : {
    2863           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    2864           0 :     return m_pImpl->m_pUndoManager.get();
    2865             : }
    2866             : 
    2867           6 : }// namespace reportdesign
    2868             : 
    2869             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10