Kaydet (Commit) 1097d2f3 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Some misc changes & some dumping facility for pivot table for debugging.

üst 16cfcce0
......@@ -31,6 +31,7 @@
#include "global.hxx"
#include "dpnumgroupinfo.hxx"
#include "dpmacros.hxx"
#include "tools/date.hxx"
#include <boost/noncopyable.hpp>
......@@ -160,6 +161,10 @@ public:
ScDPCache(ScDocument* pDoc);
~ScDPCache();
#if DEBUG_PIVOT_TABLE
void Dump() const;
#endif
private:
void PostInit();
void Clear();
......
......@@ -35,13 +35,12 @@
#include "sal/types.h"
#include "tools/solar.h"
#include "rtl/ustring.hxx"
#include "dpmacros.hxx"
#include <vector>
#include <boost/unordered_map.hpp>
#define DEBUG_DP_ITEM_DATA 0
class ScDocument;
/**
......@@ -119,7 +118,7 @@ public:
sal_uInt8 GetCellType() const;
#if DEBUG_DP_ITEM_DATA
#if DEBUG_PIVOT_TABLE
void Dump(const char* msg) const;
#endif
};
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 or as specified alternatively below. 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.
*
* Major Contributor(s):
* Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* 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.
*/
#ifndef __SC_DPMACROS_HXX__
#define __SC_DPMACROS_HXX__
#define DEBUG_PIVOT_TABLE 0
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -35,6 +35,8 @@
#include "dpoutput.hxx"
#include "dptypes.hxx"
#include "pivot.hxx"
#include "dpmacros.hxx"
#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
#include <set>
......@@ -259,6 +261,10 @@ public:
std::vector<PivotField>* pRefPageFields = NULL );
static bool IsOrientationAllowed( sal_uInt16 nOrient, sal_Int32 nDimFlags );
#if DEBUG_PIVOT_TABLE
void DumpCache() const;
#endif
};
......
......@@ -1126,4 +1126,51 @@ long ScDPCache::GetColumnCount() const
return mnColumnCount;
}
#if DEBUG_PIVOT_TABLE
#include <iostream>
using std::cout;
using std::endl;
namespace {
std::ostream& operator<< (::std::ostream& os, const rtl::OUString& str)
{
return os << ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr();
}
}
void ScDPCache::Dump() const
{
cout << "--- pivot cache dump" << endl;
{
FieldsType::const_iterator it = maFields.begin(), itEnd = maFields.end();
for (size_t i = 0; it != itEnd; ++it, ++i)
{
const Field& fld = *it;
cout << "* source field: " << GetDimensionName(i) << endl;
cout << " item count: " << fld.maItems.size() << endl;
if (fld.mpGroup)
{
cout << " group item count: " << fld.mpGroup->maItems.size() << endl;
}
}
}
{
GroupFieldsType::const_iterator it = maGroupFields.begin(), itEnd = maGroupFields.end();
for (; it != itEnd; ++it)
{
const GroupItems& gi = *it;
cout << "* group field: (unnamed)" << endl;
cout << " item count: " << gi.maItems.size() << endl;
}
}
cout << "---" << endl;
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -294,7 +294,7 @@ sal_uInt8 ScDPItemData::GetCellType() const
return SC_VALTYPE_STRING;
}
#if DEBUG_DP_ITEM_DATA
#if DEBUG_PIVOT_TABLE
void ScDPItemData::Dump(const char* msg) const
{
printf("--- (%s)\n", msg);
......
......@@ -2524,6 +2524,20 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS
return xRet;
}
#if DEBUG_PIVOT_TABLE
void ScDPObject::DumpCache() const
{
if (!mpTableData)
return;
const ScDPCache* pCache = mpTableData->GetCacheTable().getCache();
if (!pCache)
return;
pCache->Dump();
}
#endif
ScDPCollection::SheetCaches::SheetCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
namespace {
......
......@@ -1327,9 +1327,6 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
if ( pNewObj == pOldObj && pDestObj->IsImportData() )
pDestObj->ClearTableData();
if (pDestObj->HasGroups())
pDestObj->ReloadGroupTableData();
pDestObj->InvalidateData(); // before getting the new output area
// make sure the table has a name (not set by dialog)
......@@ -1479,7 +1476,7 @@ sal_uLong ScDBDocFunc::RefreshPivotTables(ScDPObject* pDPObj, bool bApi)
ScDPObject* pObj = *it;
if (bHasGroups)
// Re-build table data for each pivot table when the original contains group fields.
pObj->ClearTableData();
pObj->ReloadGroupTableData();
// This action is intentionally not undoable since it modifies cache.
DataPilotUpdate(pObj, pObj, false, bApi);
......
......@@ -85,8 +85,10 @@ public:
void Consolidate( const ScConsolidateParam& rParam, sal_Bool bRecord = sal_True );
bool MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, sal_Bool bNewTable,
const ScDPObject& rSource, sal_Bool bApi = false );
bool MakePivotTable(
const ScDPSaveData& rData, const ScRange& rDest, bool bNewTable,
const ScDPObject& rSource, bool bApi = false );
void DeletePivotTable();
void RecalcPivotTable();
bool HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts );
......
......@@ -591,8 +591,9 @@ String lcl_MakePivotTabName( const String& rPrefix, SCTAB nNumber )
return aName;
}
bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, sal_Bool bNewTable,
const ScDPObject& rSource, sal_Bool bApi )
bool ScDBFunc::MakePivotTable(
const ScDPSaveData& rData, const ScRange& rDest, bool bNewTable,
const ScDPObject& rSource, bool bApi )
{
// error message if no fields are set
// this must be removed when drag&drop of fields from a toolbox is available
......@@ -605,7 +606,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocument* pDoc = GetViewData()->GetDocument();
sal_Bool bUndo(pDoc->IsUndoEnabled());
bool bUndo = pDoc->IsUndoEnabled();
ScRange aDestRange = rDest;
if ( bNewTable )
......@@ -626,7 +627,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
while ( !pDoc->InsertTab( nNewTab, lcl_MakePivotTabName( aName, i ) ) && i <= MAXTAB )
i++;
sal_Bool bAppend = ( nNewTab+1 == pDoc->GetTableCount() );
bool bAppend = ( nNewTab+1 == pDoc->GetTableCount() );
if (bUndo)
{
pDocSh->GetUndoManager()->AddUndoAction(
......@@ -634,7 +635,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
}
GetViewData()->InsertTab( nNewTab );
SetTabNo( nNewTab, sal_True );
SetTabNo(nNewTab, true);
aDestRange = ScRange( 0, 0, nNewTab );
}
......@@ -664,7 +665,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
bool bAllowMove = (pDPObj != NULL); // allow re-positioning when editing existing table
ScDBDocFunc aFunc( *pDocSh );
bool bSuccess = aFunc.DataPilotUpdate( pDPObj, &aObj, sal_True, false, bAllowMove );
bool bSuccess = aFunc.DataPilotUpdate(pDPObj, &aObj, true, false, bAllowMove);
CursorPosChanged(); // shells may be switched
......
......@@ -599,6 +599,7 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu()
}
pDim->UpdateMemberVisibility(aResult);
pDPObj->ReloadGroupTableData();
ScDBDocFunc aFunc(*pViewData->GetDocShell());
aFunc.DataPilotUpdate(pDPObj, pDPObj, true, false);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment