LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/inc - UndoCore.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 0.0 %
Date: 2012-12-27 Functions: 0 17 0.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 SW_UNDOCORE_HXX
      21             : #define SW_UNDOCORE_HXX
      22             : 
      23             : #include <undobj.hxx>
      24             : #include <calbck.hxx>
      25             : 
      26             : class SfxItemSet;
      27             : class SwFmtColl;
      28             : class SwFmtAnchor;
      29             : class SdrMarkList;
      30             : class SwUndoDelete;
      31             : class SwRedlineSaveData;
      32             : class SwFmt;
      33             : 
      34             : namespace sw {
      35             :     class UndoManager;
      36             :     class IShellCursorSupplier;
      37             : }
      38             : 
      39           0 : class SwRedlineSaveDatas : public std::vector<SwRedlineSaveData*> {
      40             : public:
      41           0 :     ~SwRedlineSaveDatas() { DeleteAndDestroyAll(); }
      42             : 
      43             :     void DeleteAndDestroyAll();
      44             : };
      45             : 
      46             : namespace sw {
      47           0 : class SW_DLLPRIVATE UndoRedoContext
      48             :     : public SfxUndoContext
      49             : {
      50             : public:
      51           0 :     UndoRedoContext(SwDoc & rDoc, IShellCursorSupplier & rCursorSupplier)
      52             :         : m_rDoc(rDoc)
      53             :         , m_rCursorSupplier(rCursorSupplier)
      54             :         , m_pSelFmt(0)
      55           0 :         , m_pMarkList(0)
      56           0 :     { }
      57             : 
      58           0 :     SwDoc & GetDoc() const { return m_rDoc; }
      59             : 
      60           0 :     IShellCursorSupplier & GetCursorSupplier() { return m_rCursorSupplier; }
      61             : 
      62           0 :     void SetSelections(SwFrmFmt *const pSelFmt, SdrMarkList *const pMarkList)
      63             :     {
      64           0 :         m_pSelFmt = pSelFmt;
      65           0 :         m_pMarkList = pMarkList;
      66           0 :     }
      67           0 :     void GetSelections(SwFrmFmt *& o_rpSelFmt, SdrMarkList *& o_rpMarkList)
      68             :     {
      69           0 :         o_rpSelFmt = m_pSelFmt;
      70           0 :         o_rpMarkList = m_pMarkList;
      71           0 :     }
      72             : 
      73             : private:
      74             :     SwDoc & m_rDoc;
      75             :     IShellCursorSupplier & m_rCursorSupplier;
      76             :     SwFrmFmt * m_pSelFmt;
      77             :     SdrMarkList * m_pMarkList;
      78             : };
      79             : 
      80           0 : class SW_DLLPRIVATE RepeatContext
      81             :     : public SfxRepeatTarget
      82             : {
      83             : public:
      84           0 :     RepeatContext(SwDoc & rDoc, SwPaM & rPaM)
      85             :         : m_rDoc(rDoc)
      86             :         , m_pCurrentPaM(& rPaM)
      87           0 :         , m_bDeleteRepeated(false)
      88           0 :     { }
      89             : 
      90           0 :     SwDoc & GetDoc() const { return m_rDoc; }
      91             : 
      92           0 :     SwPaM & GetRepeatPaM()
      93             :     {
      94           0 :         return *m_pCurrentPaM;
      95             :     }
      96             : 
      97             : private:
      98             :     friend class ::sw::UndoManager;
      99             :     friend class ::SwUndoDelete;
     100             : 
     101             :     SwDoc & m_rDoc;
     102             :     SwPaM * m_pCurrentPaM;
     103             :     bool m_bDeleteRepeated; /// has a delete action been repeated?
     104             : };
     105             : 
     106             : } // namespace sw
     107             : 
     108             : class SwUndoFmtColl : public SwUndo, private SwUndRng
     109             : {
     110             :     String aFmtName;
     111             :     SwHistory* pHistory;
     112             :     SwFmtColl* pFmtColl;
     113             :     // for correct <ReDo(..)> and <Repeat(..)>
     114             :     // boolean, which indicates that the attributes are reseted at the nodes
     115             :     // before the format has been applied.
     116             :     const bool mbReset;
     117             :     // boolean, which indicates that the list attributes had been reseted at
     118             :     // the nodes before the format has been applied.
     119             :     const bool mbResetListAttrs;
     120             : 
     121             :     void DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM);
     122             : 
     123             : public:
     124             :     SwUndoFmtColl( const SwPaM&, SwFmtColl*,
     125             :                    const bool bReset,
     126             :                    const bool bResetListAttrs );
     127             :     virtual ~SwUndoFmtColl();
     128             : 
     129             :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     130             :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     131             :     virtual void RepeatImpl( ::sw::RepeatContext & );
     132             : 
     133             :     /**
     134             :        Returns the rewriter for this undo object.
     135             : 
     136             :        The rewriter contains one rule:
     137             : 
     138             :            $1 -> <name of format collection>
     139             : 
     140             :        <name of format collection> is the name of the format
     141             :        collection that is applied by the action recorded by this undo
     142             :        object.
     143             : 
     144             :        @return the rewriter for this undo object
     145             :     */
     146             :     virtual SwRewriter GetRewriter() const;
     147             : 
     148           0 :     SwHistory* GetHistory() { return pHistory; }
     149             : 
     150             : };
     151             : 
     152             : class SwUndoSetFlyFmt : public SwUndo, public SwClient
     153             : {
     154             :     SwFrmFmt* pFrmFmt;                  // saved FlyFormat
     155             :     SwFrmFmt* pOldFmt;
     156             :     SwFrmFmt* pNewFmt;
     157             :     SfxItemSet* pItemSet;               // the re-/ set attributes
     158             :     sal_uLong nOldNode, nNewNode;
     159             :     xub_StrLen nOldCntnt, nNewCntnt;
     160             :     sal_uInt16 nOldAnchorTyp, nNewAnchorTyp;
     161             :     sal_Bool bAnchorChgd;
     162             : 
     163             :     void PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem );
     164             :     void Modify( const SfxPoolItem*, const SfxPoolItem* );
     165             :     void GetAnchor( SwFmtAnchor& rAnhor, sal_uLong nNode, xub_StrLen nCntnt );
     166             : 
     167             : public:
     168             :     SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt );
     169             :     virtual ~SwUndoSetFlyFmt();
     170             : 
     171             :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     172             :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     173             : 
     174             :     virtual SwRewriter GetRewriter() const;
     175             :     void DeRegisterFromFormat( SwFmt& );
     176             : };
     177             : 
     178           0 : class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng
     179             : {
     180             :     short nOffset;
     181             : 
     182             : public:
     183             :     SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset );
     184             : 
     185             :     virtual void UndoImpl( ::sw::UndoRedoContext & );
     186             :     virtual void RedoImpl( ::sw::UndoRedoContext & );
     187             :     virtual void RepeatImpl( ::sw::RepeatContext & );
     188             : };
     189             : 
     190             : const int nUndoStringLength = 20;
     191             : 
     192             : /**
     193             :    Shortens a string to a maximum length.
     194             : 
     195             :    @param rStr      the string to be shortened
     196             :    @param nLength   the maximum length for rStr
     197             :    @param rFillStr  string to replace cut out characters with
     198             : 
     199             :    If rStr has less than nLength characters it will be returned unaltered.
     200             : 
     201             :    If rStr has more than nLength characters the following algorithm
     202             :    generates the shortened string:
     203             : 
     204             :        frontLength = (nLength - length(rFillStr)) / 2
     205             :        rearLength = nLength - length(rFillStr) - frontLength
     206             :        shortenedString = concat(<first frontLength characters of rStr,
     207             :                                 rFillStr,
     208             :                                 <last rearLength characters of rStr>)
     209             : 
     210             :    Preconditions:
     211             :       - nLength - length(rFillStr) >= 2
     212             : 
     213             :    @return the shortened string
     214             :  */
     215             : String
     216             : ShortenString(const String & rStr, xub_StrLen nLength, const String & rFillStr);
     217             : /**
     218             :    Denotes special characters in a string.
     219             : 
     220             :    The rStr is split into parts containing special characters and
     221             :    parts not containing special characters. In a part containing
     222             :    special characters all characters are equal. These parts are
     223             :    maximal.
     224             : 
     225             :    @param rStr     the string to denote in
     226             : 
     227             :    The resulting string is generated by concatenating the found
     228             :    parts. The parts without special characters are surrounded by
     229             :    "'". The parts containing special characters are denoted as "n x",
     230             :    where n is the length of the part and x is the representation of
     231             :    the special character (i. e. "tab(s)").
     232             : 
     233             :    @return the denoted string
     234             : */
     235             : String DenoteSpecialCharacters(const String & rStr);
     236             : 
     237             : #endif // SW_UNDOCORE_HXX
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10