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