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 #include <tools/shl.hxx> 29 #include <svx/svdview.hxx> 30 #include <svx/svdotext.hxx> 31 #include <svl/whiter.hxx> 32 #include <svx/fontwork.hxx> 33 #include <sfx2/request.hxx> 34 #include <sfx2/bindings.hxx> 35 #include <sfx2/objface.hxx> 36 #include <svl/itemiter.hxx> 37 #include <svl/srchitem.hxx> 38 #include <svx/xftsfit.hxx> 39 #include <svx/extrusionbar.hxx> 40 #include <svx/fontworkbar.hxx> 41 #include <svx/tbxcustomshapes.hxx> 42 #include <uitool.hxx> 43 #include <wview.hxx> 44 #include <swmodule.hxx> 45 #include <swwait.hxx> 46 #include <docstat.hxx> 47 #include <IDocumentStatistics.hxx> 48 49 #include <comphelper/processfactory.hxx> 50 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 51 52 #include <svx/xtable.hxx> 53 54 #include "swundo.hxx" 55 #include "wrtsh.hxx" 56 #include "cmdid.h" 57 #include "globals.hrc" 58 #include "helpid.h" 59 #include "popup.hrc" 60 #include "shells.hrc" 61 #include "drwbassh.hxx" 62 #include "drawsh.hxx" 63 64 #define SwDrawShell 65 #include <sfx2/msg.hxx> 66 #include "swslots.hxx" 67 #include "swabstdlg.hxx" //CHINA001 68 #include "misc.hrc" 69 70 using namespace ::com::sun::star; 71 using namespace ::com::sun::star::uno; 72 73 SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW)) 74 { 75 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU)); 76 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TOOLBOX)); 77 SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId()); 78 } 79 80 TYPEINIT1(SwDrawShell,SwDrawBaseShell) 81 82 /*-------------------------------------------------------------------- 83 Beschreibung: 84 --------------------------------------------------------------------*/ 85 86 87 void SwDrawShell::Execute(SfxRequest &rReq) 88 { 89 SwWrtShell &rSh = GetShell(); 90 SdrView *pSdrView = rSh.GetDrawView(); 91 const SfxItemSet *pArgs = rReq.GetArgs(); 92 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); 93 sal_uInt16 nSlotId = rReq.GetSlot(); 94 sal_Bool bChanged = pSdrView->GetModel()->IsChanged(); 95 96 pSdrView->GetModel()->SetChanged(sal_False); 97 98 const SfxPoolItem* pItem; 99 if(pArgs) 100 pArgs->GetItemState(nSlotId, sal_False, &pItem); 101 102 sal_Bool bMirror = sal_True; 103 104 switch (nSlotId) 105 { 106 case SID_OBJECT_ROTATE: 107 if (rSh.IsObjSelected() && pSdrView->IsRotateAllowed()) 108 { 109 if (GetView().IsDrawRotate()) 110 rSh.SetDragMode(SDRDRAG_MOVE); 111 else 112 rSh.SetDragMode(SDRDRAG_ROTATE); 113 114 GetView().FlipDrawRotate(); 115 } 116 break; 117 118 case SID_BEZIER_EDIT: 119 if (GetView().IsDrawRotate()) 120 { 121 rSh.SetDragMode(SDRDRAG_MOVE); 122 GetView().FlipDrawRotate(); 123 } 124 GetView().FlipDrawSelMode(); 125 pSdrView->SetFrameDragSingles(GetView().IsDrawSelMode()); 126 GetView().AttrChangedNotify(&rSh); // Shellwechsel... 127 break; 128 129 case SID_OBJECT_HELL: 130 if (rSh.IsObjSelected()) 131 { 132 rSh.StartUndo( UNDO_START ); 133 SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP); 134 rSh.SelectionToHell(); 135 rSh.EndUndo( UNDO_END ); 136 rBnd.Invalidate(SID_OBJECT_HEAVEN); 137 } 138 break; 139 140 case SID_OBJECT_HEAVEN: 141 if (rSh.IsObjSelected()) 142 { 143 rSh.StartUndo( UNDO_START ); 144 SetWrapMode(FN_FRAME_WRAPTHRU); 145 rSh.SelectionToHeaven(); 146 rSh.EndUndo( UNDO_END ); 147 rBnd.Invalidate(SID_OBJECT_HELL); 148 } 149 break; 150 151 case FN_TOOL_HIERARCHIE: 152 if (rSh.IsObjSelected()) 153 { 154 rSh.StartUndo( UNDO_START ); 155 if (rSh.GetLayerId() == 0) 156 { 157 SetWrapMode(FN_FRAME_WRAPTHRU); 158 rSh.SelectionToHeaven(); 159 } 160 else 161 { 162 SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP); 163 rSh.SelectionToHell(); 164 } 165 rSh.EndUndo( UNDO_END ); 166 rBnd.Invalidate( SID_OBJECT_HELL ); 167 rBnd.Invalidate( SID_OBJECT_HEAVEN ); 168 } 169 break; 170 171 case FN_FLIP_HORZ_GRAFIC: 172 bMirror = sal_False; 173 /* no break */ 174 case FN_FLIP_VERT_GRAFIC: 175 rSh.MirrorSelection( bMirror ); 176 break; 177 178 case SID_FONTWORK: 179 { 180 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView())); 181 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) ); 182 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 183 if (pArgs) 184 { 185 pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), 186 ((const SfxBoolItem&)(pArgs->Get(SID_FONTWORK))).GetValue()); 187 } 188 else 189 pVFrame->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() ); 190 pVFrame->GetBindings().Invalidate(SID_FONTWORK); 191 } 192 break; 193 case FN_FORMAT_FOOTNOTE_DLG: 194 { 195 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 196 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 197 198 VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE ); 199 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 200 pDlg->Execute(); 201 delete pDlg; 202 break; 203 } 204 case FN_NUMBERING_OUTLINE_DLG: 205 { 206 SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); 207 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 208 DBG_ASSERT(pFact, "Dialogdiet fail!"); 209 SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, 210 GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); 211 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 212 pDlg->Execute(); 213 delete pDlg; 214 rReq.Done(); 215 } 216 break; 217 case SID_OPEN_XML_FILTERSETTINGS: 218 { 219 try 220 { 221 uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); 222 if( xDialog.is() ) 223 { 224 xDialog->execute(); 225 } 226 } 227 catch( uno::Exception& ) 228 { 229 } 230 rReq.Ignore (); 231 } 232 break; 233 case FN_WORDCOUNT_DIALOG: 234 { 235 SwDocStat aCurr; 236 SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); 237 { 238 SwWait aWait( *GetView().GetDocShell(), sal_True ); 239 rSh.StartAction(); 240 rSh.CountWords( aCurr ); 241 rSh.UpdateDocStat( aDocStat ); 242 rSh.EndAction(); 243 } 244 245 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 246 DBG_ASSERT(pFact, "Dialogdiet fail!"); 247 AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); 248 pDialog->SetValues(aCurr, aDocStat ); 249 pDialog->Execute(); 250 delete pDialog; 251 } 252 break; 253 case SID_EXTRUSION_TOOGLE: 254 case SID_EXTRUSION_TILT_DOWN: 255 case SID_EXTRUSION_TILT_UP: 256 case SID_EXTRUSION_TILT_LEFT: 257 case SID_EXTRUSION_TILT_RIGHT: 258 case SID_EXTRUSION_3D_COLOR: 259 case SID_EXTRUSION_DEPTH: 260 case SID_EXTRUSION_DIRECTION: 261 case SID_EXTRUSION_PROJECTION: 262 case SID_EXTRUSION_LIGHTING_DIRECTION: 263 case SID_EXTRUSION_LIGHTING_INTENSITY: 264 case SID_EXTRUSION_SURFACE: 265 case SID_EXTRUSION_DEPTH_FLOATER: 266 case SID_EXTRUSION_DIRECTION_FLOATER: 267 case SID_EXTRUSION_LIGHTING_FLOATER: 268 case SID_EXTRUSION_SURFACE_FLOATER: 269 case SID_EXTRUSION_DEPTH_DIALOG: 270 svx::ExtrusionBar::execute( pSdrView, rReq, rBnd ); 271 rReq.Ignore (); 272 break; 273 274 case SID_FONTWORK_SHAPE: 275 case SID_FONTWORK_SHAPE_TYPE: 276 case SID_FONTWORK_ALIGNMENT: 277 case SID_FONTWORK_SAME_LETTER_HEIGHTS: 278 case SID_FONTWORK_CHARACTER_SPACING: 279 case SID_FONTWORK_KERN_CHARACTER_PAIRS: 280 case SID_FONTWORK_CHARACTER_SPACING_FLOATER: 281 case SID_FONTWORK_ALIGNMENT_FLOATER: 282 case SID_FONTWORK_CHARACTER_SPACING_DIALOG: 283 svx::FontworkBar::execute( pSdrView, rReq, rBnd ); 284 rReq.Ignore (); 285 break; 286 287 default: 288 DBG_ASSERT(!this, "falscher Dispatcher"); 289 return; 290 } 291 if (pSdrView->GetModel()->IsChanged()) 292 rSh.SetModified(); 293 else if (bChanged) 294 pSdrView->GetModel()->SetChanged(sal_True); 295 } 296 297 /*-------------------------------------------------------------------- 298 Beschreibung: 299 --------------------------------------------------------------------*/ 300 301 302 303 void SwDrawShell::GetState(SfxItemSet& rSet) 304 { 305 SwWrtShell &rSh = GetShell(); 306 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); 307 SfxWhichIter aIter( rSet ); 308 sal_uInt16 nWhich = aIter.FirstWhich(); 309 sal_Bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT); 310 311 if (!bProtected) // Im Parent nachsehen 312 bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; 313 314 while( nWhich ) 315 { 316 switch( nWhich ) 317 { 318 case SID_OBJECT_HELL: 319 if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 0 || bProtected ) 320 rSet.DisableItem( nWhich ); 321 break; 322 323 case SID_OBJECT_HEAVEN: 324 if ( !rSh.IsObjSelected() || rSh.GetLayerId() == 1 || bProtected ) 325 rSet.DisableItem( nWhich ); 326 break; 327 328 case FN_TOOL_HIERARCHIE: 329 if ( !rSh.IsObjSelected() || bProtected ) 330 rSet.DisableItem( nWhich ); 331 break; 332 333 case SID_OBJECT_ROTATE: 334 { 335 const sal_Bool bIsRotate = GetView().IsDrawRotate(); 336 if ( (!bIsRotate && !pSdrView->IsRotateAllowed()) || bProtected ) 337 rSet.DisableItem( nWhich ); 338 else 339 rSet.Put( SfxBoolItem( nWhich, bIsRotate ) ); 340 } 341 break; 342 343 case SID_BEZIER_EDIT: 344 if (!Disable(rSet, nWhich)) 345 rSet.Put( SfxBoolItem( nWhich, !GetView().IsDrawSelMode())); 346 break; 347 348 case FN_FLIP_HORZ_GRAFIC: 349 if ( !pSdrView->IsMirrorAllowed() || bProtected ) 350 rSet.DisableItem( nWhich ); 351 break; 352 353 case FN_FLIP_VERT_GRAFIC: 354 if ( !pSdrView->IsMirrorAllowed() || bProtected ) 355 rSet.DisableItem( nWhich ); 356 break; 357 358 case SID_FONTWORK: 359 { 360 if (bProtected) 361 rSet.DisableItem( nWhich ); 362 else 363 { 364 const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); 365 rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId))); 366 } 367 } 368 break; 369 } 370 nWhich = aIter.NextWhich(); 371 } 372 svx::ExtrusionBar::getState( pSdrView, rSet ); 373 svx::FontworkBar::getState( pSdrView, rSet ); 374 } 375 376 /*-------------------------------------------------------------------- 377 Beschreibung: 378 --------------------------------------------------------------------*/ 379 380 381 382 SwDrawShell::SwDrawShell(SwView &_rView) : 383 SwDrawBaseShell(_rView) 384 { 385 SetHelpId(SW_DRAWSHELL); 386 SetName(String::CreateFromAscii("Draw")); 387 } 388 389 /************************************************************************* 390 |* 391 |* SfxRequests fuer FontWork bearbeiten 392 |* 393 \************************************************************************/ 394 395 396 397 void SwDrawShell::ExecFormText(SfxRequest& rReq) 398 { 399 SwWrtShell &rSh = GetShell(); 400 SdrView* pDrView = rSh.GetDrawView(); 401 sal_Bool bChanged = pDrView->GetModel()->IsChanged(); 402 pDrView->GetModel()->SetChanged(sal_False); 403 404 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 405 406 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) 407 { 408 const SfxItemSet& rSet = *rReq.GetArgs(); 409 const SfxPoolItem* pItem; 410 411 if ( pDrView->IsTextEdit() ) 412 { 413 pDrView->SdrEndTextEdit( sal_True ); 414 GetView().AttrChangedNotify(&rSh); 415 } 416 417 if ( rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem) == 418 SFX_ITEM_SET && 419 ((const XFormTextStdFormItem*) pItem)->GetValue() != XFTFORM_NONE ) 420 { 421 422 const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); 423 424 SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)(GetView().GetViewFrame()-> 425 GetChildWindow(nId)->GetWindow()); 426 427 pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(), 428 rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(), 429 ((const XFormTextStdFormItem*) pItem)-> 430 GetValue()); 431 432 } 433 else 434 pDrView->SetAttributes(rSet); 435 } 436 if (pDrView->GetModel()->IsChanged()) 437 rSh.SetModified(); 438 else 439 if (bChanged) 440 pDrView->GetModel()->SetChanged(sal_True); 441 } 442 443 /************************************************************************* 444 |* 445 |* Statuswerte fuer FontWork zurueckgeben 446 |* 447 \************************************************************************/ 448 449 450 451 void SwDrawShell::GetFormTextState(SfxItemSet& rSet) 452 { 453 SwWrtShell &rSh = GetShell(); 454 SdrView* pDrView = rSh.GetDrawView(); 455 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 456 const SdrObject* pObj = NULL; 457 SvxFontWorkDialog* pDlg = NULL; 458 459 const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); 460 461 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 462 if ( pVFrame->HasChildWindow(nId) ) 463 pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow()); 464 465 if ( rMarkList.GetMarkCount() == 1 ) 466 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 467 468 if ( pObj == NULL || !pObj->ISA(SdrTextObj) || 469 !((SdrTextObj*) pObj)->HasText() ) 470 { 471 #define XATTR_ANZ 12 472 static const sal_uInt16 nXAttr[ XATTR_ANZ ] = 473 { 474 XATTR_FORMTXTSTYLE, XATTR_FORMTXTADJUST, XATTR_FORMTXTDISTANCE, 475 XATTR_FORMTXTSTART, XATTR_FORMTXTMIRROR, XATTR_FORMTXTSTDFORM, 476 XATTR_FORMTXTHIDEFORM, XATTR_FORMTXTOUTLINE, XATTR_FORMTXTSHADOW, 477 XATTR_FORMTXTSHDWCOLOR, XATTR_FORMTXTSHDWXVAL, XATTR_FORMTXTSHDWYVAL 478 }; 479 for( sal_uInt16 i = 0; i < XATTR_ANZ; ) 480 rSet.DisableItem( nXAttr[ i++ ] ); 481 } 482 else 483 { 484 if ( pDlg ) 485 pDlg->SetColorTable(XColorTable::GetStdColorTable()); 486 487 pDrView->GetAttributes( rSet ); 488 } 489 } 490 491 492 493 494