LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/inc - redline.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 68 36.8 %
Date: 2013-07-09 Functions: 11 33 33.3 %
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 _REDLINE_HXX
      20             : #define _REDLINE_HXX
      21             : 
      22             : #include <tools/datetime.hxx>
      23             : #include <tools/string.hxx>
      24             : 
      25             : #include <pam.hxx>
      26             : 
      27             : #include <IDocumentRedlineAccess.hxx>
      28             : 
      29             : #include <svl/smplhint.hxx>
      30             : #include <vector>
      31             : 
      32             : class SfxItemSet;
      33             : class SwView;
      34             : 
      35             : class SwRedlineExtraData
      36             : {
      37             :     SwRedlineExtraData( const SwRedlineExtraData& );
      38             :     SwRedlineExtraData& operator=( const SwRedlineExtraData& );
      39             : 
      40             : protected:
      41           0 :     SwRedlineExtraData() {}
      42             : 
      43             : public:
      44             :     virtual ~SwRedlineExtraData();
      45             :     virtual SwRedlineExtraData* CreateNew() const = 0;
      46             : 
      47             :     virtual void Accept( SwPaM& rPam ) const;
      48             :     virtual void Reject( SwPaM& rPam ) const;
      49             :     virtual int operator == ( const SwRedlineExtraData& ) const;
      50             : };
      51             : 
      52             : class SwRedlineExtraData_FmtColl : public SwRedlineExtraData
      53             : {
      54             :     String sFmtNm;
      55             :     SfxItemSet* pSet;
      56             :     sal_uInt16 nPoolId;
      57             : public:
      58             :     SwRedlineExtraData_FmtColl( const String& rColl, sal_uInt16 nPoolFmtId,
      59             :                                 const SfxItemSet* pSet = 0 );
      60             :     virtual ~SwRedlineExtraData_FmtColl();
      61             :     virtual SwRedlineExtraData* CreateNew() const;
      62             :     virtual void Reject( SwPaM& rPam ) const;
      63             :     virtual int operator == ( const SwRedlineExtraData& ) const;
      64             : 
      65             :     void SetItemSet( const SfxItemSet& rSet );
      66             : };
      67             : 
      68             : class SwRedlineExtraData_Format : public SwRedlineExtraData
      69             : {
      70             :     std::vector<sal_uInt16> aWhichIds;
      71             : 
      72             :     SwRedlineExtraData_Format( const SwRedlineExtraData_Format& rCpy );
      73             : 
      74             : public:
      75             :     SwRedlineExtraData_Format( const SfxItemSet& rSet );
      76             :     virtual ~SwRedlineExtraData_Format();
      77             :     virtual SwRedlineExtraData* CreateNew() const;
      78             :     virtual void Reject( SwPaM& rPam ) const;
      79             :     virtual int operator == ( const SwRedlineExtraData& ) const;
      80             : };
      81             : 
      82             : 
      83             : class SW_DLLPUBLIC SwRedlineData
      84             : {
      85             :     friend class SwRedline;
      86             :     SwRedlineData* pNext;       // Points to other data.
      87             :     SwRedlineExtraData* pExtraData;
      88             : 
      89             :     String sComment;
      90             :     DateTime aStamp;
      91             :     RedlineType_t eType;
      92             :     sal_uInt16 nAuthor, nSeqNo;
      93             : 
      94             : public:
      95             :     SwRedlineData( RedlineType_t eT, sal_uInt16 nAut );
      96             :     SwRedlineData( const SwRedlineData& rCpy, sal_Bool bCpyNext = sal_True );
      97             : 
      98             :     // For sw3io: pNext/pExtraData are taken over.
      99             :     SwRedlineData( RedlineType_t eT, sal_uInt16 nAut, const DateTime& rDT,
     100             :                    const String& rCmnt, SwRedlineData* pNxt,
     101             :                     SwRedlineExtraData* pExtraData = 0 );
     102             : 
     103             :     ~SwRedlineData();
     104             : 
     105           0 :     int operator==( const SwRedlineData& rCmp ) const
     106             :         {
     107           0 :             return nAuthor == rCmp.nAuthor &&
     108           0 :                     eType == rCmp.eType &&
     109           0 :                     sComment == rCmp.sComment &&
     110           0 :                     (( !pNext && !rCmp.pNext ) ||
     111           0 :                         ( pNext && rCmp.pNext && *pNext == *rCmp.pNext )) &&
     112           0 :                     (( !pExtraData && !rCmp.pExtraData ) ||
     113           0 :                         ( pExtraData && rCmp.pExtraData &&
     114           0 :                             *pExtraData == *rCmp.pExtraData ));
     115             :         }
     116           0 :     int operator!=( const SwRedlineData& rCmp ) const
     117           0 :         {   return !operator==( rCmp ); }
     118             : 
     119          47 :     RedlineType_t GetType() const
     120          47 :   { return ((RedlineType_t)(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
     121             :     RedlineType_t GetRealType() const { return eType; }
     122          11 :     sal_uInt16 GetAuthor() const                { return nAuthor; }
     123           0 :     const String& GetComment() const        { return sComment; }
     124         349 :     const DateTime& GetTimeStamp() const    { return aStamp; }
     125           0 :     inline const SwRedlineData* Next() const{ return pNext; }
     126             : 
     127           0 :     void SetComment( const String& rS )     { sComment = rS; }
     128           8 :     void SetTimeStamp( const DateTime& rDT ) { aStamp = rDT; }
     129             : 
     130           0 :     void SetAutoFmtFlag()
     131           0 :   { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); }
     132         736 :     int CanCombine( const SwRedlineData& rCmp ) const
     133             :         {
     134         905 :             return nAuthor == rCmp.nAuthor &&
     135         338 :                     eType == rCmp.eType &&
     136         338 :                     sComment == rCmp.sComment &&
     137         338 :                     GetTimeStamp() == rCmp.GetTimeStamp() &&
     138         338 :                     (( !pNext && !rCmp.pNext ) ||
     139           0 :                         ( pNext && rCmp.pNext &&
     140        1074 :                         pNext->CanCombine( *rCmp.pNext ))) &&
     141         338 :                     (( !pExtraData && !rCmp.pExtraData ) ||
     142           0 :                         ( pExtraData && rCmp.pExtraData &&
     143         736 :                             *pExtraData == *rCmp.pExtraData ));
     144             :         }
     145             : 
     146             :     // ExtraData gets copied, the pointer is therefore not taken over by
     147             :     // the RedlilneObject
     148             :     void SetExtraData( const SwRedlineExtraData* pData );
     149           0 :     const SwRedlineExtraData* GetExtraData() const { return pExtraData; }
     150             : 
     151             :     // For UI-side pooling of Redline-actions.
     152             :     // At the moment only used for Autoformat with Redline.
     153             :     // Value != 0 means there can be others!
     154           6 :     sal_uInt16 GetSeqNo() const                     { return nSeqNo; }
     155           0 :     void SetSeqNo( sal_uInt16 nNo )                 { nSeqNo = nNo; }
     156             : 
     157             :     String GetDescr() const;
     158             : };
     159             : 
     160             : 
     161             : class SW_DLLPUBLIC SwRedline : public SwPaM
     162             : {
     163             :     SwRedlineData* pRedlineData;
     164             :     SwNodeIndex* pCntntSect;
     165             :     sal_Bool bDelLastPara : 1;
     166             :     sal_Bool bIsLastParaDelete : 1;
     167             :     sal_Bool bIsVisible : 1;
     168             : 
     169             :     void MoveToSection();
     170             :     void CopyToSection();
     171             :     void DelCopyOfSection();
     172             :     void MoveFromSection();
     173             : 
     174             : public:
     175             :     SwRedline( RedlineType_t eType, const SwPaM& rPam );
     176             :     SwRedline( const SwRedlineData& rData, const SwPaM& rPam );
     177             :     SwRedline( const SwRedlineData& rData, const SwPosition& rPos );
     178             :     // For sw3io: pData is taken over!
     179           0 :     SwRedline(SwRedlineData* pData, const SwPosition& rPos, sal_Bool bVsbl,
     180             :                sal_Bool bDelLP, sal_Bool bIsPD) :
     181             :         SwPaM( rPos ), pRedlineData( pData ), pCntntSect( 0 ),
     182           0 :         bDelLastPara( bDelLP ), bIsLastParaDelete( bIsPD ), bIsVisible( bVsbl )
     183           0 :     {}
     184             :     SwRedline( const SwRedline& );
     185             :     virtual ~SwRedline();
     186             : 
     187         544 :     SwNodeIndex* GetContentIdx() const { return pCntntSect; }
     188             :     // For Undo.
     189             :     void SetContentIdx( const SwNodeIndex* );
     190             : 
     191        1493 :     sal_Bool IsVisible() const { return bIsVisible; }
     192           0 :     sal_Bool IsDelLastPara() const { return bDelLastPara; }
     193             : 
     194             :     // sal_Bool indicates whether after setting of Pos no range is spanned.
     195             :     // -> sal-True else range and sal-False.
     196           0 :     void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = 0 )
     197             :     {
     198           0 :         if( !pSttPtr ) pSttPtr = Start();
     199           0 :         *pSttPtr = rPos;
     200           0 :     }
     201         169 :     void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = 0 )
     202             :     {
     203         169 :         if( !pEndPtr ) pEndPtr = End();
     204         169 :         *pEndPtr = rPos;
     205         169 :     }
     206             :     /// Do we have a valid selection?
     207             :     sal_Bool HasValidRange() const;
     208             : 
     209             :     const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
     210             :     int operator==( const SwRedlineData& rCmp ) const
     211             :         { return *pRedlineData == rCmp; }
     212           0 :     int operator!=( const SwRedlineData& rCmp ) const
     213           0 :         { return *pRedlineData != rCmp; }
     214           0 :     void SetAutoFmtFlag()               { pRedlineData->SetAutoFmtFlag(); }
     215             : 
     216             :     sal_uInt16 GetStackCount() const;
     217             :     sal_uInt16 GetAuthor( sal_uInt16 nPos = 0) const;
     218             :     const String& GetAuthorString( sal_uInt16 nPos = 0 ) const;
     219             :     const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
     220             :     RedlineType_t GetRealType( sal_uInt16 nPos = 0 ) const;
     221        1424 :     RedlineType_t GetType( sal_uInt16 nPos = 0) const
     222        1424 :   { return ( (RedlineType_t)(GetRealType( nPos ) & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
     223             :     const String& GetComment( sal_uInt16 nPos = 0 ) const;
     224             : 
     225           0 :     void SetComment( const String& rS ) { pRedlineData->SetComment( rS ); }
     226             : 
     227             :     /** ExtraData gets copied, the pointer is therefor not taken over by
     228             :      *  the RedLineObject.*/
     229           0 :     void SetExtraData( const SwRedlineExtraData* pData )
     230           0 :         { pRedlineData->SetExtraData( pData ); }
     231           0 :     const SwRedlineExtraData* GetExtraData() const
     232           0 :         { return pRedlineData->GetExtraData(); }
     233             : 
     234             :     // For UI-side pooling of Redline-actions.
     235             :     // At the moment only used for Autoformat with Redline.
     236             :     // Value != 0 means there can be others!
     237           0 :     sal_uInt16 GetSeqNo() const             { return pRedlineData->GetSeqNo(); }
     238           0 :     void SetSeqNo( sal_uInt16 nNo )         { pRedlineData->SetSeqNo( nNo ); }
     239             : 
     240             :     // At Hide/ShowOriginal the list is traversed two times in order to
     241             :     // hide the Del-Redlines via Copy and Delete.
     242             :     // Otherwise at Move the attribution would be handled incorrectly.
     243             :     // All other callers must always give 0.
     244             :     void CallDisplayFunc( sal_uInt16 nLoop = 0 );
     245             :     void Show( sal_uInt16 nLoop = 0 );
     246             :     void Hide( sal_uInt16 nLoop = 0 );
     247             :     void ShowOriginal( sal_uInt16 nLoop = 0 );
     248             : 
     249             :     /// Calculates the intersection with text node number nNdIdx.
     250             :     void CalcStartEnd( sal_uLong nNdIdx, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
     251             : 
     252             :     /// Initiate the layout.
     253             :     void InvalidateRange();
     254             : 
     255         443 :     sal_Bool IsOwnRedline( const SwRedline& rRedl ) const
     256         443 :         { return GetAuthor() == rRedl.GetAuthor(); }
     257             :     sal_Bool CanCombine( const SwRedline& rRedl ) const;
     258             : 
     259             :     void PushData( const SwRedline& rRedl, sal_Bool bOwnAsNext = sal_True );
     260             :     sal_Bool PopData();
     261             : 
     262             :     /**
     263             :        Returns textual description of this a redline data element of
     264             :        this redline.
     265             : 
     266             :        @param nPos index of the redline data element to describe
     267             : 
     268             :        The textual description of the selected element contains the
     269             :        kind of redline and the possibly shortened text of the redline.
     270             : 
     271             :        @return textual description of the selected redline data element
     272             :      */
     273             :     String GetDescr(sal_uInt16 nPos = 0);
     274             : 
     275             :     int operator==( const SwRedline& ) const;
     276             :     int operator<( const SwRedline& ) const;
     277             : };
     278             : 
     279           0 : class SW_DLLPUBLIC SwRedlineHint : public SfxHint
     280             : {
     281             : #define SWREDLINE_INSERTED  1
     282             : #define SWREDLINE_REMOVED   2
     283             : #define SWREDLINE_FOCUS     3
     284             : #define SWREDLINE_CHANGED   4
     285             : #define SWREDLINE_LANGUAGE  5
     286             : 
     287             :     const SwRedline* pRedline;
     288             :     sal_Int16 nWhich;
     289             :     const SwView* pView;
     290             : 
     291             : public:
     292           0 :     SwRedlineHint( const SwRedline* p, sal_Int16 n, const SwView* pV = 0)
     293             :         : pRedline(p)
     294             :         , nWhich(n)
     295           0 :         , pView(pV)
     296           0 :         {}
     297             : 
     298             :     TYPEINFO();
     299             :     const SwRedline* GetRedline() const { return pRedline; }
     300             :     sal_Int16 Which() const { return nWhich; }
     301             :         const SwView* GetView() const { return pView; }
     302             : };
     303             : 
     304             : 
     305             : #endif
     306             : 
     307             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10