diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-05-23 15:39:06 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-05-23 15:39:06 -0400 |
commit | 42eb2de7a08c50b36b731f6df67f119e2d5d6fdf (patch) | |
tree | ae461004c3676df741fe89cd96630bb5b3334946 | |
parent | e0142fade08df22537cd9b03a279ca8f64d401a5 (diff) | |
parent | 551cca5872a7dff96016e964a602c17a516b2ef3 (diff) |
Merge branch 'master' into feature/calc-multiline-input
112 files changed, 1390 insertions, 1493 deletions
diff --git a/.gitignore b/.gitignore index de984102e..441f77934 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,11 @@ /*/unxlng??.pro /*/wntmsc??? /*/wntmsc???.pro +/*/wntgcc? +/*/wntgcc?.pro /*/unxmac??.pro /*/unxmac?? +/*/unxios? +/*/unxios?.pro +/*/unxand? +/*/unxand?.pro diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 724d90fd3..2a9015bdf 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -619,7 +619,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet { TimeInterval aTimeInterval; aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; - aTimeInterval.Number = static_cast<double>(fValue); + aTimeInterval.Number = static_cast<sal_Int32>(fValue); aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval ); bSetScale = true; } diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx index 5c8dccb61..4e54097de 100644 --- a/chart2/source/controller/main/ShapeController.cxx +++ b/chart2/source/controller/main/ShapeController.cxx @@ -328,7 +328,7 @@ void ShapeController::executeDispatch_FormatArea() SfxItemPool& rItemPool = pDrawViewWrapper->GetModel()->GetItemPool(); SfxItemSet aSet( rItemPool, rItemPool.GetFirstWhich(), rItemPool.GetLastWhich() ); const SvxColorTableItem* pColorItem = static_cast< const SvxColorTableItem* >( aSet.GetItem( SID_COLOR_TABLE ) ); - if ( pColorItem && pColorItem->GetColorTable() == XColorTable::GetStdColorTable() ) + if ( pColorItem && pColorItem->GetColorTable() == &XColorTable::GetStdColorTable() ) { pDlg->DontDeleteColorTable(); } diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 325dd5dc9..66f07c78d 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -572,6 +572,10 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException) m_xCurrentController.clear(); DisposeHelper::DisposeAndClear( m_xRangeHighlighter ); + + if( m_xOldModelAgg.is()) + m_xOldModelAgg->setDelegator( NULL ); + OSL_TRACE( "ChartModel: dispose() called" ); } diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index cb9be009a..461ba21f1 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -714,7 +714,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( } } rExplicitIncrement.MajorTimeInterval.Number = nNumer; - nMainIncrementCount = nDayCount/(nNumer*nDaysPerInterval); + nMainIncrementCount = static_cast<long>(nDayCount/(nNumer*nDaysPerInterval)); } //choose minor time interval: diff --git a/chart2/source/view/axes/Tickmarks_Dates.cxx b/chart2/source/view/axes/Tickmarks_Dates.cxx index 9a9cc85ef..98849b7be 100644 --- a/chart2/source/view/axes/Tickmarks_Dates.cxx +++ b/chart2/source/view/axes/Tickmarks_Dates.cxx @@ -82,8 +82,8 @@ void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& r Date aNull(m_aScale.NullDate); - Date aDate = aNull + ::rtl::math::approxFloor(m_aScale.Minimum); - Date aMaxDate = aNull + ::rtl::math::approxFloor(m_aScale.Maximum); + Date aDate = aNull + static_cast<long>(::rtl::math::approxFloor(m_aScale.Minimum)); + Date aMaxDate = aNull + static_cast<long>(::rtl::math::approxFloor(m_aScale.Maximum)); uno::Reference< chart2::XScaling > xScaling(m_aScale.Scaling); uno::Reference< chart2::XScaling > xInverseScaling(m_xInverseScaling); @@ -125,7 +125,7 @@ void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& r } //create minor date tickinfos - aDate = aNull + ::rtl::math::approxFloor(m_aScale.Minimum); + aDate = aNull + static_cast<long>(::rtl::math::approxFloor(m_aScale.Minimum)); while( aDate<= aMaxDate ) { if( bShifted && aDate==aMaxDate ) diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 2bd8afe4b..00c466613 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1189,11 +1189,11 @@ long VSeriesPlotter::calculateTimeResolutionOnXAxis() aNullDate = m_apNumberFormatterWrapper->getNullDate(); if( aIt!=aEnd ) { - Date aPrevious(aNullDate); aPrevious+=rtl::math::approxFloor(aIt->fValue); + Date aPrevious(aNullDate); aPrevious+=static_cast<long>(rtl::math::approxFloor(aIt->fValue)); ++aIt; for(;aIt!=aEnd;++aIt) { - Date aCurrent(aNullDate); aCurrent+=rtl::math::approxFloor(aIt->fValue); + Date aCurrent(aNullDate); aCurrent+=static_cast<long>(rtl::math::approxFloor(aIt->fValue)); if( ::com::sun::star::chart::TimeUnit::YEAR == nRet ) { if( DateHelper::IsInSameYear( aPrevious, aCurrent ) ) diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index b872ee4d9..cbfef004b 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -898,8 +898,8 @@ void VLegend::createShapes( RelativeSize aRelativeSize; if ((xLegendProp->getPropertyValue( C2U( "RelativeSize" )) >>= aRelativeSize)) { - aLegendSize.Width = ::rtl::math::approxCeil( aRelativeSize.Primary * rPageSize.Width ); - aLegendSize.Height = ::rtl::math::approxCeil( aRelativeSize.Secondary * rPageSize.Height ); + aLegendSize.Width = static_cast<sal_Int32>(::rtl::math::approxCeil( aRelativeSize.Primary * rPageSize.Width )); + aLegendSize.Height = static_cast<sal_Int32>(::rtl::math::approxCeil( aRelativeSize.Secondary * rPageSize.Height )); } else eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk index d58b8bdc0..ec8db6590 100644 --- a/sc/CppunitTest_sc_ucalc.mk +++ b/sc/CppunitTest_sc_ucalc.mk @@ -30,23 +30,10 @@ $(eval $(call gb_CppunitTest_CppunitTest,sc_ucalc)) -$(eval $(call gb_CppunitTest_add_package_headers,sc_ucalc,sc_qa_unit)) - $(eval $(call gb_CppunitTest_add_exception_objects,sc_ucalc, \ sc/qa/unit/ucalc \ )) -$(eval $(call gb_CppunitTest_set_args,sc_ucalc,\ - --headless \ - --invisible \ - "-env:UNO_TYPES=$(foreach binrdb,udkapi.rdb types.rdb,\ - file://$(if $(filter WNT,$(OS)),/)$(OUTDIR)/bin/$(binrdb))" \ - "-env:UNO_SERVICES=$(foreach rdb,$(OUTDIR)/xml/ure/services.rdb $(WORKDIR)/CustomTarget/sc/qa/unit/services.rdb,\ - file://$(if $(filter WNT,$(OS)),/)$(rdb))" \ - $(foreach dir,URE_INTERNAL_LIB_DIR OOO_BASE_DIR BRAND_BASE_DIR, \ - -env:$(dir)=file://$(if $(filter WNT,$(OS)),/$(OUTDIR)/bin,$(OUTDIR)/lib)) \ -)) - $(eval $(call gb_CppunitTest_add_library_objects,sc_ucalc,sc)) $(eval $(call gb_CppunitTest_add_linked_libs,sc_ucalc, \ diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index c57671ed7..078c94c40 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -167,7 +167,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/core/tool/collect \ sc/source/core/tool/compiler \ sc/source/core/tool/consoli \ - sc/source/core/tool/dbcolect \ + sc/source/core/tool/dbdata \ sc/source/core/tool/ddelink \ sc/source/core/tool/detdata \ sc/source/core/tool/detfunc \ diff --git a/sc/Package_qa_unit.mk b/sc/Package_qa_unit.mk deleted file mode 100644 index 8db8cb798..000000000 --- a/sc/Package_qa_unit.mk +++ /dev/null @@ -1,44 +0,0 @@ -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Bjoern Michaelsen <bjoern.michaelsen@canonical.com> (Canonical Ltd.) -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): Bjoern Michaelsen <bjoern.michaelsen@canonical.com> (Canonical Ltd.) -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. - -$(eval $(call gb_Package_Package,sc_qa_unit,$(WORKDIR)/CustomTarget/sc/qa/unit)) -$(eval $(call gb_Package_add_customtarget,sc_qa_unit,sc/qa/unit)) - -# dependencies that cause the CustomTarget Makefile to be called recursively for -# (re)build -$(eval $(call gb_CustomTarget_add_outdir_dependencies,sc/qa/unit,\ - $(foreach newcomponentfile,\ - framework/util/fwk \ - sfx2/util/sfx \ - unoxml/source/service/unoxml,\ - $(OUTDIR)/xml/component/$(newcomponentfile).component) \ - $(foreach oldcomponentfile, \ - i18npool \ - ucb1 \ - ucpfile1, \ - $(OUTDIR)/xml/$(oldcomponentfile).component) \ -)) - -# vim: set noet sw=4: diff --git a/sc/inc/arealink.hxx b/sc/inc/arealink.hxx index 38efaaab8..80ecc7037 100644 --- a/sc/inc/arealink.hxx +++ b/sc/inc/arealink.hxx @@ -49,10 +49,10 @@ private: String aOptions; String aSourceArea; ScRange aDestArea; - sal_Bool bAddUndo; - sal_Bool bInCreate; - sal_Bool bDoInsert; // is set to FALSE for first update - sal_Bool FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName ); + bool bAddUndo; + bool bInCreate; + bool bDoInsert; // is set to FALSE for first update + bool FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName ); public: TYPEINFO(); @@ -70,14 +70,14 @@ public: sal_Bool Refresh( const String& rNewFile, const String& rNewFilter, const String& rNewArea, sal_uLong nNewRefresh ); - void SetInCreate(sal_Bool bSet) { bInCreate = bSet; } - void SetDoInsert(sal_Bool bSet) { bDoInsert = bSet; } + void SetInCreate(bool bSet) { bInCreate = bSet; } + void SetDoInsert(bool bSet) { bDoInsert = bSet; } void SetDestArea(const ScRange& rNew); void SetSource(const String& rDoc, const String& rFlt, const String& rOpt, const String& rArea); - sal_Bool IsEqual( const String& rFile, const String& rFilter, const String& rOpt, - const String& rSource, const ScRange& rDest ) const; + bool IsEqual( const String& rFile, const String& rFilter, const String& rOpt, + const String& rSource, const ScRange& rDest ) const; const String& GetFile() const { return aFileName; } const String& GetFilter() const { return aFilterName; } diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 5fcc6dc8f..407b58076 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -346,7 +346,7 @@ private: sal_Bool IsMacro( const String& ); sal_Bool IsNamedRange( const String& ); bool IsExternalNamedRange( const String& rSymbol ); - sal_Bool IsDBRange( const String& ); + bool IsDBRange( const String& ); sal_Bool IsColRowName( const String& ); sal_Bool IsBoolean( const String& ); void AutoCorrectParsedSymbol(); @@ -448,7 +448,7 @@ public: ScRangeData* UpdateDeleteTab(SCTAB nTable, sal_Bool bIsMove, sal_Bool bIsName, sal_Bool& bCompile); ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, sal_Bool bIsName ); - sal_Bool HasModifiedRange(); + bool HasModifiedRange(); /** If the character is allowed as first character in sheet names or references, includes '$' and '?'. */ diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx index 7d43e4fef..53457bf4c 100644 --- a/sc/inc/datauno.hxx +++ b/sc/inc/datauno.hxx @@ -615,7 +615,7 @@ class ScDatabaseRangesObj : public cppu::WeakImplHelper4< private: ScDocShell* pDocShell; - ScDatabaseRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex); + ScDatabaseRangeObj* GetObjectByIndex_Impl(size_t nIndex); ScDatabaseRangeObj* GetObjectByName_Impl(const ::rtl::OUString& aName); public: diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx deleted file mode 100644 index 3586ca9ab..000000000 --- a/sc/inc/dbcolect.hxx +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SC_DBCOLECT_HXX -#define SC_DBCOLECT_HXX - -#include "scdllapi.h" -#include "collect.hxx" -#include "global.hxx" // MAXQUERY -#include "sortparam.hxx" // MAXSORT -#include "refreshtimer.hxx" -#include "address.hxx" -#include "scdllapi.h" -#include "subtotalparam.hxx" -#include "queryparam.hxx" - -#include <boost/ptr_container/ptr_vector.hpp> -#include <boost/scoped_ptr.hpp> - -class ScDocument; - -class ScDBData : public ScDataObject, public ScRefreshTimer -{ -private: - ScSortParam maSortParam; - ScQueryParam maQueryParam; - ScSubTotalParam maSubTotal; - ScImportParam maImportParam; - - // DBParam - ::rtl::OUString aName; - SCTAB nTable; - SCCOL nStartCol; - SCROW nStartRow; - SCCOL nEndCol; - SCROW nEndRow; - bool bByRow; - bool bHasHeader; - bool bDoSize; - bool bKeepFmt; - bool bStripData; - - // QueryParam - bool bIsAdvanced; // true if created by advanced filter - ScRange aAdvSource; // source range - - bool bDBSelection; // not in Param: if selection, block update - - sal_uInt16 nIndex; // unique index formulas - bool bAutoFilter; // AutoFilter? (not saved) - bool bModified; // is set/cleared for/by(?) UpdateReference - - using ScRefreshTimer::operator==; - -public: - SC_DLLPUBLIC ScDBData(const ::rtl::OUString& rName, - SCTAB nTab, - SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - bool bByR = true, bool bHasH = true); - ScDBData(const ScDBData& rData); - ~ScDBData(); - - virtual ScDataObject* Clone() const; - - ScDBData& operator= (const ScDBData& rData); - - bool operator== (const ScDBData& rData) const; - - SCTAB GetTable() const; - const ::rtl::OUString& GetName() const { return aName; } - void SetName(const ::rtl::OUString& rName) { aName = rName; } - void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const; - SC_DLLPUBLIC void GetArea(ScRange& rRange) const; - void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); - void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); - bool IsByRow() const { return bByRow; } - void SetByRow(bool bByR) { bByRow = bByR; } - bool HasHeader() const { return bHasHeader; } - void SetHeader(bool bHasH) { bHasHeader = bHasH; } - void SetIndex(sal_uInt16 nInd) { nIndex = nInd; } - sal_uInt16 GetIndex() const { return nIndex; } - bool IsDoSize() const { return bDoSize; } - void SetDoSize(bool bSet) { bDoSize = bSet; } - bool IsKeepFmt() const { return bKeepFmt; } - void SetKeepFmt(bool bSet) { bKeepFmt = bSet; } - bool IsStripData() const { return bStripData; } - void SetStripData(bool bSet) { bStripData = bSet; } - - ::rtl::OUString GetSourceString() const; - ::rtl::OUString GetOperations() const; - - void GetSortParam(ScSortParam& rSortParam) const; - void SetSortParam(const ScSortParam& rSortParam); - - SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const; - SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam); - SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange& rSource) const; - SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource); - - void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const; - void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam); - - void GetImportParam(ScImportParam& rImportParam) const; - void SetImportParam(const ScImportParam& rImportParam); - - bool IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const; - bool IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; - - bool HasImportParam() const { return maImportParam.bImport; } - SC_DLLPUBLIC bool HasQueryParam() const; - bool HasSortParam() const { return maSortParam.bDoSort[0]; } - bool HasSubTotalParam() const { return maSubTotal.bGroupActive[0]; } - - bool HasImportSelection() const { return bDBSelection; } - void SetImportSelection(bool bSet) { bDBSelection = bSet; } - - bool HasAutoFilter() const { return bAutoFilter; } - void SetAutoFilter(bool bSet) { bAutoFilter = bSet; } - - bool IsModified() const { return bModified; } - void SetModified(bool bMod) { bModified = bMod; } - - void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ); - void UpdateReference(ScDocument* pDoc, UpdateRefMode eUpdateRefMode, - SCCOL nCol1, SCROW nRow1, SCTAB nTab1, - SCCOL nCol2, SCROW nRow2, SCTAB nTab2, - SCsCOL nDx, SCsROW nDy, SCsTAB nDz); - - void ExtendDataArea(ScDocument* pDoc); -}; - - -//------------------------------------------------------------------------ -class SC_DLLPUBLIC ScDBCollection : public ScSortedCollection -{ - typedef ::boost::ptr_vector<ScDBData> DBRangesType; -public: - typedef DBRangesType AnonDBsType; - -private: - Link aRefreshHandler; - ScDocument* pDoc; - sal_uInt16 nEntryIndex; // counter for unique indices - AnonDBsType maAnonDBs; - -public: - ScDBCollection(sal_uInt16 nLim = 4, sal_uInt16 nDel = 4, sal_Bool bDup = false, ScDocument* pDocument = NULL) : - ScSortedCollection ( nLim, nDel, bDup ), - pDoc ( pDocument ), - nEntryIndex ( SC_START_INDEX_DB_COLL ) // see above for the names - {} - - ScDBCollection(const ScDBCollection& r); - - virtual ScDataObject* Clone() const { return new ScDBCollection(*this); } - ScDBData* operator[]( const sal_uInt16 nIndex) const {return (ScDBData*)At(nIndex);} - virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const; - virtual sal_Bool IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const; - ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const; - ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; - ScDBData* GetFilterDBAtTable(SCTAB nTab) const; - ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab ); - - sal_Bool SearchName( const String& rName, sal_uInt16& rIndex ) const; - - void DeleteOnTab( SCTAB nTab ); - void UpdateReference(UpdateRefMode eUpdateRefMode, - SCCOL nCol1, SCROW nRow1, SCTAB nTab1, - SCCOL nCol2, SCROW nRow2, SCTAB nTab2, - SCsCOL nDx, SCsROW nDy, SCsTAB nDz); - void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ); - - ScDBData* FindIndex(sal_uInt16 nIndex); - sal_uInt16 GetEntryIndex() { return nEntryIndex; } - void SetEntryIndex(sal_uInt16 nInd) { nEntryIndex = nInd; } - virtual sal_Bool Insert(ScDataObject* pScDataObject); - - void SetRefreshHandler( const Link& rLink ) - { aRefreshHandler = rLink; } - const Link& GetRefreshHandler() const { return aRefreshHandler; } - - const ScDBData* findAnonAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const; - const ScDBData* findAnonByRange(const ScRange& rRange) const; - ScDBData* getAnonByRange(const ScRange& rRange); - void insertAnonRange(ScDBData* pData); - - const AnonDBsType& getAnonRanges() const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx new file mode 100644 index 000000000..2772a0216 --- /dev/null +++ b/sc/inc/dbdata.hxx @@ -0,0 +1,266 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_DBCOLECT_HXX +#define SC_DBCOLECT_HXX + +#include "scdllapi.h" +#include "collect.hxx" +#include "global.hxx" // MAXQUERY +#include "sortparam.hxx" // MAXSORT +#include "refreshtimer.hxx" +#include "address.hxx" +#include "scdllapi.h" +#include "subtotalparam.hxx" +#include "queryparam.hxx" + +#include <boost/ptr_container/ptr_vector.hpp> +#include <boost/ptr_container/ptr_set.hpp> +#include <boost/scoped_ptr.hpp> + +class ScDocument; + +class ScDBData : public ScRefreshTimer +{ +private: + ScSortParam maSortParam; + ScQueryParam maQueryParam; + ScSubTotalParam maSubTotal; + ScImportParam maImportParam; + + // DBParam + const ::rtl::OUString aName; + SCTAB nTable; + SCCOL nStartCol; + SCROW nStartRow; + SCCOL nEndCol; + SCROW nEndRow; + bool bByRow; + bool bHasHeader; + bool bDoSize; + bool bKeepFmt; + bool bStripData; + + // QueryParam + bool bIsAdvanced; // true if created by advanced filter + ScRange aAdvSource; // source range + + bool bDBSelection; // not in Param: if selection, block update + + sal_uInt16 nIndex; // unique index formulas + bool bAutoFilter; // AutoFilter? (not saved) + bool bModified; // is set/cleared for/by(?) UpdateReference + + using ScRefreshTimer::operator==; + +public: + struct less : public ::std::binary_function<ScDBData, ScDBData, bool> + { + bool operator() (const ScDBData& left, const ScDBData& right) const; + }; + + SC_DLLPUBLIC ScDBData(const ::rtl::OUString& rName, + SCTAB nTab, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + bool bByR = true, bool bHasH = true); + ScDBData(const ScDBData& rData); + ScDBData(const ::rtl::OUString& rName, const ScDBData& rData); + ~ScDBData(); + + ScDBData& operator= (const ScDBData& rData); + + bool operator== (const ScDBData& rData) const; + + SCTAB GetTable() const; + const ::rtl::OUString& GetName() const { return aName; } + void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const; + SC_DLLPUBLIC void GetArea(ScRange& rRange) const; + void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + bool IsByRow() const { return bByRow; } + void SetByRow(bool bByR) { bByRow = bByR; } + bool HasHeader() const { return bHasHeader; } + void SetHeader(bool bHasH) { bHasHeader = bHasH; } + void SetIndex(sal_uInt16 nInd) { nIndex = nInd; } + sal_uInt16 GetIndex() const { return nIndex; } + bool IsDoSize() const { return bDoSize; } + void SetDoSize(bool bSet) { bDoSize = bSet; } + bool IsKeepFmt() const { return bKeepFmt; } + void SetKeepFmt(bool bSet) { bKeepFmt = bSet; } + bool IsStripData() const { return bStripData; } + void SetStripData(bool bSet) { bStripData = bSet; } + + ::rtl::OUString GetSourceString() const; + ::rtl::OUString GetOperations() const; + + void GetSortParam(ScSortParam& rSortParam) const; + void SetSortParam(const ScSortParam& rSortParam); + + SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const; + SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam); + SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange& rSource) const; + SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource); + + void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const; + void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam); + + void GetImportParam(ScImportParam& rImportParam) const; + void SetImportParam(const ScImportParam& rImportParam); + + bool IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const; + bool IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; + + bool HasImportParam() const { return maImportParam.bImport; } + SC_DLLPUBLIC bool HasQueryParam() const; + bool HasSortParam() const { return maSortParam.bDoSort[0]; } + bool HasSubTotalParam() const { return maSubTotal.bGroupActive[0]; } + + bool HasImportSelection() const { return bDBSelection; } + void SetImportSelection(bool bSet) { bDBSelection = bSet; } + + bool HasAutoFilter() const { return bAutoFilter; } + void SetAutoFilter(bool bSet) { bAutoFilter = bSet; } + + bool IsModified() const { return bModified; } + void SetModified(bool bMod) { bModified = bMod; } + + void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ); + void UpdateReference(ScDocument* pDoc, UpdateRefMode eUpdateRefMode, + SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz); + + void ExtendDataArea(ScDocument* pDoc); +}; + +class SC_DLLPUBLIC ScDBCollection +{ +public: + enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous }; + + /** + * Stores global named database ranges. + */ + class SC_DLLPUBLIC NamedDBs + { + friend class ScDBCollection; + + typedef ::boost::ptr_set<ScDBData, ScDBData::less> DBsType; + DBsType maDBs; + ScDBCollection& mrParent; + ScDocument& mrDoc; + NamedDBs(ScDBCollection& rParent, ScDocument& rDoc); + NamedDBs(const NamedDBs& r); + public: + typedef DBsType::iterator iterator; + typedef DBsType::const_iterator const_iterator; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + ScDBData* findByIndex(sal_uInt16 nIndex); + ScDBData* findByName(const ::rtl::OUString& rName); + bool insert(ScDBData* p); + void erase(iterator itr); + void erase(const ScDBData& r); + bool empty() const; + size_t size() const; + bool operator== (const NamedDBs& r) const; + }; + + /** + * Stores global anonymous database ranges. + */ + class AnonDBs + { + typedef ::boost::ptr_vector<ScDBData> DBsType; + DBsType maDBs; + public: + typedef DBsType::iterator iterator; + typedef DBsType::const_iterator const_iterator; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + const ScDBData* findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const; + const ScDBData* findByRange(const ScRange& rRange) const; + ScDBData* getByRange(const ScRange& rRange); + void insert(ScDBData* p); + void erase(iterator itr); + bool empty() const; + size_t size() const; + bool operator== (const AnonDBs& r) const; + }; + +private: + Link aRefreshHandler; + ScDocument* pDoc; + sal_uInt16 nEntryIndex; // counter for unique indices + NamedDBs maNamedDBs; + AnonDBs maAnonDBs; + +public: + ScDBCollection(ScDocument* pDocument); + ScDBCollection(const ScDBCollection& r); + + NamedDBs& getNamedDBs(); + const NamedDBs& getNamedDBs() const; + + AnonDBs& getAnonDBs(); + const AnonDBs& getAnonDBs() const; + + const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const; + ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly); + const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; + ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + const ScDBData* GetFilterDBAtTable(SCTAB nTab) const; + ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab ); + + void DeleteOnTab( SCTAB nTab ); + void UpdateReference(UpdateRefMode eUpdateRefMode, + SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz); + void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ); + + sal_uInt16 GetEntryIndex() { return nEntryIndex; } + void SetEntryIndex(sal_uInt16 nInd) { nEntryIndex = nInd; } + + void SetRefreshHandler( const Link& rLink ) + { aRefreshHandler = rLink; } + const Link& GetRefreshHandler() const { return aRefreshHandler; } + + bool empty() const; + bool operator== (const ScDBCollection& r) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 4c7202b05..a7f445240 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -481,10 +481,11 @@ public: SC_DLLPUBLIC ScDBCollection* GetDBCollection() const; void SetDBCollection( ScDBCollection* pNewDBCollection, sal_Bool bRemoveAutoFilter = false ); - ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, - sal_Bool bStartOnly = false) const; - ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; - ScDBData* GetFilterDBAtTable(SCTAB nTab) const; + const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly = false) const; + ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly = false); + const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; + ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + const ScDBData* GetFilterDBAtTable(SCTAB nTab) const; SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, String* pName=NULL ) const; @@ -1475,7 +1476,7 @@ public: TypedScStrCollection& rStrings, sal_Bool bLimit = false ); sal_Bool GetFormulaEntries( TypedScStrCollection& rStrings ); - sal_Bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab ); + bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab ); SC_DLLPUBLIC sal_Bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ); diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx index 9db1155e8..e9ded5ca2 100644 --- a/sc/inc/rangeutl.hxx +++ b/sc/inc/rangeutl.hxx @@ -33,6 +33,7 @@ #include "address.hxx" #include "rangenam.hxx" +#include "dbdata.hxx" #include "scdllapi.h" #include <com/sun/star/table/CellAddress.hpp> @@ -305,18 +306,19 @@ class SC_DLLPUBLIC ScAreaNameIterator { private: ScRangeName* pRangeName; + ScDBCollection* pDBCollection; ScRangeName::const_iterator maRNPos; ScRangeName::const_iterator maRNEnd; - ScDBCollection* pDBCollection; + ScDBCollection::NamedDBs::const_iterator maDBPos; + ScDBCollection::NamedDBs::const_iterator maDBEnd; bool bFirstPass; - size_t nPos; public: ScAreaNameIterator( ScDocument* pDoc ); ~ScAreaNameIterator() {} - sal_Bool Next( String& rName, ScRange& rRange ); - sal_Bool WasDBName() const { return !bFirstPass; } + bool Next( String& rName, ScRange& rRange ); + bool WasDBName() const { return !bFirstPass; } }; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 45ee67ffd..49c705fdb 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -38,7 +38,7 @@ #include "column.hxx" #include "sortparam.hxx" #include "compressedarray.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include <memory> #include <set> diff --git a/sc/qa/unit/Makefile b/sc/qa/unit/Makefile deleted file mode 100644 index 87694f116..000000000 --- a/sc/qa/unit/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Bjoern Michaelsen <bjoern.michaelsen@canonical.com> (Canonical Ltd.) -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): Bjoern Michaelsen <bjoern.michaelsen@canonical.com> (Canonical Ltd.) -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. - -MYDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))) - -all : services.rdb - -services.rdb : $(foreach newcomponentfile,\ - framework/util/fwk \ - sfx2/util/sfx \ - unoxml/source/service/unoxml,\ - $(OUTDIR)/xml/component/$(newcomponentfile).component \ -) - -services.rdb : $(foreach oldcomponentfile, \ - i18npool \ - ucb1 \ - ucpfile1, \ - $(OUTDIR)/xml/$(oldcomponentfile).component \ -) - -services.rdb : - echo '<?xml version="1.0"?><components xmlns="http://openoffice.org/2010/uno-components">' > $@ - $(gb_AWK) -- \ - '/^<\?xml version.*/ { next; } \ - { gsub(/vnd.sun.star.expand:\$$OOO_BASE_DIR\/program/, "vnd.sun.star.expand:$$OOO_BASE_DIR",$$0); gsub(/vnd.sun.star.expand:\$$BRAND_BASE_DIR\/program/, "vnd.sun.star.expand:$$BRAND_BASE_DIR",$$0); print; }' \ - $^ >> $@ - echo '</components>' >> $@ - -.PHONY : all -# vim: set noet sw=4 ts=4: diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 7ec4b234d..f736f88da 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -66,7 +66,7 @@ #include "subtotal.hxx" #include "markdata.hxx" #include "compiler.hxx" // ScTokenArray GetCodeLen -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "fillinfo.hxx" #include "segmenttree.hxx" #include "docparam.hxx" diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index d44755210..c281a3503 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -30,7 +30,9 @@ #include "precompiled_sc.hxx" // INCLUDE --------------------------------------------------------------- +#include <boost/scoped_ptr.hpp> +#include <mdds/flat_segment_tree.hpp> #include <sfx2/objsh.hxx> #include <svl/zforlist.hxx> @@ -377,13 +379,6 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe if ( ScPostIt* pNote = pItems[ nIdx ].pCell->GetNote() ) pNote->ForgetCaption(); - // special simple mode if all contents are deleted and cells do not contain broadcasters - bool bSimple = ((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS); - if (bSimple) - for ( SCSIZE nIdx = nStartIndex; bSimple && (nIdx <= nEndIndex); ++nIdx ) - if (pItems[ nIdx ].pCell->GetBroadcaster()) - bSimple = false; - ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 ); // cache all formula cells, they will be deleted at end of this function @@ -391,12 +386,17 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe FormulaCellVector aDelCells; aDelCells.reserve( nEndIndex - nStartIndex + 1 ); - // simple deletion of the cell objects - if (bSimple) + typedef mdds::flat_segment_tree<SCSIZE, bool> RemovedSegments_t; + RemovedSegments_t aRemovedSegments(nStartIndex, nEndIndex + 1, false); + SCSIZE nFirst(nStartIndex); + + // dummy replacement for old cells, to prevent that interpreter uses old cell + boost::scoped_ptr<ScNoteCell> pDummyCell(new ScNoteCell); + + for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { - // pNoteCell: dummy replacement for old cells, to prevent that interpreter uses old cell - ScNoteCell* pNoteCell = new ScNoteCell; - for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) + // all contents is deleted and cell do not contain broadcaster + if (((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS) && pItems[ nIdx ].pCell->GetBroadcaster()) { ScBaseCell* pOldCell = pItems[ nIdx ].pCell; if (pOldCell->GetCellType() == CELLTYPE_FORMULA) @@ -407,27 +407,19 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe else { // interpret in broadcast must not use the old cell - pItems[ nIdx ].pCell = pNoteCell; + pItems[ nIdx ].pCell = pDummyCell.get(); aHint.GetAddress().SetRow( pItems[ nIdx ].nRow ); aHint.SetCell( pOldCell ); pDocument->Broadcast( aHint ); pOldCell->Delete(); } } - delete pNoteCell; - memmove( &pItems[nStartIndex], &pItems[nEndIndex + 1], (nCount - nEndIndex - 1) * sizeof(ColEntry) ); - nCount -= nEndIndex-nStartIndex+1; - } - - // else: delete some contents of the cells - else - { - SCSIZE j = nStartIndex; - for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) + // delete some contents of the cells + else { // decide whether to delete the cell object according to passed flags bool bDelete = false; - ScBaseCell* pOldCell = pItems[j].pCell; + ScBaseCell* pOldCell = pItems[nIdx].pCell; CellType eCellType = pOldCell->GetCellType(); switch ( eCellType ) { @@ -439,7 +431,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe // if not, decide according to cell number format if( !bDelete && (nValFlags != 0) ) { - sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)GetAttr( pItems[j].nRow, ATTR_VALUE_FORMAT ))->GetValue(); + sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)GetAttr( pItems[nIdx].nRow, ATTR_VALUE_FORMAT ))->GetValue(); short nType = pDocument->GetFormatTable()->GetType(nIndex); bool bIsDate = (nType == NUMBERFORMAT_DATE) || (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME); bDelete = nValFlags == (bIsDate ? IDF_DATETIME : IDF_VALUE); @@ -479,21 +471,16 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe } // remove cell entry in cell item list - SCROW nOldRow = pItems[j].nRow; + SCROW nOldRow = pItems[nIdx].nRow; if (pNoteCell) { // replace old cell with the replacement note cell - pItems[j].pCell = pNoteCell; - ++j; + pItems[nIdx].pCell = pNoteCell; + // ... so it's not really deleted + bDelete = false; } else - { - // remove the old cell from the cell item list - --nCount; - memmove( &pItems[j], &pItems[j + 1], (nCount - j) * sizeof(ColEntry) ); - pItems[nCount].nRow = 0; - pItems[nCount].pCell = 0; - } + pItems[nIdx].pCell = pDummyCell.get(); // cache formula cells (will be deleted later), delete cell of other type if (eCellType == CELLTYPE_FORMULA) @@ -514,10 +501,54 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe { // delete cell note if (bDeleteNote) - pItems[j].pCell->DeleteNote(); - // cell not deleted, move index to next cell - ++j; + pItems[nIdx].pCell->DeleteNote(); } + + if (!bDelete) + { + // We just came to a non-deleted cell after a segment of + // deleted ones. So we need to remember the segment + // before moving on. + if (nFirst < nIdx) + aRemovedSegments.insert_back(nFirst, nIdx, true); + nFirst = nIdx + 1; + } + } + } + // there is a segment of deleted cells at the end + if (nFirst < nEndIndex) + aRemovedSegments.insert_back(nFirst, nEndIndex + 1, true); + + { + RemovedSegments_t::const_iterator aIt(aRemovedSegments.begin()); + RemovedSegments_t::const_iterator aEnd(aRemovedSegments.end()); + if (aIt != aEnd) + { + SCSIZE nStartSegment(aIt->first); + bool bMoveSegment(aIt->second); + // The indexes in aRemovedSegments denote cell positions in the + // original array. But as we are shifting it from the left, we have + // to compensate for already performed shifts for latter segments. + // TODO: use reverse iterators instead + SCSIZE nShift(0); + ++aIt; + do + { + SCSIZE const nEndSegment(aIt->first); + if (bMoveSegment) + { + memmove( + &pItems[nStartSegment - nShift], + &pItems[nEndSegment - nShift], + (nCount - nEndSegment) * sizeof(ColEntry)); + SCSIZE const nNewShift(nEndSegment - nStartSegment); + nShift += nNewShift; + nCount -= nNewShift; + } + nStartSegment = nEndSegment; + bMoveSegment = aIt->second; + ++aIt; + } while (aIt != aEnd); } } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index a4ba5876e..4cd36578d 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -57,7 +57,7 @@ #include "attrib.hxx" #include "patattr.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "pivot.hxx" #include "docpool.hxx" #include "stlpool.hxx" @@ -251,7 +251,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, for (SCTAB i=1; i<=MAXTAB; i++) pTab[i] = NULL; - pDBCollection = new ScDBCollection( 4, 4, false, this ); + pDBCollection = new ScDBCollection(this); pSelectionAttr = NULL; pChartCollection = new ScChartCollection; apTemporaryChartLock = std::auto_ptr< ScTemporaryChartLock >( new ScTemporaryChartLock(this) ); diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index a57a1d3a0..17d5bd95e 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -46,7 +46,7 @@ #include "cell.hxx" #include "table.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "pivot.hxx" #include "docpool.hxx" #include "poolhelp.hxx" @@ -173,56 +173,56 @@ ScDBCollection* ScDocument::GetDBCollection() const void ScDocument::SetDBCollection( ScDBCollection* pNewDBCollection, sal_Bool bRemoveAutoFilter ) { - if ( bRemoveAutoFilter ) + if (pDBCollection && bRemoveAutoFilter) { // remove auto filter attribute if new db data don't contain auto filter flag // start position is also compared, so bRemoveAutoFilter must not be set from ref-undo! - if ( pDBCollection ) + ScDBCollection::NamedDBs& rNamedDBs = pDBCollection->getNamedDBs(); + ScDBCollection::NamedDBs::const_iterator itr = rNamedDBs.begin(), itrEnd = rNamedDBs.end(); + for (; itr != itrEnd; ++itr) { - sal_uInt16 nOldCount = pDBCollection->GetCount(); - for (sal_uInt16 nOld=0; nOld<nOldCount; nOld++) - { - ScDBData* pOldData = (*pDBCollection)[nOld]; - if ( pOldData->HasAutoFilter() ) - { - ScRange aOldRange; - pOldData->GetArea( aOldRange ); + const ScDBData& rOldData = *itr; + if (!rOldData.HasAutoFilter()) + continue; - sal_Bool bFound = false; - sal_uInt16 nNewIndex = 0; - if ( pNewDBCollection && - pNewDBCollection->SearchName( pOldData->GetName(), nNewIndex ) ) - { - ScDBData* pNewData = (*pNewDBCollection)[nNewIndex]; - if ( pNewData->HasAutoFilter() ) - { - ScRange aNewRange; - pNewData->GetArea( aNewRange ); - if ( aOldRange.aStart == aNewRange.aStart ) - bFound = sal_True; - } - } + ScRange aOldRange; + rOldData.GetArea(aOldRange); - if ( !bFound ) + bool bFound = false; + if (pNewDBCollection) + { + ScDBData* pNewData = pNewDBCollection->getNamedDBs().findByName(rOldData.GetName()); + if (pNewData) + { + if (pNewData->HasAutoFilter()) { - aOldRange.aEnd.SetRow( aOldRange.aStart.Row() ); - RemoveFlagsTab( aOldRange.aStart.Col(), aOldRange.aStart.Row(), - aOldRange.aEnd.Col(), aOldRange.aEnd.Row(), - aOldRange.aStart.Tab(), SC_MF_AUTO ); - RepaintRange( aOldRange ); + ScRange aNewRange; + pNewData->GetArea(aNewRange); + if (aOldRange.aStart == aNewRange.aStart) + bFound = true; } } } + + if (!bFound) + { + aOldRange.aEnd.SetRow(aOldRange.aStart.Row()); + RemoveFlagsTab( aOldRange.aStart.Col(), aOldRange.aStart.Row(), + aOldRange.aEnd.Col(), aOldRange.aEnd.Row(), + aOldRange.aStart.Tab(), SC_MF_AUTO ); + RepaintRange( aOldRange ); + } } } if (pDBCollection) delete pDBCollection; + pDBCollection = pNewDBCollection; } -ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const +const ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const { if (pDBCollection) return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, bStartOnly); @@ -230,7 +230,23 @@ ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool return NULL; } -ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const +ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) +{ + if (pDBCollection) + return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, bStartOnly); + else + return NULL; +} + +const ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const +{ + if (pDBCollection) + return pDBCollection->GetDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2); + else + return NULL; +} + +ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) { if (pDBCollection) return pDBCollection->GetDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2); @@ -238,12 +254,12 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nC return NULL; } -ScDBData* ScDocument::GetFilterDBAtTable(SCTAB nTab) const +const ScDBData* ScDocument::GetFilterDBAtTable(SCTAB nTab) const { if (pDBCollection) return pDBCollection->GetFilterDBAtTable(nTab); else - return NULL; + return NULL; } ScDPCollection* ScDocument::GetDPCollection() @@ -1298,10 +1314,10 @@ sal_Bool ScDocument::CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR return false; } -sal_Bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab ) +bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab ) { - ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab ); - sal_Bool bHasAutoFilter = ( pDBData != NULL ); + const ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab ); + bool bHasAutoFilter = (pDBData != NULL); if ( pDBData ) { @@ -1474,16 +1490,13 @@ sal_Bool ScDocument::GetFormulaEntries( TypedScStrCollection& rStrings ) if ( pDBCollection ) { - sal_uInt16 nDBCount = pDBCollection->GetCount(); - for ( sal_uInt16 i=0; i<nDBCount; i++ ) + const ScDBCollection::NamedDBs& rDBs = pDBCollection->getNamedDBs(); + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; itr != itrEnd; ++itr) { - ScDBData* pData = (*pDBCollection)[i]; - if (pData) - { - TypedStrData* pNew = new TypedStrData( pData->GetName(), 0.0, SC_STRTYPE_DBNAMES ); - if ( !rStrings.Insert(pNew) ) - delete pNew; - } + TypedStrData* pNew = new TypedStrData(itr->GetName(), 0.0, SC_STRTYPE_DBNAMES); + if ( !rStrings.Insert(pNew) ) + delete pNew; } } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 3e86a758c..9292cb5ea 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -68,7 +68,7 @@ #include "stlsheet.hxx" #include "globstr.hrc" #include "rechead.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "pivot.hxx" #include "chartlis.hxx" #include "rangelst.hxx" @@ -4823,9 +4823,6 @@ sal_Bool ScDocument::ExtendOverlapped( ScRange& rRange ) sal_Bool ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) { - sal_uInt16 nCount = pDBCollection->GetCount(); - sal_uInt16 i; - ScDBData* pData; SCTAB nDBTab; SCCOL nDBStartCol; SCROW nDBStartRow; @@ -4834,22 +4831,25 @@ sal_Bool ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow, // Autofilter loeschen - sal_Bool bChange = RemoveFlagsTab( nStartCol,nStartRow, nEndCol,nEndRow, nTab, SC_MF_AUTO ); + bool bChange = RemoveFlagsTab( nStartCol,nStartRow, nEndCol,nEndRow, nTab, SC_MF_AUTO ); // Autofilter setzen - for (i=0; i<nCount; i++) + const ScDBData* pData = NULL; + ScDBCollection::NamedDBs& rDBs = pDBCollection->getNamedDBs(); + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; itr != itrEnd; ++itr) { - pData = (*pDBCollection)[i]; - if (pData->HasAutoFilter()) + pData = &(*itr); + if (itr->HasAutoFilter()) { - pData->GetArea( nDBTab, nDBStartCol,nDBStartRow, nDBEndCol,nDBEndRow ); + itr->GetArea( nDBTab, nDBStartCol,nDBStartRow, nDBEndCol,nDBEndRow ); if ( nDBTab==nTab && nDBStartRow<=nEndRow && nDBEndRow>=nStartRow && nDBStartCol<=nEndCol && nDBEndCol>=nStartCol ) { if (ApplyFlagsTab( nDBStartCol,nDBStartRow, nDBEndCol,nDBStartRow, nDBTab, SC_MF_AUTO )) - bChange = sal_True; + bChange = true; } } } @@ -4867,7 +4867,7 @@ sal_Bool ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow, { if (ApplyFlagsTab( nDBStartCol,nDBStartRow, nDBEndCol,nDBStartRow, nDBTab, SC_MF_AUTO )) - bChange = sal_True; + bChange = true; } } } diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 9cb01925f..9b37ed61f 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -242,14 +242,13 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const String& rName ) : // set color table SvxColorTableItem* pColItem = (SvxColorTableItem*) pObjSh->GetItem( SID_COLOR_TABLE ); - XColorTable* pXCol = pColItem ? pColItem->GetColorTable() : XColorTable::GetStdColorTable(); + XColorTable* pXCol = pColItem ? pColItem->GetColorTable() : &XColorTable::GetStdColorTable(); SetColorTable( pXCol ); } else - SetColorTable( XColorTable::GetStdColorTable() ); + SetColorTable( &XColorTable::GetStdColorTable() ); SetSwapGraphics(sal_True); -// SetSwapAsynchron(sal_True); // an der View SetScaleUnit(MAP_100TH_MM); SfxItemPool& rPool = GetItemPool(); @@ -552,8 +551,8 @@ namespace Point lcl_calcAvailableDiff(ScDocument &rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const Point &aWantedDiff) { Point aAvailableDiff(aWantedDiff); - long nHeight = rDoc.GetRowHeight( nRow, nTab ) * HMM_PER_TWIPS; - long nWidth = rDoc.GetColWidth( nCol, nTab ) * HMM_PER_TWIPS; + long nHeight = static_cast<long>(rDoc.GetRowHeight( nRow, nTab ) * HMM_PER_TWIPS); + long nWidth = static_cast<long>(rDoc.GetColWidth( nCol, nTab ) * HMM_PER_TWIPS); if (aAvailableDiff.Y() > nHeight) aAvailableDiff.Y() = nHeight; if (aAvailableDiff.X() > nWidth) @@ -565,8 +564,8 @@ namespace { rCalcPoly.setB2DPoint(nWhichPoint, basegfx::B2DPoint(rPos.X(), rPos.Y())); basegfx::B2DRange aRange(basegfx::tools::getRange(rCalcPoly)); - return Rectangle(aRange.getMinX(), aRange.getMinY(), - aRange.getMaxX(), aRange.getMaxY()); + return Rectangle(static_cast<long>(aRange.getMinX()), static_cast<long>(aRange.getMinY()), + static_cast<long>(aRange.getMaxX()), static_cast<long>(aRange.getMaxY())); } } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 779fcb798..6c07d4ef8 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1400,7 +1400,12 @@ void ScTable::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ) void ScTable::UpdateInsertTab(SCTAB nTable) { - if (nTab >= nTable) nTab++; + if (nTab >= nTable) + { + nTab++; + if (pDBDataNoName) + pDBDataNoName->UpdateMoveTab(nTab - 1 ,nTab); + } for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].UpdateInsertTab(nTable); if (IsStreamValid()) @@ -1409,7 +1414,12 @@ void ScTable::UpdateInsertTab(SCTAB nTable) void ScTable::UpdateDeleteTab( SCTAB nTable, sal_Bool bIsMove, ScTable* pRefUndo ) { - if (nTab > nTable) nTab--; + if (nTab > nTable) + { + nTab--; + if (pDBDataNoName) + pDBDataNoName->UpdateMoveTab(nTab + 1,nTab); + } SCCOL i; if (pRefUndo) diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 53b14615b..3e8c2c5ba 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2638,7 +2638,7 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow) bool ScTable::IsDataFiltered() const { bool bAnyQuery = false; - ScDBData* pDBData = pDocument->GetFilterDBAtTable(nTab); + const ScDBData* pDBData = pDocument->GetFilterDBAtTable(nTab); if ( pDBData ) { ScQueryParam aParam; diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index f39fad9fe..4837dc9e0 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -148,7 +148,8 @@ sal_Bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW !( (eCellType == CELLTYPE_FORMULA && ((cMatrixFlag = ((ScFormulaCell*)pCell)->GetMatrixFlag()) == MM_REFERENCE)) // kein UndoDoc => Matrix nicht wiederherstellbar => nicht ersetzen - || (cMatrixFlag != MM_NONE && !pUndoDoc) ) + || (cMatrixFlag != MM_NONE && !pUndoDoc) ) && + IsBlockEditable(nCol, nRow, nCol, nRow) ) { if ( cMatrixFlag == MM_NONE && rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE ) diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index fd6903978..ba65ebfa0 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -55,7 +55,7 @@ #include "rechead.hxx" #include "globstr.hrc" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include <math.h> #include <memory> @@ -681,7 +681,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings, SCSIZE nCol, nRow, nCols, nRows, n = 0; pValues->GetDimensions( nCols, nRows ); - sal_Bool bRef = false; + bool bRef = false; ScRange aRange; ScTokenArray* pArr = (ScTokenArray*) &rTokArr; @@ -691,10 +691,10 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings, { if (t->GetOpCode() == ocDBArea) { - if( ScDBData* pDBData = pDocument->GetDBCollection()->FindIndex( t->GetIndex() ) ) + if (const ScDBData* pDBData = pDocument->GetDBCollection()->getNamedDBs().findByIndex(t->GetIndex())) { pDBData->GetArea(aRange); - bRef = sal_True; + bRef = true; } } else if (t->GetOpCode() == ocName) @@ -702,7 +702,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings, ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() ); if (pName && pName->IsReference(aRange)) { - bRef = sal_True; + bRef = true; } } else if (t->GetType() != svIndex) @@ -710,7 +710,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings, t->CalcAbsIfRel(rPos); if (pArr->IsValidReference(aRange)) { - bRef = sal_True; + bRef = true; } } } diff --git a/sc/source/core/inc/core_pch.hxx b/sc/source/core/inc/core_pch.hxx index 044d995d5..123e3caa7 100644 --- a/sc/source/core/inc/core_pch.hxx +++ b/sc/source/core/inc/core_pch.hxx @@ -122,7 +122,6 @@ #include <vcl/ptrstyle.hxx> #include <tools/wintypes.hxx> #include <vcl/event.hxx> -#include <tools/ownlist.hxx> #include <svl/itempool.hxx> #include <tools/datetime.hxx> #include <attrib.hxx> @@ -196,7 +195,7 @@ #include <rangenam.hxx> #include <scmatrix.hxx> #include <svx/pageitem.hxx> -#include <dbcolect.hxx> +#include <dbdata.hxx> #include <userlist.hxx> #include <editeng/editdata.hxx> #include <basic/sbxvar.hxx> diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 7ebcb9f57..70a20b52f 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -56,7 +56,7 @@ #include <math.h> #include "compiler.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "document.hxx" #include "callform.hxx" #include "addincol.hxx" @@ -2949,21 +2949,18 @@ bool ScCompiler::IsExternalNamedRange( const String& rSymbol ) return true; } -sal_Bool ScCompiler::IsDBRange( const String& rName ) +bool ScCompiler::IsDBRange( const String& rName ) { - sal_uInt16 n; - ScDBCollection* pDBColl = pDoc->GetDBCollection(); - if (pDBColl->SearchName( rName, n ) ) - { - ScDBData* pData = (*pDBColl)[n]; - ScRawToken aToken; - aToken.SetName(true, pData->GetIndex()); // DB range is always global. - aToken.eOp = ocDBArea; - pRawToken = aToken.Clone(); - return sal_True; - } - else + ScDBCollection::NamedDBs& rDBs = pDoc->GetDBCollection()->getNamedDBs(); + const ScDBData* p = rDBs.findByName(rName); + if (!p) return false; + + ScRawToken aToken; + aToken.SetName(true, p->GetIndex()); // DB range is always global. + aToken.eOp = ocDBArea; + pRawToken = aToken.Clone(); + return true; } sal_Bool ScCompiler::IsColRowName( const String& rName ) @@ -4026,7 +4023,7 @@ sal_Bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken) //----------------------------------------------------------------------------- -sal_Bool ScCompiler::HasModifiedRange() +bool ScCompiler::HasModifiedRange() { pArr->Reset(); for ( FormulaToken* t = pArr->Next(); t; t = pArr->Next() ) @@ -4034,17 +4031,15 @@ sal_Bool ScCompiler::HasModifiedRange() OpCode eOpCode = t->GetOpCode(); if ( eOpCode == ocName ) { - ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex(t->GetIndex()); - + ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex(t->GetIndex()); if (pRangeData && pRangeData->IsModified()) - return sal_True; + return true; } else if ( eOpCode == ocDBArea ) { - ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex(t->GetIndex()); - + ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(t->GetIndex()); if (pDBData && pDBData->IsModified()) - return sal_True; + return true; } } return false; @@ -5102,7 +5097,7 @@ void ScCompiler::CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken break; case ocDBArea: { - ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex(_pTokenP->GetIndex()); + ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(_pTokenP->GetIndex()); if (pDBData) aBuffer.append(pDBData->GetName()); } @@ -5395,7 +5390,7 @@ sal_Bool ScCompiler::HandleSingleRef() // ----------------------------------------------------------------------------- sal_Bool ScCompiler::HandleDbData() { - ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex( pToken->GetIndex() ); + ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(pToken->GetIndex()); if ( !pDBData ) SetError(errNoName); else if ( !bCompileForFAP ) diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbdata.cxx index d0bd04755..a1ca196bd 100644 --- a/sc/source/core/tool/dbcolect.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ #include <tools/debug.hxx> #include <unotools/transliterationwrapper.hxx> -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "global.hxx" #include "globalnames.hxx" #include "refupdat.hxx" @@ -45,13 +45,20 @@ #include <memory> +using ::std::auto_ptr; using ::std::unary_function; using ::std::for_each; using ::std::find_if; using ::std::remove_if; +using ::std::pair; //--------------------------------------------------------------------------------------- +bool ScDBData::less::operator() (const ScDBData& left, const ScDBData& right) const +{ + return ScGlobal::GetpTransliteration()->compareString(left.GetName(), right.GetName()) < 0; +} + ScDBData::ScDBData( const ::rtl::OUString& rName, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, @@ -83,7 +90,6 @@ ScDBData::ScDBData( const ::rtl::OUString& rName, } ScDBData::ScDBData( const ScDBData& rData ) : - ScDataObject(), ScRefreshTimer ( rData ), maSortParam (rData.maSortParam), maQueryParam (rData.maQueryParam), @@ -109,14 +115,41 @@ ScDBData::ScDBData( const ScDBData& rData ) : { } +ScDBData::ScDBData( const ::rtl::OUString& rName, const ScDBData& rData ) : + ScRefreshTimer ( rData ), + maSortParam (rData.maSortParam), + maQueryParam (rData.maQueryParam), + maSubTotal (rData.maSubTotal), + maImportParam (rData.maImportParam), + aName (rName), + nTable (rData.nTable), + nStartCol (rData.nStartCol), + nStartRow (rData.nStartRow), + nEndCol (rData.nEndCol), + nEndRow (rData.nEndRow), + bByRow (rData.bByRow), + bHasHeader (rData.bHasHeader), + bDoSize (rData.bDoSize), + bKeepFmt (rData.bKeepFmt), + bStripData (rData.bStripData), + bIsAdvanced (rData.bIsAdvanced), + aAdvSource (rData.aAdvSource), + bDBSelection (rData.bDBSelection), + nIndex (rData.nIndex), + bAutoFilter (rData.bAutoFilter), + bModified (rData.bModified) +{ +} + ScDBData& ScDBData::operator= (const ScDBData& rData) { + // Don't modify the name. The name is not mutable as it is used as a key + // in the container to keep the db ranges sorted by the name. ScRefreshTimer::operator=( rData ); maSortParam = rData.maSortParam; maQueryParam = rData.maQueryParam; maSubTotal = rData.maSubTotal; maImportParam = rData.maImportParam; - aName = rData.aName; nTable = rData.nTable; nStartCol = rData.nStartCol; nStartRow = rData.nStartRow; @@ -423,11 +456,6 @@ bool ScDBData::HasQueryParam() const return maQueryParam.GetEntry(0).bDoQuery; } -ScDataObject* ScDBData::Clone() const -{ - return new ScDBData(*this); -} - void ScDBData::UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos) { ScRange aRange; @@ -512,7 +540,7 @@ void ScDBData::ExtendDataArea(ScDocument* pDoc) namespace { -class FindByTable : public ::std::unary_function<ScDBData, bool> +class FindByTable : public unary_function<ScDBData, bool> { SCTAB mnTab; public: @@ -597,124 +625,342 @@ public: } }; +class FindByIndex : public unary_function<ScDBData, bool> +{ + sal_uInt16 mnIndex; +public: + FindByIndex(sal_uInt16 nIndex) : mnIndex(nIndex) {} + bool operator() (const ScDBData& r) const + { + return r.GetIndex() == mnIndex; + } +}; + +class FindByName : public unary_function<ScDBData, bool> +{ + const ::rtl::OUString& mrName; +public: + FindByName(const ::rtl::OUString& rName) : mrName(rName) {} + bool operator() (const ScDBData& r) const + { + return r.GetName() == mrName; + } +}; + +class FindFilterDBByTable : public unary_function<ScDBData, bool> +{ + SCTAB mnTab; +public: + FindFilterDBByTable(SCTAB nTab) : mnTab(nTab) {} + bool operator() (const ScDBData& r) const + { + if (r.GetTable() != mnTab) + return false; + + return (r.HasAutoFilter() || r.HasQueryParam()); + } +}; + } -ScDBCollection::ScDBCollection(const ScDBCollection& r) : - ScSortedCollection(r), pDoc(r.pDoc), nEntryIndex(r.nEntryIndex), maAnonDBs(r.maAnonDBs) -{} +ScDBCollection::NamedDBs::NamedDBs(ScDBCollection& rParent, ScDocument& rDoc) : + mrParent(rParent), mrDoc(rDoc) {} + +ScDBCollection::NamedDBs::NamedDBs(const NamedDBs& r) : + maDBs(r.maDBs), mrParent(r.mrParent), mrDoc(r.mrDoc) {} -short ScDBCollection::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const +ScDBCollection::NamedDBs::iterator ScDBCollection::NamedDBs::begin() { - const String& rStr1 = ((ScDBData*)pKey1)->GetName(); - const String& rStr2 = ((ScDBData*)pKey2)->GetName(); - return (short) ScGlobal::GetpTransliteration()->compareString( rStr1, rStr2 ); + return maDBs.begin(); } -// IsEqual - alles gleich +ScDBCollection::NamedDBs::iterator ScDBCollection::NamedDBs::end() +{ + return maDBs.end(); +} -sal_Bool ScDBCollection::IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const +ScDBCollection::NamedDBs::const_iterator ScDBCollection::NamedDBs::begin() const { - return *(ScDBData*)pKey1 == *(ScDBData*)pKey2; + return maDBs.begin(); } -ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const +ScDBCollection::NamedDBs::const_iterator ScDBCollection::NamedDBs::end() const { - ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab); - if (pItems) + return maDBs.end(); +} + +ScDBData* ScDBCollection::NamedDBs::findByIndex(sal_uInt16 nIndex) +{ + DBsType::iterator itr = find_if( + maDBs.begin(), maDBs.end(), FindByIndex(nIndex)); + return itr == maDBs.end() ? NULL : &(*itr); +} + +ScDBData* ScDBCollection::NamedDBs::findByName(const ::rtl::OUString& rName) +{ + DBsType::iterator itr = find_if( + maDBs.begin(), maDBs.end(), FindByName(rName)); + return itr == maDBs.end() ? NULL : &(*itr); +} + +bool ScDBCollection::NamedDBs::insert(ScDBData* p) +{ + auto_ptr<ScDBData> pData(p); + if (!pData->GetIndex()) + pData->SetIndex(mrParent.nEntryIndex++); + + pair<DBsType::iterator, bool> r = maDBs.insert(pData); + + if (r.second && p->HasImportParam() && !p->HasImportSelection()) { - for (sal_uInt16 i = 0; i < nCount; i++) - { - if (((ScDBData*)pItems[i])->IsDBAtCursor(nCol, nRow, nTab, bStartOnly)) - { - ScDBData* pDB = (ScDBData*)pItems[i]; - return pDB; //return AnonymousDBData only if nothing else was found - } - } + p->SetRefreshHandler(mrParent.GetRefreshHandler()); + p->SetRefreshControl(mrDoc.GetRefreshTimerControlAddress()); } + return r.second; +} + +void ScDBCollection::NamedDBs::erase(iterator itr) +{ + maDBs.erase(itr); +} + +void ScDBCollection::NamedDBs::erase(const ScDBData& r) +{ + maDBs.erase(r); +} + +bool ScDBCollection::NamedDBs::empty() const +{ + return maDBs.empty(); +} + +size_t ScDBCollection::NamedDBs::size() const +{ + return maDBs.size(); +} + +bool ScDBCollection::NamedDBs::operator== (const NamedDBs& r) const +{ + return maDBs == r.maDBs; +} + +ScDBCollection::AnonDBs::iterator ScDBCollection::AnonDBs::begin() +{ + return maDBs.begin(); +} + +ScDBCollection::AnonDBs::iterator ScDBCollection::AnonDBs::end() +{ + return maDBs.end(); +} + +ScDBCollection::AnonDBs::const_iterator ScDBCollection::AnonDBs::begin() const +{ + return maDBs.begin(); +} + +ScDBCollection::AnonDBs::const_iterator ScDBCollection::AnonDBs::end() const +{ + return maDBs.end(); +} + +const ScDBData* ScDBCollection::AnonDBs::findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const +{ + DBsType::const_iterator itr = find_if( + maDBs.begin(), maDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly)); + return itr == maDBs.end() ? NULL : &(*itr); +} + +const ScDBData* ScDBCollection::AnonDBs::findByRange(const ScRange& rRange) const +{ + DBsType::const_iterator itr = find_if( + maDBs.begin(), maDBs.end(), FindByRange(rRange)); + return itr == maDBs.end() ? NULL : &(*itr); +} + +ScDBData* ScDBCollection::AnonDBs::getByRange(const ScRange& rRange) +{ + const ScDBData* pData = findByRange(rRange); + if (!pData) + { + // Insert a new db data. They all have identical names. + rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME)); + ::std::auto_ptr<ScDBData> pNew(new ScDBData( + aName, rRange.aStart.Tab(), rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row(), true, false)); + pData = pNew.get(); + maDBs.push_back(pNew); + } + return const_cast<ScDBData*>(pData); +} + +void ScDBCollection::AnonDBs::insert(ScDBData* p) +{ + rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME)); + ::std::auto_ptr<ScDBData> pNew(p); + maDBs.push_back(pNew); +} + +void ScDBCollection::AnonDBs::erase(iterator itr) +{ + maDBs.erase(itr); +} + +bool ScDBCollection::AnonDBs::empty() const +{ + return maDBs.empty(); +} + +size_t ScDBCollection::AnonDBs::size() const +{ + return maDBs.size(); +} + +bool ScDBCollection::AnonDBs::operator== (const AnonDBs& r) const +{ + return maDBs == r.maDBs; +} + +ScDBCollection::ScDBCollection(ScDocument* pDocument) : + pDoc(pDocument), nEntryIndex(SC_START_INDEX_DB_COLL), maNamedDBs(*this, *pDocument) {} + +ScDBCollection::ScDBCollection(const ScDBCollection& r) : + pDoc(r.pDoc), nEntryIndex(r.nEntryIndex), maNamedDBs(r.maNamedDBs), maAnonDBs(r.maAnonDBs) {} + +ScDBCollection::NamedDBs& ScDBCollection::getNamedDBs() +{ + return maNamedDBs; +} + +const ScDBCollection::NamedDBs& ScDBCollection::getNamedDBs() const +{ + return maNamedDBs; +} + +ScDBCollection::AnonDBs& ScDBCollection::getAnonDBs() +{ + return maAnonDBs; +} + +const ScDBCollection::AnonDBs& ScDBCollection::getAnonDBs() const +{ + return maAnonDBs; +} + +const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const +{ + // First, search the global named db ranges. + NamedDBs::DBsType::const_iterator itr = find_if( + maNamedDBs.begin(), maNamedDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly)); + if (itr != maNamedDBs.end()) + return &(*itr); + + // Check for the sheet-local anonymous db range. + const ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab); if (pNoNameData) if (pNoNameData->IsDBAtCursor(nCol,nRow,nTab,bStartOnly)) return pNoNameData; - // Check the anonymous db ranges. - const ScDBData* pData = findAnonAtCursor(nCol, nRow, nTab, bStartOnly); + // Check the global anonymous db ranges. + const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, bStartOnly); if (pData) - return const_cast<ScDBData*>(pData); + return pData; return NULL; } -ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const +ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) { + // First, search the global named db ranges. + NamedDBs::DBsType::iterator itr = find_if( + maNamedDBs.begin(), maNamedDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly)); + if (itr != maNamedDBs.end()) + return &(*itr); + + // Check for the sheet-local anonymous db range. ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab); - if (pItems) - { - for (sal_uInt16 i = 0; i < nCount; i++) - if (((ScDBData*)pItems[i])->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2)) - { - ScDBData* pDB = (ScDBData*)pItems[i]; - return pDB; //return AnonymousDBData only if nothing else was found - } - } if (pNoNameData) - if (pNoNameData->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2)) + if (pNoNameData->IsDBAtCursor(nCol,nRow,nTab,bStartOnly)) return pNoNameData; - // Check the anonymous db ranges. - ScRange aRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab); - const ScDBData* pData = findAnonByRange(aRange); + // Check the global anonymous db ranges. + const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, bStartOnly); if (pData) return const_cast<ScDBData*>(pData); return NULL; } -ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const +const ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const { - ScDBData* pDataEmpty = NULL; - if (pItems) - { - for (sal_uInt16 i = 0; i < nCount; i++) - { - ScDBData* pDBTemp = (ScDBData*)pItems[i]; - if ( pDBTemp->GetTable() == nTab ) - { - sal_Bool bFilter = pDBTemp->HasAutoFilter() || pDBTemp->HasQueryParam(); + // First, search the global named db ranges. + ScRange aRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab); + NamedDBs::DBsType::const_iterator itr = find_if( + maNamedDBs.begin(), maNamedDBs.end(), FindByRange(aRange)); + if (itr != maNamedDBs.end()) + return &(*itr); - if ( bFilter ) - return pDBTemp; - } - } - } + // Check for the sheet-local anonymous db range. + ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab); + if (pNoNameData) + if (pNoNameData->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2)) + return pNoNameData; - return pDataEmpty; + // Lastly, check the global anonymous db ranges. + return maAnonDBs.findByRange(aRange); } -sal_Bool ScDBCollection::SearchName( const String& rName, sal_uInt16& rIndex ) const +ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) { - if (rtl::OUString(rName)==rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME))) - DBG_ASSERT(false,"search for noname string"); - ScDBData aDataObj( rName, 0,0,0,0,0 ); - return Search( &aDataObj, rIndex ); + // First, search the global named db ranges. + ScRange aRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab); + NamedDBs::DBsType::iterator itr = find_if( + maNamedDBs.begin(), maNamedDBs.end(), FindByRange(aRange)); + if (itr != maNamedDBs.end()) + return &(*itr); + + // Check for the sheet-local anonymous db range. + ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab); + if (pNoNameData) + if (pNoNameData->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2)) + return pNoNameData; + + // Lastly, check the global anonymous db ranges. + const ScDBData* pData = getAnonDBs().findByRange(aRange); + if (pData) + return const_cast<ScDBData*>(pData); + + return NULL; +} + +const ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const +{ + NamedDBs::DBsType::const_iterator itr = find_if( + maNamedDBs.begin(), maNamedDBs.end(), FindFilterDBByTable(nTab)); + + return itr == maNamedDBs.end() ? NULL : &(*itr); } void ScDBCollection::DeleteOnTab( SCTAB nTab ) { - sal_uInt16 nPos = 0; - while ( nPos < nCount ) + FindByTable func(nTab); + // First, collect the positions of all items that need to be deleted. + ::std::vector<NamedDBs::DBsType::iterator> v; { - // look for output positions on the deleted sheet - - SCCOL nEntryCol1, nEntryCol2; - SCROW nEntryRow1, nEntryRow2; - SCTAB nEntryTab; - static_cast<const ScDBData*>(At(nPos))->GetArea( nEntryTab, nEntryCol1, nEntryRow1, nEntryCol2, nEntryRow2 ); - if ( nEntryTab == nTab ) - AtFree(nPos); - else - ++nPos; + NamedDBs::DBsType::iterator itr = maNamedDBs.begin(), itrEnd = maNamedDBs.end(); + for (; itr != itrEnd; ++itr) + { + if (func(*itr)) + v.push_back(itr); + } } - remove_if(maAnonDBs.begin(), maAnonDBs.end(), FindByTable(nTab)); + // Delete them all. + ::std::vector<NamedDBs::DBsType::iterator>::iterator itr = v.begin(), itrEnd = v.end(); + for (; itr != itrEnd; ++itr) + maNamedDBs.erase(*itr); + + remove_if(maAnonDBs.begin(), maAnonDBs.end(), func); } void ScDBCollection::UpdateReference(UpdateRefMode eUpdateRefMode, @@ -722,12 +968,6 @@ void ScDBCollection::UpdateReference(UpdateRefMode eUpdateRefMode, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) { - for (sal_uInt16 i=0; i<nCount; i++) - { - ((ScDBData*)pItems[i])->UpdateReference( - pDoc, eUpdateRefMode, - nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz); - } ScDBData* pData = pDoc->GetAnonymousDBData(nTab1); if (pData) { @@ -744,71 +984,38 @@ void ScDBCollection::UpdateReference(UpdateRefMode eUpdateRefMode, } UpdateRefFunc func(pDoc, eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz); + for_each(maNamedDBs.begin(), maNamedDBs.end(), func); for_each(maAnonDBs.begin(), maAnonDBs.end(), func); } void ScDBCollection::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) { - // wenn nOldPos vor nNewPos liegt, ist nNewPos schon angepasst - - for (sal_uInt16 i=0; i<nCount; i++) - { - ScDBData* pData = (ScDBData*)pItems[i]; - pData->UpdateMoveTab(nOldPos, nNewPos); - } - UpdateMoveTabFunc func(nOldPos, nNewPos); + for_each(maNamedDBs.begin(), maNamedDBs.end(), func); for_each(maAnonDBs.begin(), maAnonDBs.end(), func); } - -ScDBData* ScDBCollection::FindIndex(sal_uInt16 nIndex) -{ - sal_uInt16 i = 0; - while (i < nCount) - { - if ((*this)[i]->GetIndex() == nIndex) - return (*this)[i]; - i++; - } - return NULL; -} - -sal_Bool ScDBCollection::Insert(ScDataObject* pScDataObject) -{ - ScDBData* pData = (ScDBData*) pScDataObject; - if (!pData->GetIndex()) // schon gesetzt? - pData->SetIndex(nEntryIndex++); - sal_Bool bInserted = ScSortedCollection::Insert(pScDataObject); - if ( bInserted && pData->HasImportParam() && !pData->HasImportSelection() ) - { - pData->SetRefreshHandler( GetRefreshHandler() ); - pData->SetRefreshControl( pDoc->GetRefreshTimerControlAddress() ); - } - return bInserted; -} - ScDBData* ScDBCollection::GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab ) { ScDBData* pNearData = NULL; - SCTAB nAreaTab; - SCCOL nStartCol, nEndCol; - SCROW nStartRow, nEndRow; - for (sal_uInt16 i = 0; i < nCount; i++) + NamedDBs::DBsType::iterator itr = maNamedDBs.begin(), itrEnd = maNamedDBs.end(); + for (; itr != itrEnd; ++itr) { - ScDBData* pDB = (ScDBData*)pItems[i]; - pDB->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow ); + SCTAB nAreaTab; + SCCOL nStartCol, nEndCol; + SCROW nStartRow, nEndRow; + itr->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow ); if ( nTab == nAreaTab && nCol+1 >= nStartCol && nCol <= nEndCol+1 && nRow+1 >= nStartRow && nRow <= nEndRow+1 ) { if ( nCol < nStartCol || nCol > nEndCol || nRow < nStartRow || nRow > nEndRow ) { if (!pNearData) - pNearData = pDB; // ersten angrenzenden Bereich merken + pNearData = &(*itr); // ersten angrenzenden Bereich merken } else - return pDB; // nicht "unbenannt" und Cursor steht wirklich drin + return &(*itr); // nicht "unbenannt" und Cursor steht wirklich drin } } if (pNearData) @@ -816,46 +1023,15 @@ ScDBData* ScDBCollection::GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab ) return pDoc->GetAnonymousDBData(nTab); // "unbenannt" nur zurueck, wenn sonst nichts gefunden } -const ScDBData* ScDBCollection::findAnonAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const +bool ScDBCollection::empty() const { - AnonDBsType::const_iterator itr = find_if( - maAnonDBs.begin(), maAnonDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly)); - return itr == maAnonDBs.end() ? NULL : &(*itr); + return maNamedDBs.empty() && maAnonDBs.empty(); } -const ScDBData* ScDBCollection::findAnonByRange(const ScRange& rRange) const +bool ScDBCollection::operator== (const ScDBCollection& r) const { - AnonDBsType::const_iterator itr = find_if( - maAnonDBs.begin(), maAnonDBs.end(), FindByRange(rRange)); - return itr == maAnonDBs.end() ? NULL : &(*itr); -} - -ScDBData* ScDBCollection::getAnonByRange(const ScRange& rRange) -{ - const ScDBData* pData = findAnonByRange(rRange); - if (!pData) - { - // Insert a new db data. They all have identical names. - rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME)); - ::std::auto_ptr<ScDBData> pNew(new ScDBData( - aName, rRange.aStart.Tab(), rRange.aStart.Col(), rRange.aStart.Row(), - rRange.aEnd.Col(), rRange.aEnd.Row(), true, false)); - pData = pNew.get(); - maAnonDBs.push_back(pNew); - } - return const_cast<ScDBData*>(pData); -} - -void ScDBCollection::insertAnonRange(ScDBData* pData) -{ - rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME)); - ::std::auto_ptr<ScDBData> pNew(pData); - maAnonDBs.push_back(pNew); -} - -const ScDBCollection::AnonDBsType& ScDBCollection::getAnonRanges() const -{ - return maAnonDBs; + return maNamedDBs == r.maNamedDBs && maAnonDBs == r.maAnonDBs && + nEntryIndex == r.nEntryIndex && pDoc == r.pDoc && aRefreshHandler == r.aRefreshHandler; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index bfe5b6b63..c7fb264db 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -55,7 +55,7 @@ #include "interpre.hxx" #include "global.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "cell.hxx" #include "callform.hxx" #include "addincol.hxx" @@ -3493,8 +3493,7 @@ void ScInterpreter::ScTableOp() void ScInterpreter::ScDBArea() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScDBArea" ); - ScDBData* pDBData = pDok->GetDBCollection()->FindIndex( pCur->GetIndex()); + ScDBData* pDBData = pDok->GetDBCollection()->getNamedDBs().findByIndex(pCur->GetIndex()); if (pDBData) { ScComplexRefData aRefData; diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index 72bd8d644..e80031f26 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -38,7 +38,7 @@ #include "rangeutl.hxx" #include "document.hxx" #include "global.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "rangenam.hxx" #include "scresid.hxx" #include "globstr.hrc" @@ -325,16 +325,12 @@ sal_Bool ScRangeUtil::MakeRangeFromName ( } else if( eScope==RUTL_DBASE ) { - ScDBCollection& rDbNames = *(pDoc->GetDBCollection()); - sal_uInt16 nAt = 0; - - if ( rDbNames.SearchName( rName, nAt ) ) + ScDBCollection::NamedDBs& rDbNames = pDoc->GetDBCollection()->getNamedDBs(); + ScDBData* pData = rDbNames.findByName(rName); + if (pData) { - ScDBData* pData = rDbNames[nAt]; - - pData->GetArea( nTab, nColStart, nRowStart, - nColEnd, nRowEnd ); - bResult = sal_True; + pData->GetArea(nTab, nColStart, nRowStart, nColEnd, nRowEnd); + bResult = true; } } else @@ -504,9 +500,10 @@ sal_Bool ScRangeStringConverter::GetRangeFromString( if ( aUIString.GetChar(0) == (sal_Unicode) '.' ) aUIString.Erase( 0, 1 ); bResult = ((rRange.aStart.Parse( aUIString, const_cast<ScDocument*> (pDocument), eConv) & SCA_VALID) == SCA_VALID); - if (!bResult && eConv != eConv) + ::formula::FormulaGrammar::AddressConvention eConvUI = pDocument->GetAddressConvention(); + if (!bResult && eConv != eConvUI) bResult = ((rRange.aStart.Parse( - aUIString, const_cast<ScDocument*>(pDocument), eConv) & SCA_VALID) == SCA_VALID); + aUIString, const_cast<ScDocument*>(pDocument), eConvUI) & SCA_VALID) == SCA_VALID); rRange.aEnd = rRange.aStart; } else @@ -531,12 +528,14 @@ sal_Bool ScRangeStringConverter::GetRangeFromString( eConv) & SCA_VALID) == SCA_VALID) && ((rRange.aEnd.Parse( aUIString.Copy((xub_StrLen)nIndex+1), const_cast<ScDocument*>(pDocument), eConv) & SCA_VALID) == SCA_VALID); - if (!bResult && eConv != eConv) + + ::formula::FormulaGrammar::AddressConvention eConvUI = pDocument->GetAddressConvention(); + if (!bResult && eConv != eConvUI) { bResult = ((rRange.aStart.Parse( aUIString.Copy(0, (xub_StrLen)nIndex), const_cast<ScDocument*>(pDocument), - eConv) & SCA_VALID) == SCA_VALID) && + eConvUI) & SCA_VALID) == SCA_VALID) && ((rRange.aEnd.Parse( aUIString.Copy((xub_StrLen)nIndex+1), const_cast<ScDocument*>(pDocument), - eConv) & SCA_VALID) == SCA_VALID); + eConvUI) & SCA_VALID) == SCA_VALID); } } } @@ -558,12 +557,19 @@ sal_Bool ScRangeStringConverter::GetRangeListFromString( while( nOffset >= 0 ) { ScRange* pRange = new ScRange; - if ( GetRangeFromString( *pRange, rRangeListStr, pDocument, eConv, nOffset, cSeperator, cQuote ) - && (nOffset >= 0) + if ( + GetRangeFromString( *pRange, rRangeListStr, pDocument, eConv, nOffset, cSeperator, cQuote ) && + (nOffset >= 0) ) + { rRangeList.push_back( pRange ); + pRange = NULL; + } else if (nOffset > -1) bRet = false; + //if ownership transferred to rRangeList pRange was NULLed, otherwwise + //delete it + delete pRange; } return bRet; } @@ -1039,8 +1045,7 @@ sal_Bool ScArea::operator==( const ScArea& r ) const ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) : pRangeName(pDoc->GetRangeName()), pDBCollection(pDoc->GetDBCollection()), - bFirstPass(true), - nPos(0) + bFirstPass(true) { if (pRangeName) { @@ -1049,7 +1054,7 @@ ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) : } } -sal_Bool ScAreaNameIterator::Next( String& rName, ScRange& rRange ) +bool ScAreaNameIterator::Next( String& rName, ScRange& rRange ) { for (;;) { @@ -1069,18 +1074,23 @@ sal_Bool ScAreaNameIterator::Next( String& rName, ScRange& rRange ) else { bFirstPass = false; - nPos = 0; + if (pDBCollection) + { + const ScDBCollection::NamedDBs& rDBs = pDBCollection->getNamedDBs(); + maDBPos = rDBs.begin(); + maDBEnd = rDBs.end(); + } } } if ( !bFirstPass ) // dann DB-Bereiche { - if ( pDBCollection && nPos < pDBCollection->GetCount() ) + if (pDBCollection && maDBPos != maDBEnd) { - ScDBData* pData = (*pDBCollection)[nPos++]; - pData->GetArea( rRange ); - rName = pData->GetName(); - return sal_True; // gefunden + const ScDBData& rData = *maDBPos; + rData.GetArea(rRange); + rName = rData.GetName(); + return true; // gefunden } else return false; // gibt nichts mehr diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 40ff8a48f..8d6d49f07 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -51,7 +51,7 @@ #include "dociter.hxx" #include "document.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "global.hxx" #include "globstr.hrc" #include "progress.hxx" diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index 6389342e4..223dd7bfa 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -83,7 +83,7 @@ #include "docpool.hxx" #include "attrib.hxx" #include "conditio.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "globalnames.hxx" #include "editutil.hxx" #include "markdata.hxx" diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 619d48ae4..60b0ca71d 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -82,7 +82,7 @@ #include "progress.hxx" #include "dociter.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "stlsheet.hxx" #include "stlpool.hxx" #include "editutil.hxx" diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index b80d4c90a..e0faf0ea0 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -196,8 +196,8 @@ static void lcl_GetFromTo( const XclExpRoot& rRoot, const Rectangle &aRect, sal_ } if( r.Left() > aRect.Left() && r.Top() > aRect.Top() ) { - aFrom = Rectangle( nCol-1, HMM2XL( nColOff ), - nRow-1, HMM2XL( nRowOff ) ); + aFrom = Rectangle( nCol-1, static_cast<long>(HMM2XL( nColOff )), + nRow-1, static_cast<long>(HMM2XL( nRowOff )) ); bTo=true; } } @@ -209,8 +209,8 @@ static void lcl_GetFromTo( const XclExpRoot& rRoot, const Rectangle &aRect, sal_ nRow++; if( r.Right() >= aRect.Right() && r.Bottom() >= aRect.Bottom() ) { - aTo = Rectangle( nCol, HMM2XL( aRect.Right() - r.Left() ), - nRow, HMM2XL( aRect.Bottom() - r.Top() )); + aTo = Rectangle( nCol, static_cast<long>(HMM2XL( aRect.Right() - r.Left() )), + nRow, static_cast<long>(HMM2XL( aRect.Bottom() - r.Top() ))); break; } } diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx index 55a4ea8d6..432390af7 100644 --- a/sc/source/filter/excel/xename.cxx +++ b/sc/source/filter/excel/xename.cxx @@ -35,7 +35,7 @@ #include "globstr.hrc" #include "document.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "xehelper.hxx" #include "xelink.hxx" #include "globalnames.hxx" diff --git a/sc/source/filter/excel/xepage.cxx b/sc/source/filter/excel/xepage.cxx index 47899eb15..5ac8493a0 100644 --- a/sc/source/filter/excel/xepage.cxx +++ b/sc/source/filter/excel/xepage.cxx @@ -330,6 +330,14 @@ XclExpPageSettings::XclExpPageSettings( const XclExpRoot& rRoot ) : maData.maHorPageBreaks.push_back(nRow); } + if (maData.maHorPageBreaks.size() > 1026) + { + // Excel allows only up to 1026 page breaks. Trim any excess page breaks. + ScfUInt16Vec::iterator itr = maData.maHorPageBreaks.begin(); + ::std::advance(itr, 1026); + maData.maHorPageBreaks.erase(itr, maData.maHorPageBreaks.end()); + } + set<SCCOL> aColBreaks; rDoc.GetAllColBreaks(aColBreaks, nScTab, false, true); for (set<SCCOL>::const_iterator itr = aColBreaks.begin(), itrEnd = aColBreaks.end(); itr != itrEnd; ++itr) diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index eed8a4a15..672f2a2cc 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -257,12 +257,12 @@ ScHTMLExport::ScHTMLExport( SvStream& rStrmP, const String& rBaseURL, ScDocument sIndent[0] = 0; // set HTML configuration - SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get(); - eDestEnc = (pDoc->IsClipOrUndo() ? RTL_TEXTENCODING_UTF8 : pHtmlOptions->GetTextEncoding()); - bCopyLocalFileToINet = pHtmlOptions->IsSaveGraphicsLocal(); + SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get(); + eDestEnc = (pDoc->IsClipOrUndo() ? RTL_TEXTENCODING_UTF8 : rHtmlOptions.GetTextEncoding()); + bCopyLocalFileToINet = rHtmlOptions.IsSaveGraphicsLocal(); for ( sal_uInt16 j=0; j < SC_HTML_FONTSIZES; j++ ) { - sal_uInt16 nSize = pHtmlOptions->GetFontSize( j ); + sal_uInt16 nSize = rHtmlOptions.GetFontSize( j ); // remember in Twips, like our SvxFontHeightItem if ( nSize ) nFontSize[j] = nSize * 20; diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 7af88be0b..0c3531af7 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -82,9 +82,9 @@ ScHTMLParser::ScHTMLParser( EditEngine* pEditEngine, ScDocument* pDoc ) : ScEEParser( pEditEngine ), mpDoc( pDoc ) { - SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get(); + SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get(); for( sal_uInt16 nIndex = 0; nIndex < SC_HTML_FONTSIZES; ++nIndex ) - maFontHeights[ nIndex ] = pHtmlOptions->GetFontSize( nIndex ) * 20; + maFontHeights[ nIndex ] = rHtmlOptions.GetFontSize( nIndex ) * 20; } ScHTMLParser::~ScHTMLParser() @@ -1285,9 +1285,9 @@ void ScHTMLLayoutParser::Image( ImportInfo* pInfo ) sal_uInt16 nFormat; Graphic* pGraphic = new Graphic; - GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter(); + GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); if ( GRFILTER_OK != GraphicFilter::LoadGraphic( pImage->aURL, pImage->aFilterName, - *pGraphic, pFilter, &nFormat ) ) + *pGraphic, &rFilter, &nFormat ) ) { delete pGraphic; return ; // dumm gelaufen @@ -1297,7 +1297,7 @@ void ScHTMLLayoutParser::Image( ImportInfo* pInfo ) pActEntry->bHasGraphic = sal_True; pActEntry->aAltText.Erase(); } - pImage->aFilterName = pFilter->GetImportFormatName( nFormat ); + pImage->aFilterName = rFilter.GetImportFormatName( nFormat ); pImage->pGraphic = pGraphic; if ( !(pImage->aSize.Width() && pImage->aSize.Height()) ) { diff --git a/sc/source/filter/inc/filt_pch.hxx b/sc/source/filter/inc/filt_pch.hxx index 12207bd81..7ff38bcb4 100644 --- a/sc/source/filter/inc/filt_pch.hxx +++ b/sc/source/filter/inc/filt_pch.hxx @@ -177,7 +177,6 @@ #include <tools/wintypes.hxx> #include <vcl/inputctx.hxx> #include <vcl/event.hxx> -#include <tools/ownlist.hxx> #include <vcl/cmdevt.hxx> #include <vcl/vclenum.hxx> #include <cell.hxx> diff --git a/sc/source/filter/rtf/rtfparse.cxx b/sc/source/filter/rtf/rtfparse.cxx index 44d0498f0..beeb47932 100644 --- a/sc/source/filter/rtf/rtfparse.cxx +++ b/sc/source/filter/rtf/rtfparse.cxx @@ -239,15 +239,21 @@ void ScRTFParser::NewCellRow( ImportInfo* /*pInfo*/ ) ScRTFCellDefault* pD; bNewDef = false; // rechts nicht buendig? => neue Tabelle - if ( nLastWidth - && ( (pD = &(pDefaultList->back())) != 0 ) - && pD->nTwips != nLastWidth - ) + if ( nLastWidth && !pDefaultList->empty() ) { - SCCOL n1, n2; - if ( !( SeekTwips( nLastWidth, &n1 ) - && SeekTwips( pD->nTwips, &n2 ) && n1 == n2) ) - ColAdjust(); + pD = &(pDefaultList->back()); + if (pD->nTwips != nLastWidth ) + { + SCCOL n1, n2; + if ( !( SeekTwips( nLastWidth, &n1 ) + && SeekTwips( pD->nTwips, &n2 ) + && n1 == n2 + ) + ) + { + ColAdjust(); + } + } } // TwipCols aufbauen, erst nach nLastWidth Vergleich! for ( size_t i = 0, nListSize = pDefaultList->size(); i < nListSize; ++i ) @@ -299,7 +305,7 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo ) { case RTF_TROWD: // denotes table row defauls, before RTF_CELLX { - if ( (pD = &(pDefaultList->back())) != 0 ) + if ( !pDefaultList->empty() && (pD = &(pDefaultList->back())) != 0 ) nLastWidth = pD->nTwips; nColCnt = 0; pDefaultList->clear(); diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx index e01e3bd11..dfdbb585d 100644 --- a/sc/source/filter/starcalc/scflt.cxx +++ b/sc/source/filter/starcalc/scflt.cxx @@ -65,7 +65,7 @@ #include "document.hxx" #include "collect.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "stlsheet.hxx" #include "stlpool.hxx" #include "filter.hxx" @@ -1370,7 +1370,7 @@ void Sc10Import::LoadDataBaseCollection() ( SCROW ) pOldData->DataBaseRec.Block.y2, sal_True, ( sal_Bool) pOldData->DataBaseRec.RowHeader ); - pDoc->GetDBCollection()->Insert( pNewData ); + pDoc->GetDBCollection()->getNamedDBs().insert(pNewData); } } diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx index 2b5ae66ff..86084a698 100644 --- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx +++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx @@ -41,7 +41,7 @@ #include "XMLExportIterator.hxx" #include "XMLConverter.hxx" #include "unonames.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "document.hxx" #include "globstr.hrc" #include "globalnames.hxx" @@ -304,9 +304,7 @@ void ScXMLExportDatabaseRanges::WriteFilterDescriptor(const uno::Reference <shee } } ScDBCollection* pDBCollection = pDoc->GetDBCollection(); - sal_uInt16 nIndex; - pDBCollection->SearchName(sDatabaseRangeName, nIndex); - ScDBData* pDBData = (*pDBCollection)[nIndex]; + ScDBData* pDBData = pDBCollection->getNamedDBs().findByName(sDatabaseRangeName); ScRange aAdvSource; if (pDBData->GetAdvancedQuerySource(aAdvSource)) { @@ -531,9 +529,7 @@ void ScXMLExportDatabaseRanges::WriteSubTotalDescriptor(const com::sun::star::un rExport.CheckAttrList(); { ScDBCollection* pDBCollection = pDoc->GetDBCollection(); - sal_uInt16 nIndex; - pDBCollection->SearchName(sDatabaseRangeName, nIndex); - ScDBData* pDBData = (*pDBCollection)[nIndex]; + ScDBData* pDBData = pDBCollection->getNamedDBs().findByName(sDatabaseRangeName); ScSubTotalParam aSubTotalParam; pDBData->GetSubTotalParam(aSubTotalParam); if (aSubTotalParam.bDoSort) @@ -580,12 +576,25 @@ namespace { class WriteDatabaseRange : public ::std::unary_function<ScDBData, void> { + ScXMLExport& mrExport; + ScDocument* mpDoc; + sal_Int32 mnCounter; + ScDBCollection::RangeType meRangeType; public: + WriteDatabaseRange(ScXMLExport& rExport, ScDocument* pDoc) : - mrExport(rExport), mpDoc(pDoc), mnCounter(0) {} + mrExport(rExport), mpDoc(pDoc), mnCounter(0), meRangeType(ScDBCollection::GlobalNamed) {} + + void setRangeType(ScDBCollection::RangeType eNew) + { + meRangeType = eNew; + } void operator() (const ::std::pair<SCTAB, const ScDBData*>& r) { + if (meRangeType != ScDBCollection::SheetAnonymous) + return; + // name OUStringBuffer aBuf; aBuf.appendAscii(STR_DB_LOCAL_NONAME); @@ -596,12 +605,17 @@ public: void operator() (const ScDBData& rData) { - // name - OUStringBuffer aBuf; - aBuf.appendAscii(STR_DB_GLOBAL_NONAME); - aBuf.append(++mnCounter); // 1-based, for entirely arbitrary reasons. The numbers are ignored on import. + if (meRangeType == ScDBCollection::GlobalAnonymous) + { + // name + OUStringBuffer aBuf; + aBuf.appendAscii(STR_DB_GLOBAL_NONAME); + aBuf.append(++mnCounter); // 1-based, for entirely arbitrary reasons. The numbers are ignored on import. - write(aBuf.makeStringAndClear(), rData); + write(aBuf.makeStringAndClear(), rData); + } + else if (meRangeType == ScDBCollection::GlobalNamed) + write(rData.GetName(), rData); } private: @@ -1079,145 +1093,62 @@ private: } } } - -private: - ScXMLExport& mrExport; - ScDocument* mpDoc; - sal_Int32 mnCounter; }; } -void ScXMLExportDatabaseRanges::WriteDatabaseRanges(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc) +void ScXMLExportDatabaseRanges::WriteDatabaseRanges() { typedef ::std::map<SCTAB, const ScDBData*> SheetLocalDBs; pDoc = rExport.GetDocument(); - if (pDoc) + if (!pDoc) + return; + + // Get sheet-local anonymous ranges. + SCTAB nTabCount = pDoc->GetTableCount(); + SheetLocalDBs aSheetDBs; + for (SCTAB i = 0; i < nTabCount; ++i) { - // Get sheet-local anonymous ranges. - SCTAB nTabCount = pDoc->GetTableCount(); - SheetLocalDBs aSheetDBs; - for (SCTAB i = 0; i < nTabCount; ++i) - { - const ScDBData* p = pDoc->GetAnonymousDBData(i); - if (p) - aSheetDBs.insert(SheetLocalDBs::value_type(i, p)); - } + const ScDBData* p = pDoc->GetAnonymousDBData(i); + if (p) + aSheetDBs.insert(SheetLocalDBs::value_type(i, p)); + } - bool bHasRanges = !aSheetDBs.empty(); + bool bHasRanges = !aSheetDBs.empty(); - // See if we have global ranges. - ScDBCollection* pDBCollection = pDoc->GetDBCollection(); - if (pDBCollection) - if (pDBCollection->GetCount() > 0 || !pDBCollection->getAnonRanges().empty()) - bHasRanges = true; + // See if we have global ranges. + ScDBCollection* pDBCollection = pDoc->GetDBCollection(); + if (pDBCollection) + { + if (!pDBCollection->getNamedDBs().empty() || !pDBCollection->getAnonDBs().empty()) + bHasRanges = true; + } - if (!bHasRanges) - // No ranges to export. Bail out. - return; + if (!bHasRanges) + // No ranges to export. Bail out. + return; - SvXMLElementExport aElemDRs(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, sal_True, sal_True); - uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY); - if (xPropertySet.is()) - { - uno::Reference <sheet::XDatabaseRanges> xDatabaseRanges(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DATABASERNG))), uno::UNO_QUERY); - rExport.CheckAttrList(); - if (xDatabaseRanges.is()) - { - uno::Sequence <rtl::OUString> aRanges(xDatabaseRanges->getElementNames()); - sal_Int32 nDatabaseRangesCount = aRanges.getLength(); - if (nDatabaseRangesCount > 0) - { - for (sal_Int32 i = 0; i < nDatabaseRangesCount; ++i) - { - rtl::OUString sDatabaseRangeName(aRanges[i]); - uno::Reference <sheet::XDatabaseRange> xDatabaseRange(xDatabaseRanges->getByName(sDatabaseRangeName), uno::UNO_QUERY); - if (xDatabaseRange.is()) - { - rtl::OUString sOUUnbenannt (ScGlobal::GetRscString(STR_DB_NONAME)); - if (sOUUnbenannt != sDatabaseRangeName) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, sDatabaseRangeName); - table::CellRangeAddress aRangeAddress(xDatabaseRange->getDataArea()); - rtl::OUString sOUAddress; - ScRangeStringConverter::GetStringFromRange( sOUAddress, aRangeAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO ); - rExport.AddAttribute (XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sOUAddress); - sal_uInt16 nIndex; - pDBCollection->SearchName(sDatabaseRangeName, nIndex); - ScDBData* pDBData = (*pDBCollection)[nIndex]; - if (pDBData->HasImportSelection()) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IS_SELECTION, XML_TRUE); - if (pDBData->HasAutoFilter()) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_FILTER_BUTTONS, XML_TRUE); - uno::Reference <beans::XPropertySet> xPropertySetDatabaseRange (xDatabaseRange, uno::UNO_QUERY); - if (xPropertySetDatabaseRange.is()) - { - if (::cppu::any2bool(xPropertySetDatabaseRange->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_KEEPFORM))))) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_STYLES, XML_TRUE); - if (::cppu::any2bool(xPropertySetDatabaseRange->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_MOVCELLS))))) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_SIZE, XML_FALSE); - if (::cppu::any2bool(xPropertySetDatabaseRange->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT))))) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_HAS_PERSISTENT_DATA, XML_FALSE); - } - - uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor( - xDatabaseRange->getFilterDescriptor(), uno::UNO_QUERY ); - uno::Sequence <beans::PropertyValue> aSortProperties(xDatabaseRange->getSortDescriptor()); - if (xSheetFilterDescriptor.is()) - { - uno::Reference <beans::XPropertySet> xFilterProperties (xSheetFilterDescriptor, uno::UNO_QUERY); - if (xFilterProperties.is()) - { - if (!::cppu::any2bool(xFilterProperties->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONTHDR))))) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONTAINS_HEADER, XML_FALSE); - - sal_Bool bSortColumns(sal_True); - sal_Bool bFound(false); - sal_Int32 nProperty(0); - while (!bFound && (nProperty < aSortProperties.getLength())) - { - if (aSortProperties[nProperty].Name.compareToAscii(SC_UNONAME_ISSORTCOLUMNS) == 0) - { - bSortColumns = ::cppu::any2bool(aSortProperties[nProperty].Value); - bFound = sal_True; - } - else - ++nProperty; - } - - if (bSortColumns) - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_COLUMN); - } - } - sal_Int32 nRefresh( pDBData->GetRefreshDelay() ); - if( nRefresh ) - { - rtl::OUStringBuffer sBuffer; - SvXMLUnitConverter::convertTime( sBuffer, (double)nRefresh / 86400 ); - rExport.AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sBuffer.makeStringAndClear() ); - } - SvXMLElementExport aElemDR(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, sal_True, sal_True); - rExport.CheckAttrList(); - WriteImportDescriptor(xDatabaseRange->getImportDescriptor()); - if (xSheetFilterDescriptor.is()) - WriteFilterDescriptor(xSheetFilterDescriptor, sDatabaseRangeName); - WriteSortDescriptor(aSortProperties); - WriteSubTotalDescriptor(xDatabaseRange->getSubTotalDescriptor(), sDatabaseRangeName); - } - } - } - } - } + SvXMLElementExport aElemDRs(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, sal_True, sal_True); - WriteDatabaseRange func(rExport, pDoc); + WriteDatabaseRange func(rExport, pDoc); - // Write sheet-local ranges. - ::std::for_each(aSheetDBs.begin(), aSheetDBs.end(), func); + if (pDBCollection) + { + // Write global named ranges. + func.setRangeType(ScDBCollection::GlobalNamed); + const ScDBCollection::NamedDBs& rNamedDBs = pDBCollection->getNamedDBs(); + ::std::for_each(rNamedDBs.begin(), rNamedDBs.end(), func); // Add global anonymous DB ranges. - const ScDBCollection::AnonDBsType& rAnonDBs = pDBCollection->getAnonRanges(); + func.setRangeType(ScDBCollection::GlobalAnonymous); + const ScDBCollection::AnonDBs& rAnonDBs = pDBCollection->getAnonDBs(); ::std::for_each(rAnonDBs.begin(), rAnonDBs.end(), func); } + + // Write sheet-local ranges. + func.setRangeType(ScDBCollection::SheetAnonymous); + ::std::for_each(aSheetDBs.begin(), aSheetDBs.end(), func); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx index e4d7813e8..bb726ddc3 100644 --- a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx +++ b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx @@ -56,7 +56,7 @@ public: ScXMLExportDatabaseRanges(ScXMLExport& rExport); ~ScXMLExportDatabaseRanges(); ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges(); - void WriteDatabaseRanges(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc); + void WriteDatabaseRanges(); }; #endif diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx index 7e91218ee..c7a26d76b 100644 --- a/sc/source/filter/xml/xmldrani.cxx +++ b/sc/source/filter/xml/xmldrani.cxx @@ -41,7 +41,7 @@ #include "globstr.hrc" #include "globalnames.hxx" #include "docuno.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "datauno.hxx" #include "attrib.hxx" #include "unonames.hxx" @@ -151,7 +151,7 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport, bFilterSkipDuplicates(false), bFilterUseRegularExpressions(false), bFilterConditionSourceRange(false), - meRangeType(GlobalNamed) + meRangeType(ScDBCollection::GlobalNamed) { nSourceType = sheet::DataImportMode_NONE; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; @@ -223,9 +223,9 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport, } if (sDatabaseRangeName.matchAsciiL(STR_DB_LOCAL_NONAME, strlen(STR_DB_LOCAL_NONAME))) - meRangeType = SheetAnonymous; + meRangeType = ScDBCollection::SheetAnonymous; else if (sDatabaseRangeName.matchAsciiL(STR_DB_GLOBAL_NONAME, strlen(STR_DB_GLOBAL_NONAME))) - meRangeType = GlobalAnonymous; + meRangeType = ScDBCollection::GlobalAnonymous; } ScXMLDatabaseRangeContext::~ScXMLDatabaseRangeContext() @@ -453,13 +453,30 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName) return pData.release(); } +namespace { + +void setAutoFilterFlags(ScDocument& rDoc, const ScDBData& rData) +{ + if (!rData.HasAutoFilter()) + return; + + // Set autofilter flags so that the buttons get displayed. + ScRange aRange; + rData.GetArea(aRange); + rDoc.ApplyFlagsTab( + aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(), + aRange.aStart.Tab(), SC_MF_AUTO); +} + +} + void ScXMLDatabaseRangeContext::EndElement() { ScDocument* pDoc = GetScImport().GetDocument(); if (!pDoc) return; - if (meRangeType == SheetAnonymous) + if (meRangeType == ScDBCollection::SheetAnonymous) { OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)); ::std::auto_ptr<ScDBData> pData(ConvertToDBData(aName)); @@ -469,204 +486,31 @@ void ScXMLDatabaseRangeContext::EndElement() // Infer sheet index from the name. OUString aStrNum = sDatabaseRangeName.copy(aName.getLength()); SCTAB nTab = static_cast<SCTAB>(aStrNum.toInt32()); - - if (pData->HasAutoFilter()) - { - // Set autofilter flags so that the buttons get displayed. - ScRange aRange; - pData->GetArea(aRange); - pDoc->ApplyFlagsTab( - aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(), - aRange.aStart.Tab(), SC_MF_AUTO); - } - + setAutoFilterFlags(*pDoc, *pData); pDoc->SetAnonymousDBData(nTab, pData.release()); } return; } - else if (meRangeType == GlobalAnonymous) + else if (meRangeType == ScDBCollection::GlobalAnonymous) { OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME)); ::std::auto_ptr<ScDBData> pData(ConvertToDBData(aName)); if (pData.get()) { - if (pData->HasAutoFilter()) - { - // Set autofilter flags so that the buttons get displayed. - ScRange aRange; - pData->GetArea(aRange); - pDoc->ApplyFlagsTab( - aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(), - aRange.aStart.Tab(), SC_MF_AUTO); - } - - pDoc->GetDBCollection()->insertAnonRange(pData.release()); + setAutoFilterFlags(*pDoc, *pData); + pDoc->GetDBCollection()->getAnonDBs().insert(pData.release()); } return; } - - if (GetScImport().GetModel().is()) + else if (meRangeType == ScDBCollection::GlobalNamed) { - uno::Reference <beans::XPropertySet> xPropertySet( GetScImport().GetModel(), uno::UNO_QUERY ); - if (xPropertySet.is()) + ::std::auto_ptr<ScDBData> pData(ConvertToDBData(sDatabaseRangeName)); + + if (pData.get()) { - uno::Reference <sheet::XDatabaseRanges> xDatabaseRanges(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DATABASERNG))), uno::UNO_QUERY); - if (xDatabaseRanges.is()) - { - table::CellRangeAddress aCellRangeAddress; - sal_Int32 nOffset(0); - if (ScRangeStringConverter::GetRangeFromString( aCellRangeAddress, sRangeAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset )) - { - sal_Bool bInsert(sal_True); - try - { - xDatabaseRanges->addNewByName(sDatabaseRangeName, aCellRangeAddress); - } - catch ( uno::RuntimeException& rRuntimeException ) - { - bInsert = false; - rtl::OUString sErrorMessage(RTL_CONSTASCII_USTRINGPARAM("DatabaseRange ")); - sErrorMessage += sDatabaseRangeName; - sErrorMessage += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" could not be created with the range ")); - sErrorMessage += sRangeAddress; - uno::Sequence<rtl::OUString> aSeq(1); - aSeq[0] = sErrorMessage; - uno::Reference<xml::sax::XLocator> xLocator; - GetScImport().SetError(XMLERROR_API | XMLERROR_FLAG_ERROR, aSeq, rRuntimeException.Message, xLocator); - } - if (bInsert) - { - uno::Reference <sheet::XDatabaseRange> xDatabaseRange(xDatabaseRanges->getByName(sDatabaseRangeName), uno::UNO_QUERY); - if (xDatabaseRange.is()) - { - uno::Reference <beans::XPropertySet> xDatabaseRangePropertySet (xDatabaseRange, uno::UNO_QUERY); - if (xDatabaseRangePropertySet.is()) - { - xDatabaseRangePropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_KEEPFORM)), uno::makeAny(bKeepFormats)); - xDatabaseRangePropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_MOVCELLS)), uno::makeAny(bMoveCells)); - xDatabaseRangePropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT)), uno::makeAny(bStripData)); - } - uno::Sequence <beans::PropertyValue> aImportDescriptor(xDatabaseRange->getImportDescriptor()); - sal_Int32 nImportProperties = aImportDescriptor.getLength(); - for (sal_Int16 i = 0; i < nImportProperties; ++i) - { - if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_DBNAME))) - { - if (sDatabaseName.getLength()) - { - aImportDescriptor[i].Value <<= sDatabaseName; - } - else - { - aImportDescriptor[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONRES)); - aImportDescriptor[i].Value <<= sConnectionRessource; - } - } - else if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCOBJ))) - aImportDescriptor[i].Value <<= sSourceObject; - else if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCTYPE))) - aImportDescriptor[i].Value <<= nSourceType; - else if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISNATIVE))) - aImportDescriptor[i].Value <<= bNative; - } - ScDBCollection* pDBCollection = pDoc->GetDBCollection(); - sal_uInt16 nIndex; - pDBCollection->SearchName(sDatabaseRangeName, nIndex); - ScDBData* pDBData = (*pDBCollection)[nIndex]; - pDBData->SetImportSelection(bIsSelection); - pDBData->SetAutoFilter(bAutoFilter); - if (bAutoFilter) - pDoc->ApplyFlagsTab( static_cast<SCCOL>(aCellRangeAddress.StartColumn), static_cast<SCROW>(aCellRangeAddress.StartRow), - static_cast<SCCOL>(aCellRangeAddress.EndColumn), static_cast<SCROW>(aCellRangeAddress.StartRow), - aCellRangeAddress.Sheet, SC_MF_AUTO ); - ScImportParam aImportParam; - ScImportDescriptor::FillImportParam(aImportParam, aImportDescriptor); - pDBData->SetImportParam(aImportParam); - if (bContainsSort) - { - sal_uInt32 nOldSize(aSortSequence.getLength()); - aSortSequence.realloc(nOldSize + 1); - beans::PropertyValue aProperty; - aProperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ORIENT)); - aProperty.Value <<= eOrientation; - aSortSequence[nOldSize] = aProperty; - ScSortParam aSortParam; - ScSortDescriptor::FillSortParam(aSortParam, aSortSequence); - - //#98317#; until now the Fields are relative to the left top edge of the range, but the - // core wants to have the absolute position (column/row) - SCCOLROW nFieldStart = aSortParam.bByRow ? static_cast<SCCOLROW>(aCellRangeAddress.StartColumn) : static_cast<SCCOLROW>(aCellRangeAddress.StartRow); - for (sal_uInt16 i = 0; i < MAXSORT; ++i) - { - if (aSortParam.bDoSort[i]) - aSortParam.nField[i] += nFieldStart; - } - - pDBData->SetSortParam(aSortParam); - } - uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor( - xDatabaseRange->getFilterDescriptor(), uno::UNO_QUERY ); - if (xSheetFilterDescriptor.is()) - { - uno::Reference <beans::XPropertySet> xFilterPropertySet (xSheetFilterDescriptor, uno::UNO_QUERY); - if (xFilterPropertySet.is()) - { - sal_Bool bOrientation(table::TableOrientation_COLUMNS == eOrientation); - xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ORIENT)), uno::makeAny(bOrientation)); - xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONTHDR)), uno::makeAny(bContainsHeader)); - xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_COPYOUT)), uno::makeAny(bFilterCopyOutputData)); - xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE)), uno::makeAny(bFilterIsCaseSensitive)); - xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SKIPDUP)), uno::makeAny(bFilterSkipDuplicates)); - xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_USEREGEX)), uno::makeAny(bFilterUseRegularExpressions)); - xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_OUTPOS)), uno::makeAny(aFilterOutputPosition)); - } - xSheetFilterDescriptor->setFilterFields2(aFilterFields); - if (bFilterConditionSourceRange) - { - ScRange aAdvSource; - ScUnoConversion::FillScRange( aAdvSource, aFilterConditionSourceRangeAddress ); - pDBData->SetAdvancedQuerySource(&aAdvSource); - } - } - if (bContainsSubTotal) - { - uno::Reference <sheet::XSubTotalDescriptor> xSubTotalDescriptor(xDatabaseRange->getSubTotalDescriptor()); - if (xSubTotalDescriptor.is()) - { - uno::Reference <beans::XPropertySet> xSubTotalPropertySet (xSubTotalDescriptor, uno::UNO_QUERY); - if( xSubTotalPropertySet.is()) - { - xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_BINDFMT)), uno::makeAny(bSubTotalsBindFormatsToContent)); - xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ENABLEUSERSORTLIST)), uno::makeAny(bSubTotalsEnabledUserList)); - xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_USERSORTLISTINDEX)), uno::makeAny(nSubTotalsUserListIndex)); - xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INSBRK)), uno::makeAny(bSubTotalsInsertPageBreaks)); - xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE)), uno::makeAny(bSubTotalsIsCaseSensitive)); - } - ScSubTotalParam aSubTotalParam; - aSubTotalParam.bDoSort = bSubTotalsSortGroups; - aSubTotalParam.bAscending = bSubTotalsAscending; - aSubTotalParam.bUserDef = bSubTotalsEnabledUserList; - aSubTotalParam.nUserIndex = nSubTotalsUserListIndex; - pDBData->SetSubTotalParam(aSubTotalParam); - std::vector < ScSubTotalRule >::iterator aItr(aSubTotalRules.begin()); - while (!aSubTotalRules.empty()) - { - xSubTotalDescriptor->addNew(aItr->aSubTotalColumns, aItr->nSubTotalRuleGroupFieldNumber); - aItr = aSubTotalRules.erase(aItr); - } - } - } - if ( pDBData->HasImportParam() && !pDBData->HasImportSelection() ) - { - pDBData->SetRefreshDelay( nRefresh ); - pDBData->SetRefreshHandler( pDBCollection->GetRefreshHandler() ); - pDBData->SetRefreshControl( pDoc->GetRefreshTimerControlAddress() ); - } - } - } - } - } + setAutoFilterFlags(*pDoc, *pData); + pDoc->GetDBCollection()->getNamedDBs().insert(pData.release()); } } } diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx index 80b65247b..6a8c1b2a8 100644 --- a/sc/source/filter/xml/xmldrani.hxx +++ b/sc/source/filter/xml/xmldrani.hxx @@ -39,6 +39,8 @@ #include <com/sun/star/table/CellRangeAddress.hpp> #include <com/sun/star/table/TableOrientation.hpp> +#include "dbdata.hxx" + class ScDBData; class ScXMLImport; @@ -72,8 +74,6 @@ struct ScSubTotalRule class ScXMLDatabaseRangeContext : public SvXMLImportContext { - enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous }; - rtl::OUString sDatabaseRangeName; rtl::OUString sConnectionRessource; rtl::OUString sRangeAddress; @@ -109,7 +109,7 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext sal_Bool bFilterSkipDuplicates; sal_Bool bFilterUseRegularExpressions; sal_Bool bFilterConditionSourceRange; - RangeType meRangeType; + ScDBCollection::RangeType meRangeType; const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 4a5eecb25..c9597964a 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -1729,7 +1729,7 @@ void ScXMLExport::_ExportContent() } WriteExternalRefCaches(); WriteNamedExpressions(xSpreadDoc); - aExportDatabaseRanges.WriteDatabaseRanges(xSpreadDoc); + aExportDatabaseRanges.WriteDatabaseRanges(); ScXMLExportDataPilot aExportDataPilot(*this); aExportDataPilot.WriteDataPilots(xSpreadDoc); WriteConsolidation(); diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 329bf960b..fb749d630 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2640,7 +2640,7 @@ void ScInputHandler::EnterHandler( sal_uInt8 nBlockMode ) if ( aString.GetChar(0) == '=' ) { - SvxAutoCorrect* pAuto = SvxAutoCorrCfg::Get()->GetAutoCorrect(); + SvxAutoCorrect* pAuto = SvxAutoCorrCfg::Get().GetAutoCorrect(); if ( pAuto ) { sal_Unicode cReplace = pAuto->GetStartDoubleQuote(); diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 4f9abfa3d..d6b7bf953 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -69,7 +69,7 @@ #include "appoptio.hxx" #include "rangenam.hxx" #include <formula/compiler.hrc> -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "rangeutl.hxx" #include "docfunc.hxx" #include "funcdesc.hxx" @@ -275,9 +275,9 @@ void ScInputWindow::SetInputHandler( ScInputHandler* pNew ) } } -sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const +bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const { - sal_Bool bSubTotal(false); + bool bSubTotal = false; ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); if ( pViewSh ) { @@ -298,7 +298,7 @@ sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const while (!bSubTotal && nRow <= nRowEnd) { if (pDoc->RowFiltered(nRow, nTab)) - bSubTotal = sal_True; + bSubTotal = true; else ++nRow; } @@ -308,29 +308,27 @@ sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const ++nRangeIndex; } - ScDBCollection* pDBCollection = pDoc->GetDBCollection(); - sal_uInt16 nDBCount (pDBCollection->GetCount()); - sal_uInt16 nDBIndex (0); - while (!bSubTotal && nDBIndex < nDBCount) + const ScDBCollection::NamedDBs& rDBs = pDoc->GetDBCollection()->getNamedDBs(); + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; !bSubTotal && itr != itrEnd; ++itr) { - ScDBData* pDB = (*pDBCollection)[nDBIndex]; - if (pDB && pDB->HasAutoFilter()) + const ScDBData& rDB = *itr; + if (!rDB.HasAutoFilter()) + continue; + + nRangeIndex = 0; + while (!bSubTotal && nRangeIndex < nRangeCount) { - nRangeIndex = 0; - while (!bSubTotal && nRangeIndex < nRangeCount) + const ScRange* pRange = (*pRangeList)[nRangeIndex]; + if( pRange ) { - const ScRange* pRange = (*pRangeList)[nRangeIndex]; - if( pRange ) - { - ScRange aDBArea; - pDB->GetArea(aDBArea); - if (aDBArea.Intersects(*pRange)) - bSubTotal = sal_True; - } - ++nRangeIndex; + ScRange aDBArea; + rDB.GetArea(aDBArea); + if (aDBArea.Intersects(*pRange)) + bSubTotal = true; } + ++nRangeIndex; } - ++nDBIndex; } } return bSubTotal; diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 097893ffc..64a281fff 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -167,7 +167,7 @@ ScModule::ScModule( SfxObjectFactory* pFact ) : // ErrorHandler anlegen - war in Init() // zwischen OfficeApplication::Init und ScGlobal::Init - SvxErrorHandler::Get(); + SvxErrorHandler::ensure(); pErrorHdl = new SfxErrorHandler( RID_ERRHDLSC, ERRCODE_AREA_SC, ERRCODE_AREA_APP2-1, diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx index f07ed1247..e2d57315c 100644 --- a/sc/source/ui/dbgui/consdlg.cxx +++ b/sc/source/ui/dbgui/consdlg.cxx @@ -39,7 +39,7 @@ #include "tabvwsh.hxx" #include "uiitems.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "rangenam.hxx" #include "rangeutl.hxx" #include "reffact.hxx" @@ -222,8 +222,8 @@ void ScConsolidateDlg::Init() ScRangeName* pRangeNames = pDoc->GetRangeName(); ScDBCollection* pDbNames = pDoc->GetDBCollection(); - const sal_uInt16 nRangeCount = pRangeNames ? pRangeNames->size() : 0; - const sal_uInt16 nDbCount = pDbNames ? pDbNames ->GetCount() : 0; + size_t nRangeCount = pRangeNames ? pRangeNames->size() : 0; + size_t nDbCount = pDbNames ? pDbNames->getNamedDBs().size() : 0; nAreaDataCount = nRangeCount+nDbCount; pAreaData = NULL; @@ -269,7 +269,7 @@ void ScConsolidateDlg::FillAreaLists() { String aString; - for ( sal_uInt16 i=0; + for ( size_t i=0; (i<nAreaDataCount) && (pAreaData[i].aStrName.Len()>0); i++ ) { @@ -558,7 +558,7 @@ IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox*, pLb ) && (nAreaDataCount > 0) && (pAreaData != NULL) ) { - if ( nSelPos <= nAreaDataCount ) + if ( static_cast<size_t>(nSelPos) <= nAreaDataCount ) { String aString( pAreaData[nSelPos-1].aStrArea ); diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index 695b83490..09fd53633 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -66,7 +66,6 @@ class DBSaveData; static DBSaveData* pSaveObj = NULL; #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute() -#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute() //============================================================================ // class DBSaveData @@ -166,7 +165,6 @@ ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, aStrAdd ( ScResId( STR_ADD ) ), aStrModify ( ScResId( STR_MODIFY ) ), - aStrNoName ( RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)), aStrInvalid ( ScResId( STR_DB_INVALID ) ), // pViewData ( ptrViewData ), @@ -272,11 +270,8 @@ void ScDbNameDlg::Init() && (rStart.Col() == nCol1) && (rStart.Row() == nRow1) && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) ) { - theDbName = pDBData->GetName(); - if ( !theDbName.equals(aStrNoName) ) - aEdName.SetText( theDbName ); - else - aEdName.SetText( EMPTY_STRING ); + aEdName.SetText(pDBData->GetName()); + aBtnHeader.Check( pDBData->HasHeader() ); aBtnDoSize.Check( pDBData->IsDoSize() ); aBtnKeepFmt.Check( pDBData->IsKeepFmt() ); @@ -369,28 +364,20 @@ void ScDbNameDlg::SetActive() void ScDbNameDlg::UpdateNames() { - sal_uInt16 nNameCount = aLocalDbCol.GetCount(); + typedef ScDBCollection::NamedDBs DBsType; + + const DBsType& rDBs = aLocalDbCol.getNamedDBs(); aEdName.SetUpdateMode( false ); //----------------------------------------------------------- aEdName.Clear(); aEdAssign.SetText( EMPTY_STRING ); - if ( nNameCount > 0 ) + if (!rDBs.empty()) { - ScDBData* pDbData = NULL; - ::rtl::OUString aString; - - for ( sal_uInt16 i=0; i<nNameCount; i++ ) - { - pDbData = (ScDBData*)(aLocalDbCol.At( i )); - if ( pDbData ) - { - aString = pDbData->GetName(); - if (!aString.equals(aStrNoName)) - aEdName.InsertEntry( aString ); - } - } + DBsType::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; itr != itrEnd; ++itr) + aEdName.InsertEntry(itr->GetName()); } else { @@ -407,12 +394,8 @@ void ScDbNameDlg::UpdateNames() void ScDbNameDlg::UpdateDBData( const String& rStrName ) { - String theArea; - sal_uInt16 nAt; - ScDBData* pData; - aLocalDbCol.SearchName( rStrName, nAt ); - pData = (ScDBData*)(aLocalDbCol.At( nAt )); + const ScDBData* pData = aLocalDbCol.getNamedDBs().findByName(rStrName); if ( pData ) { @@ -425,6 +408,7 @@ void ScDbNameDlg::UpdateDBData( const String& rStrName ) pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd ); theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ), ScAddress( nColEnd, nRowEnd, nTab ) ); + ::rtl::OUString theArea; theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails ); aEdAssign.SetText( theArea ); aBtnAdd.SetText( aStrModify ); @@ -505,10 +489,7 @@ IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG ) ScAddress aStart = theCurArea.aStart; ScAddress aEnd = theCurArea.aEnd; - ScDBData* pOldEntry = NULL; - sal_uInt16 nFoundAt = 0; - if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) ) - pOldEntry = aLocalDbCol[nFoundAt]; + ScDBData* pOldEntry = aLocalDbCol.getNamedDBs().findByName(aNewName); if (pOldEntry) { // Bereich veraendern @@ -533,8 +514,7 @@ IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG ) pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() ); pNewEntry->SetStripData( aBtnStripData.IsChecked() ); - if ( !aLocalDbCol.Insert( pNewEntry ) ) - delete pNewEntry; + aLocalDbCol.getNamedDBs().insert(pNewEntry); } UpdateNames(); @@ -572,36 +552,49 @@ IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG ) return 0; } -//------------------------------------------------------------------------ +namespace { + +class FindByName : public ::std::unary_function<ScDBData, bool> +{ + const ::rtl::OUString& mrName; +public: + FindByName(const ::rtl::OUString& rName) : mrName(rName) {} + bool operator() (const ScDBData& r) const + { + return r.GetName().equals(mrName); + } +}; + +} IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG ) { - sal_uInt16 nRemoveAt = 0; - const String aStrEntry = aEdName.GetText(); + ::rtl::OUString aStrEntry = aEdName.GetText(); + ScDBCollection::NamedDBs& rDBs = aLocalDbCol.getNamedDBs(); + ScDBCollection::NamedDBs::iterator itr = + ::std::find_if(rDBs.begin(), rDBs.end(), FindByName(aStrEntry)); - if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) ) + if (itr != rDBs.end()) { String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY ); - String aMsg = aStrDelMsg.GetToken( 0, '#' ); - aMsg += aStrEntry; - aMsg += aStrDelMsg.GetToken( 1, '#' ); + ::rtl::OUStringBuffer aBuf; + aBuf.append(aStrDelMsg.GetToken(0, '#')); + aBuf.append(aStrEntry); + aBuf.append(aStrDelMsg.GetToken(1, '#')); + QueryBox aBox(this, WinBits(WB_YES_NO|WB_DEF_YES), aBuf.makeStringAndClear()); - if ( RET_YES == QUERYBOX(aMsg) ) + if (RET_YES == aBox.Execute()) { - ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt); - - if ( pEntry ) - { - SCTAB nTab; - SCCOL nColStart, nColEnd; - SCROW nRowStart, nRowEnd; - pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd ); - aRemoveList.Insert( - new ScRange( ScAddress( nColStart, nRowStart, nTab ), - ScAddress( nColEnd, nRowEnd, nTab ) ) ); - } - aLocalDbCol.AtFree( nRemoveAt ); + SCTAB nTab; + SCCOL nColStart, nColEnd; + SCROW nRowStart, nRowEnd; + itr->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd ); + aRemoveList.Insert( + new ScRange( ScAddress( nColStart, nRowStart, nTab ), + ScAddress( nColEnd, nRowEnd, nTab ) ) ); + + rDBs.erase(itr); UpdateNames(); diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx index eadd0f474..b32bc9f34 100644 --- a/sc/source/ui/dbgui/fieldwnd.cxx +++ b/sc/source/ui/dbgui/fieldwnd.cxx @@ -846,8 +846,8 @@ size_t ScDPHorFieldControl::CalcNewFieldIndex(SCsCOL nDX, SCsROW nDY) const size_t nFldCount = GetFieldCount(); SCsROW nRow = nSel % mnFieldBtnRowCount; SCsCOL nCol = nSel / mnFieldBtnRowCount; - SCsCOL nColUpper = ceil( - static_cast<double>(nFldCount) / static_cast<double>(mnFieldBtnRowCount)) - 1; + SCsCOL nColUpper = static_cast<SCsCOL>(ceil( + static_cast<double>(nFldCount) / static_cast<double>(mnFieldBtnRowCount)) - 1); SCsROW nRowUpper = mnFieldBtnRowCount - 1; nCol += nDX; @@ -912,8 +912,8 @@ void ScDPHorFieldControl::ScrollToShowSelection() void ScDPHorFieldControl::ResetScrollBar() { long nOldMax = maScroll.GetRangeMax(); - long nNewMax = ceil( - static_cast<double>(GetFieldCount()) / static_cast<double>(mnFieldBtnRowCount)); + long nNewMax = static_cast<long>(ceil( + static_cast<double>(GetFieldCount()) / static_cast<double>(mnFieldBtnRowCount))); if (nOldMax != nNewMax) { @@ -1281,7 +1281,7 @@ ScDPFieldType ScDPDataFieldControl::GetFieldType() const Size ScDPDataFieldControl::GetFieldSize() const { Size aWndSize = GetSizePixel(); - long nFieldObjWidth = aWndSize.Width() / 2.0 - OUTER_MARGIN_HOR - DATA_FIELD_BTN_GAP/2; + long nFieldObjWidth = static_cast<long>(aWndSize.Width() / 2.0 - OUTER_MARGIN_HOR - DATA_FIELD_BTN_GAP/2); Size aFieldSize(nFieldObjWidth, FIELD_BTN_HEIGHT); return aFieldSize; } diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index 36551ba56..205d0387a 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -39,7 +39,7 @@ #include <vcl/waitobj.hxx> #include "uiitems.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "reffact.hxx" #include "viewdata.hxx" #include "document.hxx" diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx index a6bc3f6db..a99d8727b 100644 --- a/sc/source/ui/dbgui/foptmgr.cxx +++ b/sc/source/ui/dbgui/foptmgr.cxx @@ -40,7 +40,7 @@ #include "anyrefdg.hxx" #include "rangeutl.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "viewdata.hxx" #include "document.hxx" #include "queryparam.hxx" @@ -184,9 +184,9 @@ void ScFilterOptionsMgr::Init() { ScAddress& rStart = theCurArea.aStart; ScAddress& rEnd = theCurArea.aEnd; - ScDBData* pDBData = pDBColl->GetDBAtArea( rStart.Tab(), - rStart.Col(), rStart.Row(), - rEnd.Col(), rEnd.Row() ); + const ScDBData* pDBData = pDBColl->GetDBAtArea( + rStart.Tab(), rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row()); + if ( pDBData ) { rBtnHeader.Check( pDBData->HasHeader() ); diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx index b2e0cfe28..2e7314934 100644 --- a/sc/source/ui/dbgui/pfiltdlg.cxx +++ b/sc/source/ui/dbgui/pfiltdlg.cxx @@ -44,7 +44,7 @@ #include "uiitems.hxx" #include "global.hxx" #include "globalnames.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "scresid.hxx" #include "sc.hrc" diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx index c704f5904..289019d75 100644 --- a/sc/source/ui/dbgui/sfiltdlg.cxx +++ b/sc/source/ui/dbgui/sfiltdlg.cxx @@ -38,7 +38,7 @@ #include "uiitems.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "reffact.hxx" #include "viewdata.hxx" #include "document.hxx" diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx index 0ddd3b187..e4b952985 100644 --- a/sc/source/ui/dbgui/tpsort.cxx +++ b/sc/source/ui/dbgui/tpsort.cxx @@ -44,7 +44,7 @@ #include "document.hxx" #include "global.hxx" #include "globalnames.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "userlist.hxx" #include "rangeutl.hxx" #include "scresid.hxx" diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx index e2be816a9..e9e97bddd 100644 --- a/sc/source/ui/docshell/arealink.cxx +++ b/sc/source/ui/docshell/arealink.cxx @@ -47,7 +47,7 @@ #include "document.hxx" #include "docsh.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "undoblk.hxx" #include "globstr.hrc" #include "markdata.hxx" @@ -86,9 +86,9 @@ ScAreaLink::ScAreaLink( SfxObjectShell* pShell, const String& rFile, aOptions (rOpt), aSourceArea (rArea), aDestArea (rDest), - bAddUndo (sal_True), + bAddUndo (true), bInCreate (false), - bDoInsert (sal_True) + bDoInsert (true) { DBG_ASSERT(pShell->ISA(ScDocShell), "ScAreaLink mit falscher ObjectShell"); pImpl->m_pDocSh = static_cast< ScDocShell* >( pShell ); @@ -195,7 +195,7 @@ void ScAreaLink::SetSource(const String& rDoc, const String& rFlt, const String& SetName( aNewLinkName ); } -sal_Bool ScAreaLink::IsEqual( const String& rFile, const String& rFilter, const String& rOpt, +bool ScAreaLink::IsEqual( const String& rFile, const String& rFilter, const String& rOpt, const String& rSource, const ScRange& rDest ) const { return aFileName == rFile && aFilterName == rFilter && aOptions == rOpt && @@ -203,11 +203,10 @@ sal_Bool ScAreaLink::IsEqual( const String& rFile, const String& rFilter, const } // find a range with name >rAreaName< in >pSrcDoc<, return it in >rRange< -sal_Bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName ) +bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName ) { bool bFound = false; ScRangeName* pNames = pSrcDoc->GetRangeName(); - sal_uInt16 nPos; if (pNames) // benannte Bereiche { const ScRangeData* p = pNames->findByName(rAreaName); @@ -218,15 +217,18 @@ sal_Bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const S { ScDBCollection* pDBColl = pSrcDoc->GetDBCollection(); if (pDBColl) - if (pDBColl->SearchName( rAreaName, nPos )) + { + const ScDBData* pDB = pDBColl->getNamedDBs().findByName(rAreaName); + if (pDB) { SCTAB nTab; SCCOL nCol1, nCol2; SCROW nRow1, nRow2; - (*pDBColl)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2); + pDB->GetArea(nTab,nCol1,nRow1,nCol2,nRow2); rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab ); bFound = true; } + } } if (!bFound) // direct reference (range or cell) { diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index be8b2fc06..e20f21840 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -41,7 +41,7 @@ #include "dbdocfun.hxx" #include "sc.hrc" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "undodat.hxx" #include "docsh.hxx" #include "docfunc.hxx" @@ -62,7 +62,7 @@ // ----------------------------------------------------------------- -sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sal_Bool /* bApi */ ) +bool ScDBDocFunc::AddDBRange( const ::rtl::OUString& rName, const ScRange& rRange, sal_Bool /* bApi */ ) { ScDocShellModificator aModificator( rDocShell ); @@ -82,8 +82,8 @@ sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sa // #i55926# While loading XML, formula cells only have a single string token, // so CompileDBFormula would never find any name (index) tokens, and would // unnecessarily loop through all cells. - sal_Bool bCompile = !pDoc->IsImportingXML(); - sal_Bool bOk; + bool bCompile = !pDoc->IsImportingXML(); + bool bOk; if ( bCompile ) pDoc->CompileDBFormula( sal_True ); // CreateFormulaString if (rtl::OUString(rName)==rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME))) @@ -93,7 +93,7 @@ sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sa } else { - bOk = pDocColl->Insert( pNew ); + bOk = pDocColl->getNamedDBs().insert(pNew); } if ( bCompile ) pDoc->CompileDBFormula( false ); // CompileFormulaString @@ -114,18 +114,19 @@ sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sa aModificator.SetDocumentModified(); SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); - return sal_True; + return true; } -sal_Bool ScDBDocFunc::DeleteDBRange( const String& rName, sal_Bool /* bApi */ ) +bool ScDBDocFunc::DeleteDBRange(const ::rtl::OUString& rName) { - sal_Bool bDone = false; + bool bDone = false; ScDocument* pDoc = rDocShell.GetDocument(); ScDBCollection* pDocColl = pDoc->GetDBCollection(); - sal_Bool bUndo (pDoc->IsUndoEnabled()); + bool bUndo = pDoc->IsUndoEnabled(); - sal_uInt16 nPos = 0; - if (pDocColl->SearchName( rName, nPos )) + ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs(); + const ScDBData* p = rDBs.findByName(rName); + if (p) { ScDocShellModificator aModificator( rDocShell ); @@ -133,8 +134,8 @@ sal_Bool ScDBDocFunc::DeleteDBRange( const String& rName, sal_Bool /* bApi */ ) if (bUndo) pUndoColl = new ScDBCollection( *pDocColl ); - pDoc->CompileDBFormula( sal_True ); // CreateFormulaString - pDocColl->AtFree( nPos ); + pDoc->CompileDBFormula( true ); // CreateFormulaString + rDBs.erase(*p); pDoc->CompileDBFormula( false ); // CompileFormulaString if (bUndo) @@ -146,40 +147,35 @@ sal_Bool ScDBDocFunc::DeleteDBRange( const String& rName, sal_Bool /* bApi */ ) aModificator.SetDocumentModified(); SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); - bDone = sal_True; + bDone = true; } return bDone; } -sal_Bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew, sal_Bool /* bApi */ ) +bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew ) { - sal_Bool bDone = false; + bool bDone = false; ScDocument* pDoc = rDocShell.GetDocument(); ScDBCollection* pDocColl = pDoc->GetDBCollection(); - sal_Bool bUndo (pDoc->IsUndoEnabled()); - - sal_uInt16 nPos = 0; - sal_uInt16 nDummy = 0; - if ( pDocColl->SearchName( rOld, nPos ) && - !pDocColl->SearchName( rNew, nDummy ) ) + bool bUndo = pDoc->IsUndoEnabled(); + ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs(); + const ScDBData* pOld = rDBs.findByName(rOld); + const ScDBData* pNew = rDBs.findByName(rNew); + if (pOld && !pNew) { ScDocShellModificator aModificator( rDocShell ); - ScDBData* pData = (*pDocColl)[nPos]; - ScDBData* pNewData = new ScDBData(*pData); - pNewData->SetName(rNew); + ScDBData* pNewData = new ScDBData(rNew, *pOld); ScDBCollection* pUndoColl = new ScDBCollection( *pDocColl ); - pDoc->CompileDBFormula( sal_True ); // CreateFormulaString - pDocColl->AtFree( nPos ); - sal_Bool bInserted = pDocColl->Insert( pNewData ); + pDoc->CompileDBFormula(true); // CreateFormulaString + rDBs.erase(*pOld); + bool bInserted = rDBs.insert(pNewData); if (!bInserted) // Fehler -> alten Zustand wiederherstellen - { - delete pNewData; - pDoc->SetDBCollection( pUndoColl ); // gehoert dann dem Dokument - } + pDoc->SetDBCollection(pUndoColl); // gehoert dann dem Dokument + // pDoc->CompileDBFormula( false ); // CompileFormulaString if (bInserted) // Einfuegen hat geklappt @@ -195,19 +191,19 @@ sal_Bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew, sal aModificator.SetDocumentModified(); SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); - bDone = sal_True; + bDone = true; } } return bDone; } -sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi */ ) +bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData ) { - sal_Bool bDone = false; + bool bDone = false; ScDocument* pDoc = rDocShell.GetDocument(); ScDBCollection* pDocColl = pDoc->GetDBCollection(); - sal_Bool bUndo (pDoc->IsUndoEnabled()); + bool bUndo = pDoc->IsUndoEnabled(); ScDBData* pData = NULL; if (rtl::OUString(rNewData.GetName())==rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME))) @@ -218,18 +214,15 @@ sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi * pData = pDoc->GetAnonymousDBData(nTab); } else - { - sal_uInt16 nPos = 0; - if (pDocColl->SearchName( rNewData.GetName(), nPos )) - pData = (*pDocColl)[nPos]; - } + pData = pDocColl->getNamedDBs().findByName(rNewData.GetName()); + if (pData) { ScDocShellModificator aModificator( rDocShell ); ScRange aOldRange, aNewRange; pData->GetArea(aOldRange); rNewData.GetArea(aNewRange); - sal_Bool bAreaChanged = ( aOldRange != aNewRange ); // dann muss neu compiliert werden + bool bAreaChanged = ( aOldRange != aNewRange ); // dann muss neu compiliert werden ScDBCollection* pUndoColl = NULL; if (bUndo) @@ -247,7 +240,7 @@ sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi * } aModificator.SetDocumentModified(); - bDone = sal_True; + bDone = true; } return bDone; @@ -255,11 +248,11 @@ sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi * // ----------------------------------------------------------------- -sal_Bool ScDBDocFunc::RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Bool bApi, bool bIsUnnamed, SCTAB aTab ) +bool ScDBDocFunc::RepeatDB( const ::rtl::OUString& rDBName, bool bRecord, bool bApi, bool bIsUnnamed, SCTAB aTab ) { //! auch fuer ScDBFunc::RepeatDB benutzen! - sal_Bool bDone = false; + bool bDone = false; ScDocument* pDoc = rDocShell.GetDocument(); if (bRecord && !pDoc->IsUndoEnabled()) bRecord = false; @@ -270,10 +263,9 @@ sal_Bool ScDBDocFunc::RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Boo } else { - sal_uInt16 nIndex; ScDBCollection* pColl = pDoc->GetDBCollection(); - if ( pColl && pColl->SearchName( rDBName, nIndex ) ) - pDBData = (*pColl)[nIndex]; + if (pColl) + pDBData = pColl->getNamedDBs().findByName(rDBName); } if ( pDBData ) @@ -357,7 +349,7 @@ sal_Bool ScDBDocFunc::RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Boo if (!pDocRange->empty()) pUndoRange = new ScRangeName( *pDocRange ); ScDBCollection* pDocDB = pDoc->GetDBCollection(); - if (pDocDB->GetCount()) + if (!pDocDB->empty()) pUndoDB = new ScDBCollection( *pDocDB ); } @@ -563,7 +555,7 @@ sal_Bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam, ScDBCollection* pUndoDB = NULL; ScDBCollection* pDocDB = pDoc->GetDBCollection(); - if (pDocDB->GetCount()) + if (!pDocDB->empty()) pUndoDB = new ScDBCollection( *pDocDB ); pUndoAction = new ScUndoSort( &rDocShell, nTab, rSortParam, bRepeatQuery, pUndoDoc, pUndoDB, pR ); @@ -823,7 +815,7 @@ sal_Bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam, } ScDBCollection* pDocDB = pDoc->GetDBCollection(); - if (pDocDB->GetCount()) + if (!pDocDB->empty()) pUndoDB = new ScDBCollection( *pDocDB ); pDoc->BeginDrawUndo(); @@ -1109,7 +1101,7 @@ sal_Bool ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam, if (!pDocRange->empty()) pUndoRange = new ScRangeName( *pDocRange ); ScDBCollection* pDocDB = pDoc->GetDBCollection(); - if (pDocDB->GetCount()) + if (!pDocDB->empty()) pUndoDB = new ScDBCollection( *pDocDB ); } @@ -1461,7 +1453,7 @@ sal_Bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pN // Datenbank-Import... void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName, - const String& rTableName, const String& rStatement, sal_Bool bNative, + const String& rTableName, const String& rStatement, bool bNative, sal_uInt8 nType, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& xResultSet, const SbaSelectionList* pSelection ) @@ -1470,17 +1462,8 @@ void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName, ScDocument* pDoc = rDocShell.GetDocument(); ScDBCollection& rDBColl = *pDoc->GetDBCollection(); - ScDBData* pData = NULL; - ScImportParam aImportParam; - bool bFound = false; - sal_uInt16 nCount = rDBColl.GetCount(); - for (sal_uInt16 i=0; i<nCount && !bFound; i++) - { - pData = rDBColl[i]; - if (pData->GetName().equals(rTarget)) - bFound = true; - } - if (!bFound) + const ScDBData* pData = rDBColl.getNamedDBs().findByName(rTarget); + if (!pData) { InfoBox aInfoBox(rDocShell.GetActiveDialogParent(), ScGlobal::GetRscString( STR_TARGETNOTFOUND ) ); @@ -1492,9 +1475,11 @@ void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName, SCCOL nDummyCol; SCROW nDummyRow; pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow ); + + ScImportParam aImportParam; pData->GetImportParam( aImportParam ); - sal_Bool bSql = ( rStatement.Len() != 0 ); + bool bSql = (rStatement.Len() != 0); aImportParam.aDBName = rDBName; aImportParam.bSql = bSql; @@ -1502,7 +1487,7 @@ void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName, aImportParam.bNative = bNative; aImportParam.nType = nType; aImportParam.bImport = true; - sal_Bool bContinue = DoImport( nTab, aImportParam, xResultSet, pSelection, sal_True ); + bool bContinue = DoImport( nTab, aImportParam, xResultSet, pSelection, sal_True ); // DB-Operationen wiederholen diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index 1b376645c..10e704c38 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -56,7 +56,7 @@ #include "docsh.hxx" #include "globstr.hrc" #include "scerrors.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "markdata.hxx" #include "undodat.hxx" #include "progress.hxx" @@ -119,10 +119,10 @@ void ScDBDocFunc::ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFram // ----------------------------------------------------------------- -sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos, +bool ScDBDocFunc::DoImportUno( const ScAddress& rPos, const uno::Sequence<beans::PropertyValue>& aArgs ) { - sal_Bool bDone = false; + bool bDone = false; ScImportParam aImParam; aImParam.nCol1 = aImParam.nCol2 = rPos.Col(); @@ -180,7 +180,7 @@ sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos, aList.Insert( (void*)(sal_IntPtr)nEntry, LIST_APPEND ); } - sal_Bool bAddrInsert = false; //!??? + bool bAddrInsert = false; //!??? if ( bAddrInsert ) { bDone = DoImport( rPos.Tab(), aImParam, xResSet, &aList, sal_True, bAddrInsert ); @@ -204,7 +204,7 @@ sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos, UpdateImport( sTarget, aImParam.aDBName, aTableName, aStatement, aImParam.bNative, aImParam.nType, xResSet, &aList ); - bDone = sal_True; + bDone = true; } return bDone; @@ -212,9 +212,9 @@ sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos, // ----------------------------------------------------------------- -sal_Bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, +bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, const uno::Reference< sdbc::XResultSet >& xResultSet, - const SbaSelectionList* pSelection, sal_Bool bRecord, sal_Bool bAddrInsert ) + const SbaSelectionList* pSelection, bool bRecord, bool bAddrInsert ) { ScDocument* pDoc = rDocShell.GetDocument(); ScChangeTrack *pChangeTrack = NULL; @@ -223,7 +223,7 @@ sal_Bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, if (bRecord && !pDoc->IsUndoEnabled()) bRecord = false; - ScDBData* pDBData = 0; + ScDBData* pDBData = NULL; if ( !bAddrInsert ) { pDBData = pDoc->GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1, diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 46687e86f..ff9b70e85 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -118,7 +118,7 @@ #include "xmlwrap.hxx" #include "drwlayer.hxx" #include "refreshtimer.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "scextopt.hxx" #include "compiler.hxx" #include "cfgids.hxx" diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 0a163a795..a2e676b3b 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -144,7 +144,7 @@ void ScDocShell::InitItems() else { // always use global color table instead of local copy - PutItem( SvxColorTableItem( XColorTable::GetStdColorTable(), SID_COLOR_TABLE ) ); + PutItem( SvxColorTableItem( &XColorTable::GetStdColorTable(), SID_COLOR_TABLE ) ); } if ( !aDocument.GetForbiddenCharacters().is() || diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 0d8ea68f5..36e0e8e7d 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -96,7 +96,7 @@ using namespace ::com::sun::star; #include "undocell.hxx" #include "undotab.hxx" #include "inputhdl.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "servobj.hxx" #include "rangenam.hxx" #include "scmod.hxx" @@ -243,17 +243,16 @@ void ScDocShell::Execute( SfxRequest& rReq ) } // bei Bedarf neuen Datenbankbereich anlegen - sal_Bool bMakeArea = false; + bool bMakeArea = false; if (bIsNewArea) { ScDBCollection* pDBColl = aDocument.GetDBCollection(); - sal_uInt16 nDummy; - if ( !pDBColl || !pDBColl->SearchName( sTarget, nDummy ) ) + if ( !pDBColl || !pDBColl->getNamedDBs().findByName(sTarget) ) { ScAddress aPos; if ( aPos.Parse( sTarget, &aDocument, aDocument.GetAddressConvention() ) & SCA_VALID ) { - bMakeArea = sal_True; + bMakeArea = true; if (bUndo) { String aStrImport = ScGlobal::GetRscString( STR_UNDO_IMPORTDATA ); @@ -268,7 +267,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) } // nachfragen, bevor alter DB-Bereich ueberschrieben wird - sal_Bool bDo = sal_True; + bool bDo = true; if (!bIsNewArea) { String aTemplate = ScGlobal::GetRscString( STR_IMPORT_REPLACE ); @@ -283,7 +282,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) if (bDo) { ScDBDocFunc(*this).UpdateImport( sTarget, sDBName, - sDBTable, sDBSql, sal_True, nType, xResultSet, + sDBTable, sDBSql, true, nType, xResultSet, pSelectionList ); rReq.Done(); @@ -525,33 +524,35 @@ void ScDocShell::Execute( SfxRequest& rReq ) ScGlobal::GetRscString(STR_REIMPORT_AFTER_LOAD) ); if (aBox.Execute() == RET_YES) { - for (sal_uInt16 i=0; i<pDBColl->GetCount(); i++) + ScDBCollection::NamedDBs& rDBs = pDBColl->getNamedDBs(); + ScDBCollection::NamedDBs::iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; itr != itrEnd; ++itr) { - ScDBData* pDBData = (*pDBColl)[i]; - if ( pDBData->IsStripData() && - pDBData->HasImportParam() && !pDBData->HasImportSelection() ) + ScDBData& rDBData = *itr; + if ( rDBData.IsStripData() && + rDBData.HasImportParam() && !rDBData.HasImportSelection() ) { - pDBData->GetArea(aRange); + rDBData.GetArea(aRange); pViewSh->MarkRange(aRange); // Import und interne Operationen wie SID_REFRESH_DBAREA // (Abfrage auf Import hier nicht noetig) ScImportParam aImportParam; - pDBData->GetImportParam( aImportParam ); - sal_Bool bContinue = pViewSh->ImportData( aImportParam ); - pDBData->SetImportParam( aImportParam ); + rDBData.GetImportParam( aImportParam ); + bool bContinue = pViewSh->ImportData( aImportParam ); + rDBData.SetImportParam( aImportParam ); // markieren (Groesse kann sich geaendert haben) - pDBData->GetArea(aRange); + rDBData.GetArea(aRange); pViewSh->MarkRange(aRange); if ( bContinue ) // Fehler beim Import -> Abbruch { // interne Operationen, wenn welche gespeichert - if ( pDBData->HasQueryParam() || pDBData->HasSortParam() || - pDBData->HasSubTotalParam() ) + if ( rDBData.HasQueryParam() || rDBData.HasSortParam() || + rDBData.HasSubTotalParam() ) pViewSh->RepeatDB(); // Pivottabellen die den Bereich als Quelldaten haben @@ -560,7 +561,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) } } } - bDone = sal_True; + bDone = true; } } } diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 3e7a4ee90..da2bf4576 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -58,7 +58,7 @@ #include "dpshttab.hxx" #include "dbdocfun.hxx" #include "consoli.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "olinetab.hxx" #include "patattr.hxx" #include "attrib.hxx" @@ -285,18 +285,20 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT ); long nCount = 0; - sal_uInt16 nDummy; + const ScDBData* pDummy = NULL; + ScDBCollection::NamedDBs& rDBs = pColl->getNamedDBs(); do { ++nCount; aNewName = aImport; aNewName += String::CreateFromInt32( nCount ); + pDummy = rDBs.findByName(aNewName); } - while (pColl->SearchName( aNewName, nDummy )); + while (pDummy); pNoNameData = new ScDBData( aNewName, nTab, nStartCol,nStartRow, nEndCol,nEndRow, sal_True, bHasHeader ); - pColl->Insert( pNoNameData ); + rDBs.insert(pNoNameData); } else { @@ -338,7 +340,7 @@ ScDBData* ScDocShell::GetAnonymousDBData(const ScRange& rRange) if (!pColl) return NULL; - ScDBData* pData = pColl->getAnonByRange(rRange); + ScDBData* pData = pColl->getAnonDBs().getByRange(rRange); if (!pData) return NULL; @@ -533,7 +535,7 @@ void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, sal_Bool bReco ScDocShellModificator aModificator( *this ); ScRange aOldDest; - ScDBData* pDestData = aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, sal_True ); + ScDBData* pDestData = aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, true ); if (pDestData) pDestData->GetArea(aOldDest); diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx index c8e16b2c2..45fb2f134 100644 --- a/sc/source/ui/drawfunc/drawsh.cxx +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -422,7 +422,7 @@ void ScDrawShell::ExecuteAreaDlg( SfxRequest& rReq, sal_uInt16 nTabPage ) // (see SwDrawShell::ExecDrawDlg) const SvxColorTableItem* pColorItem = static_cast<const SvxColorTableItem*>( pViewData->GetSfxDocShell()->GetItem(SID_COLOR_TABLE) ); - if (pColorItem->GetColorTable() == XColorTable::GetStdColorTable()) + if (pColorItem->GetColorTable() == &XColorTable::GetStdColorTable()) pDlg->DontDeleteColorTable(); if ( nTabPage != 0xffff ) diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx index 392497f54..30549f6ec 100644 --- a/sc/source/ui/drawfunc/fuins1.cxx +++ b/sc/source/ui/drawfunc/fuins1.cxx @@ -224,7 +224,7 @@ FuInsertGraphic::FuInsertGraphic( ScTabViewShell* pViewSh, bAsLink = ((const SfxBoolItem*)pItem)->GetValue(); Graphic aGraphic; - int nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, GraphicFilter::GetGraphicFilter() ); + int nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, &GraphicFilter::GetGraphicFilter() ); if ( nError == GRFILTER_OK ) { lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, sal_True, pViewSh, pWindow, pView ); diff --git a/sc/source/ui/inc/consdlg.hxx b/sc/source/ui/inc/consdlg.hxx index 9386fe00f..a45a49974 100644 --- a/sc/source/ui/inc/consdlg.hxx +++ b/sc/source/ui/inc/consdlg.hxx @@ -100,7 +100,7 @@ private: ScDocument* pDoc; ScRangeUtil* pRangeUtil; ScAreaData* pAreaData; - sal_uInt16 nAreaDataCount; + size_t nAreaDataCount; sal_uInt16 nWhichCons; formula::RefEdit* pRefInputEdit; diff --git a/sc/source/ui/inc/dbdocfun.hxx b/sc/source/ui/inc/dbdocfun.hxx index 35986627c..be99ee518 100644 --- a/sc/source/ui/inc/dbdocfun.hxx +++ b/sc/source/ui/inc/dbdocfun.hxx @@ -82,20 +82,19 @@ public: void UpdateImport( const String& rTarget, const String& rDBName, const String& rTableName, const String& rStatement, - sal_Bool bNative, sal_uInt8 nType, + bool bNative, sal_uInt8 nType, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& xResultSet, const SbaSelectionList* pSelection ); - sal_Bool DoImport( SCTAB nTab, const ScImportParam& rParam, - const ::com::sun::star::uno::Reference< - ::com::sun::star::sdbc::XResultSet >& xResultSet, - const SbaSelectionList* pSelection, sal_Bool bRecord, - sal_Bool bAddrInsert = false ); + bool DoImport( SCTAB nTab, const ScImportParam& rParam, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& xResultSet, + const SbaSelectionList* pSelection, bool bRecord, + bool bAddrInsert = false ); - sal_Bool DoImportUno( const ScAddress& rPos, - const com::sun::star::uno::Sequence< - com::sun::star::beans::PropertyValue>& aArgs ); + bool DoImportUno( const ScAddress& rPos, + const com::sun::star::uno::Sequence< + com::sun::star::beans::PropertyValue>& aArgs ); static void ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFrame ); @@ -109,12 +108,12 @@ public: const ScSortParam* pForceNewSort, sal_Bool bRecord, sal_Bool bApi ); - sal_Bool AddDBRange( const String& rName, const ScRange& rRange, sal_Bool bApi ); - sal_Bool DeleteDBRange( const String& rName, sal_Bool bApi ); - sal_Bool RenameDBRange( const String& rOld, const String& rNew, sal_Bool bApi ); - sal_Bool ModifyDBData( const ScDBData& rNewData, sal_Bool bApi ); // Name unveraendert + bool AddDBRange( const ::rtl::OUString& rName, const ScRange& rRange, sal_Bool bApi ); + bool DeleteDBRange( const ::rtl::OUString& rName ); + bool RenameDBRange( const String& rOld, const String& rNew ); + bool ModifyDBData( const ScDBData& rNewData ); // Name unveraendert - sal_Bool RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Bool bApi, bool bIsUnnamed=false, SCTAB aTab = 0); + bool RepeatDB( const ::rtl::OUString& rDBName, bool bRecord, bool bApi, bool bIsUnnamed=false, SCTAB aTab = 0); sal_Bool DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewObj, sal_Bool bRecord, sal_Bool bApi, sal_Bool bAllowMove = false ); diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx index 820105027..abdfe137e 100644 --- a/sc/source/ui/inc/dbfunc.hxx +++ b/sc/source/ui/inc/dbfunc.hxx @@ -75,7 +75,7 @@ public: sal_Bool ImportData( const ScImportParam& rParam, sal_Bool bRecord = sal_True ); - void GotoDBArea( const String& rDBName ); + void GotoDBArea( const ::rtl::OUString& rDBName ); // DB-Bereich vom Cursor ScDBData* GetDBData( bool bMarkArea = true, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP); diff --git a/sc/source/ui/inc/dbnamdlg.hxx b/sc/source/ui/inc/dbnamdlg.hxx index c6a16f257..e547a470f 100644 --- a/sc/source/ui/inc/dbnamdlg.hxx +++ b/sc/source/ui/inc/dbnamdlg.hxx @@ -35,7 +35,7 @@ #include <vcl/morebtn.hxx> #include "anyrefdg.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "expftext.hxx" class ScViewData; @@ -85,7 +85,6 @@ private: const String aStrAdd; // "Hinzufuegen" const String aStrModify; // "Aendern" - const String aStrNoName; // "unbenannt" const String aStrInvalid; String aStrSource; diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx index 338020ac8..ef1db4fe3 100644 --- a/sc/source/ui/inc/inputwin.hxx +++ b/sc/source/ui/inc/inputwin.hxx @@ -196,7 +196,7 @@ protected: virtual void SetText( const String& rString ); virtual String GetText() const; - sal_Bool UseSubTotal( ScRangeList* pRangeList ) const; + bool UseSubTotal( ScRangeList* pRangeList ) const; private: ScPosWnd aWndPos; diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx index 1f3cbd878..46c8578b3 100644 --- a/sc/source/ui/inc/navipi.hxx +++ b/sc/source/ui/inc/navipi.hxx @@ -73,7 +73,7 @@ public: explicit ScScenarioListBox( ScScenarioWindow& rParent ); virtual ~ScScenarioListBox(); - void UpdateEntries( List* pNewEntryList ); + void UpdateEntries( const std::vector<String> &aNewEntryList ); protected: virtual void Select(); diff --git a/sc/source/ui/inc/simpref.hxx b/sc/source/ui/inc/simpref.hxx index d0ddb0b62..40d5b3015 100644 --- a/sc/source/ui/inc/simpref.hxx +++ b/sc/source/ui/inc/simpref.hxx @@ -37,7 +37,7 @@ #include <vcl/morebtn.hxx> #include "anyrefdg.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "expftext.hxx" class ScViewData; diff --git a/sc/source/ui/inc/ui_pch.hxx b/sc/source/ui/inc/ui_pch.hxx index 4d4bdd10f..210784a14 100644 --- a/sc/source/ui/inc/ui_pch.hxx +++ b/sc/source/ui/inc/ui_pch.hxx @@ -68,7 +68,6 @@ #include <sot/object.hxx> #include <sot/sotdata.hxx> #include <sot/factory.hxx> -#include <tools/ownlist.hxx> #include <vcl/font.hxx> #include <vcl/wall.hxx> #include <vcl/settings.hxx> @@ -244,7 +243,7 @@ #include <basic/sbxcore.hxx> #include <vcl/ctrl.hxx> #include <svx/xenum.hxx> -#include <dbcolect.hxx> +#include <dbdata.hxx> #include <sot/exchange.hxx> #include <math.h> #include <vcl/wrkwin.hxx> diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx index c9142a3c9..09bfd2e52 100644 --- a/sc/source/ui/inc/undodat.hxx +++ b/sc/source/ui/inc/undodat.hxx @@ -302,15 +302,15 @@ private: class ScUndoAutoFilter: public ScDBFuncUndo { private: - String aDBName; - sal_Bool bFilterSet; + ::rtl::OUString aDBName; + bool bFilterSet; - void DoChange( sal_Bool bUndo ); + void DoChange( bool bUndo ); public: TYPEINFO(); ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange, - const String& rName, sal_Bool bSet ); + const ::rtl::OUString& rName, bool bSet ); virtual ~ScUndoAutoFilter(); virtual void Undo(); diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index dcd0aa92b..19ae54eb0 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -53,7 +53,7 @@ #include "docsh.hxx" #include "scmod.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "tablink.hxx" // fuer Loader #include "popmenu.hxx" #include "drwlayer.hxx" @@ -268,17 +268,12 @@ String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName ) if (pDoc) { ScDBCollection* pDbNames = pDoc->GetDBCollection(); - sal_uInt16 nCount = pDbNames->GetCount(); - for ( sal_uInt16 i=0; i<nCount; i++ ) + const ScDBData* pData = pDbNames->getNamedDBs().findByName(rDBName); + if (pData) { - ScDBData* pData = (*pDbNames)[i]; - if ( pData->GetName().equals(rDBName) ) - { - ScRange aRange; - pData->GetArea(aRange); - aRange.Format( aRet, SCR_ABS_3D, pDoc ); - break; - } + ScRange aRange; + pData->GetArea(aRange); + aRange.Format(aRet, SCR_ABS_3D, pDoc); } } return aRet; @@ -705,15 +700,12 @@ void ScContentTree::GetDbNames() return; ScDBCollection* pDbNames = pDoc->GetDBCollection(); - sal_uInt16 nCount = pDbNames->GetCount(); - if ( nCount > 0 ) + const ScDBCollection::NamedDBs& rDBs = pDbNames->getNamedDBs(); + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; itr != itrEnd; ++itr) { - for ( sal_uInt16 i=0; i<nCount; i++ ) - { - ScDBData* pData = (*pDbNames)[i]; - String aStrName = pData->GetName(); - InsertContent( SC_CONTENT_DBAREA, aStrName ); - } + const::rtl::OUString& aStrName = itr->GetName(); + InsertContent(SC_CONTENT_DBAREA, aStrName); } } @@ -995,10 +987,9 @@ sal_Bool ScContentTree::DrawNamesChanged( sal_uInt16 nType ) return !bEqual; } -sal_Bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRange& rRange ) +bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRange& rRange ) { - sal_Bool bFound = false; - sal_uInt16 nPos; + bool bFound = false; if ( nType == SC_CONTENT_RANGENAME ) { @@ -1014,15 +1005,18 @@ sal_Bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, { ScDBCollection* pList = pDoc->GetDBCollection(); if (pList) - if (pList->SearchName( rName, nPos )) + { + const ScDBData* p = pList->getNamedDBs().findByName(rName); + if (p) { SCTAB nTab; SCCOL nCol1, nCol2; SCROW nRow1, nRow2; - (*pList)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2); - rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab ); - bFound = sal_True; + p->GetArea(nTab, nCol1, nRow1, nCol2, nRow2); + rRange = ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab); + bFound = true; } + } } return bFound; diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx index 191156c78..ef9759a06 100644 --- a/sc/source/ui/navipi/navipi.cxx +++ b/sc/source/ui/navipi/navipi.cxx @@ -48,7 +48,7 @@ #include "tabvwsh.hxx" #include "docsh.hxx" #include "document.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "rangenam.hxx" #include "rangeutl.hxx" #include "popmenu.hxx" diff --git a/sc/source/ui/navipi/scenwnd.cxx b/sc/source/ui/navipi/scenwnd.cxx index 377f4a850..56cfa4783 100644 --- a/sc/source/ui/navipi/scenwnd.cxx +++ b/sc/source/ui/navipi/scenwnd.cxx @@ -64,15 +64,12 @@ ScScenarioListBox::~ScScenarioListBox() { } -void ScScenarioListBox::UpdateEntries( List* pNewEntryList ) +void ScScenarioListBox::UpdateEntries( const std::vector<String> &aNewEntryList ) { Clear(); maEntries.clear(); - if( !pNewEntryList ) - return; - - switch( pNewEntryList->Count() ) + switch( aNewEntryList.size() ) { case 0: // no scenarios in current sheet @@ -81,31 +78,33 @@ void ScScenarioListBox::UpdateEntries( List* pNewEntryList ) case 1: // sheet is a scenario container, comment only - mrParent.SetComment( *static_cast< String* >( pNewEntryList->First() ) ); + mrParent.SetComment( aNewEntryList[0] ); break; default: { // sheet contains scenarios - DBG_ASSERT( pNewEntryList->Count() % 3 == 0, "ScScenarioListBox::UpdateEntries - wrong list size" ); + DBG_ASSERT( aNewEntryList.size() % 3 == 0, "ScScenarioListBox::UpdateEntries - wrong list size" ); SetUpdateMode( false ); - String* pEntry = static_cast< String* >( pNewEntryList->First() ); - while( pEntry ) + + std::vector<String>::const_iterator iter; + for (iter = aNewEntryList.begin(); iter != aNewEntryList.end(); ++iter) { ScenarioEntry aEntry; // first entry of a triple is the scenario name - aEntry.maName = *pEntry; + aEntry.maName = *iter; + // second entry of a triple is the scenario comment - if( (pEntry = static_cast< String* >( pNewEntryList->Next() )) != 0 ) - aEntry.maComment = *pEntry; + ++iter; + aEntry.maComment = *iter; + // third entry of a triple is the protection ("0" = not protected, "1" = protected) - if( (pEntry = static_cast< String* >( pNewEntryList->Next() )) != 0 ) - aEntry.mbProtected = (pEntry->Len() > 0) && (pEntry->GetChar( 0 ) != '0'); + ++iter; + aEntry.mbProtected = (iter->Len() > 0) && (iter->GetChar( 0 ) != '0'); maEntries.push_back( aEntry ); InsertEntry( aEntry.maName, LISTBOX_APPEND ); - pEntry = static_cast< String* >( pNewEntryList->Next() ); } SetUpdateMode( sal_True ); SetNoSelection(); diff --git a/sc/source/ui/optdlg/opredlin.cxx b/sc/source/ui/optdlg/opredlin.cxx index 03d966db9..8c88e2298 100644 --- a/sc/source/ui/optdlg/opredlin.cxx +++ b/sc/source/ui/optdlg/opredlin.cxx @@ -159,8 +159,6 @@ sal_Bool ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ ) void ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ ) { - - XColorTable* pColorTbl = XColorTable::GetStdColorTable(); aContentColorLB.InsertEntry(aAuthorStr); aMoveColorLB.InsertEntry(aAuthorStr); aInsertColorLB.InsertEntry(aAuthorStr); @@ -171,9 +169,10 @@ void ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ ) aInsertColorLB.SetUpdateMode( false); aRemoveColorLB.SetUpdateMode( false); - for( sal_uInt16 i = 0; i < pColorTbl->Count(); ++i ) + XColorTable& rColorTbl = XColorTable::GetStdColorTable(); + for( sal_uInt16 i = 0; i < rColorTbl.Count(); ++i ) { - XColorEntry* pEntry = pColorTbl->GetColor( i ); + XColorEntry* pEntry = rColorTbl.GetColor( i ); Color aColor = pEntry->GetColor(); String sName = pEntry->GetName(); diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx index 9bbc4452f..ce555fe2e 100644 --- a/sc/source/ui/optdlg/tpview.cxx +++ b/sc/source/ui/optdlg/tpview.cxx @@ -335,7 +335,7 @@ void ScTpContentOptions::InitGridOpt() pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); } else - pColorTable = XColorTable::GetStdColorTable(); + pColorTable = &XColorTable::GetStdColorTable(); if ( !pColorTable ) return; diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src index 91ece5695..fa9a9df23 100644 --- a/sc/source/ui/src/globstr.src +++ b/sc/source/ui/src/globstr.src @@ -363,7 +363,7 @@ Resource RID_GLOBSTR }; String STR_UNDO_TRANSLITERATE { - Text [ en-US ] = "Case/Characters"; + Text [ en-US ] = "~Change Case"; }; String STR_DB_NONAME { diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src index a73f582f7..5a210d004 100644 --- a/sc/source/ui/src/optdlg.src +++ b/sc/source/ui/src/optdlg.src @@ -480,7 +480,7 @@ TabPage RID_SCPAGE_CONTENT HelpID = "sc:CheckBox:RID_SCPAGE_CONTENT:CB_GUIDELINE"; Pos = MAP_APPFONT ( 12 , 56 ) ; Size = MAP_APPFONT ( 112 , 10 ) ; - Text [ en-US ] = "Guides ~while moving"; + Text [ en-US ] = "Helplines ~While Moving"; }; CheckBox CB_HANDLES { diff --git a/sc/source/ui/undo/refundo.cxx b/sc/source/ui/undo/refundo.cxx index d49fa3f45..7bb6dc5f7 100644 --- a/sc/source/ui/undo/refundo.cxx +++ b/sc/source/ui/undo/refundo.cxx @@ -38,7 +38,7 @@ #include "refundo.hxx" #include "undobase.hxx" #include "document.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "rangenam.hxx" #include "pivot.hxx" #include "chartarr.hxx" diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index cac407515..4c8170df0 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -41,7 +41,7 @@ #include "tabvwsh.hxx" #include "undoolk.hxx" #include "undodraw.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "attrib.hxx" #include "queryparam.hxx" #include "subtotalparam.hxx" diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 71dded2b6..868ecadef 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -50,7 +50,7 @@ #include "tabvwsh.hxx" #include "rangenam.hxx" #include "rangeutl.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "stlpool.hxx" #include "stlsheet.hxx" #include "globstr.hrc" diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index 8b8f56d18..29417af8a 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -40,7 +40,7 @@ #include "docsh.hxx" #include "tabvwsh.hxx" #include "olinetab.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "rangenam.hxx" #include "pivot.hxx" #include "globstr.hrc" @@ -1090,7 +1090,7 @@ sal_Bool ScUndoQuery::CanRepeat(SfxRepeatTarget& /* rTarget */) const // ScUndoAutoFilter::ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange, - const String& rName, sal_Bool bSet ) : + const ::rtl::OUString& rName, bool bSet ) : ScDBFuncUndo( pNewDocShell, rRange ), aDBName( rName ), bFilterSet( bSet ) @@ -1106,14 +1106,13 @@ String ScUndoAutoFilter::GetComment() const return ScGlobal::GetRscString( STR_UNDO_QUERY ); // same as ScUndoQuery } -void ScUndoAutoFilter::DoChange( sal_Bool bUndo ) +void ScUndoAutoFilter::DoChange( bool bUndo ) { - sal_Bool bNewFilter = bUndo ? !bFilterSet : bFilterSet; + bool bNewFilter = bUndo ? !bFilterSet : bFilterSet; - sal_uInt16 nIndex; ScDocument* pDoc = pDocShell->GetDocument(); ScDBData* pDBData=NULL; - if (rtl::OUString(aDBName) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME))) + if (aDBName.equalsAscii(STR_DB_LOCAL_NONAME)) { SCTAB nTab = aOriginalRange.aStart.Tab(); pDBData = pDoc->GetAnonymousDBData(nTab); @@ -1121,11 +1120,9 @@ void ScUndoAutoFilter::DoChange( sal_Bool bUndo ) else { ScDBCollection* pColl = pDoc->GetDBCollection(); - if (pColl->SearchName( aDBName, nIndex )) - pDBData = (*pColl)[nIndex]; + pDBData = pColl->getNamedDBs().findByName(aDBName); } - if ( pDBData ) { pDBData->SetAutoFilter( bNewFilter ); @@ -1901,17 +1898,9 @@ void ScUndoConsolidate::Undo() ScDBCollection* pColl = pDoc->GetDBCollection(); if (pColl) { - sal_uInt16 nIndex; - if (pColl->SearchName( pUndoData->GetName(), nIndex )) - { - ScDBData* pDocData = (*pColl)[nIndex]; - if (pDocData) - *pDocData = *pUndoData; - } - else - { - OSL_FAIL("alte DB-Daten nicht gefunden"); - } + ScDBData* pDocData = pColl->getNamedDBs().findByName(pUndoData->GetName()); + if (pDocData) + *pDocData = *pUndoData; } } diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx index 1edbdc5c3..f0191e7ff 100644 --- a/sc/source/ui/undo/undoutil.cxx +++ b/sc/source/ui/undo/undoutil.cxx @@ -40,7 +40,7 @@ #include "docsh.hxx" #include "tabvwsh.hxx" #include "document.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "globstr.hrc" #include "globalnames.hxx" #include "global.hxx" diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 3273ab0b4..e146efa01 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -101,7 +101,7 @@ #include "undotab.hxx" #include "undoblk.hxx" // fuer lcl_ApplyBorder - nach docfunc verschieben! #include "stlsheet.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "attrib.hxx" #include "chartarr.hxx" #include "chartlis.hxx" diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 0e7fcfaf4..651688654 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -53,7 +53,7 @@ #include "miscuno.hxx" #include "targuno.hxx" #include "rangeutl.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "docsh.hxx" #include "dbdocfun.hxx" #include "unonames.hxx" @@ -67,6 +67,8 @@ #include <comphelper/servicehelper.hxx> #include <svx/dataaccessdescriptor.hxx> +#include <limits> + using namespace com::sun::star; SV_IMPL_PTRARR( XDBRefreshListenerArr_Impl, XDBRefreshListenerPtr ); @@ -1657,9 +1659,9 @@ ScDBData* ScDatabaseRangeObj::GetDBData_Impl() const ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); if (pNames) { - sal_uInt16 nPos = 0; - if (pNames->SearchName( aName, nPos )) - pRet = (*pNames)[nPos]; + ScDBData* p = pNames->getNamedDBs().findByName(aName); + if (p) + pRet = p; } } } @@ -1682,7 +1684,7 @@ void SAL_CALL ScDatabaseRangeObj::setName( const rtl::OUString& aNewName ) { ScDBDocFunc aFunc(*pDocShell); String aNewStr(aNewName); - sal_Bool bOk = aFunc.RenameDBRange( aName, aNewStr, sal_True ); + sal_Bool bOk = aFunc.RenameDBRange( aName, aNewStr ); if (bOk) aName = aNewStr; } @@ -1720,7 +1722,7 @@ void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aD aNewData.SetArea( aDataArea.Sheet, (SCCOL)aDataArea.StartColumn, (SCROW)aDataArea.StartRow, (SCCOL)aDataArea.EndColumn, (SCROW)aDataArea.EndRow ); ScDBDocFunc aFunc(*pDocShell); - aFunc.ModifyDBData(aNewData, sal_True); + aFunc.ModifyDBData(aNewData); } } @@ -1792,7 +1794,7 @@ void ScDatabaseRangeObj::SetQueryParam(const ScQueryParam& rQueryParam) aNewData.SetQueryParam(aParam); aNewData.SetHeader(aParam.bHasHeader); // not in ScDBData::SetQueryParam ScDBDocFunc aFunc(*pDocShell); - aFunc.ModifyDBData(aNewData, sal_True); + aFunc.ModifyDBData(aNewData); } } @@ -1852,7 +1854,7 @@ void ScDatabaseRangeObj::SetSubTotalParam(const ScSubTotalParam& rSubTotalParam) ScDBData aNewData( *pData ); aNewData.SetSubTotalParam(aParam); ScDBDocFunc aFunc(*pDocShell); - aFunc.ModifyDBData(aNewData, sal_True); + aFunc.ModifyDBData(aNewData); } } @@ -2068,7 +2070,7 @@ void SAL_CALL ScDatabaseRangeObj::setPropertyValue( if (bDo) { ScDBDocFunc aFunc(*pDocShell); - aFunc.ModifyDBData(aNewData, sal_True); + aFunc.ModifyDBData(aNewData); } } } @@ -2199,15 +2201,22 @@ void ScDatabaseRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) // XDatabaseRanges -ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex) +ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(size_t nIndex) { - if (pDocShell) - { - ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); - if (pNames && nIndex < pNames->GetCount()) - return new ScDatabaseRangeObj( pDocShell, (*pNames)[nIndex]->GetName() ); - } - return NULL; + if (!pDocShell) + return NULL; + + ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); + if (!pNames) + return NULL; + + const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs(); + if (rDBs.empty() || nIndex >= rDBs.size()) + return NULL; + + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(); + ::std::advance(itr, nIndex); // boundary check is done above. + return new ScDatabaseRangeObj(pDocShell, itr->GetName()); } ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByName_Impl(const rtl::OUString& aName) @@ -2249,7 +2258,7 @@ void SAL_CALL ScDatabaseRangesObj::removeByName( const rtl::OUString& aName ) { ScDBDocFunc aFunc(*pDocShell); String aString(aName); - bDone = aFunc.DeleteDBRange( aString, sal_True ); + bDone = aFunc.DeleteDBRange( aString ); } if (!bDone) throw uno::RuntimeException(); // no other exceptions specified @@ -2276,7 +2285,7 @@ sal_Int32 SAL_CALL ScDatabaseRangesObj::getCount() throw(uno::RuntimeException) { ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); if (pNames) - return pNames->GetCount(); + return static_cast<sal_Int32>(pNames->getNamedDBs().size()); } return 0; } @@ -2286,7 +2295,11 @@ uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex ) lang::WrappedTargetException, uno::RuntimeException) { SolarMutexGuard aGuard; - uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex)); + sal_Int32 nUpper = ::std::numeric_limits<size_t>::max(); + if (nIndex < 0 || nIndex > nUpper) + throw lang::IndexOutOfBoundsException(); + + uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl(static_cast<size_t>(nIndex))); if (xRange.is()) return uno::makeAny(xRange); else @@ -2332,12 +2345,11 @@ uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangesObj::getElementNames() ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); if (pNames) { - sal_uInt16 nCount = pNames->GetCount(); - String aName; - uno::Sequence<rtl::OUString> aSeq(nCount); - rtl::OUString* pAry = aSeq.getArray(); - for (sal_uInt16 i=0; i<nCount; i++) - pAry[i] = (*pNames)[i]->GetName(); + const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs(); + uno::Sequence<rtl::OUString> aSeq(rDBs.size()); + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (size_t i = 0; itr != itrEnd; ++itr, ++i) + aSeq[i] = itr->GetName(); return aSeq; } @@ -2356,12 +2368,7 @@ sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const rtl::OUString& aName ) { ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); if (pNames) - { - String aString(aName); - sal_uInt16 nPos = 0; - if (pNames->SearchName( aString, nPos )) - return sal_True; - } + return pNames->getNamedDBs().findByName(aName) != NULL; } return false; } diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx index ab43db95e..a2001cb7d 100644 --- a/sc/source/ui/unoobj/dispuno.cxx +++ b/sc/source/ui/unoobj/dispuno.cxx @@ -44,7 +44,7 @@ #include "dispuno.hxx" #include "tabvwsh.hxx" #include "dbdocfun.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" using namespace com::sun::star; diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 7e1694d85..457e79f51 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -287,7 +287,7 @@ void ScTableConditionalFormat::AddEntry_Impl(const ScCondFormatEntryItem& aEntry ScTableConditionalEntry* ScTableConditionalFormat::GetObjectByIndex_Impl(sal_uInt16 nIndex) const { - return aEntries[nIndex]; + return nIndex < aEntries.size() ? aEntries[nIndex] : NULL; } void SAL_CALL ScTableConditionalFormat::addNew( diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index fef83bb9e..4076ba874 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -137,7 +137,7 @@ #include <scitems.hxx> #include <svl/srchitem.hxx> #include <cellsuno.hxx> -#include <dbcolect.hxx> +#include <dbdata.hxx> #include "docfunc.hxx" #include <docuno.hxx> diff --git a/sc/source/ui/vba/vbasheetobjects.cxx b/sc/source/ui/vba/vbasheetobjects.cxx index b05aa8272..b3507448d 100644 --- a/sc/source/ui/vba/vbasheetobjects.cxx +++ b/sc/source/ui/vba/vbasheetobjects.cxx @@ -342,8 +342,8 @@ uno::Any SAL_CALL ScVbaGraphicObjectsBase::Add( const uno::Any& rLeft, const uno /* Extract double values from passed Anys (the lclPointsToHmm() helper function will throw a RuntimeException on any error), and convert from points to 1/100 mm. */ - awt::Point aPos( lclPointsToHmm( rLeft ), lclPointsToHmm( rTop ) ); - awt::Size aSize( lclPointsToHmm( rWidth ), lclPointsToHmm( rHeight ) ); + awt::Point aPos( static_cast<sal_Int32>(lclPointsToHmm( rLeft )), static_cast<sal_Int32>(lclPointsToHmm( rTop )) ); + awt::Size aSize( static_cast<sal_Int32>(lclPointsToHmm( rWidth )), static_cast<sal_Int32>(lclPointsToHmm( rHeight )) ); // TODO: translate coordinates for RTL sheets if( (aPos.X < 0) || (aPos.Y < 0) || (aSize.Width <= 0) || (aSize.Height <= 0) ) throw uno::RuntimeException(); diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index 5d6c875c8..d79512886 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -735,8 +735,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) case SID_SELECT_SCENARIO: { - List aList; - + std::vector<String> aList; Color aDummyCol; if ( !pDoc->IsScenario(nTab) ) @@ -750,12 +749,12 @@ void ScCellShell::GetState(SfxItemSet &rSet) while ( pDoc->IsScenario(nScTab) ) { pDoc->GetName( nScTab, aStr ); - aList.Insert( new String( aStr ), LIST_APPEND ); + aList.push_back(aStr); pDoc->GetScenarioData( nScTab, aStr, aDummyCol, nFlags ); - aList.Insert( new String( aStr ), LIST_APPEND ); + aList.push_back(aStr); // Protection is sal_True if both Sheet and Scenario are protected aProtect = (bSheetProtected && (nFlags & SC_SCENARIO_PROTECT)) ? '1' : '0'; - aList.Insert( new String( aProtect), LIST_APPEND ); + aList.push_back(aProtect); ++nScTab; } } @@ -764,15 +763,11 @@ void ScCellShell::GetState(SfxItemSet &rSet) String aComment; sal_uInt16 nDummyFlags; pDoc->GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags ); - DBG_ASSERT( aList.Count() == 0, "List not empty!" ); - aList.Insert( new String( aComment ) ); + DBG_ASSERT( aList.empty(), "List not empty!" ); + aList.push_back(aComment); } rSet.Put( SfxStringListItem( nWhich, &aList ) ); - - sal_uLong nCount = aList.Count(); - for ( sal_uLong i=0; i<nCount; i++ ) - delete (String*) aList.GetObject(i); } break; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 30d39333b..b315c511a 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -98,7 +98,7 @@ #include "dpobject.hxx" #include "dpsdbtab.hxx" // ScImportSourceDesc #include "dpshttab.hxx" // ScSheetSourceDesc -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "docsh.hxx" #include "globstr.hrc" diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 64fc2a391..91a48beca 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -723,26 +723,11 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) if ( pDBCol ) { - const String aStrNoName( RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME) ); - List aList; - sal_uInt16 nDBCount = pDBCol->GetCount(); - ScDBData* pDbData = NULL; - String* pDBName = NULL; - - for ( sal_uInt16 i=0; i < nDBCount; i++ ) - { - pDbData = (ScDBData*)(pDBCol->At( i )); - if ( pDbData ) - { - pDBName = new String; - *pDBName = pDbData->GetName(); - - if ( *pDBName != aStrNoName ) - aList.Insert( pDBName ); - else - DELETEZ(pDBName); - } - } + List aList; + const ScDBCollection::NamedDBs& rDBs = pDBCol->getNamedDBs(); + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; itr != itrEnd; ++itr) + aList.Insert(new String(itr->GetName())); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); DBG_ASSERT(pFact, "ScAbstractFactory create fail!"); diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx index 96530c9e2..a8a504990 100644 --- a/sc/source/ui/view/dbfunc.cxx +++ b/sc/source/ui/view/dbfunc.cxx @@ -45,7 +45,7 @@ #include "attrib.hxx" #include "sc.hrc" #include "undodat.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "globstr.hrc" #include "global.hxx" #include "dbdocfun.hxx" @@ -66,35 +66,28 @@ ScDBFunc::~ScDBFunc() // Hilfsfunktionen // -void ScDBFunc::GotoDBArea( const String& rDBName ) +void ScDBFunc::GotoDBArea( const ::rtl::OUString& rDBName ) { ScDocument* pDoc = GetViewData()->GetDocument(); ScDBCollection* pDBCol = pDoc->GetDBCollection(); - - sal_uInt16 nFoundAt = 0; - if ( pDBCol->SearchName( rDBName, nFoundAt ) ) + ScDBData* pData = pDBCol->getNamedDBs().findByName(rDBName); + if (pData) { - ScDBData* pData = (*pDBCol)[nFoundAt]; - DBG_ASSERT( pData, "GotoDBArea: Datenbankbereich nicht gefunden!" ); - - if ( pData ) - { - SCTAB nTab = 0; - SCCOL nStartCol = 0; - SCROW nStartRow = 0; - SCCOL nEndCol = 0; - SCROW nEndRow = 0; - - pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); - SetTabNo( nTab ); - - MoveCursorAbs( nStartCol, nStartRow, ScFollowMode( SC_FOLLOW_JUMP ), - false, false ); // bShift,bControl - DoneBlockMode(); - InitBlockMode( nStartCol, nStartRow, nTab ); - MarkCursor( nEndCol, nEndRow, nTab ); - SelectionChanged(); - } + SCTAB nTab = 0; + SCCOL nStartCol = 0; + SCROW nStartRow = 0; + SCCOL nEndCol = 0; + SCROW nEndRow = 0; + + pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); + SetTabNo( nTab ); + + MoveCursorAbs( nStartCol, nStartRow, ScFollowMode( SC_FOLLOW_JUMP ), + false, false ); // bShift,bControl + DoneBlockMode(); + InitBlockMode( nStartCol, nStartRow, nTab ); + MarkCursor( nEndCol, nEndRow, nTab ); + SelectionChanged(); } } diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 5f427a80c..6ec7521ab 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -59,7 +59,7 @@ #include "sc.hrc" #include "undotab.hxx" #include "undodat.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "rangenam.hxx" #include "rangeutl.hxx" #include "docsh.hxx" @@ -492,7 +492,7 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, sal_Bool bRecord, if (!pDocRange->empty()) pUndoRange = new ScRangeName( *pDocRange ); ScDBCollection* pDocDB = pDoc->GetDBCollection(); - if (pDocDB->GetCount()) + if (!pDocDB->empty()) pUndoDB = new ScDBCollection( *pDocDB ); } @@ -2277,7 +2277,7 @@ void ScDBFunc::RepeatDB( sal_Bool bRecord ) if (!pDocRange->empty()) pUndoRange = new ScRangeName( *pDocRange ); ScDBCollection* pDocDB = pDoc->GetDBCollection(); - if (pDocDB->GetCount()) + if (!pDocDB->empty()) pUndoDB = new ScDBCollection( *pDocDB ); } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index a14c9c270..cd7584231 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -84,7 +84,7 @@ #include "scmod.hxx" #include "document.hxx" #include "attrib.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "stlpool.hxx" #include "printfun.hxx" #include "cbutton.hxx" diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 7b3b01ca6..9c588e771 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -50,7 +50,7 @@ #include "document.hxx" #include "attrib.hxx" #include "patattr.hxx" // InvertSimple -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "docoptio.hxx" #include "notemark.hxx" #include "dbfunc.hxx" // oder GetPageBreakData an die ViewData diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index fdc39f5bd..9e8d97e64 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -74,7 +74,7 @@ #include "inputopt.hxx" #include "inputwin.hxx" #include "scresid.hxx" -#include "dbcolect.hxx" // fuer ReImport +#include "dbdata.hxx" // fuer ReImport #include "reffact.hxx" #include "viewuno.hxx" #include "dispuno.hxx" @@ -1642,17 +1642,19 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode ) } } - sal_Bool bReImport = false; // importierte Daten aktualisieren + bool bReImport = false; // importierte Daten aktualisieren ScDBCollection* pDBColl = pDoc->GetDBCollection(); if ( pDBColl ) { - sal_uInt16 nCount = pDBColl->GetCount(); - for (sal_uInt16 i=0; i<nCount && !bReImport; i++) + const ScDBCollection::NamedDBs& rDBs = pDBColl->getNamedDBs(); + ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end(); + for (; itr != itrEnd; ++itr) { - ScDBData* pData = (*pDBColl)[i]; - if ( pData->IsStripData() && - pData->HasImportParam() && !pData->HasImportSelection() ) - bReImport = sal_True; + if (itr->IsStripData() && itr->HasImportParam() && !itr->HasImportSelection()) + { + bReImport = true; + break; + } } } if (bReImport) diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index 74ee9d36e..215a65801 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -552,13 +552,12 @@ void ScTabViewShell::GetUndoState(SfxItemSet &rSet) SfxStringListItem aStrLst( nWhich ); if ( pUndoManager ) { - List* pList = aStrLst.GetList(); + std::vector<String> &aList = aStrLst.GetList(); sal_Bool bIsUndo = ( nWhich == SID_GETUNDOSTRINGS ); size_t nCount = bIsUndo ? pUndoManager->GetUndoActionCount() : pUndoManager->GetRedoActionCount(); for (size_t i=0; i<nCount; i++) - pList->Insert( new String( bIsUndo ? pUndoManager->GetUndoActionComment(i) : - pUndoManager->GetRedoActionComment(i) ), - LIST_APPEND ); + aList.push_back( bIsUndo ? pUndoManager->GetUndoActionComment(i) : + pUndoManager->GetRedoActionComment(i) ); } rSet.Put( aStrLst ); } diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index ec16f0f4a..00dc12fd4 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1632,22 +1632,6 @@ void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, } } - if ( nCommand == SVX_SEARCHCMD_REPLACE - || nCommand == SVX_SEARCHCMD_REPLACE_ALL ) - { - for ( SCTAB j = nStartTab; j <= nEndTab; j++ ) - { - if ( (bAllTables || rMark.GetTableSelect( j )) && - pDoc->IsTabProtected( j ) ) - { - if ( pOldSelectedTables ) - delete [] pOldSelectedTables; - ErrorMessage(STR_PROTECTIONERR); - return; - } - } - } - if ( nCommand == SVX_SEARCHCMD_FIND || nCommand == SVX_SEARCHCMD_FIND_ALL) bAddUndo = false; diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index f857b41be..43e73df86 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -166,7 +166,7 @@ #include "transobj.hxx" #include "drwtrans.hxx" #include "rangenam.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "impex.hxx" // Sylk-ID fuer CB #include "chgtrack.hxx" #include "waitoff.hxx" diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 818f3f560..48474282c 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -653,15 +653,15 @@ sal_Bool ScViewFunc::PasteFile( const Point& rPos, const String& rFile, sal_Bool sal_uInt16 nFilterFormat; Graphic aGraphic; - GraphicFilter* pGraphicFilter = GraphicFilter::GetGraphicFilter(); + GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter(); - if (!pGraphicFilter->ImportGraphic(aGraphic, aURL, + if (!rGraphicFilter.ImportGraphic(aGraphic, aURL, GRFILTER_FORMAT_DONTKNOW, &nFilterFormat )) { if ( bLink ) { - String aFltName = pGraphicFilter->GetImportFormatName(nFilterFormat); + String aFltName = rGraphicFilter.GetImportFormatName(nFilterFormat); return PasteGraphic( rPos, aGraphic, aStrURL, aFltName ); } else diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index 8499d1e51..a2e3c3007 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -68,7 +68,7 @@ #include "drawview.hxx" #include "impex.hxx" #include "dbfunc.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "sc.hrc" #include "filter.hxx" #include "scextopt.hxx" diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 85f7b06a0..eea615a40 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -68,7 +68,7 @@ #include "undoblk.hxx" #include "undotab.hxx" #include "refundo.hxx" -#include "dbcolect.hxx" +#include "dbdata.hxx" #include "olinetab.hxx" #include "rangeutl.hxx" #include "rangenam.hxx" |