LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/drawinglayer - ViewElementListProvider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 85 0.0 %
Date: 2012-12-27 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             : //------------
      44             : //oldChartModelWrapper
      45             : 
      46             : // header for class SfxItemPool
      47             : #include <svl/itempool.hxx>
      48             : // header for class FontList
      49             : #include <svtools/ctrltool.hxx>
      50             : // header for class Application
      51             : #include <vcl/svapp.hxx>
      52             : //------------
      53             : // header for class SdrObject
      54             : #include <svx/svdobj.hxx>
      55             : 
      56             : 
      57             : //---------------
      58             : //for creation of a symbol Graphic
      59             : // header for class VirtualDevice
      60             : #include <vcl/virdev.hxx>
      61             : // header for class SdrView
      62             : #include <svx/svdview.hxx>
      63             : //---------------
      64             : 
      65             : //.............................................................................
      66             : namespace chart
      67             : {
      68             : //.............................................................................
      69             : using namespace ::com::sun::star;
      70             : 
      71           0 : ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper )
      72             :                         : m_pDrawModelWrapper( pDrawModelWrapper )
      73           0 :                         , m_pFontList(NULL)
      74             : {
      75           0 : }
      76             : 
      77           0 : ViewElementListProvider::~ViewElementListProvider()
      78             : {
      79           0 :     if(m_pFontList)
      80           0 :         delete m_pFontList;
      81           0 : }
      82             : 
      83             : //-----------------------------------------------------------------------------
      84             : //-----------------------------------------------------------------------------
      85             : 
      86           0 : XColorListRef   ViewElementListProvider::GetColorTable() const
      87             : {
      88           0 :     if(m_pDrawModelWrapper)
      89           0 :         return m_pDrawModelWrapper->GetColorList();
      90           0 :     return XColorListRef();
      91             : }
      92             : 
      93           0 : XDashListRef     ViewElementListProvider::GetDashList() const
      94             : {
      95           0 :     if(m_pDrawModelWrapper)
      96           0 :         return m_pDrawModelWrapper->GetDashList();
      97           0 :     return XDashListRef();
      98             : }
      99             : 
     100           0 : XLineEndListRef  ViewElementListProvider::GetLineEndList() const
     101             : {
     102           0 :     if(m_pDrawModelWrapper)
     103           0 :         return m_pDrawModelWrapper->GetLineEndList();
     104           0 :     return XLineEndListRef();
     105             : }
     106             : 
     107           0 : XGradientListRef ViewElementListProvider::GetGradientList() const
     108             : {
     109           0 :     if(m_pDrawModelWrapper)
     110           0 :         return m_pDrawModelWrapper->GetGradientList();
     111           0 :     return XGradientListRef();
     112             : }
     113           0 : XHatchListRef    ViewElementListProvider::GetHatchList() const
     114             : {
     115           0 :     if(m_pDrawModelWrapper)
     116           0 :         return m_pDrawModelWrapper->GetHatchList();
     117           0 :     return NULL;
     118             : }
     119             : 
     120           0 : XBitmapListRef   ViewElementListProvider::GetBitmapList() const
     121             : {
     122           0 :     if(m_pDrawModelWrapper)
     123           0 :         return m_pDrawModelWrapper->GetBitmapList();
     124           0 :     return XBitmapListRef();
     125             : }
     126             : 
     127             : //-----------------------------------------------------------------------------
     128             : 
     129             : //create chartspecific symbols for linecharts
     130           0 : SdrObjList* ViewElementListProvider::GetSymbolList() const
     131             : {
     132           0 :     SdrObjList* m_pSymbolList = NULL;
     133           0 :     uno::Reference< drawing::XShapes > m_xSymbols(NULL);//@todo this keeps the first drawinglayer alive ...
     134             :     try
     135             :     {
     136           0 :         if(!m_pSymbolList || !m_pSymbolList->GetObjCount())
     137             :         {
     138             :             //@todo use mutex
     139             : 
     140             :             //get shape factory
     141           0 :             uno::Reference< lang::XMultiServiceFactory > xShapeFactory( m_pDrawModelWrapper->getShapeFactory() );
     142             : 
     143             :             //get hidden draw page (target):
     144           0 :             uno::Reference<drawing::XShapes> xTarget( m_pDrawModelWrapper->getHiddenDrawPage(), uno::UNO_QUERY );
     145             : 
     146             :             //create symbols via uno and convert to native sdr objects
     147           0 :             drawing::Direction3D aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ??
     148           0 :             m_xSymbols =  DataPointSymbolSupplier::create2DSymbolList( xShapeFactory, xTarget, aSymbolSize );
     149             : 
     150           0 :             SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( uno::Reference< drawing::XShape >( m_xSymbols, uno::UNO_QUERY ) );
     151           0 :             if(pSdrObject)
     152           0 :                 m_pSymbolList = pSdrObject->GetSubList();
     153             :         }
     154             :     }
     155           0 :     catch( const uno::Exception& e )
     156             :     {
     157             :         ASSERT_EXCEPTION( e );
     158             :     }
     159           0 :     return m_pSymbolList;
     160             : }
     161             : 
     162           0 : Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const
     163             : {
     164           0 :     SdrObjList* pSymbolList = this->GetSymbolList();
     165           0 :     if( !pSymbolList->GetObjCount() )
     166           0 :         return Graphic();
     167           0 :     if(nStandardSymbol<0)
     168           0 :         nStandardSymbol*=-1;
     169           0 :     if( nStandardSymbol >= static_cast<sal_Int32>(pSymbolList->GetObjCount()) )
     170           0 :         nStandardSymbol %= pSymbolList->GetObjCount();
     171           0 :     SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol);
     172             : 
     173           0 :     VirtualDevice aVDev;
     174           0 :     aVDev.SetMapMode(MapMode(MAP_100TH_MM));
     175           0 :     SdrModel* pModel = new SdrModel();
     176           0 :     pModel->GetItemPool().FreezeIdRanges();
     177           0 :     SdrPage* pPage = new SdrPage( *pModel, sal_False );
     178           0 :     pPage->SetSize(Size(1000,1000));
     179           0 :     pModel->InsertPage( pPage, 0 );
     180           0 :     SdrView* pView = new SdrView( pModel, &aVDev );
     181           0 :     pView->hideMarkHandles();
     182           0 :     SdrPageView* pPageView = pView->ShowSdrPage(pPage);
     183             : 
     184           0 :     pObj=pObj->Clone();
     185           0 :     pPage->NbcInsertObject(pObj);
     186           0 :     pView->MarkObj(pObj,pPageView);
     187           0 :     if( pSymbolShapeProperties )
     188           0 :         pObj->SetMergedItemSet(*pSymbolShapeProperties);
     189             : 
     190           0 :     GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
     191             : 
     192           0 :     Graphic aGraph(aMeta);
     193           0 :     Size aSize = pObj->GetSnapRect().GetSize();
     194           0 :     aGraph.SetPrefSize(aSize);
     195           0 :     aGraph.SetPrefMapMode(MAP_100TH_MM);
     196             : 
     197           0 :     pView->UnmarkAll();
     198           0 :     pObj=pPage->RemoveObject(0);
     199           0 :     SdrObject::Free( pObj );
     200           0 :     delete pView;
     201           0 :     delete pModel;
     202             : 
     203           0 :     return aGraph;
     204             : }
     205             : 
     206             : //-----------------------------------------------------------------------------
     207             : //-----------------------------------------------------------------------------
     208             : 
     209           0 : FontList* ViewElementListProvider::getFontList() const
     210             : {
     211             :     //was old chart:
     212             :     //SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST)
     213             : 
     214           0 :     if(!m_pFontList)
     215             :     {
     216           0 :         OutputDevice* pRefDev    = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : NULL;
     217           0 :         OutputDevice* pDefaultOut = Application::GetDefaultDevice();
     218             :         m_pFontList = new FontList( pRefDev ? pRefDev    : pDefaultOut
     219             :                                 , pRefDev ? pDefaultOut : NULL
     220           0 :                                 , sal_False );
     221             :     }
     222           0 :     return m_pFontList;
     223             : }
     224             : //.............................................................................
     225             : } //namespace chart
     226             : //.............................................................................
     227             : 
     228             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10