LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - chartsh.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 6 37 16.2 %
Date: 2014-11-03 Functions: 5 17 29.4 %
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         304 : SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL))
      49             : 
      50          76 : void ScChartShell::InitInterface_Impl()
      51             : {
      52             :     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
      53          76 :                                             ScResId(RID_DRAW_OBJECTBAR));
      54             : 
      55          76 :     GetStaticInterface()->RegisterPopupMenu(ScResId(RID_POPUP_CHART));
      56          76 : }
      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           0 : }
     107             : 
     108           0 : void ScChartShell::HandleSelectionChange (void)
     109             : {
     110             :     // Do not call the implementation in the base class.  Let
     111             :     // Activate()/Deactivate() handle context switches.
     112         228 : }
     113             : 
     114             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10