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 <cmdid.h>
30 : : #include <hintids.hxx>
31 : : #include <tools/urlobj.hxx>
32 : : #include <vcl/msgbox.hxx>
33 : : #include <svl/stritem.hxx>
34 : : #include <svl/whiter.hxx>
35 : : #include <svl/urihelper.hxx>
36 : : #include <sfx2/docfile.hxx>
37 : : #include <sfx2/dispatch.hxx>
38 : :
39 : : #include <sfx2/objface.hxx>
40 : : #include <editeng/sizeitem.hxx>
41 : : #include <editeng/protitem.hxx>
42 : : #include <sfx2/request.hxx>
43 : : #include <svl/srchitem.hxx>
44 : : #include <svx/htmlmode.hxx>
45 : : #include <svx/sdgluitm.hxx>
46 : : #include <svx/sdgcoitm.hxx>
47 : : #include <svx/sdggaitm.hxx>
48 : : #include <svx/sdgtritm.hxx>
49 : : #include <svx/sdginitm.hxx>
50 : : #include <svx/sdgmoitm.hxx>
51 : : #include <editeng/brshitem.hxx>
52 : : #include <svx/grfflt.hxx>
53 : : #include <svx/tbxcolor.hxx>
54 : : #include <fmturl.hxx>
55 : : #include <view.hxx>
56 : : #include <wrtsh.hxx>
57 : : #include <viewopt.hxx>
58 : : #include <swmodule.hxx>
59 : : #include <frmatr.hxx>
60 : : #include <swundo.hxx>
61 : : #include <uitool.hxx>
62 : : #include <docsh.hxx>
63 : : #include <grfsh.hxx>
64 : : #include <frmmgr.hxx>
65 : : #include <frmdlg.hxx>
66 : : #include <frmfmt.hxx>
67 : : #include <grfatr.hxx>
68 : : #include <usrpref.hxx>
69 : : #include <edtwin.hxx>
70 : : #include <swwait.hxx>
71 : : #include <shells.hrc>
72 : : #include <popup.hrc>
73 : : #include <svx/extedit.hxx>
74 : : #include <svx/graphichelper.hxx>
75 : : #define SwGrfShell
76 : : #include <sfx2/msg.hxx>
77 : : #include "swslots.hxx"
78 : :
79 : : #include "swabstdlg.hxx"
80 : :
81 : : #define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) )
82 : :
83 [ # # ]: 0 : class SwExternalToolEdit : public ExternalToolEdit
84 : : {
85 : : SwWrtShell* m_pShell;
86 : :
87 : : public:
88 : 0 : SwExternalToolEdit ( SwWrtShell* pShell ) :
89 : 0 : m_pShell (pShell)
90 : 0 : {}
91 : :
92 : 0 : virtual void Update( Graphic& aGraphic )
93 : : {
94 : 0 : m_pShell->ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &aGraphic);
95 : 0 : }
96 : : };
97 : :
98 [ + + ][ + - ]: 365 : SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC))
[ + - ][ + - ]
99 : : {
100 [ + - ][ + - ]: 73 : SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU));
101 [ + - ][ + - ]: 73 : SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_GRAFIK_TOOLBOX));
102 : 73 : }
103 : :
104 : 0 : void SwGrfShell::Execute(SfxRequest &rReq)
105 : : {
106 : 0 : SwWrtShell &rSh = GetShell();
107 : :
108 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
109 [ # # # # : 0 : switch(nSlot)
# # ]
110 : : {
111 : : case SID_TWAIN_TRANSFER:
112 : : {
113 : 0 : GetView().ExecuteScan( rReq );
114 : 0 : break;
115 : : }
116 : : case SID_SAVE_GRAPHIC:
117 : : {
118 : : const Graphic *pGraphic;
119 [ # # ]: 0 : if(0 != (pGraphic = rSh.GetGraphic()))
120 : : {
121 [ # # ][ # # ]: 0 : String sGrfNm, sFilterNm;
122 [ # # ]: 0 : rSh.GetGrfNms( &sGrfNm, &sFilterNm );
123 [ # # ][ # # ]: 0 : GraphicHelper::ExportGraphic( *pGraphic, sGrfNm );
[ # # ][ # # ]
124 : : }
125 : : }
126 : 0 : break;
127 : : case SID_EXTERNAL_EDIT:
128 : : {
129 : : /* When the graphic is selected to be opened via some external tool
130 : : * for advanced editing
131 : : */
132 : 0 : GraphicObject *pGraphicObject = (GraphicObject *) rSh.GetGraphicObj();
133 [ # # ]: 0 : if(0 != pGraphicObject)
134 : : {
135 [ # # ]: 0 : SwExternalToolEdit* externalToolEdit = new SwExternalToolEdit( &rSh );
136 : 0 : externalToolEdit->Edit ( pGraphicObject );
137 : : }
138 : : }
139 : 0 : break;
140 : :
141 : : case SID_INSERT_GRAPHIC:
142 : : case FN_FORMAT_GRAFIC_DLG:
143 : : {
144 [ # # ]: 0 : SwFlyFrmAttrMgr aMgr( sal_False, &rSh, rSh.IsFrmSelected() ?
145 [ # # ][ # # ]: 0 : FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF);
146 : 0 : const SwViewOption* pVOpt = rSh.GetViewOptions();
147 [ # # ]: 0 : SwViewOption aUsrPref( *pVOpt );
148 : :
149 : 0 : SfxItemSet aSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1,
150 : : RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF,
151 : : SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
152 : : SID_ATTR_GRAF_KEEP_ZOOM, SID_ATTR_GRAF_KEEP_ZOOM,
153 : : SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE,
154 : : SID_ATTR_GRAF_FRMSIZE_PERCENT, SID_ATTR_GRAF_FRMSIZE_PERCENT,
155 : : SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC,
156 : : FN_PARAM_GRF_CONNECT, FN_PARAM_GRF_CONNECT,
157 : : SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
158 : : FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
159 : : FN_SET_FRM_NAME, FN_KEEP_ASPECT_RATIO,
160 : : FN_PARAM_GRF_DIALOG, FN_PARAM_GRF_DIALOG,
161 : : SID_DOCFRAME, SID_DOCFRAME,
162 : : SID_HTML_MODE, SID_HTML_MODE,
163 : : FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
164 [ # # ]: 0 : 0);
165 : :
166 [ # # ][ # # ]: 0 : sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
167 [ # # ][ # # ]: 0 : aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
[ # # ]
168 [ # # ]: 0 : FieldUnit eMetric = ::GetDfltMetric((0 != (nHtmlMode&HTMLMODE_ON)));
169 [ # # ][ # # ]: 0 : SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
[ # # ][ # # ]
170 : :
171 [ # # ]: 0 : const SwRect* pRect = &rSh.GetAnyCurRect(RECT_PAGE);
172 [ # # ]: 0 : SwFmtFrmSize aFrmSize( ATT_VAR_SIZE, pRect->Width(), pRect->Height());
173 [ # # ]: 0 : aFrmSize.SetWhich( GetPool().GetWhich( SID_ATTR_PAGE_SIZE ) );
174 [ # # ]: 0 : aSet.Put( aFrmSize );
175 : :
176 [ # # ][ # # ]: 0 : aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName()));
[ # # ][ # # ]
177 [ # # ]: 0 : if ( nSlot == FN_FORMAT_GRAFIC_DLG )
178 : : {
179 : : // #i73249#
180 [ # # ][ # # ]: 0 : aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) );
[ # # ][ # # ]
[ # # ]
181 : : }
182 : :
183 [ # # ]: 0 : pRect = &rSh.GetAnyCurRect(RECT_PAGE_PRT);
184 : 0 : aFrmSize.SetWidth( pRect->Width() );
185 : 0 : aFrmSize.SetHeight( pRect->Height() );
186 [ # # ]: 0 : aFrmSize.SetWhich( GetPool().GetWhich(FN_GET_PRINT_AREA) );
187 [ # # ]: 0 : aSet.Put( aFrmSize );
188 : :
189 [ # # ]: 0 : aSet.Put( aMgr.GetAttrSet() );
190 : 0 : aSet.SetParent( aMgr.GetAttrSet().GetParent() );
191 : :
192 : : // Bei %-Werten Groesse initialisieren
193 [ # # ][ # # ]: 0 : SwFmtFrmSize aSizeCopy = (const SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE);
194 [ # # ][ # # ]: 0 : if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != 0xff)
[ # # ]
195 [ # # ]: 0 : aSizeCopy.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
196 [ # # ][ # # ]: 0 : if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != 0xff)
[ # # ]
197 [ # # ]: 0 : aSizeCopy.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
198 : :
199 : : // and now set the size for "external" tabpages
200 : : {
201 [ # # ]: 0 : SvxSizeItem aSzItm( SID_ATTR_GRAF_FRMSIZE, aSizeCopy.GetSize() );
202 [ # # ]: 0 : aSet.Put( aSzItm );
203 : :
204 : 0 : Size aSz( aSizeCopy.GetWidthPercent(), aSizeCopy.GetHeightPercent() );
205 [ # # ]: 0 : if( 0xff == aSz.Width() ) aSz.Width() = 0;
206 [ # # ]: 0 : if( 0xff == aSz.Height() ) aSz.Height() = 0;
207 : :
208 : 0 : aSzItm.SetSize( aSz );
209 : 0 : aSzItm.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT );
210 [ # # ][ # # ]: 0 : aSet.Put( aSzItm );
211 : : }
212 : :
213 [ # # ][ # # ]: 0 : String sGrfNm, sFilterNm;
214 [ # # ]: 0 : rSh.GetGrfNms( &sGrfNm, &sFilterNm );
215 [ # # ]: 0 : if( sGrfNm.Len() )
216 : : {
217 : : aSet.Put( SvxBrushItem( INetURLObject::decode( sGrfNm,
218 : : INET_HEX_ESCAPE,
219 : : INetURLObject::DECODE_UNAMBIGUOUS,
220 : : RTL_TEXTENCODING_UTF8 ),
221 : : sFilterNm, GPOS_LT,
222 [ # # ][ # # ]: 0 : SID_ATTR_GRAF_GRAPHIC ));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
223 : : }
224 : : else
225 : : {
226 : : // #119353# - robust
227 [ # # ]: 0 : const GraphicObject* pGrfObj = rSh.GetGraphicObj();
228 [ # # ]: 0 : if ( pGrfObj )
229 : : {
230 : : aSet.Put( SvxBrushItem( *pGrfObj, GPOS_LT,
231 [ # # ][ # # ]: 0 : SID_ATTR_GRAF_GRAPHIC ) );
[ # # ]
232 : : }
233 : : }
234 [ # # ][ # # ]: 0 : aSet.Put( SfxBoolItem( FN_PARAM_GRF_CONNECT, sGrfNm.Len() > 0 ) );
[ # # ]
235 : :
236 : : // get Mirror and Crop
237 : : {
238 [ # # ]: 0 : SfxItemSet aTmpSet( rSh.GetAttrPool(),
239 [ # # ]: 0 : RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF );
240 : :
241 [ # # ]: 0 : rSh.GetCurAttr( aTmpSet );
242 [ # # ][ # # ]: 0 : aSet.Put( aTmpSet );
243 : : }
244 : :
245 [ # # ][ # # ]: 0 : aSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, aUsrPref.IsKeepRatio()));
[ # # ]
246 [ # # ][ # # ]: 0 : aSet.Put(SfxBoolItem( SID_ATTR_GRAF_KEEP_ZOOM, aUsrPref.IsGrfKeepZoom()));
[ # # ]
247 : :
248 [ # # ][ # # ]: 0 : aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame()));
[ # # ][ # # ]
249 : :
250 [ # # ]: 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
251 : : OSL_ENSURE(pFact, "Dialogdiet fail!");
252 : : SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_GRF,
253 : 0 : GetView().GetViewFrame(),
254 : 0 : GetView().GetWindow(),
255 [ # # ]: 0 : aSet, sal_False, DLG_FRM_GRF);
256 : : OSL_ENSURE(pDlg, "Dialogdiet fail!");
257 [ # # ][ # # ]: 0 : if( pDlg->Execute() )
258 : : {
259 [ # # ]: 0 : rSh.StartAllAction();
260 [ # # ]: 0 : rSh.StartUndo(UNDO_START);
261 : : const SfxPoolItem* pItem;
262 [ # # ]: 0 : SfxItemSet* pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
263 [ # # ]: 0 : rReq.Done(*pSet);
264 : : // change the 2 frmsize SizeItems to the correct SwFrmSizeItem
265 [ # # ]: 0 : if( SFX_ITEM_SET == pSet->GetItemState(
266 [ # # ]: 0 : SID_ATTR_GRAF_FRMSIZE, sal_False, &pItem ))
267 : : {
268 [ # # ]: 0 : SwFmtFrmSize aSize;
269 : 0 : const Size& rSz = ((SvxSizeItem*)pItem)->GetSize();
270 : 0 : aSize.SetWidth( rSz.Width() );
271 : 0 : aSize.SetHeight( rSz.Height() );
272 : :
273 [ # # ]: 0 : if( SFX_ITEM_SET == pSet->GetItemState(
274 [ # # ]: 0 : SID_ATTR_GRAF_FRMSIZE_PERCENT, sal_False, &pItem ))
275 : : {
276 : 0 : const Size& rRelativeSize = ((SvxSizeItem*)pItem)->GetSize();
277 : 0 : aSize.SetWidthPercent( static_cast< sal_uInt8 >( rRelativeSize.Width() ) );
278 : 0 : aSize.SetHeightPercent( static_cast< sal_uInt8 >( rRelativeSize.Height() ) );
279 : : }
280 [ # # ][ # # ]: 0 : pSet->Put( aSize );
281 : : }
282 : :
283 : : // Vorlagen-AutoUpdate
284 [ # # ]: 0 : SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
285 [ # # ][ # # ]: 0 : if(pFmt && pFmt->IsAutoUpdateFmt())
[ # # ]
286 : : {
287 [ # # ]: 0 : pFmt->SetFmtAttr(*pSet);
288 : 0 : SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
289 : : RES_SURROUND, RES_SURROUND,
290 : : RES_ANCHOR, RES_ANCHOR,
291 : : RES_VERT_ORIENT,RES_HORI_ORIENT,
292 [ # # ]: 0 : 0);
293 [ # # ]: 0 : aShellSet.Put(*pSet);
294 [ # # ][ # # ]: 0 : aMgr.SetAttrSet(aShellSet);
295 : : }
296 : : else
297 : : {
298 [ # # ]: 0 : aMgr.SetAttrSet(*pSet);
299 : : }
300 [ # # ]: 0 : aMgr.UpdateFlyFrm();
301 : :
302 : 0 : sal_Bool bApplyUsrPref = sal_False;
303 [ # # ]: 0 : if (SFX_ITEM_SET == pSet->GetItemState(
304 [ # # ]: 0 : FN_KEEP_ASPECT_RATIO, sal_True, &pItem ))
305 : : {
306 : : aUsrPref.SetKeepRatio(
307 : 0 : ((const SfxBoolItem*)pItem)->GetValue() );
308 : 0 : bApplyUsrPref = sal_True;
309 : : }
310 [ # # ]: 0 : if( SFX_ITEM_SET == pSet->GetItemState(
311 [ # # ]: 0 : SID_ATTR_GRAF_KEEP_ZOOM, sal_True, &pItem ))
312 : : {
313 : : aUsrPref.SetGrfKeepZoom(
314 : 0 : ((const SfxBoolItem*)pItem)->GetValue() );
315 : 0 : bApplyUsrPref = sal_True;
316 : : }
317 : :
318 [ # # ]: 0 : if( bApplyUsrPref )
319 [ # # ][ # # ]: 0 : SW_MOD()->ApplyUsrPref(aUsrPref, &GetView());
320 : :
321 : : // and now set all the graphic attributes and other stuff
322 [ # # ]: 0 : if( SFX_ITEM_SET == pSet->GetItemState(
323 [ # # ]: 0 : SID_ATTR_GRAF_GRAPHIC, sal_True, &pItem ))
324 : : {
325 [ # # ]: 0 : if( ((SvxBrushItem*)pItem)->GetGraphicLink() )
326 [ # # ]: 0 : sGrfNm = *((SvxBrushItem*)pItem)->GetGraphicLink();
327 : : else
328 [ # # ]: 0 : sGrfNm.Erase();
329 : :
330 [ # # ]: 0 : if( ((SvxBrushItem*)pItem)->GetGraphicFilter() )
331 [ # # ]: 0 : sFilterNm = *((SvxBrushItem*)pItem)->GetGraphicFilter();
332 : : else
333 [ # # ]: 0 : sFilterNm.Erase();
334 : :
335 [ # # ]: 0 : if( sGrfNm.Len() )
336 : : {
337 [ # # ]: 0 : SwDocShell* pDocSh = GetView().GetDocShell();
338 [ # # ]: 0 : SwWait aWait( *pDocSh, sal_True );
339 : 0 : SfxMedium* pMedium = pDocSh->GetMedium();
340 [ # # ]: 0 : INetURLObject aAbs;
341 [ # # ]: 0 : if( pMedium )
342 [ # # ][ # # ]: 0 : aAbs = pMedium->GetURLObject();
343 : : rSh.ReRead( URIHelper::SmartRel2Abs(
344 : : aAbs, sGrfNm,
345 : : URIHelper::GetMaybeFileHdl() ),
346 [ # # ][ # # ]: 0 : sFilterNm, 0 );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
347 : : }
348 : : }
349 [ # # ]: 0 : if ( SFX_ITEM_SET == pSet->GetItemState(
350 [ # # ]: 0 : FN_SET_FRM_ALT_NAME, sal_True, &pItem ))
351 : : {
352 : : // #i73249#
353 [ # # ]: 0 : rSh.SetObjTitle( ((const SfxStringItem*)pItem)->GetValue() );
354 : : }
355 : :
356 [ # # ]: 0 : SfxItemSet aGrfSet( rSh.GetAttrPool(), RES_GRFATR_BEGIN,
357 [ # # ]: 0 : RES_GRFATR_END-1 );
358 [ # # ]: 0 : aGrfSet.Put( *pSet );
359 [ # # ]: 0 : if( aGrfSet.Count() )
360 [ # # ]: 0 : rSh.SetAttr( aGrfSet );
361 : :
362 [ # # ]: 0 : rSh.EndUndo(UNDO_END);
363 [ # # ][ # # ]: 0 : rSh.EndAllAction();
364 : : }
365 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
366 : : }
367 : 0 : break;
368 : :
369 : : case FN_GRAPHIC_MIRROR_ON_EVEN_PAGES:
370 : : {
371 [ # # ][ # # ]: 0 : SfxItemSet aSet(rSh.GetAttrPool(), RES_GRFATR_MIRRORGRF, RES_GRFATR_MIRRORGRF);
372 [ # # ]: 0 : rSh.GetCurAttr( aSet );
373 [ # # ][ # # ]: 0 : SwMirrorGrf aGrf((const SwMirrorGrf &)aSet.Get(RES_GRFATR_MIRRORGRF));
374 : 0 : aGrf.SetGrfToggle(!aGrf.IsGrfToggle());
375 [ # # ][ # # ]: 0 : rSh.SetAttr(aGrf);
[ # # ]
376 : : }
377 : 0 : break;
378 : :
379 : : default:
380 : : OSL_ENSURE(!this, "wrong dispatcher");
381 : 0 : return;
382 : : }
383 : : }
384 : :
385 : :
386 : 0 : void SwGrfShell::ExecAttr( SfxRequest &rReq )
387 : : {
388 : : sal_uInt16 nGrfType;
389 [ # # # # ]: 0 : if( CNT_GRF == GetShell().GetCntType() &&
[ # # ][ # # ]
390 : 0 : ( GRAPHIC_BITMAP == ( nGrfType = GetShell().GetGraphicType()) ||
391 : : GRAPHIC_GDIMETAFILE == nGrfType ))
392 : : {
393 [ # # ][ # # ]: 0 : SfxItemSet aGrfSet( GetShell().GetAttrPool(), RES_GRFATR_BEGIN,
394 [ # # ]: 0 : RES_GRFATR_END -1 );
395 : 0 : const SfxItemSet *pArgs = rReq.GetArgs();
396 : : const SfxPoolItem* pItem;
397 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
398 [ # # ][ # # ]: 0 : if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, sal_False, &pItem ))
[ # # ][ # # ]
399 : 0 : pItem = 0;
400 : :
401 [ # # # # : 0 : switch( nSlot )
# # # # #
# # # # ]
402 : : {
403 : : case FN_FLIP_VERT_GRAFIC:
404 : : case FN_FLIP_HORZ_GRAFIC:
405 : : {
406 [ # # ][ # # ]: 0 : GetShell().GetCurAttr( aGrfSet );
407 : : SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get(
408 [ # # ][ # # ]: 0 : RES_GRFATR_MIRRORGRF ) );
409 : 0 : sal_uInt16 nMirror = aMirror.GetValue();
410 [ # # ]: 0 : if( FN_FLIP_VERT_GRAFIC == nSlot )
411 [ # # # # : 0 : switch( nMirror )
# ]
412 : : {
413 : 0 : case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_VERT;
414 : 0 : break;
415 : 0 : case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_BOTH;
416 : 0 : break;
417 : 0 : case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_DONT;
418 : 0 : break;
419 : 0 : case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_HOR;
420 : 0 : break;
421 : : }
422 : : else
423 [ # # # # : 0 : switch( nMirror )
# ]
424 : : {
425 : 0 : case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_HOR;
426 : 0 : break;
427 : 0 : case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_BOTH;
428 : 0 : break;
429 : 0 : case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_DONT;
430 : 0 : break;
431 : 0 : case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_VERT;
432 : 0 : break;
433 : : }
434 : 0 : aMirror.SetValue( nMirror );
435 [ # # ]: 0 : aGrfSet.ClearItem();
436 [ # # ][ # # ]: 0 : aGrfSet.Put( aMirror );
437 : : }
438 : 0 : break;
439 : :
440 : : case SID_ATTR_GRAF_LUMINANCE:
441 [ # # ]: 0 : if( pItem )
442 : : aGrfSet.Put( SwLuminanceGrf(
443 [ # # ][ # # ]: 0 : ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
444 : 0 : break;
445 : : case SID_ATTR_GRAF_CONTRAST:
446 [ # # ]: 0 : if( pItem )
447 : : aGrfSet.Put( SwContrastGrf(
448 [ # # ][ # # ]: 0 : ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
449 : 0 : break;
450 : : case SID_ATTR_GRAF_RED:
451 [ # # ]: 0 : if( pItem )
452 : : aGrfSet.Put( SwChannelRGrf(
453 [ # # ][ # # ]: 0 : ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
454 : 0 : break;
455 : : case SID_ATTR_GRAF_GREEN:
456 [ # # ]: 0 : if( pItem )
457 : : aGrfSet.Put( SwChannelGGrf(
458 [ # # ][ # # ]: 0 : ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
459 : 0 : break;
460 : : case SID_ATTR_GRAF_BLUE:
461 [ # # ]: 0 : if( pItem )
462 : : aGrfSet.Put( SwChannelBGrf(
463 [ # # ][ # # ]: 0 : ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
464 : 0 : break;
465 : : case SID_ATTR_GRAF_GAMMA:
466 [ # # ]: 0 : if( pItem )
467 : : {
468 : 0 : double fVal = ((SfxUInt32Item*)pItem)->GetValue();
469 [ # # ][ # # ]: 0 : aGrfSet.Put( SwGammaGrf(fVal/100. ));
[ # # ]
470 : : }
471 : 0 : break;
472 : : case SID_ATTR_GRAF_TRANSPARENCE:
473 [ # # ]: 0 : if( pItem )
474 : : aGrfSet.Put( SwTransparencyGrf(
475 [ # # ][ # # ]: 0 : static_cast< sal_Int8 >( ( (SfxUInt16Item*)pItem )->GetValue() ) ) );
[ # # ]
476 : 0 : break;
477 : : case SID_ATTR_GRAF_INVERT:
478 [ # # ]: 0 : if( pItem )
479 : : aGrfSet.Put( SwInvertGrf(
480 [ # # ][ # # ]: 0 : ((SfxBoolItem*)pItem)->GetValue() ));
[ # # ]
481 : 0 : break;
482 : :
483 : : case SID_ATTR_GRAF_MODE:
484 [ # # ]: 0 : if( pItem )
485 : : aGrfSet.Put( SwDrawModeGrf(
486 [ # # ][ # # ]: 0 : ((SfxUInt16Item*)pItem)->GetValue() ));
[ # # ]
487 : 0 : break;
488 : :
489 : : case SID_COLOR_SETTINGS:
490 : : {
491 [ # # ][ # # ]: 0 : svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
492 [ # # ]: 0 : aToolboxAccess.toggleToolbox();
493 [ # # ]: 0 : break;
494 : : }
495 : : case SID_GRFFILTER:
496 : : case SID_GRFFILTER_INVERT:
497 : : case SID_GRFFILTER_SMOOTH:
498 : : case SID_GRFFILTER_SHARPEN:
499 : : case SID_GRFFILTER_REMOVENOISE:
500 : : case SID_GRFFILTER_SOBEL:
501 : : case SID_GRFFILTER_MOSAIC:
502 : : case SID_GRFFILTER_EMBOSS:
503 : : case SID_GRFFILTER_POSTER:
504 : : case SID_GRFFILTER_POPART:
505 : : case SID_GRFFILTER_SEPIA:
506 : : case SID_GRFFILTER_SOLARIZE:
507 [ # # ]: 0 : if( GRAPHIC_BITMAP == nGrfType )
508 : : {
509 : : // #119353# - robust
510 [ # # ][ # # ]: 0 : const GraphicObject* pFilterObj( GetShell().GetGraphicObj() );
511 [ # # ]: 0 : if ( pFilterObj )
512 : : {
513 [ # # ]: 0 : GraphicObject aFilterObj( *pFilterObj );
514 [ # # ]: 0 : if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
515 [ # # ]: 0 : SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ))
516 [ # # ]: 0 : GetShell().ReRead( aEmptyStr, aEmptyStr,
517 [ # # ][ # # ]: 0 : &aFilterObj.GetGraphic() );
[ # # ]
518 : : }
519 : : }
520 : 0 : break;
521 : :
522 : : default:
523 : : OSL_ENSURE(!this, "wrong dispatcher");
524 : : }
525 [ # # ]: 0 : if( aGrfSet.Count() )
526 [ # # ][ # # ]: 0 : GetShell().SetAttr( aGrfSet );
[ # # ]
527 : : }
528 : 0 : GetView().GetViewFrame()->GetBindings().Invalidate(rReq.GetSlot());
529 : 0 : }
530 : :
531 : 0 : void SwGrfShell::GetAttrState(SfxItemSet &rSet)
532 : : {
533 [ # # ]: 0 : SwWrtShell &rSh = GetShell();
534 [ # # ]: 0 : SfxItemSet aCoreSet( GetPool(), aNoTxtNodeSetRange );
535 [ # # ]: 0 : rSh.GetCurAttr( aCoreSet );
536 [ # # ]: 0 : sal_Bool bParentCntProt = 0 != rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
537 [ # # ][ # # ]: 0 : sal_Bool bIsGrfCntnt = CNT_GRF == GetShell().GetCntType();
538 : : // const GraphicObject* pGrfObj = ( bIsGrfCntnt ? rSh.GetGraphicObj() : NULL );
539 : : // sal_Bool bIsRenderGraphicGrfCntnt = ( pGrfObj && pGrfObj->IsRenderGraphic() );
540 : :
541 : :
542 : 0 : SetGetStateSet( &rSet );
543 : :
544 [ # # ]: 0 : SfxWhichIter aIter( rSet );
545 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
546 [ # # ]: 0 : while( nWhich )
547 : : {
548 : 0 : sal_Bool bDisable = bParentCntProt;
549 [ # # # # : 0 : switch( nWhich )
# # # # #
# # # # #
# # ]
550 : : {
551 : : case SID_INSERT_GRAPHIC:
552 : : case FN_FORMAT_GRAFIC_DLG:
553 : : case SID_TWAIN_TRANSFER:
554 [ # # ][ # # ]: 0 : if( bParentCntProt || !bIsGrfCntnt )
555 : 0 : bDisable = sal_True;
556 : 0 : break;
557 : : case SID_SAVE_GRAPHIC:
558 : : case SID_EXTERNAL_EDIT:
559 [ # # ][ # # ]: 0 : if( rSh.GetGraphicType() == GRAPHIC_NONE )
560 : 0 : bDisable = sal_True;
561 : 0 : break;
562 : : case SID_COLOR_SETTINGS:
563 : : {
564 [ # # ][ # # ]: 0 : if ( bParentCntProt || !bIsGrfCntnt )
565 : 0 : bDisable = sal_True;
566 : : else
567 : : {
568 [ # # ][ # # ]: 0 : svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
569 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) );
[ # # ][ # # ]
[ # # ]
570 : : }
571 : 0 : break;
572 : : }
573 : :
574 : : case FN_FLIP_VERT_GRAFIC:
575 [ # # ]: 0 : if( !bParentCntProt )
576 : : {
577 : : MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
578 [ # # ]: 0 : RES_GRFATR_MIRRORGRF )).GetValue());
579 : :
580 : : rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_VERT ||
581 [ # # ][ # # ]: 0 : nState == RES_MIRROR_GRAPH_BOTH));
[ # # ][ # # ]
[ # # ]
582 : : }
583 : 0 : break;
584 : :
585 : : case FN_FLIP_HORZ_GRAFIC:
586 [ # # ]: 0 : if( !bParentCntProt )
587 : : {
588 : : MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
589 [ # # ]: 0 : RES_GRFATR_MIRRORGRF )).GetValue());
590 : :
591 : : rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_HOR ||
592 [ # # ][ # # ]: 0 : nState == RES_MIRROR_GRAPH_BOTH));
[ # # ][ # # ]
[ # # ]
593 : : }
594 : 0 : break;
595 : :
596 : :
597 : : case SID_ATTR_GRAF_LUMINANCE:
598 [ # # ]: 0 : if( !bParentCntProt )
599 : : rSet.Put( SfxInt16Item( nWhich, ((SwLuminanceGrf&)
600 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_LUMINANCE)).GetValue() ));
[ # # ][ # # ]
601 : 0 : break;
602 : : case SID_ATTR_GRAF_CONTRAST:
603 [ # # ]: 0 : if( !bParentCntProt )
604 : : rSet.Put( SfxInt16Item( nWhich, ((SwContrastGrf&)
605 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_CONTRAST)).GetValue() ));
[ # # ][ # # ]
606 : 0 : break;
607 : : case SID_ATTR_GRAF_RED:
608 [ # # ]: 0 : if( !bParentCntProt )
609 : : rSet.Put( SfxInt16Item( nWhich, ((SwChannelRGrf&)
610 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_CHANNELR)).GetValue() ));
[ # # ][ # # ]
611 : 0 : break;
612 : : case SID_ATTR_GRAF_GREEN:
613 [ # # ]: 0 : if( !bParentCntProt )
614 : : rSet.Put( SfxInt16Item( nWhich, ((SwChannelGGrf&)
615 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_CHANNELG)).GetValue() ));
[ # # ][ # # ]
616 : 0 : break;
617 : : case SID_ATTR_GRAF_BLUE:
618 [ # # ]: 0 : if( !bParentCntProt )
619 : : rSet.Put( SfxInt16Item( nWhich, ((SwChannelBGrf&)
620 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_CHANNELB)).GetValue() ));
[ # # ][ # # ]
621 : 0 : break;
622 : :
623 : : case SID_ATTR_GRAF_GAMMA:
624 [ # # ]: 0 : if( !bParentCntProt )
625 : : rSet.Put( SfxUInt32Item( nWhich, static_cast< sal_uInt32 >(
626 [ # # ][ # # ]: 0 : ( (SwGammaGrf&)aCoreSet.Get( RES_GRFATR_GAMMA ) ).GetValue() * 100 ) ) );
[ # # ][ # # ]
627 : 0 : break;
628 : : case SID_ATTR_GRAF_TRANSPARENCE:
629 [ # # ]: 0 : if( !bParentCntProt )
630 : : {
631 : : // #119353# - robust
632 [ # # ]: 0 : const GraphicObject* pGrafObj = rSh.GetGraphicObj();
633 [ # # ]: 0 : if ( pGrafObj )
634 : : {
635 [ # # # # ]: 0 : if( pGrafObj->IsAnimated() ||
[ # # ]
636 : 0 : GRAPHIC_GDIMETAFILE == pGrafObj->GetType() )
637 : 0 : bDisable = sal_True;
638 : : else
639 : : rSet.Put( SfxUInt16Item( nWhich, ((SwTransparencyGrf&)
640 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_TRANSPARENCY)).GetValue() ));
[ # # ][ # # ]
641 : : }
642 : : }
643 : 0 : break;
644 : : case SID_ATTR_GRAF_INVERT:
645 [ # # ]: 0 : if( !bParentCntProt )
646 : : rSet.Put( SfxBoolItem( nWhich, ((SwInvertGrf&)
647 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_INVERT)).GetValue() ));
[ # # ][ # # ]
648 : 0 : break;
649 : :
650 : : case SID_ATTR_GRAF_MODE:
651 [ # # ]: 0 : if( !bParentCntProt )
652 : : rSet.Put( SfxUInt16Item( nWhich, ((SwDrawModeGrf&)
653 [ # # ][ # # ]: 0 : aCoreSet.Get(RES_GRFATR_DRAWMODE)).GetValue() ));
[ # # ][ # # ]
654 : 0 : break;
655 : :
656 : : case SID_GRFFILTER:
657 : : case SID_GRFFILTER_INVERT:
658 : : case SID_GRFFILTER_SMOOTH:
659 : : case SID_GRFFILTER_SHARPEN:
660 : : case SID_GRFFILTER_REMOVENOISE:
661 : : case SID_GRFFILTER_SOBEL:
662 : : case SID_GRFFILTER_MOSAIC:
663 : : case SID_GRFFILTER_EMBOSS:
664 : : case SID_GRFFILTER_POSTER:
665 : : case SID_GRFFILTER_POPART:
666 : : case SID_GRFFILTER_SEPIA:
667 : : case SID_GRFFILTER_SOLARIZE:
668 : : {
669 [ # # ][ # # ]: 0 : if( bParentCntProt || !bIsGrfCntnt )
670 : 0 : bDisable = sal_True;
671 : : // #i59688# load graphic only if type is unknown
672 : : else
673 : : {
674 [ # # ]: 0 : const sal_uInt16 eGraphicType( rSh.GetGraphicType() );
675 [ # # ][ # # ]: 0 : if ( ( eGraphicType == GRAPHIC_NONE ||
[ # # ][ # # ]
676 : : eGraphicType == GRAPHIC_DEFAULT ) &&
677 [ # # ]: 0 : rSh.IsGrfSwapOut( sal_True ) )
678 : : {
679 [ # # ]: 0 : rSet.DisableItem( nWhich );
680 [ # # ][ # # ]: 0 : if( AddGrfUpdateSlot( nWhich ))
681 [ # # ]: 0 : rSh.GetGraphic(sal_False); // start the loading
682 : : }
683 : : else
684 : : {
685 : 0 : bDisable = eGraphicType != GRAPHIC_BITMAP;
686 : : }
687 : : }
688 : : }
689 : 0 : break;
690 : :
691 : : default:
692 : 0 : bDisable = sal_False;
693 : : }
694 : :
695 [ # # ]: 0 : if( bDisable )
696 [ # # ]: 0 : rSet.DisableItem( nWhich );
697 [ # # ]: 0 : nWhich = aIter.NextWhich();
698 : : }
699 [ # # ][ # # ]: 0 : SetGetStateSet( 0 );
700 : 0 : }
701 : :
702 : :
703 : 0 : SwGrfShell::SwGrfShell(SwView &_rView) :
704 : 0 : SwBaseShell(_rView)
705 : :
706 : : {
707 [ # # ][ # # ]: 0 : SetName(rtl::OUString("Graphic"));
[ # # ]
708 [ # # ]: 0 : SetHelpId(SW_GRFSHELL);
709 : 0 : }
710 : :
711 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|