LCOV - code coverage report
Current view: top level - reportdesign/source/core/sdr - RptObject.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 594 0.2 %
Date: 2015-06-13 12:38:46 Functions: 2 98 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(InvalidateFlags::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 : void OCustomShape::NbcMove( const Size& rSize )
     511             : {
     512           0 :     if ( m_bIsListening )
     513             :     {
     514           0 :         m_bIsListening = false;
     515             : 
     516           0 :         if ( m_xReportComponent.is() )
     517             :         {
     518           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     519           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     520           0 :             m_xReportComponent->setPositionX(m_xReportComponent->getPositionX() + rSize.A());
     521           0 :             m_xReportComponent->setPositionY(m_xReportComponent->getPositionY() + rSize.B());
     522             :         }
     523             : 
     524             :         // set geometry properties
     525           0 :         SetPropsFromRect(GetSnapRect());
     526             : 
     527           0 :         m_bIsListening = true;
     528             :     }
     529             :     else
     530           0 :         SdrObjCustomShape::NbcMove( rSize );
     531           0 : }
     532             : 
     533           0 : void OCustomShape::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
     534             : {
     535           0 :     SdrObjCustomShape::NbcResize( rRef, xFract, yFract );
     536             : 
     537           0 :     SetPropsFromRect(GetSnapRect());
     538           0 : }
     539             : 
     540           0 : void OCustomShape::NbcSetLogicRect(const Rectangle& rRect)
     541             : {
     542           0 :     SdrObjCustomShape::NbcSetLogicRect(rRect);
     543           0 :     SetPropsFromRect(rRect);
     544           0 : }
     545             : 
     546           0 : bool OCustomShape::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
     547             : {
     548           0 :     bool bResult = SdrObjCustomShape::EndCreate(rStat, eCmd);
     549           0 :     if ( bResult )
     550             :     {
     551           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     552           0 :         if ( pRptModel )
     553             :         {
     554           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     555           0 :             if ( !m_xReportComponent.is() )
     556           0 :                 m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
     557             :         }
     558           0 :         SetPropsFromRect(GetSnapRect());
     559             :     }
     560             : 
     561           0 :     return bResult;
     562             : }
     563             : 
     564             : 
     565           0 : void OCustomShape::SetObjectItemHelper(const SfxPoolItem& rItem)
     566             : {
     567           0 :     SetObjectItem(rItem);
     568             :     // TODO
     569             :     //getSectionWindow()->getView()->AdjustMarkHdl();
     570           0 : }
     571             : 
     572             : 
     573           0 : uno::Reference< beans::XPropertySet> OCustomShape::getAwtComponent()
     574             : {
     575           0 :     return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY);
     576             : }
     577             : 
     578             : 
     579           0 : uno::Reference< uno::XInterface > OCustomShape::getUnoShape()
     580             : {
     581           0 :     uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this );
     582           0 :     if ( !m_xReportComponent.is() )
     583             :     {
     584           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     585           0 :         OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     586           0 :         m_xReportComponent.set(xShape,uno::UNO_QUERY);
     587             :     }
     588           0 :     return xShape;
     589             : }
     590             : 
     591           0 : void OCustomShape::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
     592             : {
     593           0 :     SdrObjCustomShape::impl_setUnoShape( rxUnoShape );
     594           0 :     releaseUnoShape();
     595           0 :     m_xReportComponent.clear();
     596           0 : }
     597             : 
     598             : 
     599             : 
     600           0 : TYPEINIT1(OUnoObject, SdrUnoObj);
     601             : 
     602           0 : OUnoObject::OUnoObject(const OUString& _sComponentName
     603             :                        ,const OUString& rModelName
     604             :                        ,sal_uInt16   _nObjectType)
     605             :           :SdrUnoObj(rModelName, true)
     606             :           ,OObjectBase(_sComponentName)
     607           0 :           ,m_nObjectType(_nObjectType)
     608             : {
     609           0 :     if ( !rModelName.isEmpty() )
     610           0 :         impl_initializeModel_nothrow();
     611           0 : }
     612             : 
     613           0 : OUnoObject::OUnoObject(const uno::Reference< report::XReportComponent>& _xComponent
     614             :                        ,const OUString& rModelName
     615             :                        ,sal_uInt16   _nObjectType)
     616             :           :SdrUnoObj(rModelName, true)
     617             :           ,OObjectBase(_xComponent)
     618           0 :           ,m_nObjectType(_nObjectType)
     619             : {
     620           0 :     impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) );
     621             : 
     622           0 :     if ( !rModelName.isEmpty() )
     623           0 :         impl_initializeModel_nothrow();
     624             : 
     625           0 : }
     626             : 
     627           0 : OUnoObject::~OUnoObject()
     628             : {
     629           0 : }
     630             : 
     631           0 : void OUnoObject::impl_initializeModel_nothrow()
     632             : {
     633             :     try
     634             :     {
     635           0 :         Reference< XFormattedField > xFormatted( m_xReportComponent, UNO_QUERY );
     636           0 :         if ( xFormatted.is() )
     637             :         {
     638           0 :             const Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW );
     639           0 :             const OUString sTreatAsNumberProperty = "TreatAsNumber";
     640           0 :             xModelProps->setPropertyValue( sTreatAsNumberProperty, makeAny( sal_False ) );
     641           0 :             xModelProps->setPropertyValue( PROPERTY_VERTICALALIGN,m_xReportComponent->getPropertyValue(PROPERTY_VERTICALALIGN));
     642           0 :         }
     643             :     }
     644           0 :     catch( const Exception& )
     645             :     {
     646             :         DBG_UNHANDLED_EXCEPTION();
     647             :     }
     648           0 : }
     649             : 
     650           0 : void OUnoObject::impl_setReportComponent_nothrow()
     651             : {
     652           0 :     if ( m_xReportComponent.is() )
     653           0 :         return;
     654             : 
     655           0 :     OReportModel* pReportModel = static_cast<OReportModel*>(GetModel());
     656             :     OSL_ENSURE( pReportModel, "OUnoObject::impl_setReportComponent_nothrow: no report model!" );
     657           0 :     if ( !pReportModel )
     658           0 :         return;
     659             : 
     660           0 :     OXUndoEnvironment::OUndoEnvLock aLock( pReportModel->GetUndoEnv() );
     661           0 :     m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
     662             : 
     663           0 :     impl_initializeModel_nothrow();
     664             : }
     665             : 
     666           0 : sal_uInt16 OUnoObject::GetObjIdentifier() const
     667             : {
     668           0 :     return sal_uInt16(m_nObjectType);
     669             : }
     670             : 
     671           0 : sal_uInt32 OUnoObject::GetObjInventor() const
     672             : {
     673           0 :     return ReportInventor;
     674             : }
     675             : 
     676           0 : SdrPage* OUnoObject::GetImplPage() const
     677             : {
     678           0 :     return GetPage();
     679             : }
     680             : 
     681           0 : void OUnoObject::SetSnapRectImpl(const Rectangle& _rRect)
     682             : {
     683           0 :     SetSnapRect( _rRect );
     684           0 : }
     685             : 
     686           0 : void OUnoObject::NbcMove( const Size& rSize )
     687             : {
     688             : 
     689           0 :     if ( m_bIsListening )
     690             :     {
     691             :         // stop listening
     692           0 :         OObjectBase::EndListening(false);
     693             : 
     694           0 :         bool bPositionFixed = false;
     695           0 :         Size aUndoSize(0,0);
     696           0 :         if ( m_xReportComponent.is() )
     697             :         {
     698           0 :             bool bUndoMode = false;
     699           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     700           0 :             if (pRptModel->GetUndoEnv().IsUndoMode())
     701             :             {
     702             :                 // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode
     703           0 :                 bUndoMode = true;
     704             :             }
     705           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     706             : 
     707             :             // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point?
     708           0 :             int nNewX = m_xReportComponent->getPositionX() + rSize.A();
     709           0 :             m_xReportComponent->setPositionX(nNewX);
     710           0 :             int nNewY = m_xReportComponent->getPositionY() + rSize.B();
     711           0 :             if (nNewY < 0 && !bUndoMode)
     712             :             {
     713           0 :                 aUndoSize.B() = abs(nNewY);
     714           0 :                 bPositionFixed = true;
     715           0 :                 nNewY = 0;
     716             :             }
     717           0 :             m_xReportComponent->setPositionY(nNewY);
     718             :         }
     719           0 :         if (bPositionFixed)
     720             :         {
     721           0 :             GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize));
     722             :         }
     723             :         // set geometry properties
     724           0 :         SetPropsFromRect(GetLogicRect());
     725             : 
     726             :         // start listening
     727           0 :         OObjectBase::StartListening();
     728             :     }
     729             :     else
     730           0 :         SdrUnoObj::NbcMove( rSize );
     731           0 : }
     732             : 
     733             : 
     734             : 
     735           0 : void OUnoObject::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
     736             : {
     737           0 :     SdrUnoObj::NbcResize( rRef, xFract, yFract );
     738             : 
     739             :     // stop listening
     740           0 :     OObjectBase::EndListening(false);
     741             : 
     742             :     // set geometry properties
     743           0 :     SetPropsFromRect(GetLogicRect());
     744             : 
     745             :     // start listening
     746           0 :     OObjectBase::StartListening();
     747           0 : }
     748             : 
     749           0 : void OUnoObject::NbcSetLogicRect(const Rectangle& rRect)
     750             : {
     751           0 :     SdrUnoObj::NbcSetLogicRect(rRect);
     752             :     // stop listening
     753           0 :     OObjectBase::EndListening(false);
     754             : 
     755             :     // set geometry properties
     756           0 :     SetPropsFromRect(rRect);
     757             : 
     758             :     // start listening
     759           0 :     OObjectBase::StartListening();
     760           0 : }
     761             : 
     762             : 
     763           0 : bool OUnoObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
     764             : {
     765           0 :     bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
     766           0 :     if ( bResult )
     767             :     {
     768           0 :         impl_setReportComponent_nothrow();
     769             :         // set labels
     770           0 :         if ( m_xReportComponent.is() )
     771             :         {
     772             :             try
     773             :             {
     774           0 :                 if ( supportsService( SERVICE_FIXEDTEXT ) )
     775             :                 {
     776           0 :                     m_xReportComponent->setPropertyValue( PROPERTY_LABEL, uno::makeAny(GetDefaultName(this)) );
     777             :                 }
     778             :             }
     779           0 :             catch(const uno::Exception&)
     780             :             {
     781             :                 DBG_UNHANDLED_EXCEPTION();
     782             :             }
     783             : 
     784           0 :             impl_initializeModel_nothrow();
     785             :         }
     786             :         // set geometry properties
     787           0 :         SetPropsFromRect(GetLogicRect());
     788             :     }
     789             : 
     790           0 :     return bResult;
     791             : }
     792             : 
     793           0 : OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj)
     794             : {
     795           0 :     sal_uInt16 nResId = 0;
     796           0 :     OUString aDefaultName = "HERE WE HAVE TO INSERT OUR NAME!";
     797           0 :     if ( _pObj->supportsService( SERVICE_FIXEDTEXT ) )
     798             :     {
     799           0 :         nResId = RID_STR_CLASS_FIXEDTEXT;
     800             :     }
     801           0 :     else if ( _pObj->supportsService( SERVICE_FIXEDLINE ) )
     802             :     {
     803           0 :         nResId = RID_STR_CLASS_FIXEDLINE;
     804             :     }
     805           0 :     else if ( _pObj->supportsService( SERVICE_IMAGECONTROL ) )
     806             :     {
     807           0 :         nResId = RID_STR_CLASS_IMAGECONTROL;
     808             :     }
     809           0 :     else if ( _pObj->supportsService( SERVICE_FORMATTEDFIELD ) )
     810             :     {
     811           0 :         nResId = RID_STR_CLASS_FORMATTEDFIELD;
     812             :     }
     813             : 
     814           0 :     if (nResId)
     815           0 :         aDefaultName = ModuleRes(nResId);
     816             : 
     817           0 :     return aDefaultName;
     818             : }
     819             : 
     820             : 
     821           0 : void OUnoObject::_propertyChange( const  beans::PropertyChangeEvent& evt ) throw( uno::RuntimeException)
     822             : {
     823           0 :     OObjectBase::_propertyChange(evt);
     824           0 :     if (isListening())
     825             :     {
     826           0 :         if ( evt.PropertyName == PROPERTY_CHARCOLOR )
     827             :         {
     828           0 :             Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
     829           0 :             if ( xControlModel.is() )
     830             :             {
     831           0 :                 OObjectBase::EndListening(false);
     832             :                 try
     833             :                 {
     834           0 :                     xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue);
     835             :                 }
     836           0 :                 catch(uno::Exception&)
     837             :                 {
     838             :                 }
     839           0 :                 OObjectBase::StartListening();
     840           0 :             }
     841             :         }
     842           0 :         else if ( evt.PropertyName == PROPERTY_NAME )
     843             :         {
     844           0 :             Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
     845           0 :             if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) )
     846             :             {
     847             :                 // get old name
     848           0 :                 OUString aOldName;
     849           0 :                 evt.OldValue >>= aOldName;
     850             : 
     851             :                 // get new name
     852           0 :                 OUString aNewName;
     853           0 :                 evt.NewValue >>= aNewName;
     854             : 
     855           0 :                 if ( !aNewName.equals(aOldName) )
     856             :                 {
     857             :                     // set old name property
     858           0 :                     OObjectBase::EndListening(false);
     859           0 :                     if ( m_xMediator.is() )
     860           0 :                         m_xMediator.get()->stopListening();
     861             :                     try
     862             :                     {
     863           0 :                         xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue );
     864             :                     }
     865           0 :                     catch(uno::Exception&)
     866             :                     {
     867             :                     }
     868           0 :                     if ( m_xMediator.is() )
     869           0 :                         m_xMediator.get()->startListening();
     870           0 :                     OObjectBase::StartListening();
     871           0 :                 }
     872           0 :             }
     873             :         }
     874             :     }
     875           0 : }
     876             : 
     877           0 : void OUnoObject::CreateMediator(bool _bReverse)
     878             : {
     879           0 :     if ( !m_xMediator.is() )
     880             :     {
     881           0 :         impl_setReportComponent_nothrow();
     882             : 
     883           0 :         Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);
     884           0 :         if ( !m_xMediator.is() && m_xReportComponent.is() && xControlModel.is() )
     885           0 :             m_xMediator = new OPropertyMediator(m_xReportComponent.get(),xControlModel,getPropertyNameMap(GetObjIdentifier()),_bReverse);
     886           0 :         OObjectBase::StartListening();
     887             :     }
     888           0 : }
     889             : 
     890           0 : uno::Reference< beans::XPropertySet> OUnoObject::getAwtComponent()
     891             : {
     892           0 :     return Reference<XPropertySet>(GetUnoControlModel(),uno::UNO_QUERY);
     893             : }
     894             : 
     895             : 
     896           0 : uno::Reference< uno::XInterface > OUnoObject::getUnoShape()
     897             : {
     898           0 :     return OObjectBase::getUnoShapeOf( *this );
     899             : }
     900             : 
     901           0 : void OUnoObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
     902             : {
     903           0 :     SdrUnoObj::impl_setUnoShape( rxUnoShape );
     904           0 :     releaseUnoShape();
     905           0 : }
     906             : 
     907           0 : OUnoObject& OUnoObject::operator=(const OUnoObject& rObj)
     908             : {
     909           0 :     if( this == &rObj )
     910           0 :         return *this;
     911           0 :     SdrUnoObj::operator=(rObj);
     912             : 
     913           0 :     Reference<XPropertySet> xSource(const_cast<OUnoObject&>(rObj).getUnoShape(), uno::UNO_QUERY);
     914           0 :     Reference<XPropertySet> xDest(getUnoShape(), uno::UNO_QUERY);
     915           0 :     if ( xSource.is() && xDest.is() )
     916           0 :         comphelper::copyProperties(xSource.get(), xDest.get());
     917             : 
     918           0 :     return *this;
     919             : }
     920             : 
     921           0 : OUnoObject* OUnoObject::Clone() const
     922             : {
     923           0 :     return CloneHelper< OUnoObject >();
     924             : }
     925             : 
     926             : // OOle2Obj
     927             : 
     928           0 : TYPEINIT1(OOle2Obj, SdrOle2Obj);
     929           0 : OOle2Obj::OOle2Obj(const uno::Reference< report::XReportComponent>& _xComponent,sal_uInt16 _nType)
     930             :           :SdrOle2Obj()
     931             :           ,OObjectBase(_xComponent)
     932             :           ,m_nType(_nType)
     933           0 :           ,m_bOnlyOnce(true)
     934             : {
     935             : 
     936           0 :     impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) );
     937           0 :     m_bIsListening = true;
     938           0 : }
     939             : 
     940           0 : OOle2Obj::OOle2Obj(const OUString& _sComponentName,sal_uInt16 _nType)
     941             :           :SdrOle2Obj()
     942             :           ,OObjectBase(_sComponentName)
     943             :           ,m_nType(_nType)
     944           0 :           ,m_bOnlyOnce(true)
     945             : {
     946           0 :     m_bIsListening = true;
     947           0 : }
     948             : 
     949           0 : OOle2Obj::~OOle2Obj()
     950             : {
     951           0 : }
     952             : 
     953           0 : sal_uInt16 OOle2Obj::GetObjIdentifier() const
     954             : {
     955           0 :     return m_nType;
     956             : }
     957             : 
     958           0 : sal_uInt32 OOle2Obj::GetObjInventor() const
     959             : {
     960           0 :     return ReportInventor;
     961             : }
     962             : 
     963           0 : SdrPage* OOle2Obj::GetImplPage() const
     964             : {
     965           0 :     return GetPage();
     966             : }
     967             : 
     968           0 : void OOle2Obj::SetSnapRectImpl(const Rectangle& _rRect)
     969             : {
     970           0 :     SetSnapRect( _rRect );
     971           0 : }
     972             : 
     973           0 : void OOle2Obj::NbcMove( const Size& rSize )
     974             : {
     975             : 
     976           0 :     if ( m_bIsListening )
     977             :     {
     978             :         // stop listening
     979           0 :         OObjectBase::EndListening(false);
     980             : 
     981           0 :         bool bPositionFixed = false;
     982           0 :         Size aUndoSize(0,0);
     983           0 :         if ( m_xReportComponent.is() )
     984             :         {
     985           0 :             bool bUndoMode = false;
     986           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
     987           0 :             if (pRptModel->GetUndoEnv().IsUndoMode())
     988             :             {
     989             :                 // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode
     990           0 :                 bUndoMode = true;
     991             :             }
     992           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     993             : 
     994             :             // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point?
     995           0 :             int nNewX = m_xReportComponent->getPositionX() + rSize.A();
     996             :             // can this hinder us to set components outside the area?
     997             :             // if (nNewX < 0)
     998             :             // {
     999             :             //     nNewX = 0;
    1000             :             // }
    1001           0 :             m_xReportComponent->setPositionX(nNewX);
    1002           0 :             int nNewY = m_xReportComponent->getPositionY() + rSize.B();
    1003           0 :             if (nNewY < 0 && !bUndoMode)
    1004             :             {
    1005           0 :                 aUndoSize.B() = abs(nNewY);
    1006           0 :                 bPositionFixed = true;
    1007           0 :                 nNewY = 0;
    1008             :             }
    1009           0 :             m_xReportComponent->setPositionY(nNewY);
    1010             :         }
    1011           0 :         if (bPositionFixed)
    1012             :         {
    1013           0 :             GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize));
    1014             :         }
    1015             :         // set geometry properties
    1016           0 :         SetPropsFromRect(GetLogicRect());
    1017             : 
    1018             :         // start listening
    1019           0 :         OObjectBase::StartListening();
    1020             :     }
    1021             :     else
    1022           0 :         SdrOle2Obj::NbcMove( rSize );
    1023           0 : }
    1024             : 
    1025             : 
    1026             : 
    1027           0 : void OOle2Obj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
    1028             : {
    1029           0 :     SdrOle2Obj::NbcResize( rRef, xFract, yFract );
    1030             : 
    1031             :     // stop listening
    1032           0 :     OObjectBase::EndListening(false);
    1033             : 
    1034             :     // set geometry properties
    1035           0 :     SetPropsFromRect(GetLogicRect());
    1036             : 
    1037             :     // start listening
    1038           0 :     OObjectBase::StartListening();
    1039           0 : }
    1040             : 
    1041           0 : void OOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
    1042             : {
    1043           0 :     SdrOle2Obj::NbcSetLogicRect(rRect);
    1044             :     // stop listening
    1045           0 :     OObjectBase::EndListening(false);
    1046             : 
    1047             :     // set geometry properties
    1048           0 :     SetPropsFromRect(rRect);
    1049             : 
    1050             :     // start listening
    1051           0 :     OObjectBase::StartListening();
    1052           0 : }
    1053             : 
    1054             : 
    1055           0 : bool OOle2Obj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
    1056             : {
    1057           0 :     bool bResult = SdrOle2Obj::EndCreate(rStat, eCmd);
    1058           0 :     if ( bResult )
    1059             :     {
    1060           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1061           0 :         if ( pRptModel )
    1062             :         {
    1063           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
    1064           0 :             if ( !m_xReportComponent.is() )
    1065           0 :                 m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY);
    1066             :         }
    1067             :         // set geometry properties
    1068           0 :         SetPropsFromRect(GetLogicRect());
    1069             :     }
    1070             : 
    1071           0 :     return bResult;
    1072             : }
    1073             : 
    1074           0 : uno::Reference< beans::XPropertySet> OOle2Obj::getAwtComponent()
    1075             : {
    1076           0 :     return uno::Reference< beans::XPropertySet>(m_xReportComponent,uno::UNO_QUERY);
    1077             : }
    1078             : 
    1079             : 
    1080           0 : uno::Reference< uno::XInterface > OOle2Obj::getUnoShape()
    1081             : {
    1082           0 :     uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this );
    1083           0 :     if ( !m_xReportComponent.is() )
    1084             :     {
    1085           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1086           0 :         OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
    1087           0 :         m_xReportComponent.set(xShape,uno::UNO_QUERY);
    1088             :     }
    1089           0 :     return xShape;
    1090             : }
    1091             : 
    1092           0 : void OOle2Obj::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
    1093             : {
    1094           0 :     SdrOle2Obj::impl_setUnoShape( rxUnoShape );
    1095           0 :     releaseUnoShape();
    1096           0 :     m_xReportComponent.clear();
    1097           0 : }
    1098             : 
    1099             : 
    1100           0 : uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const uno::Reference < embed::XEmbeddedObject >& _xObj)
    1101             : {
    1102           0 :     uno::Reference< chart2::data::XDatabaseDataProvider > xSource;
    1103           0 :     uno::Reference< embed::XComponentSupplier > xCompSupp(_xObj,uno::UNO_QUERY);
    1104           0 :     if( xCompSupp.is())
    1105             :     {
    1106           0 :         uno::Reference< chart2::XChartDocument> xChartDoc( xCompSupp->getComponent(), uno::UNO_QUERY );
    1107           0 :         if ( xChartDoc.is() )
    1108             :         {
    1109           0 :             xSource.set(xChartDoc->getDataProvider(),uno::UNO_QUERY);
    1110           0 :         }
    1111             :     }
    1112           0 :     return xSource;
    1113             : }
    1114             : 
    1115           0 : OOle2Obj& OOle2Obj::operator=(const OOle2Obj& rObj)
    1116             : {
    1117           0 :     if( this == &rObj )
    1118           0 :         return *this;
    1119           0 :     SdrOle2Obj::operator=(rObj);
    1120             : 
    1121           0 :     OReportModel* pRptModel = static_cast<OReportModel*>(rObj.GetModel());
    1122           0 :     svt::EmbeddedObjectRef::TryRunningState( GetObjRef() );
    1123           0 :     impl_createDataProvider_nothrow(pRptModel->getReportDefinition().get());
    1124             : 
    1125           0 :     uno::Reference< chart2::data::XDatabaseDataProvider > xSource( lcl_getDataProvider(rObj.GetObjRef()) );
    1126           0 :     uno::Reference< chart2::data::XDatabaseDataProvider > xDest( lcl_getDataProvider(GetObjRef()) );
    1127           0 :     if ( xSource.is() && xDest.is() )
    1128           0 :         comphelper::copyProperties(xSource.get(),xDest.get());
    1129             : 
    1130           0 :     initializeChart(pRptModel->getReportDefinition().get());
    1131             : 
    1132           0 :     return *this;
    1133             : }
    1134             : 
    1135             : 
    1136             : // Clone() soll eine komplette Kopie des Objektes erzeugen.
    1137           0 : OOle2Obj* OOle2Obj::Clone() const
    1138             : {
    1139           0 :     return CloneHelper< OOle2Obj >();
    1140             : }
    1141             : 
    1142           0 : void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XModel>& _xModel)
    1143             : {
    1144             :     try
    1145             :     {
    1146           0 :         uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
    1147           0 :         uno::Reference< chart2::data::XDataReceiver > xReceiver;
    1148           0 :         uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
    1149           0 :         if( xCompSupp.is())
    1150           0 :             xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
    1151             :         OSL_ASSERT( xReceiver.is());
    1152           0 :         if( xReceiver.is() )
    1153             :         {
    1154           0 :             uno::Reference< lang::XMultiServiceFactory> xFac(_xModel,uno::UNO_QUERY);
    1155           0 :             uno::Reference< chart2::data::XDatabaseDataProvider > xDataProvider( xFac->createInstance("com.sun.star.chart2.data.DataProvider"),uno::UNO_QUERY);
    1156           0 :             xReceiver->attachDataProvider( xDataProvider.get() );
    1157           0 :         }
    1158             :     }
    1159           0 :     catch(const uno::Exception &)
    1160             :     {
    1161             :     }
    1162           0 : }
    1163             : 
    1164           0 : void OOle2Obj::initializeOle()
    1165             : {
    1166           0 :     if ( m_bOnlyOnce )
    1167             :     {
    1168           0 :         m_bOnlyOnce = false;
    1169           0 :         uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
    1170           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1171           0 :         pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj));
    1172             : 
    1173           0 :         uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
    1174           0 :         if( xCompSupp.is() )
    1175             :         {
    1176           0 :             uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY );
    1177           0 :             if ( xChartProps.is() )
    1178           0 :                 xChartProps->setPropertyValue("NullDate",
    1179           0 :                     uno::makeAny(util::DateTime(0,0,0,0,30,12,1899,false)));
    1180           0 :         }
    1181             :     }
    1182           0 : }
    1183             : 
    1184           0 : void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel)
    1185             : {
    1186           0 :     uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef();
    1187           0 :     uno::Reference< chart2::data::XDataReceiver > xReceiver;
    1188           0 :     uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
    1189           0 :     if( xCompSupp.is())
    1190           0 :         xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
    1191             :     OSL_ASSERT( xReceiver.is());
    1192           0 :     if( xReceiver.is() )
    1193             :     {
    1194             :         // lock the model to suppress any internal updates
    1195           0 :         uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
    1196           0 :         if( xChartModel.is() )
    1197           0 :             xChartModel->lockControllers();
    1198             : 
    1199           0 :         if ( !lcl_getDataProvider(xObj).is() )
    1200           0 :             impl_createDataProvider_nothrow(_xModel);
    1201             : 
    1202           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
    1203           0 :         pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj));
    1204             : 
    1205           0 :         ::comphelper::NamedValueCollection aArgs;
    1206           0 :         aArgs.put( "CellRangeRepresentation", uno::makeAny( OUString( "all" ) ) );
    1207           0 :         aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
    1208           0 :         aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
    1209           0 :         aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
    1210           0 :         xReceiver->setArguments( aArgs.getPropertyValues() );
    1211             : 
    1212           0 :         if( xChartModel.is() )
    1213           0 :             xChartModel->unlockControllers();
    1214           0 :     }
    1215           0 : }
    1216             : 
    1217           0 : uno::Reference< style::XStyle> getUsedStyle(const uno::Reference< report::XReportDefinition>& _xReport)
    1218             : {
    1219           0 :     uno::Reference<container::XNameAccess> xStyles = _xReport->getStyleFamilies();
    1220           0 :     uno::Reference<container::XNameAccess> xPageStyles(xStyles->getByName("PageStyles"),uno::UNO_QUERY);
    1221             : 
    1222           0 :     uno::Reference< style::XStyle> xReturn;
    1223           0 :     uno::Sequence< OUString> aSeq = xPageStyles->getElementNames();
    1224           0 :     const OUString* pIter = aSeq.getConstArray();
    1225           0 :     const OUString* pEnd   = pIter + aSeq.getLength();
    1226           0 :     for(;pIter != pEnd && !xReturn.is() ;++pIter)
    1227             :     {
    1228           0 :         uno::Reference< style::XStyle> xStyle(xPageStyles->getByName(*pIter),uno::UNO_QUERY);
    1229           0 :         if ( xStyle->isInUse() )
    1230           0 :             xReturn = xStyle;
    1231           0 :     }
    1232           0 :     return xReturn;
    1233             : }
    1234             : 
    1235             : 
    1236           3 : } // rptui
    1237             : 
    1238             : 
    1239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11