LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/crsr - viscrs.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 114 319 35.7 %
Date: 2012-12-27 Functions: 18 48 37.5 %
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 <vcl/dialog.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <vcl/wrkwin.hxx>
      23             : #include <viewopt.hxx>
      24             : #include <frmtool.hxx>
      25             : #include <viscrs.hxx>
      26             : #include <crsrsh.hxx>
      27             : #include <doc.hxx>
      28             : #include <swtable.hxx>
      29             : #include <viewimp.hxx>
      30             : #include <dview.hxx>
      31             : #include <rootfrm.hxx>
      32             : #include <txtfrm.hxx>
      33             : #include <docary.hxx>
      34             : #include <extinput.hxx>
      35             : #include <ndtxt.hxx>
      36             : #include <scriptinfo.hxx>
      37             : #include <mdiexp.hxx>
      38             : #include <comcore.hrc>
      39             : 
      40             : #include <svx/sdr/overlay/overlaymanager.hxx>
      41             : #include <svx/sdrpaintwindow.hxx>
      42             : #include <vcl/svapp.hxx>
      43             : #include <svx/sdr/overlay/overlayselection.hxx>
      44             : 
      45             : extern void SwCalcPixStatics( OutputDevice *pOut );
      46             : 
      47             : // Here static members are defined. They will get changed on alteration of the
      48             : // MapMode. This is done so that on ShowCrsr the same size does not have to be
      49             : // expensively determined again and again.
      50             : 
      51             : long SwSelPaintRects::nPixPtX = 0;
      52             : long SwSelPaintRects::nPixPtY = 0;
      53             : MapMode* SwSelPaintRects::pMapMode = 0;
      54             : 
      55             : // -----  Starting from here: classes / methods for the non-text-cursor -----
      56             : 
      57         236 : SwVisCrsr::SwVisCrsr( const SwCrsrShell * pCShell )
      58         236 :     : pCrsrShell( pCShell )
      59             : {
      60         236 :     pCShell->GetWin()->SetCursor( &aTxtCrsr );
      61         236 :     bIsVisible = aTxtCrsr.IsVisible();
      62         236 :     bIsDragCrsr = false;
      63         236 :     aTxtCrsr.SetWidth( 0 );
      64         236 : }
      65             : 
      66             : 
      67             : 
      68         126 : SwVisCrsr::~SwVisCrsr()
      69             : {
      70          63 :     if( bIsVisible && aTxtCrsr.IsVisible() )
      71           0 :         aTxtCrsr.Hide();
      72             : 
      73          63 :     pCrsrShell->GetWin()->SetCursor( 0 );
      74          63 : }
      75             : 
      76             : 
      77             : 
      78             : 
      79        3303 : void SwVisCrsr::Show()
      80             : {
      81        3303 :     if( !bIsVisible )
      82             :     {
      83        1838 :         bIsVisible = true;
      84             : 
      85             :         // display at all?
      86        1838 :         if( pCrsrShell->VisArea().IsOver( pCrsrShell->aCharRect ) )
      87        1587 :             _SetPosAndShow();
      88             :     }
      89        3303 : }
      90             : 
      91             : 
      92             : 
      93        2166 : void SwVisCrsr::Hide()
      94             : {
      95        2166 :     if( bIsVisible )
      96             :     {
      97        1834 :         bIsVisible = false;
      98             : 
      99        1834 :         if( aTxtCrsr.IsVisible() )      // Shouldn't the flags be in effect?
     100        1581 :             aTxtCrsr.Hide();
     101             :     }
     102        2166 : }
     103             : 
     104        1587 : void SwVisCrsr::_SetPosAndShow()
     105             : {
     106        1587 :     SwRect aRect;
     107        1587 :     long nTmpY = pCrsrShell->aCrsrHeight.Y();
     108        1587 :     if( 0 > nTmpY )
     109             :     {
     110           0 :         nTmpY = -nTmpY;
     111           0 :         aTxtCrsr.SetOrientation( 900 );
     112           0 :         aRect = SwRect( pCrsrShell->aCharRect.Pos(),
     113           0 :            Size( pCrsrShell->aCharRect.Height(), nTmpY ) );
     114           0 :         aRect.Pos().X() += pCrsrShell->aCrsrHeight.X();
     115           0 :         if( pCrsrShell->IsOverwriteCrsr() )
     116           0 :             aRect.Pos().Y() += aRect.Width();
     117             :     }
     118             :     else
     119             :     {
     120        1587 :         aTxtCrsr.SetOrientation( 0 );
     121        1587 :         aRect = SwRect( pCrsrShell->aCharRect.Pos(),
     122        3174 :            Size( pCrsrShell->aCharRect.Width(), nTmpY ) );
     123        1587 :         aRect.Pos().Y() += pCrsrShell->aCrsrHeight.X();
     124             :     }
     125             : 
     126             :     // check if cursor should show the current cursor bidi level
     127        1587 :     aTxtCrsr.SetDirection( CURSOR_DIRECTION_NONE );
     128        1587 :     const SwCursor* pTmpCrsr = pCrsrShell->_GetCrsr();
     129             : 
     130        1587 :     if ( pTmpCrsr && !pCrsrShell->IsOverwriteCrsr() )
     131             :     {
     132        1587 :         SwNode& rNode = pTmpCrsr->GetPoint()->nNode.GetNode();
     133        1587 :         if( rNode.IsTxtNode() )
     134             :         {
     135        1587 :             const SwTxtNode& rTNd = *rNode.GetTxtNode();
     136        1587 :             const SwFrm* pFrm = rTNd.getLayoutFrm( pCrsrShell->GetLayout(), 0, 0, sal_False );
     137        1587 :             if ( pFrm )
     138             :             {
     139        1587 :                 const SwScriptInfo* pSI = ((SwTxtFrm*)pFrm)->GetScriptInfo();
     140             :                  // cursor level has to be shown
     141        1587 :                 if ( pSI && pSI->CountDirChg() > 1 )
     142             :                 {
     143             :                     aTxtCrsr.SetDirection(
     144           0 :                         ( pTmpCrsr->GetCrsrBidiLevel() % 2 ) ?
     145             :                           CURSOR_DIRECTION_RTL :
     146           0 :                           CURSOR_DIRECTION_LTR );
     147             :                 }
     148             : 
     149        1587 :                 if ( pFrm->IsRightToLeft() )
     150             :                 {
     151           0 :                     const OutputDevice *pOut = pCrsrShell->GetOut();
     152           0 :                     if ( pOut )
     153             :                     {
     154           0 :                         long nSize = pOut->GetSettings().GetStyleSettings().GetCursorSize();
     155           0 :                         Size aSize( nSize, nSize );
     156           0 :                         aSize = pOut->PixelToLogic( aSize );
     157           0 :                         aRect.Left( aRect.Left() - aSize.Width() );
     158             :                     }
     159             :                 }
     160             :             }
     161             :         }
     162             :     }
     163             : 
     164        1587 :     if( aRect.Height() )
     165             :     {
     166        1563 :         ::SwCalcPixStatics( pCrsrShell->GetOut() );
     167        1563 :         ::SwAlignRect( aRect, (ViewShell*)pCrsrShell );
     168             :     }
     169        1587 :     if( !pCrsrShell->IsOverwriteCrsr() || bIsDragCrsr ||
     170           0 :         pCrsrShell->IsSelection() )
     171        1587 :         aRect.Width( 0 );
     172             : 
     173        1587 :     aTxtCrsr.SetSize( aRect.SSize() );
     174             : 
     175        1587 :     aTxtCrsr.SetPos( aRect.Pos() );
     176        1587 :     if ( !pCrsrShell->IsCrsrReadonly()  || pCrsrShell->GetViewOptions()->IsSelectionInReadonly() )
     177             :     {
     178        1587 :         if ( pCrsrShell->GetDrawView() )
     179        1587 :             ((SwDrawView*)pCrsrShell->GetDrawView())->SetAnimationEnabled(
     180        3174 :                     !pCrsrShell->IsSelection() );
     181             : 
     182        1587 :         sal_uInt16 nStyle = bIsDragCrsr ? CURSOR_SHADOW : 0;
     183        1587 :         if( nStyle != aTxtCrsr.GetStyle() )
     184             :         {
     185           0 :             aTxtCrsr.SetStyle( nStyle );
     186           0 :             aTxtCrsr.SetWindow( bIsDragCrsr ? pCrsrShell->GetWin() : 0 );
     187             :         }
     188             : 
     189        1587 :         aTxtCrsr.Show();
     190             :     }
     191        1587 : }
     192             : 
     193             : 
     194         236 : SwSelPaintRects::SwSelPaintRects( const SwCrsrShell& rCSh )
     195             : :   SwRects(),
     196             :     pCShell( &rCSh ),
     197         236 :     mpCursorOverlay(0)
     198             : {
     199         236 : }
     200             : 
     201         126 : SwSelPaintRects::~SwSelPaintRects()
     202             : {
     203          63 :     Hide();
     204          63 : }
     205             : 
     206           0 : void SwSelPaintRects::swapContent(SwSelPaintRects& rSwap)
     207             : {
     208           0 :     SwRects::swap(rSwap);
     209             : 
     210             :     // #i75172# also swap mpCursorOverlay
     211           0 :     sdr::overlay::OverlayObject* pTempOverlay = getCursorOverlay();
     212           0 :     setCursorOverlay(rSwap.getCursorOverlay());
     213           0 :     rSwap.setCursorOverlay(pTempOverlay);
     214           0 : }
     215             : 
     216         319 : void SwSelPaintRects::Hide()
     217             : {
     218         319 :     if(mpCursorOverlay)
     219             :     {
     220           0 :         delete mpCursorOverlay;
     221           0 :         mpCursorOverlay = 0;
     222             :     }
     223             : 
     224         319 :     SwRects::clear();
     225         319 : }
     226             : 
     227        2888 : void SwSelPaintRects::Show()
     228             : {
     229        2888 :     SdrView* pView = (SdrView*)pCShell->GetDrawView();
     230             : 
     231        2888 :     if(pView && pView->PaintWindowCount())
     232             :     {
     233             :         // reset rects
     234        2888 :         SwRects::clear();
     235        2888 :         FillRects();
     236             : 
     237             :         // get new rects
     238        2888 :         std::vector< basegfx::B2DRange > aNewRanges;
     239             : 
     240        2888 :         for(sal_uInt16 a(0); a < size(); a++)
     241             :         {
     242           0 :             const SwRect aNextRect((*this)[a]);
     243           0 :             const Rectangle aPntRect(aNextRect.SVRect());
     244             : 
     245             :             aNewRanges.push_back(basegfx::B2DRange(
     246           0 :                 aPntRect.Left(), aPntRect.Top(),
     247           0 :                 aPntRect.Right() + 1, aPntRect.Bottom() + 1));
     248             :         }
     249             : 
     250        2888 :         if(mpCursorOverlay)
     251             :         {
     252           0 :             if(!aNewRanges.empty())
     253             :             {
     254           0 :                 static_cast< sdr::overlay::OverlaySelection* >(mpCursorOverlay)->setRanges(aNewRanges);
     255             :             }
     256             :             else
     257             :             {
     258           0 :                 delete mpCursorOverlay;
     259           0 :                 mpCursorOverlay = 0;
     260             :             }
     261             :         }
     262        2888 :         else if(!empty())
     263             :         {
     264           0 :             SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
     265           0 :             rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
     266             : 
     267           0 :             if (xTargetOverlay.is())
     268             :             {
     269             :                 // #i97672# get the system's highlight color and limit it to the
     270             :                 // maximum allowed luminance. This is needed to react on too bright
     271             :                 // highlight colors which would otherwise vive a bad visualisation.
     272           0 :                 const OutputDevice *pOut = Application::GetDefaultDevice();
     273           0 :                 Color aHighlight(pOut->GetSettings().GetStyleSettings().GetHighlightColor());
     274           0 :                 const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
     275           0 :                 const basegfx::BColor aSelection(aHighlight.getBColor());
     276           0 :                 const double fLuminance(aSelection.luminance());
     277           0 :                 const double fMaxLum(aSvtOptionsDrawinglayer.GetSelectionMaximumLuminancePercent() / 100.0);
     278             : 
     279           0 :                 if(fLuminance > fMaxLum)
     280             :                 {
     281           0 :                     const double fFactor(fMaxLum / fLuminance);
     282             :                     const basegfx::BColor aNewSelection(
     283           0 :                         aSelection.getRed() * fFactor,
     284           0 :                         aSelection.getGreen() * fFactor,
     285           0 :                         aSelection.getBlue() * fFactor);
     286             : 
     287           0 :                     aHighlight = Color(aNewSelection);
     288             :                 }
     289             : 
     290             :                 // create correct selection
     291             :                 mpCursorOverlay = new sdr::overlay::OverlaySelection(
     292             :                     sdr::overlay::OVERLAY_TRANSPARENT,
     293             :                     aHighlight,
     294             :                     aNewRanges,
     295           0 :                     true);
     296             : 
     297           0 :                 xTargetOverlay->add(*mpCursorOverlay);
     298           0 :             }
     299        2888 :         }
     300             :     }
     301        2888 : }
     302             : 
     303         245 : void SwSelPaintRects::Invalidate( const SwRect& rRect )
     304             : {
     305         245 :     sal_uInt16 nSz = size();
     306         245 :     if( !nSz )
     307         245 :         return;
     308             : 
     309           0 :     SwRegionRects aReg( GetShell()->VisArea() );
     310           0 :     aReg.assign( begin(), end() );
     311           0 :     aReg -= rRect;
     312           0 :     SwRects::erase( begin(), begin() + nSz );
     313           0 :     SwRects::insert( begin(), aReg.begin(), aReg.end() );
     314             : 
     315             :     // If the selection is to the right or at the bottom, outside the
     316             :     // visible area, it is never aligned on one pixel at the right/bottom.
     317             :     // This has to be determined here and if that is the case the
     318             :     // rectangle has to be expanded.
     319           0 :     if( GetShell()->bVisPortChgd && 0 != ( nSz = size()) )
     320             :     {
     321           0 :         SwSelPaintRects::Get1PixelInLogic( *GetShell() );
     322           0 :         iterator it = begin();
     323           0 :         for( ; nSz--; ++it )
     324             :         {
     325           0 :             SwRect& rRectIt = *it;
     326           0 :             if( rRectIt.Right() == GetShell()->aOldRBPos.X() )
     327           0 :                 rRectIt.Right( rRectIt.Right() + nPixPtX );
     328           0 :             if( rRectIt.Bottom() == GetShell()->aOldRBPos.Y() )
     329           0 :                 rRectIt.Bottom( rRectIt.Bottom() + nPixPtY );
     330             :         }
     331           0 :     }
     332             : }
     333             : 
     334           0 : void SwSelPaintRects::Paint( const Rectangle& /*rRect*/ )
     335             : {
     336             :     // nothing to do with overlays
     337           0 : }
     338             : 
     339             : 
     340             : // check current MapMode of the shell and set possibly the static members.
     341             : // Optional set the parameters pX, pY
     342           0 : void SwSelPaintRects::Get1PixelInLogic( const ViewShell& rSh,
     343             :                                         long* pX, long* pY )
     344             : {
     345           0 :     const OutputDevice* pOut = rSh.GetWin();
     346           0 :     if ( ! pOut )
     347           0 :         pOut = rSh.GetOut();
     348             : 
     349           0 :     const MapMode& rMM = pOut->GetMapMode();
     350           0 :     if( pMapMode->GetMapUnit() != rMM.GetMapUnit() ||
     351           0 :         pMapMode->GetScaleX() != rMM.GetScaleX() ||
     352           0 :         pMapMode->GetScaleY() != rMM.GetScaleY() )
     353             :     {
     354           0 :         *pMapMode = rMM;
     355           0 :         Size aTmp( 1, 1 );
     356           0 :         aTmp = pOut->PixelToLogic( aTmp );
     357           0 :         nPixPtX = aTmp.Width();
     358           0 :         nPixPtY = aTmp.Height();
     359             :     }
     360           0 :     if( pX )
     361           0 :         *pX = nPixPtX;
     362           0 :     if( pY )
     363           0 :         *pY = nPixPtY;
     364           0 : }
     365             : 
     366             : 
     367             : 
     368         236 : SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos )
     369         236 :     : SwCursor(rPos,0,false), SwSelPaintRects(rCShell), pPt(SwPaM::GetPoint())
     370         236 : {}
     371             : 
     372             : 
     373           0 : SwShellCrsr::SwShellCrsr( const SwCrsrShell& rCShell, const SwPosition &rPos,
     374             :                             const Point& rPtPos, SwPaM* pRing )
     375             :     : SwCursor(rPos, pRing, false), SwSelPaintRects(rCShell), aMkPt(rPtPos),
     376           0 :     aPtPt(rPtPos), pPt(SwPaM::GetPoint())
     377           0 : {}
     378             : 
     379             : 
     380           0 : SwShellCrsr::SwShellCrsr( SwShellCrsr& rICrsr )
     381           0 :     : SwCursor(rICrsr), SwSelPaintRects(*rICrsr.GetShell()),
     382           0 :     aMkPt(rICrsr.GetMkPos()), aPtPt(rICrsr.GetPtPos()), pPt(SwPaM::GetPoint())
     383           0 : {}
     384             : 
     385         126 : SwShellCrsr::~SwShellCrsr() {}
     386             : 
     387             : 
     388          22 : bool SwShellCrsr::IsReadOnlyAvailable() const
     389             : {
     390          22 :     return GetShell()->IsReadOnlyAvailable();
     391             : }
     392             : 
     393           0 : void SwShellCrsr::SetMark()
     394             : {
     395           0 :     if( SwPaM::GetPoint() == pPt )
     396           0 :         aMkPt = aPtPt;
     397             :     else
     398           0 :         aPtPt = aMkPt;
     399           0 :     SwPaM::SetMark();
     400           0 : }
     401             : 
     402        2888 : void SwShellCrsr::FillRects()
     403             : {
     404             :     // calculate the new rectangles
     405        2888 :     if( HasMark() &&
     406           0 :         GetPoint()->nNode.GetNode().IsCntntNode() &&
     407           0 :         GetPoint()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) &&
     408           0 :         (GetMark()->nNode == GetPoint()->nNode ||
     409           0 :         (GetMark()->nNode.GetNode().IsCntntNode() &&
     410           0 :          GetMark()->nNode.GetNode().GetCntntNode()->getLayoutFrm( GetShell()->GetLayout() ) )   ))
     411           0 :         GetShell()->GetLayout()->CalcFrmRects( *this, GetShell()->IsTableMode() );  //swmod 071107//swmod 071225
     412        2888 : }
     413             : 
     414             : 
     415        1636 : void SwShellCrsr::Show()
     416             : {
     417        1636 :     SwShellCrsr * pTmp = this;
     418        1636 :     do {
     419        1636 :         pTmp->SwSelPaintRects::Show();
     420        1636 :     } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) );
     421        1636 : }
     422             : 
     423             : // This rectangle gets painted anew, therefore the SSelection in this
     424             : // area is invalid.
     425         245 : void SwShellCrsr::Invalidate( const SwRect& rRect )
     426             : {
     427         245 :     SwShellCrsr * pTmp = this;
     428             : 
     429         245 :     do
     430             :     {
     431         245 :         pTmp->SwSelPaintRects::Invalidate( rRect );
     432             : 
     433             :         // skip any non SwShellCrsr objects in the ring
     434             :         // see also: SwAutoFormat::DeleteSel()
     435         245 :         Ring* pTmpRing = pTmp;
     436         245 :         pTmp = 0;
     437         245 :         do
     438             :         {
     439         245 :             pTmpRing = pTmpRing->GetNext();
     440         245 :             pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing);
     441             :         }
     442         245 :         while ( !pTmp );
     443             :     }
     444             :     while( this != pTmp );
     445         245 : }
     446             : 
     447             : 
     448         256 : void SwShellCrsr::Hide()
     449             : {
     450         256 :     SwShellCrsr * pTmp = this;
     451         256 :     do {
     452         256 :         pTmp->SwSelPaintRects::Hide();
     453         256 :     } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) );
     454         256 : }
     455             : 
     456           0 : SwCursor* SwShellCrsr::Create( SwPaM* pRing ) const
     457             : {
     458           0 :     return new SwShellCrsr( *GetShell(), *GetPoint(), GetPtPos(), pRing );
     459             : }
     460             : 
     461             : 
     462           0 : short SwShellCrsr::MaxReplaceArived()
     463             : {
     464           0 :     short nRet = RET_YES;
     465           0 :     Window* pDlg = ::GetSearchDialog();
     466           0 :     if( pDlg )
     467             :     {
     468             :         // Terminate old actions. The table-frames get constructed and
     469             :         // a SSelection can be created.
     470           0 :         std::vector<sal_uInt16> aArr;
     471             :         sal_uInt16 nActCnt;
     472           0 :         ViewShell *pShell = const_cast< SwCrsrShell* >( GetShell() ),
     473           0 :                   *pSh = pShell;
     474           0 :         do {
     475           0 :             for( nActCnt = 0; pSh->ActionPend(); ++nActCnt )
     476           0 :                 pSh->EndAction();
     477           0 :             aArr.push_back( nActCnt );
     478           0 :         } while( pShell != ( pSh = (ViewShell*)pSh->GetNext() ) );
     479             : 
     480             :         {
     481           0 :             nRet = QueryBox( pDlg, SW_RES( MSG_COMCORE_ASKSEARCH )).Execute();
     482             :         }
     483             : 
     484           0 :         for( sal_uInt16 n = 0; n < aArr.size(); ++n )
     485             :         {
     486           0 :             for( nActCnt = aArr[n]; nActCnt--; )
     487           0 :                 pSh->StartAction();
     488           0 :             pSh = (ViewShell*)pSh->GetNext();
     489           0 :         }   //swmod 071107 //swmod 071225
     490             :     }
     491             :     else
     492             :         // otherwise from the Basic, and than switch to RET_YES
     493           0 :         nRet = RET_YES;
     494             : 
     495           0 :     return nRet;
     496             : }
     497             : 
     498           0 : void SwShellCrsr::SaveTblBoxCntnt( const SwPosition* pPos )
     499             : {
     500           0 :     ((SwCrsrShell*)GetShell())->SaveTblBoxCntnt( pPos );
     501           0 : }
     502             : 
     503           0 : sal_Bool SwShellCrsr::UpDown( sal_Bool bUp, sal_uInt16 nCnt )
     504             : {
     505             :     return SwCursor::UpDown( bUp, nCnt,
     506           0 :                             &GetPtPos(), GetShell()->GetUpDownX() );
     507             : }
     508             : 
     509             : // if <true> than the cursor can be set to the position.
     510           0 : sal_Bool SwShellCrsr::IsAtValidPos( sal_Bool bPoint ) const
     511             : {
     512           0 :     if( GetShell() && ( GetShell()->IsAllProtect() ||
     513           0 :         GetShell()->GetViewOptions()->IsReadonly() ||
     514           0 :         ( GetShell()->Imp()->GetDrawView() &&
     515           0 :           GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
     516           0 :         return sal_True;
     517             : 
     518           0 :     return SwCursor::IsAtValidPos( bPoint );
     519             : }
     520             : 
     521             : 
     522           0 : SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
     523             :                                     const SwPosition& rPos )
     524           0 :     : SwCursor(rPos,0,false), SwShellCrsr(rCrsrSh, rPos), SwTableCursor(rPos)
     525             : {
     526           0 : }
     527             : 
     528           0 : SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
     529             :                     const SwPosition& rMkPos, const Point& rMkPt,
     530             :                     const SwPosition& rPtPos, const Point& rPtPt )
     531           0 :     : SwCursor(rPtPos,0,false), SwShellCrsr(rCrsrSh, rPtPos), SwTableCursor(rPtPos)
     532             : {
     533           0 :     SetMark();
     534           0 :     *GetMark() = rMkPos;
     535           0 :     GetMkPos() = rMkPt;
     536           0 :     GetPtPos() = rPtPt;
     537           0 : }
     538             : 
     539           0 : SwShellTableCrsr::~SwShellTableCrsr() {}
     540             : 
     541           0 : void SwShellTableCrsr::SetMark()                { SwShellCrsr::SetMark(); }
     542             : 
     543           0 : SwCursor* SwShellTableCrsr::Create( SwPaM* pRing ) const
     544             : {
     545           0 :     return SwShellCrsr::Create( pRing );
     546             : }
     547           0 : short SwShellTableCrsr::MaxReplaceArived()
     548             : {
     549           0 :     return SwShellCrsr::MaxReplaceArived();
     550             : }
     551           0 : void SwShellTableCrsr::SaveTblBoxCntnt( const SwPosition* pPos )
     552             : {
     553           0 :     SwShellCrsr::SaveTblBoxCntnt( pPos );
     554           0 : }
     555             : 
     556             : 
     557           0 : void SwShellTableCrsr::FillRects()
     558             : {
     559             :     // Calculate the new rectangles. If the cursor is still "parked" do nothing
     560           0 :     if (m_SelectedBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex())
     561           0 :         return;
     562             : 
     563           0 :     SwRegionRects aReg( GetShell()->VisArea() );
     564           0 :     SwNodes& rNds = GetDoc()->GetNodes();
     565           0 :     for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
     566             :     {
     567           0 :         const SwStartNode* pSttNd = m_SelectedBoxes[n]->GetSttNd();
     568           0 :         const SwTableNode* pSelTblNd = pSttNd->FindTableNode();
     569             : 
     570           0 :         SwNodeIndex aIdx( *pSttNd );
     571           0 :            SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
     572             : 
     573             :         // table in table
     574             :         // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different
     575             :         // version to do this)
     576           0 :         const SwTableNode* pCurTblNd = pCNd->FindTableNode();
     577           0 :         while ( pSelTblNd != pCurTblNd && pCurTblNd )
     578             :         {
     579           0 :             aIdx = pCurTblNd->EndOfSectionIndex();
     580           0 :             pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
     581           0 :             pCurTblNd = pCNd->FindTableNode();
     582             :         }
     583             : 
     584           0 :         if( !pCNd )
     585           0 :             continue;
     586             : 
     587           0 :         SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetSttPos() );
     588           0 :         while( pFrm && !pFrm->IsCellFrm() )
     589           0 :             pFrm = pFrm->GetUpper();
     590             : 
     591             :         OSL_ENSURE( pFrm, "Node not in a table" );
     592             : 
     593           0 :         while ( pFrm )
     594             :         {
     595           0 :             if( aReg.GetOrigin().IsOver( pFrm->Frm() ) )
     596           0 :                 aReg -= pFrm->Frm();
     597             : 
     598           0 :             pFrm = pFrm->GetNextCellLeaf( MAKEPAGE_NONE );
     599             :         }
     600           0 :     }
     601           0 :     aReg.Invert();
     602           0 :     insert( begin(), aReg.begin(), aReg.end() );
     603             : }
     604             : 
     605             : 
     606             : // Check if the SPoint is within the Table-SSelection.
     607           0 : sal_Bool SwShellTableCrsr::IsInside( const Point& rPt ) const
     608             : {
     609             :     // Calculate the new rectangles. If the cursor is still "parked" do nothing
     610           0 :     if (m_SelectedBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex())
     611           0 :         return sal_False;
     612             : 
     613           0 :     SwNodes& rNds = GetDoc()->GetNodes();
     614           0 :     for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
     615             :     {
     616           0 :         SwNodeIndex aIdx( *m_SelectedBoxes[n]->GetSttNd() );
     617           0 :         SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
     618           0 :         if( !pCNd )
     619           0 :             continue;
     620             : 
     621           0 :         SwFrm* pFrm = pCNd->getLayoutFrm( GetShell()->GetLayout(), &GetPtPos() );
     622           0 :         while( pFrm && !pFrm->IsCellFrm() )
     623           0 :             pFrm = pFrm->GetUpper();
     624             :         OSL_ENSURE( pFrm, "Node not in a table" );
     625           0 :         if( pFrm && pFrm->Frm().IsInside( rPt ) )
     626           0 :             return sal_True;
     627           0 :     }
     628           0 :     return sal_False;
     629             : }
     630             : 
     631           0 : sal_Bool SwShellTableCrsr::IsAtValidPos( sal_Bool bPoint ) const
     632             : {
     633           0 :     return SwShellCrsr::IsAtValidPos( bPoint );
     634             : }
     635             : 
     636             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10