summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/inc/scextopt.hxx2
-rw-r--r--sc/inc/servuno.hxx3
-rw-r--r--sc/inc/table.hxx4
-rw-r--r--sc/source/core/data/document.cxx33
-rw-r--r--sc/source/core/data/table1.cxx1
-rw-r--r--sc/source/filter/excel/excimp8.cxx8
-rw-r--r--sc/source/filter/inc/excimp8.hxx1
-rw-r--r--sc/source/ui/unoobj/servuno.cxx78
9 files changed, 130 insertions, 5 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e21b0af336f0..f74d1b1f5753 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -287,6 +287,7 @@ private:
::std::auto_ptr<ScExternalRefManager> pExternalRefMgr;
String aDocName; // opt: Dokumentname
+ String aDocCodeName; // opt: Dokumentname
ScRangePairListRef xColNameRanges;
ScRangePairListRef xRowNameRanges;
@@ -433,6 +434,8 @@ public:
SC_DLLPUBLIC const String& GetName() const { return aDocName; }
void SetName( const String& r ) { aDocName = r; }
+ const String& GetCodeName() const { return aDocCodeName; }
+ void SetCodeName( const String& r ) { aDocCodeName = r; }
void GetDocStat( ScDocStat& rDocStat );
@@ -523,6 +526,8 @@ public:
SC_DLLPUBLIC BOOL HasTable( SCTAB nTab ) const;
SC_DLLPUBLIC BOOL GetName( SCTAB nTab, String& rName ) const;
+ SC_DLLPUBLIC BOOL GetCodeName( SCTAB nTab, String& rName ) const;
+ SC_DLLPUBLIC BOOL SetCodeName( SCTAB nTab, String& rName );
SC_DLLPUBLIC BOOL GetTable( const String& rName, SCTAB& rTab ) const;
SC_DLLPUBLIC inline SCTAB GetTableCount() const { return nMaxTableNumber; }
SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
diff --git a/sc/inc/scextopt.hxx b/sc/inc/scextopt.hxx
index 4b3f763b4e8c..5f60fdc0c676 100644
--- a/sc/inc/scextopt.hxx
+++ b/sc/inc/scextopt.hxx
@@ -126,6 +126,8 @@ public:
const String& GetCodeName( size_t nIdx ) const;
/** Appends a codename for a sheet. */
void AppendCodeName( const String& rCodeName );
+ void SetCodeName( const String& rCodeName, size_t nIdx );
+ void DeleteCodeName( size_t nIdx );
private:
::std::auto_ptr< ScExtDocOptionsImpl > mxImpl;
diff --git a/sc/inc/servuno.hxx b/sc/inc/servuno.hxx
index ace44dc5be4d..a468c088d2d4 100644
--- a/sc/inc/servuno.hxx
+++ b/sc/inc/servuno.hxx
@@ -93,8 +93,9 @@ class ScDocShell;
#define SC_SERVICE_FORMULAPARS 38
#define SC_SERVICE_OPCODEMAPPER 39
+#define SC_SERVICE_VBACODENAMEPROVIDER 40
-#define SC_SERVICE_COUNT 40
+#define SC_SERVICE_COUNT 41
#define SC_SERVICE_INVALID USHRT_MAX
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e738ff5fbdb8..03be8eca157f 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -81,6 +81,7 @@ private:
ScColumn aCol[MAXCOLCOUNT];
String aName;
+ String aCodeName;
String aComment;
BOOL bScenario;
BOOL bLayoutRTL;
@@ -212,6 +213,9 @@ public:
void GetName( String& rName ) const;
void SetName( const String& rNewName );
+ void GetCodeName( String& rName ) const { rName = aCodeName; }
+ void SetCodeName( const String& rNewName ) { aCodeName = rNewName; }
+
const String& GetUpperName() const;
const String& GetPageStyle() const { return aPageStyle; }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index c58e054fb62a..9cf0151896d3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -150,6 +150,32 @@ BOOL ScDocument::GetName( SCTAB nTab, String& rName ) const
return FALSE;
}
+BOOL ScDocument::SetCodeName( SCTAB nTab, String& rName )
+{
+ if (VALIDTAB(nTab))
+ {
+ if (pTab[nTab])
+ {
+ pTab[nTab]->SetCodeName( rName );
+ return TRUE;
+ }
+ }
+ OSL_TRACE( "**** can't set code name %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ return FALSE;
+}
+
+BOOL ScDocument::GetCodeName( SCTAB nTab, String& rName ) const
+{
+ if (VALIDTAB(nTab))
+ if (pTab[nTab])
+ {
+ pTab[nTab]->GetCodeName( rName );
+ return TRUE;
+ }
+ rName.Erase();
+ return FALSE;
+}
+
BOOL ScDocument::GetTable( const String& rName, SCTAB& rTab ) const
{
@@ -289,6 +315,7 @@ BOOL ScDocument::InsertTab( SCTAB nPos, const String& rName,
if (nPos == SC_TAB_APPEND || nPos == nTabCount)
{
pTab[nTabCount] = new ScTable(this, nTabCount, rName);
+ pTab[nTabCount]->SetCodeName( rName );
++nMaxTableNumber;
if ( bExternalDocument )
pTab[nTabCount]->SetVisible( FALSE );
@@ -321,10 +348,16 @@ BOOL ScDocument::InsertTab( SCTAB nPos, const String& rName,
for (i = 0; i <= MAXTAB; i++)
if (pTab[i])
pTab[i]->UpdateInsertTab(nPos);
+
for (i = nTabCount; i > nPos; i--)
+ {
pTab[i] = pTab[i - 1];
+ }
+
pTab[nPos] = new ScTable(this, nPos, rName);
+ pTab[nPos]->SetCodeName( rName );
++nMaxTableNumber;
+
for (i = 0; i <= MAXTAB; i++)
if (pTab[i])
pTab[i]->UpdateCompile();
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 03b9fc9d90be..6546741860f7 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -124,6 +124,7 @@ extern BOOL bIsOlk, bOderSo;
ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
BOOL bColInfo, BOOL bRowInfo ) :
aName( rNewName ),
+ aCodeName( rNewName ),
bScenario( FALSE ),
bLayoutRTL( FALSE ),
bLoadingRTL( FALSE ),
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index b62470ceee3b..9e06dede525f 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -113,7 +113,7 @@ using namespace com::sun::star;
ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
- ImportExcel( rImpData, rStrm )
+ ImportExcel( rImpData, rStrm ), mnTab(0)
{
delete pFormConv;
@@ -242,9 +242,15 @@ void ImportExcel8::Codename( BOOL bWorkbookGlobals )
if( aName.Len() )
{
if( bWorkbookGlobals )
+ {
GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
+ GetDoc().SetCodeName( aName );
+ }
else
+ {
GetExtDocOptions().AppendCodeName( aName );
+ GetDoc().SetCodeName( mnTab++, aName );
+ }
}
}
}
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index 2f3913f01c57..0acf4c09501b 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -52,6 +52,7 @@ class XclImpStream;
class ImportExcel8 : public ImportExcel
{
+ SCTAB mnTab;
protected:
ExcScenarioList aScenList;
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 71f45e6ab12b..d4ef17e79a8d 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -60,9 +60,65 @@
// #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
#include <svx/xmleohlp.hxx>
#include <svx/xmlgrhlp.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/document/XCodeNameQuery.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
using namespace ::com::sun::star;
+class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
+{
+ScDocShell* mpDocShell;
+public:
+ ScVbaCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
+ // XCodeNameQuery
+ rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
+ {
+ rtl::OUString sCodeName;
+ if ( mpDocShell )
+ {
+ OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
+ // need to find the page ( and index ) for this control
+ uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
+ sal_Int32 nLen = xIndex->getCount();
+ bool bMatched = false;
+ uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
+ for ( sal_Int32 index = 0; index < nLen; ++index )
+ {
+ try
+ {
+ uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+ // get the www-standard container
+ uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
+ sal_Int32 nCntrls = xFormControls->getCount();
+ for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
+ {
+ uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
+ bMatched = ( xControl == xIf );
+ if ( bMatched )
+ {
+ String sName;
+ mpDocShell->GetDocument()->GetCodeName( static_cast<SCTAB>( index ), sName );
+ sCodeName = sName;
+ }
+ }
+ }
+ catch( uno::Exception& ) {}
+ if ( bMatched )
+ break;
+ }
+ }
+ // Probably should throw here ( if !bMatched )
+ return sCodeName;
+ }
+
+};
//------------------------------------------------------------------------
@@ -112,7 +168,8 @@ static const sal_Char* __FAR_DATA aProvNames[SC_SERVICE_COUNT] =
SC_SERVICENAME_CHDATAPROV, // SC_SERVICE_CHDATAPROV
SC_SERVICENAME_FORMULAPARS, // SC_SERVICE_FORMULAPARS
- SC_SERVICENAME_OPCODEMAPPER // SC_SERVICE_OPCODEMAPPER
+ SC_SERVICENAME_OPCODEMAPPER, // SC_SERVICE_OPCODEMAPPER
+ "ooo.vba.VBACodeNameProvider", // SC_SERVICE_OPCODEMAPPER
};
//
@@ -164,7 +221,8 @@ static const sal_Char* __FAR_DATA aOldNames[SC_SERVICE_COUNT] =
"", // SC_SERVICE_SHEETDOCSET
"", // SC_SERVICE_CHDATAPROV
"", // SC_SERVICE_FORMULAPARS
- "" // SC_SERVICE_OPCODEMAPPER
+ "", // SC_SERVICE_OPCODEMAPPER
+ "", // SC_SERVICE_VBACODENAMEPROVIDER
};
@@ -361,9 +419,23 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
ScCompiler* pComp = new ScCompiler(pDoc,aAddress);
pComp->SetGrammar( pDoc->GetGrammar() );
xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> (pComp))));
+ break;
}
- break;
+ case SC_SERVICE_VBACODENAMEPROVIDER:
+ {
+ // Only create the excel faking service for excel docs
+ const SfxFilter *pFilt = pDocShell->GetMedium()->GetFilter();
+ if ( pFilt && pFilt->IsAlienFormat() )
+ {
+ // application/vnd.ms-excel is the mime type for Excel
+ static const rtl::OUString sExcelMimeType( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.ms-excel" ) );
+ if ( sExcelMimeType.equals( pFilt->GetMimeType() ) )
+ xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
+ }
+ break;
+ }
}
+
return xRet;
}