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 0 : SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) )
49 : {
50 0 : SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
51 0 : ScResId(RID_DRAW_OBJECTBAR) );
52 0 : SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_CHART) );
53 0 : }
54 :
55 0 : TYPEINIT1( ScChartShell, ScDrawShell );
56 :
57 0 : ScChartShell::ScChartShell(ScViewData* pData) :
58 0 : ScDrawShell(pData)
59 : {
60 0 : SetHelpId( HID_SCSHELL_CHARTSH );
61 0 : SetName( OUString("ChartObject") );
62 0 : SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Chart));
63 0 : }
64 :
65 0 : ScChartShell::~ScChartShell()
66 : {
67 0 : }
68 :
69 0 : void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet )
70 : {
71 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
72 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
73 0 : bool bEnable = false;
74 0 : if( rMarkList.GetMarkCount() == 1 )
75 : {
76 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
77 :
78 0 : if( pObj && pObj->ISA( SdrOle2Obj ) )
79 0 : bEnable = true;
80 : }
81 :
82 0 : if( !bEnable )
83 0 : rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
84 0 : }
85 :
86 0 : void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
87 : {
88 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
89 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
90 :
91 0 : if( rMarkList.GetMarkCount() == 1 )
92 : {
93 0 : SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
94 :
95 0 : if( pObject && pObject->ISA( SdrOle2Obj ) )
96 : {
97 0 : Reference< drawing::XShape > xSourceDoc = Reference< drawing::XShape >( pObject->getUnoShape(), UNO_QUERY_THROW );
98 0 : GraphicHelper::SaveShapeAsGraphic( xSourceDoc );
99 : }
100 : }
101 :
102 0 : Invalidate();
103 0 : }
104 :
105 0 : void ScChartShell::HandleSelectionChange (void)
106 : {
107 : // Do not call the implementation in the base class. Let
108 : // Activate()/Deactivate() handle context switches.
109 0 : }
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|