Commits

Anonymous committed 288b57f Merge

swbookmarkfixes01: merge CWS undoapi

Comments (0)

Files changed (599)

basctl/source/basicide/basicbox.cxx

 
 void DocListenerBox::onDocumentClosed( const ScriptDocument& /*_rDocument*/ )
 {
-    if ( SFX_APP()->IsInBasicCall() )
-        // Nicht wenn Office beendet
-        FillBox();
+    FillBox();
 }
 
 void DocListenerBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )

basctl/source/basicide/baside2.cxx

 	return nFound;
 }
 
-SfxUndoManager* __EXPORT ModulWindow::GetUndoManager()
+::svl::IUndoManager* __EXPORT ModulWindow::GetUndoManager()
 {
 	if ( GetEditEngine() )
 		return &GetEditEngine()->GetUndoManager();

basctl/source/basicide/baside2.hxx

 	virtual void		BasicStarted();
 	virtual void		BasicStopped();
 
-	virtual SfxUndoManager*	GetUndoManager();
+    virtual ::svl::IUndoManager*
+                        GetUndoManager();
 
     const ::rtl::OUString&	GetModule() const { return m_aModule; }
     void					SetModule( const ::rtl::OUString& aModule ) { m_aModule = aModule; }

basctl/source/basicide/baside3.cxx

 	return pEditor->IsModified();
 }
 
-SfxUndoManager* __EXPORT DialogWindow::GetUndoManager()
+::svl::IUndoManager* __EXPORT DialogWindow::GetUndoManager()
 {
 	return pUndoMgr;
 }

basctl/source/basicide/basidesh.cxx

 	SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BasicIDE" ) ) );
 	SetHelpId( SVX_INTERFACE_BASIDE_VIEWSH );
 
-	SFX_APP()->EnterBasicCall();
-
 	LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
 	LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
 
 	// ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war.
 	// GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
 
-	SFX_APP()->LeaveBasicCall();
 	IDE_DLL()->GetExtraData()->ShellInCriticalSection() = FALSE;
 
     GnBasicIDEShellCount--;
 
 
 
-SfxUndoManager* BasicIDEShell::GetUndoManager()
+::svl::IUndoManager* BasicIDEShell::GetUndoManager()
 {
-	SfxUndoManager* pMgr = NULL;
+	::svl::IUndoManager* pMgr = NULL;
 	if( pCurWin )
 		pMgr = pCurWin->GetUndoManager();
 

basctl/source/basicide/basobj2.cxx

 
 #include <ide_pch.hxx>
 
+#include "basobj.hxx"
+#include "iderdll.hxx"
+#include "iderdll2.hxx"
+#include "iderid.hxx"
+#include "macrodlg.hxx"
+#include "moduldlg.hxx"
+#include "basidesh.hxx"
+#include "basidesh.hrc"
+#include "baside2.hxx"
+#include "basicmod.hxx"
+#include "basdoc.hxx"
+
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
+
+#include <basic/sbx.hxx>
+#include <framework/documentundoguard.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/moduleoptions.hxx>
+
 #include <vector>
 #include <algorithm>
-#include <basic/sbx.hxx>
-#include <unotools/moduleoptions.hxx>
-#include <com/sun/star/document/XEmbeddedScripts.hpp>
-#include <com/sun/star/document/XScriptInvocationContext.hpp>
-#include <basobj.hxx>
-#include <iderdll.hxx>
-#include <iderdll2.hxx>
-#include <iderid.hxx>
-#include <macrodlg.hxx>
-#include <moduldlg.hxx>
-#include <basidesh.hxx>
-#include <basidesh.hrc>
-#include <baside2.hxx>
-#include <basicmod.hxx>
-#include <basdoc.hxx>
+#include <memory>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
     return true;
 }
 
