LCOV - code coverage report
Current view: top level - chart2/source/controller/drawinglayer - ViewElementListProvider.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 85 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "ViewElementListProvider.hxx"
      21             : #include "chartview/DrawModelWrapper.hxx"
      22             : #include "chartview/DataPointSymbolSupplier.hxx"
      23             : #include "macros.hxx"
      24             : #include "DrawViewWrapper.hxx"
      25             : #include <svx/xtable.hxx>
      26             : #include <svx/XPropertyTable.hxx>
      27             : #include <svx/unofill.hxx>
      28             : #include <svx/unoapi.hxx>
      29             : 
      30             : // header for class NameOrIndex
      31             : #include <svx/xit.hxx>
      32             : // header for class XFillBitmapItem
      33             : #include <svx/xbtmpit.hxx>
      34             : #include <svx/xflftrit.hxx>
      35             : #include <svx/xlndsit.hxx>
      36             : #include <svx/xflhtit.hxx>
      37             : #include <svx/xflgrit.hxx>
      38             : // header for class XLineStartItem
      39             : #include <svx/xlnstit.hxx>
      40             : // header for class XLineEndItem
      41             : #include <svx/xlnedit.hxx>
      42             : 
      43             : //oldChartModelWrapper
      44             : 
      45             : // header for class SfxItemPool
      46             : #include <svl/itempool.hxx>
      47             : // header for class FontList
      48             : #include <svtools/ctrltool.hxx>
      49             : // header for class Application
      50             : #include <vcl/svapp.hxx>
      51             : // header for class SdrObject
      52             : #include <svx/svdobj.hxx>
      53             : 
      54             : //for creation of a symbol Graphic
      55             : // header for class VirtualDevice
      56             : #include <vcl/virdev.hxx>
      57             : // header for class SdrView
      58             : #include <svx/svdview.hxx>
      59             : 
      60             : namespace chart
      61             : {
      62             : using namespace ::com::sun::star;
      63             : 
      64           0 : ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper )
      65             :                         : m_pDrawModelWrapper( pDrawModelWrapper )
      66           0 :                         , m_pFontList(NULL)
      67             : {
      68           0 : }
      69             : 
      70           0 : ViewElementListProvider::~ViewElementListProvider()
      71             : {
      72           0 :     if(m_pFontList)
      73           0 :         delete m_pFontList;
      74           0 : }
      75             : 
      76           0 : XColorListRef   ViewElementListProvider::GetColorTable() const
      77             : {
      78           0 :     if(m_pDrawModelWrapper)
      79           0 :         return m_pDrawModelWrapper->GetColorList();
      80           0 :     return XColorListRef();
      81             : }
      82             : 
      83           0 : XDashListRef     ViewElementListProvider::GetDashList() const
      84             : {
      85           0 :     if(m_pDrawModelWrapper)
      86           0 :         return m_pDrawModelWrapper->GetDashList();
      87           0 :     return XDashListRef();
      88             : }
      89             : 
      90           0 : XLineEndListRef  ViewElementListProvider::GetLineEndList() const
      91             : {
      92           0 :     if(m_pDrawModelWrapper)
      93           0 :         return m_pDrawModelWrapper->GetLineEndList();
      94           0 :     return XLineEndListRef();
      95             : }
      96             : 
      97           0 : XGradientListRef ViewElementListProvider::GetGradientList() const
      98             : {
      99           0 :     if(m_pDrawModelWrapper)
     100           0 :         return m_pDrawModelWrapper->GetGradientList();
     101           0 :     return XGradientListRef();
     102             : }
     103           0 : XHatchListRef    ViewElementListProvider::GetHatchList() const
     104             : {
     105           0 :     if(m_pDrawModelWrapper)
     106           0 :         return m_pDrawModelWrapper->GetHatchList();
     107           0 :     return NULL;
     108             : }
     109             : 
     110           0 : XBitmapListRef   ViewElementListProvider::GetBitmapList() const
     111             : {
     112           0 :     if(m_pDrawModelWrapper)
     113           0 :         return m_pDrawModelWrapper->GetBitmapList();
     114           0 :     return XBitmapListRef();
     115             : }
     116             : 
     117             : //create chartspecific symbols for linecharts
     118           0 : SdrObjList* ViewElementListProvider::GetSymbolList() const
     119             : {
     120           0 :     SdrObjList* m_pSymbolList = NULL;
     121           0 :     uno::Reference< drawing::XShapes > m_xSymbols(NULL);//@todo this keeps the first drawinglayer alive ...
     122             :     try
     123             :     {
     124           0 :         if(!m_pSymbolList || !m_pSymbolList->GetObjCount())
     125             :         {
     126             :             //@todo use mutex
     127             : 
     128             :             //get shape factory
     129           0 :             uno::Reference< lang::XMultiServiceFactory > xShapeFactory( m_pDrawModelWrapper->getShapeFactory() );
     130             : 
     131             :             //get hidden draw page (target):
     132           0 :             uno::Reference<drawing::XShapes> xTarget( m_pDrawModelWrapper->getHiddenDrawPage(), uno::UNO_QUERY );
     133             : 
     134             :             //create symbols via uno and convert to native sdr objects
     135           0 :             drawing::Direction3D aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ??
     136           0 :             m_xSymbols =  DataPointSymbolSupplier::create2DSymbolList( xShapeFactory, xTarget, aSymbolSize );
     137             : 
     138           0 :             SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( uno::Reference< drawing::XShape >( m_xSymbols, uno::UNO_QUERY ) );
     139           0 :             if(pSdrObject)
     140           0 :                 m_pSymbolList = pSdrObject->GetSubList();
     141             :         }
     142             :     }
     143           0 :     catch( const uno::Exception& e )
     144             :     {
     145             :         ASSERT_EXCEPTION( e );
     146             :     }
     147           0 :     return m_pSymbolList;
     148             : }
     149             : 
     150           0 : Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const
     151             : {
     152           0 :     SdrObjList* pSymbolList = this->GetSymbolList();
     153           0 :     if( !pSymbolList->GetObjCount() )
     154           0 :         return Graphic();
     155           0 :     if(nStandardSymbol<0)
     156           0 :         nStandardSymbol*=-1;
     157           0 :     if( nStandardSymbol >= static_cast<sal_Int32>(pSymbolList->GetObjCount()) )
     158           0 :         nStandardSymbol %= pSymbolList->GetObjCount();
     159           0 :     SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol);
     160             : 
     161           0 :     VirtualDevice aVDev;
     162           0 :     aVDev.SetMapMode(MapMode(MAP_100TH_MM));
     163           0 :     SdrModel* pModel = new SdrModel();
     164           0 :     pModel->GetItemPool().FreezeIdRanges();
     165           0 :     SdrPage* pPage = new SdrPage( *pModel, false );
     166           0 :     pPage->SetSize(Size(1000,1000));
     167           0 :     pModel->InsertPage( pPage, 0 );
     168           0 :     SdrView* pView = new SdrView( pModel, &aVDev );
     169           0 :     pView->hideMarkHandles();
     170           0 :     SdrPageView* pPageView = pView->ShowSdrPage(pPage);
     171             : 
     172           0 :     pObj=pObj->Clone();
     173           0 :     pPage->NbcInsertObject(pObj);
     174           0 :     pView->MarkObj(pObj,pPageView);
     175           0 :     if( pSymbolShapeProperties )
     176           0 :         pObj->SetMergedItemSet(*pSymbolShapeProperties);
     177             : 
     178           0 :     GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
     179             : 
     180           0 :     Graphic aGraph(aMeta);
     181           0 :     Size aSize = pObj->GetSnapRect().GetSize();
     182           0 :     aGraph.SetPrefSize(aSize);
     183           0 :     aGraph.SetPrefMapMode(MAP_100TH_MM);
     184             : 
     185           0 :     pView->UnmarkAll();
     186           0 :     pObj=pPage->RemoveObject(0);
     187           0 :     SdrObject::Free( pObj );
     188           0 :     delete pView;
     189           0 :     delete pModel;
     190             : 
     191           0 :     return aGraph;
     192             : }
     193             : 
     194           0 : FontList* ViewElementListProvider::getFontList() const
     195             : {
     196             :     //was old chart:
     197             :     //SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST)
     198             : 
     199           0 :     if(!m_pFontList)
     200             :     {
     201           0 :         OutputDevice* pRefDev    = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : NULL;
     202           0 :         OutputDevice* pDefaultOut = Application::GetDefaultDevice();
     203             :         m_pFontList = new FontList( pRefDev ? pRefDev    : pDefaultOut
     204             :                                 , pRefDev ? pDefaultOut : NULL
     205           0 :                                 , false );
     206             :     }
     207           0 :     return m_pFontList;
     208             : }
     209             : } //namespace chart
     210             : 
     211             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10