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