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

Generated by: LCOV version 1.10