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

Generated by: LCOV version 1.10