LibreOffice Module sc (master)  1
chartsh.cxx
Go to the documentation of this file.
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 <sfx2/objface.hxx>
25 #include <vcl/EnumContext.hxx>
26 
27 #include <chartsh.hxx>
28 #include <sc.hrc>
29 #include <viewdata.hxx>
30 #include <drawview.hxx>
31 #include <gridwin.hxx>
32 
33 #define ShellClass_ScChartShell
34 #include <scslots.hxx>
35 
36 using namespace css::uno;
37 
39 
41 
42 void ScChartShell::InitInterface_Impl()
43 {
44  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT,
45  SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
46  ToolbarId::Draw_Objectbar);
47 
48  GetStaticInterface()->RegisterPopupMenu("oleobject");
49 }
50 
51 
53  ScDrawShell(rData)
54 {
55  SetName( "ChartObject" );
57 }
58 
60 {
61 }
62 
64 {
66  const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
67  bool bEnable = false;
68  if( rMarkList.GetMarkCount() == 1 )
69  {
70  SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
71 
72  if( dynamic_cast<const SdrOle2Obj*>( pObj) )
73  bEnable = true;
74  }
75 
76  if (GetObjectShell()->isExportLocked())
77  bEnable = false;
78 
79  if( !bEnable )
80  rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
81 }
82 
84 {
86  const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
87 
88  if( rMarkList.GetMarkCount() == 1 )
89  {
90  SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
91 
92  if( dynamic_cast<const SdrOle2Obj*>( pObject) )
93  {
95  Reference< drawing::XShape > xSourceDoc( pObject->getUnoShape(), UNO_QUERY_THROW );
96  GraphicHelper::SaveShapeAsGraphic(pWin ? pWin->GetFrameWeld() : nullptr, xSourceDoc);
97  }
98  }
99 
100  Invalidate();
101 }
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t GetMarkCount() const
#define SFX_IMPL_INTERFACE(Class, SuperClass)
ScViewData & GetViewData()
Definition: drawsh.hxx:51
void GetExportAsGraphicState(SfxItemSet &rSet)
Definition: chartsh.cxx:63
SdrMark * GetMark(size_t nNum) const
EmbeddedObjectRef * pObject
weld::Window * GetFrameWeld() const
virtual css::uno::Reference< css::uno::XInterface > getUnoShape()
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3074
SdrObject * GetMarkedSdrObj() const
const SdrMarkList & GetMarkedObjectList() const
void ExecuteExportAsGraphic(SfxRequest &rReq)
Definition: chartsh.cxx:83
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3062
void SetName(const OUString &rName)
#define SFX_OBJECTBAR_OBJECT
static void SaveShapeAsGraphic(weld::Window *pWin, const css::uno::Reference< css::drawing::XShape > &xShape)
static const OUString & GetContextName(const Context eContext)
void DisableItem(sal_uInt16 nWhich)
virtual ~ScChartShell() override
Definition: chartsh.cxx:59
ScChartShell(ScViewData &rData)
Definition: chartsh.cxx:52
virtual void Invalidate(sal_uInt16 nId=0)
void SetContextName(const OUString &rsContextName)
virtual SfxObjectShell * GetObjectShell()
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo