LCOV - code coverage report
Current view: top level - sw/inc - unocrsr.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 56 60 93.3 %
Date: 2015-06-13 12:38:46 Functions: 18 21 85.7 %
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             : #ifndef INCLUDED_SW_INC_UNOCRSR_HXX
      20             : #define INCLUDED_SW_INC_UNOCRSR_HXX
      21             : 
      22             : #include <swcrsr.hxx>
      23             : #include <calbck.hxx>
      24             : 
      25             : namespace sw
      26             : {
      27             :     struct SW_DLLPUBLIC DocDisposingHint SAL_FINAL : public SfxHint
      28             :     {
      29        2949 :         DocDisposingHint() {}
      30             :         virtual ~DocDisposingHint();
      31             :     };
      32             : }
      33             : 
      34             : class SwUnoCrsr : public virtual SwCursor, public SwModify
      35             : {
      36             : private:
      37             :     bool m_bRemainInSection : 1;
      38             :     bool m_bSkipOverHiddenSections : 1;
      39             :     bool m_bSkipOverProtectSections : 1;
      40             : 
      41             : public:
      42             :     SwUnoCrsr( const SwPosition &rPos, SwPaM* pRing = 0 );
      43             :     virtual ~SwUnoCrsr();
      44             : 
      45             : protected:
      46             : 
      47             :     virtual const SwContentFrm* DoSetBidiLevelLeftRight(
      48             :         bool & io_rbLeft, bool bVisualAllowed, bool bInsertCrsr) SAL_OVERRIDE;
      49             :     virtual void DoSetBidiLevelUpDown() SAL_OVERRIDE;
      50             : 
      51             : public:
      52             : 
      53             :     // Does a selection of content exist in table?
      54             :     // Return value indicates if the cursor remains at its old position.
      55             :     virtual bool IsSelOvr( int eFlags =
      56             :                                 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
      57             :                                   nsSwCursorSelOverFlags::SELOVER_TOGGLE |
      58             :                                   nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )) SAL_OVERRIDE;
      59             : 
      60             :     virtual bool IsReadOnlyAvailable() const SAL_OVERRIDE;
      61             : 
      62      981134 :     bool IsRemainInSection() const          { return m_bRemainInSection; }
      63       13047 :     void SetRemainInSection( bool bFlag )   { m_bRemainInSection = bFlag; }
      64             : 
      65       65903 :     virtual bool IsSkipOverProtectSections() const SAL_OVERRIDE
      66       65903 :                                     { return m_bSkipOverProtectSections; }
      67           0 :     void SetSkipOverProtectSections( bool bFlag )
      68           0 :                                     { m_bSkipOverProtectSections = bFlag; }
      69             : 
      70       65903 :     virtual bool IsSkipOverHiddenSections() const SAL_OVERRIDE
      71       65903 :                                     { return m_bSkipOverHiddenSections; }
      72           0 :     void SetSkipOverHiddenSections( bool bFlag )
      73           0 :                                     { m_bSkipOverHiddenSections = bFlag; }
      74             : 
      75      426582 :     DECL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr )
      76             : };
      77             : 
      78             : class SwUnoTableCrsr : public virtual SwUnoCrsr, public virtual SwTableCursor
      79             : {
      80             :     // The selection has the same order as the table boxes, i.e.
      81             :     // if something is deleted from the one array at a certain position
      82             :     // it has also to be deleted from the other!
      83             :     SwCursor m_aTableSel;
      84             : 
      85             :     using SwTableCursor::MakeBoxSels;
      86             : 
      87             : public:
      88             :     SwUnoTableCrsr( const SwPosition& rPos );
      89             :     virtual ~SwUnoTableCrsr();
      90             : 
      91             :     // Does a selection of content exist in table?
      92             :     // Return value indicates if the cursor remains at its old position.
      93             :     virtual bool IsSelOvr( int eFlags =
      94             :                                 ( nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION |
      95             :                                   nsSwCursorSelOverFlags::SELOVER_TOGGLE |
      96             :                                   nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )) SAL_OVERRIDE;
      97             : 
      98             :     std::shared_ptr<SwUnoCrsr> Clone() const;
      99             : 
     100             :     void MakeBoxSels();
     101             : 
     102        1006 :           SwCursor& GetSelRing()            { return m_aTableSel; }
     103             :     const SwCursor& GetSelRing() const      { return m_aTableSel; }
     104             : };
     105             : 
     106             : namespace sw
     107             : {
     108             :     class UnoCursorPointer : public SwClient
     109             :     {
     110             :         public:
     111       14617 :             UnoCursorPointer()
     112       14617 :                 : m_pCursor(nullptr), m_bSectionRestricted(false)
     113       14617 :             {}
     114      203467 :             UnoCursorPointer(std::shared_ptr<SwUnoCrsr> pCursor, bool bSectionRestricted=false)
     115      203467 :                 : m_pCursor(pCursor), m_bSectionRestricted(bSectionRestricted)
     116             :             {
     117      203467 :                 m_pCursor->Add(this);
     118      203467 :             }
     119        2916 :             UnoCursorPointer(const UnoCursorPointer& rOther)
     120             :                 : SwClient(nullptr)
     121             :                 , m_pCursor(rOther.m_pCursor)
     122        2916 :                 , m_bSectionRestricted(rOther.m_bSectionRestricted)
     123             :             {
     124        2916 :                 if(m_pCursor)
     125        2916 :                     m_pCursor->Add(this);
     126        2916 :             }
     127      221000 :             virtual ~UnoCursorPointer() SAL_OVERRIDE
     128      442000 :             {
     129      221000 :                 if(m_pCursor)
     130      207290 :                     m_pCursor->Remove(this);
     131      221000 :             }
     132        4915 :             virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE
     133             :             {
     134        4915 :                 SwClient::SwClientNotify(rModify, rHint);
     135        4915 :                 if(m_pCursor)
     136             :                 {
     137        4915 :                     if(typeid(rHint) == typeid(DocDisposingHint))
     138        3408 :                         m_pCursor->Remove(this);
     139        1507 :                     else if(m_bSectionRestricted && typeid(rHint) == typeid(LegacyModifyHint))
     140             :                     {
     141        1341 :                         const auto pLegacyHint = static_cast<const LegacyModifyHint*>(&rHint);
     142        1341 :                         if(pLegacyHint->m_pOld && pLegacyHint->m_pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION)
     143        1341 :                             m_pCursor->Remove(this);
     144             :                     }
     145             :                 }
     146        4915 :                 if(!GetRegisteredIn())
     147        4749 :                     m_pCursor.reset();
     148        4915 :             };
     149      678350 :             SwUnoCrsr& operator*() const
     150      678350 :                 { return *m_pCursor.get(); }
     151      205876 :             SwUnoCrsr* operator->() const
     152      205876 :                 { return m_pCursor.get(); }
     153       14616 :             UnoCursorPointer& operator=(UnoCursorPointer aOther)
     154             :             {
     155       14616 :                 if(aOther.m_pCursor)
     156       14616 :                     aOther.m_pCursor->Add(this);
     157       14616 :                 m_pCursor = aOther.m_pCursor;
     158       14616 :                 return *this;
     159             :             }
     160      573512 :             explicit operator bool() const
     161      573512 :                 { return static_cast<bool>(m_pCursor); }
     162        9111 :             void reset(std::shared_ptr<SwUnoCrsr> pNew)
     163             :             {
     164        9111 :                 if(pNew)
     165           1 :                     pNew->Add(this);
     166        9110 :                 else if(m_pCursor)
     167        8961 :                     m_pCursor->Remove(this);
     168        9111 :                 m_pCursor = pNew;
     169        9111 :             }
     170             :         private:
     171             :             std::shared_ptr<SwUnoCrsr> m_pCursor;
     172             :             const bool m_bSectionRestricted;
     173             :     };
     174             : }
     175             : #endif
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11