Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / ui / drawfunc / chartsh.cxx
blobb70ce15e57c22918949628c8f487dec1e7392568
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/svdoole2.hxx>
21 #include <svx/svdobj.hxx>
22 #include <svx/graphichelper.hxx>
24 #include <sfx2/objface.hxx>
25 #include <vcl/EnumContext.hxx>
27 #include <chartsh.hxx>
28 #include <sc.hrc>
29 #include <viewdata.hxx>
30 #include <drawview.hxx>
31 #include <gridwin.hxx>
33 #define ShellClass_ScChartShell
34 #include <scslots.hxx>
36 using namespace css::uno;
38 namespace drawing = com::sun::star::drawing;
40 SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell)
42 void ScChartShell::InitInterface_Impl()
44 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT,
45 SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
46 ToolbarId::Draw_Objectbar);
48 GetStaticInterface()->RegisterPopupMenu("oleobject");
52 ScChartShell::ScChartShell(ScViewData* pData) :
53 ScDrawShell(pData)
55 SetName( "ChartObject" );
56 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Chart));
59 ScChartShell::~ScChartShell()
63 void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet )
65 ScDrawView* pView = GetViewData()->GetScDrawView();
66 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
67 bool bEnable = false;
68 if( rMarkList.GetMarkCount() == 1 )
70 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
72 if( dynamic_cast<const SdrOle2Obj*>( pObj) )
73 bEnable = true;
76 if (GetViewShell()->isExportLocked())
77 bEnable = false;
79 if( !bEnable )
80 rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
83 void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
85 ScDrawView* pView = GetViewData()->GetScDrawView();
86 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
88 if( rMarkList.GetMarkCount() == 1 )
90 SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
92 if( dynamic_cast<const SdrOle2Obj*>( pObject) )
94 vcl::Window* pWin = GetViewData()->GetActiveWin();
95 Reference< drawing::XShape > xSourceDoc( pObject->getUnoShape(), UNO_QUERY_THROW );
96 GraphicHelper::SaveShapeAsGraphic(pWin ? pWin->GetFrameWeld() : nullptr, xSourceDoc);
100 Invalidate();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */