Kaydet (Commit) 39a68914 authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs]

undoapi: implement XUndoManager/Supplier for Base sub components

üst 846cc789
......@@ -38,13 +38,14 @@
#include <com/sun/star/sdbc/XDataSource.hpp>
#include <com/sun/star/util/XNumberFormatter.hpp>
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/document/XUndoManagerSupplier.hpp>
/** === end UNO includes === **/
#include <comphelper/broadcasthelper.hxx>
#include <comphelper/proparrhlp.hxx>
#include <comphelper/propertycontainer.hxx>
#include <connectivity/dbmetadata.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
#include <svl/undo.hxx>
#include <memory>
......@@ -59,9 +60,10 @@ namespace dbaui
//====================================================================
class OSingleDocumentController;
typedef ::cppu::ImplInheritanceHelper2 < OGenericUnoController
typedef ::cppu::ImplInheritanceHelper3 < OGenericUnoController
, ::com::sun::star::document::XScriptInvocationContext
, ::com::sun::star::util::XModifiable
, ::com::sun::star::document::XUndoManagerSupplier
> OSingleDocumentController_Base;
struct OSingleDocumentControllerImpl;
......@@ -72,9 +74,6 @@ namespace dbaui
private:
::std::auto_ptr<OSingleDocumentControllerImpl> m_pImpl;
protected:
SfxUndoManager m_aUndoManager;
private:
/** forces usage of a connection which we do not own
<p>To be used from within XInitialization::initialize, resp. impl_initialize, only.</p>
......@@ -102,7 +101,7 @@ namespace dbaui
void setEditable(sal_Bool _bEditable);
// need for undo's and redo's
SfxUndoManager& GetUndoManager();
SfxUndoManager& GetUndoManager() const;
/** addUndoActionAndInvalidate adds an undo action to the undoManager,
additionally invalidates the UNDO and REDO slot
......@@ -190,6 +189,9 @@ namespace dbaui
// XTitle
virtual ::rtl::OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException);
// XUndoManagerSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > SAL_CALL getUndoManager( ) throw (::com::sun::star::uno::RuntimeException);
protected:
OSingleDocumentController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxORB);
virtual ~OSingleDocumentController();
......
This diff is collapsed.
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef DBACCESS_DBAUNDOMANAGER_HXX
#define DBACCESS_DBAUNDOMANAGER_HXX
/** === begin UNO includes === **/
#include <com/sun/star/document/XUndoManager.hpp>
/** === end UNO includes === **/
#include <cppuhelper/implbase1.hxx>
#include <boost/scoped_ptr.hpp>
class SfxUndoManager;
//......................................................................................................................
namespace dbaui
{
//......................................................................................................................
//==================================================================================================================
//= UndoManager
//==================================================================================================================
struct UndoManager_Impl;
typedef ::cppu::ImplHelper1< ::com::sun::star::document::XUndoManager > UndoManager_Base;
class UndoManager : public UndoManager_Base
{
public:
UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex );
virtual ~UndoManager();
SfxUndoManager& GetSfxUndoManager() const;
// XInterface
virtual void SAL_CALL acquire( ) throw ();
virtual void SAL_CALL release( ) throw ();
// XComponent equivalents
void disposing();
// XUndoManager
virtual void SAL_CALL enterUndoContext( const ::rtl::OUString& i_title ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL enterHiddenUndoContext( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL leaveUndoContext( ) throw (::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addUndoAction( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoAction >& i_action ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL undo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL redo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isUndoPossible( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isRedoPossible( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getCurrentUndoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getCurrentRedoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoActionTitles( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoActionTitles( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL clear( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL clearRedo( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException);
// XLockable (base of XUndoManager)
virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL unlock( ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException);
// XChild (base of XUndoManager)
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
private:
::boost::scoped_ptr< UndoManager_Impl > m_pImpl;
};
//......................................................................................................................
} // namespace dbaui
//......................................................................................................................
#endif // DBACCESS_DBAUNDOMANAGER_HXX
......@@ -25,8 +25,8 @@
#
#*************************************************************************
PRJ=..$/..$/..
PRJINC=$(PRJ)$/source
PRJ=../../..
PRJINC=$(PRJ)/source
PRJNAME=dbaccess
TARGET=uimisc
......@@ -35,50 +35,52 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings ----------------------------------
.INCLUDE : settings.mk
.INCLUDE : $(PRJ)$/util$/makefile.pmk
.INCLUDE : $(PRJ)/util/makefile.pmk
# --- Files -------------------------------------
# ... resource files ............................
SRS1NAME=$(TARGET)
SRC1FILES = \
dbumiscres.src \
SRC1FILES = \
dbumiscres.src \
WizardPages.src
# ... object files ............................
SLOFILES= \
$(SLO)$/asyncmodaldialog.obj \
$(SLO)$/imageprovider.obj \
$(SLO)$/singledoccontroller.obj \
$(SLO)$/datasourceconnector.obj \
$(SLO)$/linkeddocuments.obj \
$(SLO)$/indexcollection.obj \
$(SLO)$/UITools.obj \
$(SLO)$/WCPage.obj \
$(SLO)$/WCopyTable.obj \
$(SLO)$/WTypeSelect.obj \
$(SLO)$/TokenWriter.obj \
$(SLO)$/HtmlReader.obj \
$(SLO)$/RtfReader.obj \
$(SLO)$/propertysetitem.obj \
$(SLO)$/databaseobjectview.obj \
$(SLO)$/DExport.obj \
$(SLO)$/uiservices.obj \
$(SLO)$/RowSetDrop.obj \
$(SLO)$/TableCopyHelper.obj \
$(SLO)$/moduledbu.obj \
$(SLO)$/WColumnSelect.obj \
$(SLO)$/WExtendPages.obj \
$(SLO)$/WNameMatch.obj \
$(SLO)$/ToolBoxHelper.obj \
$(SLO)$/stringlistitem.obj \
$(SLO)$/charsets.obj \
$(SLO)$/defaultobjectnamecheck.obj \
$(SLO)$/dsmeta.obj \
$(SLO)$/controllerframe.obj \
$(SLO)$/propertystorage.obj
SLOFILES= \
$(SLO)/asyncmodaldialog.obj \
$(SLO)/imageprovider.obj \
$(SLO)/singledoccontroller.obj \
$(SLO)/datasourceconnector.obj \
$(SLO)/linkeddocuments.obj \
$(SLO)/indexcollection.obj \
$(SLO)/UITools.obj \
$(SLO)/WCPage.obj \
$(SLO)/WCopyTable.obj \
$(SLO)/WTypeSelect.obj \
$(SLO)/TokenWriter.obj \
$(SLO)/HtmlReader.obj \
$(SLO)/RtfReader.obj \
$(SLO)/propertysetitem.obj \
$(SLO)/databaseobjectview.obj \
$(SLO)/DExport.obj \
$(SLO)/uiservices.obj \
$(SLO)/RowSetDrop.obj \
$(SLO)/TableCopyHelper.obj \
$(SLO)/moduledbu.obj \
$(SLO)/WColumnSelect.obj \
$(SLO)/WExtendPages.obj \
$(SLO)/WNameMatch.obj \
$(SLO)/ToolBoxHelper.obj \
$(SLO)/stringlistitem.obj \
$(SLO)/charsets.obj \
$(SLO)/defaultobjectnamecheck.obj \
$(SLO)/dsmeta.obj \
$(SLO)/controllerframe.obj \
$(SLO)/propertystorage.obj \
$(SLO)/dbaundomanager.obj \
# --- Targets ----------------------------------
.INCLUDE : target.mk
......
......@@ -35,9 +35,10 @@
#include "dbustrings.hrc"
#include "moduledbu.hxx"
#include "singledoccontroller.hxx"
#include <com/sun/star/frame/XUntitledNumbers.hpp>
#include "dbaundomanager.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/frame/XUntitledNumbers.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
......@@ -95,6 +96,7 @@ namespace dbaui
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::frame::XUntitledNumbers;
using ::com::sun::star::beans::PropertyVetoException;
using ::com::sun::star::document::XUndoManager;
/** === end UNO using === **/
class DataSourceHolder
......@@ -148,6 +150,8 @@ namespace dbaui
SharedConnection m_xConnection;
::dbtools::DatabaseMetaData m_aSdbMetaData;
// </properties>
::boost::scoped_ptr< UndoManager >
m_pUndoManager;
::rtl::OUString m_sDataSourceName; // the data source we're working for
DataSourceHolder m_aDataSource;
Reference< XModel > m_xDocument;
......@@ -158,9 +162,10 @@ namespace dbaui
sal_Bool m_bModified; // is the data modified
bool m_bNotAttached;
OSingleDocumentControllerImpl( ::osl::Mutex& i_rMutex )
OSingleDocumentControllerImpl( OSingleDocumentController& i_antiImpl, ::osl::Mutex& i_rMutex )
:m_aDocScriptSupport()
,m_aModifyListeners( i_rMutex )
,m_pUndoManager( new UndoManager( i_antiImpl, i_rMutex ) )
,m_nDocStartNumber(0)
,m_bSuspended( sal_False )
,m_bEditable(sal_True)
......@@ -190,7 +195,7 @@ namespace dbaui
//--------------------------------------------------------------------
OSingleDocumentController::OSingleDocumentController(const Reference< XMultiServiceFactory >& _rxORB)
:OSingleDocumentController_Base( _rxORB )
,m_pImpl( new OSingleDocumentControllerImpl( getMutex() ) )
,m_pImpl( new OSingleDocumentControllerImpl( *this, getMutex() ) )
{
}
......@@ -368,12 +373,13 @@ namespace dbaui
void SAL_CALL OSingleDocumentController::disposing()
{
OSingleDocumentController_Base::disposing();
m_aUndoManager.Clear();
GetUndoManager().Clear();
disconnect();
attachFrame( Reference < XFrame >() );
m_pImpl->m_pUndoManager->disposing();
m_pImpl->m_aDataSource.clear();
}
......@@ -483,22 +489,22 @@ namespace dbaui
switch (_nId)
{
case ID_BROWSER_UNDO:
aReturn.bEnabled = m_pImpl->m_bEditable && m_aUndoManager.GetUndoActionCount() != 0;
aReturn.bEnabled = m_pImpl->m_bEditable && GetUndoManager().GetUndoActionCount() != 0;
if ( aReturn.bEnabled )
{
String sUndo(ModuleRes(STR_UNDO_COLON));
sUndo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
sUndo += m_aUndoManager.GetUndoActionComment();
sUndo += GetUndoManager().GetUndoActionComment();
aReturn.sTitle = sUndo;
}
break;
case ID_BROWSER_REDO:
aReturn.bEnabled = m_pImpl->m_bEditable && m_aUndoManager.GetRedoActionCount() != 0;
aReturn.bEnabled = m_pImpl->m_bEditable && GetUndoManager().GetRedoActionCount() != 0;
if ( aReturn.bEnabled )
{
String sRedo(ModuleRes(STR_REDO_COLON));
sRedo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
sRedo += m_aUndoManager.GetRedoActionComment();
sRedo += GetUndoManager().GetRedoActionComment();
aReturn.sTitle = sRedo;
}
break;
......@@ -516,11 +522,11 @@ namespace dbaui
closeTask();
return;
case ID_BROWSER_UNDO:
m_aUndoManager.Undo();
GetUndoManager().Undo();
InvalidateFeature(ID_BROWSER_REDO);
break;
case ID_BROWSER_REDO:
m_aUndoManager.Redo();
GetUndoManager().Redo();
InvalidateFeature(ID_BROWSER_UNDO);
break;
default:
......@@ -530,15 +536,15 @@ namespace dbaui
InvalidateFeature(_nId);
}
// -----------------------------------------------------------------------------
SfxUndoManager& OSingleDocumentController::GetUndoManager()
SfxUndoManager& OSingleDocumentController::GetUndoManager() const
{
return m_aUndoManager;
return m_pImpl->m_pUndoManager->GetSfxUndoManager();
}
// -----------------------------------------------------------------------------
void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
{
// add undo action
m_aUndoManager.AddUndoAction(_pAction);
GetUndoManager().AddUndoAction(_pAction);
// when we add an undo action the controller was modified
setModified(sal_True);
// now inform me that or states changed
......@@ -676,6 +682,13 @@ namespace dbaui
return sTitle.makeStringAndClear();
}
// -----------------------------------------------------------------------------
Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager( ) throw (RuntimeException)
{
return m_pImpl->m_pUndoManager.get();
}
// -----------------------------------------------------------------------------
sal_Int32 OSingleDocumentController::getCurrentStartNumber() const
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment