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

Generated by: LCOV version 1.10