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