LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/inc - wrong.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 0.0 %
Date: 2012-12-27 Functions: 0 15 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             : #ifndef _WRONG_HXX
      21             : #define _WRONG_HXX
      22             : 
      23             : #include <com/sun/star/container/XStringKeyMap.hpp>
      24             : 
      25             : #include <vector>
      26             : 
      27             : #include <tools/string.hxx>
      28             : 
      29             : class SwWrongList;
      30             : 
      31             : // ST2
      32           0 : class SwWrongArea
      33             : {
      34             : public:
      35             :     rtl::OUString maType;
      36             :     com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > mxPropertyBag;
      37             :     xub_StrLen mnPos;
      38             :     xub_StrLen mnLen;
      39             :     SwWrongList* mpSubList;
      40             : 
      41             :     SwWrongArea() : mnPos(0), mnLen(0), mpSubList(NULL) {}
      42           0 :     SwWrongArea( const rtl::OUString& rType,
      43             :                  com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > xPropertyBag,
      44             :                  xub_StrLen nPos,
      45             :                  xub_StrLen nLen,
      46             :                  SwWrongList* pSubList )
      47           0 :         : maType(rType), mxPropertyBag(xPropertyBag), mnPos(nPos), mnLen(nLen), mpSubList(pSubList) {}
      48             : };
      49             : 
      50             : enum WrongListType
      51             : {
      52             :     WRONGLIST_SPELL,
      53             :     WRONGLIST_GRAMMAR,
      54             :     WRONGLIST_SMARTTAG,
      55             :     WRONGLIST_CHANGETRACKING
      56             : };
      57             : 
      58             : class SwWrongList
      59             : {
      60             :     std::vector<SwWrongArea> maList;
      61             :     WrongListType            meType;
      62             : 
      63             :     xub_StrLen nBeginInvalid;   // Start of the invalid range
      64             :     xub_StrLen nEndInvalid;     // End of the invalid range
      65             : 
      66           0 :     void ShiftLeft( xub_StrLen &rPos, xub_StrLen nStart, xub_StrLen nEnd )
      67           0 :     { if( rPos > nStart ) rPos = rPos > nEnd ? rPos - nEnd + nStart : nStart; }
      68             :     void ShiftRight( xub_StrLen &rPos, xub_StrLen nStart, xub_StrLen nEnd )
      69             :     { if( rPos >= nStart ) rPos += nStart - nEnd; }
      70             :     void _Invalidate( xub_StrLen nBegin, xub_StrLen nEnd );
      71             : 
      72             :     void Insert(sal_uInt16 nWhere, std::vector<SwWrongArea>::iterator startPos, std::vector<SwWrongArea>::iterator endPos);
      73             :     void Remove( sal_uInt16 nIdx, sal_uInt16 nLen );
      74             : 
      75             :     // forbidden and not implemented
      76             :     SwWrongList& operator= (const SwWrongList &);
      77             :     SwWrongList( const SwWrongList& rCpy );
      78             : 
      79             : public:
      80             :     SwWrongList( WrongListType eType );
      81             : 
      82             :     virtual ~SwWrongList();
      83             :     virtual SwWrongList* Clone();
      84             :     virtual void CopyFrom( const SwWrongList& rCopy );
      85             : 
      86           0 :     inline WrongListType GetWrongListType() const { return meType; }
      87           0 :     inline xub_StrLen GetBeginInv() const { return nBeginInvalid; }
      88           0 :     inline xub_StrLen GetEndInv() const { return nEndInvalid; }
      89             :     inline sal_Bool InsideInvalid( xub_StrLen nChk ) const
      90             :         { return nChk >= nBeginInvalid && nChk <= nEndInvalid; }
      91             :     void SetInvalid( xub_StrLen nBegin, xub_StrLen nEnd );
      92           0 :     inline void Validate(){ nBeginInvalid = STRING_LEN; }
      93             :     void Invalidate( xub_StrLen nBegin, xub_StrLen nEnd );
      94             :     sal_Bool InvalidateWrong();
      95             :     sal_Bool Fresh( xub_StrLen &rStart, xub_StrLen &rEnd, xub_StrLen nPos,
      96             :             xub_StrLen nLen, sal_uInt16 nIndex, xub_StrLen nCursorPos );
      97             :     sal_uInt16 GetWrongPos( xub_StrLen nValue ) const;
      98             : 
      99             :     sal_Bool Check( xub_StrLen &rChk, xub_StrLen &rLn ) const;
     100             :     sal_Bool InWrongWord( xub_StrLen &rChk, xub_StrLen &rLn ) const;
     101             :     xub_StrLen NextWrong( xub_StrLen nChk ) const;
     102             : 
     103             :     void Move( xub_StrLen nPos, long nDiff );
     104             :     void ClearList();
     105             : 
     106             :     // Divide the list into two part, the wrong words until nSplitPos will be
     107             :     // removed and transferred to a new SwWrongList.
     108             :     SwWrongList* SplitList( xub_StrLen nSplitPos );
     109             :     // Join the next SwWrongList, nInsertPos is my own text length, where
     110             :     // the other wrong list has to be inserted.
     111             :     void JoinList( SwWrongList* pNext, xub_StrLen nInsertPos );
     112             : 
     113           0 :     inline xub_StrLen Len( sal_uInt16 nIdx ) const
     114             :     {
     115           0 :         return nIdx < maList.size() ? maList[nIdx].mnLen : 0;
     116             :     }
     117             : 
     118           0 :     inline xub_StrLen Pos( sal_uInt16 nIdx ) const
     119             :     {
     120           0 :         return nIdx < maList.size() ? maList[nIdx].mnPos : 0;
     121             :     }
     122             : 
     123           0 :     inline sal_uInt16 Count() const { return (sal_uInt16)maList.size(); }
     124             : 
     125           0 :     inline void Insert( const rtl::OUString& rType,
     126             :                         com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > xPropertyBag,
     127             :                         xub_StrLen nNewPos, xub_StrLen nNewLen, sal_uInt16 nWhere )
     128             :     {
     129           0 :         std::vector<SwWrongArea>::iterator i = maList.begin();
     130           0 :         if ( nWhere >= maList.size() )
     131           0 :             i = maList.end(); // robust
     132             :         else
     133           0 :             i += nWhere;
     134           0 :         maList.insert(i, SwWrongArea( rType, xPropertyBag, nNewPos, nNewLen, 0 ) );
     135           0 :     }
     136             : 
     137             :     void Insert( const rtl::OUString& rType,
     138             :                  com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > xPropertyBag,
     139             :                  xub_StrLen nNewPos, xub_StrLen nNewLen );
     140             : 
     141           0 :     inline SwWrongList* SubList( sal_uInt16 nIdx ) const
     142             :     {
     143           0 :         return nIdx < maList.size() ? maList[nIdx].mpSubList : 0;
     144             :     }
     145             : 
     146             :     void InsertSubList( xub_StrLen nNewPos, xub_StrLen nNewLen, sal_uInt16 nWhere, SwWrongList* pSubList );
     147             : 
     148           0 :     inline const SwWrongArea* GetElement( sal_uInt16 nIdx ) const
     149             :     {
     150           0 :         return nIdx < maList.size() ? &maList[nIdx] : 0;
     151             :     }
     152             :     void RemoveEntry( xub_StrLen nBegin, xub_StrLen nEnd );
     153             :     bool LookForEntry( xub_StrLen nBegin, xub_StrLen nEnd );
     154             : };
     155             : 
     156             : #endif
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10