LCOV - code coverage report
Current view: top level - sw/source/core/inc - UndoCore.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 21 33 63.6 %
Date: 2015-06-13 12:38:46 Functions: 15 24 62.5 %
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_UNDOCORE_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_INC_UNDOCORE_HXX
      22             : 
      23             : #include <undobj.hxx>
      24             : #include <calbck.hxx>
      25             : #include <rtl/ustring.hxx>
      26             : #include <redline.hxx>
      27             : 
      28             : class SfxItemSet;
      29             : class SwFormatColl;
      30             : class SwFormatAnchor;
      31             : class SdrMarkList;
      32             : class SwUndoDelete;
      33             : class SwFormat;
      34             : 
      35             : namespace sw {
      36             :     class UndoManager;
      37             :     class IShellCursorSupplier;
      38             : }
      39             : 
      40             : class SwRedlineSaveData: public SwUndRng, public SwRedlineData, private SwUndoSaveSection
      41             : {
      42             : public:
      43             :     SwRedlineSaveData(
      44             :         SwComparePosition eCmpPos,
      45             :         const SwPosition& rSttPos,
      46             :         const SwPosition& rEndPos,
      47             :         SwRangeRedline& rRedl,
      48             :         bool bCopyNext );
      49             : 
      50             :     ~SwRedlineSaveData();
      51             : 
      52             :     void RedlineToDoc( SwPaM& rPam );
      53             : 
      54          12 :     SwNodeIndex* GetMvSttIdx() const
      55             :     {
      56          12 :         return SwUndoSaveSection::GetMvSttIdx();
      57             :     }
      58             : 
      59             : #if OSL_DEBUG_LEVEL > 0
      60             :     sal_uInt16 nRedlineCount;
      61             : #endif
      62             : };
      63             : 
      64          67 : class SwRedlineSaveDatas {
      65             : private:
      66             :     boost::ptr_vector<SwRedlineSaveData> mvData;
      67             : 
      68             : public:
      69          67 :     SwRedlineSaveDatas() : mvData() {}
      70             : 
      71          67 :     void clear() { mvData.clear(); }
      72         134 :     bool empty() const { return mvData.empty(); }
      73          11 :     size_t size() const { return mvData.size(); }
      74          12 :     void push_back (SwRedlineSaveData* value) { mvData.push_back(value); }
      75          10 :     const SwRedlineSaveData& operator[]( size_t nIdx ) const { return mvData[ nIdx ]; }
      76           2 :     SwRedlineSaveData& operator[]( size_t nIdx ) { return mvData[ nIdx ]; }
      77             : };
      78             : 
      79             : namespace sw {
      80          38 : class UndoRedoContext
      81             :     : public SfxUndoContext
      82             : {
      83             : public:
      84          38 :     UndoRedoContext(SwDoc & rDoc, IShellCursorSupplier & rCursorSupplier)
      85             :         : m_rDoc(rDoc)
      86             :         , m_rCursorSupplier(rCursorSupplier)
      87             :         , m_pSelFormat(0)
      88          38 :         , m_pMarkList(0)
      89          38 :     { }
      90             : 
      91          37 :     SwDoc & GetDoc() const { return m_rDoc; }
      92             : 
      93          10 :     IShellCursorSupplier & GetCursorSupplier() { return m_rCursorSupplier; }
      94             : 
      95           0 :     void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList)
      96             :     {
      97           0 :         m_pSelFormat = pSelFormat;
      98           0 :         m_pMarkList = pMarkList;
      99           0 :     }
     100          33 :     void GetSelections(SwFrameFormat *& o_rpSelFormat, SdrMarkList *& o_rpMarkList)
     101             :     {
     102          33 :         o_rpSelFormat = m_pSelFormat;
     103          33 :         o_rpMarkList = m_pMarkList;
     104          33 :     }
     105             : 
     106             : private:
     107             :     SwDoc & m_rDoc;
     108             :     IShellCursorSupplier & m_rCursorSupplier;
     109             :     SwFrameFormat * m_pSelFormat;
     110             :     SdrMarkList * m_pMarkList;
     111             : };
     112             : 
     113           0 : class RepeatContext
     114             :     : public SfxRepeatTarget
     115             : {
     116             : public:
     117           0 :     RepeatContext(SwDoc & rDoc, SwPaM & rPaM)
     118             :         : m_rDoc(rDoc)
     119             :         , m_pCurrentPaM(& rPaM)
     120           0 :         , m_bDeleteRepeated(false)
     121           0 :     { }
     122             : 
     123           0 :     SwDoc & GetDoc() const { return m_rDoc; }
     124             : 
     125           0 :     SwPaM & GetRepeatPaM()
     126             :     {
     127           0 :         return *m_pCurrentPaM;
     128             :     }
     129             : 
     130             : private:
     131             :     friend class ::sw::UndoManager;
     132             :     friend class ::SwUndoDelete;
     133             : 
     134             :     SwDoc & m_rDoc;
     135             :     SwPaM * m_pCurrentPaM;
     136             :     bool m_bDeleteRepeated; /// has a delete action been repeated?
     137             : };
     138             : 
     139             : } // namespace sw
     140             : 
     141             : class SwUndoFormatColl : public SwUndo, private SwUndRng
     142             : {
     143             :     OUString aFormatName;
     144             :     SwHistory* pHistory;
     145             :     SwFormatColl* pFormatColl;
     146             :     // for correct <ReDo(..)> and <Repeat(..)>
     147             :     // boolean, which indicates that the attributes are reseted at the nodes
     148             :     // before the format has been applied.
     149             :     const bool mbReset;
     150             :     // boolean, which indicates that the list attributes had been reseted at
     151             :     // the nodes before the format has been applied.
     152             :     const bool mbResetListAttrs;
     153             : 
     154             :     void DoSetFormatColl(SwDoc & rDoc, SwPaM & rPaM);
     155             : 
     156             : public:
     157             :     SwUndoFormatColl( const SwPaM&, SwFormatColl*,
     158             :                    const bool bReset,
     159             :                    const bool bResetListAttrs );
     160             :     virtual ~SwUndoFormatColl();
     161             : 
     162             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     163             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     164             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     165             : 
     166             :     /**
     167             :        Returns the rewriter for this undo object.
     168             : 
     169             :        The rewriter contains one rule:
     170             : 
     171             :            $1 -> <name of format collection>
     172             : 
     173             :        <name of format collection> is the name of the format
     174             :        collection that is applied by the action recorded by this undo
     175             :        object.
     176             : 
     177             :        @return the rewriter for this undo object
     178             :     */
     179             :     virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
     180             : 
     181        1936 :     SwHistory* GetHistory() { return pHistory; }
     182             : 
     183             : };
     184             : 
     185             : class SwUndoSetFlyFormat : public SwUndo, public SwClient
     186             : {
     187             :     SwFrameFormat* pFrameFormat;                  // saved FlyFormat
     188             :     SwFrameFormat* pOldFormat;
     189             :     SwFrameFormat* pNewFormat;
     190             :     SfxItemSet* pItemSet;               // the re-/ set attributes
     191             :     sal_uLong nOldNode, nNewNode;
     192             :     sal_Int32 nOldContent, nNewContent;
     193             :     sal_uInt16 nOldAnchorTyp, nNewAnchorTyp;
     194             :     bool bAnchorChgd;
     195             : 
     196             :     void PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem );
     197             :     void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
     198             :     void GetAnchor( SwFormatAnchor& rAnhor, sal_uLong nNode, sal_Int32 nContent );
     199             : 
     200             : public:
     201             :     SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFrameFormat );
     202             :     virtual ~SwUndoSetFlyFormat();
     203             : 
     204             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     205             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     206             : 
     207             :     virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
     208             :     void DeRegisterFromFormat( SwFormat& );
     209             : };
     210             : 
     211           0 : class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng
     212             : {
     213             :     short nOffset;
     214             : 
     215             : public:
     216             :     SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset );
     217             : 
     218             :     virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     219             :     virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
     220             :     virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
     221             : };
     222             : 
     223             : const int nUndoStringLength = 20;
     224             : 
     225             : /**
     226             :    Shortens a string to a maximum length.
     227             : 
     228             :    @param rStr      the string to be shortened
     229             :    @param nLength   the maximum length for rStr
     230             :    @param rFillStr  string to replace cut out characters with
     231             : 
     232             :    If rStr has less than nLength characters it will be returned unaltered.
     233             : 
     234             :    If rStr has more than nLength characters the following algorithm
     235             :    generates the shortened string:
     236             : 
     237             :        frontLength = (nLength - length(rFillStr)) / 2
     238             :        rearLength = nLength - length(rFillStr) - frontLength
     239             :        shortenedString = concat(<first frontLength characters of rStr,
     240             :                                 rFillStr,
     241             :                                 <last rearLength characters of rStr>)
     242             : 
     243             :    Preconditions:
     244             :       - nLength - length(rFillStr) >= 2
     245             : 
     246             :    @return the shortened string
     247             :  */
     248             : OUString
     249             : ShortenString(const OUString & rStr, sal_Int32 nLength, const OUString & rFillStr);
     250             : /**
     251             :    Denotes special characters in a string.
     252             : 
     253             :    The rStr is split into parts containing special characters and
     254             :    parts not containing special characters. In a part containing
     255             :    special characters all characters are equal. These parts are
     256             :    maximal.
     257             : 
     258             :    @param rStr     the string to denote in
     259             : 
     260             :    The resulting string is generated by concatenating the found
     261             :    parts. The parts without special characters are surrounded by
     262             :    "'". The parts containing special characters are denoted as "n x",
     263             :    where n is the length of the part and x is the representation of
     264             :    the special character (i. e. "tab(s)").
     265             : 
     266             :    @return the denoted string
     267             : */
     268             : OUString DenoteSpecialCharacters(const OUString & rStr);
     269             : 
     270             : #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOCORE_HXX
     271             : 
     272             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11