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 <sfx2/sidebar/EnumContext.hxx> 47 #include <svl/srchitem.hxx> 48 #include <svx/htmlmode.hxx> 49 #include <svx/sdgluitm.hxx> 50 #include <svx/sdgcoitm.hxx> 51 #include <svx/sdggaitm.hxx> 52 #include <svx/sdgtritm.hxx> 53 #include <svx/sdginitm.hxx> 54 #include <svx/sdgmoitm.hxx> 55 #include <editeng/brshitem.hxx> 56 #include <svx/grfflt.hxx> 57 #include <svx/tbxcolor.hxx> 58 #include <fmturl.hxx> 59 #include <view.hxx> 60 #include <wrtsh.hxx> 61 #include <viewopt.hxx> 62 #include <swmodule.hxx> 63 #include <frmatr.hxx> 64 #include <swundo.hxx> 65 #include <uitool.hxx> 66 #include <docsh.hxx> 67 #include <grfsh.hxx> 68 #include <frmmgr.hxx> 69 #include <frmdlg.hxx> 70 #include <frmfmt.hxx> 71 #include <grfatr.hxx> 72 #include <usrpref.hxx> 73 #include <edtwin.hxx> 74 #include <swwait.hxx> 75 #include <shells.hrc> 76 #include <popup.hrc> 77 78 #define SwGrfShell 79 #include <sfx2/msg.hxx> 80 #include "swslots.hxx" 81 82 #include "swabstdlg.hxx" 83 84 #define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) ) 85 86 SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC)) 87 { 88 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU)); 89 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_GRAFIK_TOOLBOX)); 90 } 91 92 void SwGrfShell::Execute(SfxRequest &rReq) 93 { 94 SwWrtShell &rSh = GetShell(); 95 96 sal_uInt16 nSlot = rReq.GetSlot(); 97 switch(nSlot) 98 { 99 case SID_TWAIN_TRANSFER: 100 { 101 GetView().ExecuteScan( rReq ); 102 break; 103 } 104 case FN_SAVE_GRAPHIC: 105 { 106 const Graphic *pGraphic; 107 if(0 != (pGraphic = rSh.GetGraphic())) 108 { 109 String sGrfNm, sFilterNm; 110 rSh.GetGrfNms( &sGrfNm, &sFilterNm ); 111 ExportGraphic( *pGraphic, sGrfNm ); 112 } 113 } 114 break; 115 case SID_INSERT_GRAPHIC: 116 case FN_FORMAT_GRAFIC_DLG: 117 case FN_DRAW_WRAP_DLG: 118 { 119 SwFlyFrmAttrMgr aMgr( sal_False, &rSh, rSh.IsFrmSelected() ? 120 FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF); 121 const SwViewOption* pVOpt = rSh.GetViewOptions(); 122 SwViewOption aUsrPref( *pVOpt ); 123 124 SfxItemSet aSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1, 125 RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF, 126 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 127 SID_ATTR_GRAF_KEEP_ZOOM, SID_ATTR_GRAF_KEEP_ZOOM, 128 SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE, 129 SID_ATTR_GRAF_FRMSIZE_PERCENT, SID_ATTR_GRAF_FRMSIZE_PERCENT, 130 SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC, 131 FN_PARAM_GRF_CONNECT, FN_PARAM_GRF_CONNECT, 132 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 133 FN_GET_PRINT_AREA, FN_GET_PRINT_AREA, 134 FN_SET_FRM_NAME, FN_KEEP_ASPECT_RATIO, 135 FN_PARAM_GRF_DIALOG, FN_PARAM_GRF_DIALOG, 136 SID_DOCFRAME, SID_DOCFRAME, 137 SID_HTML_MODE, SID_HTML_MODE, 138 FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME, 139 0); 140 141 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); 142 aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode)); 143 FieldUnit eMetric = ::GetDfltMetric((0 != (nHtmlMode&HTMLMODE_ON))); 144 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) ); 145 146 const SwRect* pRect = &rSh.GetAnyCurRect(RECT_PAGE); 147 SwFmtFrmSize aFrmSize( ATT_VAR_SIZE, pRect->Width(), pRect->Height()); 148 aFrmSize.SetWhich( GetPool().GetWhich( SID_ATTR_PAGE_SIZE ) ); 149 aSet.Put( aFrmSize ); 150 151 aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName())); 152 if ( nSlot == FN_FORMAT_GRAFIC_DLG ) 153 { 154 aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) ); 155 } 156 157 pRect = &rSh.GetAnyCurRect(RECT_PAGE_PRT); 158 aFrmSize.SetWidth( pRect->Width() ); 159 aFrmSize.SetHeight( pRect->Height() ); 160 aFrmSize.SetWhich( GetPool().GetWhich(FN_GET_PRINT_AREA) ); 161 aSet.Put( aFrmSize ); 162 163 aSet.Put( aMgr.GetAttrSet() ); 164 aSet.SetParent( aMgr.GetAttrSet().GetParent() ); 165 166 // Bei %-Werten Groesse initialisieren 167 SwFmtFrmSize aSizeCopy = (const SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE); 168 if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != 0xff) 169 aSizeCopy.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width()); 170 if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != 0xff) 171 aSizeCopy.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height()); 172 173 // and now set the size for "external" tabpages 174 { 175 SvxSizeItem aSzItm( SID_ATTR_GRAF_FRMSIZE, aSizeCopy.GetSize() ); 176 aSet.Put( aSzItm ); 177 178 Size aSz( aSizeCopy.GetWidthPercent(), aSizeCopy.GetHeightPercent() ); 179 if( 0xff == aSz.Width() ) aSz.Width() = 0; 180 if( 0xff == aSz.Height() ) aSz.Height() = 0; 181 182 aSzItm.SetSize( aSz ); 183 aSzItm.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT ); 184 aSet.Put( aSzItm ); 185 } 186 187 String sGrfNm, sFilterNm; 188 rSh.GetGrfNms( &sGrfNm, &sFilterNm ); 189 if( sGrfNm.Len() ) 190 { 191 aSet.Put( SvxBrushItem( INetURLObject::decode( sGrfNm, 192 INET_HEX_ESCAPE, 193 INetURLObject::DECODE_UNAMBIGUOUS, 194 RTL_TEXTENCODING_UTF8 ), 195 sFilterNm, GPOS_LT, 196 SID_ATTR_GRAF_GRAPHIC )); 197 } 198 else 199 { 200 // --> OD 2005-02-09 #119353# - robust 201 const GraphicObject* pGrfObj = rSh.GetGraphicObj(); 202 if ( pGrfObj ) 203 { 204 aSet.Put( SvxBrushItem( *pGrfObj, GPOS_LT, 205 SID_ATTR_GRAF_GRAPHIC ) ); 206 } 207 // <-- 208 } 209 aSet.Put( SfxBoolItem( FN_PARAM_GRF_CONNECT, sGrfNm.Len() > 0 ) ); 210 211 // get Mirror and Crop 212 { 213 SfxItemSet aTmpSet( rSh.GetAttrPool(), 214 RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF ); 215 216 rSh.GetCurAttr( aTmpSet ); 217 aSet.Put( aTmpSet ); 218 } 219 220 aSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, aUsrPref.IsKeepRatio())); 221 aSet.Put(SfxBoolItem( SID_ATTR_GRAF_KEEP_ZOOM, aUsrPref.IsGrfKeepZoom())); 222 223 aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame())); 224 225 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 226 DBG_ASSERT(pFact, "Dialogdiet fail!"); 227 SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_GRF, 228 GetView().GetViewFrame(), 229 GetView().GetWindow(), 230 aSet, sal_False, DLG_FRM_GRF); 231 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 232 233 if (nSlot == FN_DRAW_WRAP_DLG) 234 pDlg->SetCurPageId(TP_FRM_WRAP); 235 236 if( pDlg->Execute() ) 237 { 238 rSh.StartAllAction(); 239 rSh.StartUndo(UNDO_START); 240 const SfxPoolItem* pItem; 241 SfxItemSet* pSet = (SfxItemSet*)pDlg->GetOutputItemSet(); 242 rReq.Done(*pSet); 243 // change the 2 frmsize SizeItems to the correct SwFrmSizeItem 244 if( SFX_ITEM_SET == pSet->GetItemState( 245 SID_ATTR_GRAF_FRMSIZE, sal_False, &pItem )) 246 { 247 SwFmtFrmSize aSize; 248 const Size& rSz = ((SvxSizeItem*)pItem)->GetSize(); 249 aSize.SetWidth( rSz.Width() ); 250 aSize.SetHeight( rSz.Height() ); 251 252 if( SFX_ITEM_SET == pSet->GetItemState( 253 SID_ATTR_GRAF_FRMSIZE_PERCENT, sal_False, &pItem )) 254 { 255 const Size& rRelativeSize = ((SvxSizeItem*)pItem)->GetSize(); 256 aSize.SetWidthPercent( static_cast< sal_uInt8 >( rRelativeSize.Width() ) ); 257 aSize.SetHeightPercent( static_cast< sal_uInt8 >( rRelativeSize.Height() ) ); 258 } 259 pSet->Put( aSize ); 260 } 261 262 // Vorlagen-AutoUpdate 263 SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); 264 if(pFmt && pFmt->IsAutoUpdateFmt()) 265 { 266 pFmt->SetFmtAttr(*pSet); 267 SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE, 268 RES_SURROUND, RES_SURROUND, 269 RES_ANCHOR, RES_ANCHOR, 270 RES_VERT_ORIENT,RES_HORI_ORIENT, 271 0); 272 aShellSet.Put(*pSet); 273 aMgr.SetAttrSet(aShellSet); 274 } 275 else 276 { 277 aMgr.SetAttrSet(*pSet); 278 } 279 aMgr.UpdateFlyFrm(); 280 281 sal_Bool bApplyUsrPref = sal_False; 282 if (SFX_ITEM_SET == pSet->GetItemState( 283 FN_KEEP_ASPECT_RATIO, sal_True, &pItem )) 284 { 285 aUsrPref.SetKeepRatio( 286 ((const SfxBoolItem*)pItem)->GetValue() ); 287 bApplyUsrPref = sal_True; 288 } 289 if( SFX_ITEM_SET == pSet->GetItemState( 290 SID_ATTR_GRAF_KEEP_ZOOM, sal_True, &pItem )) 291 { 292 aUsrPref.SetGrfKeepZoom( 293 ((const SfxBoolItem*)pItem)->GetValue() ); 294 bApplyUsrPref = sal_True; 295 } 296 297 if( bApplyUsrPref ) 298 SW_MOD()->ApplyUsrPref(aUsrPref, &GetView()); 299 300 // and now set all the graphic attributes and other stuff 301 if( SFX_ITEM_SET == pSet->GetItemState( 302 SID_ATTR_GRAF_GRAPHIC, sal_True, &pItem )) 303 { 304 if( ((SvxBrushItem*)pItem)->GetGraphicLink() ) 305 sGrfNm = *((SvxBrushItem*)pItem)->GetGraphicLink(); 306 else 307 sGrfNm.Erase(); 308 309 if( ((SvxBrushItem*)pItem)->GetGraphicFilter() ) 310 sFilterNm = *((SvxBrushItem*)pItem)->GetGraphicFilter(); 311 else 312 sFilterNm.Erase(); 313 314 if( sGrfNm.Len() ) 315 { 316 SwDocShell* pDocSh = GetView().GetDocShell(); 317 SwWait aWait( *pDocSh, sal_True ); 318 SfxMedium* pMedium = pDocSh->GetMedium(); 319 INetURLObject aAbs; 320 if( pMedium ) 321 aAbs = pMedium->GetURLObject(); 322 rSh.ReRead( URIHelper::SmartRel2Abs( 323 aAbs, sGrfNm, 324 URIHelper::GetMaybeFileHdl() ), 325 sFilterNm, 0 ); 326 } 327 } 328 if ( SFX_ITEM_SET == pSet->GetItemState( 329 FN_SET_FRM_ALT_NAME, sal_True, &pItem )) 330 { 331 // --> OD 2009-07-13 #i73249# 332 // rSh.SetAlternateText( 333 // ((const SfxStringItem*)pItem)->GetValue() ); 334 rSh.SetObjTitle( ((const SfxStringItem*)pItem)->GetValue() ); 335 // <-- 336 } 337 338 SfxItemSet aGrfSet( rSh.GetAttrPool(), RES_GRFATR_BEGIN, 339 RES_GRFATR_END-1 ); 340 aGrfSet.Put( *pSet ); 341 if( aGrfSet.Count() ) 342 rSh.SetAttr( aGrfSet ); 343 344 rSh.EndUndo(UNDO_END); 345 rSh.EndAllAction(); 346 } 347 delete pDlg; 348 } 349 break; 350 351 case FN_GRAPHIC_MIRROR_ON_EVEN_PAGES: 352 { 353 SfxItemSet aSet(rSh.GetAttrPool(), RES_GRFATR_MIRRORGRF, RES_GRFATR_MIRRORGRF); 354 rSh.GetCurAttr( aSet ); 355 SwMirrorGrf aGrf((const SwMirrorGrf &)aSet.Get(RES_GRFATR_MIRRORGRF)); 356 aGrf.SetGrfToggle(!aGrf.IsGrfToggle()); 357 rSh.SetAttr(aGrf); 358 } 359 break; 360 361 default: 362 ASSERT(!this, falscher Dispatcher); 363 return; 364 } 365 } 366 367 368 void SwGrfShell::ExecAttr( SfxRequest &rReq ) 369 { 370 sal_uInt16 nGrfType; 371 if( CNT_GRF == GetShell().GetCntType() && 372 ( GRAPHIC_BITMAP == ( nGrfType = GetShell().GetGraphicType()) || 373 GRAPHIC_GDIMETAFILE == nGrfType )) 374 { 375 SfxItemSet aGrfSet( GetShell().GetAttrPool(), RES_GRFATR_BEGIN, 376 RES_GRFATR_END -1 ); 377 const SfxItemSet *pArgs = rReq.GetArgs(); 378 const SfxPoolItem* pItem; 379 sal_uInt16 nSlot = rReq.GetSlot(); 380 if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, sal_False, &pItem )) 381 pItem = 0; 382 383 switch( nSlot ) 384 { 385 case SID_FLIP_VERTICAL: 386 case SID_FLIP_HORIZONTAL: 387 { 388 GetShell().GetCurAttr( aGrfSet ); 389 SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get( RES_GRFATR_MIRRORGRF ) ); 390 sal_uInt16 nMirror = aMirror.GetValue(); 391 if ( nSlot==SID_FLIP_HORIZONTAL ) 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 SID_FLIP_HORIZONTAL: 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 SID_FLIP_VERTICAL: 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 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Graphic)); 698 } 699