LCOV - code coverage report
Current view: top level - reportdesign/source/core/sdr - ReportDrawPage.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 65 1.5 %
Date: 2014-11-03 Functions: 2 5 40.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 "ReportDrawPage.hxx"
      20             : #include "RptObject.hxx"
      21             : #include "RptModel.hxx"
      22             : #include "RptDef.hxx"
      23             : #include "corestrings.hrc"
      24             : #include <comphelper/mimeconfighelper.hxx>
      25             : #include <comphelper/classids.hxx>
      26             : #include <comphelper/embeddedobjectcontainer.hxx>
      27             : #include <comphelper/documentconstants.hxx>
      28             : 
      29             : #include <svx/svdmodel.hxx>
      30             : #include <com/sun/star/report/XFixedLine.hpp>
      31             : #include <com/sun/star/beans/NamedValue.hpp>
      32             : #include <com/sun/star/embed/Aspects.hpp>
      33             : 
      34             : #include <tools/diagnose_ex.h>
      35             : #include <svx/unoshape.hxx>
      36             : 
      37             : namespace reportdesign
      38             : {
      39             :     using namespace ::com::sun::star;
      40             :     using namespace rptui;
      41             : 
      42           0 : OReportDrawPage::OReportDrawPage(SdrPage* _pPage
      43             :                                  ,const uno::Reference< report::XSection >& _xSection)
      44             : : SvxDrawPage(_pPage)
      45           0 : ,m_xSection(_xSection)
      46             : {
      47           0 : }
      48             : 
      49           0 : SdrObject* OReportDrawPage::_CreateSdrObject(const uno::Reference< drawing::XShape > & xDescr)
      50             :     throw (uno::RuntimeException, std::exception)
      51             : {
      52           0 :     uno::Reference< report::XReportComponent> xReportComponent(xDescr,uno::UNO_QUERY);
      53           0 :     if ( xReportComponent.is() )
      54           0 :         return OObjectBase::createObject(xReportComponent);
      55           0 :     return SvxDrawPage::_CreateSdrObject( xDescr );
      56             : }
      57             : 
      58           0 : uno::Reference< drawing::XShape >  OReportDrawPage::_CreateShape( SdrObject *pObj ) const
      59             :     throw (uno::RuntimeException, std::exception)
      60             : {
      61           0 :     OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj);
      62           0 :     if ( !pBaseObj )
      63           0 :         return SvxDrawPage::_CreateShape( pObj );
      64             : 
      65           0 :     uno::Reference< report::XSection> xSection = m_xSection;
      66           0 :     uno::Reference< lang::XMultiServiceFactory> xFactory;
      67           0 :     if ( xSection.is() )
      68           0 :         xFactory.set(xSection->getReportDefinition(),uno::UNO_QUERY);
      69           0 :     uno::Reference< drawing::XShape > xRet;
      70           0 :     uno::Reference< drawing::XShape > xShape;
      71           0 :     if ( xFactory.is() )
      72             :     {
      73           0 :         bool bChangeOrientation = false;
      74           0 :         OUString sServiceName = pBaseObj->getServiceName();
      75             :         OSL_ENSURE(!sServiceName.isEmpty(),"No Service Name given!");
      76             : 
      77           0 :         if ( pObj->ISA(OUnoObject) )
      78             :         {
      79           0 :             OUnoObject& rUnoObj = dynamic_cast<OUnoObject&>(*pObj);
      80           0 :             if (rUnoObj.GetObjIdentifier() == OBJ_DLG_FIXEDTEXT)
      81             :             {
      82           0 :                 uno::Reference<beans::XPropertySet> xControlModel(rUnoObj.GetUnoControlModel(),uno::UNO_QUERY);
      83           0 :                 if ( xControlModel.is() )
      84           0 :                     xControlModel->setPropertyValue( PROPERTY_MULTILINE,uno::makeAny(sal_True));
      85             :             }
      86             :             else
      87           0 :                 bChangeOrientation = rUnoObj.GetObjIdentifier() == OBJ_DLG_HFIXEDLINE;
      88           0 :             SvxShapeControl* pShape = new SvxShapeControl( pObj );
      89           0 :             xShape.set(static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper *>(pShape)),uno::UNO_QUERY);
      90           0 :             pShape->setShapeKind(pObj->GetObjIdentifier());
      91             :         }
      92           0 :         else if ( pObj->ISA(OCustomShape) )
      93             :         {
      94           0 :             SvxCustomShape* pShape = new SvxCustomShape( pObj );
      95           0 :             uno::Reference < drawing::XEnhancedCustomShapeDefaulter > xShape2 = pShape;
      96           0 :             xShape.set(xShape2,uno::UNO_QUERY);
      97           0 :             pShape->setShapeKind(pObj->GetObjIdentifier());
      98             :         }
      99           0 :         else if ( pObj->ISA(SdrOle2Obj) )
     100             :         {
     101           0 :             SdrOle2Obj& rOle2Obj = dynamic_cast<SdrOle2Obj&>(*pObj);
     102           0 :             if (!rOle2Obj.GetObjRef().is())
     103             :             {
     104           0 :                 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
     105           0 :                 uno::Reference < embed::XEmbeddedObject > xObj;
     106           0 :                 OUString sName;
     107           0 :                 xObj = pObj->GetModel()->GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject(
     108             :                     ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(
     109           0 :                     OUString("80243D39-6741-46C5-926E-069164FF87BB")), sName );
     110             :                 OSL_ENSURE(xObj.is(),"Embedded Object could not be created!");
     111             : 
     112             :                 /**************************************************
     113             :                 * Das leere OLE-Objekt bekommt ein neues IPObj
     114             :                 **************************************************/
     115           0 :                 pObj->SetEmptyPresObj(false);
     116           0 :                 rOle2Obj.SetOutlinerParaObject(NULL);
     117           0 :                 rOle2Obj.SetObjRef(xObj);
     118           0 :                 rOle2Obj.SetPersistName(sName);
     119           0 :                 rOle2Obj.SetName(sName);
     120           0 :                 rOle2Obj.SetAspect(nAspect);
     121           0 :                 Rectangle aRect = rOle2Obj.GetLogicRect();
     122             : 
     123           0 :                 Size aTmp = aRect.GetSize();
     124           0 :                 awt::Size aSz( aTmp.Width(), aTmp.Height() );
     125           0 :                 xObj->setVisualAreaSize( nAspect, aSz );
     126             :             }
     127           0 :             SvxOle2Shape* pShape = new SvxOle2Shape( pObj );
     128           0 :             xShape.set(*pShape,uno::UNO_QUERY);
     129           0 :             pShape->setShapeKind(pObj->GetObjIdentifier());
     130             :         }
     131             : 
     132           0 :         if ( !xShape.is() )
     133           0 :             xShape.set( SvxDrawPage::_CreateShape( pObj ) );
     134             : 
     135             :         try
     136             :         {
     137           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel());
     138           0 :             xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW );
     139             :         }
     140           0 :         catch( const uno::Exception& )
     141             :         {
     142             :             DBG_UNHANDLED_EXCEPTION();
     143           0 :         }
     144             :     }
     145             : 
     146           0 :     return xRet;
     147             : }
     148             : 
     149           6 : }
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10