+
+//----------------------------------------------------------------------------
+
+namespace
+{
+    struct MacroExecutionData
+    {
+        ScriptDocument  aDocument;
+        SbMethodRef     xMethod;
+
+        MacroExecutionData()
+            :aDocument( ScriptDocument::NoDocument )
+            ,xMethod( NULL )
+        {
+        }
+    };
+
+    class MacroExecution
+    {
+    public:
+        DECL_STATIC_LINK( MacroExecution, ExecuteMacroEvent, MacroExecutionData* );
+    };
+
+
+    IMPL_STATIC_LINK( MacroExecution, ExecuteMacroEvent, MacroExecutionData*, i_pData )
+    {
+        (void)pThis;
+        ENSURE_OR_RETURN( i_pData, "wrong MacroExecutionData", 0L );
+        // take ownership of the data
+        ::std::auto_ptr< MacroExecutionData > pData( i_pData );
+
+        DBG_ASSERT( pData->xMethod->GetParent()->GetFlags() & SBX_EXTSEARCH, "Kein EXTSEARCH!" );
+
+        // in case this is a document-local macro, try to protect the document's Undo Manager from
+        // flawed scripts
+        ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
+        if ( pData->aDocument.isDocument() )
+            pUndoGuard.reset( new ::framework::DocumentUndoGuard( pData->aDocument.getDocument() ) );
+
+        BasicIDE::RunMethod( pData->xMethod );
+
+        return 1L;
+    }
+}
+
 //----------------------------------------------------------------------------
 
 ::rtl::OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument, BOOL bChooseOnly, const ::rtl::OUString& rMacroDesc )
 	BasicIDEDLL::Init();
 
 	IDE_DLL()->GetExtraData()->ChoosingMacro() = TRUE;
-	SFX_APP()->EnterBasicCall();
 
     String aScriptURL;
     BOOL bError = FALSE;
     SbMethod* pMethod = NULL;
 
-	MacroChooser* pChooser = new MacroChooser( NULL, TRUE );
+    ::std::auto_ptr< MacroChooser > pChooser( new MacroChooser( NULL, TRUE ) );
 	if ( bChooseOnly || !SvtModuleOptions().IsBasicIDE() )
         pChooser->SetMode( MACROCHOOSER_CHOOSEONLY );
 
             if ( !pMethod && pChooser->GetMode() == MACROCHOOSER_RECORDING )
                 pMethod = pChooser->CreateMacro();
 
