LCOV - code coverage report
Current view: top level - sw/source/core/inc - UndoAttribute.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 8 75.0 %
Date: 2012-08-25 Functions: 7 10 70.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 6 33.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SW_UNDO_ATTRIBUTE_HXX
      30                 :            : #define SW_UNDO_ATTRIBUTE_HXX
      31                 :            : 
      32                 :            : #include <undobj.hxx>
      33                 :            : #include <memory>
      34                 :            : #include <svl/itemset.hxx>
      35                 :            : #include <swtypes.hxx>
      36                 :            : #include <calbck.hxx>
      37                 :            : #include <set>
      38                 :            : 
      39                 :            : class SvxTabStopItem;
      40                 :            : class SwFmt;
      41                 :            : class SwFtnInfo;
      42                 :            : class SwEndNoteInfo;
      43                 :            : 
      44                 :            : class SwUndoAttr : public SwUndo, private SwUndRng
      45                 :            : {
      46                 :            :     SfxItemSet m_AttrSet;                           // attributes for Redo
      47                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      48                 :            :     const ::std::auto_ptr<SwHistory> m_pHistory;    // History for Undo
      49                 :            :     ::std::auto_ptr<SwRedlineData> m_pRedlineData;  // Redlining
      50                 :            :     ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
      51                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
      52                 :            :     sal_uLong m_nNodeIndex;                         // Offset: for Redlining
      53                 :            :     const SetAttrMode m_nInsertFlags;               // insert flags
      54                 :            : 
      55                 :            :     void RemoveIdx( SwDoc& rDoc );
      56                 :            : 
      57                 :            : public:
      58                 :            :     SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags );
      59                 :            :     SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags );
      60                 :            : 
      61                 :            :     virtual ~SwUndoAttr();
      62                 :            : 
      63                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
      64                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
      65                 :            :     virtual void RepeatImpl( ::sw::RepeatContext & );
      66                 :            : 
      67                 :            :     void SaveRedlineData( const SwPaM& rPam, sal_Bool bInsCntnt );
      68                 :            : 
      69                 :       3536 :     SwHistory& GetHistory() { return *m_pHistory; }
      70                 :            : };
      71                 :            : 
      72                 :            : class SwUndoResetAttr : public SwUndo, private SwUndRng
      73                 :            : {
      74                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      75                 :            :     const ::std::auto_ptr<SwHistory> m_pHistory;
      76                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
      77                 :            :     std::set<sal_uInt16> m_Ids;
      78                 :            :     const sal_uInt16 m_nFormatId;             // Format-Id for Redo
      79                 :            : 
      80                 :            : public:
      81                 :            :     SwUndoResetAttr( const SwPaM&, sal_uInt16 nFmtId );
      82                 :            :     SwUndoResetAttr( const SwPosition&, sal_uInt16 nFmtId );
      83                 :            : 
      84                 :            :     virtual ~SwUndoResetAttr();
      85                 :            : 
      86                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
      87                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
      88                 :            :     virtual void RepeatImpl( ::sw::RepeatContext & );
      89                 :            : 
      90                 :            :     void SetAttrs( const std::set<sal_uInt16> &rAttrs );
      91                 :            : 
      92                 :         20 :     SwHistory& GetHistory() { return *m_pHistory; }
      93                 :            : };
      94                 :            : 
      95                 :            : class SwUndoFmtAttr : public SwUndo
      96                 :            : {
      97                 :            :     friend class SwUndoDefaultAttr;
      98                 :            :     SwFmt * m_pFmt;
      99                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     100                 :            :     ::std::auto_ptr<SfxItemSet> m_pOldSet;    // old attributes
     101                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     102                 :            :     sal_uLong m_nNodeIndex;
     103                 :            :     const sal_uInt16 m_nFmtWhich;
     104                 :            :     const bool m_bSaveDrawPt;
     105                 :            : 
     106                 :            :     bool IsFmtInDoc( SwDoc* );   //is the attribute format still in the Doc?
     107                 :            :     void SaveFlyAnchor( bool bSaveDrawPt = false );
     108                 :            :     // #i35443# - Add return value, type <bool>.
     109                 :            :     // Return value indicates, if anchor attribute is restored.
     110                 :            :     // Notes: - If anchor attribute is restored, all other existing attributes
     111                 :            :     //          are also restored.
     112                 :            :     //        - Anchor attribute isn't restored successfully, if it contains
     113                 :            :     //          an invalid anchor position and all other existing attributes
     114                 :            :     //          aren't restored.
     115                 :            :     //          This situation occurs for undo of styles.
     116                 :            :     bool RestoreFlyAnchor(::sw::UndoRedoContext & rContext);
     117                 :            :     // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
     118                 :            :     void Init();
     119                 :            : 
     120                 :            : public:
     121                 :            :     // register at the Format and save old attributes
     122                 :            :     // --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
     123                 :            :     SwUndoFmtAttr( const SfxItemSet& rOldSet,
     124                 :            :                    SwFmt& rFmt,
     125                 :            :                    bool bSaveDrawPt = true );
     126                 :            :     SwUndoFmtAttr( const SfxPoolItem& rItem,
     127                 :            :                    SwFmt& rFmt,
     128                 :            :                    bool bSaveDrawPt = true );
     129                 :            : 
     130                 :            :     virtual ~SwUndoFmtAttr();
     131                 :            : 
     132                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     133                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     134                 :            :     virtual void RepeatImpl( ::sw::RepeatContext & );
     135                 :            : 
     136                 :            :     virtual SwRewriter GetRewriter() const;
     137                 :            : 
     138                 :            :     void PutAttr( const SfxPoolItem& rItem );
     139                 :            :     SwFmt* GetFmt( SwDoc& rDoc );   // checks if it is still in the Doc!
     140                 :            : };
     141                 :            : 
     142                 :            : // --> OD 2008-02-12 #newlistlevelattrs#
     143                 :            : class SwUndoFmtResetAttr : public SwUndo
     144                 :            : {
     145                 :            :     public:
     146                 :            :         SwUndoFmtResetAttr( SwFmt& rChangedFormat,
     147                 :            :                             const sal_uInt16 nWhichId );
     148                 :            :         ~SwUndoFmtResetAttr();
     149                 :            : 
     150                 :            :         virtual void UndoImpl( ::sw::UndoRedoContext & );
     151                 :            :         virtual void RedoImpl( ::sw::UndoRedoContext & );
     152                 :            : 
     153                 :            :     private:
     154                 :            :         // format at which a certain attribute is reset.
     155                 :            :         SwFmt * const m_pChangedFormat;
     156                 :            :         // which ID of the reset attribute
     157                 :            :         const sal_uInt16 m_nWhichId;
     158                 :            :         // old attribute which has been reset - needed for undo.
     159                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     160                 :            :         ::std::auto_ptr<SfxPoolItem> m_pOldItem;
     161                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
     162                 :            : };
     163                 :            : 
     164         [ #  # ]:          0 : class SwUndoDontExpandFmt : public SwUndo
     165                 :            : {
     166                 :            :     const sal_uLong m_nNodeIndex;
     167                 :            :     const xub_StrLen m_nContentIndex;
     168                 :            : 
     169                 :            : public:
     170                 :            :     SwUndoDontExpandFmt( const SwPosition& rPos );
     171                 :            : 
     172                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     173                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     174                 :            :     virtual void RepeatImpl( ::sw::RepeatContext & );
     175                 :            : };
     176                 :            : 
     177                 :            : // helper class to receive changed attribute sets
     178 [ +  - ][ -  + ]:        114 : class SwUndoFmtAttrHelper : public SwClient
     179                 :            : {
     180                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     181                 :            :     ::std::auto_ptr<SwUndoFmtAttr> m_pUndo;
     182                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     183                 :            :     const bool m_bSaveDrawPt;
     184                 :            : 
     185                 :            : public:
     186                 :            :     SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSaveDrawPt = true );
     187                 :            : 
     188                 :            :     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
     189                 :            : 
     190                 :        214 :     SwUndoFmtAttr* GetUndo() const  { return m_pUndo.get(); }
     191                 :            :     // release the undo object (so it is not deleted here), and return it
     192                 :        100 :     SwUndoFmtAttr* ReleaseUndo()    { return m_pUndo.release(); }
     193                 :            : };
     194                 :            : 
     195                 :            : class SwUndoMoveLeftMargin : public SwUndo, private SwUndRng
     196                 :            : {
     197                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     198                 :            :     const ::std::auto_ptr<SwHistory> m_pHistory;
     199                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     200                 :            :     const bool m_bModulus;
     201                 :            : 
     202                 :            : public:
     203                 :            :     SwUndoMoveLeftMargin( const SwPaM&, sal_Bool bRight, sal_Bool bModulus );
     204                 :            : 
     205                 :            :     virtual ~SwUndoMoveLeftMargin();
     206                 :            : 
     207                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     208                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     209                 :            :     virtual void RepeatImpl( ::sw::RepeatContext & );
     210                 :            : 
     211                 :          0 :     SwHistory& GetHistory() { return *m_pHistory; }
     212                 :            : 
     213                 :            : };
     214                 :            : 
     215                 :            : class SwUndoDefaultAttr : public SwUndo
     216                 :            : {
     217                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     218                 :            :     ::std::auto_ptr<SfxItemSet> m_pOldSet;        // the old attributes
     219                 :            :     ::std::auto_ptr<SvxTabStopItem> m_pTabStop;
     220                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     221                 :            : 
     222                 :            : public:
     223                 :            :     // registers at the format and saves old attributes
     224                 :            :     SwUndoDefaultAttr( const SfxItemSet& rOldSet );
     225                 :            : 
     226                 :            :     virtual ~SwUndoDefaultAttr();
     227                 :            : 
     228                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     229                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     230                 :            : };
     231                 :            : 
     232                 :            : class SwUndoChangeFootNote : public SwUndo, private SwUndRng
     233                 :            : {
     234                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     235                 :            :     const ::std::auto_ptr<SwHistory> m_pHistory;
     236                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     237                 :            :     const String m_Text;
     238                 :            :     const sal_uInt16 m_nNumber;
     239                 :            :     const bool m_bEndNote;
     240                 :            : 
     241                 :            : public:
     242                 :            :     SwUndoChangeFootNote( const SwPaM& rRange, const String& rTxt,
     243                 :            :                           sal_uInt16 nNum, bool bIsEndNote );
     244                 :            :     virtual ~SwUndoChangeFootNote();
     245                 :            : 
     246                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     247                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     248                 :            :     virtual void RepeatImpl( ::sw::RepeatContext & );
     249                 :            : 
     250                 :          4 :     SwHistory& GetHistory() { return *m_pHistory; }
     251                 :            : };
     252                 :            : 
     253                 :            : class SwUndoFootNoteInfo : public SwUndo
     254                 :            : {
     255                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     256                 :            :     ::std::auto_ptr<SwFtnInfo> m_pFootNoteInfo;
     257                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     258                 :            : 
     259                 :            : public:
     260                 :            :     SwUndoFootNoteInfo( const SwFtnInfo &rInfo );
     261                 :            : 
     262                 :            :     virtual ~SwUndoFootNoteInfo();
     263                 :            : 
     264                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     265                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     266                 :            : };
     267                 :            : 
     268                 :            : class SwUndoEndNoteInfo : public SwUndo
     269                 :            : {
     270                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     271                 :            :     ::std::auto_ptr<SwEndNoteInfo> m_pEndNoteInfo;
     272                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     273                 :            : 
     274                 :            : public:
     275                 :            :     SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo );
     276                 :            : 
     277                 :            :     virtual ~SwUndoEndNoteInfo();
     278                 :            : 
     279                 :            :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     280                 :            :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     281                 :            : };
     282                 :            : 
     283                 :            : #endif // SW_UNDO_ATTRIBUTE_HXX
     284                 :            : 
     285                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10