summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei@openoffice.org>2009-06-19 01:30:32 +0000
committerKohei Yoshida <kohei@openoffice.org>2009-06-19 01:30:32 +0000
commitacd89bd93d510281d1e46ca1617ff8545d0e981b (patch)
treec2d5c18631ac8ea2f8bb8e3c3c6677ebd3859544 /sc/source
parent7425283183cc26795bc3c655b2bc5cd6931091e2 (diff)
added grid layout bits.
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/dpobject.cxx25
-rw-r--r--sc/source/core/data/dpoutput.cxx19
-rw-r--r--sc/source/filter/excel/read.cxx1
-rw-r--r--sc/source/filter/excel/xepivot.cxx20
-rw-r--r--sc/source/filter/excel/xipivot.cxx93
-rw-r--r--sc/source/filter/inc/xepivot.hxx3
-rw-r--r--sc/source/filter/inc/xipivot.hxx7
-rw-r--r--sc/source/filter/inc/xlpivot.hxx25
8 files changed, 185 insertions, 8 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 4cf5d1e8a602..fa58a8b3c277 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -165,9 +165,10 @@ ScDPObject::ScDPObject( ScDocument* pD ) :
pOutput( NULL ),
bSettingsChanged( FALSE ),
bAlive( FALSE ),
- nAutoFormatIndex( 65535 ),
+ mnAutoFormatIndex( 65535 ),
bAllowMove( FALSE ),
- nHeaderRows( 0 )
+ nHeaderRows( 0 ),
+ mbHeaderLayout(false)
{
}
@@ -184,9 +185,10 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
pOutput( NULL ),
bSettingsChanged( FALSE ),
bAlive( FALSE ),
- nAutoFormatIndex( r.nAutoFormatIndex ),
+ mnAutoFormatIndex( r.mnAutoFormatIndex ),
bAllowMove( FALSE ),
- nHeaderRows( r.nHeaderRows )
+ nHeaderRows( r.nHeaderRows ),
+ mbHeaderLayout( r.mbHeaderLayout )
{
if (r.pSaveData)
pSaveData = new ScDPSaveData(*r.pSaveData);
@@ -236,12 +238,22 @@ void ScDPObject::SetSaveData(const ScDPSaveData& rData)
void ScDPObject::SetAutoFormatIndex(const sal_uInt16 nIndex)
{
- nAutoFormatIndex = nIndex;
+ mnAutoFormatIndex = nIndex;
}
sal_uInt16 ScDPObject::GetAutoFormatIndex() const
{
- return nAutoFormatIndex;
+ return mnAutoFormatIndex;
+}
+
+void ScDPObject::SetHeaderLayout (bool bUseGrid)
+{
+ mbHeaderLayout = bUseGrid;
+}
+
+bool ScDPObject::GetHeaderLayout() const
+{
+ return mbHeaderLayout;
}
void ScDPObject::SetOutRange(const ScRange& rRange)
@@ -350,6 +362,7 @@ void ScDPObject::CreateOutput()
{
BOOL bFilterButton = IsSheetData() && pSaveData && pSaveData->GetFilterButton();
pOutput = new ScDPOutput( pDoc, xSource, aOutRange.aStart, bFilterButton );
+ pOutput->SetHeaderLayout ( mbHeaderLayout );
long nOldRows = nHeaderRows;
nHeaderRows = pOutput->GetHeaderRows();
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 63acede160c9..567dcc7991f3 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -376,7 +376,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
nRowFmtCount( 0 ),
nSingleNumFmt( 0 ),
bSizesValid( FALSE ),
- bSizeOverflow( FALSE )
+ bSizeOverflow( FALSE ),
+ mbHeaderLayout( false )
{
nTabStartCol = nMemberStartCol = nDataStartCol = nTabEndCol = 0;
nTabStartRow = nMemberStartRow = nDataStartRow = nTabEndRow = 0;
@@ -666,7 +667,11 @@ void ScDPOutput::CalcSizes()
nRowCount = aData.getLength();
const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
nColCount = nRowCount ? ( pRowAry[0].getLength() ) : 0;
- nHeaderSize = 1; // one row for field names
+
+ nHeaderSize = 1;
+ if (GetHeaderLayout() && nColFieldCount == 0)
+ // Insert an extra header row only when there is no column field.
+ nHeaderSize = 2;
// calculate output positions and sizes
@@ -993,6 +998,16 @@ void ScDPOutput::GetMemberResultNames( ScStrCollection& rNames, long nDimension
}
}
+void ScDPOutput::SetHeaderLayout(bool bUseGrid)
+{
+ mbHeaderLayout = bUseGrid;
+ bSizesValid = false;
+}
+
+bool ScDPOutput::GetHeaderLayout() const
+{
+ return mbHeaderLayout;
+}
void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionData& rPosData)
{
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index a06cf041e7cf..d1ae00376cde 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -1143,6 +1143,7 @@ FltError ImportExcel8::Read( void )
case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break;
case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break;
case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break;
+ case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break;
}
}
break;
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 457cdd2a17e4..0b10ded5aa9e 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -1220,6 +1220,8 @@ XclExpPivotTable::XclExpPivotTable( const XclExpRoot& rRoot, const ScDPObject& r
maPTInfo.maDataName = ScGlobal::GetRscString( STR_PIVOT_DATA );
maPTInfo.mnCacheIdx = mrPCache.GetCacheIndex();
+ maPTAutoFormat.Init( rDPObj );
+
if( const ScDPSaveData* pSaveData = rDPObj.GetSaveData() )
{
// additional properties from ScDPSaveData
@@ -1299,6 +1301,8 @@ void XclExpPivotTable::Save( XclExpStream& rStrm )
WriteSxli( rStrm, maPTInfo.mnDataCols, maPTInfo.mnColFields );
// SXEX
WriteSxex( rStrm );
+ // SX_AUTOFORMAT
+ WriteSxAutoformat( rStrm );
}
}
@@ -1439,6 +1443,8 @@ void XclExpPivotTable::Finalize()
rnDataXclRow = rnXclRow1 + maPTInfo.mnColFields + 1;
if( maDataFields.empty() )
++rnDataXclRow;
+ if( 0 == maPTAutoFormat.mnGridLayout )
+ ++rnDataXclRow;
rnXclCol2 = ::std::max( rnXclCol2, rnDataXclCol );
rnXclRow2 = ::std::max( rnXclRow2, rnDataXclRow );
maPTInfo.mnDataCols = rnXclCol2 - rnDataXclCol + 1;
@@ -1446,6 +1452,8 @@ void XclExpPivotTable::Finalize()
// first heading
maPTInfo.mnFirstHeadRow = rnXclRow1 + 1;
+ if( 0 == maPTAutoFormat.mnGridLayout )
+ maPTInfo.mnFirstHeadRow++;
}
// records ----------------------------------------------------------------
@@ -1525,6 +1533,18 @@ void XclExpPivotTable::WriteSxex( XclExpStream& rStrm ) const
rStrm.EndRecord();
}
+void XclExpPivotTable::WriteSxAutoformat( XclExpStream& rStrm ) const
+{
+ // Until we sync the autoformat ids only export if using grid header layout
+ // That could only have been set via xls import so far.
+ if ( 0 == maPTAutoFormat.mnGridLayout )
+ {
+ rStrm.StartRecord( EXC_ID_SXVIEWEX9, 17 );
+ rStrm << maPTAutoFormat;
+ rStrm.EndRecord();
+ }
+}
+
// ============================================================================
namespace {
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index acd371f43f7d..495f73d75a68 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1296,6 +1296,11 @@ void XclImpPivotTable::ReadSxex( XclImpStream& rStrm )
rStrm >> maPTExtInfo;
}
+void XclImpPivotTable::ReadSxViewEx9( XclImpStream& rStrm )
+{
+ rStrm >> maPTAutoFormat;
+}
+
// ----------------------------------------------------------------------------
void XclImpPivotTable::Convert()
@@ -1363,6 +1368,7 @@ void XclImpPivotTable::Convert()
pDPObj->SetSheetDesc( aDesc );
pDPObj->SetOutRange( aOutRange );
pDPObj->SetAlive( TRUE );
+ pDPObj->SetHeaderLayout( maPTAutoFormat.mnGridLayout == 0 );
GetDoc().GetDPCollection()->Insert( pDPObj );
}
@@ -1458,6 +1464,12 @@ void XclImpPivotTableManager::ReadSxex( XclImpStream& rStrm )
maPTables.back()->ReadSxex( rStrm );
}
+void XclImpPivotTableManager::ReadSxViewEx9( XclImpStream& rStrm )
+{
+ if( !maPTables.empty() )
+ maPTables.back()->ReadSxViewEx9( rStrm );
+}
+
// ----------------------------------------------------------------------------
void XclImpPivotTableManager::ReadPivotCaches( XclImpStream& rStrm )
@@ -1474,3 +1486,84 @@ void XclImpPivotTableManager::ConvertPivotTables()
// ============================================================================
+// Pivot table autoformat settings ============================================
+
+/**
+classic : 10 08 00 00 00 00 00 00 20 00 00 00 01 00 00 00 00
+default : 10 08 00 00 00 00 00 00 20 00 00 00 01 00 00 00 00
+report01 : 10 08 02 00 00 00 00 00 20 00 00 00 00 10 00 00 00
+report02 : 10 08 02 00 00 00 00 00 20 00 00 00 01 10 00 00 00
+report03 : 10 08 02 00 00 00 00 00 20 00 00 00 02 10 00 00 00
+report04 : 10 08 02 00 00 00 00 00 20 00 00 00 03 10 00 00 00
+report05 : 10 08 02 00 00 00 00 00 20 00 00 00 04 10 00 00 00
+report06 : 10 08 02 00 00 00 00 00 20 00 00 00 05 10 00 00 00
+report07 : 10 08 02 00 00 00 00 00 20 00 00 00 06 10 00 00 00
+report08 : 10 08 02 00 00 00 00 00 20 00 00 00 07 10 00 00 00
+report09 : 10 08 02 00 00 00 00 00 20 00 00 00 08 10 00 00 00
+report10 : 10 08 02 00 00 00 00 00 20 00 00 00 09 10 00 00 00
+table01 : 10 08 00 00 00 00 00 00 20 00 00 00 0a 10 00 00 00
+table02 : 10 08 00 00 00 00 00 00 20 00 00 00 0b 10 00 00 00
+table03 : 10 08 00 00 00 00 00 00 20 00 00 00 0c 10 00 00 00
+table04 : 10 08 00 00 00 00 00 00 20 00 00 00 0d 10 00 00 00
+table05 : 10 08 00 00 00 00 00 00 20 00 00 00 0e 10 00 00 00
+table06 : 10 08 00 00 00 00 00 00 20 00 00 00 0f 10 00 00 00
+table07 : 10 08 00 00 00 00 00 00 20 00 00 00 10 10 00 00 00
+table08 : 10 08 00 00 00 00 00 00 20 00 00 00 11 10 00 00 00
+table09 : 10 08 00 00 00 00 00 00 20 00 00 00 12 10 00 00 00
+table10 : 10 08 00 00 00 00 00 00 20 00 00 00 13 10 00 00 00
+none : 10 08 00 00 00 00 00 00 20 00 00 00 15 10 00 00 00
+**/
+
+XclPTAutoFormat::XclPTAutoFormat() :
+ mbReport( 0 ),
+ mnAutoFormat( 0 ),
+ mnGridLayout( 0x10 )
+{
+}
+
+void XclPTAutoFormat::Init( const ScDPObject& rDPObj )
+{
+ if( rDPObj.GetHeaderLayout() )
+ {
+ mbReport = 0;
+ mnAutoFormat = 1;
+ mnGridLayout = 0;
+ }
+ else
+ {
+ // Report1 for now
+ // TODO : sync with autoformat indicies
+ mbReport = 2;
+ mnAutoFormat = 1;
+ mnGridLayout = 0x10;
+ }
+}
+
+XclImpStream& operator>>( XclImpStream& rStrm, XclPTAutoFormat& rInfo )
+{
+ rStrm.Ignore( 2 );
+ rStrm >> rInfo.mbReport; /// 2 for report* fmts ?
+ rStrm.Ignore( 6 );
+ sal_uInt8 nDummy;
+ return rStrm
+ >> rInfo.mnAutoFormat
+ >> rInfo.mnGridLayout
+ >> nDummy >> nDummy >> nDummy;
+}
+
+XclExpStream& operator<<( XclExpStream& rStrm, const XclPTAutoFormat& rInfo )
+{
+ return rStrm
+ << EXC_PT_AUTOFMT_HEADER
+ << rInfo.mbReport
+ << EXC_PT_AUTOFMT_ZERO
+ << EXC_PT_AUTOFMT_FLAGS
+ << rInfo.mnAutoFormat
+ << rInfo.mnGridLayout
+ << static_cast<sal_uInt8>(0x00)
+ << static_cast<sal_uInt8>(0x00)
+ << static_cast<sal_uInt8>(0x00);
+}
+
+// ============================================================================
+
diff --git a/sc/source/filter/inc/xepivot.hxx b/sc/source/filter/inc/xepivot.hxx
index 80356d41f4a8..67ef2ff6fcd8 100644
--- a/sc/source/filter/inc/xepivot.hxx
+++ b/sc/source/filter/inc/xepivot.hxx
@@ -412,6 +412,8 @@ private:
void WriteSxli( XclExpStream& rStrm, sal_uInt16 nLineCount, sal_uInt16 nIndexCount ) const;
/** Writes the SXEX records containing additional pivot table info. */
void WriteSxex( XclExpStream& rStrm ) const;
+ /** Writes the SX_AUTOFORMAT records with the autoformat id and header layout */
+ void WriteSxAutoformat( XclExpStream& rStrm ) const;
// ------------------------------------------------------------------------
private:
@@ -422,6 +424,7 @@ private:
const XclExpPivotCache& mrPCache; /// The pivot cache this pivot table bases on.
XclPTInfo maPTInfo; /// Info about the pivot table (SXVIEW record).
XclPTExtInfo maPTExtInfo; /// Extended info about the pivot table (SXEX record).
+ XclPTAutoFormat maPTAutoFormat; /// The selected autoformat (SXVIEWEX9)
XclExpPTFieldList maFieldList; /// All fields in pivot cache order.
ScfUInt16Vec maRowFields; /// Row field indexes.
ScfUInt16Vec maColFields; /// Column field indexes.
diff --git a/sc/source/filter/inc/xipivot.hxx b/sc/source/filter/inc/xipivot.hxx
index 52b55509219b..5a98c0793740 100644
--- a/sc/source/filter/inc/xipivot.hxx
+++ b/sc/source/filter/inc/xipivot.hxx
@@ -350,6 +350,9 @@ public:
void ReadSxdi( XclImpStream& rStrm );
/** Reads an SXEX record containing additional settings for the pivot table. */
void ReadSxex( XclImpStream& rStrm );
+ /** Reads an SXVIEWEX9 record that specifies the pivot tables
+ * autoformat. */
+ void ReadSxViewEx9( XclImpStream& rStrm );
// ------------------------------------------------------------------------
@@ -364,6 +367,7 @@ private:
XclPTInfo maPTInfo; /// General info about the pivot table (SXVIEW record).
XclPTExtInfo maPTExtInfo; /// Extended info about the pivot table (SXEX record).
+ XclPTAutoFormat maPTAutoFormat; /// The selected autoformat (SX_AUTOFORMAT)
XclImpPTFieldVec maFields; /// Vector containing all fields.
XclImpPTFieldRef mxCurrField; /// Current field for importing additional info.
ScfStringVec maVisFieldNames; /// Vector containing all visible field names.
@@ -422,6 +426,9 @@ public:
void ReadSxvi( XclImpStream& rStrm );
/** Reads an SXEX record containing additional settings for a pivot table. */
void ReadSxex( XclImpStream& rStrm );
+ /** Reads an SXVIEWEX9 record that specifies the pivot tables
+ * autoformat. */
+ void ReadSxViewEx9( XclImpStream& rStrm );
// ------------------------------------------------------------------------
diff --git a/sc/source/filter/inc/xlpivot.hxx b/sc/source/filter/inc/xlpivot.hxx
index 9604c7b1d17d..52251ed62294 100644
--- a/sc/source/filter/inc/xlpivot.hxx
+++ b/sc/source/filter/inc/xlpivot.hxx
@@ -41,6 +41,7 @@
#include <tools/datetime.hxx>
#include "ftools.hxx"
#include "xladdress.hxx"
+#include "dpobject.hxx"
class XclImpStream;
class XclExpStream;
@@ -73,6 +74,10 @@ const sal_uInt16 EXC_PT_MAXDATACOUNT = 256;
// pivot table items
const sal_uInt16 EXC_PT_MAXITEMCOUNT = 32500;
+const sal_uInt16 EXC_PT_AUTOFMT_HEADER = 0x810;
+const sal_uInt16 EXC_PT_AUTOFMT_ZERO = 0;
+const sal_uInt32 EXC_PT_AUTOFMT_FLAGS = 0x20;
+
/** Data type of a pivot cache item. */
enum XclPCItemType
{
@@ -396,6 +401,9 @@ const double EXC_SXDBEX_CREATION_DATE = 51901.029652778;
const sal_uInt16 EXC_ID_SXFDBTYPE = 0x01BB;
const sal_uInt16 EXC_SXFDBTYPE_DEFAULT = 0x0000;
+// (0x0810) SXVIEWEX9 ---------------------------------------------------------
+const sal_uInt16 EXC_ID_SXVIEWEX9 = 0x0810;
+
// ============================================================================
// Pivot cache
// ============================================================================
@@ -786,5 +794,22 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTExtInfo& rInfo );
// ============================================================================
+// Pivot table autoformat settings ==============================================
+
+/** Pivot table autoformat settings (SX_AUTOFORMAT record). */
+struct XclPTAutoFormat
+{
+ sal_uInt32 mbReport; /// 2 for report* fmts ?
+ sal_uInt8 mnAutoFormat; /// AutoFormat ID
+ sal_uInt8 mnGridLayout; /// 0 == gridlayout, 0x10 == modern
+
+ explicit XclPTAutoFormat();
+ void Init( const ScDPObject& rDPObj );
+};
+
+XclImpStream& operator>>( XclImpStream& rStrm, XclPTAutoFormat& rInfo );
+XclExpStream& operator<<( XclExpStream& rStrm, const XclPTAutoFormat& rInfo );
+
+// ============================================================================
#endif