-            if ( pMethod )
-			{
-				SbModule* pModule = pMethod->GetModule();
-				DBG_ASSERT(pModule, "BasicIDE::ChooseMacro: No Module found!");
-				if ( pModule )
-				{
-					StarBASIC* pBasic = (StarBASIC*)pModule->GetParent();
-					DBG_ASSERT(pBasic, "BasicIDE::ChooseMacro: No Basic found!");
-					if ( pBasic )
-					{
-						BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
-						DBG_ASSERT(pBasMgr, "BasicIDE::ChooseMacro: No BasicManager found!");
-						if ( pBasMgr )
-                        {
-                            // name
-                            String aName;
-							aName += pBasic->GetName();
-							aName += '.';
-							aName += pModule->GetName();
-							aName += '.';
-							aName += pMethod->GetName();
+            if ( !pMethod )
+                break;
 
-                            // language
-                            String aLanguage = String::CreateFromAscii("Basic");
+            SbModule* pModule = pMethod->GetModule();
+            ENSURE_OR_BREAK( pModule, "BasicIDE::ChooseMacro: No Module found!" );
 
-                            // location
-                            String aLocation;
-							ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
-                            if ( aDocument.isDocument() )
+            StarBASIC* pBasic = (StarBASIC*)pModule->GetParent();
+			ENSURE_OR_BREAK( pBasic, "BasicIDE::ChooseMacro: No Basic found!" );
+
+            BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+			ENSURE_OR_BREAK( pBasMgr, "BasicIDE::ChooseMacro: No BasicManager found!" );
+
+            // name
+            String aName;
+			aName += pBasic->GetName();
+			aName += '.';
+			aName += pModule->GetName();
+			aName += '.';
+			aName += pMethod->GetName();
+
+            // language
+            String aLanguage = String::CreateFromAscii("Basic");
+
+            // location
+            String aLocation;
+			ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+            if ( aDocument.isDocument() )
+            {
+                // document basic
+                aLocation = String::CreateFromAscii("document");
+
+                if ( rxLimitToDocument.is() )
+                {
+                    uno::Reference< frame::XModel > xLimitToDocument( rxLimitToDocument );
+
+                    uno::Reference< document::XEmbeddedScripts > xScripts( rxLimitToDocument, UNO_QUERY );
+                    if ( !xScripts.is() )
+                    {   // the document itself does not support embedding scripts
+                        uno::Reference< document::XScriptInvocationContext > xContext( rxLimitToDocument, UNO_QUERY );
+                        if ( xContext.is() )
+                            xScripts = xContext->getScriptContainer();
+                        if ( xScripts.is() )
+                        {   // but it is able to refer to a document which actually does support this
+                            xLimitToDocument.set( xScripts, UNO_QUERY );
+                            if ( !xLimitToDocument.is() )
                             {
-                                // document basic
-                                aLocation = String::CreateFromAscii("document");
-
-                                if ( rxLimitToDocument.is() )
-                                {
-                                    uno::Reference< frame::XModel > xLimitToDocument( rxLimitToDocument );
-
-                                    uno::Reference< document::XEmbeddedScripts > xScripts( rxLimitToDocument, UNO_QUERY );
-                                    if ( !xScripts.is() )
-                                    {   // the document itself does not support embedding scripts
-                                        uno::Reference< document::XScriptInvocationContext > xContext( rxLimitToDocument, UNO_QUERY );
-                                        if ( xContext.is() )
-                                            xScripts = xContext->getScriptContainer();
-                                        if ( xScripts.is() )
-                                        {   // but it is able to refer to a document which actually does support this
-                                            xLimitToDocument.set( xScripts, UNO_QUERY );
-                                            if ( !xLimitToDocument.is() )
-                                            {
-                                                OSL_ENSURE( false, "BasicIDE::ChooseMacro: a script container which is no document!?" );
-                                                xLimitToDocument = rxLimitToDocument;
-                                            }
-                                        }
-                                    }
-
-                                    if ( xLimitToDocument != aDocument.getDocument() )
-                                    {
-                                        // error
-                                        bError = TRUE;
-                                        ErrorBox( NULL, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_ERRORCHOOSEMACRO ) ) ).Execute();
-                                    }
-                                }
-                            }
-                            else
-                            {
-                                // application basic
-                                aLocation = String::CreateFromAscii("application");
-                            }
-
-                            // script URL
-                            if ( !bError )
-                            {
-                                aScriptURL = String::CreateFromAscii("vnd.sun.star.script:");
-                                aScriptURL += aName;
-                                aScriptURL += String::CreateFromAscii("?language=");
-                                aScriptURL += aLanguage;
-                                aScriptURL += String::CreateFromAscii("&location=");
-                                aScriptURL += aLocation;
+                                OSL_ENSURE( false, "BasicIDE::ChooseMacro: a script container which is no document!?" );
+                                xLimitToDocument = rxLimitToDocument;
                             }
                         }
-					}
-				}
-			}
+                    }
 
-			if ( pMethod && !rxLimitToDocument.is() )
+                    if ( xLimitToDocument != aDocument.getDocument() )
+                    {
+                        // error
+                        bError = TRUE;
+                        ErrorBox( NULL, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_ERRORCHOOSEMACRO ) ) ).Execute();
+                    }
+                }
+            }
+            else
+            {
+                // application basic
+                aLocation = String::CreateFromAscii("application");
+            }
+
+            // script URL
+            if ( !bError )
+            {
+                aScriptURL = String::CreateFromAscii("vnd.sun.star.script:");
+                aScriptURL += aName;
+                aScriptURL += String::CreateFromAscii("?language=");
+                aScriptURL += aLanguage;
+                aScriptURL += String::CreateFromAscii("&location=");
+                aScriptURL += aLocation;
+            }
+
+			if ( !rxLimitToDocument.is() )
 			{
-				pMethod->AddRef();	// festhalten, bis Event abgearbeitet.
-				Application::PostUserEvent( LINK( IDE_DLL()->GetExtraData(), BasicIDEData, ExecuteMacroEvent ), pMethod );
+                MacroExecutionData* pExecData = new MacroExecutionData;
+                pExecData->aDocument = aDocument;
+                pExecData->xMethod = pMethod;   // keep alive until the event has been processed
+				Application::PostUserEvent( STATIC_LINK( NULL, MacroExecution, ExecuteMacroEvent ), pExecData );
 			}
 		}
 		break;
 	}
 
