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

Generated by: LCOV version 1.11