update dev300-m58
[ooovba.git] / sw / source / ui / shells / grfsh.cxx
blobe0e5ec9178cb2e9bcd3e8f4a739933d93f42e3b7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: grfsh.cxx,v $
10 * $Revision: 1.33 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
37 #ifndef _CMDID_H
38 #include <cmdid.h>
39 #endif
40 #include <hintids.hxx>
41 #include <tools/urlobj.hxx>
42 #include <vcl/msgbox.hxx>
43 #include <svtools/stritem.hxx>
44 #include <svtools/whiter.hxx>
45 #include <svtools/urihelper.hxx>
46 #include <sfx2/docfile.hxx>
47 #include <sfx2/dispatch.hxx>
49 #include <sfx2/objface.hxx>
50 #include <svx/sizeitem.hxx>
51 #include <svx/protitem.hxx>
52 #include <sfx2/request.hxx>
53 #include <svx/srchitem.hxx>
54 #include <svx/htmlmode.hxx>
55 #include <svx/sdgluitm.hxx>
56 #include <svx/sdgcoitm.hxx>
57 #include <svx/sdggaitm.hxx>
58 #include <svx/sdgtritm.hxx>
59 #include <svx/sdginitm.hxx>
60 #include <svx/sdgmoitm.hxx>
61 #include <svx/brshitem.hxx>
62 #include <svx/grfflt.hxx>
63 #include <svx/tbxcolor.hxx>
64 #include <fmturl.hxx>
65 #include <view.hxx>
66 #include <wrtsh.hxx>
67 #include <viewopt.hxx>
68 #include <swmodule.hxx>
69 #include <frmatr.hxx>
70 #include <swundo.hxx>
71 #include <uitool.hxx>
72 #include <docsh.hxx>
73 #include <grfsh.hxx>
74 #include <frmmgr.hxx>
75 #include <frmdlg.hxx>
76 #include <frmfmt.hxx>
77 #include <grfatr.hxx>
78 #include <usrpref.hxx>
79 #include <edtwin.hxx>
80 #include <swwait.hxx>
81 #include <shells.hrc>
82 #include <popup.hrc>
84 #define SwGrfShell
85 #include <sfx2/msg.hxx>
86 #include "swslots.hxx"
88 #include "swabstdlg.hxx"
90 #define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) )
92 SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC))
94 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU));
95 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_GRAFIK_TOOLBOX));
98 void SwGrfShell::Execute(SfxRequest &rReq)
100 SwWrtShell &rSh = GetShell();
102 USHORT nSlot = rReq.GetSlot();
103 switch(nSlot)
105 case SID_TWAIN_TRANSFER:
107 GetView().ExecuteScan( rReq );
108 break;
110 case FN_SAVE_GRAPHIC:
112 const Graphic *pGraphic;
113 if(0 != (pGraphic = rSh.GetGraphic()))
115 String sGrfNm, sFilterNm;
116 rSh.GetGrfNms( &sGrfNm, &sFilterNm );
117 ExportGraphic( *pGraphic, sGrfNm );
120 break;
121 case SID_INSERT_GRAPHIC:
122 case FN_FORMAT_GRAFIC_DLG:
124 SwFlyFrmAttrMgr aMgr( FALSE, &rSh, rSh.IsFrmSelected() ?
125 FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF);
126 const SwViewOption* pVOpt = rSh.GetViewOptions();
127 SwViewOption aUsrPref( *pVOpt );
129 SfxItemSet aSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1,
130 RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF,
131 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
132 SID_ATTR_GRAF_KEEP_ZOOM, SID_ATTR_GRAF_KEEP_ZOOM,
133 SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE,
134 SID_ATTR_GRAF_FRMSIZE_PERCENT, SID_ATTR_GRAF_FRMSIZE_PERCENT,
135 SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC,
136 FN_PARAM_GRF_CONNECT, FN_PARAM_GRF_CONNECT,
137 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
138 FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
139 FN_SET_FRM_NAME, FN_KEEP_ASPECT_RATIO,
140 FN_PARAM_GRF_DIALOG, FN_PARAM_GRF_DIALOG,
141 SID_DOCFRAME, SID_DOCFRAME,
142 SID_HTML_MODE, SID_HTML_MODE,
143 FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
146 USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
147 aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
148 FieldUnit eMetric = ::GetDfltMetric((0 != (nHtmlMode&HTMLMODE_ON)));
149 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) );
151 const SwRect* pRect = &rSh.GetAnyCurRect(RECT_PAGE);
152 SwFmtFrmSize aFrmSize( ATT_VAR_SIZE, pRect->Width(), pRect->Height());
153 aFrmSize.SetWhich( GetPool().GetWhich( SID_ATTR_PAGE_SIZE ) );
154 aSet.Put( aFrmSize );
156 aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName()));
157 if ( nSlot == FN_FORMAT_GRAFIC_DLG )
159 // --> OD 2009-07-13 #i73249#
160 // aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText()));
161 aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) );
162 // <--
165 pRect = &rSh.GetAnyCurRect(RECT_PAGE_PRT);
166 aFrmSize.SetWidth( pRect->Width() );
167 aFrmSize.SetHeight( pRect->Height() );
168 aFrmSize.SetWhich( GetPool().GetWhich(FN_GET_PRINT_AREA) );
169 aSet.Put( aFrmSize );
171 aSet.Put( aMgr.GetAttrSet() );
172 aSet.SetParent( aMgr.GetAttrSet().GetParent() );
174 // Bei %-Werten Groesse initialisieren
175 SwFmtFrmSize aSizeCopy = (const SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE);
176 if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != 0xff)
177 aSizeCopy.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
178 if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != 0xff)
179 aSizeCopy.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
181 // and now set the size for "external" tabpages
183 SvxSizeItem aSzItm( SID_ATTR_GRAF_FRMSIZE, aSizeCopy.GetSize() );
184 aSet.Put( aSzItm );
186 Size aSz( aSizeCopy.GetWidthPercent(), aSizeCopy.GetHeightPercent() );
187 if( 0xff == aSz.Width() ) aSz.Width() = 0;
188 if( 0xff == aSz.Height() ) aSz.Height() = 0;
190 aSzItm.SetSize( aSz );
191 aSzItm.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT );
192 aSet.Put( aSzItm );
195 String sGrfNm, sFilterNm;
196 rSh.GetGrfNms( &sGrfNm, &sFilterNm );
197 if( sGrfNm.Len() )
199 aSet.Put( SvxBrushItem( INetURLObject::decode( sGrfNm,
200 INET_HEX_ESCAPE,
201 INetURLObject::DECODE_UNAMBIGUOUS,
202 RTL_TEXTENCODING_UTF8 ),
203 sFilterNm, GPOS_LT,
204 SID_ATTR_GRAF_GRAPHIC ));
206 else
208 // --> OD 2005-02-09 #119353# - robust
209 const GraphicObject* pGrfObj = rSh.GetGraphicObj();
210 if ( pGrfObj )
212 aSet.Put( SvxBrushItem( *pGrfObj, GPOS_LT,
213 SID_ATTR_GRAF_GRAPHIC ) );
215 // <--
217 aSet.Put( SfxBoolItem( FN_PARAM_GRF_CONNECT, sGrfNm.Len() > 0 ) );
219 // get Mirror and Crop
221 SfxItemSet aTmpSet( rSh.GetAttrPool(),
222 RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF );
224 rSh.GetCurAttr( aTmpSet );
225 aSet.Put( aTmpSet );
228 aSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, aUsrPref.IsKeepRatio()));
229 aSet.Put(SfxBoolItem( SID_ATTR_GRAF_KEEP_ZOOM, aUsrPref.IsGrfKeepZoom()));
231 aSet.Put(SfxFrameItem( SID_DOCFRAME, GetView().GetViewFrame()->GetTopFrame()));
233 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
234 DBG_ASSERT(pFact, "Dialogdiet fail!");
235 SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_GRF,
236 GetView().GetViewFrame(),
237 GetView().GetWindow(),
238 aSet, FALSE, DLG_FRM_GRF);
239 DBG_ASSERT(pDlg, "Dialogdiet fail!");
240 if( pDlg->Execute() )
242 rSh.StartAllAction();
243 rSh.StartUndo(UNDO_START);
244 const SfxPoolItem* pItem;
245 SfxItemSet* pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
246 rReq.Done(*pSet);
247 // change the 2 frmsize SizeItems to the correct SwFrmSizeItem
248 if( SFX_ITEM_SET == pSet->GetItemState(
249 SID_ATTR_GRAF_FRMSIZE, FALSE, &pItem ))
251 SwFmtFrmSize aSize;
252 const Size& rSz = ((SvxSizeItem*)pItem)->GetSize();
253 aSize.SetWidth( rSz.Width() );
254 aSize.SetHeight( rSz.Height() );
256 if( SFX_ITEM_SET == pSet->GetItemState(
257 SID_ATTR_GRAF_FRMSIZE_PERCENT, FALSE, &pItem ))
259 const Size& rRelativeSize = ((SvxSizeItem*)pItem)->GetSize();
260 aSize.SetWidthPercent( static_cast< BYTE >( rRelativeSize.Width() ) );
261 aSize.SetHeightPercent( static_cast< BYTE >( rRelativeSize.Height() ) );
263 pSet->Put( aSize );
266 // Vorlagen-AutoUpdate
267 SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
268 if(pFmt && pFmt->IsAutoUpdateFmt())
270 pFmt->SetFmtAttr(*pSet);
271 SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
272 RES_SURROUND, RES_SURROUND,
273 RES_ANCHOR, RES_ANCHOR,
274 RES_VERT_ORIENT,RES_HORI_ORIENT,
276 aShellSet.Put(*pSet);
277 aMgr.SetAttrSet(aShellSet);
279 else
281 aMgr.SetAttrSet(*pSet);
283 aMgr.UpdateFlyFrm();
285 BOOL bApplyUsrPref = FALSE;
286 if (SFX_ITEM_SET == pSet->GetItemState(
287 FN_KEEP_ASPECT_RATIO, TRUE, &pItem ))
289 aUsrPref.SetKeepRatio(
290 ((const SfxBoolItem*)pItem)->GetValue() );
291 bApplyUsrPref = TRUE;
293 if( SFX_ITEM_SET == pSet->GetItemState(
294 SID_ATTR_GRAF_KEEP_ZOOM, TRUE, &pItem ))
296 aUsrPref.SetGrfKeepZoom(
297 ((const SfxBoolItem*)pItem)->GetValue() );
298 bApplyUsrPref = TRUE;
301 if( bApplyUsrPref )
302 SW_MOD()->ApplyUsrPref(aUsrPref, &GetView());
304 // and now set all the graphic attributes and other stuff
305 if( SFX_ITEM_SET == pSet->GetItemState(
306 SID_ATTR_GRAF_GRAPHIC, TRUE, &pItem ))
308 if( ((SvxBrushItem*)pItem)->GetGraphicLink() )
309 sGrfNm = *((SvxBrushItem*)pItem)->GetGraphicLink();
310 else
311 sGrfNm.Erase();
313 if( ((SvxBrushItem*)pItem)->GetGraphicFilter() )
314 sFilterNm = *((SvxBrushItem*)pItem)->GetGraphicFilter();
315 else
316 sFilterNm.Erase();
318 if( sGrfNm.Len() )
320 SwDocShell* pDocSh = GetView().GetDocShell();
321 SwWait aWait( *pDocSh, TRUE );
322 SfxMedium* pMedium = pDocSh->GetMedium();
323 INetURLObject aAbs;
324 if( pMedium )
325 aAbs = pMedium->GetURLObject();
326 rSh.ReRead( URIHelper::SmartRel2Abs(
327 aAbs, sGrfNm,
328 URIHelper::GetMaybeFileHdl() ),
329 sFilterNm, 0 );
332 if ( SFX_ITEM_SET == pSet->GetItemState(
333 FN_SET_FRM_ALT_NAME, TRUE, &pItem ))
335 // --> OD 2009-07-13 #i73249#
336 // rSh.SetAlternateText(
337 // ((const SfxStringItem*)pItem)->GetValue() );
338 rSh.SetObjTitle( ((const SfxStringItem*)pItem)->GetValue() );
339 // <--
342 SfxItemSet aGrfSet( rSh.GetAttrPool(), RES_GRFATR_BEGIN,
343 RES_GRFATR_END-1 );
344 aGrfSet.Put( *pSet );
345 if( aGrfSet.Count() )
346 rSh.SetAttr( aGrfSet );
348 rSh.EndUndo(UNDO_END);
349 rSh.EndAllAction();
351 delete pDlg;
353 break;
355 case FN_GRAPHIC_MIRROR_ON_EVEN_PAGES:
357 SfxItemSet aSet(rSh.GetAttrPool(), RES_GRFATR_MIRRORGRF, RES_GRFATR_MIRRORGRF);
358 rSh.GetCurAttr( aSet );
359 SwMirrorGrf aGrf((const SwMirrorGrf &)aSet.Get(RES_GRFATR_MIRRORGRF));
360 aGrf.SetGrfToggle(!aGrf.IsGrfToggle());
361 rSh.SetAttr(aGrf);
363 break;
365 default:
366 ASSERT(!this, falscher Dispatcher);
367 return;
372 void SwGrfShell::ExecAttr( SfxRequest &rReq )
374 USHORT nGrfType;
375 if( CNT_GRF == GetShell().GetCntType() &&
376 ( GRAPHIC_BITMAP == ( nGrfType = GetShell().GetGraphicType()) ||
377 GRAPHIC_GDIMETAFILE == nGrfType ))
379 SfxItemSet aGrfSet( GetShell().GetAttrPool(), RES_GRFATR_BEGIN,
380 RES_GRFATR_END -1 );
381 const SfxItemSet *pArgs = rReq.GetArgs();
382 const SfxPoolItem* pItem;
383 USHORT nSlot = rReq.GetSlot();
384 if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, FALSE, &pItem ))
385 pItem = 0;
387 switch( nSlot )
389 case FN_FLIP_VERT_GRAFIC:
390 case FN_FLIP_HORZ_GRAFIC:
392 GetShell().GetCurAttr( aGrfSet );
393 SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get(
394 RES_GRFATR_MIRRORGRF ) );
395 USHORT nMirror = aMirror.GetValue();
396 if( FN_FLIP_VERT_GRAFIC == nSlot )
397 switch( nMirror )
399 case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_VERT;
400 break;
401 case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_BOTH;
402 break;
403 case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_DONT;
404 break;
405 case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_HOR;
406 break;
408 else
409 switch( nMirror )
411 case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_HOR;
412 break;
413 case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_BOTH;
414 break;
415 case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_DONT;
416 break;
417 case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_VERT;
418 break;
420 aMirror.SetValue( nMirror );
421 aGrfSet.ClearItem();
422 aGrfSet.Put( aMirror );
424 break;
426 case SID_ATTR_GRAF_LUMINANCE:
427 if( pItem )
428 aGrfSet.Put( SwLuminanceGrf(
429 ((SfxInt16Item*)pItem)->GetValue() ));
430 break;
431 case SID_ATTR_GRAF_CONTRAST:
432 if( pItem )
433 aGrfSet.Put( SwContrastGrf(
434 ((SfxInt16Item*)pItem)->GetValue() ));
435 break;
436 case SID_ATTR_GRAF_RED:
437 if( pItem )
438 aGrfSet.Put( SwChannelRGrf(
439 ((SfxInt16Item*)pItem)->GetValue() ));
440 break;
441 case SID_ATTR_GRAF_GREEN:
442 if( pItem )
443 aGrfSet.Put( SwChannelGGrf(
444 ((SfxInt16Item*)pItem)->GetValue() ));
445 break;
446 case SID_ATTR_GRAF_BLUE:
447 if( pItem )
448 aGrfSet.Put( SwChannelBGrf(
449 ((SfxInt16Item*)pItem)->GetValue() ));
450 break;
451 case SID_ATTR_GRAF_GAMMA:
452 if( pItem )
454 double fVal = ((SfxUInt32Item*)pItem)->GetValue();
455 aGrfSet.Put( SwGammaGrf(fVal/100. ));
457 break;
458 case SID_ATTR_GRAF_TRANSPARENCE:
459 if( pItem )
460 aGrfSet.Put( SwTransparencyGrf(
461 static_cast< sal_Int8 >( ( (SfxUInt16Item*)pItem )->GetValue() ) ) );
462 break;
463 case SID_ATTR_GRAF_INVERT:
464 if( pItem )
465 aGrfSet.Put( SwInvertGrf(
466 ((SfxBoolItem*)pItem)->GetValue() ));
467 break;
469 case SID_ATTR_GRAF_MODE:
470 if( pItem )
471 aGrfSet.Put( SwDrawModeGrf(
472 ((SfxUInt16Item*)pItem)->GetValue() ));
473 break;
475 case SID_COLOR_SETTINGS:
477 svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
478 aToolboxAccess.toggleToolbox();
479 break;
481 case SID_GRFFILTER:
482 case SID_GRFFILTER_INVERT:
483 case SID_GRFFILTER_SMOOTH:
484 case SID_GRFFILTER_SHARPEN:
485 case SID_GRFFILTER_REMOVENOISE:
486 case SID_GRFFILTER_SOBEL:
487 case SID_GRFFILTER_MOSAIC:
488 case SID_GRFFILTER_EMBOSS:
489 case SID_GRFFILTER_POSTER:
490 case SID_GRFFILTER_POPART:
491 case SID_GRFFILTER_SEPIA:
492 case SID_GRFFILTER_SOLARIZE:
493 if( GRAPHIC_BITMAP == nGrfType )
495 // --> OD 2005-02-09 #119353# - robust
496 const GraphicObject* pFilterObj( GetShell().GetGraphicObj() );
497 if ( pFilterObj )
499 GraphicObject aFilterObj( *pFilterObj );
500 if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
501 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ))
502 GetShell().ReRead( aEmptyStr, aEmptyStr,
503 &aFilterObj.GetGraphic() );
505 // <--
507 break;
509 default:
510 ASSERT(!this, falscher Dispatcher);
512 if( aGrfSet.Count() )
513 GetShell().SetAttr( aGrfSet );
515 GetView().GetViewFrame()->GetBindings().Invalidate(rReq.GetSlot());
518 void SwGrfShell::GetAttrState(SfxItemSet &rSet)
520 SwWrtShell &rSh = GetShell();
521 SfxItemSet aCoreSet( GetPool(), aNoTxtNodeSetRange );
522 rSh.GetCurAttr( aCoreSet );
523 BOOL bParentCntProt = 0 != rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
524 BOOL bIsGrfCntnt = CNT_GRF == GetShell().GetCntType();
525 // --> OD 2006-11-03 #i59688#
526 // BOOL bSwappedOut = rSh.IsGrfSwapOut( TRUE );
527 // BOOL bBitmapType = !bSwappedOut && GRAPHIC_BITMAP == rSh.GetGraphicType();
528 // <--
530 SetGetStateSet( &rSet );
532 SfxWhichIter aIter( rSet );
533 USHORT nWhich = aIter.FirstWhich();
534 while( nWhich )
536 BOOL bDisable = bParentCntProt;
537 switch( nWhich )
539 case SID_INSERT_GRAPHIC:
540 case FN_FORMAT_GRAFIC_DLG:
541 case SID_TWAIN_TRANSFER:
542 if( bParentCntProt || !bIsGrfCntnt )
543 bDisable = TRUE;
544 break;
545 case FN_SAVE_GRAPHIC:
546 if( rSh.GetGraphicType() == GRAPHIC_NONE )
547 bDisable = sal_True;
548 break;
549 case SID_COLOR_SETTINGS:
551 if ( bParentCntProt || !bIsGrfCntnt )
552 bDisable = TRUE;
553 else
555 svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
556 rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) );
558 break;
561 case FN_FLIP_VERT_GRAFIC:
562 if( !bParentCntProt )
564 MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
565 RES_GRFATR_MIRRORGRF )).GetValue());
567 rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_VERT ||
568 nState == RES_MIRROR_GRAPH_BOTH));
570 break;
572 case FN_FLIP_HORZ_GRAFIC:
573 if( !bParentCntProt )
575 MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
576 RES_GRFATR_MIRRORGRF )).GetValue());
578 rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_HOR ||
579 nState == RES_MIRROR_GRAPH_BOTH));
581 break;
584 case SID_ATTR_GRAF_LUMINANCE:
585 if( !bParentCntProt )
586 rSet.Put( SfxInt16Item( nWhich, ((SwLuminanceGrf&)
587 aCoreSet.Get(RES_GRFATR_LUMINANCE)).GetValue() ));
588 break;
589 case SID_ATTR_GRAF_CONTRAST:
590 if( !bParentCntProt )
591 rSet.Put( SfxInt16Item( nWhich, ((SwContrastGrf&)
592 aCoreSet.Get(RES_GRFATR_CONTRAST)).GetValue() ));
593 break;
594 case SID_ATTR_GRAF_RED:
595 if( !bParentCntProt )
596 rSet.Put( SfxInt16Item( nWhich, ((SwChannelRGrf&)
597 aCoreSet.Get(RES_GRFATR_CHANNELR)).GetValue() ));
598 break;
599 case SID_ATTR_GRAF_GREEN:
600 if( !bParentCntProt )
601 rSet.Put( SfxInt16Item( nWhich, ((SwChannelGGrf&)
602 aCoreSet.Get(RES_GRFATR_CHANNELG)).GetValue() ));
603 break;
604 case SID_ATTR_GRAF_BLUE:
605 if( !bParentCntProt )
606 rSet.Put( SfxInt16Item( nWhich, ((SwChannelBGrf&)
607 aCoreSet.Get(RES_GRFATR_CHANNELB)).GetValue() ));
608 break;
610 case SID_ATTR_GRAF_GAMMA:
611 if( !bParentCntProt )
612 rSet.Put( SfxUInt32Item( nWhich, static_cast< UINT32 >(
613 ( (SwGammaGrf&)aCoreSet.Get( RES_GRFATR_GAMMA ) ).GetValue() * 100 ) ) );
614 break;
615 case SID_ATTR_GRAF_TRANSPARENCE:
616 if( !bParentCntProt )
618 // --> OD 2005-02-09 #119353# - robust
619 const GraphicObject* pGrfObj = rSh.GetGraphicObj();
620 if ( pGrfObj )
622 if( pGrfObj->IsAnimated() ||
623 GRAPHIC_GDIMETAFILE == pGrfObj->GetType() )
624 bDisable = TRUE;
625 else
626 rSet.Put( SfxUInt16Item( nWhich, ((SwTransparencyGrf&)
627 aCoreSet.Get(RES_GRFATR_TRANSPARENCY)).GetValue() ));
630 break;
631 case SID_ATTR_GRAF_INVERT:
632 if( !bParentCntProt )
633 rSet.Put( SfxBoolItem( nWhich, ((SwInvertGrf&)
634 aCoreSet.Get(RES_GRFATR_INVERT)).GetValue() ));
635 break;
637 case SID_ATTR_GRAF_MODE:
638 if( !bParentCntProt )
639 rSet.Put( SfxUInt16Item( nWhich, ((SwDrawModeGrf&)
640 aCoreSet.Get(RES_GRFATR_DRAWMODE)).GetValue() ));
641 break;
643 case SID_GRFFILTER:
644 case SID_GRFFILTER_INVERT:
645 case SID_GRFFILTER_SMOOTH:
646 case SID_GRFFILTER_SHARPEN:
647 case SID_GRFFILTER_REMOVENOISE:
648 case SID_GRFFILTER_SOBEL:
649 case SID_GRFFILTER_MOSAIC:
650 case SID_GRFFILTER_EMBOSS:
651 case SID_GRFFILTER_POSTER:
652 case SID_GRFFILTER_POPART:
653 case SID_GRFFILTER_SEPIA:
654 case SID_GRFFILTER_SOLARIZE:
656 if( bParentCntProt || !bIsGrfCntnt )
657 bDisable = TRUE;
658 // --> OD 2006-11-03 #i59688#
659 // load graphic only if type is unknown
660 // else if( bSwappedOut )
661 // {
662 // rSet.DisableItem( nWhich );
663 // if( AddGrfUpdateSlot( nWhich ))
664 // rSh.GetGraphic(FALSE); // start the loading
665 // }
666 // else
667 // bDisable = !bBitmapType;
668 else
670 const USHORT eGraphicType( rSh.GetGraphicType() );
671 if ( ( eGraphicType == GRAPHIC_NONE ||
672 eGraphicType == GRAPHIC_DEFAULT ) &&
673 rSh.IsGrfSwapOut( TRUE ) )
675 rSet.DisableItem( nWhich );
676 if( AddGrfUpdateSlot( nWhich ))
677 rSh.GetGraphic(FALSE); // start the loading
679 else
681 bDisable = eGraphicType != GRAPHIC_BITMAP;
684 // <--
686 break;
688 default:
689 bDisable = FALSE;
692 if( bDisable )
693 rSet.DisableItem( nWhich );
694 nWhich = aIter.NextWhich();
696 SetGetStateSet( 0 );
700 SwGrfShell::SwGrfShell(SwView &_rView) :
701 SwBaseShell(_rView)
704 SetName(String::CreateFromAscii("Graphic"));
705 SetHelpId(SW_GRFSHELL);