-	delete pChooser;
-
-	SFX_APP()->LeaveBasicCall();
-
-    return ::rtl::OUString( aScriptURL );
+    return aScriptURL;
 }
 
 //----------------------------------------------------------------------------

basctl/source/basicide/bastypes.cxx

 	return this;
 }
 
-SfxUndoManager* __EXPORT IDEBaseWindow::GetUndoManager()
+::svl::IUndoManager* __EXPORT IDEBaseWindow::GetUndoManager()
 {
 	return NULL;
 }

basctl/source/basicide/iderdll.cxx

 
 	return nRet;
 }
-
-IMPL_LINK( BasicIDEData, ExecuteMacroEvent, void *, pData )
-{
-	if ( pData )
-	{
-		SFX_APP()->EnterBasicCall();
-		SbMethod* pMethod = (SbMethod*)pData;
-
-		// Ist es eine StarScript-Methode? Am Parent erkennen
-		DBG_ASSERT( pMethod->GetParent()->GetFlags() & SBX_EXTSEARCH, "Kein EXTSEARCH!" );
-		BasicIDE::RunMethod( pMethod );
-		pMethod->ReleaseRef();	// muss vorher inkrementiert worden sein!
-		SFX_APP()->LeaveBasicCall();
-	}
-	return 0;
-}
-

basctl/source/basicide/iderdll2.hxx

 
 	const String&			GetAddLibFilter() const	{ return aAddLibFilter; }
 	void					SetAddLibFilter( const String& rFilter )  { aAddLibFilter = rFilter; }
-
-	DECL_LINK( ExecuteMacroEvent, void * );
 };
 
 

basctl/source/inc/baside3.hxx

 	virtual BOOL		IsModified();
     virtual BOOL        IsPasteAllowed();
 
-	virtual SfxUndoManager*	GetUndoManager();
+    virtual ::svl::IUndoManager*
+                        GetUndoManager();
     // return number of pages to be printed
     virtual sal_Int32 countPages( Printer* pPrinter );
     // print page

basctl/source/inc/basidesh.hxx

 
 	SdrView*			GetCurDlgView() const;
 
-	SfxUndoManager*		GetUndoManager();
+    ::svl::IUndoManager*
+                        GetUndoManager();
 
     virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
     

basctl/source/inc/bastypes.hxx

 #define BASWIN_INRESCHEDULE		0x08
 
 class Printer;
-class SfxUndoManager;
 class BasicEntryDescriptor;
 
+namespace svl
+{
+    class IUndoManager;
+}
+
 class IDEBaseWindow : public Window
 {
 private:
 
 	virtual Window*	GetLayoutWindow();
 
-	virtual SfxUndoManager*	GetUndoManager();
+    virtual ::svl::IUndoManager*
+                    GetUndoManager();
 
 	virtual USHORT	GetSearchOptions();
 

basctl/util/makefile.mk

 			$(SVXCORELIB) \
 			$(SVXLIB) \
             $(SFX2LIB) \
+            $(FWELIB) \
             $(BASICLIB) \
             $(SVTOOLLIB) \
 			$(TKLIB) \

basic/inc/basic/basmgr.hxx

     */
     bool            LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< rtl::OUString >& _out_rModuleNames );
 
+    /// determines whether the Basic Manager has a given macro, given by fully qualified name
+    bool            HasMacro( String const& i_fullyQualifiedName ) const;
+    /// executes a given macro
+    ErrCode         ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue );
+    /// executes a given macro
+    ErrCode         ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue );
+
 private:
 	BOOL		    IsReference( USHORT nLib );
 

basic/source/app/appedit.cxx

     
     if( pDataEdit )
     {
-        USHORT UndoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetUndoActionCount();
-        USHORT RedoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetRedoActionCount();
+        size_t UndoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetUndoActionCount();
+        size_t RedoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetRedoActionCount();
     
         pMenu->EnableItem( RID_EDITUNDO,	UndoCount > 0 );
         pMenu->EnableItem( RID_EDITREDO, 	RedoCount > 0 );

basic/source/basmgr/basmgr.cxx

 #include <tools/diagnose_ex.h>
 #include <basic/sbmod.hxx>
 #include <basic/sbobjmod.hxx>
+#include <unotools/intlwrapper.hxx>
+#include <comphelper/processfactory.hxx>
 
 #include <basic/sbuno.hxx>
 #include <basic/basmgr.hxx>
     return false;
 }
 
