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

Generated by: LCOV version 1.10