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_sc.hxx" 26 27 #include <svx/svxdlg.hxx> //CHINA001 28 #include <svx/dialogs.hrc> //CHINA001 29 30 #include "scitems.hxx" 31 32 #include <editeng/eeitem.hxx> 33 #include <svx/fontwork.hxx> 34 //#include <svx/labdlg.hxx> CHINA001 35 #include <svl/srchitem.hxx> 36 #include <svx/tabarea.hxx> 37 #include <svx/tabline.hxx> 38 //CHINA001 #include <svx/transfrm.hxx> 39 #include <sfx2/app.hxx> 40 #include <sfx2/objface.hxx> 41 #include <sfx2/objsh.hxx> 42 #include <sfx2/request.hxx> 43 #include <sfx2/dispatch.hxx> 44 #include <svl/whiter.hxx> 45 #include <vcl/msgbox.hxx> 46 47 #include "drawsh.hxx" 48 #include "drwlayer.hxx" 49 #include "sc.hrc" 50 #include "viewdata.hxx" 51 #include "document.hxx" 52 #include "docpool.hxx" 53 #include "drawview.hxx" 54 #include "scresid.hxx" 55 #include <svx/svdobj.hxx> 56 //add header of cui CHINA001 57 #include <svx/svxdlg.hxx> 58 #include <svx/dialogs.hrc> 59 #include <svx/drawitem.hxx> 60 #include <svx/xtable.hxx> 61 62 #define ScDrawShell 63 #include "scslots.hxx" 64 65 #include "userdat.hxx" 66 #include <sfx2/objsh.hxx> 67 #include <svl/macitem.hxx> 68 #include <sfx2/evntconf.hxx> 69 #include <sfx2/viewsh.hxx> 70 #include <com/sun/star/util/XModifiable.hpp> 71 #include <com/sun/star/frame/XFrame.hpp> 72 73 //------------------------------------------------------------------ 74 75 TYPEINIT1( ScDrawShell, SfxShell ); 76 77 SFX_IMPL_INTERFACE(ScDrawShell, SfxShell, ScResId(SCSTR_DRAWSHELL) ) 78 { 79 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, 80 ScResId(RID_DRAW_OBJECTBAR) ); 81 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAW) ); 82 SFX_CHILDWINDOW_REGISTRATION( SvxFontWorkChildWindow::GetChildWindowId() ); 83 } 84 85 86 // abschalten der nicht erwuenschten Acceleratoren: 87 88 void ScDrawShell::StateDisableItems( SfxItemSet &rSet ) 89 { 90 SfxWhichIter aIter(rSet); 91 sal_uInt16 nWhich = aIter.FirstWhich(); 92 93 while (nWhich) 94 { 95 rSet.DisableItem( nWhich ); 96 nWhich = aIter.NextWhich(); 97 } 98 } 99 100 void lcl_setModified( SfxObjectShell* pShell ) 101 { 102 if ( pShell ) 103 { 104 com::sun::star::uno::Reference< com::sun::star::util::XModifiable > xModif( pShell->GetModel(), com::sun::star::uno::UNO_QUERY ); 105 if ( xModif.is() ) 106 xModif->setModified( sal_True ); 107 } 108 } 109 110 void ScDrawShell::ExecDrawAttr( SfxRequest& rReq ) 111 { 112 sal_uInt16 nSlot = rReq.GetSlot(); 113 Window* pWin = pViewData->GetActiveWin(); 114 // SfxViewFrame* pViewFrame = SfxViewShell::Current()->GetViewFrame(); //!!! koennte knallen 115 ScDrawView* pView = pViewData->GetScDrawView(); 116 SdrModel* pDoc = pViewData->GetDocument()->GetDrawLayer(); 117 118 const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 119 sal_uLong nMarkCount = rMarkList.GetMarkCount(); 120 SdrObject* pSingleSelectedObj = NULL; 121 if ( nMarkCount > 0 ) 122 pSingleSelectedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 123 124 switch ( nSlot ) 125 { 126 case SID_ASSIGNMACRO: 127 { 128 if ( pSingleSelectedObj ) 129 ExecuteMacroAssign( pSingleSelectedObj, pWin ); 130 } 131 break; 132 133 case SID_TEXT_STANDARD: // Harte Textattributierung loeschen 134 { 135 SfxItemSet aEmptyAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END); 136 pView->SetAttributes(aEmptyAttr, sal_True); 137 } 138 break; 139 140 case SID_ATTR_LINE_STYLE: 141 case SID_ATTR_LINEEND_STYLE: 142 case SID_ATTR_LINE_DASH: 143 case SID_ATTR_LINE_WIDTH: 144 case SID_ATTR_LINE_COLOR: 145 case SID_ATTR_FILL_STYLE: 146 case SID_ATTR_FILL_COLOR: 147 case SID_ATTR_FILL_GRADIENT: 148 case SID_ATTR_FILL_HATCH: 149 case SID_ATTR_FILL_BITMAP: 150 151 // #i25616# 152 case SID_ATTR_FILL_SHADOW: 153 { 154 // Wenn ToolBar vertikal : 155 if ( !rReq.GetArgs() ) 156 { 157 switch ( nSlot ) 158 { 159 case SID_ATTR_LINE_STYLE: 160 case SID_ATTR_LINE_DASH: 161 case SID_ATTR_LINE_WIDTH: 162 case SID_ATTR_LINE_COLOR: 163 ExecuteLineDlg( rReq ); 164 break; 165 166 case SID_ATTR_FILL_STYLE: 167 case SID_ATTR_FILL_COLOR: 168 case SID_ATTR_FILL_GRADIENT: 169 case SID_ATTR_FILL_HATCH: 170 case SID_ATTR_FILL_BITMAP: 171 172 // #i25616# 173 case SID_ATTR_FILL_SHADOW: 174 175 ExecuteAreaDlg( rReq ); 176 break; 177 178 default: 179 break; 180 } 181 182 //===== 183 return; 184 //===== 185 } 186 187 if( pView->AreObjectsMarked() ) 188 pView->SetAttrToMarked( *rReq.GetArgs(), sal_False ); 189 else 190 pView->SetDefaultAttr( *rReq.GetArgs(), sal_False); 191 pView->InvalidateAttribs(); 192 } 193 break; 194 195 case SID_ATTRIBUTES_LINE: 196 ExecuteLineDlg( rReq ); 197 break; 198 199 case SID_ATTRIBUTES_AREA: 200 ExecuteAreaDlg( rReq ); 201 break; 202 203 case SID_DRAWTEXT_ATTR_DLG: 204 ExecuteTextAttrDlg( rReq ); 205 break; 206 207 #ifdef ISSUE66550_HLINK_FOR_SHAPES 208 case SID_DRAW_HLINK_EDIT: 209 if ( pSingleSelectedObj ) 210 pViewData->GetDispatcher().Execute( SID_HYPERLINK_DIALOG ); 211 break; 212 213 case SID_DRAW_HLINK_DELETE: 214 if ( pSingleSelectedObj ) 215 SetHlinkForObject( pSingleSelectedObj, rtl::OUString() ); 216 break; 217 218 case SID_OPEN_HYPERLINK: 219 if ( nMarkCount == 1 ) 220 { 221 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 222 if ( pObj->IsGroupObject() ) 223 { 224 SdrPageView* pPV = 0; 225 SdrObject* pHit = 0; 226 if ( pView->PickObj( pWin->PixelToLogic( pViewData->GetMousePosPixel() ), pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) ) 227 pObj = pHit; 228 } 229 230 ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); 231 if ( pInfo && (pInfo->GetHlink().getLength() > 0) ) 232 ScGlobal::OpenURL( pInfo->GetHlink(), String::EmptyString() ); 233 } 234 break; 235 #endif 236 237 case SID_ATTR_TRANSFORM: 238 { 239 if ( pView->AreObjectsMarked() ) 240 { 241 const SfxItemSet* pArgs = rReq.GetArgs(); 242 243 if( !pArgs ) 244 { 245 // const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 246 if( rMarkList.GetMark(0) != 0 ) 247 { 248 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 249 if( pObj->GetObjIdentifier() == OBJ_CAPTION ) 250 { 251 // --------- Itemset fuer Caption -------- 252 SfxItemSet aNewAttr(pDoc->GetItemPool()); 253 pView->GetAttributes(aNewAttr); 254 // --------- Itemset fuer Groesse und Position -------- 255 SfxItemSet aNewGeoAttr(pView->GetGeoAttrFromMarked()); 256 257 //SvxCaptionTabDialog* pDlg = new SvxCaptionTabDialog(pWin, pView); 258 //change for cui CHINA001 259 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 260 if ( pFact ) 261 { 262 SfxAbstractTabDialog *pDlg = pFact->CreateCaptionDialog( pWin, pView ); 263 264 const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() ); 265 SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange ); 266 aCombSet.Put( aNewAttr ); 267 aCombSet.Put( aNewGeoAttr ); 268 pDlg->SetInputSet( &aCombSet ); 269 270 if (pDlg->Execute() == RET_OK) 271 { 272 rReq.Done(*(pDlg->GetOutputItemSet())); 273 pView->SetAttributes(*pDlg->GetOutputItemSet()); 274 pView->SetGeoAttrToMarked(*pDlg->GetOutputItemSet()); 275 } 276 277 delete pDlg; 278 }// change for cui 279 } 280 else 281 { 282 SfxItemSet aNewAttr(pView->GetGeoAttrFromMarked()); 283 //CHINA001 SvxTransformTabDialog* pDlg = new SvxTransformTabDialog(pWin, &aNewAttr, pView); 284 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 285 if(pFact) 286 { 287 SfxAbstractTabDialog* pDlg = pFact->CreateSvxTransformTabDialog( pWin, &aNewAttr,pView ); 288 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 289 if (pDlg->Execute() == RET_OK) 290 { 291 rReq.Done(*(pDlg->GetOutputItemSet())); 292 pView->SetGeoAttrToMarked(*pDlg->GetOutputItemSet()); 293 } 294 delete pDlg; 295 } 296 } 297 } 298 299 300 } 301 else 302 pView->SetGeoAttrToMarked( *pArgs ); 303 } 304 } 305 break; 306 307 default: 308 break; 309 } 310 } 311 312 void ScDrawShell::ExecuteMacroAssign( SdrObject* pObj, Window* pWin ) 313 { 314 SvxMacroItem aItem ( SFX_APP()->GetPool().GetWhich( SID_ATTR_MACROITEM ) ); 315 ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, sal_True ); 316 if ( pInfo->GetMacro().getLength() > 0 ) 317 { 318 SvxMacroTableDtor aTab; 319 String sMacro( pInfo->GetMacro() ); 320 aTab.Insert( SFX_EVENT_MOUSECLICK_OBJECT, new SvxMacro( sMacro, String() ) ); 321 aItem.SetMacroTable( aTab ); 322 } 323 324 // create empty itemset for macro-dlg 325 SfxItemSet* pItemSet = new SfxItemSet(SFX_APP()->GetPool(), SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 ); 326 pItemSet->Put ( aItem, SID_ATTR_MACROITEM ); 327 328 SfxEventNamesItem aNamesItem(SID_EVENTCONFIG); 329 aNamesItem.AddEvent( ScResId(RID_SCSTR_ONCLICK), String(), SFX_EVENT_MOUSECLICK_OBJECT ); 330 pItemSet->Put( aNamesItem, SID_EVENTCONFIG ); 331 332 com::sun::star::uno::Reference < com::sun::star::frame::XFrame > xFrame; 333 if (GetViewShell()) 334 xFrame = GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(); 335 336 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 337 SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( pWin, *pItemSet, xFrame, SID_EVENTCONFIG ); 338 if ( pMacroDlg && pMacroDlg->Execute() == RET_OK ) 339 { 340 const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet(); 341 const SfxPoolItem* pItem; 342 if( SFX_ITEM_SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, sal_False, &pItem )) 343 { 344 rtl::OUString sMacro; 345 SvxMacro* pMacro = ((SvxMacroItem*)pItem)->GetMacroTable().Get( SFX_EVENT_MOUSECLICK_OBJECT ); 346 if ( pMacro ) 347 sMacro = pMacro->GetMacName(); 348 349 if ( pObj->IsGroupObject() ) 350 { 351 SdrObjList* pOL = pObj->GetSubList(); 352 sal_uLong nObj = pOL->GetObjCount(); 353 for ( sal_uLong index=0; index<nObj; ++index ) 354 { 355 pInfo = ScDrawLayer::GetMacroInfo( pOL->GetObj(index), sal_True ); 356 pInfo->SetMacro( sMacro ); 357 } 358 } 359 else 360 pInfo->SetMacro( sMacro ); 361 lcl_setModified( GetObjectShell() ); 362 } 363 } 364 365 delete pMacroDlg; 366 delete pItemSet; 367 } 368 369 void ScDrawShell::ExecuteLineDlg( SfxRequest& rReq, sal_uInt16 nTabPage ) 370 { 371 ScDrawView* pView = pViewData->GetScDrawView(); 372 sal_Bool bHasMarked = pView->AreObjectsMarked(); 373 const SdrObject* pObj = NULL; 374 const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 375 376 if( rMarkList.GetMarkCount() == 1 ) 377 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 378 379 SfxItemSet aNewAttr( pView->GetDefaultAttr() ); 380 if( bHasMarked ) 381 pView->MergeAttrFromMarked( aNewAttr, sal_False ); 382 383 //CHINA001 SvxLineTabDialog* pDlg 384 //CHINA001 = new SvxLineTabDialog( pViewData->GetDialogParent(), 385 //CHINA001 &aNewAttr, 386 //CHINA001 pViewData->GetDocument()->GetDrawLayer(), 387 //CHINA001 pObj, 388 //CHINA001 bHasMarked ); 389 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 390 DBG_ASSERT(pFact, "Dialogdiet Factory fail!");//CHINA001 391 SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( pViewData->GetDialogParent(), 392 &aNewAttr, 393 pViewData->GetDocument()->GetDrawLayer(), 394 pObj, 395 bHasMarked); 396 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 397 if ( nTabPage != 0xffff ) 398 pDlg->SetCurPageId( nTabPage ); 399 400 if ( pDlg->Execute() == RET_OK ) 401 { 402 if( bHasMarked ) 403 pView->SetAttrToMarked( *pDlg->GetOutputItemSet(), sal_False ); 404 else 405 pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), sal_False ); 406 407 pView->InvalidateAttribs(); 408 rReq.Done(); 409 } 410 411 delete pDlg; 412 } 413 414 void ScDrawShell::ExecuteAreaDlg( SfxRequest& rReq, sal_uInt16 nTabPage ) 415 { 416 ScDrawView* pView = pViewData->GetScDrawView(); 417 sal_Bool bHasMarked = pView->AreObjectsMarked(); 418 419 SfxItemSet aNewAttr( pView->GetDefaultAttr() ); 420 if( bHasMarked ) 421 pView->MergeAttrFromMarked( aNewAttr, sal_False ); 422 423 //CHINA001 SvxAreaTabDialog* pDlg 424 //CHINA001 = new SvxAreaTabDialog( pViewData->GetDialogParent(), 425 //CHINA001 &aNewAttr, 426 //CHINA001 pViewData->GetDocument()->GetDrawLayer(), 427 //CHINA001 pView ); 428 429 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 430 DBG_ASSERT(pFact, "Dialogdiet Factory fail!");//CHINA001 431 AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( pViewData->GetDialogParent(), 432 &aNewAttr, 433 pViewData->GetDocument()->GetDrawLayer(), 434 pView); 435 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 436 437 // #i74099# by default, the dialog deletes the current color table if a different one is loaded 438 // (see SwDrawShell::ExecDrawDlg) 439 const SvxColorTableItem* pColorItem = 440 static_cast<const SvxColorTableItem*>( pViewData->GetSfxDocShell()->GetItem(SID_COLOR_TABLE) ); 441 if (pColorItem->GetColorTable() == XColorTable::GetStdColorTable()) 442 pDlg->DontDeleteColorTable(); 443 444 if ( nTabPage != 0xffff ) 445 pDlg->SetCurPageId( nTabPage ); 446 447 if ( pDlg->Execute() == RET_OK ) 448 { 449 if( bHasMarked ) 450 pView->SetAttrToMarked( *pDlg->GetOutputItemSet(), sal_False ); 451 else 452 pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), sal_False ); 453 454 pView->InvalidateAttribs(); 455 rReq.Done(); 456 } 457 458 delete pDlg; 459 } 460 461 void ScDrawShell::ExecuteTextAttrDlg( SfxRequest& rReq, sal_uInt16 /* nTabPage */ ) 462 { 463 ScDrawView* pView = pViewData->GetScDrawView(); 464 sal_Bool bHasMarked = pView->AreObjectsMarked(); 465 SfxItemSet aNewAttr ( pView->GetDefaultAttr() ); 466 467 if( bHasMarked ) 468 pView->MergeAttrFromMarked( aNewAttr, sal_False ); 469 470 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 471 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aNewAttr, pView ); 472 473 sal_uInt16 nResult = pDlg->Execute(); 474 475 if ( RET_OK == nResult ) 476 { 477 if ( bHasMarked ) 478 pView->SetAttributes( *pDlg->GetOutputItemSet() ); 479 else 480 pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), sal_False ); 481 482 pView->InvalidateAttribs(); 483 rReq.Done(); 484 } 485 delete( pDlg ); 486 } 487 488 #ifdef ISSUE66550_HLINK_FOR_SHAPES 489 void ScDrawShell::SetHlinkForObject( SdrObject* pObj, const rtl::OUString& rHlnk ) 490 { 491 if ( pObj ) 492 { 493 ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, sal_True ); 494 pInfo->SetHlink( rHlnk ); 495 lcl_setModified( GetObjectShell() ); 496 } 497 } 498 #endif 499 500