+
+namespace
+{
+    SbMethod* lcl_queryMacro( BasicManager* i_manager, String const& i_fullyQualifiedName )
+    {
+        sal_uInt16 nLast = 0;
+        String sMacro = i_fullyQualifiedName;
+        String sLibName = sMacro.GetToken( 0, '.', nLast );
+        String sModule = sMacro.GetToken( 0, '.', nLast );
+        sMacro.Erase( 0, nLast );
+
+	    IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+	    const CollatorWrapper* pCollator = aIntlWrapper.getCollator();
+	    sal_uInt16 nLibCount = i_manager->GetLibCount();
+	    for ( sal_uInt16 nLib = 0; nLib < nLibCount; ++nLib )
+	    {
+		    if ( COMPARE_EQUAL == pCollator->compareString( i_manager->GetLibName( nLib ), sLibName ) )
+		    {
+			    StarBASIC* pLib = i_manager->GetLib( nLib );
+			    if( !pLib )
+			    {
+				    i_manager->LoadLib( nLib );
+				    pLib = i_manager->GetLib( nLib );
+			    }
+
+			    if( pLib )
+			    {
+				    sal_uInt16 nModCount = pLib->GetModules()->Count();
+				    for( sal_uInt16 nMod = 0; nMod < nModCount; ++nMod )
+				    {
+					    SbModule* pMod = (SbModule*)pLib->GetModules()->Get( nMod );
+					    if ( pMod && COMPARE_EQUAL == pCollator->compareString( pMod->GetName(), sModule ) )
+					    {
+						    SbMethod* pMethod = (SbMethod*)pMod->Find( sMacro, SbxCLASS_METHOD );
+						    if( pMethod )
+							    return pMethod;
+					    }
+				    }
+			    }
+		    }
+	    }
+	    return 0;
+    }
+}
+
+bool BasicManager::HasMacro( String const& i_fullyQualifiedName ) const
+{
+    return ( NULL != lcl_queryMacro( const_cast< BasicManager* >( this ), i_fullyQualifiedName ) );
+}
+
+ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue )
+{
+    SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName );
+    ErrCode nError = 0;
+    if ( pMethod )
+    {
+        if ( i_arguments )
+            pMethod->SetParameters( i_arguments );
+        nError = pMethod->Call( i_retValue );
+    }
+    else
+        nError = ERRCODE_BASIC_PROC_UNDEFINED;
+    return nError;
+}
+
+ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue )
+{
+    SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName );
+    if ( !pMethod )
+        return ERRCODE_BASIC_PROC_UNDEFINED;
+
+    // arguments must be quoted
+    String sQuotedArgs;
+    String sArgs( i_commaSeparatedArgs );
+    if ( sArgs.Len()<2 || sArgs.GetBuffer()[1] == '\"')
+        // no args or already quoted args
+        sQuotedArgs = sArgs;
+    else
+    {
+        // quote parameters
+        sArgs.Erase( 0, 1 );
+        sArgs.Erase( sArgs.Len()-1, 1 );
+
+        sQuotedArgs = '(';
+
+        sal_uInt16 nCount = sArgs.GetTokenCount(',');
+        for ( sal_uInt16 n=0; n<nCount; ++n )
+        {
+            sQuotedArgs += '\"';
+            sQuotedArgs += sArgs.GetToken( n, ',' );
+            sQuotedArgs += '\"';
+            if ( n<nCount-1 )
+                sQuotedArgs += ',';
+        }
+
+        sQuotedArgs += ')';
+    }
+
+    // add quoted arguments and do the call
+    String sCall( '[' );
+    sCall += pMethod->GetName();
+    sCall += sQuotedArgs;
+    sCall += ']';
+
+	SbxVariable* pRet = pMethod->GetParent()->Execute( sCall );
+    if ( pRet )
+        *i_retValue = *pRet;
+    return SbxBase::GetError();
+}
+
 //=====================================================================
 
 class ModuleInfo_Impl : public ModuleInfoHelper

canvas/source/directx/dx_canvashelper_texturefill.cxx

             Gdiplus::SolidBrush aBackgroundBrush( rColors[0] );
             rGraphics->FillPath( &aBackgroundBrush, pFillPath.get() );
 
