LCOV - code coverage report
Current view: top level - chart2/source/controller/main - UndoGuard.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 1 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 1 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             : #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_UNDOGUARD_HXX
      20             : #define INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_UNDOGUARD_HXX
      21             : 
      22             : #include "ChartModelClone.hxx"
      23             : 
      24             : #include <com/sun/star/document/XUndoManager.hpp>
      25             : #include <com/sun/star/frame/XModel.hpp>
      26             : 
      27             : #include <rtl/ustring.hxx>
      28             : 
      29             : #include <boost/shared_ptr.hpp>
      30             : 
      31             : namespace chart
      32             : {
      33             : 
      34             : /** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it
      35             :     does neither auto-commit nor auto-rollback the model changes.
      36             :  */
      37             : class UndoGuard
      38             : {
      39             : public:
      40             :     explicit UndoGuard(
      41             :         const OUString& i_undoMessage,
      42             :         const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager,
      43             :         const ModelFacet i_facet = E_MODEL
      44             :     );
      45             :     ~UndoGuard();
      46             : 
      47             :     void    commit();
      48             :     void    rollback();
      49             : 
      50             : protected:
      51           0 :     bool    isActionPosted() const { return m_bActionPosted; }
      52             : 
      53             : private:
      54             :     void    discardSnapshot();
      55             : 
      56             : private:
      57             :     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >           m_xChartModel;
      58             :     const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager >  m_xUndoManager;
      59             : 
      60             :     ::boost::shared_ptr< ChartModelClone >  m_pDocumentSnapshot;
      61             :     OUString                           m_aUndoString;
      62             :     bool                                    m_bActionPosted;
      63             : };
      64             : 
      65             : /** A guard which, in its destructor, restores the model state it found in the constructor. If
      66             :     <member>commitAction</member> is called inbetween, the restouration is not performed.
      67             :  */
      68             : class UndoLiveUpdateGuard : public UndoGuard
      69             : {
      70             : public:
      71             :     explicit UndoLiveUpdateGuard(
      72             :         const OUString& i_undoMessage,
      73             :         const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
      74             :     );
      75             :     ~UndoLiveUpdateGuard();
      76             : };
      77             : 
      78             : /** Same as UndoLiveUpdateGuard but with additional storage of the chart's data.
      79             :     Only use this if the data has internal data.
      80             :  */
      81             : class UndoLiveUpdateGuardWithData :
      82             :         public UndoGuard
      83             : {
      84             : public:
      85             :     explicit UndoLiveUpdateGuardWithData(
      86             :         const OUString& i_undoMessage,
      87             :         const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
      88             :     );
      89             :     ~UndoLiveUpdateGuardWithData();
      90             : };
      91             : 
      92             : class UndoGuardWithSelection : public UndoGuard
      93             : {
      94             : public:
      95             :     explicit UndoGuardWithSelection(
      96             :         const OUString& i_undoMessage,
      97             :         const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
      98             :     );
      99             :     virtual ~UndoGuardWithSelection();
     100             : };
     101             : 
     102             : class HiddenUndoContext
     103             : {
     104             : public:
     105             :     explicit HiddenUndoContext(
     106             :         const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
     107             :     );
     108             :     ~HiddenUndoContext();
     109             : 
     110             : private:
     111             :     ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager >    m_xUndoManager;
     112             : };
     113             : 
     114             : }
     115             : // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_UNDOGUARD_HXX
     116             : #endif
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11