Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <sfx2/app.hxx>
30 : : #include <sfx2/objface.hxx>
31 : : #include <sfx2/request.hxx>
32 : : #include <svl/whiter.hxx>
33 : : #include <svx/svdograf.hxx>
34 : : #include <svx/grfflt.hxx>
35 : : #include <svx/grafctrl.hxx>
36 : :
37 : : #include "graphsh.hxx"
38 : : #include "sc.hrc"
39 : : #include "viewdata.hxx"
40 : : #include "drawview.hxx"
41 : : #include "scresid.hxx"
42 : : #include <svx/extedit.hxx>
43 : :
44 : : #define ScGraphicShell
45 : : #include "scslots.hxx"
46 : :
47 : : #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
48 : :
49 [ # # ]: 0 : class ScExternalToolEdit : public ExternalToolEdit
50 : : {
51 : : ScDrawView* m_pView;
52 : : SdrObject* m_pObj;
53 : :
54 : : public:
55 : 0 : ScExternalToolEdit ( ScDrawView* pView, SdrObject* pObj ) :
56 : : m_pView (pView),
57 : 0 : m_pObj (pObj)
58 : 0 : {}
59 : :
60 : 0 : virtual void Update( Graphic& aGraphic )
61 : : {
62 : 0 : SdrPageView* pPageView = m_pView->GetSdrPageView();
63 [ # # ]: 0 : if( pPageView )
64 : : {
65 [ # # ]: 0 : SdrGrafObj* pNewObj = (SdrGrafObj*) m_pObj->Clone();
66 [ # # ]: 0 : String aStr( m_pView->GetDescriptionOfMarkedObjects() );
67 [ # # ]: 0 : aStr.Append( sal_Unicode(' ') );
68 [ # # ][ # # ]: 0 : aStr.Append( String( "External Edit" ) );
[ # # ]
69 [ # # ]: 0 : m_pView->BegUndo( aStr );
70 [ # # ][ # # ]: 0 : pNewObj->SetGraphicObject( aGraphic );
[ # # ]
71 [ # # ]: 0 : m_pView->ReplaceObjectAtView( m_pObj, *pPageView, pNewObj );
72 [ # # ][ # # ]: 0 : m_pView->EndUndo();
73 : : }
74 : 0 : }
75 : : };
76 : :
77 [ + + ][ + - ]: 204 : SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
[ + - ][ + - ]
78 : : {
79 [ + - ]: 51 : SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
80 [ + - ]: 51 : ScResId(RID_GRAPHIC_OBJECTBAR) );
81 [ + - ][ + - ]: 51 : SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_GRAPHIC) );
82 : 51 : }
83 : :
84 [ # # ][ # # ]: 0 : TYPEINIT1( ScGraphicShell, ScDrawShell );
85 : :
86 : 0 : ScGraphicShell::ScGraphicShell(ScViewData* pData) :
87 : 0 : ScDrawShell(pData)
88 : : {
89 [ # # ]: 0 : SetHelpId(HID_SCSHELL_GRAPHIC);
90 [ # # ][ # # ]: 0 : SetName(rtl::OUString("GraphicObject"));
[ # # ]
91 : 0 : }
92 : :
93 : 0 : ScGraphicShell::~ScGraphicShell()
94 : : {
95 [ # # ]: 0 : }
96 : :
97 : 0 : void ScGraphicShell::GetAttrState( SfxItemSet& rSet )
98 : : {
99 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
100 : :
101 [ # # ]: 0 : if( pView )
102 : 0 : SvxGrafAttrHelper::GetGrafAttrState( rSet, *pView );
103 : 0 : }
104 : :
105 : 0 : void ScGraphicShell::Execute( SfxRequest& rReq )
106 : : {
107 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
108 : :
109 [ # # ]: 0 : if( pView )
110 : : {
111 : 0 : SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *pView );
112 : 0 : Invalidate();
113 : : }
114 : 0 : }
115 : :
116 : 0 : void ScGraphicShell::GetFilterState( SfxItemSet& rSet )
117 : : {
118 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
119 : 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
120 : 0 : sal_Bool bEnable = false;
121 : :
122 [ # # ]: 0 : if( rMarkList.GetMarkCount() == 1 )
123 : : {
124 : 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
125 : :
126 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
[ # # ][ # # ]
127 : 0 : bEnable = sal_True;
128 : : }
129 : :
130 [ # # ]: 0 : if( !bEnable )
131 : 0 : SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
132 : 0 : }
133 : :
134 : 0 : void ScGraphicShell::ExecuteFilter( SfxRequest& rReq )
135 : : {
136 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
137 : 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
138 : :
139 [ # # ]: 0 : if( rMarkList.GetMarkCount() == 1 )
140 : : {
141 : 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
142 : :
143 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
[ # # ][ # # ]
144 : : {
145 [ # # ][ # # ]: 0 : GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
146 : :
147 [ # # ]: 0 : if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
148 [ # # ]: 0 : SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
149 : : {
150 : 0 : SdrPageView* pPageView = pView->GetSdrPageView();
151 : :
152 [ # # ]: 0 : if( pPageView )
153 : : {
154 [ # # ]: 0 : SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
155 [ # # ]: 0 : String aStr( pView->GetDescriptionOfMarkedObjects() );
156 : :
157 [ # # ]: 0 : aStr.Append( sal_Unicode(' ') );
158 [ # # ][ # # ]: 0 : aStr.Append( String( ScResId( SCSTR_UNDO_GRAFFILTER ) ) );
[ # # ][ # # ]
159 [ # # ]: 0 : pView->BegUndo( aStr );
160 [ # # ]: 0 : pFilteredObj->SetGraphicObject( aFilterObj );
161 [ # # ]: 0 : pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
162 [ # # ][ # # ]: 0 : pView->EndUndo();
163 : : }
164 [ # # ]: 0 : }
165 : : }
166 : : }
167 : :
168 : 0 : Invalidate();
169 : 0 : }
170 : :
171 : 0 : void ScGraphicShell::GetExternalEditState( SfxItemSet& rSet )
172 : : {
173 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
174 : 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
175 : 0 : bool bEnable = false;
176 [ # # ]: 0 : if( rMarkList.GetMarkCount() == 1 )
177 : : {
178 : 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
179 : :
180 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
[ # # ][ # # ]
181 : 0 : bEnable = true;
182 : : }
183 : :
184 [ # # ]: 0 : if( !bEnable )
185 : 0 : rSet.DisableItem( SID_EXTERNAL_EDIT );
186 : 0 : }
187 : :
188 : 0 : void ScGraphicShell::ExecuteExternalEdit( SfxRequest& )
189 : : {
190 : 0 : ScDrawView* pView = GetViewData()->GetScDrawView();
191 : 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
192 : :
193 [ # # ]: 0 : if( rMarkList.GetMarkCount() == 1 )
194 : : {
195 : 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
196 : :
197 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
[ # # ][ # # ]
198 : : {
199 [ # # ][ # # ]: 0 : GraphicObject aGraphicObject( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
200 [ # # ][ # # ]: 0 : ScExternalToolEdit* aExternalToolEdit = new ScExternalToolEdit( pView, pObj );
201 [ # # ][ # # ]: 0 : aExternalToolEdit->Edit( &aGraphicObject );
202 : : }
203 : : }
204 : :
205 : 0 : Invalidate();
206 : 0 : }
207 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|