+            Gdiplus::Matrix aMatrix;
             // scale focus according to aspect ratio: for wider-than-tall
             // bounds (nAspectRatio > 1.0), the focus must have non-zero
             // width. Specifically, a bound rect twice as wide as tall has
                 // one sets both, only the translational components of the
                 // texture is respected.
 
-                Gdiplus::Matrix aMatrix;
                 tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix,
                                                         texture.AffineTransform );
                 GraphicsPathSharedPtr pGradientPath(

chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx

 #include "WrappedAddInProperty.hxx"
 #include "WrappedIgnoreProperty.hxx"
 #include "ChartRenderer.hxx"
-#include "UndoManager.hxx"
 #include <com/sun/star/chart2/XTitled.hpp>
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 
 using ::com::sun::star::chart::XComplexDescriptionAccess;
 using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
 using ::com::sun::star::uno::Reference;
 using ::com::sun::star::uno::Sequence;
 using ::com::sun::star::beans::Property;
         xResult.set( m_xChartView );
         bServiceFound = true;
     }
-    else if ( aServiceSpecifier.equals( CHART_UNDOMANAGER_SERVICE_NAME ) )
-    {
-        Reference< chart2::XUndoManager > xUndoManager( new UndoManager() );
-        xResult.set( xUndoManager );
-        bServiceFound = true;
-    }
     else
     {
         // try to create a shape

chart2/source/controller/dialogs/Strings.src

 {
 	Text [ en-US ] = "This function cannot be completed with the selected objects." ;
 };
+String STR_ACTION_EDIT_TEXT
+{
+    Text [ en-US ] = "Edit text";
+};
 
 String STR_COLUMN_LABEL
 {

chart2/source/controller/dialogs/res_ErrorBar.cxx

     if( pButton == &m_aIbRangePositive )
     {
         m_pCurrentRangeChoosingField = &m_aEdRangePositive;
-        aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS )));
+        aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS ));
     }
     else
     {
         m_pCurrentRangeChoosingField = &m_aEdRangeNegative;
-        aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS )));
+        aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS ));
     }
 
     OSL_ASSERT( m_pParentDialog );

chart2/source/controller/dialogs/tp_RangeChooser.cxx

 {
     rtl::OUString aRange = m_aED_Range.GetText();
     // using assignment for broken gcc 3.3
-    rtl::OUString aTitle = ::rtl::OUString( String( SchResId( STR_PAGE_DATA_RANGE ) ));
+    rtl::OUString aTitle = String( SchResId( STR_PAGE_DATA_RANGE ) );
 
     lcl_enableRangeChoosing( true, m_pParentDialog );
     m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this );

chart2/source/controller/main/ChartController.cxx

 #include "macros.hxx"
 #include "dlg_CreationWizard.hxx"
 #include "dlg_ChartType.hxx"
-//#include "svx/ActionDescriptionProvider.hxx"
 #include "AccessibleChartView.hxx"
 #include "DrawCommandDispatch.hxx"
 #include "ShapeController.hxx"
-#include "UndoManager.hxx"
+#include "UndoActions.hxx"
 
 #include <comphelper/InlineContainer.hxx>
 
 #include <com/sun/star/awt/PosSize.hpp>
 #include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XUndoSupplier.hpp>
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
 #include <com/sun/star/frame/XLoadable.hpp>
 #include <com/sun/star/util/XCloneable.hpp>
 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
 #include <com/sun/star/util/XModifyBroadcaster.hpp>
 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+#include <com/sun/star/document/XUndoAction.hpp>
 
 //-------
 // header for define RET_OK
 // object in the DTOR
 #include <svtools/acceleratorexecute.hxx>
 #include <svx/ActionDescriptionProvider.hxx>
+#include <tools/diagnose_ex.h>
 
 // enable the following define to let the controller listen to model changes and
 // react on this by rebuilding the view
     , m_eDrawMode( CHARTDRAW_SELECT )
 {
     DBG_CTOR(ChartController,NULL);
-//     m_aDispatchContainer.setUndoManager( m_xUndoManager );
     m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) );
 }
 
             m_pChartWindow->Invalidate();
     }
 
