update ooo310-m15
[ooovba.git] / applied_patches / 0407-vba-fix-copysheet-toend.diff
bloba88044f0a0850c1576a377219fad95f2ff876ec8
1 diff --git sc/source/ui/docshell/docsh5.cxx sc/source/ui/docshell/docsh5.cxx
2 index 3b5986c..fe54573 100644
3 --- sc/source/ui/docshell/docsh5.cxx
4 +++ sc/source/ui/docshell/docsh5.cxx
5 @@ -69,6 +69,7 @@
6 #include "waitoff.hxx"
7 #include "sizedev.hxx"
8 #include <basic/sbstar.hxx>
9 +#include <basic/basmgr.hxx>
11 // defined in docfunc.cxx
12 void lcl_InsertModule( ScDocShell& rDocSh, SCTAB nTab, String& sModuleName, String& sModuleSource );
13 @@ -844,17 +845,27 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec
16 StarBASIC* pStarBASIC = GetBasic();
17 + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
18 + if ( GetBasicManager()->GetName().Len() > 0 )
19 + {
20 + aLibName = GetBasicManager()->GetName();
21 + pStarBASIC = GetBasicManager()->GetLib( aLibName );
22 + }
23 BOOL bVbaEnabled = pStarBASIC ? pStarBASIC->isVBAEnabled() : FALSE;
24 + SCTAB nTabToUse = nDestTab;
26 + if ( nDestTab == SC_TAB_APPEND )
27 + nTabToUse = aDocument.GetMaxTableNumber() - 1;
29 if ( bVbaEnabled )
31 String sCodeName;
32 String sSource;
33 - aDocument.GetCodeName( nDestTab, sCodeName );
34 + aDocument.GetCodeName( nTabToUse, sCodeName );
35 com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer();
36 com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib;
37 if( xLibContainer.is() )
39 - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
40 com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName );
41 aLibAny >>= xLib;
43 @@ -867,7 +878,7 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec
44 xLib->getByName( sModName ) >>= sModuleInfo;
45 sSource = sModuleInfo.ModuleSource;
47 - lcl_InsertModule( *this, nDestTab, sCodeName, sSource );
48 + lcl_InsertModule( *this, nTabToUse, sCodeName, sSource );