summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/dpcachetable.cxx72
-rw-r--r--sc/source/core/data/dpobject.cxx192
-rw-r--r--sc/source/core/data/dpoutput.cxx208
-rw-r--r--sc/source/core/data/dpsdbtab.cxx116
-rw-r--r--sc/source/core/data/dpshttab.cxx18
-rw-r--r--sc/source/core/data/dptablecache.cxx95
-rw-r--r--sc/source/core/data/scdpoutputimpl.cxx184
-rw-r--r--sc/source/core/data/scdpoutputimpl.hxx79
8 files changed, 509 insertions, 455 deletions
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 67b55e7f0155..b177acff7be7 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -73,6 +73,17 @@ static sal_Bool lcl_HasQueryEntry( const ScQueryParam& rParam )
// ----------------------------------------------------------------------------
+bool ScDPCacheTable::RowFlag::isActive() const
+{
+ return mbShowByFilter && mbShowByPage;
+}
+
+ScDPCacheTable::RowFlag::RowFlag() :
+ mbShowByFilter(true),
+ mbShowByPage(true)
+{
+}
+
ScDPCacheTable::FilterItem::FilterItem() :
mfValue(0.0),
mbHasValue(false)
@@ -158,14 +169,13 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
-ScDPCacheTable::ScDPCacheTable(ScDPCache* pCache) :
+ScDPCacheTable::ScDPCacheTable(const ScDPCache* pCache) :
mpCache(pCache)
{
}
ScDPCacheTable::~ScDPCacheTable()
{
- delete mpCache;
}
sal_Int32 ScDPCacheTable::getRowSize() const
@@ -181,13 +191,13 @@ sal_Int32 ScDPCacheTable::getColSize() const
void ScDPCacheTable::fillTable(
const ScQueryParam& rQuery, bool* pSpecial, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
{
- const SCROW nRowCount = getRowSize();
- const SCCOL nColCount = (SCCOL) getColSize();
- if ( nRowCount <= 0 || nColCount <= 0)
+ const SCROW nRowCount = getRowSize();
+ const SCCOL nColCount = (SCCOL) getColSize();
+ if ( nRowCount <= 0 || nColCount <= 0)
return;
- maRowsVisible.clear();
- maRowsVisible.reserve(nRowCount);
+ maRowFlags.clear();
+ maRowFlags.reserve(nRowCount);
// Initialize field entries container.
maFieldEntries.clear();
@@ -199,7 +209,7 @@ void ScDPCacheTable::fillTable(
SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
if ( nMemCount )
{
- std::vector< SCROW > pAdded( nMemCount, -1 );
+ std::vector<SCROW> aAdded( nMemCount, -1 );
for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
{
@@ -207,24 +217,27 @@ void ScDPCacheTable::fillTable(
SCROW nOrder = getOrder( nCol, nIndex );
if ( nCol == 0 )
- maRowsVisible.push_back(false);
+ {
+ maRowFlags.push_back(RowFlag());
+ maRowFlags.back().mbShowByFilter = false;
+ }
if ( lcl_HasQueryEntry(rQuery) &&
!getCache()->ValidQuery( nRow , rQuery, pSpecial ) )
continue;
if ( bIgnoreEmptyRows && getCache()->IsRowEmpty( nRow ) )
continue;
- // Insert a new row into cache table.
+
if ( nCol == 0 )
- maRowsVisible.back() = true;
+ maRowFlags.back().mbShowByFilter = true;
- pAdded[nOrder] = nIndex;
+ aAdded[nOrder] = nIndex;
}
maFieldEntries.push_back( vector<SCROW>() );
for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
{
- if ( pAdded[nRow] != -1 )
- maFieldEntries.back().push_back( pAdded[nRow] );
+ if ( aAdded[nRow] != -1 )
+ maFieldEntries.back().push_back( aAdded[nRow] );
}
}
}
@@ -237,8 +250,8 @@ void ScDPCacheTable::fillTable()
if ( nRowCount <= 0 || nColCount <= 0)
return;
- maRowsVisible.clear();
- maRowsVisible.reserve(nRowCount);
+ maRowFlags.clear();
+ maRowFlags.reserve(nRowCount);
// Initialize field entries container.
@@ -259,8 +272,10 @@ void ScDPCacheTable::fillTable()
SCROW nOrder = getOrder( nCol, nIndex );
if ( nCol == 0 )
- maRowsVisible.push_back(true);
-
+ {
+ maRowFlags.push_back(RowFlag());
+ maRowFlags.back().mbShowByFilter = true;
+ }
pAdded[nOrder] = nIndex;
}
@@ -276,24 +291,24 @@ void ScDPCacheTable::fillTable()
bool ScDPCacheTable::isRowActive(sal_Int32 nRow) const
{
- if (nRow < 0 || static_cast<size_t>(nRow) >= maRowsVisible.size())
+ if (nRow < 0 || static_cast<size_t>(nRow) >= maRowFlags.size())
// row index out of bound
return false;
- return maRowsVisible[nRow];
+ return maRowFlags[nRow].isActive();
}
void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
{
sal_Int32 nRowSize = getRowSize();
- if (nRowSize != static_cast<sal_Int32>(maRowsVisible.size()))
+ if (nRowSize != static_cast<sal_Int32>(maRowFlags.size()))
{
// sizes of the two tables differ!
return;
}
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
- maRowsVisible[nRow] = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
+ maRowFlags[nRow].mbShowByPage = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
}
const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
@@ -359,7 +374,7 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
{
- if (!maRowsVisible[nRow])
+ if (!maRowFlags[nRow].isActive())
// This row is filtered out.
continue;
@@ -401,8 +416,7 @@ SCROW ScDPCacheTable::getOrder(long nDim, SCROW nIndex) const
void ScDPCacheTable::clear()
{
maFieldEntries.clear();
- maRowsVisible.clear();
- delete mpCache;
+ maRowFlags.clear();
mpCache = NULL;
}
@@ -411,9 +425,8 @@ bool ScDPCacheTable::empty() const
return mpCache == NULL || maFieldEntries.empty();
}
-void ScDPCacheTable::setCache(ScDPCache* p)
+void ScDPCacheTable::setCache(const ScDPCache* p)
{
- delete mpCache;
mpCache = p;
}
@@ -448,9 +461,4 @@ const ScDPCache* ScDPCacheTable::getCache() const
return mpCache;
}
-ScDPCache* ScDPCacheTable::getCache()
-{
- return mpCache;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 97e2f0db1bbc..9589fe838f7a 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -54,6 +54,7 @@
#include "dpglobal.hxx"
#include "globstr.hrc"
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XCompletedExecution.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
@@ -70,13 +71,15 @@
#include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
#include <sal/macros.h>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <svl/zforlist.hxx> // IsNumberFormat
+#include <vcl/msgbox.hxx>
#include <vector>
-#include <stdio.h>
+#include <memory>
using namespace com::sun::star;
using ::std::vector;
@@ -95,6 +98,13 @@ using ::com::sun::star::sheet::XDimensionsSupplier;
using ::com::sun::star::beans::XPropertySet;
using ::rtl::OUString;
+#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
+#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
+
+#define SC_DBPROP_DATASOURCENAME "DataSourceName"
+#define SC_DBPROP_COMMAND "Command"
+#define SC_DBPROP_COMMANDTYPE "CommandType"
+
// -----------------------------------------------------------------------
#define SCDPSOURCE_SERVICE "com.sun.star.sheet.DataPilotSource"
@@ -417,7 +427,7 @@ ScDPTableData* ScDPObject::GetTableData()
OSL_FAIL("no source descriptor");
pSheetDesc = new ScSheetSourceDesc(pDoc); // dummy defaults
}
- ScDPCache* pCache = pSheetDesc->CreateCache();
+ const ScDPCache* pCache = pSheetDesc->CreateCache();
if (pCache)
pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, pCache));
}
@@ -1843,17 +1853,20 @@ sal_Bool ScDPObject::FillOldParam(ScPivotParam& rParam) const
rParam.nTab = aOutRange.aStart.Tab();
// ppLabelArr / nLabels is not changed
- SCCOL nColAdd = pSheetDesc->GetSourceRange().aStart.Col();
+ SCCOL nSrcColOffset = 0;
+ if (IsSheetData())
+ // source data column offset is only for internal sheet source.
+ nSrcColOffset = pSheetDesc->GetSourceRange().aStart.Col();
bool bAddData = ( lcl_GetDataGetOrientation( xSource ) == sheet::DataPilotFieldOrientation_HIDDEN );
lcl_FillOldFields(
- rParam.maPageFields, xSource, sheet::DataPilotFieldOrientation_PAGE, nColAdd, false);
+ rParam.maPageFields, xSource, sheet::DataPilotFieldOrientation_PAGE, nSrcColOffset, false);
lcl_FillOldFields(
- rParam.maColFields, xSource, sheet::DataPilotFieldOrientation_COLUMN, nColAdd, bAddData);
+ rParam.maColFields, xSource, sheet::DataPilotFieldOrientation_COLUMN, nSrcColOffset, bAddData);
lcl_FillOldFields(
- rParam.maRowFields, xSource, sheet::DataPilotFieldOrientation_ROW, nColAdd, false);
+ rParam.maRowFields, xSource, sheet::DataPilotFieldOrientation_ROW, nSrcColOffset, false);
lcl_FillOldFields(
- rParam.maDataFields, xSource, sheet::DataPilotFieldOrientation_DATA, nColAdd, false);
+ rParam.maDataFields, xSource, sheet::DataPilotFieldOrientation_DATA, nSrcColOffset, false);
uno::Reference<beans::XPropertySet> xProp( xSource, uno::UNO_QUERY );
if (xProp.is())
@@ -2383,15 +2396,148 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS
return xRet;
}
-// ----------------------------------------------------------------------------
+ScDPCollection::SheetCaches::SheetCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
+
+const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange)
+{
+ CachesType::const_iterator itr = maCaches.find(rRange);
+ if (itr != maCaches.end())
+ // already cached.
+ return itr->second;
+
+ ::std::auto_ptr<ScDPCache> pCache(new ScDPCache(mpDoc));
+ pCache->InitFromDoc(mpDoc, rRange);
+ const ScDPCache* p = pCache.get();
+ maCaches.insert(rRange, pCache);
+ return p;
+}
+
+void ScDPCollection::SheetCaches::removeCache(const ScRange& rRange)
+{
+ CachesType::iterator itr = maCaches.find(rRange);
+ if (itr != maCaches.end())
+ maCaches.erase(itr);
+}
+
+ScDPCollection::NameCaches::NameCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
+
+const ScDPCache* ScDPCollection::NameCaches::getCache(const OUString& rName, const ScRange& rRange)
+{
+ CachesType::const_iterator itr = maCaches.find(rName);
+ if (itr != maCaches.end())
+ // already cached.
+ return itr->second;
+
+ ::std::auto_ptr<ScDPCache> pCache(new ScDPCache(mpDoc));
+ pCache->InitFromDoc(mpDoc, rRange);
+ const ScDPCache* p = pCache.get();
+ maCaches.insert(rName, pCache);
+ return p;
+}
+
+void ScDPCollection::NameCaches::removeCache(const OUString& rName)
+{
+ CachesType::iterator itr = maCaches.find(rName);
+ if (itr != maCaches.end())
+ maCaches.erase(itr);
+}
+
+ScDPCollection::DBType::DBType(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) :
+ mnSdbType(nSdbType), maDBName(rDBName), maCommand(rCommand) {}
+
+ScDPCollection::DBCaches::DBCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
+
+const ScDPCache* ScDPCollection::DBCaches::getCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand)
+{
+ DBType aType(nSdbType, rDBName, rCommand);
+ CachesType::const_iterator itr = maCaches.find(aType);
+ if (itr != maCaches.end())
+ // already cached.
+ return itr->second;
+
+ uno::Reference<sdbc::XRowSet> xRowSet ;
+ try
+ {
+ xRowSet = uno::Reference<sdbc::XRowSet>(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_ROWSET )) ),
+ uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY );
+ DBG_ASSERT( xRowProp.is(), "can't get RowSet" );
+ if ( xRowProp.is() )
+ {
+ //
+ // set source parameters
+ //
+ uno::Any aAny;
+ aAny <<= rDBName;
+ xRowProp->setPropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_DATASOURCENAME)), aAny );
+
+ aAny <<= rCommand;
+ xRowProp->setPropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMAND)), aAny );
+
+ aAny <<= nSdbType;
+ xRowProp->setPropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMANDTYPE)), aAny );
+
+ uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY );
+ if ( xExecute.is() )
+ {
+ uno::Reference<task::XInteractionHandler> xHandler(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_INTHANDLER )) ),
+ uno::UNO_QUERY);
+ xExecute->executeWithCompletion( xHandler );
+ }
+ else
+ xRowSet->execute();
+ }
+ }
+ catch ( sdbc::SQLException& rError )
+ {
+ //! store error message
+ InfoBox aInfoBox( 0, String(rError.Message) );
+ aInfoBox.Execute();
+ return NULL;
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_FAIL("Unexpected exception in database");
+ return NULL;
+ }
+
+ ::std::auto_ptr<ScDPCache> pCache(new ScDPCache(mpDoc));
+ SvNumberFormatter aFormat(mpDoc->GetServiceManager(), ScGlobal::eLnge);
+ pCache->InitFromDataBase(xRowSet, *aFormat.GetNullDate());
+ ::comphelper::disposeComponent(xRowSet);
+ const ScDPCache* p = pCache.get();
+ maCaches.insert(aType, pCache);
+ return p;
+}
+
+void ScDPCollection::DBCaches::removeCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand)
+{
+ DBType aType(nSdbType, rDBName, rCommand);
+ CachesType::iterator itr = maCaches.find(aType);
+ if (itr != maCaches.end())
+ maCaches.erase(itr);
+}
ScDPCollection::ScDPCollection(ScDocument* pDocument) :
- pDoc( pDocument )
+ pDoc( pDocument ),
+ maSheetCaches(pDocument),
+ maNameCaches(pDocument),
+ maDBCaches(pDocument)
{
}
ScDPCollection::ScDPCollection(const ScDPCollection& r) :
- pDoc(r.pDoc)
+ pDoc(r.pDoc),
+ maSheetCaches(r.pDoc),
+ maNameCaches(r.pDoc),
+ maDBCaches(r.pDoc)
{
}
@@ -2584,4 +2730,30 @@ bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
return pMergeAttr->HasDPTable();
}
+ScDPCollection::SheetCaches& ScDPCollection::GetSheetCaches()
+{
+ return maSheetCaches;
+}
+
+ScDPCollection::NameCaches& ScDPCollection::GetNameCaches()
+{
+ return maNameCaches;
+}
+
+ScDPCollection::DBCaches& ScDPCollection::GetDBCaches()
+{
+ return maDBCaches;
+}
+
+bool operator<(const ScDPCollection::DBType& left, const ScDPCollection::DBType& right)
+{
+ if (left.mnSdbType != right.mnSdbType)
+ return left.mnSdbType < right.mnSdbType;
+
+ if (!left.maDBName.equals(right.maDBName))
+ return left.maDBName < right.maDBName;
+
+ return left.maCommand < right.maCommand;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index c0455819285c..8351c2f3dd28 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -56,7 +56,6 @@
#include "scresid.hxx"
#include "unonames.hxx"
#include "sc.hrc"
-#include "scdpoutputimpl.hxx"
#include "dpglobal.hxx"
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -83,15 +82,16 @@ using ::rtl::OUString;
#define DP_PROP_POSITION "Position"
#define DP_PROP_USEDHIERARCHY "UsedHierarchy"
#define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension"
-#define DP_PROP_NUMBERFORMAT "NumberFormat"
#define DP_PROP_FILTER "Filter"
#define DP_PROP_COLUMNGRAND "ColumnGrand"
#define DP_PROP_ROWGRAND "RowGrand"
#define DP_PROP_SUBTOTALS "SubTotals"
-// -----------------------------------------------------------------------
+#define SC_DP_FRAME_INNER_BOLD 20
+#define SC_DP_FRAME_OUTER_BOLD 40
+
+#define SC_DP_FRAME_COLOR Color(0,0,0) //( 0x20, 0x40, 0x68 )
-//! dynamic!!!
#define SC_DPOUT_MAXLEVELS 256
struct ScDPOutLevelData
@@ -121,7 +121,187 @@ struct ScDPOutLevelData
//! bug (73840) in uno::Sequence - copy and then assign doesn't work!
};
-// -----------------------------------------------------------------------
+namespace {
+
+bool lcl_compareColfuc ( SCCOL i, SCCOL j) { return (i<j); }
+bool lcl_compareRowfuc ( SCROW i, SCROW j) { return (i<j); }
+
+class ScDPOutputImpl
+{
+ ScDocument* mpDoc;
+ sal_uInt16 mnTab;
+ ::std::vector< bool > mbNeedLineCols;
+ ::std::vector< SCCOL > mnCols;
+
+ ::std::vector< bool > mbNeedLineRows;
+ ::std::vector< SCROW > mnRows;
+
+ SCCOL mnTabStartCol;
+ SCROW mnTabStartRow;
+ SCCOL mnMemberStartCol;
+ SCROW mnMemberStartRow;
+
+ SCCOL mnDataStartCol;
+ SCROW mnDataStartRow;
+ SCCOL mnTabEndCol;
+ SCROW mnTabEndRow;
+
+public:
+ ScDPOutputImpl( ScDocument* pDoc, sal_uInt16 nTab,
+ SCCOL nTabStartCol,
+ SCROW nTabStartRow,
+ SCCOL nMemberStartCol,
+ SCROW nMemberStartRow,
+ SCCOL nDataStartCol,
+ SCROW nDataStartRow,
+ SCCOL nTabEndCol,
+ SCROW nTabEndRow );
+ bool AddRow( SCROW nRow );
+ bool AddCol( SCCOL nCol );
+
+ void OutputDataArea();
+ void OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bHori = false );
+
+};
+
+void ScDPOutputImpl::OutputDataArea()
+{
+ AddRow( mnDataStartRow );
+ AddCol( mnDataStartCol );
+
+ mnCols.push_back( mnTabEndCol+1); //set last row bottom
+ mnRows.push_back( mnTabEndRow+1); //set last col bottom
+
+ bool bAllRows = ( ( mnTabEndRow - mnDataStartRow + 2 ) == (SCROW) mnRows.size() );
+
+ std::sort( mnCols.begin(), mnCols.end(), lcl_compareColfuc );
+ std::sort( mnRows.begin(), mnRows.end(), lcl_compareRowfuc );
+
+ for( SCCOL nCol = 0; nCol < (SCCOL)mnCols.size()-1; nCol ++ )
+ {
+ if ( !bAllRows )
+ {
+ if ( nCol < (SCCOL)mnCols.size()-2)
+ {
+ for ( SCROW i = nCol%2; i < (SCROW)mnRows.size()-2; i +=2 )
+ OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
+ if ( mnRows.size()>=2 )
+ OutputBlockFrame( mnCols[nCol], mnRows[mnRows.size()-2], mnCols[nCol+1]-1, mnRows[mnRows.size()-1]-1 );
+ }
+ else
+ {
+ for ( SCROW i = 0 ; i < (SCROW)mnRows.size()-1; i++ )
+ OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
+ }
+ }
+ else
+ OutputBlockFrame( mnCols[nCol], mnRows.front(), mnCols[nCol+1]-1, mnRows.back()-1, bAllRows );
+ }
+ //out put rows area outer framer
+ if ( mnTabStartCol != mnDataStartCol )
+ {
+ if ( mnTabStartRow != mnDataStartRow )
+ OutputBlockFrame( mnTabStartCol, mnTabStartRow, mnDataStartCol-1, mnDataStartRow-1 );
+ OutputBlockFrame( mnTabStartCol, mnDataStartRow, mnDataStartCol-1, mnTabEndRow );
+ }
+ //out put cols area outer framer
+ OutputBlockFrame( mnDataStartCol, mnTabStartRow, mnTabEndCol, mnDataStartRow-1 );
+}
+
+ScDPOutputImpl::ScDPOutputImpl( ScDocument* pDoc, sal_uInt16 nTab,
+ SCCOL nTabStartCol,
+ SCROW nTabStartRow,
+ SCCOL nMemberStartCol,
+ SCROW nMemberStartRow,
+ SCCOL nDataStartCol,
+ SCROW nDataStartRow,
+ SCCOL nTabEndCol,
+ SCROW nTabEndRow ):
+ mpDoc( pDoc ),
+ mnTab( nTab ),
+ mnTabStartCol( nTabStartCol ),
+ mnTabStartRow( nTabStartRow ),
+ mnMemberStartCol( nMemberStartCol),
+ mnMemberStartRow( nMemberStartRow),
+ mnDataStartCol ( nDataStartCol ),
+ mnDataStartRow ( nDataStartRow ),
+ mnTabEndCol( nTabEndCol ),
+ mnTabEndRow( nTabEndRow )
+{
+ mbNeedLineCols.resize( nTabEndCol-nDataStartCol+1, false );
+ mbNeedLineRows.resize( nTabEndRow-nDataStartRow+1, false );
+
+}
+
+bool ScDPOutputImpl::AddRow( SCROW nRow )
+{
+ if ( !mbNeedLineRows[ nRow - mnDataStartRow ] )
+ {
+ mbNeedLineRows[ nRow - mnDataStartRow ] = true;
+ mnRows.push_back( nRow );
+ return true;
+ }
+ else
+ return false;
+}
+
+bool ScDPOutputImpl::AddCol( SCCOL nCol )
+{
+
+ if ( !mbNeedLineCols[ nCol - mnDataStartCol ] )
+ {
+ mbNeedLineCols[ nCol - mnDataStartCol ] = true;
+ mnCols.push_back( nCol );
+ return true;
+ }
+ else
+ return false;
+}
+
+void ScDPOutputImpl::OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bHori )
+{
+ Color color = SC_DP_FRAME_COLOR;
+ ::editeng::SvxBorderLine aLine( &color, SC_DP_FRAME_INNER_BOLD );
+ ::editeng::SvxBorderLine aOutLine( &color, SC_DP_FRAME_OUTER_BOLD );
+
+ SvxBoxItem aBox( ATTR_BORDER );
+
+ if ( nStartCol == mnTabStartCol )
+ aBox.SetLine(&aOutLine, BOX_LINE_LEFT);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_LEFT);
+
+ if ( nStartRow == mnTabStartRow )
+ aBox.SetLine(&aOutLine, BOX_LINE_TOP);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_TOP);
+
+ if ( nEndCol == mnTabEndCol ) //bottom row
+ aBox.SetLine(&aOutLine, BOX_LINE_RIGHT);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_RIGHT);
+
+ if ( nEndRow == mnTabEndRow ) //bottom
+ aBox.SetLine(&aOutLine, BOX_LINE_BOTTOM);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
+
+
+ SvxBoxInfoItem aBoxInfo( ATTR_BORDER_INNER );
+ aBoxInfo.SetValid(VALID_VERT,false );
+ if ( bHori )
+ {
+ aBoxInfo.SetValid(VALID_HORI,sal_True);
+ aBoxInfo.SetLine( &aLine, BOXINFO_LINE_HORI );
+ }
+ else
+ aBoxInfo.SetValid(VALID_HORI,false );
+
+ aBoxInfo.SetValid(VALID_DISTANCE,false);
+
+ mpDoc->ApplyFrameAreaTab( ScRange( nStartCol, nStartRow, mnTab, nEndCol, nEndRow , mnTab ), &aBox, &aBoxInfo );
+
+}
void lcl_SetStyleById( ScDocument* pDoc, SCTAB nTab,
SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
@@ -214,7 +394,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
aDataNames[nDataCount] = String( xDimName->getName() );
long nFormat = ScUnoHelpFunctions::GetLongProperty(
xDimProp,
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(DP_PROP_NUMBERFORMAT)) );
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)) );
nDataFormats[nDataCount] = nFormat;
if ( nFormat != 0 )
bAnySet = sal_True;
@@ -280,7 +460,7 @@ sal_uInt32 lcl_GetFirstNumberFormat( const uno::Reference<container::XIndexAcces
{
long nFormat = ScUnoHelpFunctions::GetLongProperty(
xDimProp,
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(DP_PROP_NUMBERFORMAT)) );
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)) );
return nFormat; // use format from first found data dimension
}
@@ -349,8 +529,10 @@ uno::Sequence<sheet::MemberResult> lcl_GetSelectedPageAsResult( const uno::Refer
return aRet;
}
+}
+
ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsSupplier>& xSrc,
- const ScAddress& rPos, sal_Bool bFilter ) :
+ const ScAddress& rPos, bool bFilter ) :
pDoc( pD ),
xSource( xSrc ),
aStartPos( rPos ),
@@ -526,7 +708,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
}
catch (uno::RuntimeException&)
{
- bResultsError = sal_True;
+ bResultsError = true;
}
}
@@ -618,7 +800,7 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
{
- OutputImpl outputimp( pDoc, nTab,
+ ScDPOutputImpl outputimp( pDoc, nTab,
nTabStartCol, nTabStartRow, nMemberStartCol, nMemberStartRow,
nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
//! limit frames to horizontal or vertical?
@@ -695,7 +877,7 @@ void ScDPOutput::CalcSizes()
if ( aStartPos.Col() + nRowFieldCount + nColCount - 1 > MAXCOL ||
aStartPos.Row() + nPageSize + nHeaderSize + nColFieldCount + nRowCount > MAXROW )
{
- bSizeOverflow = sal_True;
+ bSizeOverflow = true;
}
nTabStartCol = aStartPos.Col();
@@ -715,7 +897,7 @@ void ScDPOutput::CalcSizes()
nTabEndRow = nDataStartRow + (SCROW)nRowCount - 1;
else
nTabEndRow = nDataStartRow; // single row will remain empty
- bSizesValid = sal_True;
+ bSizesValid = true;
}
}
@@ -838,7 +1020,7 @@ void ScDPOutput::Output()
STR_PIVOT_STYLE_INNER );
// output column headers:
- OutputImpl outputimp( pDoc, nTab,
+ ScDPOutputImpl outputimp( pDoc, nTab,
nTabStartCol, nTabStartRow, nMemberStartCol, nMemberStartRow,
nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
for (nField=0; nField<nColFieldCount; nField++)
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index 7eeb4b93e284..72c0f06911b1 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -33,23 +33,6 @@
// INCLUDE --------------------------------------------------------------
-#include <tools/debug.hxx>
-#include <vcl/msgbox.hxx>
-#include <svl/zforlist.hxx>
-#include <comphelper/processfactory.hxx>
-#include <comphelper/types.hxx>
-
-#include <com/sun/star/sheet/DataImportMode.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sdb/CommandType.hpp>
-#include <com/sun/star/sdb/XCompletedExecution.hpp>
-#include <com/sun/star/sdbc/DataType.hpp>
-#include <com/sun/star/sdbc/XRow.hpp>
-#include <com/sun/star/sdbc/XRowSet.hpp>
-#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
-
#include "dpsdbtab.hxx"
#include "collect.hxx"
#include "global.hxx"
@@ -59,100 +42,41 @@
#include "document.hxx"
#include "dpobject.hxx"
+#include <com/sun/star/sheet/DataImportMode.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+
using namespace com::sun::star;
using ::std::vector;
using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::UNO_QUERY;
-#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
-#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
-
-//! move to a header file?
-#define SC_DBPROP_DATASOURCENAME "DataSourceName"
-#define SC_DBPROP_COMMAND "Command"
-#define SC_DBPROP_COMMANDTYPE "CommandType"
-
-ScDPCache* ScImportSourceDesc::CreateCache() const
+sal_Int32 ScImportSourceDesc::GetCommandType() const
{
- if (!mpDoc)
- return NULL;
-
sal_Int32 nSdbType = -1;
switch ( nType )
{
- case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break;
- case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break;
- case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break;
- default:
- return NULL;
+ case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break;
+ case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break;
+ case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break;
+ default:
+ ;
}
+ return nSdbType;
+}
- ScDPCache* pCache = new ScDPCache(mpDoc);
-
- uno::Reference<sdbc::XRowSet> xRowSet ;
- try
- {
- xRowSet = uno::Reference<sdbc::XRowSet>(
- comphelper::getProcessServiceFactory()->createInstance(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_ROWSET )) ),
- uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY );
- DBG_ASSERT( xRowProp.is(), "can't get RowSet" );
- if ( xRowProp.is() )
- {
- //
- // set source parameters
- //
- uno::Any aAny;
- aAny <<= rtl::OUString( aDBName );
- xRowProp->setPropertyValue(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_DATASOURCENAME)), aAny );
-
- aAny <<= rtl::OUString( aObject );
- xRowProp->setPropertyValue(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMAND)), aAny );
-
- aAny <<= nSdbType;
- xRowProp->setPropertyValue(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMANDTYPE)), aAny );
-
- uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY );
- if ( xExecute.is() )
- {
- uno::Reference<task::XInteractionHandler> xHandler(
- comphelper::getProcessServiceFactory()->createInstance(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_INTHANDLER )) ),
- uno::UNO_QUERY);
- xExecute->executeWithCompletion( xHandler );
- }
- else
- xRowSet->execute();
- SvNumberFormatter aFormat(mpDoc->GetServiceManager(), ScGlobal::eLnge);
- pCache->InitFromDataBase( xRowSet, *aFormat.GetNullDate() );
- }
- }
- catch ( sdbc::SQLException& rError )
- {
- //! store error message
- delete pCache;
- pCache = NULL;
- InfoBox aInfoBox( 0, String(rError.Message) );
- aInfoBox.Execute();
- }
- catch ( uno::Exception& )
- {
- delete pCache;
- pCache = NULL;
- OSL_FAIL("Unexpected exception in database");
- }
+const ScDPCache* ScImportSourceDesc::CreateCache() const
+{
+ if (!mpDoc)
+ return NULL;
+ sal_Int32 nSdbType = GetCommandType();
+ if (nSdbType < 0)
+ return NULL;
- ::comphelper::disposeComponent( xRowSet );
- return pCache;
+ ScDPCollection::DBCaches& rCaches = mpDoc->GetDPCollection()->GetDBCaches();
+ return rCaches.getCache(nSdbType, aDBName, aObject);
}
ScDatabaseDPData::ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport) :
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index e4aca9a45253..cfad761377bc 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -60,7 +60,7 @@ using ::std::vector;
// -----------------------------------------------------------------------
-ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, ScDPCache* pCache) :
+ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache* pCache) :
ScDPTableData(pD),
aQuery ( rDesc.GetQueryParam() ),
pSpecial(NULL),
@@ -307,7 +307,7 @@ bool ScSheetSourceDesc::operator== (const ScSheetSourceDesc& rOther) const
maQueryParam == rOther.maQueryParam;
}
-ScDPCache* ScSheetSourceDesc::CreateCache() const
+const ScDPCache* ScSheetSourceDesc::CreateCache() const
{
if (!mpDoc)
return NULL;
@@ -319,9 +319,17 @@ ScDPCache* ScSheetSourceDesc::CreateCache() const
return NULL;
}
- ScDPCache* pCache = new ScDPCache(mpDoc);
- pCache->InitFromDoc(mpDoc, GetSourceRange());
- return pCache;
+ // All cache instances are managed centrally by ScDPCollection.
+ ScDPCollection* pDPs = mpDoc->GetDPCollection();
+ if (HasRangeName())
+ {
+ // Name-based data source.
+ ScDPCollection::NameCaches& rCaches = pDPs->GetNameCaches();
+ return rCaches.getCache(GetRangeName(), GetSourceRange());
+ }
+
+ ScDPCollection::SheetCaches& rCaches = pDPs->GetSheetCaches();
+ return rCaches.getCache(GetSourceRange());
}
long ScSheetSourceDesc::GetCacheId() const
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 008cdfcf3935..35782e05bab7 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -48,6 +48,8 @@
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <memory>
+
const double D_TIMEFACTOR = 86400.0;
using namespace ::com::sun::star;
@@ -57,26 +59,37 @@ using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::std::vector;
+using ::std::auto_ptr;
namespace {
-bool lcl_isDate( sal_uLong nNumType )
+bool isDate( sal_uLong nNumType )
{
return ((nNumType & NUMBERFORMAT_DATE) != 0) ? 1 : 0;
}
-bool lcl_Search( const ScDPCache::DataListType& list, const ::std::vector<SCROW>& rOrder, const ScDPItemData& item, SCROW& rIndex)
+/**
+ * Search for an item in the data array. If it's in the array, return its
+ * index to the caller.
+ *
+ * @param rArray dimension array
+ * @param rOrder global order (what's this?)
+ * @param item item to search for
+ * @param rIndex the index of the found item in the global order.
+ *
+ * @return true if the item is found, or false otherwise.
+ */
+bool hasItemInDimension(const ScDPCache::DataListType& rArray, const ::std::vector<SCROW>& rOrder, const ScDPItemData& item, SCROW& rIndex)
{
- rIndex = list.size();
+ rIndex = rArray.size();
bool bFound = false;
SCROW nLo = 0;
- SCROW nHi = list.size() - 1;
- SCROW nIndex;
+ SCROW nHi = rArray.size() - 1;
long nCompare;
while (nLo <= nHi)
{
- nIndex = (nLo + nHi) / 2;
- nCompare = ScDPItemData::Compare( list[rOrder[nIndex]], item );
+ SCROW nIndex = (nLo + nHi) / 2;
+ nCompare = ScDPItemData::Compare( rArray[rOrder[nIndex]], item );
if (nCompare < 0)
nLo = nIndex + 1;
else
@@ -173,7 +186,7 @@ ScDPItemData* lcl_GetItemValue(
ScDPItemData::ScDPItemData(const String& rS, double fV, bool bHV, const sal_uLong nNumFormatP, bool bData) :
nNumFormat( nNumFormatP ), aString(rS), fValue(fV),
- mbFlag( (MK_VAL*!!bHV) | (MK_DATA*!!bData) | (MK_ERR*!!false) | (MK_DATE*!!lcl_isDate( nNumFormat ) ) )
+ mbFlag( (MK_VAL*!!bHV) | (MK_DATA*!!bData) | (MK_ERR*!!false) | (MK_DATE*!!isDate( nNumFormat ) ) )
{
}
@@ -203,7 +216,7 @@ ScDPItemData::ScDPItemData(ScDocument* pDoc, SCROW nRow, sal_uInt16 nCol, sal_uI
fValue = fVal;
mbFlag |= MK_VAL|MK_DATA;
nNumFormat = pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) );
- lcl_isDate( nFormat ) ? ( mbFlag |= MK_DATE ) : (mbFlag &= ~MK_DATE);
+ isDate( nFormat ) ? ( mbFlag |= MK_DATE ) : (mbFlag &= ~MK_DATE);
}
else if ( pDoc->HasData( nCol,nRow, nDocTab ) )
SetString ( aDocStr );
@@ -473,15 +486,12 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
maIndexOrder.push_back(new vector<SCROW>());
}
//check valid
- for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow ++ )
+
+ for (sal_uInt16 nCol = nStartCol; nCol <= nEndCol; ++nCol)
{
- for ( sal_uInt16 nCol = nStartCol; nCol <= nEndCol; nCol++ )
- {
- if ( nRow == nStartRow )
- AddLabel( new ScDPItemData( pDoc, nRow, nCol, nDocTab ) );
- else
- AddData( nCol - nStartCol, new ScDPItemData( pDoc, nRow, nCol, nDocTab ) );
- }
+ AddLabel(new ScDPItemData(pDoc, nStartRow, nCol, nDocTab));
+ for (SCROW nRow = nStartRow + 1; nRow <= nEndRow; ++nRow)
+ AddData(nCol - nStartCol, new ScDPItemData(pDoc, nRow, nCol, nDocTab));
}
return true;
}
@@ -489,7 +499,7 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
bool ScDPCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowSet, const Date& rNullDate)
{
if (!xRowSet.is())
- // Dont' even waste time to go any further.
+ // Don't even waste time to go any further.
return false;
try
{
@@ -565,7 +575,7 @@ sal_uLong ScDPCache::GetDimNumType( SCCOL nDim) const
return GetNumType(maTableDataValues[nDim][0].nNumFormat);
}
-bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpecial)
+bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpecial) const
{
if (!rParam.GetEntry(0).bDoQuery)
return true;
@@ -787,23 +797,23 @@ bool ScDPCache::IsEmptyMember( SCROW nRow, sal_uInt16 nColumn ) const
return !GetItemDataById( nColumn, GetItemDataId( nColumn, nRow, false ) )->IsHasData();
}
-bool ScDPCache::AddData(long nDim, ScDPItemData* pitemData)
+bool ScDPCache::AddData(long nDim, ScDPItemData* pData)
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
DBG_ASSERT( nDim < mnColumnCount && nDim >=0 , "dimension out of bound" );
- SCROW nIndex = 0;
- bool bInserted = false;
+ // Wrap this instance with scoped pointer to ensure proper deletion.
+ auto_ptr<ScDPItemData> p(pData);
+ pData->SetDate(isDate(GetNumType(pData->nNumFormat)));
- pitemData->SetDate( lcl_isDate( GetNumType( pitemData->nNumFormat ) ) );
-
- if ( !lcl_Search( maTableDataValues[nDim], maGlobalOrder[nDim], *pitemData, nIndex ) )
+ SCROW nIndex = 0;
+ if (!hasItemInDimension(maTableDataValues[nDim], maGlobalOrder[nDim], *pData, nIndex))
{
- maTableDataValues[nDim].push_back( pitemData );
+ // This item doesn't exist in the dimension array yet.
+ maTableDataValues[nDim].push_back(p);
maGlobalOrder[nDim].insert( maGlobalOrder[nDim].begin()+nIndex, maTableDataValues[nDim].size()-1 );
DBG_ASSERT( (size_t) maGlobalOrder[nDim][nIndex] == maTableDataValues[nDim].size()-1 ,"ScDPTableDataCache::AddData ");
maSourceData[nDim].push_back( maTableDataValues[nDim].size()-1 );
- bInserted = true;
}
else
maSourceData[nDim].push_back( maGlobalOrder[nDim][nIndex] );
@@ -813,12 +823,9 @@ bool ScDPCache::AddData(long nDim, ScDPItemData* pitemData)
while ( mbEmptyRow.size() <= nCurRow )
mbEmptyRow.push_back( true );
- if ( pitemData->IsHasData() )
+ if ( pData->IsHasData() )
mbEmptyRow[ nCurRow ] = false;
- if ( !bInserted )
- delete pitemData;
-
return true;
}
@@ -928,10 +935,26 @@ sal_uLong ScDPCache::GetNumberFormat( long nDim ) const
{
if ( nDim >= mnColumnCount )
return 0;
- if ( maTableDataValues[nDim].size()==0 )
+
+ if (maTableDataValues[nDim].empty())
return 0;
- else
- return maTableDataValues[nDim][0].nNumFormat;
+
+ // TODO: This is very ugly, but the best we can do right now. Check the
+ // first 10 dimension members, and take the first non-zero number format,
+ // else return the default number format (of 0). For the long-term, we
+ // need to redo this cache structure to properly indicate empty cells, and
+ // skip them when trying to determine the representative number format for
+ // a dimension.
+ size_t nCount = maTableDataValues[nDim].size();
+ if (nCount > 10)
+ nCount = 10;
+ for (size_t i = 0; i < nCount; ++i)
+ {
+ sal_uLong n = maTableDataValues[nDim][i].nNumFormat;
+ if (n)
+ return n;
+ }
+ return 0;
}
bool ScDPCache::IsDateDimension( long nDim ) const
@@ -967,7 +990,7 @@ SCCOL ScDPCache::GetDimensionIndex(String sName) const
return -1;
}
-SCROW ScDPCache::GetIdByItemData(long nDim, String sItemData ) const
+SCROW ScDPCache::GetIdByItemData(long nDim, const String& sItemData ) const
{
if ( nDim < mnColumnCount && nDim >=0 )
{
@@ -995,7 +1018,7 @@ SCROW ScDPCache::GetIdByItemData( long nDim, const ScDPItemData& rData ) const
return GetRowCount() + maAdditionalData.getDataId(rData);
}
-SCROW ScDPCache::GetAdditionalItemID ( String sItemData ) const
+SCROW ScDPCache::GetAdditionalItemID ( const String& sItemData ) const
{
ScDPItemData rData ( sItemData );
return GetAdditionalItemID( rData );
diff --git a/sc/source/core/data/scdpoutputimpl.cxx b/sc/source/core/data/scdpoutputimpl.cxx
deleted file mode 100644
index ce2201ef872c..000000000000
--- a/sc/source/core/data/scdpoutputimpl.cxx
+++ /dev/null
@@ -1,184 +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 IBM Corporation 2009.
- * Copyright 2009 by Sun Microsystems, Inc.
- *
- * 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.
- *
- ************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-// INCLUDE ---------------------------------------------------------------
-#include "scdpoutputimpl.hxx"
-#include "scitems.hxx"
-#include <editeng/boxitem.hxx>
-// -----------------------------------------------------------------------
-
-namespace
-{
- bool lcl_compareColfuc ( SCCOL i, SCCOL j) { return (i<j); }
- bool lcl_compareRowfuc ( SCROW i, SCROW j) { return (i<j); }
-}
-
-
-void OutputImpl::OutputDataArea()
-{
- AddRow( mnDataStartRow );
- AddCol( mnDataStartCol );
-
- mnCols.push_back( mnTabEndCol+1); //set last row bottom
- mnRows.push_back( mnTabEndRow+1); //set last col bottom
-
- sal_Bool bAllRows = ( ( mnTabEndRow - mnDataStartRow + 2 ) == (SCROW) mnRows.size() );
-
- std::sort( mnCols.begin(), mnCols.end(), lcl_compareColfuc );
- std::sort( mnRows.begin(), mnRows.end(), lcl_compareRowfuc );
-
- for( SCCOL nCol = 0; nCol < (SCCOL)mnCols.size()-1; nCol ++ )
- {
- if ( !bAllRows )
- {
- if ( nCol < (SCCOL)mnCols.size()-2)
- {
- for ( SCROW i = nCol%2; i < (SCROW)mnRows.size()-2; i +=2 )
- OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
- if ( mnRows.size()>=2 )
- OutputBlockFrame( mnCols[nCol], mnRows[mnRows.size()-2], mnCols[nCol+1]-1, mnRows[mnRows.size()-1]-1 );
- }
- else
- {
- for ( SCROW i = 0 ; i < (SCROW)mnRows.size()-1; i++ )
- OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
- }
- }
- else
- OutputBlockFrame( mnCols[nCol], mnRows.front(), mnCols[nCol+1]-1, mnRows.back()-1, bAllRows );
- }
- //out put rows area outer framer
- if ( mnTabStartCol != mnDataStartCol )
- {
- if ( mnTabStartRow != mnDataStartRow )
- OutputBlockFrame( mnTabStartCol, mnTabStartRow, mnDataStartCol-1, mnDataStartRow-1 );
- OutputBlockFrame( mnTabStartCol, mnDataStartRow, mnDataStartCol-1, mnTabEndRow );
- }
- //out put cols area outer framer
- OutputBlockFrame( mnDataStartCol, mnTabStartRow, mnTabEndCol, mnDataStartRow-1 );
-}
-
-OutputImpl::OutputImpl( ScDocument* pDoc, sal_uInt16 nTab,
- SCCOL nTabStartCol,
- SCROW nTabStartRow,
- SCCOL nMemberStartCol,
- SCROW nMemberStartRow,
- SCCOL nDataStartCol,
- SCROW nDataStartRow,
- SCCOL nTabEndCol,
- SCROW nTabEndRow ):
- mpDoc( pDoc ),
- mnTab( nTab ),
- mnTabStartCol( nTabStartCol ),
- mnTabStartRow( nTabStartRow ),
- mnMemberStartCol( nMemberStartCol),
- mnMemberStartRow( nMemberStartRow),
- mnDataStartCol ( nDataStartCol ),
- mnDataStartRow ( nDataStartRow ),
- mnTabEndCol( nTabEndCol ),
- mnTabEndRow( nTabEndRow )
-{
- mbNeedLineCols.resize( nTabEndCol-nDataStartCol+1, false );
- mbNeedLineRows.resize( nTabEndRow-nDataStartRow+1, false );
-
-}
-
-sal_Bool OutputImpl::AddRow( SCROW nRow )
-{
- if ( !mbNeedLineRows[ nRow - mnDataStartRow ] )
- {
- mbNeedLineRows[ nRow - mnDataStartRow ] = true;
- mnRows.push_back( nRow );
- return sal_True;
- }
- else
- return false;
-}
-
-sal_Bool OutputImpl::AddCol( SCCOL nCol )
-{
-
- if ( !mbNeedLineCols[ nCol - mnDataStartCol ] )
- {
- mbNeedLineCols[ nCol - mnDataStartCol ] = true;
- mnCols.push_back( nCol );
- return sal_True;
- }
- else
- return false;
-}
-
-void OutputImpl::OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_Bool bHori )
-{
- Color color = SC_DP_FRAME_COLOR;
- ::editeng::SvxBorderLine aLine( &color, SC_DP_FRAME_INNER_BOLD );
- ::editeng::SvxBorderLine aOutLine( &color, SC_DP_FRAME_OUTER_BOLD );
-
- SvxBoxItem aBox( ATTR_BORDER );
-
- if ( nStartCol == mnTabStartCol )
- aBox.SetLine(&aOutLine, BOX_LINE_LEFT);
- else
- aBox.SetLine(&aLine, BOX_LINE_LEFT);
-
- if ( nStartRow == mnTabStartRow )
- aBox.SetLine(&aOutLine, BOX_LINE_TOP);
- else
- aBox.SetLine(&aLine, BOX_LINE_TOP);
-
- if ( nEndCol == mnTabEndCol ) //bottom row
- aBox.SetLine(&aOutLine, BOX_LINE_RIGHT);
- else
- aBox.SetLine(&aLine, BOX_LINE_RIGHT);
-
- if ( nEndRow == mnTabEndRow ) //bottom
- aBox.SetLine(&aOutLine, BOX_LINE_BOTTOM);
- else
- aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
-
-
- SvxBoxInfoItem aBoxInfo( ATTR_BORDER_INNER );
- aBoxInfo.SetValid(VALID_VERT,false );
- if ( bHori )
- {
- aBoxInfo.SetValid(VALID_HORI,sal_True);
- aBoxInfo.SetLine( &aLine, BOXINFO_LINE_HORI );
- }
- else
- aBoxInfo.SetValid(VALID_HORI,false );
-
- aBoxInfo.SetValid(VALID_DISTANCE,false);
-
- mpDoc->ApplyFrameAreaTab( ScRange( nStartCol, nStartRow, mnTab, nEndCol, nEndRow , mnTab ), &aBox, &aBoxInfo );
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/scdpoutputimpl.hxx b/sc/source/core/data/scdpoutputimpl.hxx
deleted file mode 100644
index 35a0a65a06fc..000000000000
--- a/sc/source/core/data/scdpoutputimpl.hxx
+++ /dev/null
@@ -1,79 +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 IBM Corporation 2009.
- * Copyright 2009 by Sun Microsystems, Inc.
- *
- * 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 SCDPOUTPUTIMPL_HXX
-#define SCDPOUTPUTIMPL_HXX
-
-#include "document.hxx"
-
-#define SC_DP_FRAME_INNER_BOLD 20
-#define SC_DP_FRAME_OUTER_BOLD 40
-
-#define SC_DP_FRAME_COLOR Color(0,0,0) //( 0x20, 0x40, 0x68 )
-
-class OutputImpl
-{
- ScDocument* mpDoc;
- sal_uInt16 mnTab;
- ::std::vector< bool > mbNeedLineCols;
- ::std::vector< SCCOL > mnCols;
-
- ::std::vector< bool > mbNeedLineRows;
- ::std::vector< SCROW > mnRows;
-
- SCCOL mnTabStartCol;
- SCROW mnTabStartRow;
- SCCOL mnMemberStartCol;
- SCROW mnMemberStartRow;
-
- SCCOL mnDataStartCol;
- SCROW mnDataStartRow;
- SCCOL mnTabEndCol;
- SCROW mnTabEndRow;
-
-public:
- OutputImpl( ScDocument* pDoc, sal_uInt16 nTab,
- SCCOL nTabStartCol,
- SCROW nTabStartRow,
- SCCOL nMemberStartCol,
- SCROW nMemberStartRow,
- SCCOL nDataStartCol,
- SCROW nDataStartRow,
- SCCOL nTabEndCol,
- SCROW nTabEndRow );
- sal_Bool AddRow( SCROW nRow );
- sal_Bool AddCol( SCCOL nCol );
-
- void OutputDataArea();
- void OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_Bool bHori = false );
-
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */