LCOV - code coverage report
Current view: top level - reportdesign/source/core/sdr - RptObject.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 604 0.0 %
Date: 2014-04-11 Functions: 0 100 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #include "RptObject.hxx"
      20             : #include <vector>
      21             : #include <algorithm>
      22             : 
      23             : #include <RptDef.hxx>
      24             : #include <svx/unoshape.hxx>
      25             : #include "RptModel.hxx"
      26             : #include "RptObjectListener.hxx"
      27             : #include <toolkit/helper/vclunohelper.hxx>
      28             : #include <toolkit/helper/convert.hxx>
      29             : #include "RptPage.hxx"
      30             : #include "corestrings.hrc"
      31             : #include <dbaccess/dbsubcomponentcontroller.hxx>
      32             : #include "ModuleHelper.hxx"
      33             : 
      34             : #include <RptResId.hrc>
      35             : #include <svx/xflclit.hxx>
      36             : #include <svx/xlnclit.hxx>
      37             : #include <svx/xlndsit.hxx>
      38             : #include <svx/xlineit0.hxx>
      39             : #include <svx/sderitm.hxx>
      40             : #include <svx/xlnwtit.hxx>
      41             : #include <svx/xlntrit.hxx>
      42             : #include <com/sun/star/style/XStyle.hpp>
      43             : #include <com/sun/star/awt/XTabControllerModel.hpp>
      44             : #include <com/sun/star/awt/XUnoControlContainer.hpp>
      45             : #include <com/sun/star/awt/XVclContainerPeer.hpp>
      46             : #include <com/sun/star/awt/XWindow.hpp>
      47             : #include <com/sun/star/awt/TextAlign.hpp>
      48             : #include <com/sun/star/beans/XPropertySet.hpp>
      49             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      50             : #include <com/sun/star/embed/XComponentSupplier.hpp>
      51             : #include <com/sun/star/script/XScriptEventsSupplier.hpp>
      52             : #include <com/sun/star/container/XContainer.hpp>
      53             : #include <com/sun/star/lang/XServiceInfo.hpp>
      54             : #include <com/sun/star/report/XShape.hpp>
      55             : #include <com/sun/star/report/XFixedLine.hpp>
      56             : #include <com/sun/star/chart/ChartDataRowSource.hpp>
      57             : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
      58             : #include <com/sun/star/chart2/data/DatabaseDataProvider.hpp>
      59             : #include <com/sun/star/chart2/XChartDocument.hpp>
      60             : #include <com/sun/star/style/VerticalAlignment.hpp>
      61             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      62             : #include <com/sun/star/report/XFormattedField.hpp>
      63             : #include <comphelper/genericpropertyset.hxx>
      64             : #include <comphelper/processfactory.hxx>
      65             : #include <comphelper/property.hxx>
      66             : #include <tools/diagnose_ex.h>
      67             : #include "PropertyForward.hxx"
      68             : #include <connectivity/dbtools.hxx>
      69             : #include <connectivity/dbconversion.hxx>
      70             : #include "UndoActions.hxx"
      71             : #include "UndoEnv.hxx"
      72             : #include <functional>
      73             : 
      74             : namespace rptui
      75             : {
      76             : 
      77             : using namespace ::com::sun::star;
      78             : using namespace uno;
      79             : using namespace beans;
      80             : using namespace reportdesign;
      81             : using namespace container;
      82             : using namespace script;
      83             : using namespace report;
      84             : 
      85           0 : sal_uInt16 OObjectBase::getObjectType(const uno::Reference< report::XReportComponent>& _xComponent)
      86             : {
      87           0 :     uno::Reference< lang::XServiceInfo > xServiceInfo( _xComponent , uno::UNO_QUERY );
      88             :     OSL_ENSURE(xServiceInfo.is(),"Who deletes the XServiceInfo interface!");
      89           0 :     if ( xServiceInfo.is() )
      90             :     {
      91           0 :         if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT ))
      92           0 :             return OBJ_DLG_FIXEDTEXT;
      93           0 :         if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE ))
      94             :         {
      95           0 :             uno::Reference< report::XFixedLine> xFixedLine(_xComponent,uno::UNO_QUERY);
      96           0 :             return xFixedLine->getOrientation() ? OBJ_DLG_HFIXEDLINE : OBJ_DLG_VFIXEDLINE;
      97             :         }
      98           0 :         if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL))
      99           0 :             return OBJ_DLG_IMAGECONTROL;
     100           0 :         if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD ))
     101           0 :             return OBJ_DLG_FORMATTEDFIELD;
     102           0 :         if ( xServiceInfo->supportsService("com.sun.star.drawing.OLE2Shape") )
     103           0 :             return OBJ_OLE2;
     104           0 :         if ( xServiceInfo->supportsService( SERVICE_SHAPE ))
     105           0 :             return OBJ_CUSTOMSHAPE;
     106           0 :         if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) )
     107           0 :             return OBJ_DLG_SUBREPORT;
     108           0 :         return OBJ_OLE2;
     109             :     }
     110           0 :     return 0;
     111             : }
     112             : 
     113           0 : SdrObject* OObjectBase::createObject(const uno::Reference< report::XReportComponent>& _xComponent)
     114             : {
     115           0 :     SdrObject* pNewObj = NULL;
     116           0 :     sal_uInt16 nType = OObjectBase::getObjectType(_xComponent);
     117           0 :     switch( nType )
     118             :     {
     119             :         case OBJ_DLG_FIXEDTEXT:
     120             :             {
     121             :                 OUnoObject* pUnoObj = new OUnoObject( _xComponent
     122             :                                     ,OUString("com.sun.star.form.component.FixedText")
     123           0 :                                     ,OBJ_DLG_FIXEDTEXT);
     124           0 :                 pNewObj = pUnoObj;
     125             : 
     126           0 :                 uno::Reference<beans::XPropertySet> xControlModel(pUnoObj->GetUnoControlModel(),uno::UNO_QUERY);
     127           0 :                 if ( xControlModel.is() )
     128           0 :                     xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True));
     129             :             }
     130           0 :             break;
     131             :         case OBJ_DLG_IMAGECONTROL:
     132             :             pNewObj = new OUnoObject(_xComponent
     133             :                                     ,OUString("com.sun.star.form.component.DatabaseImageControl")
     134           0 :                                     ,OBJ_DLG_IMAGECONTROL);
     135           0 :             break;
     136             :         case OBJ_DLG_FORMATTEDFIELD:
     137             :             pNewObj = new OUnoObject( _xComponent
     138             :                                     ,OUString("com.sun.star.form.component.FormattedField")
     139           0 :                                     ,OBJ_DLG_FORMATTEDFIELD);
     140           0 :             break;
     141             :         case OBJ_DLG_HFIXEDLINE:
     142             :         case OBJ_DLG_VFIXEDLINE:
     143             :             pNewObj = new OUnoObject( _xComponent
     144             :                                     ,OUString("com.sun.star.awt.UnoControlFixedLineModel")
     145           0 :                                     ,nType);
     146           0 :             break;
     147             :         case OBJ_CUSTOMSHAPE:
     148           0 :             pNewObj = OCustomShape::Create( _xComponent );
     149             :             try
     150             :             {
     151           0 :                 sal_Bool bOpaque = sal_False;
     152           0 :                 _xComponent->getPropertyValue(PROPERTY_OPAQUE) >>= bOpaque;
     153           0 :                 pNewObj->NbcSetLayer(bOpaque ? RPT_LAYER_FRONT : RPT_LAYER_BACK);
     154             :             }
     155           0 :             catch(const uno::Exception&)
     156             :             {
     157             :                 DBG_UNHANDLED_EXCEPTION();
     158             :             }
     159           0 :             break;
     160             :         case OBJ_DLG_SUBREPORT:
     161             :         case OBJ_OLE2:
     162           0 :             pNewObj = OOle2Obj::Create( _xComponent,nType );
     163           0 :             break;
     164             :         default:
     165             :             OSL_FAIL("Unknown object id");
     166           0 :             break;
     167             :     }
     168             : 
     169           0 :     if ( pNewObj )
     170           0 :         pNewObj->SetDoNotInsertIntoPageAutomatically( true );
     171             : 
     172           0 :     ensureSdrObjectOwnership( _xComponent );
     173             : 
     174           0 :     return pNewObj;
     175             : }
     176             : 
     177             : namespace
     178             : {
     179           0 :     class ParaAdjust : public AnyConverter
     180             :     {
     181             :     public:
     182           0 :         virtual ::com::sun::star::uno::Any operator() (const OUString& _sPropertyName,const ::com::sun::star::uno::Any& lhs) const SAL_OVERRIDE
     183             :         {
     184           0 :             uno::Any aRet;
     185           0 :             if (_sPropertyName == PROPERTY_PARAADJUST)
     186             :             {
     187           0 :                 sal_Int16 nTextAlign = 0;
     188           0 :                 lhs >>= nTextAlign;
     189           0 :                 switch(nTextAlign)
     190             :                 {
     191             :                     case awt::TextAlign::LEFT:
     192           0 :                         nTextAlign = style::ParagraphAdjust_LEFT;
     193           0 :                         break;
     194             :                     case awt::TextAlign::CENTER:
     195           0 :                         nTextAlign = style::ParagraphAdjust_CENTER;
     196           0 :                         break;
     197             :                     case awt::TextAlign::RIGHT:
     198           0 :                         nTextAlign = style::ParagraphAdjust_RIGHT;
     199           0 :                         break;
     200             :                     default:
     201             :                         OSL_FAIL("Illegal text alignment value!");
     202           0 :                         break;
     203             :                 }
     204           0 :                 aRet <<= (style::ParagraphAdjust)nTextAlign;
     205             :             }
     206             :             else
     207             :             {
     208           0 :                 sal_Int16 nTextAlign = 0;
     209           0 :                 sal_Int16 eParagraphAdjust = 0;
     210           0 :                 lhs >>= eParagraphAdjust;
     211           0 :                 switch(eParagraphAdjust)
     212             :                 {
     213             :                     case style::ParagraphAdjust_LEFT:
     214             :                     case style::ParagraphAdjust_BLOCK:
     215           0 :                         nTextAlign = awt::TextAlign::LEFT;
     216           0 :                         break;
     217             :                     case style::ParagraphAdjust_CENTER:
     218           0 :                         nTextAlign = awt::TextAlign::CENTER;
     219           0 :                         break;
     220             :                     case style::ParagraphAdjust_RIGHT:
     221           0 :                         nTextAlign = awt::TextAlign::RIGHT;
     222           0 :                         break;
     223             :                     default:
     224             :                         OSL_FAIL("Illegal text alignment value!");
     225           0 :                         break;
     226             :                 }
     227           0 :                 aRet <<= nTextAlign;
     228             :             }
     229           0 :             return aRet;
     230             :         }
     231             :     };
     232             : }
     233             : 
     234           0 : const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId)
     235             : {
     236           0 :     switch(_nObjectId)
     237             :     {
     238             :         case OBJ_DLG_IMAGECONTROL:
     239             :             {
     240           0 :                 static TPropertyNamePair s_aNameMap;
     241           0 :                 if ( s_aNameMap.empty() )
     242             :                 {
     243           0 :                     ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
     244           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter)));
     245           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter)));
     246           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter)));
     247             :                 }
     248           0 :                 return s_aNameMap;
     249             :             }
     250             : 
     251             :         case OBJ_DLG_FIXEDTEXT:
     252             :             {
     253           0 :                 static TPropertyNamePair s_aNameMap;
     254           0 :                 if ( s_aNameMap.empty() )
     255             :                 {
     256           0 :                     ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
     257           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR,TPropertyConverter(PROPERTY_TEXTCOLOR,aNoConverter)));
     258           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter)));
     259           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR,TPropertyConverter(PROPERTY_TEXTLINECOLOR,aNoConverter)));
     260           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF,TPropertyConverter(PROPERTY_FONTRELIEF,aNoConverter)));
     261           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT,TPropertyConverter(PROPERTY_FONTHEIGHT,aNoConverter)));
     262           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT,TPropertyConverter(PROPERTY_FONTSTRIKEOUT,aNoConverter)));
     263           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK,TPropertyConverter(PROPERTY_FONTEMPHASISMARK,aNoConverter)));
     264           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter)));
     265           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter)));
     266             : 
     267           0 :                     ::boost::shared_ptr<AnyConverter> aParaAdjust(new ParaAdjust());
     268           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aParaAdjust)));
     269             :                 }
     270           0 :                 return s_aNameMap;
     271             :             }
     272             :         case OBJ_DLG_FORMATTEDFIELD:
     273             :             {
     274           0 :                 static TPropertyNamePair s_aNameMap;
     275           0 :                 if ( s_aNameMap.empty() )
     276             :                 {
     277           0 :                     ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
     278           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARCOLOR,TPropertyConverter(PROPERTY_TEXTCOLOR,aNoConverter)));
     279           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBACKGROUND,TPropertyConverter(PROPERTY_BACKGROUNDCOLOR,aNoConverter)));
     280           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARUNDERLINECOLOR,TPropertyConverter(PROPERTY_TEXTLINECOLOR,aNoConverter)));
     281           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARRELIEF,TPropertyConverter(PROPERTY_FONTRELIEF,aNoConverter)));
     282           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARFONTHEIGHT,TPropertyConverter(PROPERTY_FONTHEIGHT,aNoConverter)));
     283           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CHARSTRIKEOUT,TPropertyConverter(PROPERTY_FONTSTRIKEOUT,aNoConverter)));
     284           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLTEXTEMPHASISMARK,TPropertyConverter(PROPERTY_FONTEMPHASISMARK,aNoConverter)));
     285           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDER,TPropertyConverter(PROPERTY_BORDER,aNoConverter)));
     286           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_CONTROLBORDERCOLOR,TPropertyConverter(PROPERTY_BORDERCOLOR,aNoConverter)));
     287           0 :                     ::boost::shared_ptr<AnyConverter> aParaAdjust(new ParaAdjust());
     288           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aParaAdjust)));
     289             :                 }
     290           0 :                 return s_aNameMap;
     291             :             }
     292             : 
     293             :         case OBJ_CUSTOMSHAPE:
     294             :             {
     295           0 :                 static TPropertyNamePair s_aNameMap;
     296           0 :                 if ( s_aNameMap.empty() )
     297             :                 {
     298           0 :                     ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
     299           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(OUString("FillColor"),TPropertyConverter(PROPERTY_CONTROLBACKGROUND,aNoConverter)));
     300           0 :                     s_aNameMap.insert(TPropertyNamePair::value_type(PROPERTY_PARAADJUST,TPropertyConverter(PROPERTY_ALIGN,aNoConverter)));
     301             :                 }
     302           0 :                 return s_aNameMap;
     303             :             }
     304             : 
     305             :         default:
     306           0 :             break;
     307             :     }
     308           0 :     static TPropertyNamePair s_aEmptyNameMap;
     309           0 :     return s_aEmptyNameMap;
     310             : }
     311             : 
     312             : 
     313           0 : OObjectBase::OObjectBase(const uno::Reference< report::XReportComponent>& _xComponent)
     314           0 : :m_bIsListening(sal_False)
     315             : {
     316           0 :     m_xReportComponent = _xComponent;
     317           0 : }
     318             : 
     319           0 : OObjectBase::OObjectBase(const OUString& _sComponentName)
     320             : :m_sComponentName(_sComponentName)
     321           0 : ,m_bIsListening(sal_False)
     322             : {
     323           0 : }
     324             : 
     325           0 : OObjectBase::~OObjectBase()
     326             : {
     327           0 :     m_xMediator.reset();
     328           0 :     if ( isListening() )
     329           0 :         EndListening();
     330           0 :     m_xReportComponent.clear();
     331           0 : }
     332             : 
     333           0 : uno::Reference< report::XSection> OObjectBase::getSection() const
     334             : {
     335           0 :     uno::Reference< report::XSection> xSection;
     336           0 :     OReportPage* pPage = dynamic_cast<OReportPage*>(GetImplPage());
     337           0 :     if ( pPage )
     338           0 :         xSection = pPage->getSection();
     339           0 :     return xSection;
     340             : }
     341             : 
     342           0 : uno::Reference< report::XReportComponent> OObjectBase::getReportComponent() const
     343             : {
     344           0 :     return m_xReportComponent;
     345             : }
     346             : 
     347           0 : uno::Reference< beans::XPropertySet> OObjectBase::getAwtComponent()
     348             : {
     349           0 :     return uno::Reference< beans::XPropertySet>();
     350             : }
     351             : 
     352           0 : void OObjectBase::StartListening()
     353             : {
     354             :     OSL_ENSURE(!isListening(), "OUnoObject::StartListening: already listening!");
     355             : 
     356           0 :     if ( !isListening() && m_xReportComponent.is() )
     357             :     {
     358           0 :         m_bIsListening = sal_True;
     359             : 
     360           0 :         if ( !m_xPropertyChangeListener.is() )
     361             :         {
     362           0 :             m_xPropertyChangeListener = new OObjectListener( this );
     363             :             // register listener to all properties
     364           0 :             m_xReportComponent->addPropertyChangeListener( OUString() , m_xPropertyChangeListener );
     365             :         }
     366             :     }
     367           0 : }
     368             : 
     369           0 : void OObjectBase::EndListening(sal_Bool /*bRemoveListener*/)
     370             : {
     371             :     OSL_ENSURE(!m_xReportComponent.is() || isListening(), "OUnoObject::EndListening: not listening currently!");
     372             : 
     373           0 :     m_bIsListening = sal_False;
     374           0 :     if ( isListening() && m_xReportComponent.is() )
     375             :     {
     376             :         // XPropertyChangeListener
     377           0 :         if ( m_xPropertyChangeListener.is() )
     378             :         {
     379             :             // remove listener
     380             :             try
     381             :             {
     382           0 :                 m_xReportComponent->removePropertyChangeListener( OUString() , m_xPropertyChangeListener );
     383             :             }
     384           0 :             catch(const uno::Exception &)
     385             :             {
     386             :                 OSL_FAIL("OObjectBase::EndListening: Exception caught!");
     387             :             }
     388             :         }
     389           0 :         m_xPropertyChangeListener.clear();
     390             :     }
     391           0 : }
     392             : 
     393           0 : void OObjectBase::SetPropsFromRect(const Rectangle& _rRect)
     394             : {
     395             :     // set properties
     396           0 :     OReportPage* pPage = dynamic_cast<OReportPage*>(GetImplPage());
     397           0 :     if ( pPage && !_rRect.IsEmpty() )
     398             :     {
     399           0 :         uno::Reference<report::XSection> xSection = pPage->getSection();
     400             :         assert(_rRect.getHeight() >= 0);
     401           0 :         const sal_uInt32 newHeight( ::std::max(0l, _rRect.getHeight()+_rRect.Top()) );
     402           0 :         if ( xSection.is() && ( newHeight > xSection->getHeight() ) )
     403           0 :             xSection->setHeight( newHeight );
     404             : 
     405             :         // TODO
     406             :         //pModel->GetRefDevice()->Invalidate(INVALIDATE_CHILDREN);
     407             :     }
     408           0 : }
     409             : 
     410           0 : void OObjectBase::_propertyChange( const  beans::PropertyChangeEvent& /*evt*/ ) throw( uno::RuntimeException)
     411             : {
     412           0 : }
     413             : 
     414           0 : void OObjectBase::SetObjectItemHelper(const SfxPoolItem& /*rItem*/)
     415             : {
     416             :     // do nothing
     417           0 : }
     418             : 
     419             : 
     420           0 : sal_Bool OObjectBase::supportsService( const OUString& _sServiceName ) const
     421             : {
     422           0 :     sal_Bool bSupports = sal_False;
     423             : 
     424           0 :     Reference< lang::XServiceInfo > xServiceInfo( m_xReportComponent , UNO_QUERY );
     425             :         // TODO: cache xServiceInfo as member?
     426           0 :     if ( xServiceInfo.is() )
     427           0 :         bSupports = xServiceInfo->supportsService( _sServiceName );
     428             : 
     429           0 :     return bSupports;
     430             : }
     431             : 
     432             : 
     433           0 : void OObjectBase::ensureSdrObjectOwnership( const uno::Reference< uno::XInterface >& _rxShape )
     434             : {
     435             :     // UNDO in the report designer is implemented at the level of the XShapes, not
     436             :     // at the level of SdrObjects. That is, if an object is removed from the report
     437             :     // design, then this happens by removing the XShape from the UNO DrawPage, and
     438             :     // putting this XShape (resp. the ReportComponent which wraps it) into an UNDO
     439             :     // action.
     440             :     // Unfortunately, the SvxDrawPage implementation usually deletes SdrObjects
     441             :     // which are removed from it, which is deadly for us. To prevent this,
     442             :     // we give the XShape implementation the ownership of the SdrObject, which
     443             :     // ensures the SvxDrawPage won't delete it.
     444           0 :     SvxShape* pShape = SvxShape::getImplementation( _rxShape );
     445             :     OSL_ENSURE( pShape, "OObjectBase::ensureSdrObjectOwnership: can't access the SvxShape!" );
     446           0 :     if ( pShape )
     447             :     {
     448             :         OSL_ENSURE( !pShape->HasSdrObjectOwnership(), "OObjectBase::ensureSdrObjectOwnership: called twice?" );
     449           0 :         pShape->TakeSdrObjectOwnership();
     450             :     }
     451           0 : }
     452             : 
     453             : 
     454           0 : uno::Reference< uno::XInterface > OObjectBase::getUnoShapeOf( SdrObject& _rSdrObject )
     455             : {
     456           0 :     uno::Reference< uno::XInterface > xShape( _rSdrObject.getWeakUnoShape() );
     457           0 :     if ( xShape.is() )
     458           0 :         return xShape;
     459             : 
     460           0 :     xShape = _rSdrObject.SdrObject::getUnoShape();
     461           0 :     if ( !xShape.is() )
     462           0 :         return xShape;
     463             : 
     464           0 :     ensureSdrObjectOwnership( xShape );
     465             : 
     466           0 :     m_xKeepShapeAlive = xShape;
     467           0 :     return xShape;
     468             : }
     469             : 
     470             : 
     471           0 : TYPEINIT1(OCustomShape, SdrObjCustomShape);
     472           0 : OCustomShape::OCustomShape(const uno::Reference< report::XReportComponent>& _xComponent
     473             :                            )
     474             :           :SdrObjCustomShape()
     475           0 :           ,OObjectBase(_xComponent)
     476             : {
     477           0 :     impl_setUnoShape( uno::Reference< uno::XInterface >(_xComponent,uno::UNO_QUERY) );
     478           0 :     m_bIsListening = sal_True;
     479           0 : }
     480             : 
     481           0 : OCustomShape::OCustomShape(const OUString& _sComponentName)
     482             :           :SdrObjCustomShape()
     483           0 :           ,OObjectBase(_sComponentName)
     484             : {
     485           0 :     m_bIsListening = sal_True;
     486           0 : }
     487             : 
     488             : 
     489           0 : OCustomShape::~OCustomShape()
     490             : {
     491           0 : }
     492             : 
     493           0 : sal_uInt16 OCustomShape::GetObjIdentifier() const
     494             : {
     495           0 :     return sal_uInt16(OBJ_CUSTOMSHAPE);
     496             : }
     497             : 
     498           0 : sal_uInt32 OCustomShape::GetObjInventor() const
     499             : {
     500           0 :     return ReportInventor;
     501             : }
     502             : 
     503           0 : SdrPage* OCustomShape::GetImplPage() const
     504             : {
     505           0 :     return GetPage();
     506             : }
     507             : 
     508           0 : void OCustomShape::SetSnapRectImpl(const Rectangle& _rRect)
     509             : {
     510           0 :     SetSnapRect( _rRect );
     511           0 : }
     512             : 
     513           0 : sal_Int32 OCustomShape::GetStep() const
     514             : {
     515             :     // get step property
     516           0 :     sal_Int32 nStep = 0;
     517             :     OSL_FAIL("Who called me!");
     518           0 :     return nStep;
     519             : }
     520             : 
     521           0 : void OCustomShape::NbcMove( const Size& rSize )
     522             : {
     523           0 :     if ( m_bIsListening )
     524             :     {
     525           0 :         m_bIsListening = sal_False;
     526             : 
     527           0 :         if ( m_xReportComponent.is() )
     528             :         {
     529           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     530           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     531           0 :             m_xReportComponent->setPositionX(m_xReportComponent->getPositionX() + rSize.A());
     532           0 :             m_xReportComponent->setPositionY(m_xReportComponent->getPositionY() + rSize.B());
     533             :         }
     534             : 
     535             :         // set geometry properties
     536           0 :         SetPropsFromRect(GetSnapRect());
     537             : 
     538           0 :         m_bIsListening = sal_True;
     539             :     }
     540             :     else
     541           0 :         SdrObjCustomShape::NbcMove( rSize );
     542           0 : }
     543             : 
     544           0 : void OCustomShape::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
     545             : {
     546           0 :     SdrObjCustomShape::NbcResize( rRef, xFract, yFract );
     547             : 
     548           0 :     SetPropsFromRect(GetSnapRect());
     549           0 : }
     550             : 
     551           0 : void OCustomShape::NbcSetLogicRect(const Rectangle& rRect)
     552             : {
     553           0 :     SdrObjCustomShape::NbcSetLogicRect(rRect);
     554           0 :     SetPropsFromRect(rRect);
     555           0 : }
     556             : 
     557           0 : bool OCustomShape::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
     558             : {
     559           0 :     bool bResult = SdrObjCustomShape::EndCreate(rStat, eCmd);
     560           0 :     if ( bResult )
     561             :     {
     562           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     563           0 :         if ( pRptModel )
     564             :         {
     565           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     566           0 :             if ( !m_xReportComponent.is() )
     567           0 :                 m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
     568             :         }
     569           0 :         SetPropsFromRect(GetSnapRect());
     570             :     }
     571             : 
     572           0 :     return bResult;
     573             : }
     574             : 
     575             : 
     576           0 : void OCustomShape::SetObjectItemHelper(const SfxPoolItem& rItem)
     577             : {
     578           0 :     SetObjectItem(rItem);
     579             :     // TODO
     580             :     //getSectionWindow()->getView()->AdjustMarkHdl();
     581           0 : }
     582             : 
     583             : 
     584           0 : uno::Reference< beans::XPropertySet> OCustomShape::getAwtComponent()
     585             : {
     586           0 :     return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY);
     587             : }
     588             : 
     589             : 
     590           0 : uno::Reference< uno::XInterface > OCustomShape::getUnoShape()
     591             : {
     592           0 :     uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this );
     593           0 :     if ( !m_xReportComponent.is() )
     594             :     {
     595           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     596           0 :         OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     597           0 :         m_xReportComponent.set(xShape,uno::UNO_QUERY);
     598             :     }
     599           0 :     return xShape;
     600             : }
     601             : 
     602           0 : void OCustomShape::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
     603             : {
     604           0 :     SdrObjCustomShape::impl_setUnoShape( rxUnoShape );
     605           0 :     releaseUnoShape();
     606           0 :     m_xReportComponent.clear();
     607           0 : }
     608             : 
     609             : 
     610             : 
     611           0 : TYPEINIT1(OUnoObject, SdrUnoObj);
     612             : 
     613           0 : OUnoObject::OUnoObject(const OUString& _sComponentName
     614             :                        ,const OUString& rModelName
     615             :                        ,sal_uInt16   _nObjectType)
     616             :           :SdrUnoObj(rModelName, true)
     617             :           ,OObjectBase(_sComponentName)
     618           0 :           ,m_nObjectType(_nObjectType)
     619             : {
     620           0 :     if ( !rModelName.isEmpty() )
     621           0 :         impl_initializeModel_nothrow();
     622           0 : }
     623             : 
     624           0 : OUnoObject::OUnoObject(const uno::Reference< report::XReportComponent>& _xComponent
     625             :                        ,const OUString& rModelName
     626             :                        ,sal_uInt16   _nObjectType)
     627             :           :SdrUnoObj(rModelName, true)
     628             :           ,OObjectBase(_xComponent)
     629           0 :           ,m_nObjectType(_nObjectType)
     630             : {
     631           0 :     impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) );
     632             : 
     633           0 :     if ( !rModelName.isEmpty() )
     634           0 :         impl_initializeModel_nothrow();
     635             : 
     636           0 : }
     637             : 
     638           0 : OUnoObject::~OUnoObject()
     639             : {
     640           0 : }
     641             : 
     642           0 : void OUnoObject::impl_initializeModel_nothrow()
     643             : {
     644             :     try
     645             :     {
     646           0 :         Reference< XFormattedField > xFormatted( m_xReportComponent, UNO_QUERY );
     647           0 :         if ( xFormatted.is() )
     648             :         {
     649           0 :             const Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW );
     650           0 :             const OUString sTreatAsNumberProperty = "TreatAsNumber";
     651           0 :             xModelProps->setPropertyValue( sTreatAsNumberProperty, makeAny( sal_False ) );
     652           0 :             xModelProps->setPropertyValue( PROPERTY_VERTICALALIGN,m_xReportComponent->getPropertyValue(PROPERTY_VERTICALALIGN));
     653           0 :         }
     654             :     }
     655           0 :     catch( const Exception& )
     656             :     {
     657             :         DBG_UNHANDLED_EXCEPTION();
     658             :     }
     659           0 : }
     660             : 
     661           0 : void OUnoObject::impl_setReportComponent_nothrow()
     662             : {
     663           0 :     if ( m_xReportComponent.is() )
     664           0 :         return;
     665             : 
     666           0 :     OReportModel* pReportModel = static_cast<OReportModel*>(GetModel());
     667             :     OSL_ENSURE( pReportModel, "OUnoObject::impl_setReportComponent_nothrow: no report model!" );
     668           0 :     if ( !pReportModel )
     669           0 :         return;
     670             : 
     671           0 :     OXUndoEnvironment::OUndoEnvLock aLock( pReportModel->GetUndoEnv() );
     672           0 :     m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
     673             : 
     674           0 :     impl_initializeModel_nothrow();
     675             : }
     676             : 
     677           0 : sal_uInt16 OUnoObject::GetObjIdentifier() const
     678             : {
     679           0 :     return sal_uInt16(m_nObjectType);
     680             : }
     681             : 
     682           0 : sal_uInt32 OUnoObject::GetObjInventor() const
     683             : {
     684           0 :     return ReportInventor;
     685             : }
     686             : 
     687           0 : SdrPage* OUnoObject::GetImplPage() const
     688             : {
     689           0 :     return GetPage();
     690             : }
     691             : 
     692           0 : void OUnoObject::SetSnapRectImpl(const Rectangle& _rRect)
     693             : {
     694           0 :     SetSnapRect( _rRect );
     695           0 : }
     696             : 
     697           0 : sal_Int32 OUnoObject::GetStep() const
     698             : {
     699             :     // get step property
     700           0 :     sal_Int32 nStep = 0;
     701             :     OSL_FAIL("Who called me!");
     702           0 :     return nStep;
     703             : }
     704             : 
     705             : 
     706           0 : void OUnoObject::NbcMove( const Size& rSize )
     707             : {
     708             : 
     709           0 :     if ( m_bIsListening )
     710             :     {
     711             :         // stop listening
     712           0 :         OObjectBase::EndListening(sal_False);
     713             : 
     714           0 :         bool bPositionFixed = false;
     715           0 :         Size aUndoSize(0,0);
     716           0 :         bool bUndoMode = false;
     717           0 :         if ( m_xReportComponent.is() )
     718             :         {
     719           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     720           0 :             if (pRptModel->GetUndoEnv().IsUndoMode())
     721             :             {
     722             :                 // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode
     723           0 :                 bUndoMode = true;
     724             :             }
     725           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     726             : 
     727             :             // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point?
     728           0 :             int nNewX = m_xReportComponent->getPositionX() + rSize.A();
     729           0 :             m_xReportComponent->setPositionX(nNewX);
     730           0 :             int nNewY = m_xReportComponent->getPositionY() + rSize.B();
     731           0 :             if (nNewY < 0 && !bUndoMode)
     732             :             {
     733           0 :                 aUndoSize.B() = abs(nNewY);
     734           0 :                 bPositionFixed = true;
     735           0 :                 nNewY = 0;
     736             :             }
     737           0 :             m_xReportComponent->setPositionY(nNewY);
     738             :         }
     739           0 :         if (bPositionFixed)
     740             :         {
     741           0 :             GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize));
     742             :         }
     743             :         // set geometry properties
     744           0 :         SetPropsFromRect(GetLogicRect());
     745             : 
     746             :         // start listening
     747           0 :         OObjectBase::StartListening();
     748             :     }
     749             :     else
     750           0 :         SdrUnoObj::NbcMove( rSize );
     751           0 : }
     752             : 
     753             : 
     754             : 
     755           0 : void OUnoObject::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
     756             : {
     757           0 :     SdrUnoObj::NbcResize( rRef, xFract, yFract );
     758             : 
     759             :     // stop listening
     760           0 :     OObjectBase::EndListening(sal_False);
     761             : 
     762             :     // set geometry properties
     763           0 :     SetPropsFromRect(GetLogicRect());
     764             : 
     765             :     // start listening
     766           0 :     OObjectBase::StartListening();
     767           0 : }
     768             : 
     769           0 : void OUnoObject::NbcSetLogicRect(const Rectangle& rRect)
     770             : {
     771           0 :     SdrUnoObj::NbcSetLogicRect(rRect);
     772             :     // stop listening
     773           0 :     OObjectBase::EndListening(sal_False);
     774             : 
     775             :     // set geometry properties
     776           0 :     SetPropsFromRect(rRect);
     777             : 
     778             :     // start listening
     779           0 :     OObjectBase::StartListening();
     780           0 : }
     781             : 
     782             : 
     783           0 : bool OUnoObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
     784             : {
     785           0 :     bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
     786           0 :     if ( bResult )
     787             :     {
     788           0 :         impl_setReportComponent_nothrow();
     789             :         // set labels
     790           0 :         if ( m_xReportComponent.is() )
     791             :         {
     792             :             try
     793             :             {
     794           0 :                 if ( supportsService( SERVICE_FIXEDTEXT ) )
     795             :                 {
     796           0 :                     m_xReportComponent->setPropertyValue( PROPERTY_LABEL, uno::makeAny(GetDefaultName(this)) );
     797             :                 }
     798             :             }
     799           0 :             catch(const uno::Exception&)
     800             :             {
     801             :                 DBG_UNHANDLED_EXCEPTION();
     802             :             }
     803             : 
     804           0 :             impl_initializeModel_nothrow();
     805             :         }
     806             :         // set geometry properties
     807           0 :         SetPropsFromRect(GetLogicRect());
     808             :     }
     809             : 
     810           0 :     return bResult;
     811             : }
     812             : 
     813           0 : OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj)
     814             : {
     815           0 :     sal_uInt16 nResId = 0;
     816           0 :     OUString aDefaultName = "HERE WE HAVE TO INSERT OUR NAME!";
     817           0 :     if ( _pObj->supportsService( SERVICE_FIXEDTEXT ) )
     818             :     {
     819           0 :         nResId = RID_STR_CLASS_FIXEDTEXT;
     820             :     }
     821           0 :     else if ( _pObj->supportsService( SERVICE_FIXEDLINE ) )
     822             :     {
     823           0 :         nResId = RID_STR_CLASS_FIXEDLINE;
     824             :     }
     825           0 :     else if ( _pObj->supportsService( SERVICE_IMAGECONTROL ) )
     826             :     {
     827           0 :         nResId = RID_STR_CLASS_IMAGECONTROL;
     828             :     }
     829           0 :     else if ( _pObj->supportsService( SERVICE_FORMATTEDFIELD ) )
     830             :     {
     831           0 :         nResId = RID_STR_CLASS_FORMATTEDFIELD;
     832             :     }
     833             : 
     834           0 :     if (nResId)
     835           0 :         aDefaultName = ModuleRes(nResId);
     836             : 
     837           0 :     return aDefaultName;
     838             : }
     839             : 
     840             : 
     841           0 : void OUnoObject::_propertyChange( const  beans::PropertyChangeEvent& evt ) throw( uno::RuntimeException)
     842             : {
     843           0 :     OObjectBase::_propertyChange(evt);
     844           0 :     if (isListening())
     845             :     {
     846           0 :         if ( evt.PropertyName == PROPERTY_CHARCOLOR )
     847             :         {
     848           0 :             Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
     849           0 :             if ( xControlModel.is() )
     850             :             {
     851           0 :                 OObjectBase::EndListening(sal_False);
     852             :                 try
     853             :                 {
     854           0 :                     xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue);
     855             :                 }
     856           0 :                 catch(uno::Exception&)
     857             :                 {
     858             :                 }
     859           0 :                 OObjectBase::StartListening();
     860           0 :             }
     861             :         }
     862           0 :         else if ( evt.PropertyName == PROPERTY_NAME )
     863             :         {
     864           0 :             Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
     865           0 :             if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) )
     866             :             {
     867             :                 // get old name
     868           0 :                 OUString aOldName;
     869           0 :                 evt.OldValue >>= aOldName;
     870             : 
     871             :                 // get new name
     872           0 :                 OUString aNewName;
     873           0 :                 evt.NewValue >>= aNewName;
     874             : 
     875           0 :                 if ( !aNewName.equals(aOldName) )
     876             :                 {
     877             :                     // set old name property
     878           0 :                     OObjectBase::EndListening(sal_False);
     879           0 :                     if ( m_xMediator.is() )
     880           0 :                         m_xMediator.get()->stopListening();
     881             :                     try
     882             :                     {
     883           0 :                         xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue );
     884             :                     }
     885           0 :                     catch(uno::Exception&)
     886             :                     {
     887             :                     }
     888           0 :                     if ( m_xMediator.is() )
     889           0 :                         m_xMediator.get()->startListening();
     890           0 :                     OObjectBase::StartListening();
     891           0 :                 }
     892           0 :             }
     893             :         }
     894             :     }
     895           0 : }
     896             : 
     897           0 : void OUnoObject::CreateMediator(sal_Bool _bReverse)
     898             : {
     899           0 :     if ( !m_xMediator.is() )
     900             :     {
     901           0 :         impl_setReportComponent_nothrow();
     902             : 
     903           0 :         Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
     904           0 :         if ( !m_xMediator.is() && m_xReportComponent.is() && xControlModel.is() )
     905           0 :             m_xMediator = TMediator::createFromQuery(new OPropertyMediator(m_xReportComponent.get(),xControlModel,getPropertyNameMap(GetObjIdentifier()),_bReverse));
     906           0 :         OObjectBase::StartListening();
     907             :     }
     908           0 : }
     909             : 
     910           0 : uno::Reference< beans::XPropertySet> OUnoObject::getAwtComponent()
     911             : {
     912           0 :     return Reference<XPropertySet>(GetUnoControlModel(),uno::UNO_QUERY);
     913             : }
     914             : 
     915             : 
     916           0 : uno::Reference< uno::XInterface > OUnoObject::getUnoShape()
     917             : {
     918           0 :     return OObjectBase::getUnoShapeOf( *this );
     919             : }
     920             : 
     921           0 : void OUnoObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
     922             : {
     923           0 :     SdrUnoObj::impl_setUnoShape( rxUnoShape );
     924           0 :     releaseUnoShape();
     925           0 : }
     926             : 
     927           0 : OUnoObject& OUnoObject::operator=(const OUnoObject& rObj)
     928             : {
     929           0 :     if( this == &rObj )
     930           0 :         return *this;
     931           0 :     SdrUnoObj::operator=(rObj);
     932             : 
     933           0 :     Reference<XPropertySet> xSource(const_cast<OUnoObject&>(rObj).getUnoShape(), uno::UNO_QUERY);
     934           0 :     Reference<XPropertySet> xDest(getUnoShape(), uno::UNO_QUERY);
     935           0 :     if ( xSource.is() && xDest.is() )
     936           0 :         comphelper::copyProperties(xSource.get(), xDest.get());
     937             : 
     938           0 :     return *this;
     939             : }
     940             : 
     941           0 : OUnoObject* OUnoObject::Clone() const
     942             : {
     943           0 :     return CloneHelper< OUnoObject >();
     944             : }
     945             : 
     946             : // OOle2Obj
     947             : 
     948           0 : TYPEINIT1(OOle2Obj, SdrOle2Obj);
     949           0 : OOle2Obj::OOle2Obj(const uno::Reference< report::XReportComponent>& _xComponent,sal_uInt16 _nType)
     950             :           :SdrOle2Obj()
     951             :           ,OObjectBase(_xComponent)
     952             :           ,m_nType(_nType)
     953           0 :           ,m_bOnlyOnce(true)
     954             : {
     955             : 
     956           0 :     impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) );
     957           0 :     m_bIsListening = sal_True;
     958           0 : }
     959             : 
     960           0 : OOle2Obj::OOle2Obj(const OUString& _sComponentName,sal_uInt16 _nType)
     961             :           :SdrOle2Obj()
     962             :           ,OObjectBase(_sComponentName)
     963             :           ,m_nType(_nType)
     964           0 :           ,m_bOnlyOnce(true)
     965             : {
     966           0 :     m_bIsListening = sal_True;
     967           0 : }
     968             : 
     969           0 : OOle2Obj::~OOle2Obj()
     970             : {
     971           0 : }
     972             : 
     973           0 : sal_uInt16 OOle2Obj::GetObjIdentifier() const
     974             : {
     975           0 :     return m_nType;
     976             : }
     977             : 
     978           0 : sal_uInt32 OOle2Obj::GetObjInventor() const
     979             : {
     980           0 :     return ReportInventor;
     981             : }
     982             : 
     983           0 : SdrPage* OOle2Obj::GetImplPage() const
     984             : {
     985           0 :     return GetPage();
     986             : }
     987             : 
     988           0 : void OOle2Obj::SetSnapRectImpl(const Rectangle& _rRect)
     989             : {
     990           0 :     SetSnapRect( _rRect );
     991           0 : }
     992             : 
     993           0 : sal_Int32 OOle2Obj::GetStep() const
     994             : {
     995             :     // get step property
     996           0 :     sal_Int32 nStep = 0;
     997             :     OSL_FAIL("Who called me!");
     998           0 :     return nStep;
     999             : }
    1000             : 
    1001             : 
    1002           0 : void OOle2Obj::NbcMove( const Size& rSize )
    1003             : {
    1004             : 
    1005           0 :     if ( m_bIsListening )
    1006             :     {
    1007             :         // stop listening
    1008           0 :         OObjectBase::EndListening(sal_False);
    1009             : 
    1010           0 :         bool bPositionFixed = false;
    1011           0 :         Size aUndoSize(0,0);
    1012           0 :         bool bUndoMode = false;
    1013           0 :         if ( m_xReportComponent.is() )
    1014             :         {
    1015           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1016           0 :             if (pRptModel->GetUndoEnv().IsUndoMode())
    1017             :             {
    1018             :                 // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode
    1019           0 :                 bUndoMode = true;
    1020             :             }
    1021           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
    1022             : 
    1023             :             // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point?
    1024           0 :             int nNewX = m_xReportComponent->getPositionX() + rSize.A();
    1025             :             // can this hinder us to set components outside the area?
    1026             :             // if (nNewX < 0)
    1027             :             // {
    1028             :             //     nNewX = 0;
    1029             :             // }
    1030           0 :             m_xReportComponent->setPositionX(nNewX);
    1031           0 :             int nNewY = m_xReportComponent->getPositionY() + rSize.B();
    1032           0 :             if (nNewY < 0 && !bUndoMode)
    1033             :             {
    1034           0 :                 aUndoSize.B() = abs(nNewY);
    1035           0 :                 bPositionFixed = true;
    1036           0 :                 nNewY = 0;
    1037             :             }
    1038           0 :             m_xReportComponent->setPositionY(nNewY);
    1039             :         }
    1040           0 :         if (bPositionFixed)
    1041             :         {
    1042           0 :             GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize));
    1043             :         }
    1044             :         // set geometry properties
    1045           0 :         SetPropsFromRect(GetLogicRect());
    1046             : 
    1047             :         // start listening
    1048           0 :         OObjectBase::StartListening();
    1049             :     }
    1050             :     else
    1051           0 :         SdrOle2Obj::NbcMove( rSize );
    1052           0 : }
    1053             : 
    1054             : 
    1055             : 
    1056           0 : void OOle2Obj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
    1057             : {
    1058           0 :     SdrOle2Obj::NbcResize( rRef, xFract, yFract );
    1059             : 
    1060             :     // stop listening
    1061           0 :     OObjectBase::EndListening(sal_False);
    1062             : 
    1063             :     // set geometry properties
    1064           0 :     SetPropsFromRect(GetLogicRect());
    1065             : 
    1066             :     // start listening
    1067           0 :     OObjectBase::StartListening();
    1068           0 : }
    1069             : 
    1070           0 : void OOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
    1071             : {
    1072           0 :     SdrOle2Obj::NbcSetLogicRect(rRect);
    1073             :     // stop listening
    1074           0 :     OObjectBase::EndListening(sal_False);
    1075             : 
    1076             :     // set geometry properties
    1077           0 :     SetPropsFromRect(rRect);
    1078             : 
    1079             :     // start listening
    1080           0 :     OObjectBase::StartListening();
    1081           0 : }
    1082             : 
    1083             : 
    1084           0 : bool OOle2Obj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
    1085             : {
    1086           0 :     bool bResult = SdrOle2Obj::EndCreate(rStat, eCmd);
    1087           0 :     if ( bResult )
    1088             :     {
    1089           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1090           0 :         if ( pRptModel )
    1091             :         {
    1092           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
    1093           0 :             if ( !m_xReportComponent.is() )
    1094           0 :                 m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
    1095             :         }
    1096             :         // set geometry properties
    1097           0 :         SetPropsFromRect(GetLogicRect());
    1098             :     }
    1099             : 
    1100           0 :     return bResult;
    1101             : }
    1102             : 
    1103           0 : uno::Reference< beans::XPropertySet> OOle2Obj::getAwtComponent()
    1104             : {
    1105           0 :     return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY);
    1106             : }
    1107             : 
    1108             : 
    1109           0 : uno::Reference< uno::XInterface > OOle2Obj::getUnoShape()
    1110             : {
    1111           0 :     uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this );
    1112           0 :     if ( !m_xReportComponent.is() )
    1113             :     {
    1114           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1115           0 :         OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
    1116           0 :         m_xReportComponent.set(xShape,uno::UNO_QUERY);
    1117             :     }
    1118           0 :     return xShape;
    1119             : }
    1120             : 
    1121           0 : void OOle2Obj::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
    1122             : {
    1123           0 :     SdrOle2Obj::impl_setUnoShape( rxUnoShape );
    1124           0 :     releaseUnoShape();
    1125           0 :     m_xReportComponent.clear();
    1126           0 : }
    1127             : 
    1128             : 
    1129           0 : uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const uno::Reference < embed::XEmbeddedObject >& _xObj)
    1130             : {
    1131           0 :     uno::Reference< chart2::data::XDatabaseDataProvider > xSource;
    1132           0 :     uno::Reference< embed::XComponentSupplier > xCompSupp(_xObj,uno::UNO_QUERY);
    1133           0 :     if( xCompSupp.is())
    1134             :     {
    1135           0 :         uno::Reference< chart2::XChartDocument> xChartDoc( xCompSupp->getComponent(), uno::UNO_QUERY );
    1136           0 :         if ( xChartDoc.is() )
    1137             :         {
    1138           0 :             xSource.set(xChartDoc->getDataProvider(),uno::UNO_QUERY);
    1139           0 :         }
    1140             :     }
    1141           0 :     return xSource;
    1142             : }
    1143             : 
    1144           0 : OOle2Obj& OOle2Obj::operator=(const OOle2Obj& rObj)
    1145             : {
    1146           0 :     if( this == &rObj )
    1147           0 :         return *this;
    1148           0 :     SdrOle2Obj::operator=(rObj);
    1149             : 
    1150           0 :     OReportModel* pRptModel = static_cast<OReportModel*>(rObj.GetModel());
    1151           0 :     svt::EmbeddedObjectRef::TryRunningState( GetObjRef() );
    1152           0 :     impl_createDataProvider_nothrow(pRptModel->getReportDefinition().get());
    1153             : 
    1154           0 :     uno::Reference< chart2::data::XDatabaseDataProvider > xSource( lcl_getDataProvider(rObj.GetObjRef()) );
    1155           0 :     uno::Reference< chart2::data::XDatabaseDataProvider > xDest( lcl_getDataProvider(GetObjRef()) );
    1156           0 :     if ( xSource.is() && xDest.is() )
    1157           0 :         comphelper::copyProperties(xSource.get(),xDest.get());
    1158             : 
    1159           0 :     initializeChart(pRptModel->getReportDefinition().get());
    1160             : 
    1161           0 :     return *this;
    1162             : }
    1163             : 
    1164             : 
    1165             : // Clone() soll eine komplette Kopie des Objektes erzeugen.
    1166           0 : OOle2Obj* OOle2Obj::Clone() const
    1167             : {
    1168           0 :     return CloneHelper< OOle2Obj >();
    1169             : }
    1170             : 
    1171           0 : void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XModel>& _xModel)
    1172             : {
    1173             :     try
    1174             :     {
    1175           0 :         uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
    1176           0 :         uno::Reference< chart2::data::XDataReceiver > xReceiver;
    1177           0 :         uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
    1178           0 :         if( xCompSupp.is())
    1179           0 :             xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
    1180             :         OSL_ASSERT( xReceiver.is());
    1181           0 :         if( xReceiver.is() )
    1182             :         {
    1183           0 :             uno::Reference< lang::XMultiServiceFactory> xFac(_xModel,uno::UNO_QUERY);
    1184           0 :             uno::Reference< chart2::data::XDatabaseDataProvider > xDataProvider( xFac->createInstance("com.sun.star.chart2.data.DataProvider"),uno::UNO_QUERY);
    1185           0 :             xReceiver->attachDataProvider( xDataProvider.get() );
    1186           0 :         }
    1187             :     }
    1188           0 :     catch(const uno::Exception &)
    1189             :     {
    1190             :     }
    1191           0 : }
    1192             : 
    1193           0 : void OOle2Obj::initializeOle()
    1194             : {
    1195           0 :     if ( m_bOnlyOnce )
    1196             :     {
    1197           0 :         m_bOnlyOnce = false;
    1198           0 :         uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
    1199           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1200           0 :         pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj));
    1201             : 
    1202           0 :         uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
    1203           0 :         if( xCompSupp.is() )
    1204             :         {
    1205           0 :             uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY );
    1206           0 :             if ( xChartProps.is() )
    1207           0 :                 xChartProps->setPropertyValue("NullDate",
    1208           0 :                     uno::makeAny(util::DateTime(0,0,0,0,30,12,1899,false)));
    1209           0 :         }
    1210             :     }
    1211           0 : }
    1212             : 
    1213           0 : void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel)
    1214             : {
    1215           0 :     uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
    1216           0 :     uno::Reference< chart2::data::XDataReceiver > xReceiver;
    1217           0 :     uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
    1218           0 :     if( xCompSupp.is())
    1219           0 :         xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
    1220             :     OSL_ASSERT( xReceiver.is());
    1221           0 :     if( xReceiver.is() )
    1222             :     {
    1223             :         // lock the model to suppress any internal updates
    1224           0 :         uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
    1225           0 :         if( xChartModel.is() )
    1226           0 :             xChartModel->lockControllers();
    1227             : 
    1228           0 :         if ( !lcl_getDataProvider(xObj).is() )
    1229           0 :             impl_createDataProvider_nothrow(_xModel);
    1230             : 
    1231           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1232           0 :         pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj));
    1233             : 
    1234           0 :         ::comphelper::NamedValueCollection aArgs;
    1235           0 :         aArgs.put( "CellRangeRepresentation", uno::makeAny( OUString( "all" ) ) );
    1236           0 :         aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
    1237           0 :         aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
    1238           0 :         aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
    1239           0 :         xReceiver->setArguments( aArgs.getPropertyValues() );
    1240             : 
    1241           0 :         if( xChartModel.is() )
    1242           0 :             xChartModel->unlockControllers();
    1243           0 :     }
    1244           0 : }
    1245             : 
    1246           0 : uno::Reference< style::XStyle> getUsedStyle(const uno::Reference< report::XReportDefinition>& _xReport)
    1247             : {
    1248           0 :     uno::Reference<container::XNameAccess> xStyles = _xReport->getStyleFamilies();
    1249           0 :     uno::Reference<container::XNameAccess> xPageStyles(xStyles->getByName("PageStyles"),uno::UNO_QUERY);
    1250             : 
    1251           0 :     uno::Reference< style::XStyle> xReturn;
    1252           0 :     uno::Sequence< OUString> aSeq = xPageStyles->getElementNames();
    1253           0 :     const OUString* pIter = aSeq.getConstArray();
    1254           0 :     const OUString* pEnd   = pIter + aSeq.getLength();
    1255           0 :     for(;pIter != pEnd && !xReturn.is() ;++pIter)
    1256             :     {
    1257           0 :         uno::Reference< style::XStyle> xStyle(xPageStyles->getByName(*pIter),uno::UNO_QUERY);
    1258           0 :         if ( xStyle->isInUse() )
    1259           0 :             xReturn = xStyle;
    1260           0 :     }
    1261           0 :     return xReturn;
    1262             : }
    1263             : 
    1264             : 
    1265             : } // rptui
    1266             : 
    1267             : 
    1268             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10