-    uno::Reference< chart2::XUndoSupplier > xUndoSupplier( getModel(), uno::UNO_QUERY );
-    if( xUndoSupplier.is())
-        m_xUndoManager.set( xUndoSupplier->getUndoManager());
+    uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
+    m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
 
 	return sal_True;
 }
 {
     // using assignment for broken gcc 3.3
     UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
-        ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE ))), m_xUndoManager, getModel() );
+        String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager );
 
     // /--
     ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
     if( aDlg.Execute() == RET_OK )
     {
         impl_adaptDataSeriesAutoResize();
-        aUndoGuard.commitAction();
+        aUndoGuard.commit();
     }
     // \--
 }
 
     // using assignment for broken gcc 3.3
     UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
-        ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES ))), m_xUndoManager, getModel() );
+        String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager );
     if( xChartDoc.is())
     {
         // /--
         if( aDlg.Execute() == RET_OK )
         {
             impl_adaptDataSeriesAutoResize();
-            aUndoGuard.commitAction();
+            aUndoGuard.commit();
         }
         // \--
     }
     UndoGuardWithSelection aUndoGuard(
         ActionDescriptionProvider::createDescription(
             (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM),
-            ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))),
-        m_xUndoManager, getModel());
+            String( SchResId( STR_OBJECT_DATASERIES ))),
+        m_xUndoManager );
 
     bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward );
     if( bChanged )
     {
         m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) );
-        aUndoGuard.commitAction();
+        aUndoGuard.commit();
     }
 }
 
 
 IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction )
 {
+    ENSURE_OR_RETURN( pUndoAction, "invalid Undo action", 1L );
+
     ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID();
     if ( aObjectCID.getLength() == 0 )
     {
-        UndoManager* pUndoManager = UndoManager::getImplementation( m_xUndoManager );
-        if ( pUndoManager )
+        try
         {
-            pUndoManager->addShapeUndoAction( pUndoAction );
+            const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
+            const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
+            const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) );
+            xUndoManager->addUndoAction( xAction );
+        }
+        catch( const uno::Exception& )
+        {
+        	DBG_UNHANDLED_EXCEPTION();
         }
     }
     return 0L;

chart2/source/controller/main/ChartController.hxx

 #include <cppuhelper/implbase12.hxx>
 
 #include <com/sun/star/accessibility/XAccessible.hpp>
-#include <com/sun/star/chart2/XUndoManager.hpp>
+#include <com/sun/star/document/XUndoManager.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
 {
 //.............................................................................
 
+class UndoGuard;
+
 enum ChartDrawMode { CHARTDRAW_INSERT, CHARTDRAW_SELECT };
 
 class WindowController
 
     bool volatile       m_bConnectingToView;
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager;
+    ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager >    m_xUndoManager;
+    ::std::auto_ptr< UndoGuard >                                                    m_pTextActionUndoGuard;
     /// needed for dispatching URLs in FeatureStateEvents
     mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
 

chart2/source/controller/main/ChartController_EditData.cxx

             ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
             // using assignment for broken gcc 3.3
             UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData(
-                ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHART_DATA ))),
-                m_xUndoManager, getModel() );
+                String( SchResId( STR_ACTION_EDIT_CHART_DATA )),
+                m_xUndoManager );
             DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC );
             // the dialog has no OK/Cancel
             aDataEditorDialog.Execute();
-            aUndoGuard.commitAction();
+            aUndoGuard.commit();
             // \--
         }
     }

chart2/source/controller/main/ChartController_Insert.cxx

 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXES )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXES ))),
+        m_xUndoManager );
 
     try
     {
                 , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC
                 , mpRefSizeProvider.get() );
             if( bChanged )
-                aUndoGuard.commitAction();
+                aUndoGuard.commit();
         }
     }
     catch( uno::RuntimeException& e)
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRIDS )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRIDS ))),
+        m_xUndoManager );
 
     try
     {
             bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram
                 , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC );
             if( bChanged )
-                aUndoGuard.commitAction();
+                aUndoGuard.commit();
         }
     }
     catch( uno::RuntimeException& e)
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLES )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLES ))),
+        m_xUndoManager );
 
     try
     {
             aDlg.getResult( aDialogOutput );
             bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput );
             if( bChanged )
