diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2010-02-04 16:22:08 +0100 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2010-02-04 16:22:08 +0100 |
commit | 664b49ae1768b45294d04c480074029750a51ec6 (patch) | |
tree | 52f729535779370800b63cfa046f05273f10b54a | |
parent | 25b005cbda460837f063ddf996c1ec72d4f4865b (diff) | |
parent | e1842855acab54883d4b17cb520ef4f622d05bb4 (diff) |
CWS-TOOLING: integrate CWS ab71
-rw-r--r-- | sc/inc/document.hxx | 5 | ||||
-rw-r--r-- | sc/inc/scextopt.hxx | 2 | ||||
-rw-r--r-- | sc/inc/servuno.hxx | 3 | ||||
-rw-r--r-- | sc/inc/table.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 33 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/excel/excimp8.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/inc/excimp8.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/unoobj/servuno.cxx | 76 |
9 files changed, 129 insertions, 4 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index cc575b529d73..bace1d6a8cfa 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 fdf05430cc69..9e779b0366ae 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 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 f400054d00b7..a956bbf5874c 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 f8fa2bc46c9b..9d35510656f7 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 403377342661..dfe27b2354e7 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 a172bd63e69b..513a39231ba1 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 9bd633eae879..8a30d6f9e9c5 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 1f51bc1646af..47e1be008645 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; } |