summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-02-04 16:22:08 +0100
committerVladimir Glazunov <vg@openoffice.org>2010-02-04 16:22:08 +0100
commit3554f1e3e0bdfa936ecd49f7d3b4c93be59b8c43 (patch)
tree3ebdb421d0ebe43d197b6c75e8927b8d1d7172bf
parent64666f2a50a08fa43c5c83ed000bdecc26d72740 (diff)
parent0b2a5c8d1a41700496755e2922d38169b9febd67 (diff)
CWS-TOOLING: integrate CWS ab71
-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.cxx76
9 files changed, 129 insertions, 4 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 91336201f..03d2c03d2 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -291,6 +291,7 @@ private:
mxFormulaParserPool; /// Pool for all external formula parsers used by this document.
String aDocName; // opt: Dokumentname
+ String aDocCodeName; // opt: Dokumentname
ScRangePairListRef xColNameRanges;
ScRangePairListRef xRowNameRanges;
@@ -435,6 +436,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 );
@@ -520,6 +523,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 d9e654e46..64b2f5b52 100644
--- a/sc/inc/scextopt.hxx
+++ b/sc/inc/scextopt.hxx
@@ -124,6 +124,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 f32dedcb2..081eac69e 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 4001f74e8..3b5532d25 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -89,6 +89,7 @@ private:
ScColumn aCol[MAXCOLCOUNT];
String aName;
+ String aCodeName;
String aComment;
BOOL bScenario;
BOOL bLayoutRTL;
@@ -229,6 +230,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 4cb1331ba..458f94fc0 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -154,6 +154,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
{
@@ -293,6 +319,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 );
@@ -320,10 +347,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;
+
// UpdateBroadcastAreas must be called between UpdateInsertTab,
// which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners.
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 22d9f6405..df37a1bee 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -125,6 +125,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 9b0b1b601..b873194ea 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -117,7 +117,7 @@ using namespace com::sun::star;
ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
- ImportExcel( rImpData, rStrm )
+ ImportExcel( rImpData, rStrm ), mnTab(0)
{
delete pFormConv;
@@ -240,9 +240,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 fadad4125..c3b369365 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 e36c88cda..207acf2a1 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;
+ }
+
+};
//------------------------------------------------------------------------
//
@@ -119,6 +175,7 @@ static const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
{ SC_SERVICENAME_CHDATAPROV, SC_SERVICE_CHDATAPROV },
{ SC_SERVICENAME_FORMULAPARS, SC_SERVICE_FORMULAPARS },
{ SC_SERVICENAME_OPCODEMAPPER, SC_SERVICE_OPCODEMAPPER },
+ { "ooo.vba.VBACodeNameProvider", SC_SERVICE_VBACODENAMEPROVIDER },
// case-correct versions of the service names (#i102468#)
{ "com.sun.star.text.textfield.URL", SC_SERVICE_URLFIELD },
@@ -180,7 +237,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
};
@@ -383,9 +441,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;
}