-                aUndoGuard.commitAction();
+                aUndoGuard.commit();
         }
     }
     catch( uno::RuntimeException& e)
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))),
+        m_xUndoManager );
 
     LegendHelper::hideLegend( getModel() );
-    aUndoGuard.commitAction();
+    aUndoGuard.commit();
 }
 
 void ChartController::executeDispatch_InsertLegend()
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))),
+        m_xUndoManager );
 
     Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( getModel(), m_xCC );
-    aUndoGuard.commitAction();
+    aUndoGuard.commit();
 }
 
 void ChartController::executeDispatch_OpenLegendDialog()
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))),
+        m_xUndoManager );
 
     try
     {
             ControllerLockGuard aCLGuard( getModel() );
             bool bChanged = aDlg.writeToModel( getModel() );
             if( bChanged )
-                aUndoGuard.commitAction();
+                aUndoGuard.commit();
         }
     }
     catch( uno::RuntimeException& e)
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))),
+        m_xUndoManager );
 
     //if a series is selected insert labels for that series only:
     uno::Reference< chart2::XDataSeries > xSeries(
 
         bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true );
         if( bSuccess ) 
-            aUndoGuard.commitAction();
+            aUndoGuard.commit();
         return;
     }
 
             ControllerLockGuard aCLGuard( getModel() );
             bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
             if( bChanged )
-                aUndoGuard.commitAction();
+                aUndoGuard.commit();
         }
     }
     catch( uno::RuntimeException& e)
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
             ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ),
-        m_xUndoManager, getModel() );
+        m_xUndoManager );
 
     try
     {
             ControllerLockGuard aCLGuard( getModel() );
             bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
             if( bChanged )
-                aUndoGuard.commitAction();
+                aUndoGuard.commit();
         }
     }
     catch( uno::RuntimeException& e)
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
+        m_xUndoManager );
     lcl_InsertMeanValueLine( m_xCC ).operator()(
         ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ));
-    aUndoGuard.commitAction();
+    aUndoGuard.commit();
 }
 
 void ChartController::executeDispatch_InsertMenu_MeanValues()
 {
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
-            ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
-        m_xUndoManager, getModel() );
+            ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
+        m_xUndoManager );
 
     uno::Reference< chart2::XDataSeries > xSeries(
         ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY );
             DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() )));
         ::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC ));
     }
-    aUndoGuard.commitAction();
+    aUndoGuard.commit();
 }
 
 void ChartController::executeDispatch_InsertMenu_Trendlines()
     UndoGuard aUndoGuard(
         ActionDescriptionProvider::createDescription(
             ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ),
-        m_xUndoManager, getModel() );
+        m_xUndoManager );
 
     try
     {
             ControllerLockGuard aCLGuard( getModel() );
             bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
             if( bChanged )
-                aUndoGuard.commitAction();
+                aUndoGuard.commit();
         }
     }
     catch( uno::RuntimeException& e)
     {
         UndoLiveUpdateGuard aUndoGuard(
             ActionDescriptionProvider::createDescription(
-                ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))),
-            m_xUndoManager, getModel() );
+                ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))),
+            m_xUndoManager );
 
         // add a linear curve
         RegressionCurveHelper::addRegressionCurve(
                 ControllerLockGuard aCLGuard( getModel() );
                 aItemConverter.ApplyItemSet( *pOutItemSet );
             }
-            aUndoGuard.commitAction();
+            aUndoGuard.commit();
         }
     }
 }
     {
         UndoLiveUpdateGuard aUndoGuard(
             ActionDescriptionProvider::createDescription(
-                ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))),
-            m_xUndoManager, getModel() );
+                ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_ERROR_BARS ))),
+            m_xUndoManager );
 
         // add error bars with standard deviation
         uno::Reference< beans::XPropertySet > xErrorBarProp(
                 ControllerLockGuard aCLGuard( getModel() );
                 aItemConverter.ApplyItemSet( *pOutItemSet );
             }
-            aUndoGuard.commitAction();
+            aUndoGuard.commit();
         }
     }
 }
             // using assignment for broken gcc 3.3
             UndoGuard aUndoGuard = UndoGuard(
                 ActionDescriptionProvider::createDescription(
-                    ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
-                m_xUndoManager, getModel() );
+                    ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),