diff options
47 files changed, 417 insertions, 333 deletions
diff --git a/sc/inc/collect.hxx b/sc/inc/collect.hxx index 8f6388a86040..dc7778d12da3 100644 --- a/sc/inc/collect.hxx +++ b/sc/inc/collect.hxx @@ -80,7 +80,7 @@ public: ScDataObject* At(USHORT nIndex) const; virtual USHORT IndexOf(ScDataObject* pScDataObject) const; - USHORT GetCount() const { return nCount; } + USHORT GetCount() const; ScDataObject* operator[]( const USHORT nIndex) const {return At(nIndex);} ScCollection& operator=( const ScCollection& rCol ); @@ -192,6 +192,7 @@ public: TypedScStrCollection( const TypedScStrCollection& rCpy ) : ScSortedCollection( rCpy ) { bCaseSensitive = rCpy.bCaseSensitive; } + ~TypedScStrCollection(); virtual ScDataObject* Clone() const; virtual short Compare( ScDataObject* pKey1, ScDataObject* pKey2 ) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 566bd07b6223..6711a2c974ad 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -258,7 +258,7 @@ private: ScChartCollection* pChartCollection; std::auto_ptr< ScTemporaryChartLock > apTemporaryChartLock; ScPatternAttr* pSelectionAttr; // Attribute eines Blocks - SvxLinkManager* pLinkManager; + mutable SvxLinkManager* pLinkManager; ScFormulaCell* pFormulaTree; // Berechnungsbaum Start ScFormulaCell* pEOFormulaTree; // Berechnungsbaum Ende, letzte Zelle ScFormulaCell* pFormulaTrack; // BroadcastTrack Start @@ -440,7 +440,7 @@ public: SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = NULL ); XColorTable* GetColorTable(); - SvxLinkManager* GetLinkManager() { return pLinkManager; } + SC_DLLPUBLIC SvxLinkManager* GetLinkManager() const; SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const; SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt ); @@ -512,7 +512,7 @@ public: ::com::sun::star::embed::XEmbeddedObject > FindOleObjectByName( const String& rName ); - SC_DLLPUBLIC void MakeTable( SCTAB nTab ); + SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true ); SCTAB GetVisibleTab() const { return nVisibleTab; } SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; } diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index e46decce34ed..0d69c9f68670 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -111,6 +111,7 @@ private: BOOL FillRenderMarkData( const com::sun::star::uno::Any& aSelection, ScMarkData& rMark, ScPrintSelectionStatus& rStatus ) const; + com::sun::star::uno::Reference<com::sun::star::uno::XAggregation> GetFormatter(); rtl::OUString maBuildId; protected: diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 7bdff1d0592e..1f6dc13d04ce 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -541,9 +541,15 @@ class ScGlobal static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XOrdinalSuffix> xOrdinalSuffix; + static CalendarWrapper* pCalendar; + static CollatorWrapper* pCaseCollator; + static CollatorWrapper* pCollator; + static ::utl::TransliterationWrapper* pTransliteration; + static ::utl::TransliterationWrapper* pCaseTransliteration; + static IntlWrapper* pScIntlWrapper; + static ::com::sun::star::lang::Locale* pLocale; public: - static ::com::sun::star::lang::Locale* pLocale; static SvtSysLocale* pSysLocale; // for faster access a pointer to the single instance provided by SvtSysLocale SC_DLLPUBLIC static const CharClass* pCharClass; @@ -551,15 +557,15 @@ public: SC_DLLPUBLIC static const LocaleDataWrapper* pLocaleData; SC_DLLPUBLIC static const LocaleDataWrapper* GetpLocaleData(); - static CalendarWrapper* pCalendar; - SC_DLLPUBLIC static CollatorWrapper* pCollator; - static CollatorWrapper* pCaseCollator; + static CalendarWrapper* GetCalendar(); + SC_DLLPUBLIC static CollatorWrapper* GetCollator(); + static CollatorWrapper* GetCaseCollator(); + static IntlWrapper* GetScIntlWrapper(); + static ::com::sun::star::lang::Locale* GetLocale(); - static ::utl::TransliterationWrapper* pTransliteration; SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration(); //CHINA001 + static ::utl::TransliterationWrapper* GetCaseTransliteration(); - static ::utl::TransliterationWrapper* pCaseTransliteration; - static IntlWrapper* pScIntlWrapper; SC_DLLPUBLIC static LanguageType eLnge; static sal_Unicode cListDelimiter; diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx index d106e5824571..2daa10fa29d4 100644 --- a/sc/source/core/data/autonamecache.cxx +++ b/sc/source/core/data/autonamecache.cxx @@ -99,7 +99,7 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurences( const String& rNa ; // nothing, prevent compiler warning break; } - if ( ScGlobal::pTransliteration->isEqual( aStr, rName ) ) + if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rName ) ) { rAddresses.push_back( ScAddress( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ) ); } diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index b4d8a5972211..45ead48d0f35 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -786,7 +786,7 @@ BOOL ScConditionEntry::IsValidStr( const String& rArg ) const String aUpVal2( aStrVal2 ); if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN ) - if ( ScGlobal::pCollator->compareString( aUpVal1, aUpVal2 ) + if ( ScGlobal::GetCollator()->compareString( aUpVal1, aUpVal2 ) == COMPARE_GREATER ) { // richtige Reihenfolge fuer Wertebereich @@ -797,16 +797,16 @@ BOOL ScConditionEntry::IsValidStr( const String& rArg ) const switch ( eOp ) { case SC_COND_EQUAL: - bValid = (ScGlobal::pCollator->compareString( + bValid = (ScGlobal::GetCollator()->compareString( rArg, aUpVal1 ) == COMPARE_EQUAL); break; case SC_COND_NOTEQUAL: - bValid = (ScGlobal::pCollator->compareString( + bValid = (ScGlobal::GetCollator()->compareString( rArg, aUpVal1 ) != COMPARE_EQUAL); break; default: { - sal_Int32 nCompare = ScGlobal::pCollator->compareString( + sal_Int32 nCompare = ScGlobal::GetCollator()->compareString( rArg, aUpVal1 ); switch ( eOp ) { @@ -826,7 +826,7 @@ BOOL ScConditionEntry::IsValidStr( const String& rArg ) const case SC_COND_NOTBETWEEN: // Test auf NOTBETWEEN: bValid = ( nCompare == COMPARE_LESS || - ScGlobal::pCollator->compareString( rArg, + ScGlobal::GetCollator()->compareString( rArg, aUpVal2 ) == COMPARE_GREATER ); if ( eOp == SC_COND_BETWEEN ) bValid = !bValid; diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 3b650f5d8ca4..b88cd49a6a8c 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1074,8 +1074,8 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() ScBaseCell* pCell; SCSIZE nHi, nLo; - CollatorWrapper* pCollator = (aParam.bCaseSens ? ScGlobal::pCaseCollator : - ScGlobal::pCollator); + CollatorWrapper* pCollator = (aParam.bCaseSens ? ScGlobal::GetCaseCollator() : + ScGlobal::GetCollator()); SvNumberFormatter& rFormatter = *(pDoc->GetFormatTable()); const ScQueryEntry& rEntry = aParam.GetEntry(0); bool bLessEqual = rEntry.eOp == SC_LESS_EQUAL; diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx index c2a77a0d0ede..fce83f25cd93 100644 --- a/sc/source/core/data/docpool.cxx +++ b/sc/source/core/data/docpool.cxx @@ -741,7 +741,7 @@ SfxItemPresentation lcl_HFPresentation default: if ( !pIntl ) - pIntl = ScGlobal::pScIntlWrapper; + pIntl = ScGlobal::GetScIntlWrapper(); pItem->GetPresentation( ePresentation, eCoreMetric, ePresentationMetric, aText, pIntl ); } @@ -1018,7 +1018,7 @@ SfxItemPresentation __EXPORT ScDocumentPool::GetPresentation( default: if ( !pIntl ) - pIntl = ScGlobal::pScIntlWrapper; + pIntl = ScGlobal::GetScIntlWrapper(); ePresentation = rItem.GetPresentation( ePresentation, GetMetric( nW ), ePresentationMetric, rText, pIntl ); break; } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index ae1f087a23a8..4949254b7ab8 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -262,6 +262,15 @@ ScDocument::ScDocument( ScDocumentMode eMode, aTrackTimer.SetTimeout( 100 ); } +SvxLinkManager* ScDocument::GetLinkManager() const +{ + if ( bAutoCalc && !pLinkManager && pShell) + { + pLinkManager = new SvxLinkManager( pShell ); + } + return pLinkManager; +} + void ScDocument::SetStorageGrammar( formula::FormulaGrammar::Grammar eGram ) { @@ -372,7 +381,7 @@ ScDocument::~ScDocument() // Links aufrauemen - if ( pLinkManager ) + if ( GetLinkManager() ) { // BaseLinks freigeben for ( USHORT n = pLinkManager->GetServers().Count(); n; ) diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index dba29553462e..7355fb5241ce 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -428,7 +428,7 @@ BOOL ScDocument::LinkExternalTab( SCTAB& rTab, const String& aDocTab, { ScTableLink* pLink = new ScTableLink( pShell, aFileName, aFilterName, aOptions, nRefreshDelay ); pLink->SetInCreate( TRUE ); - pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, + GetLinkManager()->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, &aFilterName ); pLink->Update(); pLink->SetInCreate( FALSE ); @@ -1735,10 +1735,7 @@ void ScDocument::SetDocOptions( const ScDocOptions& rOpt ) *pDocOptions = rOpt; rOpt.GetDate( d,m,y ); - SvNumberFormatter* pFormatter = xPoolHelper->GetFormTable(); - pFormatter->ChangeNullDate( d,m,y ); - pFormatter->ChangeStandardPrec( (USHORT)rOpt.GetStdPrecision() ); - pFormatter->SetYear2000( rOpt.GetYear2000() ); + xPoolHelper->SetFormTableOpt(rOpt); } const ScViewOptions& ScDocument::GetViewOptions() const diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index b337cc902aef..620a8a6a3e13 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -925,7 +925,7 @@ BOOL ScDocument::IdleCheckLinks() // TRUE = demnaechst wieder versuche { BOOL bAnyLeft = FALSE; - if (pLinkManager) + if (GetLinkManager()) { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -953,7 +953,7 @@ void ScDocument::SaveDdeLinks(SvStream& rStream) const // bei 4.0-Export alle mit Modus != DEFAULT weglassen BOOL bExport40 = ( rStream.GetVersion() <= SOFFICE_FILEFORMAT_40 ); - const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); + const ::sfx2::SvBaseLinks& rLinks = GetLinkManager()->GetLinks(); USHORT nCount = rLinks.Count(); // erstmal zaehlen... @@ -991,6 +991,7 @@ void ScDocument::LoadDdeLinks(SvStream& rStream) { ScMultipleReadHeader aHdr( rStream ); + GetLinkManager(); USHORT nCount; rStream >> nCount; for (USHORT i=0; i<nCount; i++) @@ -1003,7 +1004,7 @@ void ScDocument::LoadDdeLinks(SvStream& rStream) BOOL ScDocument::HasDdeLinks() const { - if (pLinkManager) // Clipboard z.B. hat keinen LinkManager + if (GetLinkManager()) // Clipboard z.B. hat keinen LinkManager { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1030,7 +1031,7 @@ BOOL ScDocument::IsInLinkUpdate() const void ScDocument::UpdateExternalRefLinks() { - if (!pLinkManager) + if (!GetLinkManager()) return; const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); @@ -1069,7 +1070,7 @@ void ScDocument::UpdateExternalRefLinks() void ScDocument::UpdateDdeLinks() { - if (pLinkManager) + if (GetLinkManager()) { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1115,7 +1116,7 @@ BOOL ScDocument::UpdateDdeLink( const String& rAppl, const String& rTopic, const //! wenn's mal alles asynchron wird, aber auch hier BOOL bFound = FALSE; - if (pLinkManager) + if (GetLinkManager()) { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1140,7 +1141,7 @@ BOOL ScDocument::UpdateDdeLink( const String& rAppl, const String& rTopic, const void ScDocument::DisconnectDdeLinks() { - if (pLinkManager) + if (GetLinkManager()) { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1163,7 +1164,7 @@ void ScDocument::CopyDdeLinks( ScDocument* pDestDoc ) const pDestDoc->LoadDdeLinks(*pClipData); } } - else if (pLinkManager) // Links direkt kopieren + else if (GetLinkManager()) // Links direkt kopieren { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1184,7 +1185,7 @@ void ScDocument::CopyDdeLinks( ScDocument* pDestDoc ) const USHORT ScDocument::GetDdeLinkCount() const { USHORT nDdeCount = 0; - if (pLinkManager) + if (GetLinkManager()) { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1260,12 +1261,12 @@ ScDdeLink* lclGetDdeLink( const SvxLinkManager* pLinkManager, USHORT nDdePos ) bool ScDocument::FindDdeLink( const String& rAppl, const String& rTopic, const String& rItem, BYTE nMode, USHORT& rnDdePos ) { - return lclGetDdeLink( pLinkManager, rAppl, rTopic, rItem, nMode, &rnDdePos ) != NULL; + return lclGetDdeLink( GetLinkManager(), rAppl, rTopic, rItem, nMode, &rnDdePos ) != NULL; } bool ScDocument::GetDdeLinkData( USHORT nDdePos, String& rAppl, String& rTopic, String& rItem ) const { - if( const ScDdeLink* pDdeLink = lclGetDdeLink( pLinkManager, nDdePos ) ) + if( const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) ) { rAppl = pDdeLink->GetAppl(); rTopic = pDdeLink->GetTopic(); @@ -1277,7 +1278,7 @@ bool ScDocument::GetDdeLinkData( USHORT nDdePos, String& rAppl, String& rTopic, bool ScDocument::GetDdeLinkMode( USHORT nDdePos, BYTE& rnMode ) const { - if( const ScDdeLink* pDdeLink = lclGetDdeLink( pLinkManager, nDdePos ) ) + if( const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) ) { rnMode = pDdeLink->GetMode(); return true; @@ -1287,7 +1288,7 @@ bool ScDocument::GetDdeLinkMode( USHORT nDdePos, BYTE& rnMode ) const const ScMatrix* ScDocument::GetDdeLinkResultMatrix( USHORT nDdePos ) const { - const ScDdeLink* pDdeLink = lclGetDdeLink( pLinkManager, nDdePos ); + const ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ); return pDdeLink ? pDdeLink->GetResult() : NULL; } @@ -1298,7 +1299,7 @@ bool ScDocument::CreateDdeLink( const String& rAppl, const String& rTopic, const on existing and new links. */ //! store DDE links additionally at document (for efficiency)? DBG_ASSERT( nMode != SC_DDE_IGNOREMODE, "ScDocument::CreateDdeLink - SC_DDE_IGNOREMODE not allowed here" ); - if( pLinkManager && (nMode != SC_DDE_IGNOREMODE) ) + if( GetLinkManager() && (nMode != SC_DDE_IGNOREMODE) ) { ScDdeLink* pDdeLink = lclGetDdeLink( pLinkManager, rAppl, rTopic, rItem, nMode ); if( !pDdeLink ) @@ -1319,7 +1320,7 @@ bool ScDocument::CreateDdeLink( const String& rAppl, const String& rTopic, const bool ScDocument::SetDdeLinkResultMatrix( USHORT nDdePos, ScMatrix* pResults ) { - if( ScDdeLink* pDdeLink = lclGetDdeLink( pLinkManager, nDdePos ) ) + if( ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) ) { pDdeLink->SetResult( pResults ); return true; @@ -1331,7 +1332,7 @@ bool ScDocument::SetDdeLinkResultMatrix( USHORT nDdePos, ScMatrix* pResults ) BOOL ScDocument::HasAreaLinks() const { - if (pLinkManager) // Clipboard z.B. hat keinen LinkManager + if (GetLinkManager()) // Clipboard z.B. hat keinen LinkManager { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1345,7 +1346,7 @@ BOOL ScDocument::HasAreaLinks() const void ScDocument::UpdateAreaLinks() { - if (pLinkManager) + if (GetLinkManager()) { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nCount = rLinks.Count(); @@ -1360,7 +1361,7 @@ void ScDocument::UpdateAreaLinks() void ScDocument::DeleteAreaLinksOnTab( SCTAB nTab ) { - if (pLinkManager) + if (GetLinkManager()) { const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); USHORT nPos = 0; @@ -1379,7 +1380,7 @@ void ScDocument::DeleteAreaLinksOnTab( SCTAB nTab ) void ScDocument::UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode, const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) { - if (pLinkManager) + if (GetLinkManager()) { bool bAnyUpdate = false; diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index 793be9a8c2e9..de27a80b17ee 100644 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -223,7 +223,7 @@ void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell ) if ( pShell && !pShell->IsLoading() ) // #88438# don't call GetTitle while loading aName = pShell->GetTitle(); pDrawLayer = new ScDrawLayer( this, aName ); - if (pLinkManager) + if (GetLinkManager()) pDrawLayer->SetLinkManager( pLinkManager ); // Drawing pages are accessed by table number, so they must also be present diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index e5af00781cff..0150593fa6ef 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -115,13 +115,14 @@ struct ScLessDefaultAttr typedef std::set<ScDefaultAttr, ScLessDefaultAttr> ScDefaultAttrSet; -void ScDocument::MakeTable( SCTAB nTab ) +void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck ) { if ( ValidTab(nTab) && !pTab[nTab] ) { String aString = ScGlobal::GetRscString(STR_TABLE_DEF); //"Tabelle" aString += String::CreateFromInt32(nTab+1); - CreateValidTabName( aString ); // keine doppelten + if ( _bNeedsNameCheck ) + CreateValidTabName( aString ); // keine doppelten pTab[nTab] = new ScTable(this, nTab, aString); ++nMaxTableNumber; @@ -219,7 +220,7 @@ BOOL ScDocument::ValidNewTabName( const String& rName ) const { String aOldName; pTab[i]->GetName(aOldName); - bValid = !ScGlobal::pTransliteration->isEqual( rName, aOldName ); + bValid = !ScGlobal::GetpTransliteration()->isEqual( rName, aOldName ); } return bValid; } @@ -464,7 +465,7 @@ BOOL ScDocument::RenameTab( SCTAB nTab, const String& rName, BOOL /* bUpdateRef { String aOldName; pTab[i]->GetName(aOldName); - bValid = !ScGlobal::pTransliteration->isEqual( rName, aOldName ); + bValid = !ScGlobal::GetpTransliteration()->isEqual( rName, aOldName ); } if (bValid) { diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx index a92d1681ec0e..a2d21079826d 100644 --- a/sc/source/core/data/dpgroup.cxx +++ b/sc/source/core/data/dpgroup.cxx @@ -250,7 +250,7 @@ String lcl_GetDateGroupName( sal_Int32 nDatePart, sal_Int32 nValue, SvNumberForm break; case com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS: //! cache getMonths() result? - aRet = ScGlobal::pCalendar->getDisplayName( + aRet = ScGlobal::GetCalendar()->getDisplayName( ::com::sun::star::i18n::CalendarDisplayIndex::MONTH, sal_Int16(nValue-1), 0 ); // 0-based, get short name break; diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 1f1ebbc45d18..787875fcb5ff 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1098,7 +1098,7 @@ bool lcl_IsAtStart( const String& rList, const String& rSearch, sal_Int32& rMatc } } - if ( bParsed && ScGlobal::pTransliteration->isEqual( aDequoted, rSearch ) ) + if ( bParsed && ScGlobal::GetpTransliteration()->isEqual( aDequoted, rSearch ) ) { nMatchList = nQuoteEnd; // match count in the list string, including quotes nMatchSearch = rSearch.Len(); @@ -1107,7 +1107,7 @@ bool lcl_IsAtStart( const String& rList, const String& rSearch, sal_Int32& rMatc else { // otherwise look for search string at the start of rList - ScGlobal::pTransliteration->equals( rList, 0, rList.Len(), nMatchList, + ScGlobal::GetpTransliteration()->equals( rList, 0, rList.Len(), nMatchList, rSearch, 0, rSearch.Len(), nMatchSearch ); } diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 63acede160c9..d1fad68f16a2 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1192,20 +1192,20 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>& bool lcl_IsNamedDataField( const ScDPGetPivotDataField& rTarget, const String& rSourceName, const String& rGivenName ) { // match one of the names, ignoring case - return ScGlobal::pTransliteration->isEqual( rTarget.maFieldName, rSourceName ) || - ScGlobal::pTransliteration->isEqual( rTarget.maFieldName, rGivenName ); + return ScGlobal::GetpTransliteration()->isEqual( rTarget.maFieldName, rSourceName ) || + ScGlobal::GetpTransliteration()->isEqual( rTarget.maFieldName, rGivenName ); } bool lcl_IsNamedCategoryField( const ScDPGetPivotDataField& rFilter, const ScDPOutLevelData& rField ) { //! name from source instead of caption? - return ScGlobal::pTransliteration->isEqual( rFilter.maFieldName, rField.aCaption ); + return ScGlobal::GetpTransliteration()->isEqual( rFilter.maFieldName, rField.aCaption ); } bool lcl_IsCondition( const sheet::MemberResult& rResultEntry, const ScDPGetPivotDataField& rFilter ) { //! handle numeric conditions? - return ScGlobal::pTransliteration->isEqual( rResultEntry.Name, rFilter.maValStr ); + return ScGlobal::GetpTransliteration()->isEqual( rResultEntry.Name, rFilter.maValStr ); } bool lcl_CheckPageField( const ScDPOutLevelData& rField, diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx index a58241cea416..41e44f84b647 100644 --- a/sc/source/core/data/dptabdat.cxx +++ b/sc/source/core/data/dptabdat.cxx @@ -66,7 +66,7 @@ BOOL ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const //! inline? return bHasValue ? ( r.bHasValue && rtl::math::approxEqual( fValue, r.fValue ) ) : ( !r.bHasValue && - ScGlobal::pTransliteration->isEqual( aString, r.aString ) ); + ScGlobal::GetpTransliteration()->isEqual( aString, r.aString ) ); } size_t ScDPItemData::Hash() const @@ -115,7 +115,7 @@ sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA, else if ( rB.bHasValue ) return 1; // values first else - return ScGlobal::pCollator->compareString( rA.aString, rB.aString ); + return ScGlobal::GetCollator()->compareString( rA.aString, rB.aString ); } // --------------------------------------------------------------------------- diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 959e0342fe38..3e9a7586fd1a 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -2505,14 +2505,14 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const else if ( nHier == SC_DAPI_HIERARCHY_WEEK && nLev == SC_DAPI_LEVEL_WEEKDAY ) { nVal = nIndex; // DayOfWeek is 0-based - aName = ScGlobal::pCalendar->getDisplayName( + aName = ScGlobal::GetCalendar()->getDisplayName( ::com::sun::star::i18n::CalendarDisplayIndex::DAY, sal::static_int_cast<sal_Int16>(nVal), 0 ); } else if ( nHier == SC_DAPI_HIERARCHY_QUARTER && nLev == SC_DAPI_LEVEL_MONTH ) { nVal = nIndex; // Month is 0-based - aName = ScGlobal::pCalendar->getDisplayName( + aName = ScGlobal::GetCalendar()->getDisplayName( ::com::sun::star::i18n::CalendarDisplayIndex::MONTH, sal::static_int_cast<sal_Int16>(nVal), 0 ); } diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 3320e9a9a95c..88ff065572b4 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -559,24 +559,9 @@ void ScGlobal::Init() //! Wenn Sortierung etc. von der Sprache der installierten Offfice-Version //! abhaengen sollen, hier "Application::GetSettings().GetUILanguage()" - LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage(); - pLocale = new ::com::sun::star::lang::Locale( Application::GetSettings().GetLocale()); pSysLocale = new SvtSysLocale; pCharClass = pSysLocale->GetCharClassPtr(); pLocaleData = pSysLocale->GetLocaleDataPtr(); - pCalendar = new CalendarWrapper( ::comphelper::getProcessServiceFactory() ); - pCalendar->loadDefaultCalendar( *pLocale ); - pCollator = new CollatorWrapper( ::comphelper::getProcessServiceFactory() ); - pCollator->loadDefaultCollator( *pLocale, SC_COLLATOR_IGNORES ); - pCaseCollator = new CollatorWrapper( ::comphelper::getProcessServiceFactory() ); - pCaseCollator->loadDefaultCollator( *pLocale, 0 ); - pTransliteration = new ::utl::TransliterationWrapper( - ::comphelper::getProcessServiceFactory(), SC_TRANSLITERATION_IGNORECASE ); - pTransliteration->loadModuleIfNeeded( eOfficeLanguage ); - pCaseTransliteration = new ::utl::TransliterationWrapper( - ::comphelper::getProcessServiceFactory(), SC_TRANSLITERATION_CASESENSE ); - pCaseTransliteration->loadModuleIfNeeded( eOfficeLanguage ); - pScIntlWrapper = new IntlWrapper( ::comphelper::getProcessServiceFactory(), *pLocale ); ppRscString = new String *[ STR_COUNT ]; for( USHORT nC = 0 ; nC < STR_COUNT ; nC++ ) ppRscString[ nC ] = NULL; @@ -1766,6 +1751,7 @@ ScFunctionMgr::ScFunctionMgr() aCatLists[i] = new List; pRootList = aCatLists[0]; // Gesamtliste ("Alle") erstellen + CollatorWrapper* pCaseCollator = ScGlobal::GetCaseCollator(); for ( n=0; n<nCount; n++ ) { ULONG nTmpCnt=0; @@ -1775,8 +1761,7 @@ ScFunctionMgr::ScFunctionMgr() // ist zwar case-sensitiv, aber Umlaute muessen richtig einsortiert werden const ScFuncDesc* pTmpDesc = (const ScFuncDesc*)pRootList->GetObject(nTmpCnt); - if ( ScGlobal::pCaseCollator->compareString( - *pDesc->pFuncName, *pTmpDesc->pFuncName ) == COMPARE_LESS ) + if ( pCaseCollator->compareString(*pDesc->pFuncName, *pTmpDesc->pFuncName ) == COMPARE_LESS ) break; } pRootList->Insert((void*)pDesc, nTmpCnt); // Einsortieren @@ -1949,6 +1934,13 @@ sal_uInt32 ScFunctionCategory::getNumber() const utl::TransliterationWrapper* ScGlobal::GetpTransliteration() //add by CHINA001 { + if ( !pTransliteration ) + { + const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage(); + pTransliteration = new ::utl::TransliterationWrapper( + ::comphelper::getProcessServiceFactory(), SC_TRANSLITERATION_IGNORECASE ); + pTransliteration->loadModuleIfNeeded( eOfficeLanguage ); + } DBG_ASSERT( pTransliteration, "ScGlobal::GetpTransliteration() called before ScGlobal::Init()"); @@ -1962,3 +1954,57 @@ const LocaleDataWrapper* ScGlobal::GetpLocaleData() "ScGlobal::GetpLocaleData() called before ScGlobal::Init()"); return pLocaleData; } +CalendarWrapper* ScGlobal::GetCalendar() +{ + if ( !pCalendar ) + { + pCalendar = new CalendarWrapper( ::comphelper::getProcessServiceFactory() ); + pCalendar->loadDefaultCalendar( *GetLocale() ); + } + return pCalendar; +} +CollatorWrapper* ScGlobal::GetCollator() +{ + if ( !pCollator ) + { + pCollator = new CollatorWrapper( ::comphelper::getProcessServiceFactory() ); + pCollator->loadDefaultCollator( *GetLocale(), SC_COLLATOR_IGNORES ); + } // if ( !pCollator ) + return pCollator; +} +CollatorWrapper* ScGlobal::GetCaseCollator() +{ + if ( !pCaseCollator ) + { + pCaseCollator = new CollatorWrapper( ::comphelper::getProcessServiceFactory() ); + pCaseCollator->loadDefaultCollator( *GetLocale(), 0 ); + } // if ( !pCaseCollator ) + return pCaseCollator; +} +::utl::TransliterationWrapper* ScGlobal::GetCaseTransliteration() +{ + if ( !pCaseTransliteration ) + { + const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage(); + pCaseTransliteration = new ::utl::TransliterationWrapper(::comphelper::getProcessServiceFactory(), SC_TRANSLITERATION_CASESENSE ); + pCaseTransliteration->loadModuleIfNeeded( eOfficeLanguage ); + } // if ( !pCaseTransliteration ) + return pCaseTransliteration; +} +IntlWrapper* ScGlobal::GetScIntlWrapper() +{ + if ( !pScIntlWrapper ) + { + pScIntlWrapper = new IntlWrapper( ::comphelper::getProcessServiceFactory(), *GetLocale() ); + } + return pScIntlWrapper; +} +::com::sun::star::lang::Locale* ScGlobal::GetLocale() +{ + if ( !pLocale ) + { + pLocale = new ::com::sun::star::lang::Locale( Application::GetSettings().GetLocale()); + } + return pLocale; +} + diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx index db02c921be98..e12df0cda6e5 100644 --- a/sc/source/core/data/pivot2.cxx +++ b/sc/source/core/data/pivot2.cxx @@ -63,7 +63,6 @@ using ::com::sun::star::sheet::DataPilotFieldReference; // STATIC DATA ----------------------------------------------------------- - // ============================================================================ LabelData::LabelData( const String& rName, short nCol, bool bIsValue ) : diff --git a/sc/source/core/data/poolhelp.cxx b/sc/source/core/data/poolhelp.cxx index 0121eca685e4..ff8f7bb76c5c 100644 --- a/sc/source/core/data/poolhelp.cxx +++ b/sc/source/core/data/poolhelp.cxx @@ -46,26 +46,16 @@ // ----------------------------------------------------------------------- ScPoolHelper::ScPoolHelper( ScDocument* pSourceDoc ) +:pFormTable(NULL) +,pEditPool(NULL) +,pEnginePool(NULL) +,m_pSourceDoc(pSourceDoc) { DBG_ASSERT( pSourceDoc, "ScPoolHelper: no document" ); - pDocPool = new ScDocumentPool; pDocPool->FreezeIdRanges(); mxStylePool = new ScStyleSheetPool( *pDocPool, pSourceDoc ); - - pFormTable = new SvNumberFormatter( pSourceDoc->GetServiceManager(), ScGlobal::eLnge ); - pFormTable->SetColorLink( LINK( pSourceDoc, ScDocument, GetUserDefinedColor ) ); - pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT ); - - pEditPool = EditEngine::CreatePool(); - pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); - pEditPool->FreezeIdRanges(); - pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 ); // used in ScGlobal::EETextObjEqual - - pEnginePool = EditEngine::CreatePool(); - pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); - pEnginePool->FreezeIdRanges(); } ScPoolHelper::~ScPoolHelper() @@ -76,12 +66,49 @@ ScPoolHelper::~ScPoolHelper() mxStylePool.clear(); SfxItemPool::Free(pDocPool); } - +SfxItemPool* ScPoolHelper::GetEditPool() const +{ + if ( !pEditPool ) + { + pEditPool = EditEngine::CreatePool(); + pEditPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); + pEditPool->FreezeIdRanges(); + pEditPool->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 ); // used in ScGlobal::EETextObjEqual + } + return pEditPool; +} +SfxItemPool* ScPoolHelper::GetEnginePool() const +{ + if ( !pEnginePool ) + { + pEnginePool = EditEngine::CreatePool(); + pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); + pEnginePool->FreezeIdRanges(); + } // ifg ( pEnginePool ) + return pEnginePool; +} +SvNumberFormatter* ScPoolHelper::GetFormTable() const +{ + if ( !pFormTable ) + { + pFormTable = new SvNumberFormatter( m_pSourceDoc->GetServiceManager(), ScGlobal::eLnge ); + pFormTable->SetColorLink( LINK( m_pSourceDoc, ScDocument, GetUserDefinedColor ) ); + pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT ); + + USHORT d,m,y; + aOpt.GetDate( d,m,y ); + pFormTable->ChangeNullDate( d,m,y ); + pFormTable->ChangeStandardPrec( (USHORT)aOpt.GetStdPrecision() ); + pFormTable->SetYear2000( aOpt.GetYear2000() ); + } + return pFormTable; +} void ScPoolHelper::SourceDocumentGone() { // reset all pointers to the source document mxStylePool->SetDocument( NULL ); - pFormTable->SetColorLink( Link() ); + if ( pFormTable ) + pFormTable->SetColorLink( Link() ); } // ----------------------------------------------------------------------- diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index ca78acc8a1e0..260385d6feac 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -263,7 +263,7 @@ void ScStyleSheetPool::CreateStandardStyles() String aStr; xub_StrLen nStrLen; String aHelpFile;//XXX JN welcher Text??? - ULONG nNumFmt = 0L; + //ULONG nNumFmt = 0L; SfxItemSet* pSet = NULL; SfxItemSet* pHFSet = NULL; SvxSetItem* pHFSetItem = NULL; @@ -345,10 +345,11 @@ void ScStyleSheetPool::CreateStandardStyles() pSheet->SetParent( SCSTR( STR_STYLENAME_RESULT ) ); pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG1 ); - pSet = &pSheet->GetItemSet(); - nNumFmt = pDoc->GetFormatTable()->GetStandardFormat( NUMBERFORMAT_CURRENCY, - ScGlobal::eLnge ); - pSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumFmt ) ); + // will now be done in GetItemSet(); + // pSet = &pSheet->GetItemSet(); + // nNumFmt = pDoc->GetFormatTable()->GetStandardFormat( NUMBERFORMAT_CURRENCY, + // ScGlobal::eLnge ); + // pSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumFmt ) ); //---------------- // 4. Ueberschrift diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index bad2c664cc4d..4452cd357132 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -53,10 +53,11 @@ #include <svtools/smplhint.hxx> #include "attrib.hxx" + #include <vcl/svapp.hxx> // GetSettings() #include "globstr.hrc" - +#include "sc.hrc" //------------------------------------------------------------------------ TYPEINIT1(ScStyleSheet, SfxStyleSheet); @@ -247,6 +248,18 @@ SfxItemSet& __EXPORT ScStyleSheet::GetItemSet() break; } bMySet = TRUE; + } // if ( !pSet ) + if ( nHelpId == HID_SC_SHEET_CELL_ERG1 ) + { + if ( !pSet->Count() ) + { + ScDocument* pDoc = ((ScStyleSheetPool&)GetPool()).GetDocument(); + if ( pDoc ) + { + ULONG nNumFmt = pDoc->GetFormatTable()->GetStandardFormat( NUMBERFORMAT_CURRENCY,ScGlobal::eLnge ); + pSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumFmt ) ); + } // if ( pDoc && pDoc->IsLoadingDone() ) + } } return *pSet; diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index ae299fdf5fca..01dc74f8644e 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -171,8 +171,8 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 ) BOOL ScTable::IsSortCollatorGlobal() const { - return pSortCollator == ScGlobal::pCollator || - pSortCollator == ScGlobal::pCaseCollator; + return pSortCollator == ScGlobal::GetCollator() || + pSortCollator == ScGlobal::GetCaseCollator(); } @@ -188,8 +188,8 @@ void ScTable::InitSortCollator( const ScSortParam& rPar ) else { // SYSTEM DestroySortCollator(); - pSortCollator = (rPar.bCaseSens ? ScGlobal::pCaseCollator : - ScGlobal::pCollator); + pSortCollator = (rPar.bCaseSens ? ScGlobal::GetCaseCollator() : + ScGlobal::GetCollator()); } } @@ -948,10 +948,10 @@ BOOL ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam, long nPos = -1; SCSIZE i = 0; BOOL bMatchWholeCell = pDocument->GetDocOptions().IsMatchWholeCell(); - CollatorWrapper* pCollator = (rParam.bCaseSens ? ScGlobal::pCaseCollator : - ScGlobal::pCollator); + CollatorWrapper* pCollator = (rParam.bCaseSens ? ScGlobal::GetCaseCollator() : + ScGlobal::GetCollator()); ::utl::TransliterationWrapper* pTransliteration = (rParam.bCaseSens ? - ScGlobal::pCaseTransliteration : ScGlobal::pTransliteration); + ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration()); while ( (i < nEntryCount) && rParam.GetEntry(i).bDoQuery ) { diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 9ca7b29b745e..09362b9996ed 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -658,7 +658,7 @@ BOOL ScTable::SearchAndReplace(const SvxSearchItem& rSearchItem, { // SearchParam no longer needed - SearchOptions contains all settings com::sun::star::util::SearchOptions aSearchOptions = rSearchItem.GetSearchOptions(); - aSearchOptions.Locale = *ScGlobal::pLocale; + aSearchOptions.Locale = *ScGlobal::GetLocale(); // #107259# reflect UseAsianOptions flag in SearchOptions // (use only ignore case and width if asian options are disabled). diff --git a/sc/source/core/inc/poolhelp.hxx b/sc/source/core/inc/poolhelp.hxx index 0d43278978b8..a60b8db462ab 100644 --- a/sc/source/core/inc/poolhelp.hxx +++ b/sc/source/core/inc/poolhelp.hxx @@ -34,6 +34,7 @@ #include <rtl/ref.hxx> #include <vos/refernce.hxx> #include <tools/link.hxx> +#include "docoptio.hxx" class ScDocument; class ScDocumentPool; @@ -45,11 +46,13 @@ class SfxItemPool; class ScPoolHelper : public vos::OReference { private: + ScDocOptions aOpt; ScDocumentPool* pDocPool; rtl::Reference< ScStyleSheetPool > mxStylePool; - SvNumberFormatter* pFormTable; - SfxItemPool* pEditPool; // EditTextObjectPool - SfxItemPool* pEnginePool; // EditEnginePool + mutable SvNumberFormatter* pFormTable; + mutable SfxItemPool* pEditPool; // EditTextObjectPool + mutable SfxItemPool* pEnginePool; // EditEnginePool + ScDocument* m_pSourceDoc; public: ScPoolHelper( ScDocument* pSourceDoc ); @@ -61,9 +64,11 @@ public: // access to pointers (are never 0): ScDocumentPool* GetDocPool() const { return pDocPool; } ScStyleSheetPool* GetStylePool() const { return mxStylePool.get(); } - SvNumberFormatter* GetFormTable() const { return pFormTable; } - SfxItemPool* GetEditPool() const { return pEditPool; } - SfxItemPool* GetEnginePool() const { return pEnginePool; } + SvNumberFormatter* GetFormTable() const; + SfxItemPool* GetEditPool() const; + SfxItemPool* GetEnginePool() const; + + void SetFormTableOpt(const ScDocOptions& rOpt) { aOpt = rOpt; } }; #endif diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx index 05af63a2ff2f..3b8a88c47e2f 100644 --- a/sc/source/core/tool/autoform.cxx +++ b/sc/source/core/tool/autoform.cxx @@ -1026,11 +1026,11 @@ short ScAutoFormat::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const ((ScAutoFormatData*)pKey1)->GetName(aStr1); ((ScAutoFormatData*)pKey2)->GetName(aStr2); String aStrStandard = ScGlobal::GetRscString(STR_STYLENAME_STANDARD); - if ( ScGlobal::pTransliteration->isEqual( aStr1, aStrStandard ) ) + if ( ScGlobal::GetpTransliteration()->isEqual( aStr1, aStrStandard ) ) return -1; - if ( ScGlobal::pTransliteration->isEqual( aStr2, aStrStandard ) ) + if ( ScGlobal::GetpTransliteration()->isEqual( aStr2, aStrStandard ) ) return 1; - return (short) ScGlobal::pTransliteration->compareString( aStr1, aStr2 ); + return (short) ScGlobal::GetpTransliteration()->compareString( aStr1, aStr2 ); } BOOL ScAutoFormat::Load() diff --git a/sc/source/core/tool/callform.cxx b/sc/source/core/tool/callform.cxx index c3634db854a6..b98525e45968 100644 --- a/sc/source/core/tool/callform.cxx +++ b/sc/source/core/tool/callform.cxx @@ -156,7 +156,7 @@ FuncData::FuncData(const FuncData& rData) : short FuncCollection::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const { - return (short) ScGlobal::pTransliteration->compareString( + return (short) ScGlobal::GetpTransliteration()->compareString( ((FuncData*)pKey1)->aInternalName, ((FuncData*)pKey2)->aInternalName ); } @@ -205,7 +205,7 @@ static ModuleCollection aModuleCollection; short ModuleCollection::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const { - return (short) ScGlobal::pTransliteration->compareString( + return (short) ScGlobal::GetpTransliteration()->compareString( ((ModuleData*)pKey1)->aName, ((ModuleData*)pKey2)->aName ); } diff --git a/sc/source/core/tool/collect.cxx b/sc/source/core/tool/collect.cxx index c5d4df22ccea..e66c14ee0317 100644 --- a/sc/source/core/tool/collect.cxx +++ b/sc/source/core/tool/collect.cxx @@ -96,7 +96,7 @@ ScCollection::~ScCollection() } //------------------------------------------------------------------------ - +USHORT ScCollection::GetCount() const { return nCount; } void ScCollection::AtFree(USHORT nIndex) { if ((pItems) && (nIndex < nCount)) @@ -359,7 +359,8 @@ ScDataObject* TypedStrData::Clone() const { return new TypedStrData(*this); } - +TypedScStrCollection::~TypedScStrCollection() +{} ScDataObject* TypedScStrCollection::Clone() const { return new TypedScStrCollection(*this); @@ -396,10 +397,10 @@ short TypedScStrCollection::Compare( ScDataObject* pKey1, ScDataObject* pKey2 ) // Strings vergleichen: //--------------------- if ( bCaseSensitive ) - nResult = (short) ScGlobal::pCaseTransliteration->compareString( + nResult = (short) ScGlobal::GetCaseTransliteration()->compareString( rData1.aStrValue, rData2.aStrValue ); else - nResult = (short) ScGlobal::pTransliteration->compareString( + nResult = (short) ScGlobal::GetpTransliteration()->compareString( rData1.aStrValue, rData2.aStrValue ); } } @@ -435,12 +436,12 @@ BOOL TypedScStrCollection::FindText( const String& rStart, String& rResult, TypedStrData* pData = (TypedStrData*) pItems[i]; if (pData->nStrType) { - if ( ScGlobal::pTransliteration->isMatch( rStart, pData->aStrValue ) ) + if ( ScGlobal::GetpTransliteration()->isMatch( rStart, pData->aStrValue ) ) { // If the collection is case sensitive, it may contain several entries // that are equal when compared case-insensitive. They are skipped here. if ( !bCaseSensitive || !aOldResult.Len() || - !ScGlobal::pTransliteration->isEqual( + !ScGlobal::GetpTransliteration()->isEqual( pData->aStrValue, aOldResult ) ) { rResult = pData->aStrValue; @@ -463,12 +464,12 @@ BOOL TypedScStrCollection::FindText( const String& rStart, String& rResult, TypedStrData* pData = (TypedStrData*) pItems[i]; if (pData->nStrType) { - if ( ScGlobal::pTransliteration->isMatch( rStart, pData->aStrValue ) ) + if ( ScGlobal::GetpTransliteration()->isMatch( rStart, pData->aStrValue ) ) { // If the collection is case sensitive, it may contain several entries // that are equal when compared case-insensitive. They are skipped here. if ( !bCaseSensitive || !aOldResult.Len() || - !ScGlobal::pTransliteration->isEqual( + !ScGlobal::GetpTransliteration()->isEqual( pData->aStrValue, aOldResult ) ) { rResult = pData->aStrValue; @@ -491,7 +492,7 @@ BOOL TypedScStrCollection::GetExactMatch( String& rString ) const for (USHORT i=0; i<nCount; i++) { TypedStrData* pData = (TypedStrData*) pItems[i]; - if ( pData->nStrType && ScGlobal::pTransliteration->isEqual( + if ( pData->nStrType && ScGlobal::GetpTransliteration()->isEqual( pData->aStrValue, rString ) ) { rString = pData->aStrValue; // String anpassen diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 599d7c63d68b..0da842e6ca5a 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -2973,7 +2973,7 @@ BOOL ScCompiler::IsColRowName( const String& rName ) ; // nothing, prevent compiler warning break; } - if ( ScGlobal::pTransliteration->isEqual( aStr, aName ) ) + if ( ScGlobal::GetpTransliteration()->isEqual( aStr, aName ) ) { aRef.InitFlags(); aRef.nCol = aIter.GetCol(); @@ -3102,7 +3102,7 @@ BOOL ScCompiler::IsColRowName( const String& rName ) ; // nothing, prevent compiler warning break; } - if ( ScGlobal::pTransliteration->isEqual( aStr, aName ) ) + if ( ScGlobal::GetpTransliteration()->isEqual( aStr, aName ) ) { SCCOL nCol = aIter.GetCol(); SCROW nRow = aIter.GetRow(); diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx index e6c039b5d79f..61ca8ee00195 100644 --- a/sc/source/core/tool/dbcolect.cxx +++ b/sc/source/core/tool/dbcolect.cxx @@ -701,7 +701,7 @@ short ScDBCollection::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const { const String& rStr1 = ((ScDBData*)pKey1)->GetName(); const String& rStr2 = ((ScDBData*)pKey2)->GetName(); - return (short) ScGlobal::pTransliteration->compareString( rStr1, rStr2 ); + return (short) ScGlobal::GetpTransliteration()->compareString( rStr1, rStr2 ); } // IsEqual - alles gleich diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 195366271f0d..1145fe2ed3c4 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -734,8 +734,8 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp, ScCompareOptions* pOp else if (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL) { ::utl::TransliterationWrapper* pTransliteration = - (pOptions->bIgnoreCase ? ScGlobal::pTransliteration : - ScGlobal::pCaseTransliteration); + (pOptions->bIgnoreCase ? ScGlobal::GetpTransliteration() : + ScGlobal::GetCaseTransliteration()); bool bMatch; if (pOptions->bMatchWholeCell) bMatch = pTransliteration->isEqual( *rComp.pVal[0], *rComp.pVal[1]); @@ -752,17 +752,17 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp, ScCompareOptions* pOp fRes = (bMatch ? 0 : 1); } else if (pOptions->bIgnoreCase) - fRes = (double) ScGlobal::pCollator->compareString( + fRes = (double) ScGlobal::GetCollator()->compareString( *rComp.pVal[ 0 ], *rComp.pVal[ 1 ] ); else - fRes = (double) ScGlobal::pCaseCollator->compareString( + fRes = (double) ScGlobal::GetCaseCollator()->compareString( *rComp.pVal[ 0 ], *rComp.pVal[ 1 ] ); } else if (pDok->GetDocOptions().IsIgnoreCase()) - fRes = (double) ScGlobal::pCollator->compareString( + fRes = (double) ScGlobal::GetCollator()->compareString( *rComp.pVal[ 0 ], *rComp.pVal[ 1 ] ); else - fRes = (double) ScGlobal::pCaseCollator->compareString( + fRes = (double) ScGlobal::GetCaseCollator()->compareString( *rComp.pVal[ 0 ], *rComp.pVal[ 1 ] ); } return fRes; @@ -1876,7 +1876,7 @@ void ScInterpreter::ScCell() String aFuncResult; ScBaseCell* pCell = GetCell( aCellPos ); - ScCellKeywordTranslator::transKeyword(aInfoType, ScGlobal::pLocale, ocCell); + ScCellKeywordTranslator::transKeyword(aInfoType, ScGlobal::GetLocale(), ocCell); // *** ADDRESS INFO *** if( aInfoType.EqualsAscii( "COL" ) ) @@ -3975,7 +3975,7 @@ static sal_Int32 lcl_CompareMatrix2Query( SCSIZE i, const ScMatrix& rMat, const String& rStr1 = rMat.GetString(i); const String& rStr2 = *rEntry.pStr; - return ScGlobal::pCollator->compareString( rStr1, rStr2); // case-insensitive + return ScGlobal::GetCollator()->compareString( rStr1, rStr2); // case-insensitive } /** returns the last item with the identical value as the original item @@ -5375,12 +5375,13 @@ void ScInterpreter::CalculateLookup(BOOL HLookup) String aParamStr = *rEntry.pStr; if ( bSorted ) { + static CollatorWrapper* pCollator = ScGlobal::GetCollator(); for (SCSIZE i = 0; i < nMatCount; i++) { if (HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i)) { sal_Int32 nRes = - ScGlobal::pCollator->compareString( HLookup ? pMat->GetString(i,0) : pMat->GetString(0,i), aParamStr); + pCollator->compareString( HLookup ? pMat->GetString(i,0) : pMat->GetString(0,i), aParamStr); if (nRes <= 0) nDelta = i; else if (i>0) // #i2168# ignore first mismatch @@ -5396,7 +5397,7 @@ void ScInterpreter::CalculateLookup(BOOL HLookup) { if (HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i)) { - if ( ScGlobal::pTransliteration->isEqual( + if ( ScGlobal::GetpTransliteration()->isEqual( HLookup ? pMat->GetString(i,0) : pMat->GetString(0,i), aParamStr ) ) { nDelta = i; @@ -5734,7 +5735,7 @@ BOOL ScInterpreter::GetDBParams(SCTAB& rTab, ScQueryParam& rParam, { ScBaseCell* pCell = GetCell( aLook ); GetCellString( aCellStr, pCell ); - bFound = ScGlobal::pTransliteration->isEqual( aCellStr, aStr ); + bFound = ScGlobal::GetpTransliteration()->isEqual( aCellStr, aStr ); if (!bFound) aLook.IncCol(); } diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index 41ddf3dc0aa0..5fb45755eb7c 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -2796,7 +2796,7 @@ void ScInterpreter::ScInfo() if( MustHaveParamCount( GetByte(), 1 ) ) { String aStr = GetString(); - ScCellKeywordTranslator::transKeyword(aStr, ScGlobal::pLocale, ocInfo); + ScCellKeywordTranslator::transKeyword(aStr, ScGlobal::GetLocale(), ocInfo); if( aStr.EqualsAscii( "SYSTEM" ) ) PushString( String( RTL_CONSTASCII_USTRINGPARAM( SC_INFO_OSVERSION ) ) ); else if( aStr.EqualsAscii( "OSVERSION" ) ) diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx index 5c11249ef6be..775b0207be59 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -624,7 +624,7 @@ ScRangePairList_QsortNameCompare( const void* p1, const void* p2 ) { ps1->pDoc->GetName( rStartPos1.Tab(), aStr1 ); ps2->pDoc->GetName( rStartPos2.Tab(), aStr2 ); - nComp = ScGlobal::pCollator->compareString( aStr1, aStr2 ); + nComp = ScGlobal::GetCollator()->compareString( aStr1, aStr2 ); } switch ( nComp ) { @@ -655,7 +655,7 @@ ScRangePairList_QsortNameCompare( const void* p1, const void* p2 ) { ps1->pDoc->GetName( rEndPos1.Tab(), aStr1 ); ps2->pDoc->GetName( rEndPos2.Tab(), aStr2 ); - nComp = ScGlobal::pCollator->compareString( aStr1, aStr2 ); + nComp = ScGlobal::GetCollator()->compareString( aStr1, aStr2 ); } switch ( nComp ) { diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index 24ed502e33b1..0f2475bc2f65 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -683,7 +683,7 @@ __cdecl #endif ScRangeData_QsortNameCompare( const void* p1, const void* p2 ) { - return (int) ScGlobal::pCollator->compareString( + return (int) ScGlobal::GetCollator()->compareString( (*(const ScRangeData**)p1)->GetName(), (*(const ScRangeData**)p2)->GetName() ); } diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx index bc3537d1c94a..24dd852c6a5f 100644 --- a/sc/source/core/tool/userlist.cxx +++ b/sc/source/core/tool/userlist.cxx @@ -153,7 +153,7 @@ StringCompare ScUserListData::Compare(const String& rSubStr1, const String& rSub else if (bFound2) return COMPARE_GREATER; else - return (StringCompare) ScGlobal::pCaseTransliteration->compareString( rSubStr1, rSubStr2 ); + return (StringCompare) ScGlobal::GetCaseTransliteration()->compareString( rSubStr1, rSubStr2 ); } StringCompare ScUserListData::ICompare(const String& rSubStr1, const String& rSubStr2) const @@ -179,7 +179,7 @@ StringCompare ScUserListData::ICompare(const String& rSubStr1, const String& rSu else if (bFound2) return COMPARE_GREATER; else - return (StringCompare) ScGlobal::pTransliteration->compareString( rSubStr1, rSubStr2 ); + return (StringCompare) ScGlobal::GetpTransliteration()->compareString( rSubStr1, rSubStr2 ); } ScUserList::ScUserList(USHORT nLim, USHORT nDel) : diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 2c6741811f3f..47f101f4c351 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -903,7 +903,7 @@ typedef ::std::vector< XclExpTabName > XclExpTabNameVec; inline bool operator<( const XclExpTabName& rArg1, const XclExpTabName& rArg2 ) { // compare the sheet names only - return ScGlobal::pCollator->compareString( rArg1.first, rArg2.first ) == COMPARE_LESS; + return ScGlobal::GetCollator()->compareString( rArg1.first, rArg2.first ) == COMPARE_LESS; } void XclExpTabInfo::CalcSortedIndexes() diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 6bc96c13d5b6..773862088155 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -82,7 +82,7 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList ) xub_StrLen nCount = rList.GetTokenCount('\t'); for ( xub_StrLen i=0; i<nCount; i+=2 ) { - if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.GetToken(i,'\t') ) )//CHINA001 if ( ScGlobal::pTransliteration->isEqual( aStr, rList.GetToken(i,'\t') ) ) + if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.GetToken(i,'\t') ) )//CHINA001 if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.GetToken(i,'\t') ) ) c = (sal_Unicode)rList.GetToken(i+1,'\t').ToInt32(); } if (!c && aStr.Len()) diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 149856b4aa6b..d58777b9b5d5 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -43,13 +43,14 @@ #include <ucbhelper/content.hxx> #include <unotools/sharedunocomponent.hxx> #include <comphelper/processfactory.hxx> -#include <connectivity/dbcharset.hxx> #include <svx/txenctab.hxx> +#include <svx/dbcharsethelper.hxx> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbc/XDriver.hpp> +#include <com/sun/star/sdbc/XDriverAccess.hpp> #include <com/sun/star/sdbc/XDriverManager.hpp> #include <com/sun/star/sdbc/XResultSetUpdate.hpp> #include <com/sun/star/sdbc/XRow.hpp> @@ -104,6 +105,61 @@ using namespace com::sun::star; #define SC_ROWCOUNT_ERROR (-1) +namespace +{ + ULONG lcl_getDBaseConnection(uno::Reference<sdbc::XDriverManager>& _rDrvMgr,uno::Reference<sdbc::XConnection>& _rConnection,String& _rTabName,const String& rFullFileName,rtl_TextEncoding eCharSet) + { + INetURLObject aURL; + aURL.SetSmartProtocol( INET_PROT_FILE ); + aURL.SetSmartURL( rFullFileName ); + _rTabName = aURL.getBase( INetURLObject::LAST_SEGMENT, true, + INetURLObject::DECODE_UNAMBIGUOUS ); + String aExtension = aURL.getExtension(); + aURL.removeSegment(); + aURL.removeFinalSlash(); + String aPath = aURL.GetMainURL(INetURLObject::NO_DECODE); + uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); + if (!xFactory.is()) return SCERR_EXPORT_CONNECT; + + _rDrvMgr.set( xFactory->createInstance( + rtl::OUString::createFromAscii( SC_SERVICE_DRVMAN ) ), + uno::UNO_QUERY); + DBG_ASSERT( _rDrvMgr.is(), "can't get DriverManager" ); + if (!_rDrvMgr.is()) return SCERR_EXPORT_CONNECT; + + // get connection + + String aConnUrl = String::CreateFromAscii("sdbc:dbase:"); + aConnUrl += aPath; + + svxform::ODataAccessCharsetHelper aHelper; + ::std::vector< rtl_TextEncoding > aEncodings; + aHelper.getSupportedTextEncodings( aEncodings ); + ::std::vector< rtl_TextEncoding >::iterator aIter = ::std::find(aEncodings.begin(),aEncodings.end(),(rtl_TextEncoding) eCharSet); + if ( aIter == aEncodings.end() ) + { + DBG_ERRORFILE( "DBaseImport: dbtools::OCharsetMap doesn't know text encoding" ); + return SCERR_IMPORT_CONNECT; + } // if ( aIter == aMap.end() ) + rtl::OUString aCharSetStr; + if ( RTL_TEXTENCODING_DONTKNOW != *aIter ) + { // it's not the virtual "system charset" + const char* pIanaName = rtl_getMimeCharsetFromTextEncoding( *aIter ); + OSL_ENSURE( pIanaName, "invalid mime name!" ); + if ( pIanaName ) + aCharSetStr = ::rtl::OUString::createFromAscii( pIanaName ); + } + + uno::Sequence<beans::PropertyValue> aProps(2); + aProps[0].Name = rtl::OUString::createFromAscii(SC_DBPROP_EXTENSION); + aProps[0].Value <<= rtl::OUString( aExtension ); + aProps[1].Name = rtl::OUString::createFromAscii(SC_DBPROP_CHARSET); + aProps[1].Value <<= aCharSetStr; + + _rConnection = _rDrvMgr->getConnectionWithInfo( aConnUrl, aProps ); + return 0L; + } +} // ----------------------------------------------------------------------- // MoveFile/KillFile/IsDocument: similar to SfxContentHelper @@ -201,48 +257,13 @@ ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet, try { - INetURLObject aURL; - aURL.SetSmartProtocol( INET_PROT_FILE ); - aURL.SetSmartURL( rFullFileName ); - String aTabName = aURL.getBase( INetURLObject::LAST_SEGMENT, true, - INetURLObject::DECODE_UNAMBIGUOUS ); - String aExtension = aURL.getExtension(); - aURL.removeSegment(); - aURL.removeFinalSlash(); - String aPath = aURL.GetMainURL(INetURLObject::NO_DECODE); - - uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); - if (!xFactory.is()) - return ERRCODE_IO_GENERAL; - - uno::Reference<sdbc::XDriverManager> xDrvMan( xFactory->createInstance( - rtl::OUString::createFromAscii( SC_SERVICE_DRVMAN ) ), - uno::UNO_QUERY); - DBG_ASSERT( xDrvMan.is(), "can't get DriverManager" ); - if (!xDrvMan.is()) return SCERR_IMPORT_CONNECT; - - String aConnUrl = String::CreateFromAscii("sdbc:dbase:"); - aConnUrl += aPath; - - dbtools::OCharsetMap aMap; - dbtools::OCharsetMap::CharsetIterator aIter = aMap.find( (rtl_TextEncoding) eCharSet ); - if ( aIter == aMap.end() ) - { - DBG_ERRORFILE( "DBaseImport: dbtools::OCharsetMap doesn't know text encoding" ); - return SCERR_IMPORT_CONNECT; - } - rtl::OUString aCharSetStr = (*aIter).getIanaName(); - - uno::Sequence<beans::PropertyValue> aProps(2); - aProps[0].Name = rtl::OUString::createFromAscii(SC_DBPROP_EXTENSION); - aProps[0].Value <<= rtl::OUString( aExtension ); - aProps[1].Name = rtl::OUString::createFromAscii(SC_DBPROP_CHARSET); - aProps[1].Value <<= aCharSetStr; - - uno::Reference<sdbc::XConnection> xConnection = - xDrvMan->getConnectionWithInfo( aConnUrl, aProps ); - DBG_ASSERT( xConnection.is(), "can't get Connection" ); - if (!xConnection.is()) return SCERR_IMPORT_CONNECT; + String aTabName; + uno::Reference<sdbc::XDriverManager> xDrvMan; + uno::Reference<sdbc::XConnection> xConnection; + ULONG nRet = lcl_getDBaseConnection(xDrvMan,xConnection,aTabName,rFullFileName,eCharSet); + if ( !xConnection.is() || !xDrvMan.is() ) + return nRet; + ::utl::DisposableComponent aConnectionHelper(xConnection); long nRowCount = 0; if ( nRowCount < 0 ) @@ -252,10 +273,11 @@ ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet, } ScProgress aProgress( this, ScGlobal::GetRscString( STR_LOAD_DOC ), nRowCount ); - + uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); uno::Reference<sdbc::XRowSet> xRowSet( xFactory->createInstance( rtl::OUString::createFromAscii( SC_SERVICE_ROWSET ) ), uno::UNO_QUERY); + ::utl::DisposableComponent aRowSetHelper(xRowSet); uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY ); DBG_ASSERT( xRowProp.is(), "can't get RowSet" ); if (!xRowProp.is()) return SCERR_IMPORT_CONNECT; @@ -369,9 +391,6 @@ ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet, if ( nRowCount ) aProgress.SetStateOnPercent( nRow ); } - - comphelper::disposeComponent( xRowSet ); - comphelper::disposeComponent( xConnection ); } catch ( sdbc::SQLException& ) { @@ -733,91 +752,29 @@ ULONG ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet, BO aColNames.getArray(), aColTypes.getArray(), aColLengths.getArray(), aColScales.getArray(), bHasMemo, eCharSet ); - - INetURLObject aURL; - aURL.SetSmartProtocol( INET_PROT_FILE ); - aURL.SetSmartURL( rFullFileName ); - String aTabName = aURL.getBase( INetURLObject::LAST_SEGMENT, true, - INetURLObject::DECODE_UNAMBIGUOUS ); - String aExtension = aURL.getExtension(); - aURL.removeSegment(); - aURL.removeFinalSlash(); - String aPath = aURL.GetMainURL(INetURLObject::NO_DECODE); - // also needed for exception catch SCROW nDocRow = 0; ScFieldEditEngine aEditEngine( aDocument.GetEditPool() ); String aString; + String aTabName; try { - uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); - if (!xFactory.is()) return SCERR_EXPORT_CONNECT; - - uno::Reference<sdbc::XDriverManager> xDrvMan( xFactory->createInstance( - rtl::OUString::createFromAscii( SC_SERVICE_DRVMAN ) ), - uno::UNO_QUERY); - DBG_ASSERT( xDrvMan.is(), "can't get DriverManager" ); - if (!xDrvMan.is()) return SCERR_EXPORT_CONNECT; - - // get connection - - String aConnUrl = String::CreateFromAscii("sdbc:dbase:"); - aConnUrl += aPath; - - dbtools::OCharsetMap aMap; - dbtools::OCharsetMap::CharsetIterator aIter = aMap.find( (rtl_TextEncoding) eCharSet ); - if ( aIter == aMap.end() ) - { - DBG_ERRORFILE( "DBaseExport: dbtools::OCharsetMap doesn't know text encoding" ); - return SCERR_EXPORT_CONNECT; - } - rtl::OUString aCharSetStr = (*aIter).getIanaName(); - - uno::Sequence<beans::PropertyValue> aProps(2); - aProps[0].Name = rtl::OUString::createFromAscii(SC_DBPROP_EXTENSION); - aProps[0].Value <<= rtl::OUString( aExtension ); - aProps[1].Name = rtl::OUString::createFromAscii(SC_DBPROP_CHARSET); - aProps[1].Value <<= aCharSetStr; - - uno::Reference<sdbc::XConnection> xConnection = - xDrvMan->getConnectionWithInfo( aConnUrl, aProps ); - DBG_ASSERT( xConnection.is(), "can't get Connection" ); - if (!xConnection.is()) return SCERR_EXPORT_CONNECT; + uno::Reference<sdbc::XDriverManager> xDrvMan; + uno::Reference<sdbc::XConnection> xConnection; + ULONG nRet = lcl_getDBaseConnection(xDrvMan,xConnection,aTabName,rFullFileName,eCharSet); + if ( !xConnection.is() || !xDrvMan.is() ) + return nRet; ::utl::DisposableComponent aConnectionHelper(xConnection); // get dBase driver - - uno::Reference<sdbc::XDriver> xDriver; - BOOL bDriverFound = FALSE; - - uno::Reference<container::XEnumerationAccess> xEnAcc( xDrvMan, uno::UNO_QUERY ); - DBG_ASSERT( xEnAcc.is(), "can't get DriverManager EnumerationAccess" ); - if (!xEnAcc.is()) return SCERR_EXPORT_CONNECT; - - uno::Reference<container::XEnumeration> xEnum = xEnAcc->createEnumeration(); - DBG_ASSERT( xEnum.is(), "can't get DriverManager Enumeration" ); - if (!xEnum.is()) return SCERR_EXPORT_CONNECT; - - while ( xEnum->hasMoreElements() && !bDriverFound ) - { - uno::Any aElement = xEnum->nextElement(); - if ( aElement >>= xDriver ) - if ( xDriver.is() && xDriver->acceptsURL( aConnUrl ) ) - bDriverFound = TRUE; - } - - DBG_ASSERT( bDriverFound, "can't get dBase driver" ); - if (!bDriverFound) return SCERR_EXPORT_CONNECT; + uno::Reference< sdbc::XDriverAccess> xAccess(xDrvMan,uno::UNO_QUERY); + uno::Reference< sdbcx::XDataDefinitionSupplier > xDDSup( xAccess->getDriverByURL( xConnection->getMetaData()->getURL() ), uno::UNO_QUERY ); + if ( !xDDSup.is() ) + return SCERR_EXPORT_CONNECT; // create table - - uno::Reference<sdbcx::XDataDefinitionSupplier> xDDSup( xDriver, uno::UNO_QUERY ); - DBG_ASSERT( xDDSup.is(), "can't get XDataDefinitionSupplier" ); - if (!xDDSup.is()) return SCERR_EXPORT_CONNECT; - - uno::Reference<sdbcx::XTablesSupplier> xTablesSupp = - xDDSup->getDataDefinitionByConnection( xConnection ); + uno::Reference<sdbcx::XTablesSupplier> xTablesSupp =xDDSup->getDataDefinitionByConnection( xConnection ); DBG_ASSERT( xTablesSupp.is(), "can't get Data Definition" ); if (!xTablesSupp.is()) return SCERR_EXPORT_CONNECT; @@ -893,7 +850,7 @@ ULONG ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet, BO // if (!xConnection.is()) return SCERR_EXPORT_CONNECT; // get row set for writing - + uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); uno::Reference<sdbc::XRowSet> xRowSet( xFactory->createInstance( rtl::OUString::createFromAscii( SC_SERVICE_ROWSET ) ), uno::UNO_QUERY); diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx index 9f7c201c8aca..570d41f7885d 100644 --- a/sc/source/ui/docshell/tablink.cxx +++ b/sc/source/ui/docshell/tablink.cxx @@ -280,7 +280,7 @@ BOOL ScTableLink::Refresh(const String& rNewFile, const String& rNewFilter, { String aName; pDoc->GetName( nTab, aName ); - if ( ScGlobal::pTransliteration->isEqual( + if ( ScGlobal::GetpTransliteration()->isEqual( ScGlobal::GetDocTabName( aFileName, aTabName ), aName ) ) { pDoc->RenameTab( nTab, diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index 2faf148e5ac1..76330036b1f5 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -2127,7 +2127,7 @@ IMPL_LINK( ScAcceptChgDlg, ColCompareHdl, SvSortData*, pSortData ) if(nRightKind == SV_ITEM_ID_LBOXSTRING && nLeftKind == SV_ITEM_ID_LBOXSTRING ) { - eCompare= (StringCompare) ScGlobal::pCaseCollator->compareString( + eCompare= (StringCompare) ScGlobal::GetCaseCollator()->compareString( ((SvLBoxString*)pLeftItem)->GetText(), ((SvLBoxString*)pRightItem)->GetText()); diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx index 5f38fbf5c049..08dbd00de0f9 100644 --- a/sc/source/ui/miscdlgs/solveroptions.cxx +++ b/sc/source/ui/miscdlgs/solveroptions.cxx @@ -66,7 +66,7 @@ struct ScSolverOptionsEntry bool operator< (const ScSolverOptionsEntry& rOther) const { - return ( ScGlobal::pCollator->compareString( aDescription, rOther.aDescription ) == COMPARE_LESS ); + return ( ScGlobal::GetCollator()->compareString( aDescription, rOther.aDescription ) == COMPARE_LESS ); } }; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index ec706252a737..cd63adc33989 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -60,6 +60,9 @@ #include <com/sun/star/script/XLibraryContainer.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> +#include <com/sun/star/document/XDocumentEventBroadcaster.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/reflection/XIdlClassProvider.hpp> #include <comphelper/processfactory.hxx> #include "docuno.hxx" @@ -224,15 +227,30 @@ ScModelObj::ScModelObj( ScDocShell* pDocSh ) : if ( pDocShell ) { pDocShell->GetDocument()->AddUnoObject(*this); // SfxModel is derived from SfxListener + } +} +ScModelObj::~ScModelObj() +{ + if (pDocShell) + pDocShell->GetDocument()->RemoveUnoObject(*this); + + if (xNumberAgg.is()) + xNumberAgg->setDelegator(uno::Reference<uno::XInterface>()); + + delete pPrintFuncCache; +} + +uno::Reference< uno::XAggregation> ScModelObj::GetFormatter() +{ + if ( !xNumberAgg.is() ) + { // setDelegator veraendert den RefCount, darum eine Referenz selber halten // (direkt am m_refCount, um sich beim release nicht selbst zu loeschen) comphelper::increment( m_refCount ); - // waehrend des queryInterface braucht man ein Ref auf das // SvNumberFormatsSupplierObj, sonst wird es geloescht. - uno::Reference<util::XNumberFormatsSupplier> xFormatter(new SvNumberFormatsSupplierObj( - pDocShell->GetDocument()->GetFormatTable() )); + uno::Reference<util::XNumberFormatsSupplier> xFormatter(new SvNumberFormatsSupplierObj(pDocShell->GetDocument()->GetFormatTable() )); { xNumberAgg.set(uno::Reference<uno::XAggregation>( xFormatter, uno::UNO_QUERY )); // extra block to force deletion of the temporary before setDelegator @@ -243,20 +261,9 @@ ScModelObj::ScModelObj( ScDocShell* pDocSh ) : if (xNumberAgg.is()) xNumberAgg->setDelegator( (cppu::OWeakObject*)this ); - comphelper::decrement( m_refCount ); - } -} - -ScModelObj::~ScModelObj() -{ - if (pDocShell) - pDocShell->GetDocument()->RemoveUnoObject(*this); - - if (xNumberAgg.is()) - xNumberAgg->setDelegator(uno::Reference<uno::XInterface>()); - - delete pPrintFuncCache; + } // if ( !xNumberAgg.is() ) + return xNumberAgg; } ScDocument* ScModelObj::GetDocument() const @@ -316,8 +323,19 @@ uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType ) SC_QUERYINTERFACE( util::XChangesNotifier ) uno::Any aRet(SfxBaseModel::queryInterface( rType )); - if ( !aRet.hasValue() && xNumberAgg.is() ) - aRet = xNumberAgg->queryAggregation( rType ); + if ( !aRet.hasValue() + && rType != ::getCppuType((uno::Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0) + && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XController>*)0) + && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XFrame>*)0) + && rType != ::getCppuType((uno::Reference< com::sun::star::script::XInvocation>*)0) + && rType != ::getCppuType((uno::Reference< com::sun::star::reflection::XIdlClassProvider>*)0) + && rType != ::getCppuType((uno::Reference< com::sun::star::beans::XFastPropertySet>*)0) + && rType != ::getCppuType((uno::Reference< com::sun::star::awt::XWindow>*)0)) + { + GetFormatter(); + if ( xNumberAgg.is() ) + aRet = xNumberAgg->queryAggregation( rType ); + } return aRet; } @@ -342,7 +360,7 @@ uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeExcep const uno::Type* pParentPtr = aParentTypes.getConstArray(); uno::Sequence<uno::Type> aAggTypes; - if ( xNumberAgg.is() ) + if ( GetFormatter().is() ) { const uno::Type& rProvType = ::getCppuType((uno::Reference<lang::XTypeProvider>*) 0); uno::Any aNumProv(xNumberAgg->queryAggregation(rProvType)); @@ -433,7 +451,7 @@ void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { // NumberFormatter-Pointer am Uno-Objekt neu setzen - if (xNumberAgg.is()) + if (GetFormatter().is()) { SvNumberFormatsSupplierObj* pNumFmt = SvNumberFormatsSupplierObj::getImplementation( @@ -1760,7 +1778,7 @@ sal_Int64 SAL_CALL ScModelObj::getSomething( if ( nRet ) return nRet; - if ( xNumberAgg.is() ) + if ( GetFormatter().is() ) { const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*) 0); uno::Any aNumTunnel(xNumberAgg->queryAggregation(rTunnelType)); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index dd76058756a1..f5688171b145 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -94,7 +94,6 @@ const USHORT SC_SHRINKAGAIN_MAX = 7; class ScDrawStringsVars { ScOutputData* pOutput; // Verbindung - SvNumberFormatter* pFormatter; const ScPatternAttr* pPattern; // Attribute const SfxItemSet* pCondSet; // aus bedingter Formatierung @@ -187,8 +186,6 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, BOOL bPTL) : bShrink ( FALSE ), bPixelToLogic( bPTL ) { - pFormatter = pData->pDoc->GetFormatTable(); - ScModule* pScMod = SC_MOD(); // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE) bCellContrast = pOutput->bUseStyleColor && @@ -373,7 +370,7 @@ void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* // Zahlenformat // ULONG nOld = nValueFormat; - nValueFormat = pPattern->GetNumberFormat( pFormatter, pCondSet ); + nValueFormat = pPattern->GetNumberFormat( pOutput->pDoc->GetFormatTable(), pCondSet ); /* s.u. if (nValueFormat != nOld) @@ -414,7 +411,7 @@ void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxIt const SfxPoolItem* pLangItem; if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,TRUE,&pLangItem) != SFX_ITEM_SET ) pLangItem = &pPattern->GetItem(ATTR_LANGUAGE_FORMAT); - nValueFormat = pFormatter->GetFormatForLanguageIfBuiltIn( + nValueFormat = pOutput->pDoc->GetFormatTable()->GetFormatForLanguageIfBuiltIn( ((SfxUInt32Item*)pFormItem)->GetValue(), ((SvxLanguageItem*)pLangItem)->GetLanguage() ); @@ -456,7 +453,7 @@ BOOL ScDrawStringsVars::SetText( ScBaseCell* pCell ) ULONG nFormat = GetValueFormat(); ScCellFormat::GetString( pCell, nFormat, aString, &pColor, - *pFormatter, + *pOutput->pDoc->GetFormatTable(), pOutput->bShowNullValues, pOutput->bShowFormulas, ftCheck ); @@ -1916,8 +1913,6 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) Size aMinSize = pRefDevice->PixelToLogic(Size(0,100)); // erst darueber wird ausgegeben // UINT32 nMinHeight = aMinSize.Height() / 200; // 1/2 Pixel - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - ScModule* pScMod = SC_MOD(); sal_Int32 nConfBackColor = pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE) @@ -2321,12 +2316,12 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) else { ULONG nFormat = pPattern->GetNumberFormat( - pFormatter, pCondSet ); + pDoc->GetFormatTable(), pCondSet ); String aString; Color* pColor; ScCellFormat::GetString( pCell, nFormat,aString, &pColor, - *pFormatter, + *pDoc->GetFormatTable(), bShowNullValues, bShowFormulas, ftCheck ); @@ -2812,8 +2807,6 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) nRotMax = pRowInfo[nRotY].nRotMaxCol; - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - ScModule* pScMod = SC_MOD(); sal_Int32 nConfBackColor = pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE) @@ -3102,12 +3095,12 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) else { ULONG nFormat = pPattern->GetNumberFormat( - pFormatter, pCondSet ); + pDoc->GetFormatTable(), pCondSet ); String aString; Color* pColor; ScCellFormat::GetString( pCell, nFormat,aString, &pColor, - *pFormatter, + *pDoc->GetFormatTable(), bShowNullValues, bShowFormulas, ftCheck ); diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index d8449ebc3699..29ebede481b9 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1806,7 +1806,7 @@ void ScTabViewShell::Construct( BYTE nForceDesignMode ) { SCTAB nInitTabCount = 3; //! konfigurierbar !!! for (SCTAB i=1; i<nInitTabCount; i++) - pDoc->MakeTable(i); + pDoc->MakeTable(i,false); } pDocSh->SetEmpty( FALSE ); // #i6232# make sure this is done only once diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 766785d5ffc8..72fb7bfdf06f 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -104,30 +104,38 @@ BOOL ScTabViewShell::GetFunction( String& rFuncStr ) aStr = ScGlobal::GetRscString(nGlobStrId); aStr += '='; - // Anzahl im Standardformat, die anderen nach Cursorposition - sal_uInt32 nNumFmt = 0; - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 ) - { - // Zahlformat aus Attributen oder Formel - pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt ); - if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) - { - ScBaseCell* pCell; - pDoc->GetCell( nPosX, nPosY, nTab, pCell ); - if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) - nNumFmt = ((ScFormulaCell*)pCell)->GetStandardFormat( - *pFormatter, nNumFmt ); - } - } ScAddress aCursor( nPosX, nPosY, nTab ); double nVal; if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) ) { - String aValStr; - Color* pDummy; - pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy ); - aStr += aValStr; + if ( nVal == 0.0 ) + aStr += '0'; + else + { + // Anzahl im Standardformat, die anderen nach Cursorposition + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + sal_uInt32 nNumFmt = 0; + if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 ) + { + // Zahlformat aus Attributen oder Formel + pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt ); + if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) + { + ScBaseCell* pCell; + pDoc->GetCell( nPosX, nPosY, nTab, pCell ); + if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) + { + + nNumFmt = ((ScFormulaCell*)pCell)->GetStandardFormat(*pFormatter, nNumFmt ); + } + } + } + + String aValStr; + Color* pDummy; + pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy ); + aStr += aValStr; + } } rFuncStr = aStr; diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk index 49eb10b7e8b4..c06071ff6324 100644 --- a/sc/util/makefile.mk +++ b/sc/util/makefile.mk @@ -100,7 +100,6 @@ SHL1STDLIBS= \ $(UNOTOOLSLIB) \ $(SOTLIB) \ $(XMLOFFLIB) \ - $(DBTOOLSLIB) \ $(AVMEDIALIB) \ $(FORLIB) \ $(FORUILIB) |