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 "viscrs.hxx" 32 #include <sfx2/frame.hxx> 33 #include <sfx2/printer.hxx> 34 #include <cmdid.h> 35 #include <hintids.hxx> 36 #include <docsh.hxx> 37 #include <rubylist.hxx> 38 #include <doc.hxx> 39 #include <unotxvw.hxx> 40 #include <unodispatch.hxx> 41 #include <unomap.hxx> 42 #include <unostyle.hxx> 43 #include <unoprnms.hxx> 44 #include <view.hxx> 45 #include <viewopt.hxx> 46 #include <unomod.hxx> 47 #include <unoframe.hxx> 48 #include <unocrsr.hxx> 49 #include <wrtsh.hxx> 50 #include <unotbl.hxx> 51 #include <svx/fmshell.hxx> 52 #include <svx/svdview.hxx> 53 #include <svx/svdpage.hxx> 54 #include <svx/svdouno.hxx> 55 #include <svx/svdogrp.hxx> 56 #include <editeng/pbinitem.hxx> 57 #include <pagedesc.hxx> 58 #include <editeng/lrspitem.hxx> 59 #include <editeng/ulspitem.hxx> 60 #include <sfx2/bindings.hxx> 61 #include <sfx2/request.hxx> 62 #include <frmatr.hxx> 63 #include <vos/mutex.hxx> 64 #include <IMark.hxx> 65 #include <unotxdoc.hxx> 66 #include <unodraw.hxx> 67 #include <svx/unoshcol.hxx> 68 #include <svx/unoshape.hxx> 69 #include <svx/svdpagv.hxx> 70 #include <swerror.h> 71 #include <tools/cachestr.hxx> 72 #include <shellio.hxx> 73 #include <ndtxt.hxx> 74 #include <SwStyleNameMapper.hxx> 75 #include <crsskip.hxx> 76 #include <com/sun/star/beans/PropertyAttribute.hpp> 77 #include <editeng/outliner.hxx> 78 #include <editeng/editview.hxx> 79 #include <unobookmark.hxx> 80 #include <unoparagraph.hxx> 81 #include <unocrsrhelper.hxx> 82 #include <unotextrange.hxx> 83 #include <sfx2/docfile.hxx> 84 #include <switerator.hxx> 85 #include "swdtflvr.hxx" 86 #include <vcl/svapp.hxx> 87 88 89 using namespace ::com::sun::star; 90 using namespace ::com::sun::star::uno; 91 using namespace ::com::sun::star::lang; 92 using namespace ::com::sun::star::beans; 93 using namespace ::com::sun::star::text; 94 using namespace ::com::sun::star::view; 95 using namespace ::com::sun::star::frame; 96 using namespace rtl; 97 98 using ::com::sun::star::util::URL; 99 using comphelper::HelperBaseNoState; 100 101 SV_IMPL_PTRARR( SelectionChangeListenerArr, XSelectionChangeListenerPtr ); 102 103 /* -----------------22.05.98 12:20------------------- 104 * 105 * --------------------------------------------------*/ 106 SwPaM* lcl_createPamCopy(const SwPaM& rPam) 107 { 108 SwPaM *const pRet = new SwPaM(*rPam.GetPoint()); 109 ::sw::DeepCopyPaM(rPam, *pRet); 110 return pRet; 111 } 112 /****************************************************************** 113 * SwXTextView 114 ******************************************************************/ 115 /*-- 17.12.98 09:34:25--------------------------------------------------- 116 117 -----------------------------------------------------------------------*/ 118 SwXTextView::SwXTextView(SwView* pSwView) : 119 SfxBaseController(pSwView), 120 m_pView(pSwView), 121 m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ), 122 pxViewSettings(0), 123 pxTextViewCursor(0) 124 { 125 126 } 127 /*-- 17.12.98 09:34:25--------------------------------------------------- 128 129 -----------------------------------------------------------------------*/ 130 SwXTextView::~SwXTextView() 131 { 132 Invalidate(); 133 } 134 /* -----------------------------09.03.01 15:47-------------------------------- 135 136 ---------------------------------------------------------------------------*/ 137 void SwXTextView::Invalidate() 138 { 139 if(pxViewSettings) 140 { 141 HelperBaseNoState *pSettings = static_cast < HelperBaseNoState * > ( pxViewSettings->get() ); 142 static_cast < SwXViewSettings* > ( pSettings )->Invalidate(); 143 DELETEZ(pxViewSettings); 144 } 145 if(pxTextViewCursor) 146 { 147 text::XTextViewCursor* pCrsr = pxTextViewCursor->get(); 148 ((SwXTextViewCursor*)pCrsr)->Invalidate(); 149 DELETEZ(pxTextViewCursor); 150 } 151 152 m_refCount++; //prevent second d'tor call 153 154 sal_uInt16 nCount = aSelChangedListeners.Count(); 155 if(nCount) 156 { 157 uno::Reference< uno::XInterface > xInt = (cppu::OWeakObject*)(SfxBaseController*)this; 158 lang::EventObject aEvent(xInt); 159 for ( sal_uInt16 i = nCount; i--; ) 160 { 161 uno::Reference< view::XSelectionChangeListener > *pObj = aSelChangedListeners[i]; 162 (*pObj)->disposing(aEvent); 163 } 164 } 165 166 // #i85580: now clean up any possibly remaining entries in the array... 167 // (i.e. listeners that did not call removeSelectionChangeListener in their disposing.) 168 while ((nCount = aSelChangedListeners.Count()) != 0) 169 { 170 removeSelectionChangeListener( *aSelChangedListeners[0] ); 171 } 172 173 m_refCount--; 174 m_pView = 0; 175 } 176 177 /* -----------------------------18.05.00 10:18-------------------------------- 178 179 ---------------------------------------------------------------------------*/ 180 Sequence< uno::Type > SAL_CALL SwXTextView::getTypes( ) throw(uno::RuntimeException) 181 { 182 // uno::Sequence< uno::Type > aViewTypes = SwXTextViewBaseClass::getTypes(); 183 uno::Sequence< uno::Type > aBaseTypes = SfxBaseController::getTypes(); 184 185 long nIndex = aBaseTypes.getLength(); 186 aBaseTypes.realloc( 187 aBaseTypes.getLength() + 8 ); 188 189 uno::Type* pBaseTypes = aBaseTypes.getArray(); 190 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XSelectionSupplier >*)0); 191 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XServiceInfo >*)0); 192 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XFormLayerAccess >*)0); 193 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XTextViewCursorSupplier>*)0); 194 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XViewSettingsSupplier >*)0); 195 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XRubySelection >*)0); 196 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XPropertySet >*)0); 197 pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0); 198 return aBaseTypes; 199 } 200 /* -----------------------------18.05.00 10:18-------------------------------- 201 202 ---------------------------------------------------------------------------*/ 203 Sequence< sal_Int8 > SAL_CALL SwXTextView::getImplementationId( ) throw(uno::RuntimeException) 204 { 205 vos::OGuard aGuard(Application::GetSolarMutex()); 206 static Sequence< sal_Int8 > aId( 16 ); 207 static sal_Bool bInit = sal_False; 208 if(!bInit) 209 { 210 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 211 bInit = sal_True; 212 } 213 return aId; 214 } 215 /* -----------------------------18.05.00 10:18-------------------------------- 216 217 ---------------------------------------------------------------------------*/ 218 void SAL_CALL SwXTextView::acquire( )throw() 219 { 220 SfxBaseController::acquire(); 221 } 222 /* -----------------------------18.05.00 10:18-------------------------------- 223 224 ---------------------------------------------------------------------------*/ 225 void SAL_CALL SwXTextView::release( )throw() 226 { 227 SfxBaseController::release(); 228 } 229 /* -----------------------------18.05.00 10:23-------------------------------- 230 231 ---------------------------------------------------------------------------*/ 232 uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType ) 233 throw (RuntimeException) 234 { 235 uno::Any aRet; 236 if(aType == ::getCppuType((uno::Reference<view::XSelectionSupplier >*)0)) 237 { 238 uno::Reference<view::XSelectionSupplier> xRet = this; 239 aRet.setValue(&xRet, aType); 240 } 241 else if(aType == ::getCppuType((uno::Reference<lang::XServiceInfo >*)0)) 242 { 243 uno::Reference<lang::XServiceInfo> xRet = this; 244 aRet.setValue(&xRet, aType); 245 } 246 else if(aType == ::getCppuType((uno::Reference<view::XControlAccess >*)0)) 247 { 248 uno::Reference<view::XControlAccess> xRet = this; 249 aRet.setValue(&xRet, aType); 250 } 251 else if(aType == ::getCppuType((uno::Reference<view::XFormLayerAccess >*)0)) 252 { 253 uno::Reference<view::XFormLayerAccess> xRet = this; 254 aRet.setValue(&xRet, aType); 255 } 256 else if(aType == ::getCppuType((uno::Reference<text::XTextViewCursorSupplier>*)0)) 257 { 258 uno::Reference<text::XTextViewCursorSupplier> xRet = this; 259 aRet.setValue(&xRet, aType); 260 } 261 else if(aType == ::getCppuType((uno::Reference<view::XViewSettingsSupplier >*)0)) 262 { 263 uno::Reference<view::XViewSettingsSupplier> xRet = this; 264 aRet.setValue(&xRet, aType); 265 } 266 else if(aType == ::getCppuType((uno::Reference<XRubySelection>*)0)) 267 { 268 uno::Reference<XRubySelection> xRet = this; 269 aRet.setValue(&xRet, aType); 270 } 271 else if(aType == ::getCppuType((uno::Reference<XPropertySet>*)0)) 272 { 273 uno::Reference<XPropertySet> xRet = this; 274 aRet.setValue(&xRet, aType); 275 } 276 else if(aType == ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0)) 277 { 278 uno::Reference<datatransfer::XTransferableSupplier> xRet = this; 279 aRet.setValue(&xRet, aType); 280 } 281 else 282 aRet = SfxBaseController::queryInterface(aType); 283 return aRet; 284 } 285 /*-- 17.12.98 09:34:26--------------------------------------------------- 286 287 -----------------------------------------------------------------------*/ 288 sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArgumentException, uno::RuntimeException ) 289 { 290 ::vos::OGuard aGuard(Application::GetSolarMutex()); 291 uno::Reference< uno::XInterface > xInterface; 292 if(GetView() && (aInterface >>= xInterface)) 293 { 294 SwWrtShell& rSh = GetView()->GetWrtShell(); 295 SwDoc* pDoc = GetView()->GetDocShell()->GetDoc(); 296 uno::Reference< lang::XUnoTunnel > xIfcTunnel(xInterface, uno::UNO_QUERY); 297 uno::Reference< text::XTextCursor > xCrsr(xInterface, uno::UNO_QUERY); 298 uno::Reference< container::XIndexAccess > xPosN(xInterface, uno::UNO_QUERY); 299 uno::Reference< text::XTextRange > xPos(xInterface, uno::UNO_QUERY); 300 SwXFrame* pFrame = xIfcTunnel.is() ? reinterpret_cast<SwXFrame*>( 301 xIfcTunnel->getSomething(SwXFrame::getUnoTunnelId())) : 0; 302 303 SwXCell* pCell = xIfcTunnel.is() ? reinterpret_cast<SwXCell*>( 304 xIfcTunnel->getSomething(SwXCell::getUnoTunnelId())) : 0; 305 306 SwPaM * pPam = 0; 307 SwXTextRanges* pPosN = 0; 308 if(xCrsr.is()) 309 { 310 // 311 OTextCursorHelper* pCursor = 312 xIfcTunnel.is() ? 313 reinterpret_cast<OTextCursorHelper*>(xIfcTunnel->getSomething(OTextCursorHelper::getUnoTunnelId())) 314 : 0; 315 316 if(pCursor && pCursor->GetDoc() == GetView()->GetDocShell()->GetDoc()) 317 { 318 pPam = lcl_createPamCopy(*pCursor->GetPaM()); 319 } 320 } 321 else if(xPosN.is() && 322 xIfcTunnel.is() && 323 0 != (pPosN = reinterpret_cast<SwXTextRanges*>(xIfcTunnel->getSomething(SwXTextRanges::getUnoTunnelId())))) 324 { 325 const SwUnoCrsr* pUnoCrsr = pPosN->GetCursor(); 326 if(pUnoCrsr) 327 { 328 pPam = lcl_createPamCopy(*pUnoCrsr); 329 } 330 } 331 // prevent misinterpretation of text frames that provide a XTextRange interface, too 332 else if(!pFrame && !pCell && xPos.is()) 333 { 334 SwUnoInternalPaM aPam(*pDoc); 335 if (::sw::XTextRangeToSwPaM(aPam, xPos)) 336 { 337 pPam = lcl_createPamCopy(aPam); 338 } 339 } 340 if(pPam) 341 { 342 rSh.EnterStdMode(); 343 rSh.SetSelection(*pPam); 344 while( pPam->GetNext() != pPam ) 345 delete pPam->GetNext(); 346 delete pPam; 347 return sal_True; 348 } 349 if(pFrame) 350 { 351 352 SwFrmFmt* pFrmFmt = pFrame->GetFrmFmt(); 353 if(pFrmFmt && pFrmFmt->GetDoc() == pDoc) 354 { 355 sal_Bool bSuccess = rSh.GotoFly( pFrmFmt->GetName(), pFrame->GetFlyCntType()); 356 if (bSuccess) 357 { 358 rSh.HideCrsr(); 359 rSh.EnterSelFrmMode(); 360 } 361 return sal_True; 362 } 363 } 364 365 uno::Reference< text::XTextTable > xTbl(xInterface, uno::UNO_QUERY);; 366 367 if(xTbl.is() && xIfcTunnel.is()) 368 { 369 SwXTextTable* pTable = reinterpret_cast<SwXTextTable*>( 370 xIfcTunnel->getSomething(SwXTextTable::getUnoTunnelId())); 371 372 SwFrmFmt* pTblFrmFmt = pTable ? ((SwXTextTable*)pTable)->GetFrmFmt() : 0; 373 if(pTblFrmFmt &&pTblFrmFmt->GetDoc() == pDoc) 374 { 375 rSh.EnterStdMode(); 376 rSh.GotoTable(pTblFrmFmt->GetName()); 377 } 378 return sal_True; 379 } 380 381 if(pCell) 382 { 383 SwFrmFmt* pTblFrmFmt = pCell->GetFrmFmt(); 384 if(pTblFrmFmt && pTblFrmFmt->GetDoc() == pDoc) 385 { 386 SwTableBox* pBox = pCell->GetTblBox(); 387 SwTable* pTable = SwTable::FindTable( pTblFrmFmt ); 388 pBox = pCell->FindBox(pTable, pBox); 389 if(pBox) 390 { 391 const SwStartNode* pSttNd = pBox->GetSttNd(); 392 SwPosition aPos(*pSttNd); 393 SwPaM aPam(aPos); 394 aPam.Move(fnMoveForward, fnGoNode); 395 rSh.EnterStdMode(); 396 rSh.SetSelection(aPam); 397 return sal_True; 398 } 399 } 400 } 401 SwXCellRange* pRange = xIfcTunnel.is() ? reinterpret_cast<SwXCellRange*>( 402 xIfcTunnel->getSomething(SwXCellRange::getUnoTunnelId())) : 0; 403 if(pRange) 404 { 405 const SwUnoCrsr* pUnoCrsr = pRange->GetTblCrsr(); 406 if(pUnoCrsr) 407 { 408 UnoActionRemoveContext aContext(pDoc); 409 rSh.EnterStdMode(); 410 rSh.SetSelection(*pUnoCrsr); 411 return sal_True; 412 } 413 } 414 uno::Reference< text::XTextContent > xBkm(xInterface, uno::UNO_QUERY);; 415 416 if(xBkm.is() && xIfcTunnel.is()) 417 { 418 ::sw::mark::IMark const*const pMark( 419 SwXBookmark::GetBookmarkInDoc(pDoc, xIfcTunnel) ); 420 if (pMark) 421 { 422 rSh.EnterStdMode(); 423 rSh.GotoMark(pMark); 424 return sal_True; 425 } 426 } 427 // IndexMark, Index, TextField, Draw, Section, Footnote, Paragraph 428 // 429 430 // detect controls 431 432 uno::Reference< awt::XControlModel > xCtrlModel(xInterface, UNO_QUERY); 433 if(xCtrlModel.is()) 434 { 435 uno::Reference<awt::XControl> XControl; 436 SdrObject* pObj = GetControl(xCtrlModel, XControl); 437 if(pObj) 438 { 439 SdrView* pDrawView = rSh.GetDrawView(); 440 SdrPageView* pPV = pDrawView->GetSdrPageView(); 441 if ( pPV && pObj->GetPage() == pPV->GetPage() ) 442 { 443 pDrawView->SdrEndTextEdit(); 444 pDrawView->UnmarkAll(); 445 pDrawView->MarkObj( pObj, pPV ); 446 } 447 return sal_True; 448 } 449 } 450 451 uno::Reference< drawing::XShapes > xShapeColl( xInterface, uno::UNO_QUERY ); 452 uno::Reference< beans::XPropertySet > xTmpProp(xInterface, uno::UNO_QUERY); 453 SwXShape* pSwXShape = 0; 454 if(xIfcTunnel.is()) 455 pSwXShape = reinterpret_cast<SwXShape*>(xIfcTunnel->getSomething(SwXShape::getUnoTunnelId())); 456 SvxShape* pSvxShape = 0; 457 if(pSwXShape) 458 { 459 uno::Reference< uno::XAggregation > xAgg = pSwXShape->GetAggregationInterface(); 460 if(xAgg.is()) 461 { 462 pSvxShape = reinterpret_cast<SvxShape*>(xIfcTunnel->getSomething(SvxShape::getUnoTunnelId())); 463 } 464 } 465 466 if ( pSvxShape || xShapeColl.is() ) // Drawing drawing::Layer 467 { 468 SdrView* pDrawView = rSh.GetDrawView(); 469 if (pDrawView) 470 { 471 pDrawView->SdrEndTextEdit(); 472 pDrawView->UnmarkAll(); 473 474 if (pSvxShape) // einzelnes Shape 475 { 476 SdrObject *pObj = pSvxShape->GetSdrObject(); 477 if (pObj) 478 { 479 // lcl_ShowObject( *m_pViewSh, *pDrawView, pObj ); 480 SdrPageView* pPV = pDrawView->GetSdrPageView(); 481 if ( pPV && pObj->GetPage() == pPV->GetPage() ) 482 { 483 pDrawView->MarkObj( pObj, pPV ); 484 return sal_True; 485 } 486 } 487 } 488 else // Shape Collection 489 { 490 sal_Bool bSelected = sal_False; 491 SdrPageView* pPV = NULL; 492 long nCount = xShapeColl->getCount(); 493 for ( long i = 0; i < nCount; i++ ) 494 { 495 uno::Reference< drawing::XShape > xShapeInt; 496 uno::Any aAny = xShapeColl->getByIndex(i); 497 aAny >>= xShapeInt; 498 if (xShapeInt.is()) 499 { 500 uno::Reference< lang::XUnoTunnel> xShapeTunnel(xShapeInt, uno::UNO_QUERY); 501 502 SvxShape* pShape = xShapeTunnel.is() ? 503 reinterpret_cast<SvxShape*>(xShapeTunnel->getSomething(SvxShape::getUnoTunnelId())) : 0; 504 505 if (pShape) 506 { 507 SdrObject *pObj = pShape->GetSdrObject(); 508 if (pObj) 509 { 510 if (!pPV) // erstes Objekt 511 { 512 // lcl_ShowObject( *m_pViewSh, *pDrawView, pObj ); 513 pPV = pDrawView->GetSdrPageView(); 514 } 515 if ( pPV && pObj->GetPage() == pPV->GetPage() ) 516 { 517 pDrawView->MarkObj( pObj, pPV ); 518 bSelected = sal_True; 519 } 520 } 521 } 522 } 523 } 524 return bSelected; 525 } 526 } 527 } 528 } 529 return sal_False; 530 531 } 532 /*-- 17.12.98 09:34:26--------------------------------------------------- 533 534 -----------------------------------------------------------------------*/ 535 uno::Any SwXTextView::getSelection(void) throw( uno::RuntimeException ) 536 { 537 ::vos::OGuard aGuard(Application::GetSolarMutex()); 538 uno::Reference< uno::XInterface > aRef; 539 if(GetView()) 540 { 541 //force immediat shell update 542 m_pView->StopShellTimer(); 543 // ein interface aus der aktuellen Selektion erzeugen 544 SwWrtShell& rSh = m_pView->GetWrtShell(); 545 ShellModes eSelMode = m_pView->GetShellMode(); 546 switch(eSelMode) 547 { 548 case SHELL_MODE_TABLE_TEXT : 549 { 550 if(rSh.GetTableCrsr()) 551 { 552 DBG_ASSERT(rSh.GetTableFmt(), "kein Tabellenformat?"); 553 uno::Reference< text::XTextTableCursor > xCrsr = new SwXTextTableCursor(*rSh.GetTableFmt(), 554 rSh.GetTableCrsr()); 555 aRef = uno::Reference< uno::XInterface > (xCrsr, uno::UNO_QUERY);; 556 break; 557 } 558 559 } 560 // ohne Tabellenselektion wird der Text geliefert 561 //break; 562 case SHELL_MODE_LIST_TEXT : 563 case SHELL_MODE_TABLE_LIST_TEXT: 564 case SHELL_MODE_TEXT : 565 { 566 uno::Reference< container::XIndexAccess > xPos = new SwXTextRanges(rSh.GetCrsr()); 567 aRef = uno::Reference< uno::XInterface >(xPos, uno::UNO_QUERY); 568 } 569 break; 570 case SHELL_MODE_FRAME : 571 case SHELL_MODE_GRAPHIC : 572 case SHELL_MODE_OBJECT : 573 { 574 //Get FlyFrameFormat; fuer UI Macro Anbindung an Flys 575 const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt(); 576 if (pFmt) 577 { 578 SwXFrame* pxFrame = SwIterator<SwXFrame,SwFmt>::FirstElement(*pFmt); 579 if(pxFrame) //das einzige gemeinsame interface fuer alle Frames 580 { 581 aRef = uno::Reference< uno::XInterface >((cppu::OWeakObject*)pxFrame, uno::UNO_QUERY); 582 } 583 else 584 { 585 if(SHELL_MODE_FRAME == eSelMode) 586 { 587 uno::Reference< text::XTextFrame > xFrm = new SwXTextFrame((SwFrmFmt&)*pFmt); 588 aRef = uno::Reference< uno::XInterface >(xFrm, uno::UNO_QUERY); 589 } 590 else if(SHELL_MODE_GRAPHIC == eSelMode) 591 { 592 uno::Reference< text::XTextContent > xFrm = new SwXTextGraphicObject((SwFrmFmt&)*pFmt); 593 aRef = xFrm; 594 } 595 else 596 { 597 uno::Reference< text::XTextContent > xFrm = new SwXTextEmbeddedObject((SwFrmFmt&)*pFmt); 598 aRef = xFrm; 599 } 600 } 601 } 602 } 603 break; 604 case SHELL_MODE_DRAW : 605 case SHELL_MODE_DRAW_CTRL : 606 case SHELL_MODE_DRAW_FORM : 607 case SHELL_MODE_DRAWTEXT : 608 case SHELL_MODE_BEZIER : 609 { 610 uno::Reference< drawing::XDrawPageSupplier > xPageSupp; 611 uno::Reference< frame::XModel > xModel = m_pView->GetDocShell()->GetBaseModel(); 612 uno::Reference< lang::XUnoTunnel > xModelTunnel(xModel, uno::UNO_QUERY); 613 SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument*>(xModelTunnel-> 614 getSomething(SwXTextDocument::getUnoTunnelId())); 615 616 SwFmDrawPage* pSvxDrawPage = pTextDoc->GetDrawPage()->GetSvxPage(); 617 uno::Reference< drawing::XShapes > xShCol = new SvxShapeCollection(); 618 619 const SdrMarkList& rMarkList = rSh.GetDrawView()->GetMarkedObjectList(); 620 for(sal_uInt16 i = 0; i < rMarkList.GetMarkCount(); i++) 621 { 622 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); 623 uno::Reference< uno::XInterface > xInt = pSvxDrawPage->GetInterface( pObj ); 624 uno::Reference< drawing::XShape > xShape(xInt, uno::UNO_QUERY);; 625 xShCol->add(xShape); 626 } 627 aRef = uno::Reference< uno::XInterface >(xShCol, uno::UNO_QUERY); 628 } 629 break; 630 default:;//prevent warning 631 } 632 } 633 uno::Any aRet(&aRef, ::getCppuType((uno::Reference<uno::XInterface>*)0)); 634 return aRet; 635 } 636 /*-- 17.12.98 09:34:27--------------------------------------------------- 637 638 -----------------------------------------------------------------------*/ 639 void SwXTextView::addSelectionChangeListener( 640 const uno::Reference< view::XSelectionChangeListener > & rxListener) 641 throw( uno::RuntimeException ) 642 { 643 ::vos::OGuard aGuard(Application::GetSolarMutex()); 644 uno::Reference< view::XSelectionChangeListener > * pInsert = new uno::Reference< view::XSelectionChangeListener > ; 645 *pInsert = rxListener; 646 aSelChangedListeners.Insert(pInsert, aSelChangedListeners.Count()); 647 } 648 /*-- 17.12.98 09:34:27--------------------------------------------------- 649 650 -----------------------------------------------------------------------*/ 651 void SwXTextView::removeSelectionChangeListener( 652 const uno::Reference< view::XSelectionChangeListener > & rxListener) 653 throw( uno::RuntimeException ) 654 { 655 ::vos::OGuard aGuard(Application::GetSolarMutex()); 656 view::XSelectionChangeListener* pLeft = rxListener.get(); 657 for(sal_uInt16 i = 0; i < aSelChangedListeners.Count(); i++) 658 { 659 uno::Reference< view::XSelectionChangeListener > * pElem = aSelChangedListeners.GetObject(i); 660 view::XSelectionChangeListener* pRight = pElem->get(); 661 if(pLeft == pRight) 662 { 663 aSelChangedListeners.Remove(i); 664 delete pElem; 665 break; 666 } 667 } 668 } 669 /* -----------------------------01.06.01 14:41-------------------------------- 670 671 ---------------------------------------------------------------------------*/ 672 SdrObject* SwXTextView::GetControl( 673 const uno::Reference< awt::XControlModel > & xModel, 674 uno::Reference< awt::XControl >& xToFill ) 675 { 676 SwView* pView2 = GetView(); 677 FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL; 678 SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL; 679 Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL; 680 681 DBG_ASSERT( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" ); 682 683 SdrObject* pControl = NULL; 684 if ( pFormShell && pDrawView && pWindow ) 685 pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow, xToFill ); 686 return pControl; 687 } 688 /*-- 17.12.98 09:34:27--------------------------------------------------- 689 690 -----------------------------------------------------------------------*/ 691 uno::Reference< awt::XControl > SwXTextView::getControl(const uno::Reference< awt::XControlModel > & xModel) 692 throw( container::NoSuchElementException, uno::RuntimeException ) 693 { 694 ::vos::OGuard aGuard(Application::GetSolarMutex()); 695 uno::Reference< awt::XControl > xRet; 696 GetControl(xModel, xRet); 697 return xRet; 698 } 699 700 /*-- 08.03.07 13:55------------------------------------------------------ 701 702 -----------------------------------------------------------------------*/ 703 uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& _Form ) throw (RuntimeException) 704 { 705 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 706 707 SwView* pView2 = GetView(); 708 FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL; 709 SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL; 710 Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL; 711 DBG_ASSERT( pFormShell && pDrawView && pWindow, "SwXTextView::getFormController: how could I?" ); 712 713 uno::Reference< form::runtime::XFormController > xController; 714 if ( pFormShell && pDrawView && pWindow ) 715 xController = pFormShell->GetFormController( _Form, *pDrawView, *pWindow ); 716 return xController; 717 } 718 719 /*-- 08.03.07 13:55------------------------------------------------------ 720 721 -----------------------------------------------------------------------*/ 722 ::sal_Bool SAL_CALL SwXTextView::isFormDesignMode( ) throw (uno::RuntimeException) 723 { 724 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 725 SwView* pView2 = GetView(); 726 FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL; 727 return pFormShell ? pFormShell->IsDesignMode() : sal_True; 728 } 729 730 /*-- 08.03.07 13:55------------------------------------------------------ 731 732 -----------------------------------------------------------------------*/ 733 void SAL_CALL SwXTextView::setFormDesignMode( ::sal_Bool _DesignMode ) throw (RuntimeException) 734 { 735 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 736 SwView* pView2 = GetView(); 737 FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL; 738 if ( pFormShell ) 739 pFormShell->SetDesignMode( _DesignMode ); 740 } 741 742 /*-- 17.12.98 09:34:28--------------------------------------------------- 743 744 -----------------------------------------------------------------------*/ 745 uno::Reference< text::XTextViewCursor > SwXTextView::getViewCursor(void) throw( uno::RuntimeException ) 746 { 747 ::vos::OGuard aGuard(Application::GetSolarMutex()); 748 if(GetView()) 749 { 750 if(!pxTextViewCursor) 751 { 752 ((SwXTextView*)this)->pxTextViewCursor = new uno::Reference< text::XTextViewCursor > ; 753 *pxTextViewCursor = new SwXTextViewCursor(GetView()); 754 } 755 return *pxTextViewCursor; 756 } 757 else 758 throw uno::RuntimeException(); 759 } 760 /*-- 17.12.98 09:34:28--------------------------------------------------- 761 762 -----------------------------------------------------------------------*/ 763 uno::Reference< beans::XPropertySet > SwXTextView::getViewSettings(void) throw( uno::RuntimeException ) 764 { 765 ::vos::OGuard aGuard(Application::GetSolarMutex()); 766 if(m_pView) 767 { 768 if(!pxViewSettings) 769 { 770 ((SwXTextView*)this)->pxViewSettings = new uno::Reference< beans::XPropertySet > ; 771 *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, m_pView ) ); 772 } 773 } 774 else 775 throw uno::RuntimeException(); 776 return *pxViewSettings; 777 } 778 /* -----------------------------30.01.01 15:01-------------------------------- 779 780 ---------------------------------------------------------------------------*/ 781 Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAutomatic*/ ) throw(RuntimeException) 782 { 783 ::vos::OGuard aGuard(Application::GetSolarMutex()); 784 785 if(!GetView()) 786 throw RuntimeException(); 787 SwWrtShell& rSh = m_pView->GetWrtShell(); 788 ShellModes eSelMode = m_pView->GetShellMode(); 789 if (eSelMode != SHELL_MODE_LIST_TEXT && 790 eSelMode != SHELL_MODE_TABLE_LIST_TEXT && 791 eSelMode != SHELL_MODE_TABLE_TEXT && 792 eSelMode != SHELL_MODE_TEXT ) 793 return Sequence< Sequence< PropertyValue > > (); 794 795 SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); 796 SwRubyList aList; 797 798 sal_uInt16 nCount = pDoc->FillRubyList( *rSh.GetCrsr(), aList, 0 ); 799 Sequence< Sequence< PropertyValue > > aRet(nCount); 800 Sequence< PropertyValue >* pRet = aRet.getArray(); 801 String aString; 802 for(sal_uInt16 n = 0; n < nCount; n++) 803 { 804 const SwRubyListEntryPtr pEntry = aList[n]; 805 806 const String& rEntryText = pEntry->GetText(); 807 const SwFmtRuby& rAttr = pEntry->GetRubyAttr(); 808 809 pRet[n].realloc(5); 810 PropertyValue* pValues = pRet[n].getArray(); 811 pValues[0].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_BASE_TEXT)); 812 pValues[0].Value <<= OUString(rEntryText); 813 pValues[1].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_TEXT)); 814 pValues[1].Value <<= OUString(rAttr.GetText()); 815 pValues[2].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_CHAR_STYLE_NAME)); 816 SwStyleNameMapper::FillProgName(rAttr.GetCharFmtName(), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 817 pValues[2].Value <<= OUString( aString ); 818 pValues[3].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_ADJUST)); 819 pValues[3].Value <<= (sal_Int16)rAttr.GetAdjustment(); 820 pValues[4].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_IS_ABOVE)); 821 sal_Bool bVal = !rAttr.GetPosition(); 822 pValues[4].Value.setValue(&bVal, ::getBooleanCppuType()); 823 } 824 return aRet; 825 } 826 /* -----------------------------30.01.01 15:02-------------------------------- 827 828 ---------------------------------------------------------------------------*/ 829 void SAL_CALL SwXTextView::setRubyList( 830 const Sequence< Sequence< PropertyValue > >& rRubyList, sal_Bool /*bAutomatic*/ ) 831 throw(RuntimeException) 832 { 833 ::vos::OGuard aGuard(Application::GetSolarMutex()); 834 835 if(!GetView() || !rRubyList.getLength()) 836 throw RuntimeException(); 837 SwWrtShell& rSh = m_pView->GetWrtShell(); 838 ShellModes eSelMode = m_pView->GetShellMode(); 839 if (eSelMode != SHELL_MODE_LIST_TEXT && 840 eSelMode != SHELL_MODE_TABLE_LIST_TEXT && 841 eSelMode != SHELL_MODE_TABLE_TEXT && 842 eSelMode != SHELL_MODE_TEXT ) 843 throw RuntimeException(); 844 845 SwRubyList aList; 846 847 const Sequence<PropertyValue>* pRubyList = rRubyList.getConstArray(); 848 for(sal_Int32 nPos = 0; nPos < rRubyList.getLength(); nPos++) 849 { 850 SwRubyListEntryPtr pEntry = new SwRubyListEntry; 851 const PropertyValue* pProperties = pRubyList[nPos].getConstArray(); 852 OUString sTmp; 853 for(sal_Int32 nProp = 0; nProp < pRubyList[nPos].getLength(); nProp++) 854 { 855 if(pProperties[nProp].Name.equalsAsciiL( 856 SW_PROP_NAME(UNO_NAME_RUBY_BASE_TEXT))) 857 { 858 pProperties[nProp].Value >>= sTmp; 859 pEntry->SetText(sTmp); 860 } 861 else if(pProperties[nProp].Name.equalsAsciiL( 862 SW_PROP_NAME(UNO_NAME_RUBY_TEXT))) 863 { 864 pProperties[nProp].Value >>= sTmp; 865 pEntry->GetRubyAttr().SetText(sTmp); 866 } 867 else if(pProperties[nProp].Name.equalsAsciiL( 868 SW_PROP_NAME(UNO_NAME_RUBY_CHAR_STYLE_NAME))) 869 { 870 if((pProperties[nProp].Value >>= sTmp)) 871 { 872 String sName; 873 SwStyleNameMapper::FillUIName(sTmp, sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); 874 sal_uInt16 nPoolId = sName.Len() ? 875 SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) : 0; 876 877 pEntry->GetRubyAttr().SetCharFmtName( sName ); 878 pEntry->GetRubyAttr().SetCharFmtId( nPoolId ); 879 } 880 } 881 else if(pProperties[nProp].Name.equalsAsciiL( 882 SW_PROP_NAME(UNO_NAME_RUBY_ADJUST))) 883 { 884 sal_Int16 nTmp = 0; 885 if((pProperties[nProp].Value >>= nTmp)) 886 pEntry->GetRubyAttr().SetAdjustment(nTmp); 887 } 888 else if(pProperties[nProp].Name.equalsAsciiL( 889 SW_PROP_NAME(UNO_NAME_RUBY_IS_ABOVE))) 890 { 891 sal_Bool bValue = pProperties[nProp].Value.hasValue() ? 892 *(sal_Bool*)pProperties[nProp].Value.getValue() : sal_True; 893 pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1); 894 } 895 } 896 aList.Insert(pEntry, (sal_uInt16)nPos); 897 } 898 SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); 899 pDoc->SetRubyList( *rSh.GetCrsr(), aList, 0 ); 900 } 901 /*-- 29.12.02 15:45:29--------------------------------------------------- 902 903 -----------------------------------------------------------------------*/ 904 SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc() 905 { 906 SwWrtShell& rOldSh = m_pView->GetWrtShell(); 907 SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false ); 908 SwDocShell* pDocSh; 909 SfxObjectShellLock xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) ); 910 xDocSh->DoInitNew( 0 ); 911 SwDoc *const pTempDoc( pDocSh->GetDoc() ); 912 // #i103634#, #i112425#: do not expand numbering and fields on PDF export 913 pTempDoc->SetClipBoard(true); 914 rOldSh.FillPrtDoc(pTempDoc, pPrt); 915 SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 ); 916 SwView* pDocView = (SwView*) pDocFrame->GetViewShell(); 917 pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//Damit SelectShell gerufen wird. 918 SwWrtShell* pSh = pDocView->GetWrtShellPtr(); 919 920 IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess(); 921 SfxPrinter* pTempPrinter = pIDDA->getPrinter( true ); 922 923 const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc()); 924 925 IDocumentDeviceAccess* pIDDA_old = rOldSh.getIDocumentDeviceAccess(); 926 927 if( pIDDA_old->getPrinter( false ) ) 928 { 929 pIDDA->setJobsetup( *pIDDA_old->getJobsetup() ); 930 //#69563# if it isn't the same printer then the pointer has been invalidated! 931 pTempPrinter = pIDDA->getPrinter( true ); 932 } 933 934 pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); 935 936 return xDocSh; 937 } 938 939 /*-- 17.12.98 09:34:29--------------------------------------------------- 940 941 -----------------------------------------------------------------------*/ 942 void SwXTextView::NotifySelChanged() 943 { 944 DBG_ASSERT( m_pView, "view is missing" ); 945 946 // destroy temporary document with selected text that is used 947 // in PDF export of (multi-)selections. 948 if (m_pView && m_pView->GetTmpSelectionDoc().Is()) 949 { 950 m_pView->GetTmpSelectionDoc()->DoClose(); 951 m_pView->GetTmpSelectionDoc() = 0; 952 } 953 954 uno::Reference< uno::XInterface > xInt = (cppu::OWeakObject*)(SfxBaseController*)this; 955 956 lang::EventObject aEvent(xInt); 957 958 sal_uInt16 nCount = aSelChangedListeners.Count(); 959 for ( sal_uInt16 i = nCount; i--; ) 960 { 961 uno::Reference< view::XSelectionChangeListener > *pObj = aSelChangedListeners[i]; 962 (*pObj)->selectionChanged(aEvent); 963 } 964 } 965 /* -----------------------------12.07.01 13:26-------------------------------- 966 967 ---------------------------------------------------------------------------*/ 968 void SwXTextView::NotifyDBChanged() 969 { 970 URL aURL; 971 aURL.Complete = C2U(SwXDispatch::GetDBChangeURL()); 972 973 sal_uInt16 nCount = aSelChangedListeners.Count(); 974 for ( sal_uInt16 i = nCount; i--; ) 975 { 976 uno::Reference< view::XSelectionChangeListener > *pObj = aSelChangedListeners[i]; 977 uno::Reference<XDispatch> xDispatch((*pObj), UNO_QUERY); 978 if(xDispatch.is()) 979 xDispatch->dispatch(aURL, Sequence<PropertyValue>(0)); 980 } 981 } 982 983 /* -----------------------------10.12.04 11:07-------------------------------- 984 985 ---------------------------------------------------------------------------*/ 986 987 uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo( ) 988 throw (uno::RuntimeException) 989 { 990 vos::OGuard aGuard( Application::GetSolarMutex() ); 991 static uno::Reference< XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo(); 992 return aRef; 993 } 994 995 996 void SAL_CALL SwXTextView::setPropertyValue( 997 const OUString& rPropertyName, const uno::Any& rValue ) 998 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 999 { 1000 vos::OGuard aGuard( Application::GetSolarMutex() ); 1001 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); 1002 if (!pEntry) 1003 throw UnknownPropertyException(); 1004 else if (pEntry->nFlags & PropertyAttribute::READONLY) 1005 throw PropertyVetoException(); 1006 else 1007 { 1008 switch (pEntry->nWID) 1009 { 1010 case WID_IS_HIDE_SPELL_MARKS : 1011 // deprecated #i91949 1012 break; 1013 case WID_IS_CONSTANT_SPELLCHECK : 1014 { 1015 sal_Bool bVal = sal_False; 1016 const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions(); 1017 if (!pOpt || !(rValue >>= bVal)) 1018 throw RuntimeException(); 1019 SwViewOption aNewOpt( *pOpt ); 1020 if (pEntry->nWID == WID_IS_CONSTANT_SPELLCHECK) 1021 aNewOpt.SetOnlineSpell(bVal); 1022 m_pView->GetWrtShell().ApplyViewOptions( aNewOpt ); 1023 } 1024 break; 1025 default : 1026 DBG_ERROR("unknown WID"); 1027 } 1028 } 1029 } 1030 1031 1032 uno::Any SAL_CALL SwXTextView::getPropertyValue( 1033 const OUString& rPropertyName ) 1034 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1035 { 1036 vos::OGuard aGuard( Application::GetSolarMutex() ); 1037 1038 Any aRet; 1039 1040 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); 1041 if (!pEntry) 1042 throw UnknownPropertyException(); 1043 else 1044 { 1045 sal_Int16 nWID = pEntry->nWID; 1046 switch (nWID) 1047 { 1048 case WID_PAGE_COUNT : 1049 case WID_LINE_COUNT : 1050 { 1051 // format document completely in order to get meaningful 1052 // values for page count and line count 1053 m_pView->GetWrtShell().CalcLayout(); 1054 1055 sal_Int32 nCount = -1; 1056 if (nWID == WID_PAGE_COUNT) 1057 nCount = m_pView->GetWrtShell().GetPageCount(); 1058 else // WID_LINE_COUNT 1059 nCount = m_pView->GetWrtShell().GetLineCount( sal_False /*of whole document*/ ); 1060 aRet <<= nCount; 1061 } 1062 break; 1063 case WID_IS_HIDE_SPELL_MARKS : 1064 // deprecated #i91949 1065 break; 1066 case WID_IS_CONSTANT_SPELLCHECK : 1067 { 1068 const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions(); 1069 if (!pOpt) 1070 throw RuntimeException(); 1071 sal_uInt32 nFlag = VIEWOPT_1_ONLINESPELL; 1072 sal_Bool bVal = 0 != (pOpt->GetCoreOptions() & nFlag); 1073 aRet <<= bVal; 1074 } 1075 break; 1076 default : 1077 DBG_ERROR("unknown WID"); 1078 } 1079 } 1080 1081 return aRet; 1082 } 1083 1084 1085 void SAL_CALL SwXTextView::addPropertyChangeListener( 1086 const OUString& /*rPropertyName*/, 1087 const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ ) 1088 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1089 { 1090 DBG_WARNING("not implemented"); 1091 } 1092 1093 1094 void SAL_CALL SwXTextView::removePropertyChangeListener( 1095 const OUString& /*rPropertyName*/, 1096 const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ ) 1097 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1098 { 1099 DBG_WARNING("not implemented"); 1100 } 1101 1102 1103 void SAL_CALL SwXTextView::addVetoableChangeListener( 1104 const OUString& /*rPropertyName*/, 1105 const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ ) 1106 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1107 { 1108 DBG_WARNING("not implemented"); 1109 } 1110 1111 1112 void SAL_CALL SwXTextView::removeVetoableChangeListener( 1113 const OUString& /*rPropertyName*/, 1114 const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ ) 1115 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1116 { 1117 DBG_WARNING("not implemented"); 1118 } 1119 1120 /* -----------------------------06.04.00 11:07-------------------------------- 1121 1122 ---------------------------------------------------------------------------*/ 1123 OUString SwXTextView::getImplementationName(void) throw( RuntimeException ) 1124 { 1125 return C2U("SwXTextView"); 1126 } 1127 /* -----------------------------06.04.00 11:07-------------------------------- 1128 1129 ---------------------------------------------------------------------------*/ 1130 sal_Bool SwXTextView::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1131 { 1132 return rServiceName.equalsAscii("com.sun.star.text.TextDocumentView") || 1133 rServiceName.equalsAscii("com.sun.star.view.OfficeDocumentView"); 1134 } 1135 /* -----------------------------06.04.00 11:07-------------------------------- 1136 1137 ---------------------------------------------------------------------------*/ 1138 Sequence< OUString > SwXTextView::getSupportedServiceNames(void) throw( RuntimeException ) 1139 { 1140 Sequence< OUString > aRet(2); 1141 OUString* pArray = aRet.getArray(); 1142 pArray[0] = C2U("com.sun.star.text.TextDocumentView"); 1143 pArray[1] = C2U("com.sun.star.view.OfficeDocumentView"); 1144 return aRet; 1145 } 1146 1147 /****************************************************************** 1148 * SwXTextViewCursor 1149 ******************************************************************/ 1150 /*-- 17.12.98 09:36:23--------------------------------------------------- 1151 1152 -----------------------------------------------------------------------*/ 1153 SwXTextViewCursor::SwXTextViewCursor(SwView* pVw) : 1154 m_pView(pVw), 1155 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)) 1156 { 1157 } 1158 /*-- 17.12.98 09:36:24--------------------------------------------------- 1159 1160 -----------------------------------------------------------------------*/ 1161 SwXTextViewCursor::~SwXTextViewCursor() 1162 { 1163 } 1164 /*-- 06.10.04 09:36:25--------------------------------------------------- 1165 1166 -----------------------------------------------------------------------*/ 1167 1168 // used to determine if there is a text selction or not. 1169 // If there is no text selection the functions that need a working 1170 // cursor will be disabled (throw RuntimeException). This will be the case 1171 // for the following interfaces: 1172 // - XViewCursor 1173 // - XTextCursor 1174 // - XTextRange 1175 // - XLineCursor 1176 1177 sal_Bool SwXTextViewCursor::IsTextSelection( sal_Bool bAllowTables ) const 1178 { 1179 1180 sal_Bool bRes = sal_False; 1181 DBG_ASSERT(m_pView, "m_pView is NULL ???"); 1182 if(m_pView) 1183 { 1184 //! m_pView->GetShellMode() will only work after the shell 1185 //! has already changed and thus can not be used here! 1186 SelectionType eSelType = m_pView->GetWrtShell().GetSelectionType(); 1187 bRes = ( (nsSelectionType::SEL_TXT & eSelType) || 1188 (nsSelectionType::SEL_NUM & eSelType) ) && 1189 (!(nsSelectionType::SEL_TBL_CELLS & eSelType) || bAllowTables); 1190 } 1191 return bRes; 1192 } 1193 1194 /*-- 17.12.98 09:36:25--------------------------------------------------- 1195 1196 -----------------------------------------------------------------------*/ 1197 sal_Bool SwXTextViewCursor::isVisible(void) throw( uno::RuntimeException ) 1198 { 1199 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1200 DBG_WARNING("not implemented"); 1201 return sal_True; 1202 } 1203 /*-- 17.12.98 09:36:25--------------------------------------------------- 1204 1205 -----------------------------------------------------------------------*/ 1206 void SwXTextViewCursor::setVisible(sal_Bool /*bVisible*/) throw( uno::RuntimeException ) 1207 { 1208 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1209 DBG_WARNING("not implemented"); 1210 } 1211 /*-- 17.12.98 09:36:26--------------------------------------------------- 1212 1213 -----------------------------------------------------------------------*/ 1214 awt::Point SwXTextViewCursor::getPosition(void) throw( uno::RuntimeException ) 1215 { 1216 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1217 awt::Point aRet; 1218 if(m_pView) 1219 { 1220 const SwWrtShell& rSh = m_pView->GetWrtShell(); 1221 const SwRect aCharRect(rSh.GetCharRect()); 1222 1223 const SwFrmFmt& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster(); 1224 1225 const SvxULSpaceItem& rUL = rMaster.GetULSpace(); 1226 const long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER); 1227 aRet.Y = TWIP_TO_MM100(nY); 1228 1229 const SvxLRSpaceItem& rLR = rMaster.GetLRSpace(); 1230 const long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER); 1231 aRet.X = TWIP_TO_MM100(nX); 1232 } 1233 else 1234 throw uno::RuntimeException(); 1235 return aRet; 1236 } 1237 /*-- 17.12.98 09:36:26--------------------------------------------------- 1238 1239 -----------------------------------------------------------------------*/ 1240 void SwXTextViewCursor::collapseToStart(void) throw( uno::RuntimeException ) 1241 { 1242 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1243 if(m_pView) 1244 { 1245 if (!IsTextSelection()) 1246 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1247 1248 SwWrtShell& rSh = m_pView->GetWrtShell(); 1249 if(rSh.HasSelection()) 1250 { 1251 SwPaM* pShellCrsr = rSh.GetCrsr(); 1252 if(*pShellCrsr->GetPoint() > *pShellCrsr->GetMark()) 1253 pShellCrsr->Exchange(); 1254 pShellCrsr->DeleteMark(); 1255 rSh.EnterStdMode(); 1256 rSh.SetSelection(*pShellCrsr); 1257 } 1258 } 1259 else 1260 throw uno::RuntimeException(); 1261 } 1262 /*-- 17.12.98 09:36:26--------------------------------------------------- 1263 1264 -----------------------------------------------------------------------*/ 1265 void SwXTextViewCursor::collapseToEnd(void) throw( uno::RuntimeException ) 1266 { 1267 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1268 if(m_pView) 1269 { 1270 if (!IsTextSelection()) 1271 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1272 1273 SwWrtShell& rSh = m_pView->GetWrtShell(); 1274 if(rSh.HasSelection()) 1275 { 1276 SwPaM* pShellCrsr = rSh.GetCrsr(); 1277 if(*pShellCrsr->GetPoint() < *pShellCrsr->GetMark()) 1278 pShellCrsr->Exchange(); 1279 pShellCrsr->DeleteMark(); 1280 rSh.EnterStdMode(); 1281 rSh.SetSelection(*pShellCrsr); 1282 } 1283 } 1284 else 1285 throw uno::RuntimeException(); 1286 } 1287 /*-- 17.12.98 09:36:27--------------------------------------------------- 1288 1289 -----------------------------------------------------------------------*/ 1290 sal_Bool SwXTextViewCursor::isCollapsed(void) throw( uno::RuntimeException ) 1291 { 1292 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1293 sal_Bool bRet = sal_False; 1294 if(m_pView) 1295 { 1296 if (!IsTextSelection()) 1297 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1298 1299 const SwWrtShell& rSh = m_pView->GetWrtShell(); 1300 bRet = !rSh.HasSelection(); 1301 } 1302 else 1303 throw uno::RuntimeException(); 1304 return bRet; 1305 1306 } 1307 /*-- 17.12.98 09:36:27--------------------------------------------------- 1308 1309 -----------------------------------------------------------------------*/ 1310 sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException ) 1311 { 1312 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1313 sal_Bool bRet = sal_False; 1314 if(m_pView) 1315 { 1316 if (!IsTextSelection()) 1317 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1318 1319 for( sal_uInt16 i = 0; i < nCount; i++ ) 1320 bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, 1, sal_True ); 1321 } 1322 else 1323 throw uno::RuntimeException(); 1324 return bRet; 1325 } 1326 /*-- 17.12.98 09:36:27--------------------------------------------------- 1327 1328 -----------------------------------------------------------------------*/ 1329 sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException ) 1330 { 1331 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1332 sal_Bool bRet = sal_False; 1333 if(m_pView) 1334 { 1335 if (!IsTextSelection()) 1336 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1337 1338 for( sal_uInt16 i = 0; i < nCount; i++ ) 1339 bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, 1, sal_True ); 1340 } 1341 else 1342 throw uno::RuntimeException(); 1343 return bRet; 1344 1345 } 1346 /* -----------------08.03.99 11:18------------------- 1347 * 1348 * --------------------------------------------------*/ 1349 void SwXTextViewCursor::gotoRange( 1350 const uno::Reference< text::XTextRange > & xRange, 1351 sal_Bool bExpand) 1352 throw(RuntimeException) 1353 { 1354 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1355 if(m_pView && xRange.is()) 1356 { 1357 if (!IsTextSelection()) 1358 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1359 1360 SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); 1361 if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) 1362 { 1363 throw uno::RuntimeException(); 1364 } 1365 1366 ShellModes eSelMode = m_pView->GetShellMode(); 1367 SwWrtShell& rSh = m_pView->GetWrtShell(); 1368 // call EnterStdMode in non-text selections only 1369 if(!bExpand || 1370 (eSelMode != SHELL_MODE_TABLE_TEXT && 1371 eSelMode != SHELL_MODE_LIST_TEXT && 1372 eSelMode != SHELL_MODE_TABLE_LIST_TEXT && 1373 eSelMode != SHELL_MODE_TEXT )) 1374 rSh.EnterStdMode(); 1375 SwPaM* pShellCrsr = rSh.GetCrsr(); 1376 SwPaM aOwnPaM(*pShellCrsr->GetPoint()); 1377 if(pShellCrsr->HasMark()) 1378 { 1379 aOwnPaM.SetMark(); 1380 *aOwnPaM.GetMark() = *pShellCrsr->GetMark(); 1381 } 1382 1383 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); 1384 SwXTextRange* pRange = 0; 1385 SwXParagraph* pPara = 0; 1386 OTextCursorHelper* pCursor = 0; 1387 if(xRangeTunnel.is()) 1388 { 1389 pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething( 1390 SwXTextRange::getUnoTunnelId())); 1391 pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething( 1392 OTextCursorHelper::getUnoTunnelId())); 1393 pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething( 1394 SwXParagraph::getUnoTunnelId())); 1395 } 1396 1397 const sal_uInt16 nFrmType = rSh.GetFrmType(0,sal_True); 1398 1399 SwStartNodeType eSearchNodeType = SwNormalStartNode; 1400 if(nFrmType & FRMTYPE_FLY_ANY) 1401 eSearchNodeType = SwFlyStartNode; 1402 else if(nFrmType &FRMTYPE_HEADER) 1403 eSearchNodeType = SwHeaderStartNode; 1404 else if(nFrmType & FRMTYPE_FOOTER) 1405 eSearchNodeType = SwFooterStartNode; 1406 else if(nFrmType & FRMTYPE_TABLE) 1407 eSearchNodeType = SwTableBoxStartNode; 1408 else if(nFrmType & FRMTYPE_FOOTNOTE) 1409 eSearchNodeType = SwFootnoteStartNode; 1410 1411 const SwStartNode* pOwnStartNode = aOwnPaM.GetNode()-> 1412 FindSttNodeByType(eSearchNodeType); 1413 1414 const SwNode* pSrcNode = 0; 1415 if(pCursor && pCursor->GetPaM()) 1416 { 1417 pSrcNode = pCursor->GetPaM()->GetNode(); 1418 } 1419 else if (pRange) 1420 { 1421 SwPaM aPam(pRange->GetDoc()->GetNodes()); 1422 if (pRange->GetPositions(aPam)) 1423 { 1424 pSrcNode = aPam.GetNode(); 1425 } 1426 } 1427 else if (pPara && pPara->GetTxtNode()) 1428 { 1429 pSrcNode = pPara->GetTxtNode(); 1430 } 1431 const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0; 1432 1433 //SectionNodes ueberspringen 1434 while(pTmp && pTmp->IsSectionNode()) 1435 { 1436 pTmp = pTmp->StartOfSectionNode(); 1437 } 1438 while(pOwnStartNode && pOwnStartNode->IsSectionNode()) 1439 { 1440 pOwnStartNode = pOwnStartNode->StartOfSectionNode(); 1441 } 1442 //ohne Expand darf mit dem ViewCursor ueberall hingesprungen werden 1443 //mit Expand nur in der gleichen Umgebung 1444 if(bExpand && 1445 (pOwnStartNode != pTmp || 1446 (eSelMode != SHELL_MODE_TABLE_TEXT && 1447 eSelMode != SHELL_MODE_LIST_TEXT && 1448 eSelMode != SHELL_MODE_TABLE_LIST_TEXT && 1449 eSelMode != SHELL_MODE_TEXT))) 1450 throw uno::RuntimeException(); 1451 1452 //jetzt muss die Selektion erweitert werden 1453 if(bExpand) 1454 { 1455 // der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen 1456 // Range eingeschlossen wurde 1457 SwPosition aOwnLeft(*aOwnPaM.Start()); 1458 SwPosition aOwnRight(*aOwnPaM.End()); 1459 SwPosition* pParamLeft = rDestPam.Start(); 1460 SwPosition* pParamRight = rDestPam.End(); 1461 // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche? 1462 if(aOwnRight > *pParamRight) 1463 *aOwnPaM.GetPoint() = aOwnRight; 1464 else 1465 *aOwnPaM.GetPoint() = *pParamRight; 1466 aOwnPaM.SetMark(); 1467 if(aOwnLeft < *pParamLeft) 1468 *aOwnPaM.GetMark() = aOwnLeft; 1469 else 1470 *aOwnPaM.GetMark() = *pParamLeft; 1471 } 1472 else 1473 { 1474 //der Cursor soll dem uebergebenen Range entsprechen 1475 *aOwnPaM.GetPoint() = *rDestPam.GetPoint(); 1476 if(rDestPam.HasMark()) 1477 { 1478 aOwnPaM.SetMark(); 1479 *aOwnPaM.GetMark() = *rDestPam.GetMark(); 1480 } 1481 else 1482 aOwnPaM.DeleteMark(); 1483 } 1484 rSh.SetSelection(aOwnPaM); 1485 } 1486 else 1487 throw uno::RuntimeException(); 1488 1489 } 1490 /*-- 17.12.98 09:36:28--------------------------------------------------- 1491 1492 -----------------------------------------------------------------------*/ 1493 void SwXTextViewCursor::gotoStart(sal_Bool bExpand) throw( uno::RuntimeException ) 1494 { 1495 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1496 if(m_pView) 1497 { 1498 if (!IsTextSelection()) 1499 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1500 1501 m_pView->GetWrtShell().SttDoc( bExpand ); 1502 } 1503 else 1504 throw uno::RuntimeException(); 1505 } 1506 /*-- 17.12.98 09:36:28--------------------------------------------------- 1507 1508 -----------------------------------------------------------------------*/ 1509 void SwXTextViewCursor::gotoEnd(sal_Bool bExpand) throw( uno::RuntimeException ) 1510 { 1511 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1512 if(m_pView) 1513 { 1514 if (!IsTextSelection()) 1515 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1516 1517 m_pView->GetWrtShell().EndDoc( bExpand ); 1518 } 1519 else 1520 throw uno::RuntimeException(); 1521 } 1522 /*-- 17.12.98 09:36:28--------------------------------------------------- 1523 1524 -----------------------------------------------------------------------*/ 1525 sal_Bool SwXTextViewCursor::jumpToFirstPage(void) throw( uno::RuntimeException ) 1526 { 1527 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1528 sal_Bool bRet = sal_False; 1529 if(m_pView) 1530 { 1531 SwWrtShell& rSh = m_pView->GetWrtShell(); 1532 if (rSh.IsSelFrmMode()) 1533 { 1534 rSh.UnSelectFrm(); 1535 rSh.LeaveSelFrmMode(); 1536 } 1537 rSh.EnterStdMode(); 1538 bRet = rSh.SttEndDoc(sal_True); 1539 } 1540 else 1541 throw uno::RuntimeException(); 1542 return bRet; 1543 } 1544 /*-- 17.12.98 09:36:29--------------------------------------------------- 1545 1546 -----------------------------------------------------------------------*/ 1547 sal_Bool SwXTextViewCursor::jumpToLastPage(void) throw( uno::RuntimeException ) 1548 { 1549 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1550 sal_Bool bRet = sal_False; 1551 if(m_pView) 1552 { 1553 SwWrtShell& rSh = m_pView->GetWrtShell(); 1554 if (rSh.IsSelFrmMode()) 1555 { 1556 rSh.UnSelectFrm(); 1557 rSh.LeaveSelFrmMode(); 1558 } 1559 rSh.EnterStdMode(); 1560 bRet = rSh.SttEndDoc(sal_False); 1561 rSh.SttPg(); 1562 } 1563 else 1564 throw uno::RuntimeException(); 1565 return bRet; 1566 } 1567 /*-- 17.12.98 09:36:30--------------------------------------------------- 1568 1569 -----------------------------------------------------------------------*/ 1570 sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage) throw( uno::RuntimeException ) 1571 { 1572 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1573 sal_Bool bRet = sal_False; 1574 if(m_pView) 1575 bRet = m_pView->GetWrtShell().GotoPage(nPage, sal_True); 1576 else 1577 throw uno::RuntimeException(); 1578 return bRet; 1579 } 1580 /*-- 17.12.98 09:36:30--------------------------------------------------- 1581 1582 -----------------------------------------------------------------------*/ 1583 sal_Bool SwXTextViewCursor::jumpToNextPage(void) throw( uno::RuntimeException ) 1584 { 1585 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1586 sal_Bool bRet = sal_False; 1587 if(m_pView) 1588 bRet = m_pView->GetWrtShell().SttNxtPg(); 1589 else 1590 throw uno::RuntimeException(); 1591 return bRet; 1592 } 1593 /*-- 17.12.98 09:36:31--------------------------------------------------- 1594 1595 -----------------------------------------------------------------------*/ 1596 sal_Bool SwXTextViewCursor::jumpToPreviousPage(void) throw( uno::RuntimeException ) 1597 { 1598 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1599 sal_Bool bRet = sal_False; 1600 if(m_pView) 1601 bRet = m_pView->GetWrtShell().EndPrvPg(); 1602 else 1603 throw uno::RuntimeException(); 1604 return bRet; 1605 } 1606 /*-- 17.12.98 09:36:32--------------------------------------------------- 1607 1608 -----------------------------------------------------------------------*/ 1609 sal_Bool SwXTextViewCursor::jumpToEndOfPage(void) throw( uno::RuntimeException ) 1610 { 1611 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1612 sal_Bool bRet = sal_False; 1613 if(m_pView) 1614 bRet = m_pView->GetWrtShell().EndPg(); 1615 else 1616 throw uno::RuntimeException(); 1617 return bRet; 1618 } 1619 /*-- 17.12.98 09:36:32--------------------------------------------------- 1620 1621 -----------------------------------------------------------------------*/ 1622 sal_Bool SwXTextViewCursor::jumpToStartOfPage(void) throw( uno::RuntimeException ) 1623 { 1624 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1625 sal_Bool bRet = sal_False; 1626 if(m_pView) 1627 bRet = m_pView->GetWrtShell().SttPg(); 1628 else 1629 throw uno::RuntimeException(); 1630 return bRet; 1631 } 1632 /* -----------------04.10.99 14:21------------------- 1633 1634 --------------------------------------------------*/ 1635 sal_Int16 SwXTextViewCursor::getPage(void) throw( uno::RuntimeException ) 1636 { 1637 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1638 short nRet = 0; 1639 if(m_pView) 1640 { 1641 SwWrtShell& rSh = m_pView->GetWrtShell(); 1642 SwPaM* pShellCrsr = rSh.GetCrsr(); 1643 nRet = (short)pShellCrsr->GetPageNum( sal_True, 0 ); 1644 } 1645 else 1646 throw uno::RuntimeException(); 1647 return nRet; 1648 } 1649 /*-- 17.12.98 09:36:33--------------------------------------------------- 1650 1651 -----------------------------------------------------------------------*/ 1652 sal_Bool SwXTextViewCursor::screenDown(void) throw( uno::RuntimeException ) 1653 { 1654 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1655 sal_Bool bRet = sal_False; 1656 if(m_pView) 1657 { 1658 SfxRequest aReq(FN_PAGEDOWN, SFX_CALLMODE_SLOT, m_pView->GetPool()); 1659 m_pView->Execute(aReq); 1660 const SfxPoolItem* pRet = aReq.GetReturnValue(); 1661 bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue(); 1662 } 1663 else 1664 throw uno::RuntimeException(); 1665 return bRet; 1666 } 1667 /*-- 17.12.98 09:36:33--------------------------------------------------- 1668 1669 -----------------------------------------------------------------------*/ 1670 sal_Bool SwXTextViewCursor::screenUp(void) throw( uno::RuntimeException ) 1671 { 1672 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1673 sal_Bool bRet = sal_False; 1674 if(m_pView) 1675 { 1676 SfxRequest aReq(FN_PAGEUP, SFX_CALLMODE_SLOT, m_pView->GetPool()); 1677 m_pView->Execute(aReq); 1678 const SfxPoolItem* pRet = aReq.GetReturnValue(); 1679 bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue(); 1680 } 1681 else 1682 throw uno::RuntimeException(); 1683 return bRet; 1684 } 1685 /*-- 17.12.98 11:59:05--------------------------------------------------- 1686 1687 -----------------------------------------------------------------------*/ 1688 uno::Reference< text::XText > SwXTextViewCursor::getText(void) throw( uno::RuntimeException ) 1689 { 1690 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1691 uno::Reference< text::XText > xRet; 1692 if(m_pView) 1693 { 1694 if (!IsTextSelection( sal_False )) 1695 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1696 1697 SwWrtShell& rSh = m_pView->GetWrtShell(); 1698 SwPaM* pShellCrsr = rSh.GetCrsr(); 1699 SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); 1700 xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start()); 1701 } 1702 else 1703 throw uno::RuntimeException(); 1704 return xRet; 1705 } 1706 /*-- 17.12.98 11:59:05--------------------------------------------------- 1707 1708 -----------------------------------------------------------------------*/ 1709 uno::Reference< text::XTextRange > SwXTextViewCursor::getStart(void) throw( uno::RuntimeException ) 1710 { 1711 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1712 uno::Reference< text::XTextRange > xRet; 1713 if(m_pView) 1714 { 1715 if (!IsTextSelection()) 1716 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1717 1718 SwWrtShell& rSh = m_pView->GetWrtShell(); 1719 SwPaM* pShellCrsr = rSh.GetCrsr(); 1720 SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); 1721 xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0); 1722 } 1723 else 1724 throw uno::RuntimeException(); 1725 return xRet; 1726 } 1727 /*-- 17.12.98 11:59:06--------------------------------------------------- 1728 1729 -----------------------------------------------------------------------*/ 1730 uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd(void) throw( uno::RuntimeException ) 1731 { 1732 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1733 uno::Reference< text::XTextRange > xRet; 1734 if(m_pView) 1735 { 1736 if (!IsTextSelection()) 1737 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1738 1739 SwWrtShell& rSh = m_pView->GetWrtShell(); 1740 SwPaM* pShellCrsr = rSh.GetCrsr(); 1741 SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); 1742 xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0); 1743 } 1744 else 1745 throw uno::RuntimeException(); 1746 return xRet; 1747 } 1748 /* -----------------12.10.99 09:03------------------- 1749 1750 --------------------------------------------------*/ 1751 OUString SwXTextViewCursor::getString(void) throw( uno::RuntimeException ) 1752 { 1753 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1754 OUString uRet; 1755 if(m_pView) 1756 { 1757 if (!IsTextSelection( sal_False )) 1758 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1759 1760 ShellModes eSelMode = m_pView->GetShellMode(); 1761 switch(eSelMode) 1762 { 1763 //! since setString for SEL_TABLE_TEXT (with possible 1764 //! multi selection of cells) would not work properly we 1765 //! will ignore this case for both 1766 //! functions (setString AND getString) because of symmetrie. 1767 1768 case SHELL_MODE_LIST_TEXT : 1769 case SHELL_MODE_TABLE_LIST_TEXT: 1770 case SHELL_MODE_TEXT : 1771 { 1772 SwWrtShell& rSh = m_pView->GetWrtShell(); 1773 SwPaM* pShellCrsr = rSh.GetCrsr(); 1774 SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet); 1775 } 1776 default:;//prevent warning 1777 } 1778 } 1779 return uRet; 1780 } 1781 /*-- 17.12.98 11:59:06--------------------------------------------------- 1782 1783 -----------------------------------------------------------------------*/ 1784 void SwXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeException ) 1785 { 1786 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1787 if(m_pView) 1788 { 1789 if (!IsTextSelection( sal_False )) 1790 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1791 1792 ShellModes eSelMode = m_pView->GetShellMode(); 1793 switch(eSelMode) 1794 { 1795 //! since setString for SEL_TABLE_TEXT (with possible 1796 //! multi selection of cells) would not work properly we 1797 //! will ignore this case for both 1798 //! functions (setString AND getString) because of symmetrie. 1799 1800 case SHELL_MODE_LIST_TEXT : 1801 case SHELL_MODE_TABLE_LIST_TEXT : 1802 case SHELL_MODE_TEXT : 1803 { 1804 SwWrtShell& rSh = m_pView->GetWrtShell(); 1805 SwCursor* pShellCrsr = rSh.GetSwCrsr(); 1806 SwUnoCursorHelper::SetString(*pShellCrsr, aString); 1807 } 1808 default:;//prevent warning 1809 } 1810 } 1811 } 1812 1813 /*-- 29.06.00 17:33:38--------------------------------------------------- 1814 1815 -----------------------------------------------------------------------*/ 1816 uno::Reference< XPropertySetInfo > SwXTextViewCursor::getPropertySetInfo( ) throw(RuntimeException) 1817 { 1818 static uno::Reference< XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); 1819 return xRef; 1820 } 1821 /*-- 29.06.00 17:33:39--------------------------------------------------- 1822 1823 -----------------------------------------------------------------------*/ 1824 void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const Any& aValue ) 1825 throw(UnknownPropertyException, PropertyVetoException, 1826 IllegalArgumentException, WrappedTargetException, RuntimeException) 1827 { 1828 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1829 if(m_pView) 1830 { 1831 SwWrtShell& rSh = m_pView->GetWrtShell(); 1832 SwPaM* pShellCrsr = rSh.GetCrsr(); 1833 SwNode *pNode = pShellCrsr->GetNode(); 1834 if (pNode && pNode->IsTxtNode()) 1835 { 1836 SwUnoCursorHelper::SetPropertyValue( 1837 *pShellCrsr, *m_pPropSet, rPropertyName, aValue ); 1838 } 1839 else 1840 throw RuntimeException(); 1841 } 1842 else 1843 throw RuntimeException(); 1844 } 1845 /*-- 29.06.00 17:33:39--------------------------------------------------- 1846 1847 -----------------------------------------------------------------------*/ 1848 Any SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName ) 1849 throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1850 { 1851 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1852 Any aRet; 1853 if(m_pView) 1854 { 1855 SwWrtShell& rSh = m_pView->GetWrtShell(); 1856 SwPaM* pShellCrsr = rSh.GetCrsr(); 1857 aRet = SwUnoCursorHelper::GetPropertyValue( 1858 *pShellCrsr, *m_pPropSet, rPropertyName); 1859 } 1860 else 1861 throw RuntimeException(); 1862 return aRet; 1863 } 1864 /*-- 29.06.00 17:33:40--------------------------------------------------- 1865 1866 -----------------------------------------------------------------------*/ 1867 void SwXTextViewCursor::addPropertyChangeListener( 1868 const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ ) 1869 throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1870 { 1871 } 1872 /*-- 29.06.00 17:33:40--------------------------------------------------- 1873 1874 -----------------------------------------------------------------------*/ 1875 void SwXTextViewCursor::removePropertyChangeListener( 1876 const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*aListener*/ ) 1877 throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1878 { 1879 } 1880 /*-- 29.06.00 17:33:41--------------------------------------------------- 1881 1882 -----------------------------------------------------------------------*/ 1883 void SwXTextViewCursor::addVetoableChangeListener( 1884 const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) 1885 throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1886 { 1887 } 1888 /*-- 29.06.00 17:33:41--------------------------------------------------- 1889 1890 -----------------------------------------------------------------------*/ 1891 void SwXTextViewCursor::removeVetoableChangeListener( 1892 const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1893 { 1894 } 1895 /*-- 29.06.00 17:33:41--------------------------------------------------- 1896 1897 -----------------------------------------------------------------------*/ 1898 PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyName ) 1899 throw(UnknownPropertyException, RuntimeException) 1900 { 1901 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1902 PropertyState eState; 1903 if(m_pView) 1904 { 1905 SwWrtShell& rSh = m_pView->GetWrtShell(); 1906 SwPaM* pShellCrsr = rSh.GetCrsr(); 1907 eState = SwUnoCursorHelper::GetPropertyState( 1908 *pShellCrsr, *m_pPropSet, rPropertyName); 1909 } 1910 else 1911 throw RuntimeException(); 1912 return eState; 1913 } 1914 /*-- 29.06.00 17:33:42--------------------------------------------------- 1915 1916 -----------------------------------------------------------------------*/ 1917 Sequence< PropertyState > SwXTextViewCursor::getPropertyStates( 1918 const Sequence< OUString >& rPropertyNames ) throw(UnknownPropertyException, RuntimeException) 1919 { 1920 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1921 Sequence< PropertyState > aRet; 1922 if(m_pView) 1923 { 1924 SwWrtShell& rSh = m_pView->GetWrtShell(); 1925 SwPaM* pShellCrsr = rSh.GetCrsr(); 1926 aRet = SwUnoCursorHelper::GetPropertyStates( 1927 *pShellCrsr, *m_pPropSet, rPropertyNames); 1928 } 1929 return aRet; 1930 } 1931 /*-- 29.06.00 17:33:42--------------------------------------------------- 1932 1933 -----------------------------------------------------------------------*/ 1934 void SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName ) 1935 throw(UnknownPropertyException, RuntimeException) 1936 { 1937 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1938 if(m_pView) 1939 { 1940 SwWrtShell& rSh = m_pView->GetWrtShell(); 1941 SwPaM* pShellCrsr = rSh.GetCrsr(); 1942 SwUnoCursorHelper::SetPropertyToDefault( 1943 *pShellCrsr, *m_pPropSet, rPropertyName); 1944 } 1945 } 1946 /*-- 29.06.00 17:33:43--------------------------------------------------- 1947 1948 -----------------------------------------------------------------------*/ 1949 Any SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName ) 1950 throw(UnknownPropertyException, WrappedTargetException, RuntimeException) 1951 { 1952 Any aRet; 1953 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1954 if(m_pView) 1955 { 1956 SwWrtShell& rSh = m_pView->GetWrtShell(); 1957 SwPaM* pShellCrsr = rSh.GetCrsr(); 1958 aRet = SwUnoCursorHelper::GetPropertyDefault( 1959 *pShellCrsr, *m_pPropSet, rPropertyName); 1960 } 1961 return aRet; 1962 } 1963 /*-- 28.09.99 08:31:19--------------------------------------------------- 1964 1965 -----------------------------------------------------------------------*/ 1966 sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException ) 1967 { 1968 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1969 sal_Bool bRet = sal_False; 1970 if(m_pView) 1971 { 1972 if (!IsTextSelection()) 1973 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1974 1975 for( sal_uInt16 i = 0; i < nCount; i++ ) 1976 bRet = m_pView->GetWrtShell().Down( bExpand, 1, sal_True ); 1977 } 1978 else 1979 throw uno::RuntimeException(); 1980 return bRet; 1981 } 1982 /*-- 28.09.99 08:31:20--------------------------------------------------- 1983 1984 -----------------------------------------------------------------------*/ 1985 sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException ) 1986 { 1987 ::vos::OGuard aGuard(Application::GetSolarMutex()); 1988 sal_Bool bRet = sal_False; 1989 if(m_pView) 1990 { 1991 if (!IsTextSelection()) 1992 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 1993 1994 for( sal_uInt16 i = 0; i < nCount; i++ ) 1995 bRet = m_pView->GetWrtShell().Up( bExpand, 1, sal_True ); 1996 } 1997 else 1998 throw uno::RuntimeException(); 1999 return bRet; 2000 } 2001 /*-- 28.09.99 08:31:20--------------------------------------------------- 2002 2003 -----------------------------------------------------------------------*/ 2004 sal_Bool SwXTextViewCursor::isAtStartOfLine(void) throw( uno::RuntimeException ) 2005 { 2006 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2007 sal_Bool bRet = sal_False; 2008 if(m_pView) 2009 { 2010 if (!IsTextSelection( sal_False )) 2011 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2012 2013 bRet = m_pView->GetWrtShell().IsAtLeftMargin(); 2014 } 2015 else 2016 throw uno::RuntimeException(); 2017 return bRet; 2018 } 2019 /*-- 28.09.99 08:31:21--------------------------------------------------- 2020 2021 -----------------------------------------------------------------------*/ 2022 sal_Bool SwXTextViewCursor::isAtEndOfLine(void) throw( uno::RuntimeException ) 2023 { 2024 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2025 sal_Bool bRet = sal_False; 2026 if(m_pView) 2027 { 2028 if (!IsTextSelection( sal_False )) 2029 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2030 2031 bRet = m_pView->GetWrtShell().IsAtRightMargin(sal_True); 2032 } 2033 else 2034 throw uno::RuntimeException(); 2035 return bRet; 2036 } 2037 /*-- 28.09.99 08:31:21--------------------------------------------------- 2038 2039 -----------------------------------------------------------------------*/ 2040 void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand) throw( uno::RuntimeException ) 2041 { 2042 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2043 if(m_pView) 2044 { 2045 if (!IsTextSelection( sal_False )) 2046 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2047 2048 m_pView->GetWrtShell().RightMargin(bExpand, sal_True); 2049 } 2050 else 2051 throw uno::RuntimeException(); 2052 } 2053 /*-- 28.09.99 08:31:22--------------------------------------------------- 2054 2055 -----------------------------------------------------------------------*/ 2056 void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand) throw( uno::RuntimeException ) 2057 { 2058 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2059 if(m_pView) 2060 { 2061 if (!IsTextSelection( sal_False )) 2062 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); 2063 2064 m_pView->GetWrtShell().LeftMargin(bExpand, sal_True); 2065 } 2066 else 2067 throw uno::RuntimeException(); 2068 } 2069 /* -----------------------------06.04.00 11:07-------------------------------- 2070 2071 ---------------------------------------------------------------------------*/ 2072 OUString SwXTextViewCursor::getImplementationName(void) throw( RuntimeException ) 2073 { 2074 return C2U("SwXTextViewCursor"); 2075 } 2076 /* -----------------------------06.04.00 11:07-------------------------------- 2077 2078 ---------------------------------------------------------------------------*/ 2079 sal_Bool SwXTextViewCursor::supportsService(const OUString& rServiceName) throw( RuntimeException ) 2080 { 2081 return !rServiceName.compareToAscii("com.sun.star.text.TextViewCursor") || 2082 !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties") || 2083 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian") || 2084 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex") || 2085 !rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") || 2086 !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") || 2087 !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex"); 2088 } 2089 /* -----------------------------06.04.00 11:07-------------------------------- 2090 2091 ---------------------------------------------------------------------------*/ 2092 Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames(void) throw( RuntimeException ) 2093 { 2094 Sequence< OUString > aRet(7); 2095 OUString* pArray = aRet.getArray(); 2096 pArray[0] = C2U("com.sun.star.text.TextViewCursor"); 2097 pArray[1] = C2U("com.sun.star.style.CharacterProperties"); 2098 pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian"); 2099 pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex"); 2100 pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); 2101 pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); 2102 pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); 2103 return aRet; 2104 } 2105 /* -----------------------------03.03.03 11:07-------------------------------- 2106 2107 ---------------------------------------------------------------------------*/ 2108 const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId() 2109 { 2110 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 2111 return aSeq; 2112 } 2113 /* -----------------------------03.03.03 11:07-------------------------------- 2114 2115 ---------------------------------------------------------------------------*/ 2116 //XUnoTunnel 2117 sal_Int64 SAL_CALL SwXTextViewCursor::getSomething( 2118 const uno::Sequence< sal_Int8 >& rId ) 2119 throw(uno::RuntimeException) 2120 { 2121 if( rId.getLength() == 16 2122 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 2123 rId.getConstArray(), 16 ) ) 2124 { 2125 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); 2126 } 2127 return OTextCursorHelper::getSomething(rId);; 2128 } 2129 // ----------------------------------------------------------------------------- 2130 2131 IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper) 2132 const SwDoc* SwXTextViewCursor::GetDoc() const 2133 { 2134 SwWrtShell& rSh = m_pView->GetWrtShell(); 2135 return rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0; 2136 } 2137 // ----------------------------------------------------------------------------- 2138 SwDoc* SwXTextViewCursor::GetDoc() 2139 { 2140 SwWrtShell& rSh = m_pView->GetWrtShell(); 2141 return rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0; 2142 } 2143 // ----------------------------------------------------------------------------- 2144 const SwPaM* SwXTextViewCursor::GetPaM() const 2145 { 2146 SwWrtShell& rSh = m_pView->GetWrtShell(); 2147 return rSh.GetCrsr(); 2148 } 2149 // ----------------------------------------------------------------------------- 2150 SwPaM* SwXTextViewCursor::GetPaM() 2151 { 2152 SwWrtShell& rSh = m_pView->GetWrtShell(); 2153 return rSh.GetCrsr(); 2154 } 2155 2156 uno::Reference< datatransfer::XTransferable > SAL_CALL SwXTextView::getTransferable( ) throw (uno::RuntimeException) 2157 { 2158 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2159 2160 //force immediat shell update 2161 GetView()->StopShellTimer(); 2162 SwWrtShell& rSh = GetView()->GetWrtShell(); 2163 if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT ) 2164 { 2165 SdrView *pSdrView = rSh.GetDrawView(); 2166 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 2167 return pOLV->GetEditView().GetTransferable(); 2168 } 2169 else 2170 { 2171 SwTransferable* pTransfer = new SwTransferable( rSh ); 2172 const sal_Bool bLockedView = rSh.IsViewLocked(); 2173 rSh.LockView( sal_True ); //lock visible section 2174 pTransfer->PrepareForCopy(); 2175 rSh.LockView( bLockedView ); 2176 return uno::Reference< datatransfer::XTransferable >( pTransfer ); 2177 } 2178 } 2179 2180 void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfer::XTransferable >& xTrans ) throw (datatransfer::UnsupportedFlavorException, uno::RuntimeException) 2181 { 2182 ::vos::OGuard aGuard(Application::GetSolarMutex()); 2183 2184 //force immediat shell update 2185 GetView()->StopShellTimer(); 2186 SwWrtShell& rSh = GetView()->GetWrtShell(); 2187 if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT ) 2188 { 2189 SdrView *pSdrView = rSh.GetDrawView(); 2190 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 2191 pOLV->GetEditView().InsertText( xTrans, GetView()->GetDocShell()->GetMedium()->GetBaseURL(), sal_False ); 2192 } 2193 else 2194 { 2195 TransferableDataHelper aDataHelper( xTrans ); 2196 if ( SwTransferable::IsPaste( rSh, aDataHelper ) ) 2197 { 2198 SwTransferable::Paste( rSh, aDataHelper ); 2199 if( rSh.IsFrmSelected() || rSh.IsObjSelected() ) 2200 rSh.EnterSelFrmMode(); 2201 GetView()->AttrChangedNotify( &rSh ); 2202 } 2203 } 2204 } 2205 2206 // ----------------------------------------------------------------------------- 2207 2208