LCOV - code coverage report
Current view: top level - chart2/source/controller/drawinglayer - ViewElementListProvider.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 86 1.2 %
Date: 2015-06-13 12:38:46 Functions: 2 14 14.3 %
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             : 
      20             : #include "ViewElementListProvider.hxx"
      21             : #include "chartview/DrawModelWrapper.hxx"
      22             : #include "chartview/DataPointSymbolSupplier.hxx"
      23             : #include "macros.hxx"
      24             : #include "DrawViewWrapper.hxx"
      25             : 
      26             : #include <svx/xtable.hxx>
      27             : #include <svx/XPropertyTable.hxx>
      28             : #include <svx/unofill.hxx>
      29             : #include <svx/unoapi.hxx>
      30             : #include <svx/xit.hxx>
      31             : #include <svx/xbtmpit.hxx>
      32             : #include <svx/xflftrit.hxx>
      33             : #include <svx/xlndsit.hxx>
      34             : #include <svx/xflhtit.hxx>
      35             : #include <svx/xflgrit.hxx>
      36             : #include <svx/xlnstit.hxx>
      37             : #include <svx/xlnedit.hxx>
      38             : #include <svl/itempool.hxx>
      39             : #include <svtools/ctrltool.hxx>
      40             : #include <vcl/svapp.hxx>
      41             : #include <svx/svdobj.hxx>
      42             : #include <vcl/virdev.hxx>
      43             : #include <svx/svdview.hxx>
      44             : 
      45             : namespace chart
      46             : {
      47             : using namespace ::com::sun::star;
      48             : 
      49           0 : ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper )
      50             :                         : m_pDrawModelWrapper( pDrawModelWrapper )
      51           0 :                         , m_pFontList(NULL)
      52             : {
      53           0 : }
      54             : 
      55           0 : ViewElementListProvider::~ViewElementListProvider()
      56             : {
      57           0 :     if(m_pFontList)
      58           0 :         delete m_pFontList;
      59           0 : }
      60             : 
      61           0 : XColorListRef   ViewElementListProvider::GetColorTable() const
      62             : {
      63           0 :     if(m_pDrawModelWrapper)
      64           0 :         return m_pDrawModelWrapper->GetColorList();
      65           0 :     return XColorListRef();
      66             : }
      67             : 
      68           0 : XDashListRef     ViewElementListProvider::GetDashList() const
      69             : {
      70           0 :     if(m_pDrawModelWrapper)
      71           0 :         return m_pDrawModelWrapper->GetDashList();
      72           0 :     return XDashListRef();
      73             : }
      74             : 
      75           0 : XLineEndListRef  ViewElementListProvider::GetLineEndList() const
      76             : {
      77           0 :     if(m_pDrawModelWrapper)
      78           0 :         return m_pDrawModelWrapper->GetLineEndList();
      79           0 :     return XLineEndListRef();
      80             : }
      81             : 
      82           0 : XGradientListRef ViewElementListProvider::GetGradientList() const
      83             : {
      84           0 :     if(m_pDrawModelWrapper)
      85           0 :         return m_pDrawModelWrapper->GetGradientList();
      86           0 :     return XGradientListRef();
      87             : }
      88           0 : XHatchListRef    ViewElementListProvider::GetHatchList() const
      89             : {
      90           0 :     if(m_pDrawModelWrapper)
      91           0 :         return m_pDrawModelWrapper->GetHatchList();
      92           0 :     return NULL;
      93             : }
      94             : 
      95           0 : XBitmapListRef   ViewElementListProvider::GetBitmapList() const
      96             : {
      97           0 :     if(m_pDrawModelWrapper)
      98           0 :         return m_pDrawModelWrapper->GetBitmapList();
      99           0 :     return XBitmapListRef();
     100             : }
     101             : 
     102             : //create chartspecific symbols for linecharts
     103           0 : SdrObjList* ViewElementListProvider::GetSymbolList() const
     104             : {
     105           0 :     SdrObjList* m_pSymbolList = NULL;
     106           0 :     uno::Reference< drawing::XShapes > m_xSymbols(NULL);//@todo this keeps the first drawinglayer alive ...
     107             :     try
     108             :     {
     109           0 :         if(!m_pSymbolList || !m_pSymbolList->GetObjCount())
     110             :         {
     111             :             //@todo use mutex
     112             : 
     113             :             //get shape factory
     114           0 :             uno::Reference< lang::XMultiServiceFactory > xShapeFactory( m_pDrawModelWrapper->getShapeFactory() );
     115             : 
     116             :             //get hidden draw page (target):
     117           0 :             uno::Reference<drawing::XShapes> xTarget( m_pDrawModelWrapper->getHiddenDrawPage(), uno::UNO_QUERY );
     118             : 
     119             :             //create symbols via uno and convert to native sdr objects
     120           0 :             drawing::Direction3D aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ??
     121           0 :             m_xSymbols =  DataPointSymbolSupplier::create2DSymbolList( xShapeFactory, xTarget, aSymbolSize );
     122             : 
     123           0 :             SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( uno::Reference< drawing::XShape >( m_xSymbols, uno::UNO_QUERY ) );
     124           0 :             if(pSdrObject)
     125           0 :                 m_pSymbolList = pSdrObject->GetSubList();
     126             :         }
     127             :     }
     128           0 :     catch( const uno::Exception& e )
     129             :     {
     130             :         ASSERT_EXCEPTION( e );
     131             :     }
     132           0 :     return m_pSymbolList;
     133             : }
     134             : 
     135           0 : Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const
     136             : {
     137           0 :     SdrObjList* pSymbolList = this->GetSymbolList();
     138           0 :     if( !pSymbolList->GetObjCount() )
     139           0 :         return Graphic();
     140           0 :     if(nStandardSymbol<0)
     141           0 :         nStandardSymbol*=-1;
     142           0 :     if( static_cast<size_t>(nStandardSymbol) >= pSymbolList->GetObjCount() )
     143           0 :         nStandardSymbol %= pSymbolList->GetObjCount();
     144           0 :     SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol);
     145             : 
     146           0 :     ScopedVclPtrInstance< VirtualDevice > pVDev;
     147           0 :     pVDev->SetMapMode(MapMode(MAP_100TH_MM));
     148           0 :     SdrModel* pModel = new SdrModel();
     149           0 :     pModel->GetItemPool().FreezeIdRanges();
     150           0 :     SdrPage* pPage = new SdrPage( *pModel, false );
     151           0 :     pPage->SetSize(Size(1000,1000));
     152           0 :     pModel->InsertPage( pPage, 0 );
     153           0 :     SdrView* pView = new SdrView( pModel, pVDev );
     154           0 :     pView->hideMarkHandles();
     155           0 :     SdrPageView* pPageView = pView->ShowSdrPage(pPage);
     156             : 
     157           0 :     pObj=pObj->Clone();
     158           0 :     pPage->NbcInsertObject(pObj);
     159           0 :     pView->MarkObj(pObj,pPageView);
     160           0 :     if( pSymbolShapeProperties )
     161           0 :         pObj->SetMergedItemSet(*pSymbolShapeProperties);
     162             : 
     163           0 :     GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
     164             : 
     165           0 :     Graphic aGraph(aMeta);
     166           0 :     Size aSize = pObj->GetSnapRect().GetSize();
     167           0 :     aGraph.SetPrefSize(aSize);
     168           0 :     aGraph.SetPrefMapMode(MAP_100TH_MM);
     169             : 
     170           0 :     pView->UnmarkAll();
     171           0 :     pObj=pPage->RemoveObject(0);
     172           0 :     SdrObject::Free( pObj );
     173           0 :     delete pView;
     174           0 :     delete pModel;
     175             : 
     176           0 :     return aGraph;
     177             : }
     178             : 
     179           0 : FontList* ViewElementListProvider::getFontList() const
     180             : {
     181             :     //was old chart:
     182             :     //SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST)
     183             : 
     184           0 :     if(!m_pFontList)
     185             :     {
     186           0 :         OutputDevice* pRefDev    = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : NULL;
     187           0 :         OutputDevice* pDefaultOut = Application::GetDefaultDevice();
     188             :         m_pFontList = new FontList( pRefDev ? pRefDev    : pDefaultOut
     189             :                                 , pRefDev ? pDefaultOut : NULL
     190           0 :                                 , false );
     191             :     }
     192           0 :     return m_pFontList;
     193             : }
     194          57 : } //namespace chart
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11