LCOV - code coverage report
Current view: top level - dbaccess/source/ui/misc - singledoccontroller.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 63 0.0 %
Date: 2014-04-14 Functions: 0 13 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             : #include <dbaccess/dbaundomanager.hxx>
      21             : #include "singledoccontroller.hxx"
      22             : #include "browserids.hxx"
      23             : #include "dbu_misc.hrc"
      24             : #include "dbustrings.hrc"
      25             : #include "moduledbu.hxx"
      26             : 
      27             : #include <svl/undo.hxx>
      28             : #include <osl/diagnose.h>
      29             : 
      30             : #include <boost/scoped_ptr.hpp>
      31             : 
      32             : namespace dbaui
      33             : {
      34             : 
      35             :     using ::com::sun::star::uno::Reference;
      36             :     using ::com::sun::star::uno::XInterface;
      37             :     using ::com::sun::star::uno::UNO_QUERY;
      38             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      39             :     using ::com::sun::star::uno::UNO_SET_THROW;
      40             :     using ::com::sun::star::uno::Exception;
      41             :     using ::com::sun::star::uno::RuntimeException;
      42             :     using ::com::sun::star::uno::Any;
      43             :     using ::com::sun::star::uno::makeAny;
      44             :     using ::com::sun::star::uno::Sequence;
      45             :     using ::com::sun::star::uno::Type;
      46             :     using ::com::sun::star::uno::XComponentContext;
      47             :     using ::com::sun::star::document::XUndoManager;
      48             :     using ::com::sun::star::lang::XMultiServiceFactory;
      49             :     using ::com::sun::star::beans::PropertyValue;
      50             :     using ::com::sun::star::lang::EventObject;
      51             : 
      52             :     // OSingleDocumentController_Data
      53           0 :     struct OSingleDocumentController_Data
      54             :     {
      55             :         ::boost::scoped_ptr< UndoManager >  m_pUndoManager;
      56             : 
      57           0 :         OSingleDocumentController_Data( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
      58           0 :             :m_pUndoManager( new UndoManager( i_parent, i_mutex ) )
      59             :         {
      60           0 :         }
      61             :     };
      62             : 
      63             :     // OSingleDocumentController
      64           0 :     OSingleDocumentController::OSingleDocumentController( const Reference< XComponentContext >& _rxORB )
      65             :         :OSingleDocumentController_Base( _rxORB )
      66           0 :         ,m_pData( new OSingleDocumentController_Data( *this, getMutex() ) )
      67             :     {
      68           0 :     }
      69             : 
      70           0 :     OSingleDocumentController::~OSingleDocumentController()
      71             :     {
      72           0 :     }
      73             : 
      74           0 :     void SAL_CALL OSingleDocumentController::disposing()
      75             :     {
      76           0 :         OSingleDocumentController_Base::disposing();
      77           0 :         ClearUndoManager();
      78           0 :         m_pData->m_pUndoManager->disposing();
      79           0 :     }
      80             : 
      81           0 :     void SAL_CALL OSingleDocumentController::disposing( const EventObject& i_event ) throw( RuntimeException, std::exception )
      82             :     {
      83             :         // simply disambiguate
      84           0 :         OSingleDocumentController_Base::disposing( i_event );
      85           0 :     }
      86             : 
      87           0 :     void OSingleDocumentController::ClearUndoManager()
      88             :     {
      89           0 :         GetUndoManager().Clear();
      90           0 :     }
      91             : 
      92           0 :     SfxUndoManager& OSingleDocumentController::GetUndoManager() const
      93             :     {
      94           0 :         return m_pData->m_pUndoManager->GetSfxUndoManager();
      95             :     }
      96             : 
      97           0 :     void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
      98             :     {
      99             :         // add undo action
     100           0 :         GetUndoManager().AddUndoAction( _pAction );
     101             : 
     102             :         // when we add an undo action the controller was modified
     103           0 :         setModified( sal_True );
     104             : 
     105             :         // now inform me that or states changed
     106           0 :         InvalidateFeature( ID_BROWSER_UNDO );
     107           0 :         InvalidateFeature( ID_BROWSER_REDO );
     108           0 :     }
     109             : 
     110           0 :     Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager(  ) throw (RuntimeException, std::exception)
     111             :     {
     112           0 :         return m_pData->m_pUndoManager.get();
     113             :     }
     114             : 
     115           0 :     FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const
     116             :     {
     117           0 :         FeatureState aReturn;
     118           0 :         switch ( _nId )
     119             :         {
     120             :             case ID_BROWSER_UNDO:
     121           0 :                 aReturn.bEnabled = isEditable() && GetUndoManager().GetUndoActionCount() != 0;
     122           0 :                 if ( aReturn.bEnabled )
     123             :                 {
     124           0 :                     OUString sUndo(ModuleRes(STR_UNDO_COLON));
     125           0 :                     sUndo += " ";
     126           0 :                     sUndo += GetUndoManager().GetUndoActionComment();
     127           0 :                     aReturn.sTitle = sUndo;
     128             :                 }
     129           0 :                 break;
     130             : 
     131             :             case ID_BROWSER_REDO:
     132           0 :                 aReturn.bEnabled = isEditable() && GetUndoManager().GetRedoActionCount() != 0;
     133           0 :                 if ( aReturn.bEnabled )
     134             :                 {
     135           0 :                     OUString sRedo(ModuleRes(STR_REDO_COLON));
     136           0 :                     sRedo += " ";
     137           0 :                     sRedo += GetUndoManager().GetRedoActionComment();
     138           0 :                     aReturn.sTitle = sRedo;
     139             :                 }
     140           0 :                 break;
     141             : 
     142             :             default:
     143           0 :                 aReturn = OSingleDocumentController_Base::GetState(_nId);
     144             :         }
     145           0 :         return aReturn;
     146             :     }
     147           0 :     void OSingleDocumentController::Execute( sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs )
     148             :     {
     149           0 :         switch ( _nId )
     150             :         {
     151             :             case ID_BROWSER_UNDO:
     152           0 :                 GetUndoManager().Undo();
     153           0 :                 InvalidateFeature( ID_BROWSER_UNDO );
     154           0 :                 InvalidateFeature( ID_BROWSER_REDO );
     155           0 :                 break;
     156             : 
     157             :             case ID_BROWSER_REDO:
     158           0 :                 GetUndoManager().Redo();
     159           0 :                 InvalidateFeature( ID_BROWSER_UNDO );
     160           0 :                 InvalidateFeature( ID_BROWSER_REDO );
     161           0 :                 break;
     162             : 
     163             :             default:
     164           0 :                 OSingleDocumentController_Base::Execute( _nId, _rArgs );
     165           0 :                 break;
     166             :         }
     167           0 :         InvalidateFeature(_nId);
     168           0 :     }
     169             : 
     170             : } // namespace dbaui
     171             : 
     172             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10