LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - chartsh.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 35 17.1 %
Date: 2015-06-13 12:38:46 Functions: 5 16 31.2 %
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 <svx/svdoole2.hxx>
      21             : #include <svx/svdobj.hxx>
      22             : #include <svx/graphichelper.hxx>
      23             : 
      24             : #include <svl/srchitem.hxx>
      25             : #include <sfx2/app.hxx>
      26             : #include <sfx2/objface.hxx>
      27             : #include <sfx2/request.hxx>
      28             : #include <sfx2/sidebar/EnumContext.hxx>
      29             : #include <svl/whiter.hxx>
      30             : #include <vcl/msgbox.hxx>
      31             : 
      32             : #include "chartsh.hxx"
      33             : #include "drwlayer.hxx"
      34             : #include "sc.hrc"
      35             : #include "viewdata.hxx"
      36             : #include "document.hxx"
      37             : #include "docpool.hxx"
      38             : #include "drawview.hxx"
      39             : #include "scresid.hxx"
      40             : 
      41             : #define ScChartShell
      42             : #include "scslots.hxx"
      43             : 
      44             : using namespace css::uno;
      45             : 
      46             : namespace drawing = com::sun::star::drawing;
      47             : 
      48         208 : SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell)
      49             : 
      50          52 : void ScChartShell::InitInterface_Impl()
      51             : {
      52             :     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
      53          52 :                                             RID_DRAW_OBJECTBAR);
      54             : 
      55          52 :     GetStaticInterface()->RegisterPopupMenu(ScResId(RID_POPUP_CHART));
      56          52 : }
      57             : 
      58           0 : TYPEINIT1( ScChartShell, ScDrawShell );
      59             : 
      60           0 : ScChartShell::ScChartShell(ScViewData* pData) :
      61           0 :     ScDrawShell(pData)
      62             : {
      63           0 :     SetHelpId( HID_SCSHELL_CHARTSH );
      64           0 :     SetName( OUString("ChartObject") );
      65           0 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Chart));
      66           0 : }
      67             : 
      68           0 : ScChartShell::~ScChartShell()
      69             : {
      70           0 : }
      71             : 
      72           0 : void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet )
      73             : {
      74           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
      75           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
      76           0 :     bool bEnable = false;
      77           0 :     if( rMarkList.GetMarkCount() == 1 )
      78             :     {
      79           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
      80             : 
      81           0 :         if( pObj && pObj->ISA( SdrOle2Obj ) )
      82           0 :             bEnable = true;
      83             :     }
      84             : 
      85           0 :     if( !bEnable )
      86           0 :         rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
      87           0 : }
      88             : 
      89           0 : void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
      90             : {
      91           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
      92           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
      93             : 
      94           0 :     if( rMarkList.GetMarkCount() == 1 )
      95             :     {
      96           0 :         SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
      97             : 
      98           0 :         if( pObject && pObject->ISA( SdrOle2Obj ) )
      99             :         {
     100           0 :             Reference< drawing::XShape > xSourceDoc = Reference< drawing::XShape >( pObject->getUnoShape(), UNO_QUERY_THROW );
     101           0 :             GraphicHelper::SaveShapeAsGraphic( xSourceDoc );
     102             :         }
     103             :     }
     104             : 
     105           0 :     Invalidate();
     106         156 : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11