LCOV - code coverage report
Current view: top level - sw/source/core/inc - UndoAttribute.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 7 8 87.5 %
Date: 2014-11-03 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             :     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 bInsCntnt );
      58             : 
      59       18542 :     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 nFmtId );
      70             :     SwUndoResetAttr( const SwPosition&, sal_uInt16 nFmtId );
      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          32 :     SwHistory& GetHistory() { return *m_pHistory; }
      81             : };
      82             : 
      83             : class SwUndoFmtAttr : public SwUndo
      84             : {
      85             :     friend class SwUndoDefaultAttr;
      86             :     SwFmt * m_pFmt;
      87             :     ::std::unique_ptr<SfxItemSet> m_pOldSet;    // old attributes
      88             :     sal_uLong m_nNodeIndex;
      89             :     const sal_uInt16 m_nFmtWhich;
      90             :     const bool m_bSaveDrawPt;
      91             : 
      92             :     bool IsFmtInDoc( 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             :     SwUndoFmtAttr( const SfxItemSet& rOldSet,
     110             :                    SwFmt& rFmt,
     111             :                    bool bSaveDrawPt = true );
     112             :     SwUndoFmtAttr( const SfxPoolItem& rItem,
     113             :                    SwFmt& rFmt,
     114             :                    bool bSaveDrawPt = true );
     115             : 
     116             :     virtual ~SwUndoFmtAttr();
     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             :     SwFmt* GetFmt( SwDoc& rDoc );   // checks if it is still in the Doc!
     126             : };
     127             : 
     128             : // --> OD 2008-02-12 #newlistlevelattrs#
     129             : class SwUndoFmtResetAttr : public SwUndo
     130             : {
     131             :     public:
     132             :         SwUndoFmtResetAttr( SwFmt& rChangedFormat,
     133             :                             const sal_uInt16 nWhichId );
     134             :         virtual ~SwUndoFmtResetAttr();
     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             :         SwFmt * 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           4 : class SwUndoDontExpandFmt : public SwUndo
     149             : {
     150             :     const sal_uLong m_nNodeIndex;
     151             :     const sal_Int32 m_nContentIndex;
     152             : 
     153             : public:
     154             :     SwUndoDontExpandFmt( 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         196 : class SwUndoFmtAttrHelper : public SwClient
     163             : {
     164             :     ::std::unique_ptr<SwUndoFmtAttr> m_pUndo;
     165             :     const bool m_bSaveDrawPt;
     166             : 
     167             : public:
     168             :     SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSaveDrawPt = true );
     169             : 
     170             :     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
     171             : 
     172         318 :     SwUndoFmtAttr* GetUndo() const  { return m_pUndo.get(); }
     173             :     // release the undo object (so it is not deleted here), and return it
     174         142 :     SwUndoFmtAttr* 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& rTxt,
     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           4 :     SwHistory& GetHistory() { return *m_pHistory; }
     227             : };
     228             : 
     229             : class SwUndoFootNoteInfo : public SwUndo
     230             : {
     231             :     ::std::unique_ptr<SwFtnInfo> m_pFootNoteInfo;
     232             : 
     233             : public:
     234             :     SwUndoFootNoteInfo( const SwFtnInfo &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.10