LCOV - code coverage report
Current view: top level - sw/source/core/inc - UndoAttribute.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 7 8 87.5 %
Date: 2014-04-11 Functions: 9 10 90.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 INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
      22             : 
      23             : #include <undobj.hxx>
      24             : #include <memory>
      25             : #include <rtl/ustring.hxx>
      26             : #include <svl/itemset.hxx>
      27             : #include <swtypes.hxx>
      28             : #include <calbck.hxx>
      29             : #include <set>
      30             : 
      31             : class SvxTabStopItem;
      32             : class SwFmt;
      33             : class SwFtnInfo;
      34             : class SwEndNoteInfo;
      35             : 
      36             : class SwUndoAttr : public SwUndo, private SwUndRng
      37             : {
      38             :     SfxItemSet m_AttrSet;                           // attributes for Redo
      39             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      40             :     const ::std::auto_ptr<SwHistory> m_pHistory;    // History for Undo
      41             :     ::std::auto_ptr<SwRedlineData> m_pRedlineData;  // Redlining
      42             :     ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
      43             :     SAL_WNODEPRECATED_DECLARATIONS_POP
      44             :     sal_uLong m_nNodeIndex;                         // Offset: for Redlining
      45             :     const SetAttrMode m_nInsertFlags;               // insert flags
      46             : 
      47             :     void RemoveIdx( SwDoc& rDoc );
      48             : 
      49             : public:
      50             :     SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags );
      51             :     SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags );
      52             : 
      53             :     virtual ~SwUndoAttr();
      54             : 
      55             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      56             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      57             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
      58             : 
      59             :     void SaveRedlineData( const SwPaM& rPam, sal_Bool bInsCntnt );
      60             : 
      61        8540 :     SwHistory& GetHistory() { return *m_pHistory; }
      62             : };
      63             : 
      64             : class SwUndoResetAttr : public SwUndo, private SwUndRng
      65             : {
      66             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      67             :     const ::std::auto_ptr<SwHistory> m_pHistory;
      68             :     SAL_WNODEPRECATED_DECLARATIONS_POP
      69             :     std::set<sal_uInt16> m_Ids;
      70             :     const sal_uInt16 m_nFormatId;             // Format-Id for Redo
      71             : 
      72             : public:
      73             :     SwUndoResetAttr( const SwPaM&, sal_uInt16 nFmtId );
      74             :     SwUndoResetAttr( const SwPosition&, sal_uInt16 nFmtId );
      75             : 
      76             :     virtual ~SwUndoResetAttr();
      77             : 
      78             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      79             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
      80             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
      81             : 
      82             :     void SetAttrs( const std::set<sal_uInt16> &rAttrs );
      83             : 
      84          16 :     SwHistory& GetHistory() { return *m_pHistory; }
      85             : };
      86             : 
      87             : class SwUndoFmtAttr : public SwUndo
      88             : {
      89             :     friend class SwUndoDefaultAttr;
      90             :     SwFmt * m_pFmt;
      91             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      92             :     ::std::auto_ptr<SfxItemSet> m_pOldSet;    // old attributes
      93             :     SAL_WNODEPRECATED_DECLARATIONS_POP
      94             :     sal_uLong m_nNodeIndex;
      95             :     const sal_uInt16 m_nFmtWhich;
      96             :     const bool m_bSaveDrawPt;
      97             : 
      98             :     bool IsFmtInDoc( SwDoc* );   //is the attribute format still in the Doc?
      99             :     void SaveFlyAnchor( bool bSaveDrawPt = false );
     100             :     // #i35443# - Add return value, type <bool>.
     101             :     // Return value indicates, if anchor attribute is restored.
     102             :     // Notes: - If anchor attribute is restored, all other existing attributes
     103             :     //          are also restored.
     104             :     //        - Anchor attribute isn't restored successfully, if it contains
     105             :     //          an invalid anchor position and all other existing attributes
     106             :     //          aren't restored.
     107             :     //          This situation occurs for undo of styles.
     108             :     bool RestoreFlyAnchor(::sw::UndoRedoContext & rContext);
     109             :     // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
     110             :     void Init();
     111             : 
     112             : public:
     113             :     // register at the Format and save old attributes
     114             :     // --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
     115             :     SwUndoFmtAttr( const SfxItemSet& rOldSet,
     116             :                    SwFmt& rFmt,
     117             :                    bool bSaveDrawPt = true );
     118             :     SwUndoFmtAttr( const SfxPoolItem& rItem,
     119             :                    SwFmt& rFmt,
     120             :                    bool bSaveDrawPt = true );
     121             : 
     122             :     virtual ~SwUndoFmtAttr();
     123             : 
     124             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     125             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     126             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     127             : 
     128             :     virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
     129             : 
     130             :     void PutAttr( const SfxPoolItem& rItem );
     131             :     SwFmt* GetFmt( SwDoc& rDoc );   // checks if it is still in the Doc!
     132             : };
     133             : 
     134             : // --> OD 2008-02-12 #newlistlevelattrs#
     135             : class SwUndoFmtResetAttr : public SwUndo
     136             : {
     137             :     public:
     138             :         SwUndoFmtResetAttr( SwFmt& rChangedFormat,
     139             :                             const sal_uInt16 nWhichId );
     140             :         virtual ~SwUndoFmtResetAttr();
     141             : 
     142             :         virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     143             :         virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     144             : 
     145             :     private:
     146             :         // format at which a certain attribute is reset.
     147             :         SwFmt * const m_pChangedFormat;
     148             :         // which ID of the reset attribute
     149             :         const sal_uInt16 m_nWhichId;
     150             :         // old attribute which has been reset - needed for undo.
     151             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     152             :         ::std::auto_ptr<SfxPoolItem> m_pOldItem;
     153             :         SAL_WNODEPRECATED_DECLARATIONS_POP
     154             : };
     155             : 
     156           2 : class SwUndoDontExpandFmt : public SwUndo
     157             : {
     158             :     const sal_uLong m_nNodeIndex;
     159             :     const sal_Int32 m_nContentIndex;
     160             : 
     161             : public:
     162             :     SwUndoDontExpandFmt( const SwPosition& rPos );
     163             : 
     164             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     165             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     166             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     167             : };
     168             : 
     169             : // helper class to receive changed attribute sets
     170         113 : class SwUndoFmtAttrHelper : public SwClient
     171             : {
     172             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     173             :     ::std::auto_ptr<SwUndoFmtAttr> m_pUndo;
     174             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     175             :     const bool m_bSaveDrawPt;
     176             : 
     177             : public:
     178             :     SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSaveDrawPt = true );
     179             : 
     180             :     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
     181             : 
     182         162 :     SwUndoFmtAttr* GetUndo() const  { return m_pUndo.get(); }
     183             :     // release the undo object (so it is not deleted here), and return it
     184          63 :     SwUndoFmtAttr* ReleaseUndo()    { return m_pUndo.release(); }
     185             : };
     186             : 
     187             : class SwUndoMoveLeftMargin : public SwUndo, private SwUndRng
     188             : {
     189             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     190             :     const ::std::auto_ptr<SwHistory> m_pHistory;
     191             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     192             :     const bool m_bModulus;
     193             : 
     194             : public:
     195             :     SwUndoMoveLeftMargin( const SwPaM&, sal_Bool bRight, bool bModulus );
     196             : 
     197             :     virtual ~SwUndoMoveLeftMargin();
     198             : 
     199             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     200             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     201             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     202             : 
     203           0 :     SwHistory& GetHistory() { return *m_pHistory; }
     204             : 
     205             : };
     206             : 
     207             : class SwUndoDefaultAttr : public SwUndo
     208             : {
     209             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     210             :     ::std::auto_ptr<SfxItemSet> m_pOldSet;        // the old attributes
     211             :     ::std::auto_ptr<SvxTabStopItem> m_pTabStop;
     212             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     213             : 
     214             : public:
     215             :     // registers at the format and saves old attributes
     216             :     SwUndoDefaultAttr( const SfxItemSet& rOldSet );
     217             : 
     218             :     virtual ~SwUndoDefaultAttr();
     219             : 
     220             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     221             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     222             : };
     223             : 
     224             : class SwUndoChangeFootNote : public SwUndo, private SwUndRng
     225             : {
     226             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     227             :     const ::std::auto_ptr<SwHistory> m_pHistory;
     228             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     229             :     const OUString m_Text;
     230             :     const sal_uInt16 m_nNumber;
     231             :     const bool m_bEndNote;
     232             : 
     233             : public:
     234             :     SwUndoChangeFootNote( const SwPaM& rRange, const OUString& rTxt,
     235             :                           sal_uInt16 nNum, bool bIsEndNote );
     236             :     virtual ~SwUndoChangeFootNote();
     237             : 
     238             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     239             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     240             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     241             : 
     242           2 :     SwHistory& GetHistory() { return *m_pHistory; }
     243             : };
     244             : 
     245             : class SwUndoFootNoteInfo : public SwUndo
     246             : {
     247             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     248             :     ::std::auto_ptr<SwFtnInfo> m_pFootNoteInfo;
     249             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     250             : 
     251             : public:
     252             :     SwUndoFootNoteInfo( const SwFtnInfo &rInfo );
     253             : 
     254             :     virtual ~SwUndoFootNoteInfo();
     255             : 
     256             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     257             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     258             : };
     259             : 
     260             : class SwUndoEndNoteInfo : public SwUndo
     261             : {
     262             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     263             :     ::std::auto_ptr<SwEndNoteInfo> m_pEndNoteInfo;
     264             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     265             : 
     266             : public:
     267             :     SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo );
     268             : 
     269             :     virtual ~SwUndoEndNoteInfo();
     270             : 
     271             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     272             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     273             : };
     274             : 
     275             : #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
     276             : 
     277             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10