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