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 { 385 GetShell().GetCurAttr( aGrfSet ); 386 SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get( 387 RES_GRFATR_MIRRORGRF ) ); 388 sal_uInt16 nMirror = aMirror.GetValue(); 389 if( FN_FLIP_VERT_GRAFIC == nSlot ) 390 switch( nMirror ) 391 { 392 case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_VERT; 393 break; 394 case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_BOTH; 395 break; 396 case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_DONT; 397 break; 398 case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_HOR; 399 break; 400 } 401 else 402 switch( nMirror ) 403 { 404 case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_HOR; 405 break; 406 case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_BOTH; 407 break; 408 case RES_MIRROR_GRAPH_HOR: nMirror = RES_MIRROR_GRAPH_DONT; 409 break; 410 case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_VERT; 411 break; 412 } 413 aMirror.SetValue( nMirror ); 414 aGrfSet.ClearItem(); 415 aGrfSet.Put( aMirror ); 416 } 417 break; 418 419 case SID_ATTR_GRAF_LUMINANCE: 420 if( pItem ) 421 aGrfSet.Put( SwLuminanceGrf( 422 ((SfxInt16Item*)pItem)->GetValue() )); 423 break; 424 case SID_ATTR_GRAF_CONTRAST: 425 if( pItem ) 426 aGrfSet.Put( SwContrastGrf( 427 ((SfxInt16Item*)pItem)->GetValue() )); 428 break; 429 case SID_ATTR_GRAF_RED: 430 if( pItem ) 431 aGrfSet.Put( SwChannelRGrf( 432 ((SfxInt16Item*)pItem)->GetValue() )); 433 break; 434 case SID_ATTR_GRAF_GREEN: 435 if( pItem ) 436 aGrfSet.Put( SwChannelGGrf( 437 ((SfxInt16Item*)pItem)->GetValue() )); 438 break; 439 case SID_ATTR_GRAF_BLUE: 440 if( pItem ) 441 aGrfSet.Put( SwChannelBGrf( 442 ((SfxInt16Item*)pItem)->GetValue() )); 443 break; 444 case SID_ATTR_GRAF_GAMMA: 445 if( pItem ) 446 { 447 double fVal = ((SfxUInt32Item*)pItem)->GetValue(); 448 aGrfSet.Put( SwGammaGrf(fVal/100. )); 449 } 450 break; 451 case SID_ATTR_GRAF_TRANSPARENCE: 452 if( pItem ) 453 aGrfSet.Put( SwTransparencyGrf( 454 static_cast< sal_Int8 >( ( (SfxUInt16Item*)pItem )->GetValue() ) ) ); 455 break; 456 case SID_ATTR_GRAF_INVERT: 457 if( pItem ) 458 aGrfSet.Put( SwInvertGrf( 459 ((SfxBoolItem*)pItem)->GetValue() )); 460 break; 461 462 case SID_ATTR_GRAF_MODE: 463 if( pItem ) 464 aGrfSet.Put( SwDrawModeGrf( 465 ((SfxUInt16Item*)pItem)->GetValue() )); 466 break; 467 468 case SID_COLOR_SETTINGS: 469 { 470 svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); 471 aToolboxAccess.toggleToolbox(); 472 break; 473 } 474 case SID_GRFFILTER: 475 case SID_GRFFILTER_INVERT: 476 case SID_GRFFILTER_SMOOTH: 477 case SID_GRFFILTER_SHARPEN: 478 case SID_GRFFILTER_REMOVENOISE: 479 case SID_GRFFILTER_SOBEL: 480 case SID_GRFFILTER_MOSAIC: 481 case SID_GRFFILTER_EMBOSS: 482 case SID_GRFFILTER_POSTER: 483 case SID_GRFFILTER_POPART: 484 case SID_GRFFILTER_SEPIA: 485 case SID_GRFFILTER_SOLARIZE: 486 if( GRAPHIC_BITMAP == nGrfType ) 487 { 488 // --> OD 2005-02-09 #119353# - robust 489 const GraphicObject* pFilterObj( GetShell().GetGraphicObj() ); 490 if ( pFilterObj ) 491 { 492 GraphicObject aFilterObj( *pFilterObj ); 493 if( SVX_GRAPHICFILTER_ERRCODE_NONE == 494 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj )) 495 GetShell().ReRead( aEmptyStr, aEmptyStr, 496 &aFilterObj.GetGraphic() ); 497 } 498 // <-- 499 } 500 break; 501 502 default: 503 ASSERT(!this, falscher Dispatcher); 504 } 505 if( aGrfSet.Count() ) 506 GetShell().SetAttr( aGrfSet ); 507 } 508 GetView().GetViewFrame()->GetBindings().Invalidate(rReq.GetSlot()); 509 } 510 511 void SwGrfShell::GetAttrState(SfxItemSet &rSet) 512 { 513 SwWrtShell &rSh = GetShell(); 514 SfxItemSet aCoreSet( GetPool(), aNoTxtNodeSetRange ); 515 rSh.GetCurAttr( aCoreSet ); 516 sal_Bool bParentCntProt = 0 != rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ); 517 sal_Bool bIsGrfCntnt = CNT_GRF == GetShell().GetCntType(); 518 // const GraphicObject* pGrfObj = ( bIsGrfCntnt ? rSh.GetGraphicObj() : NULL ); 519 // sal_Bool bIsRenderGraphicGrfCntnt = ( pGrfObj && pGrfObj->IsRenderGraphic() ); 520 521 // --> OD 2006-11-03 #i59688# 522 // sal_Bool bSwappedOut = rSh.IsGrfSwapOut( sal_True ); 523 // sal_Bool bBitmapType = !bSwappedOut && GRAPHIC_BITMAP == rSh.GetGraphicType(); 524 // <-- 525 526 SetGetStateSet( &rSet ); 527 528 SfxWhichIter aIter( rSet ); 529 sal_uInt16 nWhich = aIter.FirstWhich(); 530 while( nWhich ) 531 { 532 sal_Bool bDisable = bParentCntProt; 533 switch( nWhich ) 534 { 535 case SID_INSERT_GRAPHIC: 536 case FN_FORMAT_GRAFIC_DLG: 537 case SID_TWAIN_TRANSFER: 538 if( bParentCntProt || !bIsGrfCntnt ) 539 bDisable = sal_True; 540 break; 541 case FN_SAVE_GRAPHIC: 542 if( rSh.GetGraphicType() == GRAPHIC_NONE ) 543 bDisable = sal_True; 544 break; 545 case SID_COLOR_SETTINGS: 546 { 547 if ( bParentCntProt || !bIsGrfCntnt ) 548 bDisable = sal_True; 549 else 550 { 551 svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); 552 rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) ); 553 } 554 break; 555 } 556 557 case FN_FLIP_VERT_GRAFIC: 558 if( !bParentCntProt ) 559 { 560 MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get( 561 RES_GRFATR_MIRRORGRF )).GetValue()); 562 563 rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_VERT || 564 nState == RES_MIRROR_GRAPH_BOTH)); 565 } 566 break; 567 568 case FN_FLIP_HORZ_GRAFIC: 569 if( !bParentCntProt ) 570 { 571 MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get( 572 RES_GRFATR_MIRRORGRF )).GetValue()); 573 574 rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_HOR || 575 nState == RES_MIRROR_GRAPH_BOTH)); 576 } 577 break; 578 579 580 case SID_ATTR_GRAF_LUMINANCE: 581 if( !bParentCntProt ) 582 rSet.Put( SfxInt16Item( nWhich, ((SwLuminanceGrf&) 583 aCoreSet.Get(RES_GRFATR_LUMINANCE)).GetValue() )); 584 break; 585 case SID_ATTR_GRAF_CONTRAST: 586 if( !bParentCntProt ) 587 rSet.Put( SfxInt16Item( nWhich, ((SwContrastGrf&) 588 aCoreSet.Get(RES_GRFATR_CONTRAST)).GetValue() )); 589 break; 590 case SID_ATTR_GRAF_RED: 591 if( !bParentCntProt ) 592 rSet.Put( SfxInt16Item( nWhich, ((SwChannelRGrf&) 593 aCoreSet.Get(RES_GRFATR_CHANNELR)).GetValue() )); 594 break; 595 case SID_ATTR_GRAF_GREEN: 596 if( !bParentCntProt ) 597 rSet.Put( SfxInt16Item( nWhich, ((SwChannelGGrf&) 598 aCoreSet.Get(RES_GRFATR_CHANNELG)).GetValue() )); 599 break; 600 case SID_ATTR_GRAF_BLUE: 601 if( !bParentCntProt ) 602 rSet.Put( SfxInt16Item( nWhich, ((SwChannelBGrf&) 603 aCoreSet.Get(RES_GRFATR_CHANNELB)).GetValue() )); 604 break; 605 606 case SID_ATTR_GRAF_GAMMA: 607 if( !bParentCntProt ) 608 rSet.Put( SfxUInt32Item( nWhich, static_cast< sal_uInt32 >( 609 ( (SwGammaGrf&)aCoreSet.Get( RES_GRFATR_GAMMA ) ).GetValue() * 100 ) ) ); 610 break; 611 case SID_ATTR_GRAF_TRANSPARENCE: 612 if( !bParentCntProt ) 613 { 614 // --> OD 2005-02-09 #119353# - robust 615 const GraphicObject* pGrafObj = rSh.GetGraphicObj(); 616 if ( pGrafObj ) 617 { 618 if( pGrafObj->IsAnimated() || 619 GRAPHIC_GDIMETAFILE == pGrafObj->GetType() ) 620 bDisable = sal_True; 621 else 622 rSet.Put( SfxUInt16Item( nWhich, ((SwTransparencyGrf&) 623 aCoreSet.Get(RES_GRFATR_TRANSPARENCY)).GetValue() )); 624 } 625 } 626 break; 627 case SID_ATTR_GRAF_INVERT: 628 if( !bParentCntProt ) 629 rSet.Put( SfxBoolItem( nWhich, ((SwInvertGrf&) 630 aCoreSet.Get(RES_GRFATR_INVERT)).GetValue() )); 631 break; 632 633 case SID_ATTR_GRAF_MODE: 634 if( !bParentCntProt ) 635 rSet.Put( SfxUInt16Item( nWhich, ((SwDrawModeGrf&) 636 aCoreSet.Get(RES_GRFATR_DRAWMODE)).GetValue() )); 637 break; 638 639 case SID_GRFFILTER: 640 case SID_GRFFILTER_INVERT: 641 case SID_GRFFILTER_SMOOTH: 642 case SID_GRFFILTER_SHARPEN: 643 case SID_GRFFILTER_REMOVENOISE: 644 case SID_GRFFILTER_SOBEL: 645 case SID_GRFFILTER_MOSAIC: 646 case SID_GRFFILTER_EMBOSS: 647 case SID_GRFFILTER_POSTER: 648 case SID_GRFFILTER_POPART: 649 case SID_GRFFILTER_SEPIA: 650 case SID_GRFFILTER_SOLARIZE: 651 { 652 if( bParentCntProt || !bIsGrfCntnt ) 653 bDisable = sal_True; 654 // --> OD 2006-11-03 #i59688# 655 // load graphic only if type is unknown 656 // else if( bSwappedOut ) 657 // { 658 // rSet.DisableItem( nWhich ); 659 // if( AddGrfUpdateSlot( nWhich )) 660 // rSh.GetGraphic(sal_False); // start the loading 661 // } 662 // else 663 // bDisable = !bBitmapType; 664 else 665 { 666 const sal_uInt16 eGraphicType( rSh.GetGraphicType() ); 667 if ( ( eGraphicType == GRAPHIC_NONE || 668 eGraphicType == GRAPHIC_DEFAULT ) && 669 rSh.IsGrfSwapOut( sal_True ) ) 670 { 671 rSet.DisableItem( nWhich ); 672 if( AddGrfUpdateSlot( nWhich )) 673 rSh.GetGraphic(sal_False); // start the loading 674 } 675 else 676 { 677 bDisable = eGraphicType != GRAPHIC_BITMAP; 678 } 679 } 680 // <-- 681 } 682 break; 683 684 default: 685 bDisable = sal_False; 686 } 687 688 if( bDisable ) 689 rSet.DisableItem( nWhich ); 690 nWhich = aIter.NextWhich(); 691 } 692 SetGetStateSet( 0 ); 693 } 694 695 696 SwGrfShell::SwGrfShell(SwView &_rView) : 697 SwBaseShell(_rView) 698 699 { 700 SetName(String::CreateFromAscii("Graphic")); 701 SetHelpId(SW_GRFSHELL); 702 } 703