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 const bool bNoTxtFrmPrtAreaChanged ) 707 { 708 //Einstellen der Skalierung am Client. Diese ergibt sich aus der Differenz 709 //zwischen der VisArea des Objektes und der ObjArea. 710 ASSERT( xObj.is(), "ObjectRef not valid" ); 711 712 sal_Int64 nAspect = xObj.GetViewAspect(); 713 if ( nAspect == embed::Aspects::MSOLE_ICON ) 714 return; // the replacement image is completely controlled by container in this case 715 716 sal_Int64 nMisc = 0; 717 sal_Bool bLinkingChart = sal_False; 718 719 try 720 { 721 nMisc = xObj->getStatus( nAspect ); 722 723 //Das kann ja wohl nur ein nicht aktives Objekt sein. Diese bekommen 724 //auf Wunsch die neue Groesse als VisArea gesetzt (StarChart) 725 if( embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE & nMisc ) 726 { 727 // TODO/MBA: testing 728 SwRect aRect( pFlyPrtRect ? *pFlyPrtRect 729 : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() )); 730 if( !aRect.IsEmpty() ) 731 { 732 // TODO/LEAN: getMapUnit can switch object to running state 733 // xObj.TryRunningState(); 734 735 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); 736 737 // TODO/LATER: needs complete VisArea?! 738 Size aSize( OutputDevice::LogicToLogic( aRect.SVRect(), MAP_TWIP, aUnit ).GetSize() ); 739 awt::Size aSz; 740 aSz.Width = aSize.Width(); 741 aSz.Height = aSize.Height(); 742 xObj->setVisualAreaSize( nAspect, aSz ); 743 // --> OD 2005-05-02 #i48419# - action 'UpdateReplacement' doesn't 744 // have to change the modified state of the document. 745 // This is only a workaround for the defect, that this action 746 // modifies a document after load, because unnecessarily the 747 // replacement graphic is updated, in spite of the fact that 748 // nothing has been changed. 749 // If the replacement graphic changes by this action, the document 750 // will be already modified via other mechanisms. 751 { 752 bool bResetEnableSetModified(false); 753 if ( GetDoc()->GetDocShell()->IsEnableSetModified() ) 754 { 755 GetDoc()->GetDocShell()->EnableSetModified( sal_False ); 756 bResetEnableSetModified = true; 757 } 758 759 //#i79576# don't destroy chart replacement images on load 760 //#i79578# don't request a new replacement image for charts to often 761 //a chart sends a modified call to the framework if it was changed 762 //thus the replacement update is already handled elsewhere 763 if ( !SotExchange::IsChart( xObj->getClassID() ) ) 764 xObj.UpdateReplacement(); 765 766 if ( bResetEnableSetModified ) 767 { 768 GetDoc()->GetDocShell()->EnableSetModified( sal_True ); 769 } 770 } 771 // <-- 772 } 773 774 // TODO/LATER: this is only a workaround, 775 uno::Reference< chart2::XChartDocument > xChartDocument( xObj->getComponent(), uno::UNO_QUERY ); 776 bLinkingChart = ( xChartDocument.is() && !xChartDocument->hasInternalDataProvider() ); 777 } 778 } 779 catch ( uno::Exception& ) 780 { 781 // TODO/LATER: handle the error 782 return; 783 } 784 785 SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() ); 786 if ( !pCli ) 787 { 788 if ( (embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY & nMisc) 789 || bLinkingChart 790 // TODO/LATER: ResizeOnPrinterChange 791 //|| SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->GetMiscStatus() 792 // --> OD #i117189# - refine condition for non-resizable objects 793 // non-resizable objects need to be set the size back by this method 794 || ( bNoTxtFrmPrtAreaChanged && nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE ) ) 795 { 796 pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj ); 797 } 798 else 799 return; 800 } 801 802 // TODO/LEAN: getMapUnit can switch object to running state 803 // xObj.TryRunningState(); 804 805 awt::Size aSize; 806 try 807 { 808 aSize = xObj->getVisualAreaSize( nAspect ); 809 } 810 catch( embed::NoVisualAreaSizeException& ) 811 { 812 DBG_ERROR( "Can't get visual area size!\n" ); 813 // the scaling will not be done 814 } 815 catch( uno::Exception& ) 816 { 817 // TODO/LATER: handle the error 818 DBG_ERROR( "Can't get visual area size!\n" ); 819 return; 820 } 821 822 Size _aVisArea( aSize.Width, aSize.Height ); 823 824 Fraction aScaleWidth( 1, 1 ); 825 Fraction aScaleHeight( 1, 1 ); 826 827 sal_Bool bUseObjectSize = sal_False; 828 829 // solange keine vernuenftige Size vom Object kommt, kann nichts 830 // skaliert werden 831 if( _aVisArea.Width() && _aVisArea.Height() ) 832 { 833 const MapMode aTmp( MAP_TWIP ); 834 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); 835 _aVisArea = OutputDevice::LogicToLogic( _aVisArea, aUnit, aTmp); 836 Size aObjArea; 837 if ( pFlyPrtRect ) 838 aObjArea = pFlyPrtRect->SSize(); 839 else 840 aObjArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ).SSize(); 841 842 // differ the aObjArea and _aVisArea by 1 Pixel then set new VisArea 843 long nX, nY; 844 SwSelPaintRects::Get1PixelInLogic( *this, &nX, &nY ); 845 if( !( _aVisArea.Width() - nX <= aObjArea.Width() && 846 _aVisArea.Width() + nX >= aObjArea.Width() && 847 _aVisArea.Height()- nY <= aObjArea.Height()&& 848 _aVisArea.Height()+ nY >= aObjArea.Height() )) 849 { 850 // TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE 851 /* 852 if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & nMisc ) 853 { 854 //This type of objects should never be resized. 855 //If this request comes from the Writer core (inaktive Object 856 //ist resized), the Object should be resized too. 857 //If this request comes from the Object itself, the Frame 858 //in the Writer core should be resized. 859 if ( pFlyPrtRect ) //Request from core? 860 { 861 xObj->SetVisArea( OutputDevice::LogicToLogic( 862 pFlyPrtRect->SVRect(), MAP_TWIP, xObj->GetMapUnit() )); 863 } 864 else 865 { 866 SwRect aTmp( Point( LONG_MIN, LONG_MIN ), _aVisArea ); 867 RequestObjectResize( aTmp, xObj ); 868 } 869 //Der Rest erledigt sich, weil wir eh wiederkommen sollten, evtl. 870 //sogar rekursiv. 871 return; 872 } 873 else*/ 874 875 if ( nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE ) 876 { 877 // the object must not be scaled, the size stored in object must be used for restoring 878 bUseObjectSize = sal_True; 879 } 880 else 881 { 882 aScaleWidth = Fraction( aObjArea.Width(), _aVisArea.Width() ); 883 aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height()); 884 } 885 } 886 } 887 888 //Jetzt ist auch der guenstige Zeitpunkt die ObjArea einzustellen. 889 //Die Scalierung muss beruecksichtigt werden. 890 SwRect aArea; 891 if ( pFlyPrtRect ) 892 { 893 aArea = *pFlyPrtRect; 894 aArea += pFlyFrmRect->Pos(); 895 } 896 else 897 { 898 aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ); 899 aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos(); 900 } 901 902 if ( bUseObjectSize ) 903 { 904 // --> this moves non-resizable object so that when adding borders the baseline remains the same 905 const SwFlyFrmFmt *pFlyFrmFmt = dynamic_cast< const SwFlyFrmFmt * >( GetFlyFrmFmt() ); 906 ASSERT( pFlyFrmFmt, "Could not find fly frame." ); 907 if ( pFlyFrmFmt ) 908 { 909 const Point &rPoint = pFlyFrmFmt->GetLastFlyFrmPrtRectPos(); 910 SwRect aRect( pFlyPrtRect ? *pFlyPrtRect 911 : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() )); 912 aArea += rPoint - aRect.Pos(); // adjust area by diff of printing area position in order to keep baseline alignment correct. 913 } 914 // <-- 915 aArea.Width ( _aVisArea.Width() ); 916 aArea.Height( _aVisArea.Height() ); 917 RequestObjectResize( aArea, xObj.GetObject() ); 918 } 919 else 920 { 921 aArea.Width ( Fraction( aArea.Width() ) / pCli->GetScaleWidth() ); 922 aArea.Height( Fraction( aArea.Height() ) / pCli->GetScaleHeight()); 923 } 924 925 pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight ); 926 } 927 928 929 930 void SwWrtShell::ConnectObj( svt::EmbeddedObjectRef& xObj, const SwRect &rPrt, 931 const SwRect &rFrm ) 932 { 933 SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin()); 934 if ( !pCli ) 935 pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj ); 936 CalcAndSetScale( xObj, &rPrt, &rFrm ); 937 } 938 939 /*------------------------------------------------------------------------ 940 Beschreibung: Einfuegen harter Seitenumbruch; 941 Selektionen werden ueberschrieben 942 ------------------------------------------------------------------------*/ 943 944 945 946 void SwWrtShell::InsertPageBreak(const String *pPageDesc, sal_uInt16 nPgNum ) 947 { 948 ResetCursorStack(); 949 if( _CanInsert() ) 950 { 951 ACT_KONTEXT(this); 952 StartUndo(UNDO_UI_INSERT_PAGE_BREAK); 953 954 if ( !IsCrsrInTbl() ) 955 { 956 if(HasSelection()) 957 DelRight(); 958 SwFEShell::SplitNode(); 959 } 960 961 const SwPageDesc *pDesc = pPageDesc 962 ? FindPageDescByName( *pPageDesc, sal_True ) : 0; 963 if( pDesc ) 964 { 965 SwFmtPageDesc aDesc( pDesc ); 966 aDesc.SetNumOffset( nPgNum ); 967 SetAttr( aDesc ); 968 } 969 else 970 SetAttr( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) ); 971 EndUndo(UNDO_UI_INSERT_PAGE_BREAK); 972 } 973 } 974 /*------------------------------------------------------------------------ 975 Beschreibung: Einfuegen harter Zeilenumbruch; 976 Selektionen werden ueberschrieben 977 ------------------------------------------------------------------------*/ 978 979 980 void SwWrtShell::InsertLineBreak() 981 { 982 ResetCursorStack(); 983 if( _CanInsert() ) 984 { 985 if(HasSelection()) 986 DelRight(); 987 988 const sal_Unicode cIns = 0x0A; 989 SvxAutoCorrect* pACorr = lcl_IsAutoCorr(); 990 if( pACorr ) 991 AutoCorrect( *pACorr, cIns ); 992 else 993 SwWrtShell::Insert( String( cIns ) ); 994 } 995 } 996 /*------------------------------------------------------------------------ 997 Beschreibung: Einfuegen harter Spaltenumbruch; 998 Selektionen werden ueberschrieben 999 ------------------------------------------------------------------------*/ 1000 1001 1002 void SwWrtShell::InsertColumnBreak() 1003 { 1004 ACT_KONTEXT(this); 1005 ResetCursorStack(); 1006 if( _CanInsert() ) 1007 { 1008 StartUndo(UNDO_UI_INSERT_COLUMN_BREAK); 1009 1010 if ( !IsCrsrInTbl() ) 1011 { 1012 if(HasSelection()) 1013 DelRight(); 1014 SwFEShell::SplitNode( sal_False, sal_False ); 1015 } 1016 SetAttr(SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK)); 1017 1018 EndUndo(UNDO_UI_INSERT_COLUMN_BREAK); 1019 } 1020 } 1021 1022 /*------------------------------------------------------------------------ 1023 Beschreibung: Einfuegen Fussnote 1024 Parameter: rStr -- optionales Fussnotenzeichen 1025 ------------------------------------------------------------------------*/ 1026 1027 1028 void SwWrtShell::InsertFootnote(const String &rStr, sal_Bool bEndNote, sal_Bool bEdit ) 1029 { 1030 ResetCursorStack(); 1031 if( _CanInsert() ) 1032 { 1033 if(HasSelection()) 1034 { 1035 //collapse cursor to the end 1036 if(!IsCrsrPtAtEnd()) 1037 SwapPam(); 1038 ClearMark(); 1039 } 1040 1041 SwFmtFtn aFootNote( bEndNote ); 1042 if(rStr.Len()) 1043 aFootNote.SetNumStr( rStr ); 1044 1045 SetAttr(aFootNote); 1046 1047 if( bEdit ) 1048 { 1049 // zur Bearbeiung des Fussnotentextes 1050 Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 1051 GotoFtnTxt(); 1052 } 1053 } 1054 } 1055 /*------------------------------------------------------------------------ 1056 Beschreibung: SplitNode; hier auch, da 1057 - selektierter Inhalt geloescht wird; 1058 - der Cursorstack gfs. zurueckgesetzt wird. 1059 ------------------------------------------------------------------------*/ 1060 1061 1062 void SwWrtShell::SplitNode( sal_Bool bAutoFmt, sal_Bool bCheckTableStart ) 1063 { 1064 ResetCursorStack(); 1065 if( _CanInsert() ) 1066 { 1067 ACT_KONTEXT(this); 1068 1069 rView.GetEditWin().FlushInBuffer(); 1070 sal_Bool bHasSel = HasSelection(); 1071 if( bHasSel ) 1072 { 1073 StartUndo( UNDO_INSERT ); 1074 DelRight(); 1075 } 1076 1077 SwFEShell::SplitNode( bAutoFmt, bCheckTableStart ); 1078 if( bHasSel ) 1079 EndUndo( UNDO_INSERT ); 1080 } 1081 } 1082 1083 /*------------------------------------------------------------------------ 1084 Beschreibung: Numerierung anschalten 1085 Parameter: Optionale Angabe eines Namens fuer die benannte Liste; 1086 dieser bezeichnet eine Position, wenn er in eine 1087 Zahl konvertierbar ist und kleiner ist als nMaxRules. 1088 -------------------------------------------------------------------------*/ 1089 1090 1091 // zum Testen der CharFormate an der Numerierung 1092 // extern void SetNumChrFmt( SwWrtShell*, SwNumRules& ); 1093 1094 // -> #i40041# 1095 // --> OD 2005-10-25 #b6340308# 1096 // Preconditions (as far as OD has figured out): 1097 // - <SwEditShell::HasNumber()> is sal_False, if <bNum> is sal_True 1098 // - <SwEditShell::HasBullet()> is sal_False, if <bNum> is sal_False 1099 // Behavior of method is determined by the current situation at the current 1100 // cursor position in the document. 1101 void SwWrtShell::NumOrBulletOn(sal_Bool bNum) 1102 { 1103 // determine numbering rule found at current cursor position in the docment. 1104 const SwNumRule* pCurRule = GetCurNumRule(); 1105 1106 StartUndo(UNDO_NUMORNONUM); 1107 1108 const SwNumRule * pNumRule = pCurRule; 1109 1110 // --> OD 2005-10-25 #b6340308# 1111 // - activate outline rule respectively turning on outline rule for 1112 // current text node. But, only for turning on a numbering (<bNum> == sal_True). 1113 // - overwrite found numbering rule at current cursor position, if 1114 // no numbering rule can be retrieved from the paragraph style. 1115 bool bContinueFoundNumRule( false ); 1116 bool bActivateOutlineRule( false ); 1117 int nActivateOutlineLvl( MAXLEVEL ); // only relevant, if <bActivateOutlineRule> == sal_True 1118 SwTxtFmtColl * pColl = GetCurTxtFmtColl(); 1119 if ( pColl ) 1120 { 1121 // --> OD 2005-10-25 #b6340308# - retrieve numbering rule at paragraph 1122 // style, which is found at current cursor position in the document. 1123 SwNumRule* pCollRule = pDoc->FindNumRulePtr(pColl->GetNumRule().GetValue()); 1124 // --> OD 2005-10-25 #125993# - The outline numbering rule isn't allowed 1125 // to be derived from a parent paragraph style to a derived one. 1126 // Thus check, if the found outline numbering rule is directly 1127 // set at the paragraph style <pColl>. If not, set <pCollRule> to NULL 1128 if ( pCollRule && pCollRule == GetDoc()->GetOutlineNumRule() ) 1129 { 1130 const SwNumRule* pDirectCollRule = 1131 pDoc->FindNumRulePtr(pColl->GetNumRule( sal_False ).GetValue()); 1132 if ( !pDirectCollRule ) 1133 { 1134 pCollRule = 0; 1135 } 1136 } 1137 // --> OD 2006-11-20 #i71764# 1138 // Document setting OUTLINE_LEVEL_YIELDS_OUTLINE_RULE has no influence 1139 // any more. 1140 // if ( pCollRule == NULL && 1141 // NO_NUMBERING != pColl->GetOutlineLevel() && 1142 // GetDoc()->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE) ) 1143 // { 1144 // pCollRule = GetDoc()->GetOutlineNumRule(); 1145 // } 1146 // <-- 1147 1148 // <-- 1149 // --> OD 2005-10-25 #b6340308# 1150 if ( !pCollRule ) 1151 { 1152 pNumRule = pCollRule; 1153 } 1154 // --> OD 2006-06-12 #b6435904# 1155 // no activation or continuation of outline numbering in Writer/Web document 1156 else if ( bNum && 1157 !dynamic_cast<SwWebDocShell*>(GetDoc()->GetDocShell()) && 1158 pCollRule == GetDoc()->GetOutlineNumRule() ) 1159 // <-- 1160 { 1161 if ( pNumRule == pCollRule ) 1162 { 1163 // check, if text node at current cursor positioned is counted. 1164 // If not, let it been counted. Then it has to be checked, 1165 // of the outline numbering has to be activated or continued. 1166 SwTxtNode* pTxtNode = 1167 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1168 if ( pTxtNode && !pTxtNode->IsCountedInList() ) 1169 { 1170 // check, if numbering of the outline level of the pararaph 1171 // style is active. If not, activate this outline level. 1172 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel(); 1173 ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(), //<-end,zhaojianwei 1174 "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); 1175 if ( pColl->IsAssignedToListLevelOfOutlineStyle() && //<-end,zhaojianwei 1176 pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType() 1177 == SVX_NUM_NUMBER_NONE ) 1178 { 1179 // activate outline numbering 1180 bActivateOutlineRule = true; 1181 } 1182 else 1183 { 1184 // turning on outline numbering at current cursor position 1185 bContinueFoundNumRule = true; 1186 } 1187 } 1188 else 1189 { 1190 // --> OD 2009-08-27 #i101234# 1191 // activate outline numbering, because from the precondition 1192 // it's known, that <SwEdit::HasNumber()> == sal_False 1193 bActivateOutlineRule = true; 1194 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei 1195 } 1196 } 1197 else if ( !pNumRule ) 1198 { 1199 // --> OD 2009-08-27 #i101234# 1200 // Check, if corresponding list level of the outline numbering 1201 // has already a numbering format set. 1202 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei,need further consideration 1203 if ( pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType() 1204 == SVX_NUM_NUMBER_NONE ) 1205 { 1206 // activate outline numbering, because from the precondition 1207 // it's known, that <SwEdit::HasNumber()> == sal_False 1208 bActivateOutlineRule = true; 1209 } 1210 else 1211 { 1212 // turning on outline numbering at current cursor position 1213 bContinueFoundNumRule = true; 1214 } 1215 // <-- 1216 } 1217 else 1218 { 1219 // check, if numbering of the outline level of the pararaph 1220 // style is active. If not, activate this outline level. 1221 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//#outline level,zhaojianwei 1222 ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(),//#outline level,zhaojianwei 1223 "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); 1224 if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&//#outline level,zhaojianwei 1225 pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType() 1226 == SVX_NUM_NUMBER_NONE ) 1227 { 1228 // activate outline numbering 1229 bActivateOutlineRule = true; 1230 } 1231 else 1232 { 1233 // turning on outline numbering at current cursor position 1234 bContinueFoundNumRule = true; 1235 } 1236 } 1237 pNumRule = pCollRule; 1238 } 1239 } 1240 1241 // --> OD 2005-10-25 #b6340308# 1242 // Only automatic numbering/bullet rules should be changed. 1243 // Note: The outline numbering rule is also an automatic one. It's only 1244 // changed, if it has to be activated. 1245 if ( pNumRule ) 1246 { 1247 if ( !pNumRule->IsAutoRule() ) 1248 { 1249 pNumRule = 0; 1250 } 1251 else if ( pNumRule == GetDoc()->GetOutlineNumRule() && 1252 !bActivateOutlineRule && !bContinueFoundNumRule ) 1253 { 1254 pNumRule = 0; 1255 } 1256 } 1257 // <-- 1258 1259 // --> OD 2005-10-25 #b6340308# 1260 // Search for a previous numbering/bullet rule to continue it. 1261 // --> OD 2008-03-18 #refactorlists# 1262 String sContinuedListId; 1263 if ( !pNumRule ) 1264 { 1265 pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(), 1266 false, bNum, false, 0, 1267 sContinuedListId ); 1268 bContinueFoundNumRule = pNumRule != 0; 1269 } 1270 // <-- 1271 1272 if (pNumRule) 1273 { 1274 SwNumRule aNumRule(*pNumRule); 1275 1276 // --> OD 2005-10-25 #b6340308# 1277 // do not change found numbering/bullet rule, if it should only be continued. 1278 if ( !bContinueFoundNumRule ) 1279 { 1280 SwTxtNode * pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1281 1282 if (pTxtNode) 1283 { 1284 // --> OD 2005-10-26 #b6340308# - use above retrieve outline 1285 // level, if outline numbering has to be activated. 1286 int nLevel = bActivateOutlineRule ////#outline level,zhaojianwei,need more consideration 1287 ? nActivateOutlineLvl 1288 : pTxtNode->GetActualListLevel(); 1289 // <-- 1290 1291 if (nLevel < 0) 1292 nLevel = 0; 1293 1294 if (nLevel >= MAXLEVEL) 1295 nLevel = MAXLEVEL - 1; 1296 1297 SwNumFmt aFmt(aNumRule.Get(static_cast<sal_uInt16>(nLevel))); 1298 1299 if (bNum) 1300 aFmt.SetNumberingType(SVX_NUM_ARABIC); 1301 else 1302 { 1303 // --> OD 2008-06-03 #i63395# 1304 // Only apply user defined default bullet font 1305 if ( numfunc::IsDefBulletFontUserDefined() ) 1306 { 1307 const Font* pFnt = &numfunc::GetDefBulletFont(); 1308 aFmt.SetBulletFont( pFnt ); 1309 } 1310 // <-- 1311 aFmt.SetBulletChar( numfunc::GetBulletChar(static_cast<sal_uInt8>(nLevel))); 1312 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); 1313 // #i93908# clear suffix for bullet lists 1314 aFmt.SetPrefix(::rtl::OUString()); 1315 aFmt.SetSuffix(::rtl::OUString()); 1316 } 1317 aNumRule.Set(static_cast<sal_uInt16>(nLevel), aFmt); 1318 } 1319 } 1320 // <-- 1321 1322 // --> OD 2008-02-08 #newlistlevelattrs# 1323 // reset indent attribute on applying list style 1324 // --> OD 2008-03-27 #refactorlists# 1325 SetCurNumRule( aNumRule, false, sContinuedListId, true ); 1326 // <-- 1327 } 1328 else 1329 { 1330 // --> OD 2009-08-27 #i95907# 1331 const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode( 1332 numfunc::GetDefaultPositionAndSpaceMode() ); 1333 // --> OD 2008-02-11 #newlistlevelattrs# 1334 SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode ); 1335 // <-- 1336 // <-- 1337 // Zeichenvorlage an die Numerierung haengen 1338 SwCharFmt* pChrFmt; 1339 SwDocShell* pDocSh = GetView().GetDocShell(); 1340 // --> OD 2008-06-03 #i63395# 1341 // Only apply user defined default bullet font 1342 const Font* pFnt = numfunc::IsDefBulletFontUserDefined() 1343 ? &numfunc::GetDefBulletFont() 1344 : 0; 1345 // <-- 1346 1347 if (bNum) 1348 { 1349 pChrFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL ); 1350 } 1351 else 1352 { 1353 pChrFmt = GetCharFmtFromPool( RES_POOLCHR_BUL_LEVEL ); 1354 } 1355 1356 const SwTxtNode* pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1357 const SwTwips nWidthOfTabs = pTxtNode 1358 ? pTxtNode->GetWidthOfLeadingTabs() 1359 : 0; 1360 GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() ); 1361 1362 const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh); 1363 const bool bRightToLeft = IsInRightToLeftText(); 1364 for( sal_uInt8 nLvl = 0; nLvl < MAXLEVEL; ++nLvl ) 1365 { 1366 SwNumFmt aFmt( aNumRule.Get( nLvl ) ); 1367 aFmt.SetCharFmt( pChrFmt ); 1368 1369 if (! bNum) 1370 { 1371 // --> OD 2008-06-03 #i63395# 1372 // Only apply user defined default bullet font 1373 if ( pFnt ) 1374 { 1375 aFmt.SetBulletFont( pFnt ); 1376 } 1377 aFmt.SetBulletChar( numfunc::GetBulletChar(nLvl) ); 1378 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); 1379 // #i93908# clear suffix for bullet lists 1380 aFmt.SetPrefix(::rtl::OUString()); 1381 aFmt.SetSuffix(::rtl::OUString()); 1382 } 1383 1384 // --> OD 2009-08-26 #i95907# 1385 if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) 1386 { 1387 if(bHtml && nLvl) 1388 { 1389 // 1/2" fuer HTML 1390 aFmt.SetLSpace(720); 1391 aFmt.SetAbsLSpace(nLvl * 720); 1392 } 1393 else if ( nWidthOfTabs > 0 ) 1394 { 1395 aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720); 1396 } 1397 } 1398 // <-- 1399 1400 // --> FME 2005-01-21 #i38904# Default alignment for 1401 // numbering/bullet should be rtl in rtl paragraph: 1402 if ( bRightToLeft ) 1403 { 1404 aFmt.SetNumAdjust( SVX_ADJUST_RIGHT ); 1405 } 1406 // <-- 1407 1408 aNumRule.Set( nLvl, aFmt ); 1409 } 1410 1411 // --> OD 2009-08-26 #i95907# 1412 if ( pTxtNode && 1413 ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT ) 1414 { 1415 // --> OD 2010-01-05 #b6884103# 1416 // short nTxtNodeFirstLineOffset( 0 ); 1417 // pTxtNode->GetFirstLineOfsWithNum( nTxtNodeFirstLineOffset ); 1418 // const SwTwips nTxtNodeIndent = pTxtNode->GetLeftMarginForTabCalculation() + 1419 // nTxtNodeFirstLineOffset; 1420 const SwTwips nTxtNodeIndent = pTxtNode->GetAdditionalIndentForStartingNewList(); 1421 // <-- 1422 if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 ) 1423 { 1424 // --> OD 2010-05-05 #i111172# 1425 // If text node is already inside a list, assure that the indents 1426 // are the same. Thus, adjust the indent change value by subtracting 1427 // indents of to be applied list style. 1428 SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs; 1429 if ( pTxtNode->GetNumRule() ) 1430 { 1431 const SwNumFmt aFmt( aNumRule.Get( 0 ) ); 1432 if ( aFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) 1433 { 1434 nIndentChange -= aFmt.GetIndentAt() + aFmt.GetFirstLineIndent(); 1435 } 1436 } 1437 // <-- 1438 aNumRule.ChangeIndent( nIndentChange ); 1439 } 1440 } 1441 // <-- 1442 // --> OD 2008-02-08 #newlistlevelattrs# 1443 // reset indent attribute on applying list style 1444 // --> OD 2008-03-17 #refactorlists# 1445 // start new list 1446 SetCurNumRule( aNumRule, true, String(), true ); 1447 // <-- 1448 } 1449 1450 EndUndo(UNDO_NUMORNONUM); 1451 } 1452 // <- #i40041# 1453 1454 void SwWrtShell::NumOn() 1455 { 1456 NumOrBulletOn(sal_True); 1457 } 1458 1459 void SwWrtShell::NumOrBulletOff() 1460 { 1461 const SwNumRule * pCurNumRule = GetCurNumRule(); 1462 1463 if (pCurNumRule) 1464 { 1465 if (pCurNumRule->IsOutlineRule()) 1466 { 1467 SwNumRule aNumRule(*pCurNumRule); 1468 1469 SwTxtNode * pTxtNode = 1470 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1471 1472 if (pTxtNode) 1473 { 1474 sal_uInt16 nLevel = sal::static_int_cast<sal_uInt16, sal_Int32>(pTxtNode->GetActualListLevel()); 1475 SwNumFmt aFmt(aNumRule.Get(nLevel)); 1476 1477 aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE); 1478 aNumRule.Set(nLevel, aFmt); 1479 1480 // --> OD 2008-03-17 #refactorlists# 1481 // no start or continuation of a list - the outline style is only changed. 1482 SetCurNumRule( aNumRule, false ); 1483 // <-- 1484 } 1485 } 1486 else 1487 { 1488 DelNumRules(); 1489 } 1490 1491 // --> OD 2005-10-24 #126346# - Cursor can not be anymore in front of 1492 // a label, because numbering/bullet is switched off. 1493 SetInFrontOfLabel( sal_False ); 1494 // <-- 1495 } 1496 } 1497 // <- #i29560# 1498 1499 /*------------------------------------------------------------------------ 1500 Beschreibung: Default-Bulletliste erfragen 1501 ------------------------------------------------------------------------*/ 1502 1503 void SwWrtShell::BulletOn() 1504 { 1505 NumOrBulletOn(sal_False); 1506 } 1507 1508 1509 /*-------------------------------------------------- 1510 1511 --------------------------------------------------*/ 1512 SelectionType SwWrtShell::GetSelectionType() const 1513 { 1514 // ContentType kann nicht ermittelt werden innerhalb einer 1515 // Start-/Endactionklammerung. 1516 // Da es keinen ungueltigen Wert gibt, wird TEXT geliefert. 1517 // Der Wert ist egal, da in EndAction ohnehin aktualisiert wird. 1518 1519 if ( BasicActionPend() ) 1520 return IsSelFrmMode() ? nsSelectionType::SEL_FRM : nsSelectionType::SEL_TXT; 1521 1522 // if ( IsTableMode() ) 1523 // return nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS; 1524 1525 SwView &_rView = ((SwView&)GetView()); 1526 if (_rView.GetPostItMgr() && _rView.GetPostItMgr()->HasActiveSidebarWin() ) 1527 return nsSelectionType::SEL_POSTIT; 1528 int nCnt; 1529 1530 // Rahmen einfuegen ist kein DrawMode 1531 if ( !_rView.GetEditWin().IsFrmAction() && 1532 (IsObjSelected() || (_rView.IsDrawMode() && !IsFrmSelected()) )) 1533 { 1534 if (GetDrawView()->IsTextEdit()) 1535 nCnt = nsSelectionType::SEL_DRW_TXT; 1536 else 1537 { 1538 if (GetView().IsFormMode()) // Nur Forms selektiert 1539 nCnt = nsSelectionType::SEL_DRW_FORM; 1540 else 1541 nCnt = nsSelectionType::SEL_DRW; // Irgendein Draw-Objekt 1542 1543 if (_rView.IsBezierEditMode()) 1544 nCnt |= nsSelectionType::SEL_BEZ; 1545 else if( GetDrawView()->GetContext() == SDRCONTEXT_MEDIA ) 1546 nCnt |= nsSelectionType::SEL_MEDIA; 1547 1548 if (svx::checkForSelectedCustomShapes( 1549 const_cast<SdrView *>(GetDrawView()), 1550 true /* bOnlyExtruded */ )) 1551 { 1552 nCnt |= nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE; 1553 } 1554 sal_uInt32 nCheckStatus = 0; 1555 if (svx::checkForSelectedFontWork( 1556 const_cast<SdrView *>(GetDrawView()), nCheckStatus )) 1557 { 1558 nCnt |= nsSelectionType::SEL_FONTWORK; 1559 } 1560 } 1561 1562 return nCnt; 1563 } 1564 1565 nCnt = GetCntType(); 1566 1567 if ( IsFrmSelected() ) 1568 { 1569 if (_rView.IsDrawMode()) 1570 _rView.LeaveDrawCreate(); // Aufraeumen (Bug #45639) 1571 if ( !(nCnt & (CNT_GRF | CNT_OLE)) ) 1572 return nsSelectionType::SEL_FRM; 1573 } 1574 1575 if ( IsCrsrInTbl() ) 1576 nCnt |= nsSelectionType::SEL_TBL; 1577 1578 if ( IsTableMode() ) 1579 nCnt |= (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS); 1580 1581 // --> FME 2005-01-12 #i39855# 1582 // Do not pop up numbering toolbar, if the text node has a numbering 1583 // of type SVX_NUM_NUMBER_NONE. 1584 const SwNumRule* pNumRule = GetCurNumRule(); 1585 if ( pNumRule ) 1586 { 1587 const SwTxtNode* pTxtNd = 1588 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); 1589 1590 // --> OD 2008-03-19 #refactorlists# 1591 if ( pTxtNd && pTxtNd->IsInList() ) 1592 // <-- 1593 { 1594 const SwNumFmt& rFmt = pNumRule->Get(sal::static_int_cast< sal_uInt8, sal_Int32>(pTxtNd->GetActualListLevel())); 1595 if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() ) 1596 nCnt |= nsSelectionType::SEL_NUM; 1597 } 1598 } 1599 // <-- 1600 1601 return nCnt; 1602 } 1603 1604 /*------------------------------------------------------------------------ 1605 Beschreibung: Finden der TextCollection mit dem Name rCollname 1606 Return: Pointer auf die Collection oder 0, wenn keine 1607 TextCollection mit diesem Namen existiert oder 1608 diese eine Defaultvorlage ist. 1609 ------------------------------------------------------------------------*/ 1610 1611 1612 SwTxtFmtColl *SwWrtShell::GetParaStyle(const String &rCollName, GetStyle eCreate ) 1613 { 1614 SwTxtFmtColl* pColl = FindTxtFmtCollByName( rCollName ); 1615 if( !pColl && GETSTYLE_NOCREATE != eCreate ) 1616 { 1617 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); 1618 if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate ) 1619 pColl = GetTxtCollFromPool( nId ); 1620 } 1621 return pColl; 1622 } 1623 /*------------------------------------------------------------------------ 1624 Beschreibung: Finden der Zeichenvorlage mit dem Name rCollname 1625 Return: Pointer auf die Collection oder 0, wenn keine 1626 Zeichenvorlage mit diesem Namen existiert oder 1627 diese eine Defaultvorlage oder automatische Vorlage ist. 1628 ------------------------------------------------------------------------*/ 1629 1630 1631 1632 SwCharFmt *SwWrtShell::GetCharStyle(const String &rFmtName, GetStyle eCreate ) 1633 { 1634 SwCharFmt* pFmt = FindCharFmtByName( rFmtName ); 1635 if( !pFmt && GETSTYLE_NOCREATE != eCreate ) 1636 { 1637 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rFmtName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); 1638 if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate ) 1639 pFmt = (SwCharFmt*)GetFmtFromPool( nId ); 1640 } 1641 return pFmt; 1642 } 1643 1644 /*------------------------------------------------------------------------ 1645 Beschreibung: Finden des Tabellenformates mit dem Name rFmtname 1646 Return: Pointer auf das Format oder 0, wenn kein 1647 Rahmenformat mit diesem Namen existiert oder 1648 dieses eine Defaultformat oder automatisches Format ist. 1649 ------------------------------------------------------------------------*/ 1650 1651 1652 1653 SwFrmFmt *SwWrtShell::GetTblStyle(const String &rFmtName) 1654 { 1655 SwFrmFmt *pFmt = 0; 1656 for( sal_uInt16 i = GetTblFrmFmtCount(); i; ) 1657 if( !( pFmt = &GetTblFrmFmt( --i ) )->IsDefault() && 1658 pFmt->GetName() == rFmtName && IsUsed( *pFmt ) ) 1659 return pFmt; 1660 return 0; 1661 } 1662 1663 1664 /*------------------------------------------------------------------------ 1665 Beschreibung: Anwenden der Vorlagen 1666 ------------------------------------------------------------------------*/ 1667 1668 1669 1670 void SwWrtShell::SetPageStyle(const String &rCollName) 1671 { 1672 if( !SwCrsrShell::HasSelection() && !IsSelFrmMode() && !IsObjSelected() ) 1673 { 1674 SwPageDesc* pDesc = FindPageDescByName( rCollName, sal_True ); 1675 if( pDesc ) 1676 ChgCurPageDesc( *pDesc ); 1677 } 1678 } 1679 1680 /*------------------------------------------------------------------------ 1681 Beschreibung: Zugriff Vorlagen 1682 ------------------------------------------------------------------------*/ 1683 1684 1685 1686 String SwWrtShell::GetCurPageStyle( const sal_Bool bCalcFrm ) const 1687 { 1688 return GetPageDesc(GetCurPageDesc( bCalcFrm )).GetName(); 1689 } 1690 1691 /*------------------------------------------------------------------------ 1692 Beschreibung: Aktuelle Vorlage anhand der geltenden Attribute aendern 1693 ------------------------------------------------------------------------*/ 1694 1695 1696 void SwWrtShell::QuickUpdateStyle() 1697 { 1698 SwTxtFmtColl *pColl = GetCurTxtFmtColl(); 1699 1700 // Standard kann nicht geaendert werden 1701 if(pColl && !pColl->IsDefault()) 1702 { 1703 FillByEx(pColl); 1704 // Vorlage auch anwenden, um harte Attributierung 1705 // zu entfernen 1706 SetTxtFmtColl(pColl); 1707 } 1708 } 1709 1710 1711 void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet) 1712 { 1713 SfxItemSet aCoreSet( GetAttrPool(), 1714 RES_CHRATR_BEGIN, RES_CHRATR_END - 1, 1715 RES_PARATR_BEGIN, RES_PARATR_END - 1, 1716 RES_FRMATR_BEGIN, RES_FRMATR_END - 1, 1717 SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS, 1718 SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS, 1719 SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET, 1720 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 1721 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP, 1722 SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM, 1723 0 ); 1724 GetCurAttr( aCoreSet ); 1725 sal_Bool bReset = sal_False; 1726 SfxItemIter aParaIter( aCoreSet ); 1727 const SfxPoolItem* pParaItem = aParaIter.FirstItem(); 1728 while( pParaItem ) 1729 { 1730 if(!IsInvalidItem(pParaItem)) 1731 { 1732 sal_uInt16 nWhich = pParaItem->Which(); 1733 if(SFX_ITEM_SET == aCoreSet.GetItemState(nWhich) && 1734 SFX_ITEM_SET == rStyleSet.GetItemState(nWhich)) 1735 { 1736 aCoreSet.ClearItem(nWhich); 1737 bReset = sal_True; 1738 } 1739 } 1740 pParaItem = aParaIter.NextItem(); 1741 } 1742 StartAction(); 1743 if(bReset) 1744 { 1745 ResetAttr(); 1746 SetAttr(aCoreSet); 1747 } 1748 pDoc->ChgFmt(*pColl, rStyleSet ); 1749 EndAction(); 1750 } 1751 1752 /*-----------------12.03.97 12.24------------------- 1753 1754 --------------------------------------------------*/ 1755 1756 void SwWrtShell::AutoUpdateFrame( SwFrmFmt* pFmt, const SfxItemSet& rStyleSet ) 1757 { 1758 StartAction(); 1759 1760 ResetFlyFrmAttr( 0, &rStyleSet ); 1761 pFmt->SetFmtAttr( rStyleSet ); 1762 1763 EndAction(); 1764 } 1765 1766 1767 void SwWrtShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar ) 1768 { 1769 ResetCursorStack(); 1770 if(_CanInsert()) 1771 { 1772 sal_Bool bStarted = sal_False; 1773 if(HasSelection()) 1774 { 1775 // nur hier klammern, da das normale Insert schon an der 1776 // Editshell geklammert ist 1777 StartAllAction(); 1778 StartUndo(UNDO_INSERT); 1779 bStarted = sal_True; 1780 DelRight(); 1781 } 1782 SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar ); 1783 1784 if(bStarted) 1785 { 1786 EndAllAction(); 1787 EndUndo(UNDO_INSERT); 1788 } 1789 } 1790 } 1791 1792 1793 /* 1794 * eine Art kontrollierter copy ctor 1795 */ 1796 1797 SwWrtShell::SwWrtShell( SwWrtShell& rSh, Window *_pWin, SwView &rShell ) 1798 : SwFEShell( rSh, _pWin ), 1799 COMMON_INI_LIST 1800 { 1801 BITFLD_INI_LIST 1802 SET_CURR_SHELL( this ); 1803 1804 SetSfxViewShell( (SfxViewShell *)&rShell ); 1805 SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) ); 1806 1807 // place the cursor on the first field... 1808 IFieldmark *pBM = NULL; 1809 if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=NULL ) { 1810 GotoFieldmark(pBM); 1811 } 1812 } 1813 1814 1815 SwWrtShell::SwWrtShell( SwDoc& rDoc, Window *_pWin, SwView &rShell, 1816 const SwViewOption *pViewOpt ) 1817 : SwFEShell( rDoc, _pWin, pViewOpt), 1818 COMMON_INI_LIST 1819 { 1820 BITFLD_INI_LIST 1821 SET_CURR_SHELL( this ); 1822 SetSfxViewShell( (SfxViewShell *)&rShell ); 1823 SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) ); 1824 } 1825 1826 /* 1827 * ctor 1828 */ 1829 1830 1831 1832 SwWrtShell::~SwWrtShell() 1833 { 1834 SET_CURR_SHELL( this ); 1835 while(IsModePushed()) 1836 PopMode(); 1837 while(PopCrsr(sal_False)) 1838 ; 1839 SwTransferable::ClearSelection( *this ); 1840 } 1841 1842 sal_Bool SwWrtShell::Pop( sal_Bool bOldCrsr ) 1843 { 1844 sal_Bool bRet = SwCrsrShell::Pop( bOldCrsr ); 1845 if( bRet && IsSelection() ) 1846 { 1847 fnSetCrsr = &SwWrtShell::SetCrsrKillSel; 1848 fnKillSel = &SwWrtShell::ResetSelect; 1849 } 1850 return bRet; 1851 } 1852 1853 /*-------------------------------------------------------------------- 1854 Beschreibung: 1855 --------------------------------------------------------------------*/ 1856 sal_Bool SwWrtShell::CanInsert() 1857 { 1858 return (!(IsSelFrmMode() | IsObjSelected() | (GetView().GetDrawFuncPtr() != NULL) | (GetView().GetPostItMgr()->GetActiveSidebarWin()!= NULL))); 1859 } 1860 1861 // die Core erzeugt eine Selektion, das SttSelect muss gerufen werden 1862 void SwWrtShell::NewCoreSelection() 1863 { 1864 SttSelect(); 1865 } 1866 1867 // -------------- 1868 void SwWrtShell::ChgDBData(const SwDBData& aDBData) 1869 { 1870 SwEditShell::ChgDBData(aDBData); 1871 //notify the db-beamer if available 1872 GetView().NotifyDBChanged(); 1873 } 1874 1875 String SwWrtShell::GetSelDescr() const 1876 { 1877 String aResult; 1878 1879 int nSelType = GetSelectionType(); 1880 switch (nSelType) 1881 { 1882 case nsSelectionType::SEL_GRF: 1883 aResult = SW_RES(STR_GRAPHIC); 1884 1885 break; 1886 case nsSelectionType::SEL_FRM: 1887 { 1888 const SwFrmFmt * pFrmFmt = GetCurFrmFmt(); 1889 1890 if (pFrmFmt) 1891 aResult = pFrmFmt->GetDescription(); 1892 } 1893 break; 1894 case nsSelectionType::SEL_DRW: 1895 { 1896 aResult = SW_RES(STR_DRAWING_OBJECTS); 1897 } 1898 break; 1899 default: 1900 if (0 != pDoc) 1901 aResult = GetCrsrDescr(); 1902 } 1903 1904 return aResult; 1905 } 1906 1907 void SwWrtShell::ApplyViewOptions( const SwViewOption &rOpt ) 1908 { 1909 SwFEShell::ApplyViewOptions( rOpt ); 1910 //#i115062# invalidate meta character slot 1911 GetView().GetViewFrame()->GetBindings().Invalidate( FN_VIEW_META_CHARS ); 1912 } 1913 1914 1915