LCOV - code coverage report
Current view: top level - sw/inc - redline.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 53 82 64.6 %
Date: 2014-11-03 Functions: 26 41 63.4 %
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_REDLINE_HXX
      20             : #define INCLUDED_SW_INC_REDLINE_HXX
      21             : 
      22             : #include <tools/datetime.hxx>
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : #include <pam.hxx>
      26             : #include <swtable.hxx>
      27             : 
      28             : #include <IDocumentRedlineAccess.hxx>
      29             : 
      30             : #include <svl/smplhint.hxx>
      31             : #include <vector>
      32             : 
      33             : class SfxItemSet;
      34             : class SwView;
      35             : 
      36             : class SW_DLLPUBLIC SwRedlineExtraData
      37             : {
      38             :     SwRedlineExtraData( const SwRedlineExtraData& );
      39             :     SwRedlineExtraData& operator=( const SwRedlineExtraData& );
      40             : 
      41             : protected:
      42        3228 :     SwRedlineExtraData() {}
      43             : 
      44             : public:
      45             :     virtual ~SwRedlineExtraData();
      46             :     virtual SwRedlineExtraData* CreateNew() const = 0;
      47             : 
      48             :     virtual void Accept( SwPaM& rPam ) const;
      49             :     virtual void Reject( SwPaM& rPam ) const;
      50             :     virtual bool operator == ( const SwRedlineExtraData& ) const;
      51             : };
      52             : 
      53             : class SwRedlineExtraData_FmtColl : public SwRedlineExtraData
      54             : {
      55             :     OUString sFmtNm;
      56             :     SfxItemSet* pSet;
      57             :     sal_uInt16 nPoolId;
      58             : public:
      59             :     SwRedlineExtraData_FmtColl( const OUString& rColl, sal_uInt16 nPoolFmtId,
      60             :                                 const SfxItemSet* pSet = 0 );
      61             :     virtual ~SwRedlineExtraData_FmtColl();
      62             :     virtual SwRedlineExtraData* CreateNew() const SAL_OVERRIDE;
      63             :     virtual void Reject( SwPaM& rPam ) const SAL_OVERRIDE;
      64             :     virtual bool operator == ( const SwRedlineExtraData& ) const SAL_OVERRIDE;
      65             : 
      66             :     void SetItemSet( const SfxItemSet& rSet );
      67             : };
      68             : 
      69             : class SwRedlineExtraData_Format : public SwRedlineExtraData
      70             : {
      71             :     std::vector<sal_uInt16> aWhichIds;
      72             : 
      73             :     SwRedlineExtraData_Format( const SwRedlineExtraData_Format& rCpy );
      74             : 
      75             : public:
      76             :     SwRedlineExtraData_Format( const SfxItemSet& rSet );
      77             :     virtual ~SwRedlineExtraData_Format();
      78             :     virtual SwRedlineExtraData* CreateNew() const SAL_OVERRIDE;
      79             :     virtual void Reject( SwPaM& rPam ) const SAL_OVERRIDE;
      80             :     virtual bool operator == ( const SwRedlineExtraData& ) const SAL_OVERRIDE;
      81             : };
      82             : 
      83             : /*
      84             :  * This class is used to store 'redline' data regarding formatting changes,
      85             :  * e.g. - a text portion *was* italic and now is not italic,
      86             :  * e.g. - a text portion got a hightlight to it
      87             :  *
      88             :  * The way the information is stored is in an 'SfxItemSet' that holds all
      89             :  * the WhichIds with their values.
      90             :  */
      91             : class SW_DLLPUBLIC SwRedlineExtraData_FormattingChanges : public SwRedlineExtraData
      92             : {
      93             :     SfxItemSet* pSet;
      94             : 
      95             :     SwRedlineExtraData_FormattingChanges( const SwRedlineExtraData_FormattingChanges& rCpy );
      96             : 
      97             : public:
      98             :     SwRedlineExtraData_FormattingChanges( const SfxItemSet* pItemSet );
      99             :     virtual ~SwRedlineExtraData_FormattingChanges();
     100             :     virtual SwRedlineExtraData* CreateNew() const SAL_OVERRIDE;
     101             :     virtual void Reject( SwPaM& rPam ) const SAL_OVERRIDE;
     102             :     virtual bool operator == ( const SwRedlineExtraData& ) const SAL_OVERRIDE;
     103          16 :     SfxItemSet* GetItemSet( ) const { return pSet; }
     104             : };
     105             : 
     106             : class SW_DLLPUBLIC SwRedlineData
     107             : {
     108             :     friend class SwRangeRedline;
     109             :     SwRedlineData* pNext;       // Points to other data.
     110             :     SwRedlineExtraData* pExtraData;
     111             : 
     112             :     OUString sComment;
     113             :     DateTime aStamp;
     114             :     RedlineType_t eType;
     115             :     sal_uInt16 nAuthor, nSeqNo;
     116             : 
     117             : public:
     118             :     SwRedlineData( RedlineType_t eT, sal_uInt16 nAut );
     119             :     SwRedlineData( const SwRedlineData& rCpy, bool bCpyNext = true );
     120             : 
     121             :     // For sw3io: pNext/pExtraData are taken over.
     122             :     SwRedlineData( RedlineType_t eT, sal_uInt16 nAut, const DateTime& rDT,
     123             :                    const OUString& rCmnt, SwRedlineData* pNxt,
     124             :                     SwRedlineExtraData* pExtraData = 0 );
     125             : 
     126             :     ~SwRedlineData();
     127             : 
     128           0 :     bool operator==( const SwRedlineData& rCmp ) const
     129             :         {
     130           0 :             return nAuthor == rCmp.nAuthor &&
     131           0 :                     eType == rCmp.eType &&
     132           0 :                     sComment == rCmp.sComment &&
     133           0 :                     (( !pNext && !rCmp.pNext ) ||
     134           0 :                         ( pNext && rCmp.pNext && *pNext == *rCmp.pNext )) &&
     135           0 :                     (( !pExtraData && !rCmp.pExtraData ) ||
     136           0 :                         ( pExtraData && rCmp.pExtraData &&
     137           0 :                             *pExtraData == *rCmp.pExtraData ));
     138             :         }
     139           0 :     bool operator!=( const SwRedlineData& rCmp ) const
     140           0 :         {   return !operator==( rCmp ); }
     141             : 
     142        1374 :     RedlineType_t GetType() const
     143        1374 :   { return ((RedlineType_t)(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
     144             :     RedlineType_t GetRealType() const { return eType; }
     145          94 :     sal_uInt16 GetAuthor() const                { return nAuthor; }
     146           6 :     const OUString& GetComment() const        { return sComment; }
     147        6576 :     const DateTime& GetTimeStamp() const    { return aStamp; }
     148          10 :     inline const SwRedlineData* Next() const{ return pNext; }
     149             : 
     150           0 :     void SetComment( const OUString& rS )     { sComment = rS; }
     151        2944 :     void SetTimeStamp( const DateTime& rDT ) { aStamp = rDT; }
     152             : 
     153           0 :     void SetAutoFmtFlag()
     154           0 :   { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); }
     155        5618 :     bool CanCombine( const SwRedlineData& rCmp ) const
     156             :         {
     157        9571 :             return nAuthor == rCmp.nAuthor &&
     158        7194 :                     eType == rCmp.eType &&
     159        6482 :                     sComment == rCmp.sComment &&
     160        6110 :                     GetTimeStamp() == rCmp.GetTimeStamp() &&
     161        5738 :                     (( !pNext && !rCmp.pNext ) ||
     162           0 :                         ( pNext && rCmp.pNext &&
     163       10864 :                         pNext->CanCombine( *rCmp.pNext ))) &&
     164        4372 :                     (( !pExtraData && !rCmp.pExtraData ) ||
     165        2684 :                         ( pExtraData && rCmp.pExtraData &&
     166        6960 :                             *pExtraData == *rCmp.pExtraData ));
     167             :         }
     168             : 
     169             :     // ExtraData gets copied, the pointer is therefore not taken over by
     170             :     // the RedlilneObject
     171             :     void SetExtraData( const SwRedlineExtraData* pData );
     172          34 :     const SwRedlineExtraData* GetExtraData() const { return pExtraData; }
     173             : 
     174             :     // For UI-side pooling of Redline-actions.
     175             :     // At the moment only used for Autoformat with Redline.
     176             :     // Value != 0 means there can be others!
     177          46 :     sal_uInt16 GetSeqNo() const                     { return nSeqNo; }
     178           0 :     void SetSeqNo( sal_uInt16 nNo )                 { nSeqNo = nNo; }
     179             : 
     180             :     OUString GetDescr() const;
     181             : };
     182             : 
     183             : class SW_DLLPUBLIC SwRangeRedline : public SwPaM
     184             : {
     185             :     SwRedlineData* pRedlineData;
     186             :     SwNodeIndex* pCntntSect;
     187             :     bool bDelLastPara : 1;
     188             :     bool bIsLastParaDelete : 1;
     189             :     bool bIsVisible : 1;
     190             : 
     191             :     void MoveToSection();
     192             :     void CopyToSection();
     193             :     void DelCopyOfSection();
     194             :     void MoveFromSection();
     195             : 
     196             : public:
     197             :     SwRangeRedline( RedlineType_t eType, const SwPaM& rPam );
     198             :     SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam );
     199             :     SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos );
     200             :     // For sw3io: pData is taken over!
     201          20 :     SwRangeRedline(SwRedlineData* pData, const SwPosition& rPos, bool bVsbl,
     202             :                bool bDelLP, bool bIsPD) :
     203             :         SwPaM( rPos ), pRedlineData( pData ), pCntntSect( 0 ),
     204          20 :         bDelLastPara( bDelLP ), bIsLastParaDelete( bIsPD ), bIsVisible( bVsbl )
     205          20 :     {}
     206             :     SwRangeRedline( const SwRangeRedline& );
     207             :     virtual ~SwRangeRedline();
     208             : 
     209        4177 :     SwNodeIndex* GetContentIdx() const { return pCntntSect; }
     210             :     // For Undo.
     211             :     void SetContentIdx( const SwNodeIndex* );
     212             : 
     213       11280 :     bool IsVisible() const { return bIsVisible; }
     214           0 :     bool IsDelLastPara() const { return bDelLastPara; }
     215             : 
     216             :     // sal_Bool indicates whether after setting of Pos no range is spanned.
     217             :     // -> sal-True else range and sal-False.
     218         730 :     void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = 0 )
     219             :     {
     220         730 :         if( !pSttPtr ) pSttPtr = Start();
     221         730 :         *pSttPtr = rPos;
     222         730 :     }
     223        1503 :     void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = 0 )
     224             :     {
     225        1503 :         if( !pEndPtr ) pEndPtr = End();
     226        1503 :         *pEndPtr = rPos;
     227        1503 :     }
     228             :     /// Do we have a valid selection?
     229             :     bool HasValidRange() const;
     230             : 
     231             :     const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
     232             :     bool operator==( const SwRedlineData& rCmp ) const
     233             :         { return *pRedlineData == rCmp; }
     234           0 :     bool operator!=( const SwRedlineData& rCmp ) const
     235           0 :         { return *pRedlineData != rCmp; }
     236           0 :     void SetAutoFmtFlag()               { pRedlineData->SetAutoFmtFlag(); }
     237             : 
     238             :     sal_uInt16 GetStackCount() const;
     239             :     sal_uInt16 GetAuthor( sal_uInt16 nPos = 0) const;
     240             :     OUString GetAuthorString( sal_uInt16 nPos = 0 ) const;
     241             :     const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
     242             :     RedlineType_t GetRealType( sal_uInt16 nPos = 0 ) const;
     243      333803 :     RedlineType_t GetType( sal_uInt16 nPos = 0) const
     244      333803 :         { return ( (RedlineType_t)(GetRealType( nPos ) & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
     245             :     const OUString& GetComment( sal_uInt16 nPos = 0 ) const;
     246             : 
     247           0 :     void SetComment( const OUString& rS ) { pRedlineData->SetComment( rS ); }
     248             : 
     249             :     /** ExtraData gets copied, the pointer is therefore not taken over by
     250             :      *  the RedLineObject.*/
     251        2876 :     void SetExtraData( const SwRedlineExtraData* pData )
     252        2876 :         { pRedlineData->SetExtraData( pData ); }
     253           0 :     const SwRedlineExtraData* GetExtraData() const
     254           0 :         { return pRedlineData->GetExtraData(); }
     255             : 
     256             :     // For UI-side pooling of Redline-actions.
     257             :     // At the moment only used for Autoformat with Redline.
     258             :     // Value != 0 means there can be others!
     259           0 :     sal_uInt16 GetSeqNo() const             { return pRedlineData->GetSeqNo(); }
     260           0 :     void SetSeqNo( sal_uInt16 nNo )         { pRedlineData->SetSeqNo( nNo ); }
     261             : 
     262             :     // At Hide/ShowOriginal the list is traversed two times in order to
     263             :     // hide the Del-Redlines via Copy and Delete.
     264             :     // Otherwise at Move the attribution would be handled incorrectly.
     265             :     // All other callers must always give 0.
     266             :     void CallDisplayFunc( sal_uInt16 nLoop = 0 );
     267             :     void Show( sal_uInt16 nLoop = 0 );
     268             :     void Hide( sal_uInt16 nLoop = 0 );
     269             :     void ShowOriginal( sal_uInt16 nLoop = 0 );
     270             : 
     271             :     /// Calculates the intersection with text node number nNdIdx.
     272             :     void CalcStartEnd(sal_uLong nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) const;
     273             : 
     274             :     /// Initiate the layout.
     275             :     void InvalidateRange();
     276             : 
     277       21806 :     bool IsOwnRedline( const SwRangeRedline& rRedl ) const
     278       21806 :         { return GetAuthor() == rRedl.GetAuthor(); }
     279             :     bool CanCombine( const SwRangeRedline& rRedl ) const;
     280             : 
     281             :     void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
     282             :     bool PopData();
     283             : 
     284             :     /**
     285             :        Returns textual description of this a redline data element of
     286             :        this redline.
     287             : 
     288             :        @param nPos index of the redline data element to describe
     289             : 
     290             :        The textual description of the selected element contains the
     291             :        kind of redline and the possibly shortened text of the redline.
     292             : 
     293             :        @return textual description of the selected redline data element
     294             :      */
     295             :     OUString GetDescr(sal_uInt16 nPos = 0);
     296             : 
     297             :     bool operator==( const SwRangeRedline& ) const;
     298             :     bool operator<( const SwRangeRedline& ) const;
     299             : };
     300             : 
     301             : /// Base object for 'Redlines' that are not of 'Ranged' type (like table row insert\delete)
     302          68 : class SW_DLLPUBLIC SwExtraRedline : private boost::noncopyable
     303             : {
     304             : public:
     305             :     virtual ~SwExtraRedline();
     306             : };
     307             : 
     308             : /// Redline that holds information about a table-row that had some change
     309             : class SW_DLLPUBLIC SwTableRowRedline : public SwExtraRedline
     310             : {
     311             : private:
     312             :     SwRedlineData m_aRedlineData;
     313             :     const SwTableLine& m_rTableLine;
     314             : 
     315             : public:
     316             :     SwTableRowRedline(const SwRedlineData& rData, const SwTableLine& rTableLine);
     317             :     virtual ~SwTableRowRedline();
     318             : 
     319             :     /** ExtraData gets copied, the pointer is therefore not taken over by
     320             :      *  the RedLineObject.*/
     321          56 :     void SetExtraData( const SwRedlineExtraData* pData )
     322          56 :         { m_aRedlineData.SetExtraData( pData ); }
     323             :     const SwRedlineExtraData* GetExtraData() const
     324             :         { return m_aRedlineData.GetExtraData(); }
     325          12 :     const SwTableLine& GetTableLine() const
     326          12 :         { return m_rTableLine; }
     327           4 :     const SwRedlineData& GetRedlineData() const
     328           4 :         { return m_aRedlineData; }
     329             : };
     330             : 
     331             : /// Redline that holds information about a table-cell that had some change
     332             : class SW_DLLPUBLIC SwTableCellRedline : public SwExtraRedline
     333             : {
     334             : private:
     335             :     SwRedlineData m_aRedlineData;
     336             :     const SwTableBox& m_rTableBox;
     337             : 
     338             : public:
     339             :     SwTableCellRedline(const SwRedlineData& rData, const SwTableBox& rTableBox);
     340             :     virtual ~SwTableCellRedline();
     341             : 
     342             :     /** ExtraData gets copied, the pointer is therefore not taken over by
     343             :      *  the RedLineObject.*/
     344          12 :     void SetExtraData( const SwRedlineExtraData* pData )
     345          12 :         { m_aRedlineData.SetExtraData( pData ); }
     346             :     const SwRedlineExtraData* GetExtraData() const
     347             :         { return m_aRedlineData.GetExtraData(); }
     348          36 :     const SwTableBox& GetTableBox() const
     349          36 :         { return m_rTableBox; }
     350           4 :     const SwRedlineData& GetRedlineData() const
     351           4 :         { return m_aRedlineData; }
     352             : };
     353             : 
     354           0 : class SW_DLLPUBLIC SwRedlineHint : public SfxHint
     355             : {
     356             : #define SWREDLINE_INSERTED  1
     357             : #define SWREDLINE_REMOVED   2
     358             : #define SWREDLINE_FOCUS     3
     359             : #define SWREDLINE_CHANGED   4
     360             : #define SWREDLINE_LANGUAGE  5
     361             : 
     362             :     const SwRangeRedline* pRedline;
     363             :     sal_Int16 nWhich;
     364             :     const SwView* pView;
     365             : 
     366             : public:
     367           0 :     SwRedlineHint( const SwRangeRedline* p, sal_Int16 n, const SwView* pV = 0)
     368             :         : pRedline(p)
     369             :         , nWhich(n)
     370           0 :         , pView(pV)
     371           0 :         {}
     372             : 
     373             :     const SwRangeRedline* GetRedline() const { return pRedline; }
     374             :     sal_Int16 Which() const { return nWhich; }
     375             :         const SwView* GetView() const { return pView; }
     376             : };
     377             : 
     378             : #endif
     379             : 
     380             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10