LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/uno - unotxvw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 457 969 47.2 %
Date: 2013-07-09 Functions: 58 100 58.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "viscrs.hxx"
      22             : #include <sfx2/frame.hxx>
      23             : #include <sfx2/printer.hxx>
      24             : #include <cmdid.h>
      25             : #include <hintids.hxx>
      26             : #include <docsh.hxx>
      27             : #include <rubylist.hxx>
      28             : #include <doc.hxx>
      29             : #include <unotxvw.hxx>
      30             : #include <unodispatch.hxx>
      31             : #include <unomap.hxx>
      32             : #include <unostyle.hxx>
      33             : #include <unoprnms.hxx>
      34             : #include <view.hxx>
      35             : #include <viewopt.hxx>
      36             : #include <unomod.hxx>
      37             : #include <unoframe.hxx>
      38             : #include <unocrsr.hxx>
      39             : #include <wrtsh.hxx>
      40             : #include <unotbl.hxx>
      41             : #include <svx/fmshell.hxx>
      42             : #include <svx/svdview.hxx>
      43             : #include <svx/svdpage.hxx>
      44             : #include <svx/svdouno.hxx>
      45             : #include <svx/svdogrp.hxx>
      46             : #include <editeng/pbinitem.hxx>
      47             : #include <pagedesc.hxx>
      48             : #include <editeng/lrspitem.hxx>
      49             : #include <editeng/ulspitem.hxx>
      50             : #include <sfx2/bindings.hxx>
      51             : #include <sfx2/request.hxx>
      52             : #include <frmatr.hxx>
      53             : #include <osl/mutex.hxx>
      54             : #include <IMark.hxx>
      55             : #include <unotxdoc.hxx>
      56             : #include <unodraw.hxx>
      57             : #include <svx/unoshcol.hxx>
      58             : #include <svx/unoshape.hxx>
      59             : #include <svx/svdpagv.hxx>
      60             : #include <swerror.h>
      61             : #include <shellio.hxx>
      62             : #include <ndtxt.hxx>
      63             : #include <SwStyleNameMapper.hxx>
      64             : #include <crsskip.hxx>
      65             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      66             : #include <editeng/outliner.hxx>
      67             : #include <editeng/editview.hxx>
      68             : #include <unoparagraph.hxx>
      69             : #include <unocrsrhelper.hxx>
      70             : #include <unotextrange.hxx>
      71             : #include <sfx2/docfile.hxx>
      72             : #include <switerator.hxx>
      73             : #include "swdtflvr.hxx"
      74             : #include <vcl/svapp.hxx>
      75             : #include <comphelper/servicehelper.hxx>
      76             : 
      77             : using namespace ::com::sun::star;
      78             : using namespace ::com::sun::star::uno;
      79             : using namespace ::com::sun::star::lang;
      80             : using namespace ::com::sun::star::beans;
      81             : using namespace ::com::sun::star::text;
      82             : using namespace ::com::sun::star::view;
      83             : using namespace ::com::sun::star::frame;
      84             : 
      85             : using ::com::sun::star::util::URL;
      86             : using comphelper::HelperBaseNoState;
      87             : 
      88             : 
      89         793 : SwXTextView::SwXTextView(SwView* pSwView) :
      90             :     SfxBaseController(pSwView),
      91             :     m_SelChangedListeners(m_aMutex),
      92             :     m_pView(pSwView),
      93         793 :     m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ),
      94             :     pxViewSettings(0),
      95        1586 :     pxTextViewCursor(0)
      96             : {
      97             : 
      98         793 : }
      99             : 
     100        2106 : SwXTextView::~SwXTextView()
     101             : {
     102         702 :     Invalidate();
     103        1404 : }
     104             : 
     105        2286 : void SwXTextView::Invalidate()
     106             : {
     107        2286 :     if(pxViewSettings)
     108             :     {
     109          13 :          HelperBaseNoState *pSettings = static_cast < HelperBaseNoState * > ( pxViewSettings->get() );
     110          13 :         static_cast < SwXViewSettings* > ( pSettings )->Invalidate();
     111          13 :         DELETEZ(pxViewSettings);
     112             :     }
     113        2286 :     if(pxTextViewCursor)
     114             :     {
     115          19 :         text::XTextViewCursor* pCrsr = pxTextViewCursor->get();
     116          19 :         ((SwXTextViewCursor*)pCrsr)->Invalidate();
     117          19 :         DELETEZ(pxTextViewCursor);
     118             :     }
     119             : 
     120        2286 :     m_refCount++; //prevent second d'tor call
     121             : 
     122             :     {
     123             :         uno::Reference<uno::XInterface> const xInt(static_cast<
     124        2286 :                 cppu::OWeakObject*>(static_cast<SfxBaseController*>(this)));
     125        4572 :         lang::EventObject aEvent(xInt);
     126        4572 :         m_SelChangedListeners.disposeAndClear(aEvent);
     127             :     }
     128             : 
     129        2286 :     m_refCount--;
     130        2286 :     m_pView = 0;
     131        2286 : }
     132             : 
     133           0 : Sequence< uno::Type > SAL_CALL SwXTextView::getTypes(  ) throw(uno::RuntimeException)
     134             : {
     135           0 :     uno::Sequence< uno::Type > aBaseTypes = SfxBaseController::getTypes();
     136             : 
     137           0 :     long nIndex = aBaseTypes.getLength();
     138             :     aBaseTypes.realloc(
     139           0 :         aBaseTypes.getLength() + 8 );
     140             : 
     141           0 :     uno::Type* pBaseTypes = aBaseTypes.getArray();
     142           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XSelectionSupplier >*)0);
     143           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XServiceInfo           >*)0);
     144           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XFormLayerAccess   >*)0);
     145           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XTextViewCursorSupplier>*)0);
     146           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XViewSettingsSupplier  >*)0);
     147           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XRubySelection >*)0);
     148           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XPropertySet  >*)0);
     149           0 :     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0);
     150           0 :     return aBaseTypes;
     151             : }
     152             : 
     153             : namespace
     154             : {
     155             :     class theSwXTextViewImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXTextViewImplementationId > {};
     156             : }
     157             : 
     158           0 : Sequence< sal_Int8 > SAL_CALL SwXTextView::getImplementationId(  ) throw(uno::RuntimeException)
     159             : {
     160           0 :     return theSwXTextViewImplementationId::get().getSeq();
     161             : }
     162             : 
     163      667168 : void SAL_CALL SwXTextView::acquire(  )throw()
     164             : {
     165      667168 :     SfxBaseController::acquire();
     166      667168 : }
     167             : 
     168      668658 : void SAL_CALL SwXTextView::release(  )throw()
     169             : {
     170      668658 :     SfxBaseController::release();
     171      668658 : }
     172             : 
     173      135270 : uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType )
     174             :     throw (RuntimeException)
     175             : {
     176      135270 :     uno::Any aRet;
     177      135270 :     if(aType == ::getCppuType((uno::Reference<view::XSelectionSupplier  >*)0))
     178             :     {
     179          11 :         uno::Reference<view::XSelectionSupplier> xRet = this;
     180          11 :         aRet.setValue(&xRet, aType);
     181             :     }
     182      135259 :     else if(aType == ::getCppuType((uno::Reference<lang::XServiceInfo           >*)0))
     183             :     {
     184           0 :         uno::Reference<lang::XServiceInfo> xRet = this;
     185           0 :         aRet.setValue(&xRet, aType);
     186             :     }
     187      135259 :     else if(aType == ::getCppuType((uno::Reference<view::XControlAccess     >*)0))
     188             :     {
     189          34 :         uno::Reference<view::XControlAccess> xRet = this;
     190          34 :         aRet.setValue(&xRet, aType);
     191             :     }
     192      135225 :     else if(aType == ::getCppuType((uno::Reference<view::XFormLayerAccess   >*)0))
     193             :     {
     194           5 :         uno::Reference<view::XFormLayerAccess> xRet = this;
     195           5 :         aRet.setValue(&xRet, aType);
     196             :     }
     197      135220 :     else if(aType == ::getCppuType((uno::Reference<text::XTextViewCursorSupplier>*)0))
     198             :     {
     199          25 :         uno::Reference<text::XTextViewCursorSupplier> xRet = this;
     200          25 :         aRet.setValue(&xRet, aType);
     201             :     }
     202      135195 :     else if(aType == ::getCppuType((uno::Reference<view::XViewSettingsSupplier  >*)0))
     203             :     {
     204          13 :         uno::Reference<view::XViewSettingsSupplier> xRet = this;
     205          13 :         aRet.setValue(&xRet, aType);
     206             :     }
     207      135182 :     else if(aType == ::getCppuType((uno::Reference<XRubySelection>*)0))
     208             :     {
     209           0 :         uno::Reference<XRubySelection> xRet = this;
     210           0 :         aRet.setValue(&xRet, aType);
     211             :     }
     212      135182 :     else if(aType == ::getCppuType((uno::Reference<XPropertySet>*)0))
     213             :     {
     214        2382 :         uno::Reference<XPropertySet> xRet = this;
     215        2382 :         aRet.setValue(&xRet, aType);
     216             :     }
     217      132800 :     else if(aType == ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier   >*)0))
     218             :     {
     219           0 :         uno::Reference<datatransfer::XTransferableSupplier> xRet = this;
     220           0 :         aRet.setValue(&xRet, aType);
     221             :     }
     222             :     else
     223      132800 :         aRet = SfxBaseController::queryInterface(aType);
     224      135270 :     return aRet;
     225             : }
     226             : 
     227           9 : sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArgumentException, uno::RuntimeException )
     228             : {
     229           9 :     SolarMutexGuard aGuard;
     230             : 
     231          18 :     uno::Reference< uno::XInterface >  xInterface;
     232           9 :     if (!GetView() || !(aInterface >>= xInterface))
     233             :     {
     234           0 :         return sal_False;
     235             :     }
     236             : 
     237           9 :     SwWrtShell& rSh = GetView()->GetWrtShell();
     238           9 :     SwDoc* pDoc = GetView()->GetDocShell()->GetDoc();
     239          18 :     std::vector<SdrObject *> sdrObjects;
     240             :     uno::Reference<awt::XControlModel> const xCtrlModel(xInterface,
     241          18 :             UNO_QUERY);
     242           9 :     if (xCtrlModel.is())
     243             :     {
     244           0 :         uno::Reference<awt::XControl> xControl;
     245           0 :         SdrObject *const pSdrObject = GetControl(xCtrlModel, xControl);
     246           0 :         if (pSdrObject) // hmm... needs view to verify it's in right doc...
     247             :         {
     248           0 :             sdrObjects.push_back(pSdrObject);
     249           0 :         }
     250             :     }
     251             :     else
     252             :     {
     253           9 :         SwPaM * pPaM(0);
     254           9 :         std::pair<OUString, FlyCntType> frame;
     255           9 :         OUString tableName;
     256           9 :         SwUnoTableCrsr const* pTableCursor(0);
     257           9 :         ::sw::mark::IMark const* pMark(0);
     258             :         SwUnoCursorHelper::GetSelectableFromAny(xInterface, *pDoc,
     259           9 :                 pPaM, frame, tableName, pTableCursor, pMark, sdrObjects);
     260           9 :         if (pPaM)
     261             :         {
     262           0 :             rSh.EnterStdMode();
     263           0 :             rSh.SetSelection(*pPaM);
     264             :             // the pPaM has been copied - delete it
     265           0 :             while (pPaM->GetNext() != pPaM)
     266           0 :                 delete pPaM->GetNext();
     267           0 :             delete pPaM;
     268           0 :             return sal_True;
     269             :         }
     270           9 :         else if (!frame.first.isEmpty())
     271             :         {
     272           0 :             bool const bSuccess(rSh.GotoFly(frame.first, frame.second));
     273           0 :             if (bSuccess)
     274             :             {
     275           0 :                 rSh.HideCrsr();
     276           0 :                 rSh.EnterSelFrmMode();
     277             :             }
     278           0 :             return sal_True;
     279             :         }
     280           9 :         else if (!tableName.isEmpty())
     281             :         {
     282           9 :             rSh.EnterStdMode();
     283           9 :             rSh.GotoTable(tableName);
     284           9 :             return sal_True;
     285             :         }
     286           0 :         else if (pTableCursor)
     287             :         {
     288           0 :             UnoActionRemoveContext const aContext(pDoc);
     289           0 :             rSh.EnterStdMode();
     290           0 :             rSh.SetSelection(*pTableCursor);
     291           0 :             return sal_True;
     292             :         }
     293           0 :         else if (pMark)
     294             :         {
     295           0 :             rSh.EnterStdMode();
     296           0 :             rSh.GotoMark(pMark);
     297           0 :             return sal_True;
     298           0 :         }
     299             :         // sdrObjects handled below
     300             :     }
     301           0 :     sal_Bool bRet(sal_False);
     302           0 :     if (sdrObjects.size())
     303             :     {
     304             : 
     305           0 :         SdrView *const pDrawView = rSh.GetDrawView();
     306           0 :         SdrPageView *const pPV = pDrawView->GetSdrPageView();
     307             : 
     308           0 :         pDrawView->SdrEndTextEdit();
     309           0 :         pDrawView->UnmarkAll();
     310             : 
     311           0 :         for (size_t i = 0; i < sdrObjects.size(); ++i)
     312             :         {
     313           0 :             SdrObject *const pSdrObject(sdrObjects[i]);
     314             :             // GetSelectableFromAny did not check pSdrObject is in right doc!
     315           0 :             if (pPV && pSdrObject->GetPage() == pPV->GetPage())
     316             :             {
     317           0 :                 pDrawView->MarkObj(pSdrObject, pPV);
     318           0 :                 bRet = sal_True;
     319             :             }
     320             :         }
     321             :     }
     322           9 :     return bRet;
     323             : }
     324             : 
     325           2 : uno::Any SwXTextView::getSelection(void) throw( uno::RuntimeException )
     326             : {
     327           2 :     SolarMutexGuard aGuard;
     328           4 :     uno::Reference< uno::XInterface >  aRef;
     329           2 :     if(GetView())
     330             :     {
     331             :         //force immediat shell update
     332           2 :         m_pView->StopShellTimer();
     333             :         //Generating an interface from the current selection.
     334           2 :         SwWrtShell& rSh = m_pView->GetWrtShell();
     335           2 :         ShellModes  eSelMode = m_pView->GetShellMode();
     336           2 :         switch(eSelMode)
     337             :         {
     338             :             case SHELL_MODE_TABLE_TEXT      :
     339             :             {
     340           1 :                 if(rSh.GetTableCrsr())
     341             :                 {
     342             :                     OSL_ENSURE(rSh.GetTableFmt(), "not a table format?");
     343           0 :                     uno::Reference< text::XTextTableCursor >  xCrsr = new SwXTextTableCursor(*rSh.GetTableFmt(),
     344           0 :                                                     rSh.GetTableCrsr());
     345           0 :                     aRef = uno::Reference< uno::XInterface >  (xCrsr, uno::UNO_QUERY);
     346           0 :                     break;
     347             :                 }
     348             : 
     349             :             }
     350             :             //Without a table selection the text will be delivered.
     351             :             //break;
     352             :             case SHELL_MODE_LIST_TEXT       :
     353             :             case SHELL_MODE_TABLE_LIST_TEXT:
     354             :             case SHELL_MODE_TEXT            :
     355             :             {
     356           2 :                 uno::Reference< container::XIndexAccess >  xPos = new SwXTextRanges(rSh.GetCrsr());
     357           2 :                 aRef = uno::Reference< uno::XInterface >(xPos, uno::UNO_QUERY);
     358             :             }
     359           2 :             break;
     360             :             case SHELL_MODE_FRAME           :
     361             :             case SHELL_MODE_GRAPHIC         :
     362             :             case SHELL_MODE_OBJECT          :
     363             :             {
     364             :                 //Get FlyFrameFormat; for UI-Macro connection to flys
     365           0 :                 const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
     366           0 :                 if (pFmt)
     367             :                 {
     368           0 :                     SwXFrame* pxFrame = SwIterator<SwXFrame,SwFmt>::FirstElement(*pFmt);
     369           0 :                     if(pxFrame)                //The only common interface for all frames.
     370             :                     {
     371           0 :                         aRef = uno::Reference< uno::XInterface >((cppu::OWeakObject*)pxFrame, uno::UNO_QUERY);
     372             :                     }
     373             :                     else
     374             :                     {
     375           0 :                         if(SHELL_MODE_FRAME == eSelMode)
     376             :                         {
     377           0 :                             uno::Reference< text::XTextFrame >  xFrm =  new SwXTextFrame((SwFrmFmt&)*pFmt);
     378           0 :                             aRef = uno::Reference< uno::XInterface >(xFrm, uno::UNO_QUERY);
     379             :                         }
     380           0 :                         else if(SHELL_MODE_GRAPHIC == eSelMode)
     381             :                         {
     382           0 :                             uno::Reference< text::XTextContent >  xFrm = new SwXTextGraphicObject((SwFrmFmt&)*pFmt);
     383           0 :                             aRef = xFrm;
     384             :                         }
     385             :                         else
     386             :                         {
     387           0 :                             uno::Reference< text::XTextContent >  xFrm =  new SwXTextEmbeddedObject((SwFrmFmt&)*pFmt);
     388           0 :                             aRef = xFrm;
     389             :                         }
     390             :                     }
     391             :                 }
     392             :             }
     393           0 :             break;
     394             :             case SHELL_MODE_DRAW            :
     395             :             case SHELL_MODE_DRAW_CTRL       :
     396             :             case SHELL_MODE_DRAW_FORM       :
     397             :             case SHELL_MODE_DRAWTEXT        :
     398             :             case SHELL_MODE_BEZIER          :
     399             :             {
     400           0 :                 uno::Reference< drawing::XDrawPageSupplier >  xPageSupp;
     401           0 :                 uno::Reference< frame::XModel > xModel = m_pView->GetDocShell()->GetBaseModel();
     402           0 :                 uno::Reference< lang::XUnoTunnel > xModelTunnel(xModel, uno::UNO_QUERY);
     403           0 :                 SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument*>(xModelTunnel->
     404           0 :                                 getSomething(SwXTextDocument::getUnoTunnelId()));
     405             : 
     406           0 :                 SwFmDrawPage* pSvxDrawPage =    pTextDoc->GetDrawPage()->GetSvxPage();
     407           0 :                 uno::Reference< drawing::XShapes >  xShCol = new SvxShapeCollection();
     408             : 
     409           0 :                 const SdrMarkList& rMarkList = rSh.GetDrawView()->GetMarkedObjectList();
     410           0 :                 for(sal_uInt16 i = 0; i < rMarkList.GetMarkCount(); i++)
     411             :                 {
     412           0 :                     SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
     413           0 :                     uno::Reference< uno::XInterface >  xInt = pSvxDrawPage->GetInterface( pObj );
     414           0 :                     uno::Reference< drawing::XShape >  xShape(xInt, uno::UNO_QUERY);
     415           0 :                     xShCol->add(xShape);
     416           0 :                 }
     417           0 :                 aRef = uno::Reference< uno::XInterface >(xShCol, uno::UNO_QUERY);
     418             :             }
     419           0 :             break;
     420             :             default:;//prevent warning
     421             :         }
     422             :     }
     423           2 :     uno::Any aRet(&aRef, ::getCppuType((uno::Reference<uno::XInterface>*)0));
     424           4 :     return aRet;
     425             : }
     426             : 
     427           1 : void SwXTextView::addSelectionChangeListener(
     428             :                                     const uno::Reference< view::XSelectionChangeListener > & rxListener)
     429             :                                     throw( uno::RuntimeException )
     430             : {
     431           1 :     SolarMutexGuard aGuard;
     432           1 :     m_SelChangedListeners.addInterface(rxListener);
     433           1 : }
     434             : 
     435           1 : void SwXTextView::removeSelectionChangeListener(
     436             :                                         const uno::Reference< view::XSelectionChangeListener > & rxListener)
     437             :                                         throw( uno::RuntimeException )
     438             : {
     439           1 :     SolarMutexGuard aGuard;
     440           1 :     m_SelChangedListeners.removeInterface(rxListener);
     441           1 : }
     442             : 
     443          94 : SdrObject* SwXTextView::GetControl(
     444             :         const uno::Reference< awt::XControlModel > & xModel,
     445             :         uno::Reference< awt::XControl >& xToFill  )
     446             : {
     447          94 :     SwView* pView2 = GetView();
     448          94 :     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
     449          94 :     SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
     450          94 :     Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
     451             : 
     452             :     OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" );
     453             : 
     454          94 :     SdrObject* pControl = NULL;
     455          94 :     if ( pFormShell && pDrawView && pWindow )
     456          94 :         pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow, xToFill );
     457          94 :     return pControl;
     458             : }
     459             : 
     460          94 : uno::Reference< awt::XControl >  SwXTextView::getControl(const uno::Reference< awt::XControlModel > & xModel)
     461             :         throw( container::NoSuchElementException, uno::RuntimeException )
     462             : {
     463          94 :     SolarMutexGuard aGuard;
     464          94 :     uno::Reference< awt::XControl >  xRet;
     465          94 :     GetControl(xModel, xRet);
     466          94 :     return xRet;
     467             : }
     468             : 
     469           0 : uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& _Form ) throw (RuntimeException)
     470             : {
     471           0 :     SolarMutexGuard aGuard;
     472             : 
     473           0 :     SwView* pView2 = GetView();
     474           0 :     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
     475           0 :     SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
     476           0 :     Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
     477             :     OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::getFormController: how could I?" );
     478             : 
     479           0 :     uno::Reference< form::runtime::XFormController > xController;
     480           0 :     if ( pFormShell && pDrawView && pWindow )
     481           0 :         xController = pFormShell->GetFormController( _Form, *pDrawView, *pWindow );
     482           0 :     return xController;
     483             : }
     484             : 
     485           1 : ::sal_Bool SAL_CALL SwXTextView::isFormDesignMode(  ) throw (uno::RuntimeException)
     486             : {
     487           1 :     SolarMutexGuard aGuard;
     488           1 :     SwView* pView2 = GetView();
     489           1 :     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
     490           1 :     return pFormShell ? pFormShell->IsDesignMode() : sal_True;
     491             : }
     492             : 
     493           4 : void SAL_CALL SwXTextView::setFormDesignMode( ::sal_Bool _DesignMode ) throw (RuntimeException)
     494             : {
     495           4 :     SolarMutexGuard aGuard;
     496           4 :     SwView* pView2 = GetView();
     497           4 :     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
     498           4 :     if ( pFormShell )
     499           4 :         pFormShell->SetDesignMode( _DesignMode );
     500           4 : }
     501             : 
     502          25 : uno::Reference< text::XTextViewCursor >  SwXTextView::getViewCursor(void) throw( uno::RuntimeException )
     503             : {
     504          25 :     SolarMutexGuard aGuard;
     505          25 :     if(GetView())
     506             :     {
     507          25 :         if(!pxTextViewCursor)
     508             :         {
     509          19 :             ((SwXTextView*)this)->pxTextViewCursor = new uno::Reference< text::XTextViewCursor > ;
     510          19 :             *pxTextViewCursor = new  SwXTextViewCursor(GetView());
     511             :         }
     512          50 :         return *pxTextViewCursor;
     513             :     }
     514             :     else
     515           0 :         throw uno::RuntimeException();
     516             : }
     517             : 
     518          14 : uno::Reference< beans::XPropertySet >  SwXTextView::getViewSettings(void) throw( uno::RuntimeException )
     519             : {
     520          14 :     SolarMutexGuard aGuard;
     521          14 :     if(m_pView)
     522             :     {
     523          14 :         if(!pxViewSettings)
     524             :         {
     525          13 :             ((SwXTextView*)this)->pxViewSettings = new uno::Reference< beans::XPropertySet > ;
     526          13 :             *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, m_pView ) );
     527             :         }
     528             :     }
     529             :     else
     530           0 :         throw uno::RuntimeException();
     531          14 :     return *pxViewSettings;
     532             : }
     533             : 
     534           0 : Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAutomatic*/ ) throw(RuntimeException)
     535             : {
     536           0 :     SolarMutexGuard aGuard;
     537             : 
     538           0 :     if(!GetView())
     539           0 :         throw RuntimeException();
     540           0 :     SwWrtShell& rSh = m_pView->GetWrtShell();
     541           0 :     ShellModes  eSelMode = m_pView->GetShellMode();
     542           0 :     if (eSelMode != SHELL_MODE_LIST_TEXT      &&
     543           0 :         eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
     544           0 :         eSelMode != SHELL_MODE_TABLE_TEXT      &&
     545             :         eSelMode != SHELL_MODE_TEXT           )
     546           0 :         return Sequence< Sequence< PropertyValue > > ();
     547             : 
     548           0 :     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
     549           0 :     SwRubyList aList;
     550             : 
     551           0 :     sal_uInt16 nCount = pDoc->FillRubyList( *rSh.GetCrsr(), aList, 0 );
     552           0 :     Sequence< Sequence< PropertyValue > > aRet(nCount);
     553           0 :     Sequence< PropertyValue >* pRet = aRet.getArray();
     554           0 :     String aString;
     555           0 :     for(sal_uInt16 n = 0; n < nCount; n++)
     556             :     {
     557           0 :         const SwRubyListEntry* pEntry = &aList[n];
     558             : 
     559           0 :         const String& rEntryText = pEntry->GetText();
     560           0 :         const SwFmtRuby& rAttr = pEntry->GetRubyAttr();
     561             : 
     562           0 :         pRet[n].realloc(5);
     563           0 :         PropertyValue* pValues = pRet[n].getArray();
     564           0 :         pValues[0].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RUBY_BASE_TEXT));
     565           0 :         pValues[0].Value <<= OUString(rEntryText);
     566           0 :         pValues[1].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RUBY_TEXT));
     567           0 :         pValues[1].Value <<= OUString(rAttr.GetText());
     568           0 :         pValues[2].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RUBY_CHAR_STYLE_NAME));
     569           0 :         SwStyleNameMapper::FillProgName(rAttr.GetCharFmtName(), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
     570           0 :         pValues[2].Value <<= OUString( aString );
     571           0 :         pValues[3].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RUBY_ADJUST));
     572           0 :         pValues[3].Value <<= (sal_Int16)rAttr.GetAdjustment();
     573           0 :         pValues[4].Name = OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RUBY_IS_ABOVE));
     574           0 :         sal_Bool bVal = !rAttr.GetPosition();
     575           0 :         pValues[4].Value.setValue(&bVal, ::getBooleanCppuType());
     576             :     }
     577           0 :     return aRet;
     578             : }
     579             : 
     580           0 : void SAL_CALL SwXTextView::setRubyList(
     581             :     const Sequence< Sequence< PropertyValue > >& rRubyList, sal_Bool /*bAutomatic*/ )
     582             :         throw(RuntimeException)
     583             : {
     584           0 :     SolarMutexGuard aGuard;
     585             : 
     586           0 :     if(!GetView() || !rRubyList.getLength())
     587           0 :         throw RuntimeException();
     588           0 :     SwWrtShell& rSh = m_pView->GetWrtShell();
     589           0 :     ShellModes  eSelMode = m_pView->GetShellMode();
     590           0 :     if (eSelMode != SHELL_MODE_LIST_TEXT      &&
     591           0 :         eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
     592           0 :         eSelMode != SHELL_MODE_TABLE_TEXT      &&
     593             :         eSelMode != SHELL_MODE_TEXT           )
     594           0 :         throw RuntimeException();
     595             : 
     596           0 :     SwRubyList aList;
     597             : 
     598           0 :     const Sequence<PropertyValue>* pRubyList = rRubyList.getConstArray();
     599           0 :     for(sal_Int32 nPos = 0; nPos < rRubyList.getLength(); nPos++)
     600             :     {
     601           0 :         SwRubyListEntry* pEntry = new SwRubyListEntry;
     602           0 :         const PropertyValue* pProperties = pRubyList[nPos].getConstArray();
     603           0 :         OUString sTmp;
     604           0 :         for(sal_Int32 nProp = 0; nProp < pRubyList[nPos].getLength(); nProp++)
     605             :         {
     606           0 :             if(pProperties[nProp].Name.equalsAsciiL(
     607           0 :                                     SW_PROP_NAME(UNO_NAME_RUBY_BASE_TEXT)))
     608             :             {
     609           0 :                 pProperties[nProp].Value >>= sTmp;
     610           0 :                 pEntry->SetText(sTmp);
     611             :             }
     612           0 :             else if(pProperties[nProp].Name.equalsAsciiL(
     613           0 :                                     SW_PROP_NAME(UNO_NAME_RUBY_TEXT)))
     614             :             {
     615           0 :                 pProperties[nProp].Value >>= sTmp;
     616           0 :                 pEntry->GetRubyAttr().SetText(sTmp);
     617             :             }
     618           0 :             else if(pProperties[nProp].Name.equalsAsciiL(
     619           0 :                                     SW_PROP_NAME(UNO_NAME_RUBY_CHAR_STYLE_NAME)))
     620             :             {
     621           0 :                 if((pProperties[nProp].Value >>= sTmp))
     622             :                 {
     623           0 :                     String sName;
     624           0 :                     SwStyleNameMapper::FillUIName(sTmp, sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
     625           0 :                     sal_uInt16 nPoolId = sName.Len() ?
     626           0 :                         SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) : 0;
     627             : 
     628           0 :                     pEntry->GetRubyAttr().SetCharFmtName( sName );
     629           0 :                     pEntry->GetRubyAttr().SetCharFmtId( nPoolId );
     630             :                 }
     631             :             }
     632           0 :             else if(pProperties[nProp].Name.equalsAsciiL(
     633           0 :                                     SW_PROP_NAME(UNO_NAME_RUBY_ADJUST)))
     634             :             {
     635           0 :                 sal_Int16 nTmp = 0;
     636           0 :                 if((pProperties[nProp].Value >>= nTmp))
     637           0 :                     pEntry->GetRubyAttr().SetAdjustment(nTmp);
     638             :             }
     639           0 :             else if(pProperties[nProp].Name.equalsAsciiL(
     640           0 :                                     SW_PROP_NAME(UNO_NAME_RUBY_IS_ABOVE)))
     641             :             {
     642           0 :                 sal_Bool bValue = pProperties[nProp].Value.hasValue() ?
     643           0 :                     *(sal_Bool*)pProperties[nProp].Value.getValue() : sal_True;
     644           0 :                 pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
     645             :             }
     646             :         }
     647           0 :         aList.insert(aList.begin() + nPos, pEntry);
     648           0 :     }
     649           0 :     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
     650           0 :     pDoc->SetRubyList( *rSh.GetCrsr(), aList, 0 );
     651           0 : }
     652             : 
     653           0 : SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc()
     654             : {
     655           0 :     SwWrtShell& rOldSh = m_pView->GetWrtShell();
     656           0 :     SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false );
     657             :     SwDocShell* pDocSh;
     658           0 :     SfxObjectShellLock xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) );
     659           0 :     xDocSh->DoInitNew( 0 );
     660           0 :     SwDoc *const pTempDoc( pDocSh->GetDoc() );
     661             :     // #i103634#, #i112425#: do not expand numbering and fields on PDF export
     662           0 :     pTempDoc->SetClipBoard(true);
     663           0 :     rOldSh.FillPrtDoc(pTempDoc,  pPrt);
     664           0 :     SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
     665           0 :     SwView* pDocView = (SwView*) pDocFrame->GetViewShell();
     666           0 :     pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//So that SelectShell is called.
     667           0 :     SwWrtShell* pSh = pDocView->GetWrtShellPtr();
     668             : 
     669           0 :     IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
     670           0 :     SfxPrinter* pTempPrinter = pIDDA->getPrinter( true );
     671             : 
     672           0 :     const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc());
     673             : 
     674           0 :     IDocumentDeviceAccess* pIDDA_old = rOldSh.getIDocumentDeviceAccess();
     675             : 
     676           0 :     if( pIDDA_old->getPrinter( false ) )
     677             :     {
     678           0 :         pIDDA->setJobsetup( *pIDDA_old->getJobsetup() );
     679             :         //#69563# if it isn't the same printer then the pointer has been invalidated!
     680           0 :         pTempPrinter = pIDDA->getPrinter( true );
     681             :     }
     682             : 
     683           0 :     pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
     684             : 
     685           0 :     return xDocSh;
     686             : }
     687             : 
     688       10865 : void SwXTextView::NotifySelChanged()
     689             : {
     690             :     OSL_ENSURE( m_pView, "view is missing" );
     691             : 
     692             :     uno::Reference<uno::XInterface> const xInt(
     693       10865 :         static_cast<cppu::OWeakObject*>(static_cast<SfxBaseController*>(this)));
     694             : 
     695       21730 :     lang::EventObject const aEvent(xInt);
     696             :     m_SelChangedListeners.notifyEach(
     697       21730 :             &view::XSelectionChangeListener::selectionChanged, aEvent);
     698       10865 : }
     699             : 
     700             : namespace {
     701             :     struct DispatchListener
     702             :     {
     703             :         URL const & m_rURL;
     704             :         Sequence<PropertyValue> const& m_rSeq;
     705           0 :         explicit DispatchListener(URL const& rURL,
     706             :                 Sequence<PropertyValue> const& rSeq)
     707           0 :             : m_rURL(rURL), m_rSeq(rSeq) { }
     708           0 :         void operator()(uno::Reference<XDispatch> const & xListener) const
     709             :         {
     710           0 :             xListener->dispatch(m_rURL, m_rSeq);
     711           0 :         }
     712             :     };
     713             : }
     714             : 
     715           0 : void SwXTextView::NotifyDBChanged()
     716             : {
     717           0 :     URL aURL;
     718           0 :     aURL.Complete = OUString::createFromAscii(SwXDispatch::GetDBChangeURL());
     719             : 
     720             :     m_SelChangedListeners.forEach<XDispatch>(
     721           0 :             DispatchListener(aURL, Sequence<PropertyValue>(0)));
     722           0 : }
     723             : 
     724        2382 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo(  )
     725             :     throw (uno::RuntimeException)
     726             : {
     727        2382 :     SolarMutexGuard aGuard;
     728        2382 :     static uno::Reference< XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
     729        2382 :     return aRef;
     730             : }
     731             : 
     732           0 : void SAL_CALL SwXTextView::setPropertyValue(
     733             :         const OUString& rPropertyName, const uno::Any& rValue )
     734             :     throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
     735             : {
     736           0 :     SolarMutexGuard aGuard;
     737           0 :     const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
     738           0 :     if (!pEntry)
     739           0 :         throw UnknownPropertyException();
     740           0 :     else if (pEntry->nFlags & PropertyAttribute::READONLY)
     741           0 :         throw PropertyVetoException();
     742             :     else
     743             :     {
     744           0 :         switch (pEntry->nWID)
     745             :         {
     746             :             case WID_IS_HIDE_SPELL_MARKS :
     747             :                 // deprecated #i91949
     748           0 :             break;
     749             :             case WID_IS_CONSTANT_SPELLCHECK :
     750             :             {
     751           0 :                 sal_Bool bVal = sal_False;
     752           0 :                 const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
     753           0 :                 if (!pOpt || !(rValue >>= bVal))
     754           0 :                     throw RuntimeException();
     755           0 :                 SwViewOption aNewOpt( *pOpt );
     756           0 :                 if (pEntry->nWID == WID_IS_CONSTANT_SPELLCHECK)
     757           0 :                     aNewOpt.SetOnlineSpell(bVal);
     758           0 :                 m_pView->GetWrtShell().ApplyViewOptions( aNewOpt );
     759             :             }
     760           0 :             break;
     761             :             default :
     762             :                 OSL_FAIL("unknown WID");
     763             :         }
     764           0 :     }
     765           0 : }
     766             : 
     767           0 : uno::Any SAL_CALL SwXTextView::getPropertyValue(
     768             :         const OUString& rPropertyName )
     769             :     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     770             : {
     771           0 :     SolarMutexGuard aGuard;
     772             : 
     773           0 :     Any aRet;
     774             : 
     775           0 :     const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
     776           0 :     if (!pEntry)
     777           0 :         throw UnknownPropertyException();
     778             :     else
     779             :     {
     780           0 :         sal_Int16 nWID = pEntry->nWID;
     781           0 :         switch (nWID)
     782             :         {
     783             :             case WID_PAGE_COUNT :
     784             :             case WID_LINE_COUNT :
     785             :             {
     786             :                 // format document completely in order to get meaningful
     787             :                 // values for page count and line count
     788           0 :                 m_pView->GetWrtShell().CalcLayout();
     789             : 
     790           0 :                 sal_Int32 nCount = -1;
     791           0 :                 if (nWID == WID_PAGE_COUNT)
     792           0 :                     nCount = m_pView->GetWrtShell().GetPageCount();
     793             :                 else // WID_LINE_COUNT
     794           0 :                     nCount = m_pView->GetWrtShell().GetLineCount( sal_False /*of whole document*/ );
     795           0 :                 aRet <<= nCount;
     796             :             }
     797           0 :             break;
     798             :             case WID_IS_HIDE_SPELL_MARKS :
     799             :                 // deprecated #i91949
     800           0 :             break;
     801             :             case WID_IS_CONSTANT_SPELLCHECK :
     802             :             {
     803           0 :                 const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
     804           0 :                 if (!pOpt)
     805           0 :                     throw RuntimeException();
     806           0 :                 sal_uInt32 nFlag = VIEWOPT_1_ONLINESPELL;
     807           0 :                 sal_Bool bVal = 0 != (pOpt->GetCoreOptions() & nFlag);
     808           0 :                 aRet <<= bVal;
     809             :             }
     810           0 :             break;
     811             :             default :
     812             :                 OSL_FAIL("unknown WID");
     813             :         }
     814             :     }
     815             : 
     816           0 :     return aRet;
     817             : }
     818             : 
     819           0 : void SAL_CALL SwXTextView::addPropertyChangeListener(
     820             :         const OUString& /*rPropertyName*/,
     821             :         const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
     822             :     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     823             : {
     824             :     OSL_FAIL("not implemented");
     825           0 : }
     826             : 
     827           0 : void SAL_CALL SwXTextView::removePropertyChangeListener(
     828             :         const OUString& /*rPropertyName*/,
     829             :         const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
     830             :     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     831             : {
     832             :     OSL_FAIL("not implemented");
     833           0 : }
     834             : 
     835           0 : void SAL_CALL SwXTextView::addVetoableChangeListener(
     836             :         const OUString& /*rPropertyName*/,
     837             :         const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
     838             :     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     839             : {
     840             :     OSL_FAIL("not implemented");
     841           0 : }
     842             : 
     843           0 : void SAL_CALL SwXTextView::removeVetoableChangeListener(
     844             :         const OUString& /*rPropertyName*/,
     845             :         const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
     846             :     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     847             : {
     848             :     OSL_FAIL("not implemented");
     849           0 : }
     850             : 
     851           0 : OUString SwXTextView::getImplementationName(void) throw( RuntimeException )
     852             : {
     853           0 :     return OUString("SwXTextView");
     854             : }
     855             : 
     856           0 : sal_Bool SwXTextView::supportsService(const OUString& rServiceName) throw( RuntimeException )
     857             : {
     858           0 :     return rServiceName == "com.sun.star.text.TextDocumentView" || rServiceName == "com.sun.star.view.OfficeDocumentView";
     859             : }
     860             : 
     861           0 : Sequence< OUString > SwXTextView::getSupportedServiceNames(void) throw( RuntimeException )
     862             : {
     863           0 :     Sequence< OUString > aRet(2);
     864           0 :     OUString* pArray = aRet.getArray();
     865           0 :     pArray[0] = "com.sun.star.text.TextDocumentView";
     866           0 :     pArray[1] = "com.sun.star.view.OfficeDocumentView";
     867           0 :     return aRet;
     868             : }
     869             : 
     870          19 : SwXTextViewCursor::SwXTextViewCursor(SwView* pVw) :
     871             :     m_pView(pVw),
     872          19 :     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
     873             : {
     874          19 : }
     875             : 
     876          38 : SwXTextViewCursor::~SwXTextViewCursor()
     877             : {
     878          38 : }
     879             : 
     880             : // used to determine if there is a text selction or not.
     881             : // If there is no text selection the functions that need a working
     882             : // cursor will be disabled (throw RuntimeException). This will be the case
     883             : // for the following interfaces:
     884             : // - XViewCursor
     885             : // - XTextCursor
     886             : // - XTextRange
     887             : // - XLineCursor
     888          46 : sal_Bool SwXTextViewCursor::IsTextSelection( sal_Bool bAllowTables ) const
     889             : {
     890             : 
     891          46 :     sal_Bool bRes = sal_False;
     892             :     OSL_ENSURE(m_pView, "m_pView is NULL ???");
     893          46 :     if(m_pView)
     894             :     {
     895             :         //! m_pView->GetShellMode() will only work after the shell
     896             :         //! has already changed and thus can not be used here!
     897          46 :         SelectionType eSelType = m_pView->GetWrtShell().GetSelectionType();
     898          46 :         bRes =  ( (nsSelectionType::SEL_TXT & eSelType) ||
     899         138 :                   (nsSelectionType::SEL_NUM & eSelType) )  &&
     900          92 :                 (!(nsSelectionType::SEL_TBL_CELLS & eSelType) || bAllowTables);
     901             :     }
     902          46 :     return bRes;
     903             : }
     904             : 
     905           0 : sal_Bool SwXTextViewCursor::isVisible(void) throw( uno::RuntimeException )
     906             : {
     907           0 :     SolarMutexGuard aGuard;
     908             :     OSL_FAIL("not implemented");
     909           0 :     return sal_True;
     910             : }
     911             : 
     912           0 : void SwXTextViewCursor::setVisible(sal_Bool /*bVisible*/) throw( uno::RuntimeException )
     913             : {
     914           0 :     SolarMutexGuard aGuard;
     915           0 :     OSL_FAIL("not implemented");
     916           0 : }
     917             : 
     918           8 : awt::Point SwXTextViewCursor::getPosition(void) throw( uno::RuntimeException )
     919             : {
     920           8 :     SolarMutexGuard aGuard;
     921           8 :     awt::Point aRet;
     922           8 :     if(m_pView)
     923             :     {
     924           8 :         const SwWrtShell& rSh = m_pView->GetWrtShell();
     925           8 :         const SwRect aCharRect(rSh.GetCharRect());
     926             : 
     927           8 :         const SwFrmFmt& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster();
     928             : 
     929           8 :         const SvxULSpaceItem& rUL = rMaster.GetULSpace();
     930           8 :         const long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER);
     931           8 :         aRet.Y = TWIP_TO_MM100(nY);
     932             : 
     933           8 :         const SvxLRSpaceItem& rLR = rMaster.GetLRSpace();
     934           8 :         const long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER);
     935           8 :         aRet.X = TWIP_TO_MM100(nX);
     936             :     }
     937             :     else
     938           0 :         throw uno::RuntimeException();
     939           8 :     return aRet;
     940             : }
     941             : 
     942           1 : void SwXTextViewCursor::collapseToStart(void) throw( uno::RuntimeException )
     943             : {
     944           1 :     SolarMutexGuard aGuard;
     945           1 :     if(m_pView)
     946             :     {
     947           1 :         if (!IsTextSelection())
     948           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
     949             : 
     950           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
     951           1 :         if(rSh.HasSelection())
     952             :         {
     953           1 :             SwPaM* pShellCrsr = rSh.GetCrsr();
     954           1 :             if(*pShellCrsr->GetPoint() > *pShellCrsr->GetMark())
     955           1 :                 pShellCrsr->Exchange();
     956           1 :             pShellCrsr->DeleteMark();
     957           1 :             rSh.EnterStdMode();
     958           1 :             rSh.SetSelection(*pShellCrsr);
     959             :         }
     960             :     }
     961             :     else
     962           0 :         throw uno::RuntimeException();
     963           1 : }
     964             : 
     965           1 : void SwXTextViewCursor::collapseToEnd(void) throw( uno::RuntimeException )
     966             : {
     967           1 :     SolarMutexGuard aGuard;
     968           1 :     if(m_pView)
     969             :     {
     970           1 :         if (!IsTextSelection())
     971           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
     972             : 
     973           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
     974           1 :         if(rSh.HasSelection())
     975             :         {
     976           1 :             SwPaM* pShellCrsr = rSh.GetCrsr();
     977           1 :             if(*pShellCrsr->GetPoint() < *pShellCrsr->GetMark())
     978           0 :                 pShellCrsr->Exchange();
     979           1 :             pShellCrsr->DeleteMark();
     980           1 :             rSh.EnterStdMode();
     981           1 :             rSh.SetSelection(*pShellCrsr);
     982             :         }
     983             :     }
     984             :     else
     985           0 :         throw uno::RuntimeException();
     986           1 : }
     987             : 
     988           2 : sal_Bool SwXTextViewCursor::isCollapsed(void) throw( uno::RuntimeException )
     989             : {
     990           2 :     SolarMutexGuard aGuard;
     991           2 :     sal_Bool bRet = sal_False;
     992           2 :     if(m_pView)
     993             :     {
     994           2 :         if (!IsTextSelection())
     995           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
     996             : 
     997           2 :         const SwWrtShell& rSh = m_pView->GetWrtShell();
     998           2 :         bRet = !rSh.HasSelection();
     999             :     }
    1000             :     else
    1001           0 :         throw uno::RuntimeException();
    1002           2 :     return bRet;
    1003             : 
    1004             : }
    1005             : 
    1006           2 : sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
    1007             : {
    1008           2 :     SolarMutexGuard aGuard;
    1009           2 :     sal_Bool bRet = sal_False;
    1010           2 :     if(m_pView)
    1011             :     {
    1012           2 :         if (!IsTextSelection())
    1013           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1014             : 
    1015           8 :         for( sal_uInt16 i = 0; i < nCount; i++ )
    1016           6 :             bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
    1017             :     }
    1018             :     else
    1019           0 :         throw uno::RuntimeException();
    1020           2 :     return bRet;
    1021             : }
    1022             : 
    1023           3 : sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
    1024             : {
    1025           3 :     SolarMutexGuard aGuard;
    1026           3 :     sal_Bool bRet = sal_False;
    1027           3 :     if(m_pView)
    1028             :     {
    1029           3 :         if (!IsTextSelection())
    1030           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1031             : 
    1032          14 :         for( sal_uInt16 i = 0; i < nCount; i++ )
    1033          11 :             bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
    1034             :     }
    1035             :     else
    1036           0 :         throw uno::RuntimeException();
    1037           3 :     return bRet;
    1038             : 
    1039             : }
    1040             : 
    1041           1 : void SwXTextViewCursor::gotoRange(
    1042             :     const uno::Reference< text::XTextRange > & xRange,
    1043             :     sal_Bool bExpand)
    1044             :         throw(RuntimeException)
    1045             : {
    1046           1 :     SolarMutexGuard aGuard;
    1047           1 :     if(m_pView && xRange.is())
    1048             :     {
    1049           1 :         if (!IsTextSelection())
    1050           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1051             : 
    1052           1 :         SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc());
    1053           1 :         if (!::sw::XTextRangeToSwPaM(rDestPam, xRange))
    1054             :         {
    1055           0 :             throw uno::RuntimeException();
    1056             :         }
    1057             : 
    1058           1 :         ShellModes  eSelMode = m_pView->GetShellMode();
    1059           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1060             :         // call EnterStdMode in non-text selections only
    1061           1 :         if(!bExpand ||
    1062           0 :            (eSelMode != SHELL_MODE_TABLE_TEXT &&
    1063           0 :             eSelMode != SHELL_MODE_LIST_TEXT &&
    1064           0 :             eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
    1065             :             eSelMode != SHELL_MODE_TEXT ))
    1066           1 :                 rSh.EnterStdMode();
    1067           1 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1068           2 :         SwPaM aOwnPaM(*pShellCrsr->GetPoint());
    1069           1 :         if(pShellCrsr->HasMark())
    1070             :         {
    1071           0 :             aOwnPaM.SetMark();
    1072           0 :             *aOwnPaM.GetMark() = *pShellCrsr->GetMark();
    1073             :         }
    1074             : 
    1075           2 :         uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
    1076           1 :         SwXTextRange* pRange = 0;
    1077           1 :         SwXParagraph* pPara = 0;
    1078           1 :         OTextCursorHelper* pCursor = 0;
    1079           1 :         if(xRangeTunnel.is())
    1080             :         {
    1081           1 :             pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
    1082           1 :                                     SwXTextRange::getUnoTunnelId()));
    1083           1 :             pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
    1084           1 :                                     OTextCursorHelper::getUnoTunnelId()));
    1085           1 :             pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething(
    1086           1 :                                     SwXParagraph::getUnoTunnelId()));
    1087             :         }
    1088             : 
    1089           1 :         const sal_uInt16 nFrmType = rSh.GetFrmType(0,sal_True);
    1090             : 
    1091           1 :         SwStartNodeType eSearchNodeType = SwNormalStartNode;
    1092           1 :         if(nFrmType & FRMTYPE_FLY_ANY)
    1093           0 :             eSearchNodeType = SwFlyStartNode;
    1094           1 :         else if(nFrmType &FRMTYPE_HEADER)
    1095           0 :             eSearchNodeType = SwHeaderStartNode;
    1096           1 :         else if(nFrmType & FRMTYPE_FOOTER)
    1097           0 :             eSearchNodeType = SwFooterStartNode;
    1098           1 :         else if(nFrmType & FRMTYPE_TABLE)
    1099           0 :             eSearchNodeType = SwTableBoxStartNode;
    1100           1 :         else if(nFrmType & FRMTYPE_FOOTNOTE)
    1101           0 :             eSearchNodeType = SwFootnoteStartNode;
    1102             : 
    1103             :         const SwStartNode* pOwnStartNode = aOwnPaM.GetNode()->
    1104           1 :                                                 FindSttNodeByType(eSearchNodeType);
    1105             : 
    1106           1 :         const SwNode* pSrcNode = 0;
    1107           1 :         if(pCursor && pCursor->GetPaM())
    1108             :         {
    1109           0 :             pSrcNode = pCursor->GetPaM()->GetNode();
    1110             :         }
    1111           1 :         else if (pRange)
    1112             :         {
    1113           1 :             SwPaM aPam(pRange->GetDoc()->GetNodes());
    1114           1 :             if (pRange->GetPositions(aPam))
    1115             :             {
    1116           1 :                 pSrcNode = aPam.GetNode();
    1117           1 :             }
    1118             :         }
    1119           0 :         else if (pPara && pPara->GetTxtNode())
    1120             :         {
    1121           0 :             pSrcNode = pPara->GetTxtNode();
    1122             :         }
    1123           1 :         const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0;
    1124             : 
    1125             :         //Skip SectionNodes
    1126           2 :         while(pTmp && pTmp->IsSectionNode())
    1127             :         {
    1128           0 :             pTmp = pTmp->StartOfSectionNode();
    1129             :         }
    1130           2 :         while(pOwnStartNode && pOwnStartNode->IsSectionNode())
    1131             :         {
    1132           0 :             pOwnStartNode = pOwnStartNode->StartOfSectionNode();
    1133             :         }
    1134             :         //Without Expand it is allowed to jump out with the ViewCursor everywhere,
    1135             :         //with Expand only in the same environment
    1136           1 :         if(bExpand &&
    1137           0 :             (pOwnStartNode != pTmp ||
    1138           0 :             (eSelMode != SHELL_MODE_TABLE_TEXT &&
    1139           0 :                 eSelMode != SHELL_MODE_LIST_TEXT &&
    1140           0 :                 eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
    1141             :                 eSelMode != SHELL_MODE_TEXT)))
    1142           0 :             throw uno::RuntimeException();
    1143             : 
    1144             :         //Now, the selection must be expanded.
    1145           1 :         if(bExpand)
    1146             :         {
    1147             :             // The cursor should include everything that has been included
    1148             :             // by him and the transfered Range.
    1149           0 :             SwPosition aOwnLeft(*aOwnPaM.Start());
    1150           0 :             SwPosition aOwnRight(*aOwnPaM.End());
    1151           0 :             SwPosition* pParamLeft = rDestPam.Start();
    1152           0 :             SwPosition* pParamRight = rDestPam.End();
    1153             :             // Now four SwPositions are there, two of them are needed, but which?
    1154           0 :             if(aOwnRight > *pParamRight)
    1155           0 :                 *aOwnPaM.GetPoint() = aOwnRight;
    1156             :             else
    1157           0 :                 *aOwnPaM.GetPoint() = *pParamRight;
    1158           0 :             aOwnPaM.SetMark();
    1159           0 :             if(aOwnLeft < *pParamLeft)
    1160           0 :                 *aOwnPaM.GetMark() = aOwnLeft;
    1161             :             else
    1162           0 :                 *aOwnPaM.GetMark() = *pParamLeft;
    1163             :         }
    1164             :         else
    1165             :         {
    1166             :             //The cursor shall match the passed range.
    1167           1 :             *aOwnPaM.GetPoint() = *rDestPam.GetPoint();
    1168           1 :             if(rDestPam.HasMark())
    1169             :             {
    1170           0 :                 aOwnPaM.SetMark();
    1171           0 :                 *aOwnPaM.GetMark() = *rDestPam.GetMark();
    1172             :             }
    1173             :             else
    1174           1 :                 aOwnPaM.DeleteMark();
    1175             :         }
    1176           2 :         rSh.SetSelection(aOwnPaM);
    1177             :     }
    1178             :     else
    1179           0 :         throw uno::RuntimeException();
    1180             : 
    1181           1 : }
    1182             : 
    1183           8 : void SwXTextViewCursor::gotoStart(sal_Bool bExpand) throw( uno::RuntimeException )
    1184             : {
    1185           8 :     SolarMutexGuard aGuard;
    1186           8 :     if(m_pView)
    1187             :     {
    1188           8 :         if (!IsTextSelection())
    1189           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1190             : 
    1191           8 :         m_pView->GetWrtShell().SttDoc( bExpand );
    1192             :     }
    1193             :     else
    1194           0 :         throw uno::RuntimeException();
    1195           8 : }
    1196             : 
    1197           8 : void SwXTextViewCursor::gotoEnd(sal_Bool bExpand) throw( uno::RuntimeException )
    1198             : {
    1199           8 :     SolarMutexGuard aGuard;
    1200           8 :     if(m_pView)
    1201             :     {
    1202           8 :         if (!IsTextSelection())
    1203           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1204             : 
    1205           8 :         m_pView->GetWrtShell().EndDoc( bExpand );
    1206             :     }
    1207             :     else
    1208           0 :         throw uno::RuntimeException();
    1209           8 : }
    1210             : 
    1211           2 : sal_Bool SwXTextViewCursor::jumpToFirstPage(void) throw( uno::RuntimeException )
    1212             : {
    1213           2 :     SolarMutexGuard aGuard;
    1214           2 :     sal_Bool bRet = sal_False;
    1215           2 :     if(m_pView)
    1216             :     {
    1217           2 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1218           2 :         if (rSh.IsSelFrmMode())
    1219             :         {
    1220           0 :             rSh.UnSelectFrm();
    1221           0 :             rSh.LeaveSelFrmMode();
    1222             :         }
    1223           2 :         rSh.EnterStdMode();
    1224           2 :         bRet = rSh.SttEndDoc(sal_True);
    1225             :     }
    1226             :     else
    1227           0 :         throw uno::RuntimeException();
    1228           2 :     return bRet;
    1229             : }
    1230             : 
    1231          14 : sal_Bool SwXTextViewCursor::jumpToLastPage(void) throw( uno::RuntimeException )
    1232             : {
    1233          14 :     SolarMutexGuard aGuard;
    1234          14 :     sal_Bool bRet = sal_False;
    1235          14 :     if(m_pView)
    1236             :     {
    1237          14 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1238          14 :         if (rSh.IsSelFrmMode())
    1239             :         {
    1240           0 :             rSh.UnSelectFrm();
    1241           0 :             rSh.LeaveSelFrmMode();
    1242             :         }
    1243          14 :         rSh.EnterStdMode();
    1244          14 :         bRet = rSh.SttEndDoc(sal_False);
    1245          14 :         rSh.SttPg();
    1246             :     }
    1247             :     else
    1248           0 :         throw uno::RuntimeException();
    1249          14 :     return bRet;
    1250             : }
    1251             : 
    1252           1 : sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage) throw( uno::RuntimeException )
    1253             : {
    1254           1 :     SolarMutexGuard aGuard;
    1255           1 :     sal_Bool bRet = sal_False;
    1256           1 :     if(m_pView)
    1257           1 :         bRet = m_pView->GetWrtShell().GotoPage(nPage, sal_True);
    1258             :     else
    1259           0 :         throw uno::RuntimeException();
    1260           1 :     return bRet;
    1261             : }
    1262             : 
    1263           1 : sal_Bool SwXTextViewCursor::jumpToNextPage(void) throw( uno::RuntimeException )
    1264             : {
    1265           1 :     SolarMutexGuard aGuard;
    1266           1 :     sal_Bool bRet = sal_False;
    1267           1 :     if(m_pView)
    1268           1 :         bRet = m_pView->GetWrtShell().SttNxtPg();
    1269             :     else
    1270           0 :         throw uno::RuntimeException();
    1271           1 :     return bRet;
    1272             : }
    1273             : 
    1274           1 : sal_Bool SwXTextViewCursor::jumpToPreviousPage(void) throw( uno::RuntimeException )
    1275             : {
    1276           1 :     SolarMutexGuard aGuard;
    1277           1 :     sal_Bool bRet = sal_False;
    1278           1 :     if(m_pView)
    1279           1 :         bRet = m_pView->GetWrtShell().EndPrvPg();
    1280             :     else
    1281           0 :         throw uno::RuntimeException();
    1282           1 :     return bRet;
    1283             : }
    1284             : 
    1285           1 : sal_Bool SwXTextViewCursor::jumpToEndOfPage(void) throw( uno::RuntimeException )
    1286             : {
    1287           1 :     SolarMutexGuard aGuard;
    1288           1 :     sal_Bool bRet = sal_False;
    1289           1 :     if(m_pView)
    1290           1 :         bRet = m_pView->GetWrtShell().EndPg();
    1291             :     else
    1292           0 :         throw uno::RuntimeException();
    1293           1 :     return bRet;
    1294             : }
    1295             : 
    1296           1 : sal_Bool SwXTextViewCursor::jumpToStartOfPage(void) throw( uno::RuntimeException )
    1297             : {
    1298           1 :     SolarMutexGuard aGuard;
    1299           1 :     sal_Bool bRet = sal_False;
    1300           1 :     if(m_pView)
    1301           1 :         bRet = m_pView->GetWrtShell().SttPg();
    1302             :     else
    1303           0 :         throw uno::RuntimeException();
    1304           1 :     return bRet;
    1305             : }
    1306             : 
    1307          13 : sal_Int16 SwXTextViewCursor::getPage(void) throw( uno::RuntimeException )
    1308             : {
    1309          13 :     SolarMutexGuard aGuard;
    1310          13 :     sal_Int16 nRet = 0;
    1311          13 :     if(m_pView)
    1312             :     {
    1313          13 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1314          13 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1315          13 :         nRet = static_cast<sal_Int16>(pShellCrsr->GetPageNum( true, 0 ));
    1316             :     }
    1317             :     else
    1318           0 :         throw uno::RuntimeException();
    1319          13 :     return nRet;
    1320             : }
    1321             : 
    1322           0 : sal_Bool SwXTextViewCursor::screenDown(void) throw( uno::RuntimeException )
    1323             : {
    1324           0 :     SolarMutexGuard aGuard;
    1325           0 :     sal_Bool bRet = sal_False;
    1326           0 :     if(m_pView)
    1327             :     {
    1328           0 :         SfxRequest aReq(FN_PAGEDOWN, SFX_CALLMODE_SLOT, m_pView->GetPool());
    1329           0 :         m_pView->Execute(aReq);
    1330           0 :         const SfxPoolItem* pRet = aReq.GetReturnValue();
    1331           0 :         bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
    1332             :     }
    1333             :     else
    1334           0 :         throw uno::RuntimeException();
    1335           0 :     return bRet;
    1336             : }
    1337             : 
    1338           0 : sal_Bool SwXTextViewCursor::screenUp(void) throw( uno::RuntimeException )
    1339             : {
    1340           0 :     SolarMutexGuard aGuard;
    1341           0 :     sal_Bool bRet = sal_False;
    1342           0 :     if(m_pView)
    1343             :     {
    1344           0 :         SfxRequest aReq(FN_PAGEUP, SFX_CALLMODE_SLOT, m_pView->GetPool());
    1345           0 :         m_pView->Execute(aReq);
    1346           0 :         const SfxPoolItem* pRet = aReq.GetReturnValue();
    1347           0 :         bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
    1348             :     }
    1349             :     else
    1350           0 :         throw uno::RuntimeException();
    1351           0 :     return bRet;
    1352             : }
    1353             : 
    1354           1 : uno::Reference< text::XText >  SwXTextViewCursor::getText(void) throw( uno::RuntimeException )
    1355             : {
    1356           1 :     SolarMutexGuard aGuard;
    1357           1 :     uno::Reference< text::XText >  xRet;
    1358           1 :     if(m_pView)
    1359             :     {
    1360           1 :         if (!IsTextSelection( sal_False ))
    1361           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1362             : 
    1363           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1364           1 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1365           1 :         SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
    1366           1 :         xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start());
    1367             :     }
    1368             :     else
    1369           0 :         throw uno::RuntimeException();
    1370           1 :     return xRet;
    1371             : }
    1372             : 
    1373           2 : uno::Reference< text::XTextRange >  SwXTextViewCursor::getStart(void) throw( uno::RuntimeException )
    1374             : {
    1375           2 :     SolarMutexGuard aGuard;
    1376           2 :     uno::Reference< text::XTextRange >  xRet;
    1377           2 :     if(m_pView)
    1378             :     {
    1379           2 :         if (!IsTextSelection())
    1380           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1381             : 
    1382           2 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1383           2 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1384           2 :         SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
    1385           2 :         xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0);
    1386             :     }
    1387             :     else
    1388           0 :         throw uno::RuntimeException();
    1389           2 :     return xRet;
    1390             : }
    1391             : 
    1392           1 : uno::Reference< text::XTextRange >  SwXTextViewCursor::getEnd(void) throw( uno::RuntimeException )
    1393             : {
    1394           1 :     SolarMutexGuard aGuard;
    1395           1 :     uno::Reference< text::XTextRange >  xRet;
    1396           1 :     if(m_pView)
    1397             :     {
    1398           1 :         if (!IsTextSelection())
    1399           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1400             : 
    1401           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1402           1 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1403           1 :         SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
    1404           1 :         xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0);
    1405             :     }
    1406             :     else
    1407           0 :         throw uno::RuntimeException();
    1408           1 :     return xRet;
    1409             : }
    1410             : 
    1411           8 : OUString SwXTextViewCursor::getString(void) throw( uno::RuntimeException )
    1412             : {
    1413           8 :     SolarMutexGuard aGuard;
    1414           8 :     OUString uRet;
    1415           8 :     if(m_pView)
    1416             :     {
    1417           8 :         if (!IsTextSelection( sal_False ))
    1418           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1419             : 
    1420           8 :         ShellModes  eSelMode = m_pView->GetShellMode();
    1421           8 :         switch(eSelMode)
    1422             :         {
    1423             :             //! since setString for SEL_TABLE_TEXT (with possible
    1424             :             //! multi selection of cells) would not work properly we
    1425             :             //! will ignore this case for both
    1426             :             //! functions (setString AND getString) because of symmetrie.
    1427             : 
    1428             :             case SHELL_MODE_LIST_TEXT       :
    1429             :             case SHELL_MODE_TABLE_LIST_TEXT:
    1430             :             case SHELL_MODE_TEXT            :
    1431             :             {
    1432           8 :                 SwWrtShell& rSh = m_pView->GetWrtShell();
    1433           8 :                 SwPaM* pShellCrsr = rSh.GetCrsr();
    1434           8 :                 SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet);
    1435             :             }
    1436             :             default:;//prevent warning
    1437             :         }
    1438             :     }
    1439           8 :     return uRet;
    1440             : }
    1441             : 
    1442           8 : void SwXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeException )
    1443             : {
    1444           8 :     SolarMutexGuard aGuard;
    1445           8 :     if(m_pView)
    1446             :     {
    1447           8 :         if (!IsTextSelection( sal_False ))
    1448           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1449             : 
    1450           8 :         ShellModes  eSelMode = m_pView->GetShellMode();
    1451           8 :         switch(eSelMode)
    1452             :         {
    1453             :             //! since setString for SEL_TABLE_TEXT (with possible
    1454             :             //! multi selection of cells) would not work properly we
    1455             :             //! will ignore this case for both
    1456             :             //! functions (setString AND getString) because of symmetrie.
    1457             : 
    1458             :             case SHELL_MODE_LIST_TEXT       :
    1459             :             case SHELL_MODE_TABLE_LIST_TEXT :
    1460             :             case SHELL_MODE_TEXT            :
    1461             :             {
    1462           8 :                 SwWrtShell& rSh = m_pView->GetWrtShell();
    1463           8 :                 SwCursor* pShellCrsr = rSh.GetSwCrsr();
    1464           8 :                 SwUnoCursorHelper::SetString(*pShellCrsr, aString);
    1465             :             }
    1466             :             default:;//prevent warning
    1467             :         }
    1468           8 :     }
    1469           8 : }
    1470             : 
    1471         146 : uno::Reference< XPropertySetInfo >  SwXTextViewCursor::getPropertySetInfo(  ) throw(RuntimeException)
    1472             : {
    1473         146 :     static uno::Reference< XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
    1474         146 :     return xRef;
    1475             : }
    1476             : 
    1477          73 : void  SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const Any& aValue )
    1478             :                             throw(UnknownPropertyException, PropertyVetoException,
    1479             :                                 IllegalArgumentException, WrappedTargetException, RuntimeException)
    1480             : {
    1481          73 :     SolarMutexGuard aGuard;
    1482          73 :     if(m_pView)
    1483             :     {
    1484          73 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1485          73 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1486          73 :         SwNode *pNode = pShellCrsr->GetNode();
    1487          73 :         if (pNode && pNode->IsTxtNode())
    1488             :         {
    1489             :             SwUnoCursorHelper::SetPropertyValue(
    1490          73 :                 *pShellCrsr, *m_pPropSet, rPropertyName, aValue );
    1491             :         }
    1492             :         else
    1493           0 :             throw RuntimeException();
    1494             :     }
    1495             :     else
    1496           0 :         throw RuntimeException();
    1497          73 : }
    1498             : 
    1499         148 : Any  SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName )
    1500             :                 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1501             : {
    1502         148 :     SolarMutexGuard aGuard;
    1503         148 :     Any aRet;
    1504         148 :     if(m_pView)
    1505             :     {
    1506         148 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1507         148 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1508         296 :         aRet = SwUnoCursorHelper::GetPropertyValue(
    1509         148 :                 *pShellCrsr, *m_pPropSet, rPropertyName);
    1510             :     }
    1511             :     else
    1512           0 :         throw RuntimeException();
    1513         148 :     return aRet;
    1514             : }
    1515             : 
    1516           0 : void  SwXTextViewCursor::addPropertyChangeListener(
    1517             :     const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
    1518             :         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1519             : {
    1520           0 : }
    1521             : 
    1522           0 : void  SwXTextViewCursor::removePropertyChangeListener(
    1523             :     const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*aListener*/ )
    1524             :         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1525             : {
    1526           0 : }
    1527             : 
    1528           0 : void  SwXTextViewCursor::addVetoableChangeListener(
    1529             :     const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ )
    1530             :         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1531             : {
    1532           0 : }
    1533             : 
    1534           0 : void  SwXTextViewCursor::removeVetoableChangeListener(
    1535             :     const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1536             : {
    1537           0 : }
    1538             : 
    1539           1 : PropertyState  SwXTextViewCursor::getPropertyState( const OUString& rPropertyName )
    1540             :     throw(UnknownPropertyException, RuntimeException)
    1541             : {
    1542           1 :     SolarMutexGuard aGuard;
    1543             :     PropertyState eState;
    1544           1 :     if(m_pView)
    1545             :     {
    1546           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1547           1 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1548             :         eState = SwUnoCursorHelper::GetPropertyState(
    1549           1 :                 *pShellCrsr, *m_pPropSet, rPropertyName);
    1550             :     }
    1551             :     else
    1552           0 :         throw RuntimeException();
    1553           1 :     return eState;
    1554             : }
    1555             : 
    1556           1 : Sequence< PropertyState >  SwXTextViewCursor::getPropertyStates(
    1557             :     const Sequence< OUString >& rPropertyNames ) throw(UnknownPropertyException, RuntimeException)
    1558             : {
    1559           1 :     SolarMutexGuard aGuard;
    1560           1 :     Sequence< PropertyState >  aRet;
    1561           1 :     if(m_pView)
    1562             :     {
    1563           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1564           1 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1565           2 :         aRet = SwUnoCursorHelper::GetPropertyStates(
    1566           1 :                 *pShellCrsr, *m_pPropSet,  rPropertyNames);
    1567             :     }
    1568           1 :     return aRet;
    1569             : }
    1570             : 
    1571           1 : void  SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName )
    1572             :                                         throw(UnknownPropertyException, RuntimeException)
    1573             : {
    1574           1 :     SolarMutexGuard aGuard;
    1575           1 :     if(m_pView)
    1576             :     {
    1577           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1578           1 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1579             :         SwUnoCursorHelper::SetPropertyToDefault(
    1580           1 :                 *pShellCrsr, *m_pPropSet, rPropertyName);
    1581           1 :     }
    1582           1 : }
    1583             : 
    1584           1 : Any  SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName )
    1585             :                         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1586             : {
    1587           1 :     Any aRet;
    1588           2 :     SolarMutexGuard aGuard;
    1589           1 :     if(m_pView)
    1590             :     {
    1591           1 :         SwWrtShell& rSh = m_pView->GetWrtShell();
    1592           1 :         SwPaM* pShellCrsr = rSh.GetCrsr();
    1593           2 :         aRet = SwUnoCursorHelper::GetPropertyDefault(
    1594           1 :                 *pShellCrsr, *m_pPropSet, rPropertyName);
    1595             :     }
    1596           2 :     return aRet;
    1597             : }
    1598             : 
    1599           0 : sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
    1600             : {
    1601           0 :     SolarMutexGuard aGuard;
    1602           0 :     sal_Bool bRet = sal_False;
    1603           0 :     if(m_pView)
    1604             :     {
    1605           0 :         if (!IsTextSelection())
    1606           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1607             : 
    1608           0 :         for( sal_uInt16 i = 0; i < nCount; i++ )
    1609           0 :             bRet = m_pView->GetWrtShell().Down( bExpand, 1, sal_True );
    1610             :     }
    1611             :     else
    1612           0 :         throw uno::RuntimeException();
    1613           0 :     return bRet;
    1614             : }
    1615             : 
    1616           0 : sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
    1617             : {
    1618           0 :     SolarMutexGuard aGuard;
    1619           0 :     sal_Bool bRet = sal_False;
    1620           0 :     if(m_pView)
    1621             :     {
    1622           0 :         if (!IsTextSelection())
    1623           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1624             : 
    1625           0 :         for( sal_uInt16 i = 0; i < nCount; i++ )
    1626           0 :             bRet = m_pView->GetWrtShell().Up( bExpand, 1, sal_True );
    1627             :     }
    1628             :     else
    1629           0 :         throw uno::RuntimeException();
    1630           0 :     return bRet;
    1631             : }
    1632             : 
    1633           0 : sal_Bool SwXTextViewCursor::isAtStartOfLine(void) throw( uno::RuntimeException )
    1634             : {
    1635           0 :     SolarMutexGuard aGuard;
    1636           0 :     sal_Bool bRet = sal_False;
    1637           0 :     if(m_pView)
    1638             :     {
    1639           0 :         if (!IsTextSelection( sal_False ))
    1640           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1641             : 
    1642           0 :         bRet = m_pView->GetWrtShell().IsAtLeftMargin();
    1643             :     }
    1644             :     else
    1645           0 :         throw uno::RuntimeException();
    1646           0 :     return bRet;
    1647             : }
    1648             : 
    1649           0 : sal_Bool SwXTextViewCursor::isAtEndOfLine(void) throw( uno::RuntimeException )
    1650             : {
    1651           0 :     SolarMutexGuard aGuard;
    1652           0 :     sal_Bool bRet = sal_False;
    1653           0 :     if(m_pView)
    1654             :     {
    1655           0 :         if (!IsTextSelection( sal_False ))
    1656           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1657             : 
    1658           0 :         bRet = m_pView->GetWrtShell().IsAtRightMargin(sal_True);
    1659             :     }
    1660             :     else
    1661           0 :         throw uno::RuntimeException();
    1662           0 :     return bRet;
    1663             : }
    1664             : 
    1665           0 : void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand) throw( uno::RuntimeException )
    1666             : {
    1667           0 :     SolarMutexGuard aGuard;
    1668           0 :     if(m_pView)
    1669             :     {
    1670           0 :         if (!IsTextSelection( sal_False ))
    1671           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1672             : 
    1673           0 :         m_pView->GetWrtShell().RightMargin(bExpand, sal_True);
    1674             :     }
    1675             :     else
    1676           0 :         throw uno::RuntimeException();
    1677           0 : }
    1678             : 
    1679           0 : void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand) throw( uno::RuntimeException )
    1680             : {
    1681           0 :     SolarMutexGuard aGuard;
    1682           0 :     if(m_pView)
    1683             :     {
    1684           0 :         if (!IsTextSelection( sal_False ))
    1685           0 :             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
    1686             : 
    1687           0 :         m_pView->GetWrtShell().LeftMargin(bExpand, sal_True);
    1688             :     }
    1689             :     else
    1690           0 :         throw uno::RuntimeException();
    1691           0 : }
    1692             : 
    1693           0 : OUString SwXTextViewCursor::getImplementationName(void) throw( RuntimeException )
    1694             : {
    1695           0 :     return OUString("SwXTextViewCursor");
    1696             : }
    1697             : 
    1698           5 : sal_Bool SwXTextViewCursor::supportsService(const OUString& rServiceName) throw( RuntimeException )
    1699             : {
    1700          10 :     return !rServiceName.compareToAscii("com.sun.star.text.TextViewCursor") ||
    1701           9 :             !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties") ||
    1702           7 :             !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian") ||
    1703           5 :             !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex") ||
    1704           4 :             !rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") ||
    1705           8 :             !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") ||
    1706           6 :             !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex");
    1707             : }
    1708             : 
    1709           0 : Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames(void) throw( RuntimeException )
    1710             : {
    1711           0 :     Sequence< OUString > aRet(7);
    1712           0 :     OUString* pArray = aRet.getArray();
    1713           0 :     pArray[0] = "com.sun.star.text.TextViewCursor";
    1714           0 :     pArray[1] = "com.sun.star.style.CharacterProperties";
    1715           0 :     pArray[2] = "com.sun.star.style.CharacterPropertiesAsian";
    1716           0 :     pArray[3] = "com.sun.star.style.CharacterPropertiesComplex";
    1717           0 :     pArray[4] = "com.sun.star.style.ParagraphProperties";
    1718           0 :     pArray[5] = "com.sun.star.style.ParagraphPropertiesAsian";
    1719           0 :     pArray[6] = "com.sun.star.style.ParagraphPropertiesComplex";
    1720           0 :     return aRet;
    1721             : }
    1722             : 
    1723             : namespace
    1724             : {
    1725             :     class theSwXTextViewCursorUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextViewCursorUnoTunnelId > {};
    1726             : }
    1727             : 
    1728           0 : const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId()
    1729             : {
    1730           0 :     return theSwXTextViewCursorUnoTunnelId::get().getSeq();
    1731             : }
    1732             : 
    1733             : //XUnoTunnel
    1734           0 : sal_Int64 SAL_CALL SwXTextViewCursor::getSomething(
    1735             :     const uno::Sequence< sal_Int8 >& rId )
    1736             :         throw(uno::RuntimeException)
    1737             : {
    1738           0 :     if( rId.getLength() == 16
    1739           0 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
    1740           0 :                                         rId.getConstArray(), 16 ) )
    1741             :         {
    1742           0 :                 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
    1743             :         }
    1744           0 :     return OTextCursorHelper::getSomething(rId);
    1745             : }
    1746             : 
    1747         261 : IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper)
    1748           0 : const SwDoc*        SwXTextViewCursor::GetDoc() const
    1749             : {
    1750           0 :     SwWrtShell& rSh = m_pView->GetWrtShell();
    1751           0 :     return   rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
    1752             : }
    1753             : 
    1754           0 : SwDoc*  SwXTextViewCursor::GetDoc()
    1755             : {
    1756           0 :     SwWrtShell& rSh = m_pView->GetWrtShell();
    1757           0 :     return   rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
    1758             : }
    1759             : 
    1760           0 : const SwPaM*    SwXTextViewCursor::GetPaM() const
    1761             : {
    1762           0 :     SwWrtShell& rSh = m_pView->GetWrtShell();
    1763           0 :     return rSh.GetCrsr();
    1764             : }
    1765             : 
    1766           0 : SwPaM*  SwXTextViewCursor::GetPaM()
    1767             : {
    1768           0 :     SwWrtShell& rSh = m_pView->GetWrtShell();
    1769           0 :     return rSh.GetCrsr();
    1770             : }
    1771             : 
    1772           0 : uno::Reference< datatransfer::XTransferable > SAL_CALL SwXTextView::getTransferable(  ) throw (uno::RuntimeException)
    1773             : {
    1774           0 :     SolarMutexGuard aGuard;
    1775             : 
    1776             :     //force immediat shell update
    1777           0 :     GetView()->StopShellTimer();
    1778           0 :     SwWrtShell& rSh = GetView()->GetWrtShell();
    1779           0 :     if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
    1780             :     {
    1781           0 :         SdrView *pSdrView = rSh.GetDrawView();
    1782           0 :         OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
    1783           0 :         return pOLV->GetEditView().GetTransferable();
    1784             :     }
    1785             :     else
    1786             :     {
    1787           0 :         SwTransferable* pTransfer = new SwTransferable( rSh );
    1788           0 :         const sal_Bool bLockedView = rSh.IsViewLocked();
    1789           0 :         rSh.LockView( sal_True );    //lock visible section
    1790           0 :         pTransfer->PrepareForCopy();
    1791           0 :         rSh.LockView( bLockedView );
    1792           0 :         return uno::Reference< datatransfer::XTransferable >( pTransfer );
    1793           0 :     }
    1794             : }
    1795             : 
    1796           0 : void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfer::XTransferable >& xTrans ) throw (datatransfer::UnsupportedFlavorException, uno::RuntimeException)
    1797             : {
    1798           0 :     SolarMutexGuard aGuard;
    1799             : 
    1800             :     //force immediat shell update
    1801           0 :     GetView()->StopShellTimer();
    1802           0 :     SwWrtShell& rSh = GetView()->GetWrtShell();
    1803           0 :     if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
    1804             :     {
    1805           0 :         SdrView *pSdrView = rSh.GetDrawView();
    1806           0 :         OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
    1807           0 :         pOLV->GetEditView().InsertText( xTrans, GetView()->GetDocShell()->GetMedium()->GetBaseURL(), sal_False );
    1808             :     }
    1809             :     else
    1810             :     {
    1811           0 :         TransferableDataHelper aDataHelper( xTrans );
    1812           0 :         if ( SwTransferable::IsPaste( rSh, aDataHelper ) )
    1813             :         {
    1814           0 :             SwTransferable::Paste( rSh, aDataHelper );
    1815           0 :             if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
    1816           0 :                 rSh.EnterSelFrmMode();
    1817           0 :             GetView()->AttrChangedNotify( &rSh );
    1818           0 :         }
    1819           0 :     }
    1820          99 : }
    1821             : 
    1822             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10