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 <svl/whiter.hxx>
29 : #include <vcl/msgbox.hxx>
30 :
31 : #include "chartsh.hxx"
32 : #include "drwlayer.hxx"
33 : #include "sc.hrc"
34 : #include "viewdata.hxx"
35 : #include "document.hxx"
36 : #include "docpool.hxx"
37 : #include "drawview.hxx"
38 : #include "scresid.hxx"
39 :
40 : #define ScChartShell
41 : #include "scslots.hxx"
42 :
43 25 : SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) )
44 : {
45 10 : SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
46 5 : ScResId(RID_DRAW_OBJECTBAR) );
47 5 : SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_CHART) );
48 5 : }
49 :
50 0 : TYPEINIT1( ScChartShell, ScDrawShell );
51 :
52 0 : ScChartShell::ScChartShell(ScViewData* pData) :
53 0 : ScDrawShell(pData)
54 : {
55 0 : SetHelpId( HID_SCSHELL_CHARTSH );
56 0 : SetName( OUString("ChartObject") );
57 0 : }
58 :
59 0 : ScChartShell::~ScChartShell()
60 : {
61 0 : }
62 :
63 0 : void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet )
64 : {
65 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
66 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
67 0 : bool bEnable = false;
68 0 : if( rMarkList.GetMarkCount() == 1 )
69 : {
70 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
71 :
72 0 : if( pObj && pObj->ISA( SdrOle2Obj ) )
73 0 : bEnable = true;
74 : }
75 :
76 0 : if( !bEnable )
77 0 : rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
78 0 : }
79 :
80 0 : void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
81 : {
82 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
83 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
84 :
85 0 : if( rMarkList.GetMarkCount() == 1 )
86 : {
87 0 : SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
88 :
89 0 : if( pObject && pObject->ISA( SdrOle2Obj ) )
90 : {
91 0 : SdrOle2Obj* aOle2Object = ((SdrOle2Obj*) pObject)->Clone();
92 0 : aOle2Object->NbcResize(Point(), Fraction(1,1), Fraction(1,1));
93 0 : Graphic* pGraphic = aOle2Object->GetGraphic();
94 0 : if( pGraphic != NULL )
95 : {
96 0 : String sGrfNm, sFilterNm;
97 0 : GraphicHelper::ExportGraphic( *pGraphic, String("") );
98 : }
99 : }
100 : }
101 :
102 0 : Invalidate();
103 15 : }
104 :
105 :
106 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|