1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #include <com/sun/star/container/XChild.hpp> 32 #include <com/sun/star/embed/XVisualObject.hpp> 33 #include <com/sun/star/embed/EmbedMisc.hpp> 34 #include <com/sun/star/embed/EmbedStates.hpp> 35 #include <com/sun/star/beans/XPropertySet.hpp> 36 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> 37 #include <com/sun/star/chart2/XChartDocument.hpp> 38 #include <com/sun/star/util/XModifiable.hpp> 39 40 #if STLPORT_VERSION>=321 41 #include <math.h> // prevent conflict between exception and std::exception 42 #endif 43 #include <hintids.hxx> 44 #include <svx/svdview.hxx> 45 #include <sot/factory.hxx> 46 #include <svl/itemiter.hxx> 47 #include <vcl/sound.hxx> 48 #include <tools/bigint.hxx> 49 #include <sot/storage.hxx> 50 #include <svtools/insdlg.hxx> 51 #include <sfx2/frmdescr.hxx> 52 #include <sfx2/ipclient.hxx> 53 #include <svtools/ehdl.hxx> 54 #include <svtools/soerr.hxx> 55 #include <tools/cachestr.hxx> 56 #include <unotools/moduleoptions.hxx> 57 #include <editeng/sizeitem.hxx> 58 #include <editeng/brkitem.hxx> 59 #include <editeng/svxacorr.hxx> 60 #include <vcl/graph.hxx> 61 #include <sfx2/printer.hxx> 62 #include <unotools/charclass.hxx> 63 #include <comphelper/storagehelper.hxx> 64 #include <svx/svxdlg.hxx> 65 #include <svx/extrusionbar.hxx> 66 #include <svx/fontworkbar.hxx> 67 #include <frmfmt.hxx> 68 #include <fmtftn.hxx> 69 #include <fmtpdsc.hxx> 70 #include <wdocsh.hxx> 71 #include <basesh.hxx> 72 #include <swmodule.hxx> 73 #include <wrtsh.hxx> 74 #include <view.hxx> 75 #include <uitool.hxx> 76 #include <cmdid.h> 77 #include <cfgitems.hxx> 78 #include <pagedesc.hxx> 79 #include <frmmgr.hxx> 80 #include <shellio.hxx> 81 #include <uinums.hxx> // fuer Anwenden einer 82 #include <swundo.hxx> // fuer Undo-Ids 83 #include <swcli.hxx> 84 #include <poolfmt.hxx> 85 #include <wview.hxx> 86 #include <edtwin.hxx> 87 #include <fmtcol.hxx> 88 #include <swtable.hxx> 89 #include <caption.hxx> 90 #include <viscrs.hxx> 91 #include <swdtflvr.hxx> 92 #include <crsskip.hxx> 93 #include <doc.hxx> 94 #include <wrtsh.hrc> 95 #include <SwStyleNameMapper.hxx> 96 #include <sfx2/request.hxx> 97 #include <paratr.hxx> 98 #include <ndtxt.hxx> 99 #include <editeng/acorrcfg.hxx> 100 #include <IMark.hxx> 101 #include <sfx2/bindings.hxx> 102 103 // -> #111827# 104 #include <SwRewriter.hxx> 105 #include <comcore.hrc> 106 // <- #111827# 107 108 #include <toolkit/helper/vclunohelper.hxx> 109 #include <sfx2/viewfrm.hxx> 110 111 #include <editeng/acorrcfg.hxx> 112 113 #include "PostItMgr.hxx" 114 #include <sfx2/msgpool.hxx> 115 116 using namespace sw::mark; 117 using namespace com::sun::star; 118 119 #define COMMON_INI_LIST \ 120 fnDrag(&SwWrtShell::BeginDrag),\ 121 fnSetCrsr(&SwWrtShell::SetCrsr),\ 122 fnEndDrag(&SwWrtShell::EndDrag),\ 123 fnKillSel(&SwWrtShell::Ignore),\ 124 pModeStack(0), \ 125 ePageMove(MV_NO),\ 126 pCrsrStack(0), \ 127 rView(rShell),\ 128 bDestOnStack(sal_False), \ 129 fnLeaveSelect(&SwWrtShell::SttLeaveSelect) 130 131 #define BITFLD_INI_LIST \ 132 bClearMark = \ 133 bIns = sal_True;\ 134 bAddMode = \ 135 bBlockMode = \ 136 bExtMode = \ 137 bInSelect = \ 138 bCopy = \ 139 bLayoutMode = \ 140 bNoEdit = \ 141 bSelWrd = \ 142 bSelLn = \ 143 bIsInClickToEdit = \ 144 mbRetainSelection = sal_False; 145 146 147 SvxAutoCorrect* lcl_IsAutoCorr() 148 { 149 SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get()->GetAutoCorrect(); 150 if( pACorr && !pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd | 151 AddNonBrkSpace | ChgOrdinalNumber | 152 ChgToEnEmDash | SetINetAttr | Autocorrect )) 153 pACorr = 0; 154 return pACorr; 155 } 156 157 void SwWrtShell::NoEdit(sal_Bool bHideCrsr) 158 { 159 if(bHideCrsr) 160 HideCrsr(); 161 bNoEdit = sal_True; 162 } 163 164 165 166 void SwWrtShell::Edit() 167 { 168 if (CanInsert()) 169 { 170 ShowCrsr(); 171 bNoEdit = sal_False; 172 } 173 } 174 175 176 177 sal_Bool SwWrtShell::IsEndWrd() 178 { 179 MV_KONTEXT(this); 180 if(IsEndPara() && !IsSttPara()) 181 return sal_True; 182 183 return IsEndWord(); 184 } 185 186 187 /*------------------------------------------------------------------------ 188 Beschreibung: Abfrage, ob Einfuegen moeglich ist; gfs. Beep 189 ------------------------------------------------------------------------*/ 190 191 192 193 sal_Bool SwWrtShell::_CanInsert() 194 { 195 if(!CanInsert()) 196 { 197 Sound::Beep(); 198 return sal_False; 199 } 200 return sal_True; 201 } 202 /*------------------------------------------------------------------------ 203 Beschreibung: String einfuegen 204 ------------------------------------------------------------------------*/ 205 206 void SwWrtShell::InsertByWord( const String & rStr) 207 { 208 if( rStr.Len() ) 209 { 210 sal_Bool bDelim = GetAppCharClass().isLetterNumeric( rStr, 0 ); 211 xub_StrLen nPos = 0, nStt = 0; 212 for( ; nPos < rStr.Len(); nPos++ ) 213 { 214 sal_Bool bTmpDelim = GetAppCharClass().isLetterNumeric( rStr, nPos ); 215 if( bTmpDelim != bDelim ) 216 { 217 Insert( rStr.Copy( nStt, nPos - nStt )); 218 nStt = nPos; 219 } 220 } 221 if( nStt != nPos ) 222 Insert( rStr.Copy( nStt, nPos - nStt )); 223 } 224 } 225 226 227 void SwWrtShell::Insert( const String &rStr ) 228 { 229 ResetCursorStack(); 230 if( !_CanInsert() ) 231 return; 232 233 sal_Bool bStarted = sal_False, bHasSel = HasSelection(), 234 bCallIns = bIns /*|| bHasSel*/; 235 bool bDeleted = false; 236 237 if( bHasSel || ( !bIns && SelectHiddenRange() ) ) 238 { 239 // nur hier klammern, da das normale Insert schon an der 240 // Editshell geklammert ist 241 StartAllAction(); 242 243 // #111827# 244 SwRewriter aRewriter; 245 246 aRewriter.AddRule(UNDO_ARG1, GetCrsrDescr()); 247 aRewriter.AddRule(UNDO_ARG2, String(SW_RES(STR_YIELDS))); 248 { 249 String aTmpStr; 250 aTmpStr += String(SW_RES(STR_START_QUOTE)); 251 aTmpStr += rStr; 252 aTmpStr += String(SW_RES(STR_END_QUOTE)); 253 254 aRewriter.AddRule(UNDO_ARG3, rStr); 255 } 256 257 StartUndo(UNDO_REPLACE, &aRewriter); 258 bStarted = sal_True; 259 bDeleted = DelRight() != 0; 260 } 261 262 /* 263 JP 21.01.98: Ueberschreiben ueberschreibt nur die Selektion, nicht das 264 naechste Zeichen. 265 if( bHasSel && !bIns && 1 < rStr.Len() ) 266 { 267 // falls mehrere Zeichen anstehen, nur das erste einfuegen, 268 // der Rest muss dann aber Ueberschrieben werden. 269 SwEditShell::Insert( rStr.GetChar( 0 ) ); 270 SwEditShell::Overwrite( rStr.Copy( 1 ) ); 271 } 272 else 273 */ 274 bCallIns ? 275 SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr ); 276 277 278 if( bStarted ) 279 { 280 EndAllAction(); 281 EndUndo(); 282 } 283 // delete pChgFlg; 284 } 285 286 /* Begrenzung auf maximale Hoehe geht nicht, da die maximale Hoehe 287 * des aktuellen Frames nicht erfragt werden kann. */ 288 289 290 291 void SwWrtShell::Insert( const String &rPath, const String &rFilter, 292 const Graphic &rGrf, SwFlyFrmAttrMgr *pFrmMgr, 293 sal_Bool bRule ) 294 { 295 ResetCursorStack(); 296 if ( !_CanInsert() ) 297 return; 298 299 StartAllAction(); 300 301 SwRewriter aRewriter; 302 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_GRAPHIC)); 303 304 StartUndo(UNDO_INSERT, &aRewriter); 305 306 if ( HasSelection() ) 307 DelRight(); 308 // eingefuegte Grafik in eigenen Absatz, falls am Ende 309 // eines nichtleeren Absatzes 310 if ( IsEndPara() && !IsSttPara() ) 311 SwFEShell::SplitNode(); 312 313 EnterSelFrmMode(); 314 315 sal_Bool bSetGrfSize = sal_True; 316 sal_Bool bOwnMgr = sal_False; 317 318 if ( !pFrmMgr ) 319 { 320 bOwnMgr = sal_True; 321 pFrmMgr = new SwFlyFrmAttrMgr( sal_True, this, FRMMGR_TYPE_GRF ); 322 323 // VORSICHT 324 // GetAttrSet nimmt einen Abgleich vor 325 // Beim Einfuegen ist eine SwFrmSize vorhanden wegen der 326 // DEF-Rahmengroesse 327 // Diese muss fuer die optimale Groesse explizit entfernt werden 328 pFrmMgr->DelAttr(RES_FRM_SIZE); 329 } 330 else 331 { 332 Size aSz( pFrmMgr->GetSize() ); 333 if ( !aSz.Width() || !aSz.Height() ) 334 { 335 aSz.Width() = aSz.Height() = 567; 336 pFrmMgr->SetSize( aSz ); 337 } 338 else if ( aSz.Width() != DFLT_WIDTH && aSz.Height() != DFLT_HEIGHT ) 339 bSetGrfSize = sal_False; 340 341 pFrmMgr->SetHeightSizeType(ATT_FIX_SIZE); 342 343 } 344 345 // Einfuegen der Grafik 346 SwFEShell::Insert(rPath, rFilter, &rGrf, &pFrmMgr->GetAttrSet()); 347 if ( bOwnMgr ) 348 pFrmMgr->UpdateAttrMgr(); 349 350 if( bSetGrfSize && !bRule ) 351 { 352 Size aGrfSize, aBound = GetGraphicDefaultSize(); 353 GetGrfSize( aGrfSize ); 354 355 //Die GrafikSize noch um die Randattribute vergroessern, denn die 356 //Zaehlen beim Rahmen mit. 357 aGrfSize.Width() += pFrmMgr->CalcWidthBorder(); 358 aGrfSize.Height()+= pFrmMgr->CalcHeightBorder(); 359 360 const BigInt aTempWidth( aGrfSize.Width() ); 361 const BigInt aTempHeight( aGrfSize.Height()); 362 363 // ggf. Breite anpassen, Hoehe dann proportional verkleinern 364 if( aGrfSize.Width() > aBound.Width() ) 365 { 366 aGrfSize.Width() = aBound.Width(); 367 aGrfSize.Height() = ((BigInt)aBound.Width()) * aTempHeight / aTempWidth; 368 } 369 // ggf. Hoehe anpassen, Breite dann proportional verkleinern 370 if( aGrfSize.Height() > aBound.Height() ) 371 { 372 aGrfSize.Height() = aBound.Height(); 373 aGrfSize.Width() = ((BigInt)aBound.Height()) * aTempWidth / aTempHeight; 374 } 375 pFrmMgr->SetSize( aGrfSize ); 376 pFrmMgr->UpdateFlyFrm(); 377 } 378 if ( bOwnMgr ) 379 delete pFrmMgr; 380 381 EndUndo(); 382 EndAllAction(); 383 } 384 385 386 /*------------------------------------------------------------------------ 387 Beschreibung: Fuegt ein OLE-Objekt in die CORE ein. 388 Wenn kein Object uebergeben wird, so wird eins erzeugt. 389 ------------------------------------------------------------------------*/ 390 391 392 void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName *pName, 393 sal_Bool bActivate, sal_uInt16 nSlotId ) 394 { 395 ResetCursorStack(); 396 if( !_CanInsert() ) 397 return; 398 399 if( !xRef.is() ) 400 { 401 // temporary storage 402 svt::EmbeddedObjectRef xObj; 403 uno::Reference < embed::XStorage > xStor = comphelper::OStorageHelper::GetTemporaryStorage(); 404 sal_Bool bDoVerb = sal_True; 405 if ( pName ) 406 { 407 comphelper::EmbeddedObjectContainer aCnt( xStor ); 408 ::rtl::OUString aName; 409 // TODO/LATER: get aspect? 410 xObj.Assign( aCnt.CreateEmbeddedObject( pName->GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT ); 411 } 412 else 413 { 414 SvObjectServerList aServerList; 415 switch (nSlotId) 416 { 417 case SID_INSERT_OBJECT: 418 { 419 aServerList.FillInsertObjects(); 420 aServerList.Remove( SwDocShell::Factory().GetClassId() ); 421 // Intentionally no break! 422 } 423 424 // TODO/LATER: recording! Convert properties to items 425 case SID_INSERT_PLUGIN: 426 /* 427 if(pReq) 428 { 429 INetURLObject* pURL = aDlg.GetURL(); 430 if(pURL) 431 pReq->AppendItem(SfxStringItem(FN_PARAM_2, pURL->GetMainURL(INetURLObject::NO_DECODE))); 432 pReq->AppendItem(SfxStringItem(FN_PARAM_3 , aDlg.GetCommands())); 433 } */ 434 case SID_INSERT_FLOATINGFRAME: 435 /* 436 if(pReq && xFloatingFrame.Is()) 437 { 438 const SfxFrameDescriptor* pDescriptor = xFloatingFrame->GetFrameDescriptor(); 439 pReq->AppendItem(SfxStringItem(FN_PARAM_1, pDescriptor->GetName())); 440 pReq->AppendItem( 441 SfxStringItem( FN_PARAM_2, 442 pDescriptor->GetURL().GetMainURL(INetURLObject::NO_DECODE))); 443 pReq->AppendItem(SvxSizeItem(FN_PARAM_3, pDescriptor->GetMargin())); 444 pReq->AppendItem(SfxByteItem(FN_PARAM_4, pDescriptor->GetScrollingMode())); 445 pReq->AppendItem(SfxBoolItem(FN_PARAM_5, pDescriptor->HasFrameBorder())); 446 }*/ 447 { 448 SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool(); 449 const SfxSlot* pSlot = pSlotPool->GetSlot(nSlotId); 450 rtl::OString aCmd(".uno:"); 451 aCmd += pSlot->GetUnoName(); 452 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 453 SfxAbstractInsertObjectDialog* pDlg = 454 pFact->CreateInsertObjectDialog( GetWin(), rtl::OUString( aCmd, aCmd.getLength(), RTL_TEXTENCODING_UTF8 ), xStor, &aServerList ); 455 if ( pDlg ) 456 { 457 pDlg->Execute(); 458 bDoVerb = pDlg->IsCreateNew(); 459 ::rtl::OUString aIconMediaType; 460 uno::Reference< io::XInputStream > xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType ); 461 xObj.Assign( pDlg->GetObject(), 462 xIconMetaFile.is() ? embed::Aspects::MSOLE_ICON : embed::Aspects::MSOLE_CONTENT ); 463 if ( xIconMetaFile.is() ) 464 xObj.SetGraphicStream( xIconMetaFile, aIconMediaType ); 465 466 DELETEZ( pDlg ); 467 } 468 469 break; 470 } 471 472 default: 473 break; 474 } 475 } 476 477 if ( xObj.is() ) 478 { 479 if( InsertOleObject( xObj ) && bActivate && bDoVerb ) 480 { 481 SfxInPlaceClient* pClient = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() ); 482 if ( !pClient ) 483 { 484 pClient = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj ); 485 SetCheckForOLEInCaption( sal_True ); 486 } 487 488 if ( xObj.GetViewAspect() == embed::Aspects::MSOLE_ICON ) 489 { 490 SwRect aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ); 491 aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos(); 492 MapMode aMapMode( MAP_TWIP ); 493 Size aSize = xObj.GetSize( &aMapMode ); 494 aArea.Width( aSize.Width() ); 495 aArea.Height( aSize.Height() ); 496 RequestObjectResize( aArea, xObj.GetObject() ); 497 } 498 else 499 CalcAndSetScale( xObj ); 500 501 //#50270# Error brauchen wir nicht handeln, das erledigt das 502 //DoVerb in der SfxViewShell 503 pClient->DoVerb( SVVERB_SHOW ); 504 505 // TODO/LATER: set document name - should be done in Client 506 //if ( !ERRCODE_TOERROR( nErr ) ) 507 // xIPObj->SetDocumentName( GetView().GetDocShell()->GetTitle() ); 508 } 509 } 510 } 511 else 512 { 513 if( HasSelection() ) 514 DelRight(); 515 InsertOleObject( xRef ); 516 } 517 } 518 519 /*------------------------------------------------------------------------ 520 Beschreibung: Object in die Core einfuegen. 521 Vom ClipBoard oder Insert 522 ------------------------------------------------------------------------*/ 523 524 sal_Bool SwWrtShell::InsertOleObject( const svt::EmbeddedObjectRef& xRef, SwFlyFrmFmt **pFlyFrmFmt ) 525 { 526 ResetCursorStack(); 527 StartAllAction(); 528 529 StartUndo(UNDO_INSERT); 530 531 //Some differences between StarMath and any other objects: 532 //1. Selections should be deleted. For StarMath the Text should be 533 // passed to the Object 534 //2. If the cursor is at the end of an non empty paragraph a paragraph 535 // break should be insertet. StarMath objects are character bound and 536 // no break should be inserted. 537 //3. If an selektion is passed to a StarMath object, this object should 538 // not be activated. sal_False should be returned then. 539 sal_Bool bStarMath = sal_True; 540 sal_Bool bActivate = sal_True; 541 542 // set parent to get correct VisArea(in case of object needing parent printer) 543 uno::Reference < container::XChild > xChild( xRef.GetObject(), uno::UNO_QUERY ); 544 if ( xChild.is() ) 545 xChild->setParent( pDoc->GetDocShell()->GetModel() ); 546 547 SvGlobalName aCLSID( xRef->getClassID() ); 548 bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 ); 549 if( IsSelection() ) 550 { 551 if( bStarMath ) 552 { 553 String aMathData; 554 GetSelectedText( aMathData, GETSELTXT_PARABRK_TO_ONLYCR ); 555 556 if( aMathData.Len() && svt::EmbeddedObjectRef::TryRunningState( xRef.GetObject() ) ) 557 { 558 uno::Reference < beans::XPropertySet > xSet( xRef->getComponent(), uno::UNO_QUERY ); 559 if ( xSet.is() ) 560 { 561 try 562 { 563 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("Formula"), uno::makeAny( ::rtl::OUString( aMathData ) ) ); 564 bActivate = sal_False; 565 } 566 catch ( uno::Exception& ) 567 { 568 } 569 } 570 } 571 } 572 DelRight(); 573 } 574 575 if ( !bStarMath ) 576 SwFEShell::SplitNode( sal_False, sal_False ); 577 578 EnterSelFrmMode(); 579 580 SwFlyFrmAttrMgr aFrmMgr( sal_True, this, FRMMGR_TYPE_OLE ); 581 aFrmMgr.SetHeightSizeType(ATT_FIX_SIZE); 582 583 SwRect aBound; 584 CalcBoundRect( aBound, aFrmMgr.GetAnchor() ); 585 586 //The Size should be suggested by the OLE server 587 MapMode aMapMode( MAP_TWIP ); 588 Size aSz = xRef.GetSize( &aMapMode ); 589 590 //Object size can be limited 591 if ( aSz.Width() > aBound.Width() ) 592 { 593 //Immer proportional begrenzen. 594 aSz.Height() = aSz.Height() * aBound.Width() / aSz.Width(); 595 aSz.Width() = aBound.Width(); 596 } 597 aFrmMgr.SetSize( aSz ); 598 SwFlyFrmFmt *pFmt = SwFEShell::InsertObject( xRef, &aFrmMgr.GetAttrSet() ); 599 600 // --> #i972# 601 if ( bStarMath && pDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) ) 602 AlignFormulaToBaseline( xRef.GetObject() ); 603 // <-- 604 605 if (pFlyFrmFmt) 606 *pFlyFrmFmt = pFmt; 607 608 if ( SotExchange::IsChart( aCLSID ) ) 609 { 610 uno::Reference< embed::XEmbeddedObject > xEmbeddedObj( xRef.GetObject(), uno::UNO_QUERY ); 611 if ( xEmbeddedObj.is() ) 612 { 613 bool bDisableDataTableDialog = false; 614 svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj ); 615 uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY ); 616 if ( xProps.is() && 617 ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) && 618 bDisableDataTableDialog ) 619 { 620 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ), 621 uno::makeAny( sal_False ) ); 622 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ), 623 uno::makeAny( sal_False ) ); 624 uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY ); 625 if ( xModifiable.is() ) 626 { 627 xModifiable->setModified( sal_True ); 628 } 629 } 630 } 631 } 632 633 EndAllAction(); 634 GetView().AutoCaption(OLE_CAP, &aCLSID); 635 636 SwRewriter aRewriter; 637 638 if ( bStarMath ) 639 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_MATH_FORMULA)); 640 else if ( SotExchange::IsChart( aCLSID ) ) 641 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_CHART)); 642 else 643 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_OLE)); 644 645 EndUndo(UNDO_INSERT, &aRewriter); 646 647 return bActivate; 648 } 649 650 /*------------------------------------------------------------------------ 651 Beschreibung: Das aktuelle selektierte OLE-Objekt wird mit dem 652 Verb in den Server geladen. 653 ------------------------------------------------------------------------*/ 654 655 656 657 void SwWrtShell::LaunchOLEObj( long nVerb ) 658 { 659 if ( GetCntType() == CNT_OLE && 660 !GetView().GetViewFrame()->GetFrame().IsInPlace() ) 661 { 662 svt::EmbeddedObjectRef& xRef = GetOLEObject(); 663 ASSERT( xRef.is(), "OLE not found" ); 664 SfxInPlaceClient* pCli=0; 665 666 pCli = GetView().FindIPClient( xRef.GetObject(), &GetView().GetEditWin() ); 667 if ( !pCli ) 668 pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xRef ); 669 670 ((SwOleClient*)pCli)->SetInDoVerb( sal_True ); 671 672 CalcAndSetScale( xRef ); 673 pCli->DoVerb( nVerb ); 674 675 ((SwOleClient*)pCli)->SetInDoVerb( sal_False ); 676 CalcAndSetScale( xRef ); 677 } 678 } 679 680 void SwWrtShell::MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset ) 681 { 682 try 683 { 684 sal_Int32 nState = xObj->getCurrentState(); 685 if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE 686 || nState == ::com::sun::star::embed::EmbedStates::UI_ACTIVE ) 687 { 688 SfxInPlaceClient* pCli = 689 GetView().FindIPClient( xObj.GetObject(), &(GetView().GetEditWin()) ); 690 if ( pCli ) 691 { 692 Rectangle aArea = pCli->GetObjArea(); 693 aArea += rOffset; 694 pCli->SetObjArea( aArea ); 695 } 696 } 697 } 698 catch( uno::Exception& ) 699 {} 700 } 701 702 703 void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj, 704 const SwRect *pFlyPrtRect, 705 const SwRect *pFlyFrmRect ) 706 { 707 //Einstellen der Skalierung am Client. Diese ergibt sich aus der Differenz 708 //zwischen der VisArea des Objektes und der ObjArea. 709 ASSERT( xObj.is(), "ObjectRef not valid" ); 710 711 sal_Int64 nAspect = xObj.GetViewAspect(); 712 if ( nAspect == embed::Aspects::MSOLE_ICON ) 713 return; // the replacement image is completely controlled by container in this case 714 715 sal_Int64 nMisc = 0; 716 sal_Bool bLinkingChart = sal_False; 717 718 try 719 { 720 nMisc = xObj->getStatus( nAspect ); 721 722 //Das kann ja wohl nur ein nicht aktives Objekt sein. Diese bekommen 723 //auf Wunsch die neue Groesse als VisArea gesetzt (StarChart) 724 if( embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE & nMisc ) 725 { 726 // TODO/MBA: testing 727 SwRect aRect( pFlyPrtRect ? *pFlyPrtRect 728 : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() )); 729 if( !aRect.IsEmpty() ) 730 { 731 // TODO/LEAN: getMapUnit can switch object to running state 732 // xObj.TryRunningState(); 733 734 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); 735 736 // TODO/LATER: needs complete VisArea?! 737 Size aSize( OutputDevice::LogicToLogic( aRect.SVRect(), MAP_TWIP, aUnit ).GetSize() ); 738 awt::Size aSz; 739 aSz.Width = aSize.Width(); 740 aSz.Height = aSize.Height(); 741 xObj->setVisualAreaSize( nAspect, aSz ); 742 // --> OD 2005-05-02 #i48419# - action 'UpdateReplacement' doesn't 743 // have to change the modified state of the document. 744 // This is only a workaround for the defect, that this action 745 // modifies a document after load, because unnecessarily the 746 // replacement graphic is updated, in spite of the fact that 747 // nothing has been changed. 748 // If the replacement graphic changes by this action, the document 749 // will be already modified via other mechanisms. 750 { 751 bool bResetEnableSetModified(false); 752 if ( GetDoc()->GetDocShell()->IsEnableSetModified() ) 753 { 754 GetDoc()->GetDocShell()->EnableSetModified( sal_False ); 755 bResetEnableSetModified = true; 756 } 757 758 //#i79576# don't destroy chart replacement images on load 759 //#i79578# don't request a new replacement image for charts to often 760 //a chart sends a modified call to the framework if it was changed 761 //thus the replacement update is already handled elsewhere 762 if ( !SotExchange::IsChart( xObj->getClassID() ) ) 763 xObj.UpdateReplacement(); 764 765 if ( bResetEnableSetModified ) 766 { 767 GetDoc()->GetDocShell()->EnableSetModified( sal_True ); 768 } 769 } 770 // <-- 771 } 772 773 // TODO/LATER: this is only a workaround, 774 uno::Reference< chart2::XChartDocument > xChartDocument( xObj->getComponent(), uno::UNO_QUERY ); 775 bLinkingChart = ( xChartDocument.is() && !xChartDocument->hasInternalDataProvider() ); 776 } 777 } 778 catch ( uno::Exception& ) 779 { 780 // TODO/LATER: handle the error 781 return; 782 } 783 784 SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() ); 785 if ( !pCli ) 786 { 787 if ( (embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY & nMisc) || bLinkingChart 788 // TODO/LATER: ResizeOnPrinterChange 789 //|| SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->GetMiscStatus() 790 || nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE // non-resizable objects need to be 791 // set the size back by this method 792 ) 793 { 794 pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj ); 795 } 796 else 797 return; 798 } 799 800 // TODO/LEAN: getMapUnit can switch object to running state 801 // xObj.TryRunningState(); 802 803 awt::Size aSize; 804 try 805 { 806 aSize = xObj->getVisualAreaSize( nAspect ); 807 } 808 catch( embed::NoVisualAreaSizeException& ) 809 { 810 DBG_ERROR( "Can't get visual area size!\n" ); 811 // the scaling will not be done 812 } 813 catch( uno::Exception& ) 814 { 815 // TODO/LATER: handle the error 816 DBG_ERROR( "Can't get visual area size!\n" ); 817 return; 818 } 819 820 Size _aVisArea( aSize.Width, aSize.Height ); 821 822 Fraction aScaleWidth( 1, 1 ); 823 Fraction aScaleHeight( 1, 1 ); 824 825 sal_Bool bUseObjectSize = sal_False; 826 827 // solange keine vernuenftige Size vom Object kommt, kann nichts 828 // skaliert werden 829 if( _aVisArea.Width() && _aVisArea.Height() ) 830 { 831 const MapMode aTmp( MAP_TWIP ); 832 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); 833 _aVisArea = OutputDevice::LogicToLogic( _aVisArea, aUnit, aTmp); 834 Size aObjArea; 835 if ( pFlyPrtRect ) 836 aObjArea = pFlyPrtRect->SSize(); 837 else 838 aObjArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ).SSize(); 839 840 // differ the aObjArea and _aVisArea by 1 Pixel then set new VisArea 841 long nX, nY; 842 SwSelPaintRects::Get1PixelInLogic( *this, &nX, &nY ); 843 if( !( _aVisArea.Width() - nX <= aObjArea.Width() && 844 _aVisArea.Width() + nX >= aObjArea.Width() && 845 _aVisArea.Height()- nY <= aObjArea.Height()&& 846 _aVisArea.Height()+ nY >= aObjArea.Height() )) 847 { 848 // TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE 849 /* 850 if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & nMisc ) 851 { 852 //This type of objects should never be resized. 853 //If this request comes from the Writer core (inaktive Object 854 //ist resized), the Object should be resized too. 855 //If this request comes from the Object itself, the Frame 856 //in the Writer core should be resized. 857 if ( pFlyPrtRect ) //Request from core? 858 { 859 xObj->SetVisArea( OutputDevice::LogicToLogic( 860 pFlyPrtRect->SVRect(), MAP_TWIP, xObj->GetMapUnit() )); 861 } 862 else 863 { 864 SwRect aTmp( Point( LONG_MIN, LONG_MIN ), _aVisArea ); 865 RequestObjectResize( aTmp, xObj ); 866 } 867 //Der Rest erledigt sich, weil wir eh wiederkommen sollten, evtl. 868 //sogar rekursiv. 869 return; 870 } 871 else*/ 872 873 if ( nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE ) 874 { 875 // the object must not be scaled, the size stored in object must be used for restoring 876 bUseObjectSize = sal_True; 877 } 878 else 879 { 880 aScaleWidth = Fraction( aObjArea.Width(), _aVisArea.Width() ); 881 aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height()); 882 } 883 } 884 } 885 886 //Jetzt ist auch der guenstige Zeitpunkt die ObjArea einzustellen. 887 //Die Scalierung muss beruecksichtigt werden. 888 SwRect aArea; 889 if ( pFlyPrtRect ) 890 { 891 aArea = *pFlyPrtRect; 892 aArea += pFlyFrmRect->Pos(); 893 } 894 else 895 { 896 aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ); 897 aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos(); 898 } 899 900 if ( bUseObjectSize ) 901 { 902 // --> this moves non-resizable object so that when adding borders the baseline remains the same 903 const SwFlyFrmFmt *pFlyFrmFmt = dynamic_cast< const SwFlyFrmFmt * >( GetFlyFrmFmt() ); 904 ASSERT( pFlyFrmFmt, "Could not find fly frame." ); 905 if ( pFlyFrmFmt ) 906 { 907 const Point &rPoint = pFlyFrmFmt->GetLastFlyFrmPrtRectPos(); 908 SwRect aRect( pFlyPrtRect ? *pFlyPrtRect 909 : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() )); 910 aArea += rPoint - aRect.Pos(); // adjust area by diff of printing area position in order to keep baseline alignment correct. 911 } 912 // <-- 913 aArea.Width ( _aVisArea.Width() ); 914 aArea.Height( _aVisArea.Height() ); 915 RequestObjectResize( aArea, xObj.GetObject() ); 916 } 917 else 918 { 919 aArea.Width ( Fraction( aArea.Width() ) / pCli->GetScaleWidth() ); 920 aArea.Height( Fraction( aArea.Height() ) / pCli->GetScaleHeight()); 921 } 922 923 pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight ); 924 } 925 926 927 928 void SwWrtShell::ConnectObj( svt::EmbeddedObjectRef& xObj, const SwRect &rPrt, 929 const SwRect &rFrm ) 930 { 931 SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin()); 932 if ( !pCli ) 933 pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj ); 934 CalcAndSetScale( xObj, &rPrt, &rFrm ); 935 } 936 937 /*------------------------------------------------------------------------ 938 Beschreibung: Einfuegen harter Seitenumbruch; 939 Selektionen werden ueberschrieben 940 ------------------------------------------------------------------------*/ 941 942 943 944 void SwWrtShell::InsertPageBreak(const String *pPageDesc, sal_uInt16 nPgNum ) 945 { 946 ResetCursorStack(); 947 if( _CanInsert() ) 948 { 949 ACT_KONTEXT(this); 950 StartUndo(UNDO_UI_INSERT_PAGE_BREAK); 951 952 if ( !IsCrsrInTbl() ) 953 { 954 if(HasSelection()) 955 DelRight(); 956 SwFEShell::SplitNode(); 957 } 958 959 const SwPageDesc *pDesc = pPageDesc 960 ? FindPageDescByName( *pPageDesc, sal_True ) : 0; 961 if( pDesc ) 962 { 963 SwFmtPageDesc aDesc( pDesc ); 964 aDesc.SetNumOffset( nPgNum ); 965 SetAttr( aDesc ); 966 } 967 else 968 SetAttr( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) ); 969 EndUndo(UNDO_UI_INSERT_PAGE_BREAK); 970 } 971 } 972 /*------------------------------------------------------------------------ 973 Beschreibung: Einfuegen harter Zeilenumbruch; 974 Selektionen werden ueberschrieben 975 ------------------------------------------------------------------------*/ 976 977 978 void SwWrtShell::InsertLineBreak() 979 { 980 ResetCursorStack(); 981 if( _CanInsert() ) 982 { 983 if(HasSelection()) 984 DelRight(); 985 986 const sal_Unicode cIns = 0x0A; 987 SvxAutoCorrect* pACorr = lcl_IsAutoCorr(); 988 if( pACorr ) 989 AutoCorrect( *pACorr, cIns ); 990 else 991 SwWrtShell::Insert( String( cIns ) ); 992 } 993 } 994 /*------------------------------------------------------------------------ 995 Beschreibung: Einfuegen harter Spaltenumbruch; 996 Selektionen werden ueberschrieben 997 ------------------------------------------------------------------------*/ 998 999 1000 void SwWrtShell::InsertColumnBreak() 1001 { 1002 ACT_KONTEXT(this); 1003 ResetCursorStack(); 1004 if( _CanInsert() ) 1005 { 1006 StartUndo(UNDO_UI_INSERT_COLUMN_BREAK); 1007 1008 if ( !IsCrsrInTbl() ) 1009 { 1010 if(HasSelection()) 1011 DelRight(); 1012 SwFEShell::SplitNode( sal_False, sal_False ); 1013 } 1014 SetAttr(SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK)); 1015 1016 EndUndo(UNDO_UI_INSERT_COLUMN_BREAK); 1017 } 1018 } 1019 1020 /*------------------------------------------------------------------------ 1021 Beschreibung: Einfuegen Fussnote 1022 Parameter: rStr -- optionales Fussnotenzeichen 1023 ------------------------------------------------------------------------*/ 1024 1025 1026 void SwWrtShell::InsertFootnote(const String &rStr, sal_Bool bEndNote, sal_Bool bEdit ) 1027 { 1028 ResetCursorStack(); 1029 if( _CanInsert() ) 1030 { 1031 if(HasSelection()) 1032 { 1033 //collapse cursor to the end 1034 if(!IsCrsrPtAtEnd()) 1035 SwapPam(); 1036 ClearMark(); 1037 } 1038 1039 SwFmtFtn aFootNote( bEndNote ); 1040 if(rStr.Len()) 1041 aFootNote.SetNumStr( rStr ); 1042 1043 SetAttr(aFootNote); 1044 1045 if( bEdit ) 1046 { 1047 // zur Bearbeiung des Fussnotentextes 1048 Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 1049 GotoFtnTxt(); 1050 } 1051 } 1052 } 1053 /*------------------------------------------------------------------------ 1054 Beschreibung: SplitNode; hier auch, da 1055 - selektierter Inhalt geloescht wird; 1056 - der Cursorstack gfs. zurueckgesetzt wird. 1057 ------------------------------------------------------------------------*/ 1058 1059 1060 void SwWrtShell::SplitNode( sal_Bool bAutoFmt, sal_Bool bCheckTableStart ) 1061 { 1062 ResetCursorStack(); 1063 if( _CanInsert() ) 1064 { 1065 ACT_KONTEXT(this); 1066 1067 rView.GetEditWin().FlushInBuffer(); 1068 sal_Bool bHasSel = HasSelection(); 1069 if( bHasSel ) 1070 { 1071 StartUndo( UNDO_INSERT ); 1072 DelRight(); 1073 } 1074 1075 SwFEShell::SplitNode( bAutoFmt, bCheckTableStart ); 1076 if( bHasSel ) 1077 EndUndo( UNDO_INSERT ); 1078 } 1079 } 1080 1081 /*------------------------------------------------------------------------ 1082 Beschreibung: Numerierung anschalten 1083 Parameter: Optionale Angabe eines Namens fuer die benannte Liste; 1084 dieser bezeichnet eine Position, wenn er in eine 1085 Zahl konvertierbar ist und kleiner ist als nMaxRules. 1086 -------------------------------------------------------------------------*/ 1087 1088 1089 // zum Testen der CharFormate an der Numerierung 1090 // extern void SetNumChrFmt( SwWrtShell*, SwNumRules& ); 1091 1092 // -> #i40041# 1093 // --> OD 2005-10-25 #b6340308# 1094 // Preconditions (as far as OD has figured out): 1095 // - <SwEditShell::HasNumber()> is sal_False, if <bNum> is sal_True 1096 // - <SwEditShell::HasBullet()> is sal_False, if <bNum> is sal_False 1097 // Behavior of method is determined by the current situation at the current 1098 // cursor position in the document. 1099 void SwWrtShell::NumOrBulletOn(sal_Bool bNum) 1100 { 1101 // determine numbering rule found at current cursor position in the docment. 1102 const SwNumRule* pCurRule = GetCurNumRule(); 1103 1104 StartUndo(UNDO_NUMORNONUM); 1105 1106 const SwNumRule * pNumRule = pCurRule; 1107 1108 // --> OD 2005-10-25 #b6340308# 1109 // - activate outline rule respectively turning on outline rule for 1110 // current text node. But, only for turning on a numbering (<bNum> == sal_True). 1111 // - overwrite found numbering rule at current cursor position, if 1112 // no numbering rule can be retrieved from the paragraph style. 1113 bool bContinueFoundNumRule( false ); 1114 bool bActivateOutlineRule( false ); 1115 int nActivateOutlineLvl( MAXLEVEL ); // only relevant, if <bActivateOutlineRule> == sal_True 1116 SwTxtFmtColl * pColl = GetCurTxtFmtColl(); 1117 if ( pColl ) 1118 { 1119 // --> OD 2005-10-25 #b6340308# - retrieve numbering rule at paragraph 1120 // style, which is found at current cursor position in the document. 1121 SwNumRule* pCollRule = pDoc->FindNumRulePtr(pColl->GetNumRule().GetValue()); 1122 // --> OD 2005-10-25 #125993# - The outline numbering rule isn't allowed 1123 // to be derived from a parent paragraph style to a derived one. 1124 // Thus check, if the found outline numbering rule is directly 1125 // set at the paragraph style <pColl>. If not, set <pCollRule> to NULL 1126 if ( pCollRule && pCollRule == GetDoc()->GetOutlineNumRule() ) 1127 { 1128 const SwNumRule* pDirectCollRule = 1129 pDoc->FindNumRulePtr(pColl->GetNumRule( sal_False ).GetValue()); 1130 if ( !pDirectCollRule ) 1131 { 1132 pCollRule = 0; 1133 } 1134 } 1135 // --> OD 2006-11-20 #i71764# 1136 // Document setting OUTLINE_LEVEL_YIELDS_OUTLINE_RULE has no influence 1137 // any more. 1138 // if ( pCollRule == NULL && 1139 // NO_NUMBERING != pColl->GetOutlineLevel() && 1140 // GetDoc()->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE) ) 1141 // { 1142 // pCollRule = GetDoc()->GetOutlineNumRule(); 1143 // } 1144 // <-- 1145 1146 // <-- 1147 // --> OD 2005-10-25 #b6340308# 1148 if ( !pCollRule ) 1149 { 1150 pNumRule = pCollRule; 1151 } 1152 // --> OD 2006-06-12 #b6435904# 1153 // no activation or continuation of outline numbering in Writer/Web document 1154 else if ( bNum && 1155 !dynamic_cast<SwWebDocShell*>(GetDoc()->GetDocShell()) && 1156 pCollRule == GetDoc()->GetOutlineNumRule() ) 1157 // <-- 1158 { 1159 if ( pNumRule == pCollRule ) 1160 { 1161 // check, if text node at current cursor positioned is counted. 1162 // If not, let it been counted. Then it has to be checked, 1163 // of the outline numbering has to be activated or continued. 1164 SwTxtNode* pTxtNode = 1165 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1166 if ( pTxtNode && !pTxtNode->IsCountedInList() ) 1167 { 1168 // check, if numbering of the outline level of the pararaph 1169 // style is active. If not, activate this outline level. 1170 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel(); 1171 ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(), //<-end,zhaojianwei 1172 "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); 1173 if ( pColl->IsAssignedToListLevelOfOutlineStyle() && //<-end,zhaojianwei 1174 pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType() 1175 == SVX_NUM_NUMBER_NONE ) 1176 { 1177 // activate outline numbering 1178 bActivateOutlineRule = true; 1179 } 1180 else 1181 { 1182 // turning on outline numbering at current cursor position 1183 bContinueFoundNumRule = true; 1184 } 1185 } 1186 else 1187 { 1188 // --> OD 2009-08-27 #i101234# 1189 // activate outline numbering, because from the precondition 1190 // it's known, that <SwEdit::HasNumber()> == sal_False 1191 bActivateOutlineRule = true; 1192 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei 1193 } 1194 } 1195 else if ( !pNumRule ) 1196 { 1197 // --> OD 2009-08-27 #i101234# 1198 // Check, if corresponding list level of the outline numbering 1199 // has already a numbering format set. 1200 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei,need further consideration 1201 if ( pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType() 1202 == SVX_NUM_NUMBER_NONE ) 1203 { 1204 // activate outline numbering, because from the precondition 1205 // it's known, that <SwEdit::HasNumber()> == sal_False 1206 bActivateOutlineRule = true; 1207 } 1208 else 1209 { 1210 // turning on outline numbering at current cursor position 1211 bContinueFoundNumRule = true; 1212 } 1213 // <-- 1214 } 1215 else 1216 { 1217 // check, if numbering of the outline level of the pararaph 1218 // style is active. If not, activate this outline level. 1219 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//#outline level,zhaojianwei 1220 ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(),//#outline level,zhaojianwei 1221 "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); 1222 if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&//#outline level,zhaojianwei 1223 pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType() 1224 == SVX_NUM_NUMBER_NONE ) 1225 { 1226 // activate outline numbering 1227 bActivateOutlineRule = true; 1228 } 1229 else 1230 { 1231 // turning on outline numbering at current cursor position 1232 bContinueFoundNumRule = true; 1233 } 1234 } 1235 pNumRule = pCollRule; 1236 } 1237 } 1238 1239 // --> OD 2005-10-25 #b6340308# 1240 // Only automatic numbering/bullet rules should be changed. 1241 // Note: The outline numbering rule is also an automatic one. It's only 1242 // changed, if it has to be activated. 1243 if ( pNumRule ) 1244 { 1245 if ( !pNumRule->IsAutoRule() ) 1246 { 1247 pNumRule = 0; 1248 } 1249 else if ( pNumRule == GetDoc()->GetOutlineNumRule() && 1250 !bActivateOutlineRule && !bContinueFoundNumRule ) 1251 { 1252 pNumRule = 0; 1253 } 1254 } 1255 // <-- 1256 1257 // --> OD 2005-10-25 #b6340308# 1258 // Search for a previous numbering/bullet rule to continue it. 1259 // --> OD 2008-03-18 #refactorlists# 1260 String sContinuedListId; 1261 if ( !pNumRule ) 1262 { 1263 pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(), 1264 false, bNum, false, 0, 1265 sContinuedListId ); 1266 bContinueFoundNumRule = pNumRule != 0; 1267 } 1268 // <-- 1269 1270 if (pNumRule) 1271 { 1272 SwNumRule aNumRule(*pNumRule); 1273 1274 // --> OD 2005-10-25 #b6340308# 1275 // do not change found numbering/bullet rule, if it should only be continued. 1276 if ( !bContinueFoundNumRule ) 1277 { 1278 SwTxtNode * pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1279 1280 if (pTxtNode) 1281 { 1282 // --> OD 2005-10-26 #b6340308# - use above retrieve outline 1283 // level, if outline numbering has to be activated. 1284 int nLevel = bActivateOutlineRule ////#outline level,zhaojianwei,need more consideration 1285 ? nActivateOutlineLvl 1286 : pTxtNode->GetActualListLevel(); 1287 // <-- 1288 1289 if (nLevel < 0) 1290 nLevel = 0; 1291 1292 if (nLevel >= MAXLEVEL) 1293 nLevel = MAXLEVEL - 1; 1294 1295 SwNumFmt aFmt(aNumRule.Get(static_cast<sal_uInt16>(nLevel))); 1296 1297 if (bNum) 1298 aFmt.SetNumberingType(SVX_NUM_ARABIC); 1299 else 1300 { 1301 // --> OD 2008-06-03 #i63395# 1302 // Only apply user defined default bullet font 1303 if ( numfunc::IsDefBulletFontUserDefined() ) 1304 { 1305 const Font* pFnt = &numfunc::GetDefBulletFont(); 1306 aFmt.SetBulletFont( pFnt ); 1307 } 1308 // <-- 1309 aFmt.SetBulletChar( numfunc::GetBulletChar(static_cast<sal_uInt8>(nLevel))); 1310 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); 1311 // #i93908# clear suffix for bullet lists 1312 aFmt.SetPrefix(::rtl::OUString()); 1313 aFmt.SetSuffix(::rtl::OUString()); 1314 } 1315 aNumRule.Set(static_cast<sal_uInt16>(nLevel), aFmt); 1316 } 1317 } 1318 // <-- 1319 1320 // --> OD 2008-02-08 #newlistlevelattrs# 1321 // reset indent attribute on applying list style 1322 // --> OD 2008-03-27 #refactorlists# 1323 SetCurNumRule( aNumRule, false, sContinuedListId, true ); 1324 // <-- 1325 } 1326 else 1327 { 1328 // --> OD 2009-08-27 #i95907# 1329 const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode( 1330 numfunc::GetDefaultPositionAndSpaceMode() ); 1331 // --> OD 2008-02-11 #newlistlevelattrs# 1332 SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode ); 1333 // <-- 1334 // <-- 1335 // Zeichenvorlage an die Numerierung haengen 1336 SwCharFmt* pChrFmt; 1337 SwDocShell* pDocSh = GetView().GetDocShell(); 1338 // --> OD 2008-06-03 #i63395# 1339 // Only apply user defined default bullet font 1340 const Font* pFnt = numfunc::IsDefBulletFontUserDefined() 1341 ? &numfunc::GetDefBulletFont() 1342 : 0; 1343 // <-- 1344 1345 if (bNum) 1346 { 1347 pChrFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL ); 1348 } 1349 else 1350 { 1351 pChrFmt = GetCharFmtFromPool( RES_POOLCHR_BUL_LEVEL ); 1352 } 1353 1354 const SwTxtNode* pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1355 const SwTwips nWidthOfTabs = pTxtNode 1356 ? pTxtNode->GetWidthOfLeadingTabs() 1357 : 0; 1358 GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() ); 1359 1360 const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh); 1361 const bool bRightToLeft = IsInRightToLeftText(); 1362 for( sal_uInt8 nLvl = 0; nLvl < MAXLEVEL; ++nLvl ) 1363 { 1364 SwNumFmt aFmt( aNumRule.Get( nLvl ) ); 1365 aFmt.SetCharFmt( pChrFmt ); 1366 1367 if (! bNum) 1368 { 1369 // --> OD 2008-06-03 #i63395# 1370 // Only apply user defined default bullet font 1371 if ( pFnt ) 1372 { 1373 aFmt.SetBulletFont( pFnt ); 1374 } 1375 aFmt.SetBulletChar( numfunc::GetBulletChar(nLvl) ); 1376 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); 1377 // #i93908# clear suffix for bullet lists 1378 aFmt.SetPrefix(::rtl::OUString()); 1379 aFmt.SetSuffix(::rtl::OUString()); 1380 } 1381 1382 // --> OD 2009-08-26 #i95907# 1383 if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) 1384 { 1385 if(bHtml && nLvl) 1386 { 1387 // 1/2" fuer HTML 1388 aFmt.SetLSpace(720); 1389 aFmt.SetAbsLSpace(nLvl * 720); 1390 } 1391 else if ( nWidthOfTabs > 0 ) 1392 { 1393 aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720); 1394 } 1395 } 1396 // <-- 1397 1398 // --> FME 2005-01-21 #i38904# Default alignment for 1399 // numbering/bullet should be rtl in rtl paragraph: 1400 if ( bRightToLeft ) 1401 { 1402 aFmt.SetNumAdjust( SVX_ADJUST_RIGHT ); 1403 } 1404 // <-- 1405 1406 aNumRule.Set( nLvl, aFmt ); 1407 } 1408 1409 // --> OD 2009-08-26 #i95907# 1410 if ( pTxtNode && 1411 ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT ) 1412 { 1413 // --> OD 2010-01-05 #b6884103# 1414 // short nTxtNodeFirstLineOffset( 0 ); 1415 // pTxtNode->GetFirstLineOfsWithNum( nTxtNodeFirstLineOffset ); 1416 // const SwTwips nTxtNodeIndent = pTxtNode->GetLeftMarginForTabCalculation() + 1417 // nTxtNodeFirstLineOffset; 1418 const SwTwips nTxtNodeIndent = pTxtNode->GetAdditionalIndentForStartingNewList(); 1419 // <-- 1420 if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 ) 1421 { 1422 // --> OD 2010-05-05 #i111172# 1423 // If text node is already inside a list, assure that the indents 1424 // are the same. Thus, adjust the indent change value by subtracting 1425 // indents of to be applied list style. 1426 SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs; 1427 if ( pTxtNode->GetNumRule() ) 1428 { 1429 const SwNumFmt aFmt( aNumRule.Get( 0 ) ); 1430 if ( aFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) 1431 { 1432 nIndentChange -= aFmt.GetIndentAt() + aFmt.GetFirstLineIndent(); 1433 } 1434 } 1435 // <-- 1436 aNumRule.ChangeIndent( nIndentChange ); 1437 } 1438 } 1439 // <-- 1440 // --> OD 2008-02-08 #newlistlevelattrs# 1441 // reset indent attribute on applying list style 1442 // --> OD 2008-03-17 #refactorlists# 1443 // start new list 1444 SetCurNumRule( aNumRule, true, String(), true ); 1445 // <-- 1446 } 1447 1448 EndUndo(UNDO_NUMORNONUM); 1449 } 1450 // <- #i40041# 1451 1452 void SwWrtShell::NumOn() 1453 { 1454 NumOrBulletOn(sal_True); 1455 } 1456 1457 void SwWrtShell::NumOrBulletOff() 1458 { 1459 const SwNumRule * pCurNumRule = GetCurNumRule(); 1460 1461 if (pCurNumRule) 1462 { 1463 if (pCurNumRule->IsOutlineRule()) 1464 { 1465 SwNumRule aNumRule(*pCurNumRule); 1466 1467 SwTxtNode * pTxtNode = 1468 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1469 1470 if (pTxtNode) 1471 { 1472 sal_uInt16 nLevel = sal::static_int_cast<sal_uInt16, sal_Int32>(pTxtNode->GetActualListLevel()); 1473 SwNumFmt aFmt(aNumRule.Get(nLevel)); 1474 1475 aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE); 1476 aNumRule.Set(nLevel, aFmt); 1477 1478 // --> OD 2008-03-17 #refactorlists# 1479 // no start or continuation of a list - the outline style is only changed. 1480 SetCurNumRule( aNumRule, false ); 1481 // <-- 1482 } 1483 } 1484 else 1485 { 1486 DelNumRules(); 1487 } 1488 1489 // --> OD 2005-10-24 #126346# - Cursor can not be anymore in front of 1490 // a label, because numbering/bullet is switched off. 1491 SetInFrontOfLabel( sal_False ); 1492 // <-- 1493 } 1494 } 1495 // <- #i29560# 1496 1497 /*------------------------------------------------------------------------ 1498 Beschreibung: Default-Bulletliste erfragen 1499 ------------------------------------------------------------------------*/ 1500 1501 void SwWrtShell::BulletOn() 1502 { 1503 NumOrBulletOn(sal_False); 1504 } 1505 1506 1507 /*-------------------------------------------------- 1508 1509 --------------------------------------------------*/ 1510 SelectionType SwWrtShell::GetSelectionType() const 1511 { 1512 // ContentType kann nicht ermittelt werden innerhalb einer 1513 // Start-/Endactionklammerung. 1514 // Da es keinen ungueltigen Wert gibt, wird TEXT geliefert. 1515 // Der Wert ist egal, da in EndAction ohnehin aktualisiert wird. 1516 1517 if ( BasicActionPend() ) 1518 return IsSelFrmMode() ? nsSelectionType::SEL_FRM : nsSelectionType::SEL_TXT; 1519 1520 // if ( IsTableMode() ) 1521 // return nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS; 1522 1523 SwView &_rView = ((SwView&)GetView()); 1524 if (_rView.GetPostItMgr() && _rView.GetPostItMgr()->HasActiveSidebarWin() ) 1525 return nsSelectionType::SEL_POSTIT; 1526 int nCnt; 1527 1528 // Rahmen einfuegen ist kein DrawMode 1529 if ( !_rView.GetEditWin().IsFrmAction() && 1530 (IsObjSelected() || (_rView.IsDrawMode() && !IsFrmSelected()) )) 1531 { 1532 if (GetDrawView()->IsTextEdit()) 1533 nCnt = nsSelectionType::SEL_DRW_TXT; 1534 else 1535 { 1536 if (GetView().IsFormMode()) // Nur Forms selektiert 1537 nCnt = nsSelectionType::SEL_DRW_FORM; 1538 else 1539 nCnt = nsSelectionType::SEL_DRW; // Irgendein Draw-Objekt 1540 1541 if (_rView.IsBezierEditMode()) 1542 nCnt |= nsSelectionType::SEL_BEZ; 1543 else if( GetDrawView()->GetContext() == SDRCONTEXT_MEDIA ) 1544 nCnt |= nsSelectionType::SEL_MEDIA; 1545 1546 if (svx::checkForSelectedCustomShapes( 1547 const_cast<SdrView *>(GetDrawView()), 1548 true /* bOnlyExtruded */ )) 1549 { 1550 nCnt |= nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE; 1551 } 1552 sal_uInt32 nCheckStatus = 0; 1553 if (svx::checkForSelectedFontWork( 1554 const_cast<SdrView *>(GetDrawView()), nCheckStatus )) 1555 { 1556 nCnt |= nsSelectionType::SEL_FONTWORK; 1557 } 1558 } 1559 1560 return nCnt; 1561 } 1562 1563 nCnt = GetCntType(); 1564 1565 if ( IsFrmSelected() ) 1566 { 1567 if (_rView.IsDrawMode()) 1568 _rView.LeaveDrawCreate(); // Aufraeumen (Bug #45639) 1569 if ( !(nCnt & (CNT_GRF | CNT_OLE)) ) 1570 return nsSelectionType::SEL_FRM; 1571 } 1572 1573 if ( IsCrsrInTbl() ) 1574 nCnt |= nsSelectionType::SEL_TBL; 1575 1576 if ( IsTableMode() ) 1577 nCnt |= (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS); 1578 1579 // --> FME 2005-01-12 #i39855# 1580 // Do not pop up numbering toolbar, if the text node has a numbering 1581 // of type SVX_NUM_NUMBER_NONE. 1582 const SwNumRule* pNumRule = GetCurNumRule(); 1583 if ( pNumRule ) 1584 { 1585 const SwTxtNode* pTxtNd = 1586 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1587 1588 // --> OD 2008-03-19 #refactorlists# 1589 if ( pTxtNd && pTxtNd->IsInList() ) 1590 // <-- 1591 { 1592 const SwNumFmt& rFmt = pNumRule->Get(sal::static_int_cast< sal_uInt8, sal_Int32>(pTxtNd->GetActualListLevel())); 1593 if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() ) 1594 nCnt |= nsSelectionType::SEL_NUM; 1595 } 1596 } 1597 // <-- 1598 1599 return nCnt; 1600 } 1601 1602 /*------------------------------------------------------------------------ 1603 Beschreibung: Finden der TextCollection mit dem Name rCollname 1604 Return: Pointer auf die Collection oder 0, wenn keine 1605 TextCollection mit diesem Namen existiert oder 1606 diese eine Defaultvorlage ist. 1607 ------------------------------------------------------------------------*/ 1608 1609 1610 SwTxtFmtColl *SwWrtShell::GetParaStyle(const String &rCollName, GetStyle eCreate ) 1611 { 1612 SwTxtFmtColl* pColl = FindTxtFmtCollByName( rCollName ); 1613 if( !pColl && GETSTYLE_NOCREATE != eCreate ) 1614 { 1615 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); 1616 if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate ) 1617 pColl = GetTxtCollFromPool( nId ); 1618 } 1619 return pColl; 1620 } 1621 /*------------------------------------------------------------------------ 1622 Beschreibung: Finden der Zeichenvorlage mit dem Name rCollname 1623 Return: Pointer auf die Collection oder 0, wenn keine 1624 Zeichenvorlage mit diesem Namen existiert oder 1625 diese eine Defaultvorlage oder automatische Vorlage ist. 1626 ------------------------------------------------------------------------*/ 1627 1628 1629 1630 SwCharFmt *SwWrtShell::GetCharStyle(const String &rFmtName, GetStyle eCreate ) 1631 { 1632 SwCharFmt* pFmt = FindCharFmtByName( rFmtName ); 1633 if( !pFmt && GETSTYLE_NOCREATE != eCreate ) 1634 { 1635 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rFmtName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 1636 if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate ) 1637 pFmt = (SwCharFmt*)GetFmtFromPool( nId ); 1638 } 1639 return pFmt; 1640 } 1641 1642 /*------------------------------------------------------------------------ 1643 Beschreibung: Finden des Tabellenformates mit dem Name rFmtname 1644 Return: Pointer auf das Format oder 0, wenn kein 1645 Rahmenformat mit diesem Namen existiert oder 1646 dieses eine Defaultformat oder automatisches Format ist. 1647 ------------------------------------------------------------------------*/ 1648 1649 1650 1651 SwFrmFmt *SwWrtShell::GetTblStyle(const String &rFmtName) 1652 { 1653 SwFrmFmt *pFmt = 0; 1654 for( sal_uInt16 i = GetTblFrmFmtCount(); i; ) 1655 if( !( pFmt = &GetTblFrmFmt( --i ) )->IsDefault() && 1656 pFmt->GetName() == rFmtName && IsUsed( *pFmt ) ) 1657 return pFmt; 1658 return 0; 1659 } 1660 1661 1662 /*------------------------------------------------------------------------ 1663 Beschreibung: Anwenden der Vorlagen 1664 ------------------------------------------------------------------------*/ 1665 1666 1667 1668 void SwWrtShell::SetPageStyle(const String &rCollName) 1669 { 1670 if( !SwCrsrShell::HasSelection() && !IsSelFrmMode() && !IsObjSelected() ) 1671 { 1672 SwPageDesc* pDesc = FindPageDescByName( rCollName, sal_True ); 1673 if( pDesc ) 1674 ChgCurPageDesc( *pDesc ); 1675 } 1676 } 1677 1678 /*------------------------------------------------------------------------ 1679 Beschreibung: Zugriff Vorlagen 1680 ------------------------------------------------------------------------*/ 1681 1682 1683 1684 String SwWrtShell::GetCurPageStyle( const sal_Bool bCalcFrm ) const 1685 { 1686 return GetPageDesc(GetCurPageDesc( bCalcFrm )).GetName(); 1687 } 1688 1689 /*------------------------------------------------------------------------ 1690 Beschreibung: Aktuelle Vorlage anhand der geltenden Attribute aendern 1691 ------------------------------------------------------------------------*/ 1692 1693 1694 void SwWrtShell::QuickUpdateStyle() 1695 { 1696 SwTxtFmtColl *pColl = GetCurTxtFmtColl(); 1697 1698 // Standard kann nicht geaendert werden 1699 if(pColl && !pColl->IsDefault()) 1700 { 1701 FillByEx(pColl); 1702 // Vorlage auch anwenden, um harte Attributierung 1703 // zu entfernen 1704 SetTxtFmtColl(pColl); 1705 } 1706 } 1707 1708 1709 void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet) 1710 { 1711 SfxItemSet aCoreSet( GetAttrPool(), 1712 RES_CHRATR_BEGIN, RES_CHRATR_END - 1, 1713 RES_PARATR_BEGIN, RES_PARATR_END - 1, 1714 RES_FRMATR_BEGIN, RES_FRMATR_END - 1, 1715 SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS, 1716 SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS, 1717 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET, 1718 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 1719 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP, 1720 SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM, 1721 0 ); 1722 GetCurAttr( aCoreSet ); 1723 sal_Bool bReset = sal_False; 1724 SfxItemIter aParaIter( aCoreSet ); 1725 const SfxPoolItem* pParaItem = aParaIter.FirstItem(); 1726 while( pParaItem ) 1727 { 1728 if(!IsInvalidItem(pParaItem)) 1729 { 1730 sal_uInt16 nWhich = pParaItem->Which(); 1731 if(SFX_ITEM_SET == aCoreSet.GetItemState(nWhich) && 1732 SFX_ITEM_SET == rStyleSet.GetItemState(nWhich)) 1733 { 1734 aCoreSet.ClearItem(nWhich); 1735 bReset = sal_True; 1736 } 1737 } 1738 pParaItem = aParaIter.NextItem(); 1739 } 1740 StartAction(); 1741 if(bReset) 1742 { 1743 ResetAttr(); 1744 SetAttr(aCoreSet); 1745 } 1746 pDoc->ChgFmt(*pColl, rStyleSet ); 1747 EndAction(); 1748 } 1749 1750 /*-----------------12.03.97 12.24------------------- 1751 1752 --------------------------------------------------*/ 1753 1754 void SwWrtShell::AutoUpdateFrame( SwFrmFmt* pFmt, const SfxItemSet& rStyleSet ) 1755 { 1756 StartAction(); 1757 1758 ResetFlyFrmAttr( 0, &rStyleSet ); 1759 pFmt->SetFmtAttr( rStyleSet ); 1760 1761 EndAction(); 1762 } 1763 1764 1765 void SwWrtShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar ) 1766 { 1767 ResetCursorStack(); 1768 if(_CanInsert()) 1769 { 1770 sal_Bool bStarted = sal_False; 1771 if(HasSelection()) 1772 { 1773 // nur hier klammern, da das normale Insert schon an der 1774 // Editshell geklammert ist 1775 StartAllAction(); 1776 StartUndo(UNDO_INSERT); 1777 bStarted = sal_True; 1778 DelRight(); 1779 } 1780 SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar ); 1781 1782 if(bStarted) 1783 { 1784 EndAllAction(); 1785 EndUndo(UNDO_INSERT); 1786 } 1787 } 1788 } 1789 1790 1791 /* 1792 * eine Art kontrollierter copy ctor 1793 */ 1794 1795 SwWrtShell::SwWrtShell( SwWrtShell& rSh, Window *_pWin, SwView &rShell ) 1796 : SwFEShell( rSh, _pWin ), 1797 COMMON_INI_LIST 1798 { 1799 BITFLD_INI_LIST 1800 SET_CURR_SHELL( this ); 1801 1802 SetSfxViewShell( (SfxViewShell *)&rShell ); 1803 SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) ); 1804 1805 // place the cursor on the first field... 1806 IFieldmark *pBM = NULL; 1807 if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=NULL ) { 1808 GotoFieldmark(pBM); 1809 } 1810 } 1811 1812 1813 SwWrtShell::SwWrtShell( SwDoc& rDoc, Window *_pWin, SwView &rShell, 1814 const SwViewOption *pViewOpt ) 1815 : SwFEShell( rDoc, _pWin, pViewOpt), 1816 COMMON_INI_LIST 1817 { 1818 BITFLD_INI_LIST 1819 SET_CURR_SHELL( this ); 1820 SetSfxViewShell( (SfxViewShell *)&rShell ); 1821 SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) ); 1822 } 1823 1824 /* 1825 * ctor 1826 */ 1827 1828 1829 1830 SwWrtShell::~SwWrtShell() 1831 { 1832 SET_CURR_SHELL( this ); 1833 while(IsModePushed()) 1834 PopMode(); 1835 while(PopCrsr(sal_False)) 1836 ; 1837 SwTransferable::ClearSelection( *this ); 1838 } 1839 1840 sal_Bool SwWrtShell::Pop( sal_Bool bOldCrsr ) 1841 { 1842 sal_Bool bRet = SwCrsrShell::Pop( bOldCrsr ); 1843 if( bRet && IsSelection() ) 1844 { 1845 fnSetCrsr = &SwWrtShell::SetCrsrKillSel; 1846 fnKillSel = &SwWrtShell::ResetSelect; 1847 } 1848 return bRet; 1849 } 1850 1851 /*-------------------------------------------------------------------- 1852 Beschreibung: 1853 --------------------------------------------------------------------*/ 1854 sal_Bool SwWrtShell::CanInsert() 1855 { 1856 return (!(IsSelFrmMode() | IsObjSelected() | (GetView().GetDrawFuncPtr() != NULL) | (GetView().GetPostItMgr()->GetActiveSidebarWin()!= NULL))); 1857 } 1858 1859 // die Core erzeugt eine Selektion, das SttSelect muss gerufen werden 1860 void SwWrtShell::NewCoreSelection() 1861 { 1862 SttSelect(); 1863 } 1864 1865 // -------------- 1866 void SwWrtShell::ChgDBData(const SwDBData& aDBData) 1867 { 1868 SwEditShell::ChgDBData(aDBData); 1869 //notify the db-beamer if available 1870 GetView().NotifyDBChanged(); 1871 } 1872 1873 String SwWrtShell::GetSelDescr() const 1874 { 1875 String aResult; 1876 1877 int nSelType = GetSelectionType(); 1878 switch (nSelType) 1879 { 1880 case nsSelectionType::SEL_GRF: 1881 aResult = SW_RES(STR_GRAPHIC); 1882 1883 break; 1884 case nsSelectionType::SEL_FRM: 1885 { 1886 const SwFrmFmt * pFrmFmt = GetCurFrmFmt(); 1887 1888 if (pFrmFmt) 1889 aResult = pFrmFmt->GetDescription(); 1890 } 1891 break; 1892 case nsSelectionType::SEL_DRW: 1893 { 1894 aResult = SW_RES(STR_DRAWING_OBJECTS); 1895 } 1896 break; 1897 default: 1898 if (0 != pDoc) 1899 aResult = GetCrsrDescr(); 1900 } 1901 1902 return aResult; 1903 } 1904 1905 void SwWrtShell::ApplyViewOptions( const SwViewOption &rOpt ) 1906 { 1907 SwFEShell::ApplyViewOptions( rOpt ); 1908 //#i115062# invalidate meta character slot 1909 GetView().GetViewFrame()->GetBindings().Invalidate( FN_VIEW_META_CHARS ); 1910 } 1911 1912 1913