LCOV - code coverage report
Current view: top level - sw/source/core/crsr - unocrsr.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 118 0.0 %
Date: 2014-04-14 Functions: 0 21 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 <unocrsr.hxx>
      21             : #include <doc.hxx>
      22             : #include <swtable.hxx>
      23             : #include <docary.hxx>
      24             : #include <rootfrm.hxx>
      25             : 
      26           0 : IMPL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr )
      27             : 
      28           0 : SwUnoCrsr::SwUnoCrsr( const SwPosition &rPos, SwPaM* pRing )
      29             :     : SwCursor( rPos, pRing, false ), SwModify( 0 ),
      30             :     bRemainInSection( sal_True ),
      31             :     bSkipOverHiddenSections( sal_False ),
      32           0 :     bSkipOverProtectSections( sal_False )
      33           0 : {}
      34             : 
      35           0 : SwUnoCrsr::~SwUnoCrsr()
      36             : {
      37           0 :     SwDoc* pDoc = GetDoc();
      38           0 :     if( !pDoc->IsInDtor() )
      39             :     {
      40             :         // then remove cursor from array
      41           0 :         SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
      42           0 :         if( !rTbl.erase( this ) )
      43             :         {
      44             :             OSL_ENSURE( !this, "UNO Cursor nicht mehr im Array" );
      45             :         }
      46             :     }
      47             : 
      48             :     // delete the whole ring
      49           0 :     while( GetNext() != this )
      50             :     {
      51           0 :         Ring* pNxt = GetNext();
      52           0 :         pNxt->MoveTo( 0 ); // remove from chain
      53           0 :         delete pNxt;       // and delete
      54             :     }
      55           0 : }
      56             : 
      57           0 : SwUnoCrsr * SwUnoCrsr::Clone() const
      58             : {
      59           0 :     SwUnoCrsr * pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint() );
      60           0 :     if (HasMark())
      61             :     {
      62           0 :         pNewCrsr->SetMark();
      63           0 :         *pNewCrsr->GetMark() = *GetMark();
      64             :     }
      65           0 :     return pNewCrsr;
      66             : }
      67             : 
      68           0 : SwUnoTableCrsr * SwUnoTableCrsr::Clone() const
      69             : {
      70             :     SwUnoTableCrsr * pNewCrsr = dynamic_cast<SwUnoTableCrsr*>(
      71             :         GetDoc()->CreateUnoCrsr(
      72           0 :             *GetPoint(), true /* create SwUnoTableCrsr */ ) );
      73             :     OSL_ENSURE(pNewCrsr, "Clone: cannot create SwUnoTableCrsr?");
      74           0 :     if (pNewCrsr && HasMark())
      75             :     {
      76           0 :         pNewCrsr->SetMark();
      77           0 :         *pNewCrsr->GetMark() = *GetMark();
      78             :     }
      79           0 :     return pNewCrsr;
      80             : }
      81             : 
      82           0 : bool SwUnoCrsr::IsReadOnlyAvailable() const
      83             : {
      84           0 :     return true;
      85             : }
      86             : 
      87             : const SwCntntFrm*
      88           0 : SwUnoCrsr::DoSetBidiLevelLeftRight( sal_Bool &, sal_Bool, sal_Bool )
      89             : {
      90           0 :     return 0; // not for uno cursor
      91             : }
      92             : 
      93           0 : void SwUnoCrsr::DoSetBidiLevelUpDown()
      94             : {
      95           0 :     return; // not for uno cursor
      96             : }
      97             : 
      98           0 : sal_Bool SwUnoCrsr::IsSelOvr( int eFlags )
      99             : {
     100           0 :     if( bRemainInSection )
     101             :     {
     102           0 :         SwDoc* pDoc = GetDoc();
     103           0 :         SwNodeIndex aOldIdx( *pDoc->GetNodes()[ GetSavePos()->nNode ] );
     104           0 :         SwNodeIndex& rPtIdx = GetPoint()->nNode;
     105           0 :         SwStartNode *pOldSttNd = aOldIdx.GetNode().StartOfSectionNode(),
     106           0 :                     *pNewSttNd = rPtIdx.GetNode().StartOfSectionNode();
     107           0 :         if( pOldSttNd != pNewSttNd )
     108             :         {
     109           0 :             bool bMoveDown = GetSavePos()->nNode < rPtIdx.GetIndex();
     110           0 :             bool bValidPos = false;
     111             : 
     112             :             // search the correct surrounded start node - which the index
     113             :             // can't leave.
     114           0 :             while( pOldSttNd->IsSectionNode() )
     115           0 :                 pOldSttNd = pOldSttNd->StartOfSectionNode();
     116             : 
     117             :             // is the new index inside this surrounded section?
     118           0 :             if( rPtIdx > *pOldSttNd &&
     119           0 :                 rPtIdx < pOldSttNd->EndOfSectionIndex() )
     120             :             {
     121             :                 // check if it a valid move inside this section
     122             :                 // (only over SwSection's !)
     123             :                 const SwStartNode* pInvalidNode;
     124           0 :                 do {
     125           0 :                     pInvalidNode = 0;
     126           0 :                     pNewSttNd = rPtIdx.GetNode().StartOfSectionNode();
     127             : 
     128           0 :                     const SwStartNode *pSttNd = pNewSttNd, *pEndNd = pOldSttNd;
     129           0 :                     if( pSttNd->EndOfSectionIndex() >
     130           0 :                         pEndNd->EndOfSectionIndex() )
     131             :                     {
     132           0 :                         pEndNd = pNewSttNd;
     133           0 :                         pSttNd = pOldSttNd;
     134             :                     }
     135             : 
     136           0 :                     while( pSttNd->GetIndex() > pEndNd->GetIndex() )
     137             :                     {
     138           0 :                         if( !pSttNd->IsSectionNode() )
     139           0 :                             pInvalidNode = pSttNd;
     140           0 :                         pSttNd = pSttNd->StartOfSectionNode();
     141             :                     }
     142           0 :                     if( pInvalidNode )
     143             :                     {
     144           0 :                         if( bMoveDown )
     145             :                         {
     146           0 :                             rPtIdx.Assign( *pInvalidNode->EndOfSectionNode(), 1 );
     147             : 
     148           0 :                             if( !rPtIdx.GetNode().IsCntntNode() &&
     149           0 :                                 ( !pDoc->GetNodes().GoNextSection( &rPtIdx ) ||
     150           0 :                                   rPtIdx > pOldSttNd->EndOfSectionIndex() ) )
     151           0 :                                 break;
     152             :                         }
     153             :                         else
     154             :                         {
     155           0 :                             rPtIdx.Assign( *pInvalidNode, -1 );
     156             : 
     157           0 :                             if( !rPtIdx.GetNode().IsCntntNode() &&
     158           0 :                                 ( !pDoc->GetNodes().GoPrevSection( &rPtIdx ) ||
     159           0 :                                   rPtIdx < *pOldSttNd ) )
     160           0 :                                 break;
     161             :                         }
     162             :                     }
     163             :                     else
     164           0 :                         bValidPos = true;
     165             :                 } while ( pInvalidNode );
     166             :             }
     167             : 
     168           0 :             if( bValidPos )
     169             :             {
     170           0 :                 SwCntntNode* pCNd = GetCntntNode();
     171           0 :                 GetPoint()->nContent.Assign( pCNd, (pCNd && !bMoveDown) ? pCNd->Len() : 0);
     172             :             }
     173             :             else
     174             :             {
     175           0 :                 rPtIdx = GetSavePos()->nNode;
     176           0 :                 GetPoint()->nContent.Assign( GetCntntNode(), GetSavePos()->nCntnt );
     177           0 :                 return sal_True;
     178             :             }
     179           0 :         }
     180             :     }
     181           0 :     return SwCursor::IsSelOvr( eFlags );
     182             : }
     183             : 
     184           0 : SwUnoTableCrsr::SwUnoTableCrsr(const SwPosition& rPos)
     185           0 :     : SwCursor(rPos,0,false), SwUnoCrsr(rPos), SwTableCursor(rPos), aTblSel(rPos,0,false)
     186             : {
     187           0 :     SetRemainInSection(sal_False);
     188           0 : }
     189             : 
     190           0 : SwUnoTableCrsr::~SwUnoTableCrsr()
     191             : {
     192           0 :     while( aTblSel.GetNext() != &aTblSel )
     193           0 :         delete aTblSel.GetNext();
     194           0 : }
     195             : 
     196           0 : sal_Bool SwUnoTableCrsr::IsSelOvr( int eFlags )
     197             : {
     198           0 :     sal_Bool bRet = SwUnoCrsr::IsSelOvr( eFlags );
     199           0 :     if( !bRet )
     200             :     {
     201           0 :         const SwTableNode* pTNd = GetPoint()->nNode.GetNode().FindTableNode();
     202           0 :         bRet = !(pTNd == GetDoc()->GetNodes()[ GetSavePos()->nNode ]->
     203           0 :                 FindTableNode() && (!HasMark() ||
     204           0 :                 pTNd == GetMark()->nNode.GetNode().FindTableNode() ));
     205             :     }
     206           0 :     return bRet;
     207             : }
     208             : 
     209           0 : void SwUnoTableCrsr::MakeBoxSels()
     210             : {
     211             :     const SwCntntNode* pCNd;
     212           0 :     bool bMakeTblCrsrs = true;
     213           0 :     if( GetPoint()->nNode.GetIndex() && GetMark()->nNode.GetIndex() &&
     214           0 :             0 != ( pCNd = GetCntntNode() ) && pCNd->getLayoutFrm( pCNd->GetDoc()->GetCurrentLayout() ) &&
     215           0 :             0 != ( pCNd = GetCntntNode(false) ) && pCNd->getLayoutFrm( pCNd->GetDoc()->GetCurrentLayout() ) )
     216           0 :         bMakeTblCrsrs = GetDoc()->GetCurrentLayout()->MakeTblCrsrs( *this );
     217             : 
     218           0 :     if ( !bMakeTblCrsrs )
     219             :     {
     220           0 :         SwSelBoxes const& rTmpBoxes = GetSelectedBoxes();
     221           0 :         while (!rTmpBoxes.empty())
     222             :         {
     223           0 :             DeleteBox(0);
     224             :         }
     225             :     }
     226             : 
     227           0 :     if( IsChgd() )
     228             :     {
     229           0 :         SwTableCursor::MakeBoxSels( &aTblSel );
     230           0 :         if (!GetSelectedBoxesCount())
     231             :         {
     232             :             const SwTableBox* pBox;
     233           0 :             const SwNode* pBoxNd = GetPoint()->nNode.GetNode().FindTableBoxStartNode();
     234           0 :             const SwTableNode* pTblNd = pBoxNd ? pBoxNd->FindTableNode() : 0;
     235           0 :             if( pTblNd && 0 != ( pBox = pTblNd->GetTable().GetTblBox( pBoxNd->GetIndex() )) )
     236           0 :                 InsertBox( *pBox );
     237             :         }
     238             :     }
     239           0 : }
     240             : 
     241           0 : SwUnoCrsrTbl::~SwUnoCrsrTbl()
     242             : {
     243           0 :     while (!empty())
     244             :     {
     245           0 :         delete *begin();
     246           0 :         erase( begin() );
     247             :     }
     248           0 : }
     249             : 
     250             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10