Update to m13
[ooovba.git] / applied_patches / 0511-calc-dp-hide-list-menu.diff
blob2a6d889ae2e26dea5d1dcecdfc847493bcf6d33f
1 diff --git sc/inc/attrib.hxx sc/inc/attrib.hxx
2 index 3fed033..22e7d27 100644
3 --- sc/inc/attrib.hxx
4 +++ sc/inc/attrib.hxx
5 @@ -42,13 +42,16 @@
7 // Flags fuer durch Merge verdeckte Zellen
8 // und Control fuer Auto-Filter
9 -#define SC_MF_HOR 1
10 -#define SC_MF_VER 2
11 -#define SC_MF_AUTO 4
12 -#define SC_MF_BUTTON 8
13 -#define SC_MF_SCENARIO 16
15 -#define SC_MF_ALL 31
16 +#define SC_MF_HOR 0x0001
17 +#define SC_MF_VER 0x0002
18 +#define SC_MF_AUTO 0x0004 /// autofilter arrow
19 +#define SC_MF_BUTTON 0x0008 /// field button for datapilot
20 +#define SC_MF_SCENARIO 0x0010
21 +#define SC_MF_BUTTON_POPUP 0x0020 /// dp button with popup arrow
22 +#define SC_MF_HIDDEN_MEMBER 0x0040 /// dp field button with presence of hidden member
23 +#define SC_MF_DP_TABLE 0x0080 /// dp table output
25 +#define SC_MF_ALL 0x00FF
28 class EditTextObject;
29 diff --git sc/inc/dpoutput.hxx sc/inc/dpoutput.hxx
30 index 025e62d..90c0062 100644
31 --- sc/inc/dpoutput.hxx
32 +++ sc/inc/dpoutput.hxx
33 @@ -94,6 +94,7 @@ private:
34 com::sun::star::uno::Sequence<
35 com::sun::star::sheet::DataResult> > aData;
36 BOOL bResultsError;
37 + bool mbHasDataLayout;
38 String aDataDescription;
40 // Number format related parameters
41 @@ -124,8 +125,8 @@ private:
42 void HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
43 const com::sun::star::sheet::MemberResult& rData,
44 BOOL bColHeader, long nLevel );
45 - void FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption,
46 - BOOL bFrame = TRUE );
47 + void FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption,
48 + bool bInTable, bool bPopup, bool bHasHiddenMember );
49 void CalcSizes();
51 /** Query which sub-area of the table the cell is in. See
52 diff --git sc/inc/dpoutputgeometry.hxx sc/inc/dpoutputgeometry.hxx
53 new file mode 100644
54 index 0000000..aae3271
55 --- /dev/null
56 +++ sc/inc/dpoutputgeometry.hxx
57 @@ -0,0 +1,75 @@
58 +/*************************************************************************
59 + *
60 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
61 + *
62 + * Copyright 2008 by Sun Microsystems, Inc.
63 + *
64 + * OpenOffice.org - a multi-platform office productivity suite
65 + *
66 + * $RCSfile: xmldpimp.cxx,v $
67 + * $Revision: 1.27.134.1 $
68 + *
69 + * This file is part of OpenOffice.org.
70 + *
71 + * OpenOffice.org is free software: you can redistribute it and/or modify
72 + * it under the terms of the GNU Lesser General Public License version 3
73 + * only, as published by the Free Software Foundation.
74 + *
75 + * OpenOffice.org is distributed in the hope that it will be useful,
76 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
77 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 + * GNU Lesser General Public License version 3 for more details
79 + * (a copy is included in the LICENSE file that accompanied this code).
80 + *
81 + * You should have received a copy of the GNU Lesser General Public License
82 + * version 3 along with OpenOffice.org. If not, see
83 + * <http://www.openoffice.org/license.html>
84 + * for a copy of the LGPLv3 License.
85 + *
86 + ************************************************************************/
88 +#ifndef SC_DPOUTPUTGEOMETRY_HXX
89 +#define SC_DPOUTPUTGEOMETRY_HXX
91 +#include "address.hxx"
92 +#include <vector>
94 +class ScAddress;
96 +class SC_DLLPUBLIC ScDPOutputGeometry
98 +public:
99 + enum FieldType { Column, Row, Page, Data, None };
101 + ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter);
102 + ~ScDPOutputGeometry();
104 + /**
105 + * @param nCount number of row fields, <b>excluding the data layout
106 + * field if exists</b>.
107 + */
108 + void setRowFieldCount(sal_uInt32 nCount);
109 + void setColumnFieldCount(sal_uInt32 nCount);
110 + void setPageFieldCount(sal_uInt32 nCount);
111 + void setDataFieldCount(sal_uInt32 nCount);
113 + void getColumnFieldPositions(::std::vector<ScAddress>& rAddrs) const;
114 + void getRowFieldPositions(::std::vector<ScAddress>& rAddrs) const;
115 + void getPageFieldPositions(::std::vector<ScAddress>& rAddrs) const;
117 + FieldType getFieldButtonType(const ScAddress& rPos) const;
119 +private:
120 + ScDPOutputGeometry(); // disabled
122 +private:
123 + ScRange maOutRange;
124 + sal_uInt32 mnRowFields;
125 + sal_uInt32 mnColumnFields;
126 + sal_uInt32 mnPageFields;
127 + sal_uInt32 mnDataFields;
129 + bool mbShowFilter;
132 +#endif
133 diff --git sc/inc/dpsave.hxx sc/inc/dpsave.hxx
134 index cb381fb..d1d961a 100644
135 --- sc/inc/dpsave.hxx
136 +++ sc/inc/dpsave.hxx
137 @@ -179,6 +179,10 @@ public:
139 void WriteToSource( const com::sun::star::uno::Reference<
140 com::sun::star::uno::XInterface>& xDim );
142 + void UpdateMemberVisibility(const ::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rData);
144 + bool HasInvisibleMember() const;
148 @@ -222,7 +226,7 @@ public:
149 ScDPSaveDimension* DuplicateDimension(const String& rName);
150 SC_DLLPUBLIC ScDPSaveDimension& DuplicateDimension(const ScDPSaveDimension& rDim);
152 - SC_DLLPUBLIC ScDPSaveDimension* GetExistingDimensionByName(const String& rName);
153 + SC_DLLPUBLIC ScDPSaveDimension* GetExistingDimensionByName(const String& rName) const;
154 SC_DLLPUBLIC ScDPSaveDimension* GetNewDimensionByName(const String& rName);
156 void RemoveDimensionByName(const String& rName);
157 @@ -256,6 +260,13 @@ public:
158 SC_DLLPUBLIC ScDPDimensionSaveData* GetDimensionData(); // create if not there
159 void SetDimensionData( const ScDPDimensionSaveData* pNew ); // copied
160 void BuildAllDimensionMembers(ScDPTableData* pData);
162 + /**
163 + * Check whether a dimension has one or more invisible members.
165 + * @param rDimName dimension name
166 + */
167 + SC_DLLPUBLIC bool HasInvisibleMember(const ::rtl::OUString& rDimName) const;
171 diff --git sc/inc/dptabsrc.hxx sc/inc/dptabsrc.hxx
172 index 9d6e8e4..22492d5 100644
173 --- sc/inc/dptabsrc.hxx
174 +++ sc/inc/dptabsrc.hxx
175 @@ -348,6 +348,7 @@ private:
176 BOOL bHasSelectedPage;
177 String aSelectedPage;
178 ScDPItemData* pSelectedData; // internal, temporary, created from aSelectedPage
179 + sal_Bool mbHasHiddenMember;
181 public:
182 ScDPDimension( ScDPSource* pSrc, long nD );
183 diff --git sc/inc/fillinfo.hxx sc/inc/fillinfo.hxx
184 index c9bfc1d..7f8bd54 100644
185 --- sc/inc/fillinfo.hxx
186 +++ sc/inc/fillinfo.hxx
187 @@ -99,6 +99,8 @@ struct CellInfo
188 BOOL bVOverlapped : 1;
189 BOOL bAutoFilter : 1;
190 BOOL bPushButton : 1;
191 + bool bPopupButton: 1;
192 + bool bFilterActive:1;
194 BOOL bPrinted : 1; // bei Bedarf (Pagebreak-Modus)
196 diff --git sc/inc/global.hxx sc/inc/global.hxx
197 index a64dd1c..b2d6e50 100644
198 --- sc/inc/global.hxx
199 +++ sc/inc/global.hxx
200 @@ -94,8 +94,6 @@ extern "C" {
201 #define OLD_PIVOT_IMPLEMENTATION 0
203 //------------------------------------------------------------------------
204 -struct LabelData;
205 -//------------------------------------------------------------------------
207 // die 1000 Namen des Calc...
208 // Clipboard-Namen sind jetzt in so3/soapp.hxx
209 diff --git sc/inc/pivot.hxx sc/inc/pivot.hxx
210 index 042a10d..c548f04 100644
211 --- sc/inc/pivot.hxx
212 +++ sc/inc/pivot.hxx
213 @@ -53,6 +53,7 @@
214 #include "address.hxx"
216 #include <vector>
217 +#include <boost/shared_ptr.hpp>
219 class SubTotal;
220 #include "collect.hxx"
221 @@ -80,7 +81,9 @@ class ScUserListData;
222 class ScMultipleReadHeader;
223 class ScMultipleWriteHeader;
224 class ScProgress;
225 -struct LabelData;
226 +struct ScDPLabelData;
228 +typedef ::boost::shared_ptr<ScDPLabelData> ScDPLabelDataRef;
230 // -----------------------------------------------------------------------
232 @@ -104,8 +107,7 @@ struct ScPivotParam
233 SCCOL nCol; // Cursor Position /
234 SCROW nRow; // bzw. Anfang des Zielbereiches
235 SCTAB nTab;
236 - LabelData** ppLabelArr;
237 - SCSIZE nLabels;
238 + ::std::vector<ScDPLabelDataRef> maLabelArray;
239 PivotField aPageArr[PIVOT_MAXPAGEFIELD];
240 PivotField aColArr[PIVOT_MAXFIELD];
241 PivotField aRowArr[PIVOT_MAXFIELD];
242 @@ -126,10 +128,8 @@ struct ScPivotParam
243 ScPivotParam& operator= ( const ScPivotParam& r );
244 BOOL operator== ( const ScPivotParam& r ) const;
245 void Clear ();
246 - void ClearLabelData ();
247 void ClearPivotArrays();
248 - void SetLabelData ( LabelData** ppLabArr,
249 - SCSIZE nLab );
250 + void SetLabelData (const ::std::vector<ScDPLabelDataRef>& r);
251 void SetPivotArrays ( const PivotField* pPageArr,
252 const PivotField* pColArr,
253 const PivotField* pRowArr,
254 @@ -366,7 +366,7 @@ public:
256 //------------------------------------------------------------------------
258 -struct LabelData
259 +struct ScDPLabelData
261 String maName; /// Visible name of the dimension.
262 SCsCOL mnCol;
263 @@ -383,7 +383,7 @@ struct LabelData
264 ::com::sun::star::sheet::DataPilotFieldLayoutInfo maLayoutInfo; /// Layout info.
265 ::com::sun::star::sheet::DataPilotFieldAutoShowInfo maShowInfo; /// AutoShow info.
267 - explicit LabelData( const String& rName, short nCol, bool bIsValue );
268 + explicit ScDPLabelData( const String& rName, short nCol, bool bIsValue );
271 // ============================================================================
272 @@ -401,7 +401,6 @@ struct ScDPFuncData
274 // ============================================================================
276 -typedef LabelData ScDPLabelData;
277 typedef std::vector< ScDPLabelData > ScDPLabelDataVec;
278 typedef std::vector< String > ScDPNameVec;
280 diff --git sc/inc/scabstdlg.hxx sc/inc/scabstdlg.hxx
281 index 1a2b9a2..2c7f1e0 100644
282 --- sc/inc/scabstdlg.hxx
283 +++ sc/inc/scabstdlg.hxx
284 @@ -244,7 +244,7 @@ class AbstractScDPSubtotalDlg : public VclAbstractDialog //add for ScDPSubtotal
286 public:
287 virtual USHORT GetFuncMask() const = 0;
288 - virtual void FillLabelData( LabelData& rLabelData ) const = 0;
289 + virtual void FillLabelData( ScDPLabelData& rLabelData ) const = 0;
292 class AbstractScDPNumGroupDlg : public VclAbstractDialog
293 diff --git sc/inc/unonames.hxx sc/inc/unonames.hxx
294 index 6afb1a3..89b3a94 100644
295 --- sc/inc/unonames.hxx
296 +++ sc/inc/unonames.hxx
297 @@ -566,6 +566,7 @@
298 #define SC_UNO_LAYOUTNAME "LayoutName"
299 #define SC_UNO_FIELD_SUBTOTALNAME "FieldSubtotalName"
300 #define SC_UNO_GRANDTOTAL_NAME "GrandTotalName"
301 +#define SC_UNO_HAS_HIDDEN_MEMBER "HasHiddenMember"
303 // (preliminary:)
304 #define SC_UNO_REFVALUE "ReferenceValue"
305 diff --git sc/source/core/data/dpobject.cxx sc/source/core/data/dpobject.cxx
306 index afa90e9..7e977f0 100644
307 --- sc/source/core/data/dpobject.cxx
308 +++ sc/source/core/data/dpobject.cxx
309 @@ -1807,7 +1807,7 @@ BOOL ScDPObject::FillOldParam(ScPivotParam& rParam, BOOL bForFile) const
310 return TRUE;
313 -void lcl_FillLabelData( LabelData& rData, const uno::Reference< beans::XPropertySet >& xDimProp )
314 +void lcl_FillLabelData( ScDPLabelData& rData, const uno::Reference< beans::XPropertySet >& xDimProp )
316 uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDimProp, uno::UNO_QUERY );
317 if ( xDimProp.is() && xDimSupp.is() )
318 @@ -1853,6 +1853,8 @@ void lcl_FillLabelData( LabelData& rData, const uno::Reference< beans::XProperty
320 BOOL ScDPObject::FillLabelData(ScPivotParam& rParam)
322 + rParam.maLabelArray.clear();
324 ((ScDPObject*)this)->CreateObjects();
326 uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
327 @@ -1863,8 +1865,6 @@ BOOL ScDPObject::FillLabelData(ScPivotParam& rParam)
328 if (!nDimCount)
329 return FALSE;
331 - SCSIZE nOutCount = 0;
332 - LabelData** aLabelArr = new LabelData*[nDimCount];
333 for (long nDim=0; nDim < nDimCount; nDim++)
335 String aFieldName;
336 @@ -1899,24 +1899,15 @@ BOOL ScDPObject::FillLabelData(ScPivotParam& rParam)
337 SCsCOL nCol = static_cast< SCsCOL >( nDim ); //! ???
338 bool bIsValue = true; //! check
340 - aLabelArr[nOutCount] = new LabelData( aFieldName, nCol, bIsValue );
342 - LabelData& rLabelData = *aLabelArr[nOutCount];
343 - GetHierarchies( nDim, rLabelData.maHiers );
344 - GetMembers( nDim, rLabelData.maMembers, &rLabelData.maVisible, &rLabelData.maShowDet );
345 - lcl_FillLabelData( rLabelData, xDimProp );
347 - ++nOutCount;
348 + ScDPLabelDataRef pNewLabel(new ScDPLabelData(aFieldName, nCol, bIsValue));
349 + GetHierarchies(nDim, pNewLabel->maHiers);
350 + GetMembers(nDim, pNewLabel->maMembers, &pNewLabel->maVisible, &pNewLabel->maShowDet);
351 + lcl_FillLabelData(*pNewLabel, xDimProp);
352 + rParam.maLabelArray.push_back(pNewLabel);
357 - rParam.SetLabelData( aLabelArr, nOutCount );
359 - for (SCSIZE i=0; i<nOutCount; i++)
360 - delete aLabelArr[i];
361 - delete[] aLabelArr;
363 return TRUE;
366 diff --git sc/source/core/data/dpoutput.cxx sc/source/core/data/dpoutput.cxx
367 index de9c898..431cf47 100644
368 --- sc/source/core/data/dpoutput.cxx
369 +++ sc/source/core/data/dpoutput.cxx
370 @@ -121,8 +121,13 @@ struct ScDPOutLevelData
371 uno::Sequence<sheet::MemberResult> aResult;
372 String maName; /// Name is the internal field name.
373 String aCaption; /// Caption is the name visible in the output table.
374 + bool mbHasHiddenMember;
376 - ScDPOutLevelData() { nDim = nHier = nLevel = nDimPos = -1; }
377 + ScDPOutLevelData()
378 + {
379 + nDim = nHier = nLevel = nDimPos = -1;
380 + mbHasHiddenMember = false;
383 BOOL operator<(const ScDPOutLevelData& r) const
384 { return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) ||
385 @@ -371,6 +376,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
386 aStartPos( rPos ),
387 bDoFilter( bFilter ),
388 bResultsError( FALSE ),
389 + mbHasDataLayout(false),
390 pColNumFmt( NULL ),
391 pRowNumFmt( NULL ),
392 nColFmtCount( 0 ),
393 @@ -415,6 +421,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
394 BOOL bIsDataLayout = ScUnoHelpFunctions::GetBoolProperty(
395 xDimProp,
396 rtl::OUString::createFromAscii(DP_PROP_ISDATALAYOUT) );
397 + bool bHasHiddenMember = ScUnoHelpFunctions::GetBoolProperty(
398 + xDimProp, OUString::createFromAscii(SC_UNO_HAS_HIDDEN_MEMBER));
400 if ( eDimOrient != sheet::DataPilotFieldOrientation_HIDDEN )
402 @@ -454,6 +462,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
403 OUString::createFromAscii(SC_UNO_LAYOUTNAME));
404 any >>= aCaption;
407 + bool bRowFieldHasMember = false;
408 switch ( eDimOrient )
410 case sheet::DataPilotFieldOrientation_COLUMN:
411 @@ -464,6 +474,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
412 pColFields[nColFieldCount].aResult = xLevRes->getResults();
413 pColFields[nColFieldCount].maName = aName;
414 pColFields[nColFieldCount].aCaption= aCaption;
415 + pColFields[nColFieldCount].mbHasHiddenMember = bHasHiddenMember;
416 if (!lcl_MemberEmpty(pColFields[nColFieldCount].aResult))
417 ++nColFieldCount;
418 break;
419 @@ -475,8 +486,12 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
420 pRowFields[nRowFieldCount].aResult = xLevRes->getResults();
421 pRowFields[nRowFieldCount].maName = aName;
422 pRowFields[nRowFieldCount].aCaption= aCaption;
423 + pRowFields[nRowFieldCount].mbHasHiddenMember = bHasHiddenMember;
424 if (!lcl_MemberEmpty(pRowFields[nRowFieldCount].aResult))
425 + {
426 ++nRowFieldCount;
427 + bRowFieldHasMember = true;
429 break;
430 case sheet::DataPilotFieldOrientation_PAGE:
431 pPageFields[nPageFieldCount].nDim = nDim;
432 @@ -486,6 +501,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
433 pPageFields[nPageFieldCount].aResult = lcl_GetSelectedPageAsResult(xDimProp);
434 pPageFields[nPageFieldCount].maName = aName;
435 pPageFields[nPageFieldCount].aCaption= aCaption;
436 + pPageFields[nPageFieldCount].mbHasHiddenMember = bHasHiddenMember;
437 // no check on results for page fields
438 ++nPageFieldCount;
439 break;
440 @@ -498,6 +514,9 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
441 // get number formats from data dimensions
442 if ( bIsDataLayout )
444 + if (bRowFieldHasMember)
445 + mbHasDataLayout = true;
447 DBG_ASSERT( nLevCount == 1, "data layout: multiple levels?" );
448 if ( eDimOrient == sheet::DataPilotFieldOrientation_COLUMN )
449 lcl_FillNumberFormats( pColNumFmt, nColFmtCount, xLevRes, xDims );
450 @@ -658,14 +677,20 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
454 -void ScDPOutput::FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption, BOOL bFrame )
455 +void ScDPOutput::FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption,
456 + bool bInTable, bool bPopup, bool bHasHiddenMember )
458 pDoc->SetString( nCol, nRow, nTab, rCaption );
459 - if (bFrame)
460 - lcl_SetFrame( pDoc,nTab, nCol,nRow, nCol,nRow, 20 );
461 + if (bInTable)
462 + lcl_SetFrame( pDoc,nTab, nCol,nRow, nCol,nRow, 20 );
464 // Button
465 - pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr(SC_MF_BUTTON) );
466 + sal_uInt16 nMergeFlag = SC_MF_BUTTON;
467 + if (bPopup)
468 + nMergeFlag |= SC_MF_BUTTON_POPUP;
469 + if (bHasHiddenMember)
470 + nMergeFlag |= SC_MF_HIDDEN_MEMBER;
471 + pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr(nMergeFlag) );
473 lcl_SetStyleById( pDoc,nTab, nCol,nRow, nCol,nRow, STR_PIVOT_STYLE_FIELDNAME );
475 @@ -799,7 +824,7 @@ void ScDPOutput::Output()
476 SCCOL nHdrCol = aStartPos.Col();
477 SCROW nHdrRow = aStartPos.Row() + nField + ( bDoFilter ? 1 : 0 );
478 // draw without frame for consistency with filter button:
479 - FieldCell( nHdrCol, nHdrRow, nTab, pPageFields[nField].aCaption, FALSE );
480 + FieldCell( nHdrCol, nHdrRow, nTab, pPageFields[nField].aCaption, false, false, pPageFields[nField].mbHasHiddenMember );
481 SCCOL nFldCol = nHdrCol + 1;
483 String aPageValue;
484 @@ -838,7 +863,7 @@ void ScDPOutput::Output()
485 for (nField=0; nField<nColFieldCount; nField++)
487 SCCOL nHdrCol = nDataStartCol + (SCCOL)nField; //! check for overflow
488 - FieldCell( nHdrCol, nTabStartRow, nTab, pColFields[nField].aCaption );
489 + FieldCell( nHdrCol, nTabStartRow, nTab, pColFields[nField].aCaption, true, true, pColFields[nField].mbHasHiddenMember );
491 SCROW nRowPos = nMemberStartRow + (SCROW)nField; //! check for overflow
492 const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nField].aResult;
493 @@ -873,9 +898,12 @@ void ScDPOutput::Output()
495 for (nField=0; nField<nRowFieldCount; nField++)
497 + bool bDataLayout = mbHasDataLayout && (nField == nRowFieldCount-1);
499 SCCOL nHdrCol = nTabStartCol + (SCCOL)nField; //! check for overflow
500 SCROW nHdrRow = nDataStartRow - 1;
501 - FieldCell( nHdrCol, nHdrRow, nTab, pRowFields[nField].aCaption );
502 + FieldCell( nHdrCol, nHdrRow, nTab, pRowFields[nField].aCaption, true, !bDataLayout,
503 + pRowFields[nField].mbHasHiddenMember );
505 SCCOL nColPos = nMemberStartCol + (SCCOL)nField; //! check for overflow
506 const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nField].aResult;
507 diff --git sc/source/core/data/dpoutputgeometry.cxx sc/source/core/data/dpoutputgeometry.cxx
508 new file mode 100644
509 index 0000000..4d6996b
510 --- /dev/null
511 +++ sc/source/core/data/dpoutputgeometry.cxx
512 @@ -0,0 +1,204 @@
513 +/*************************************************************************
515 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
516 + *
517 + * Copyright 2008 by Sun Microsystems, Inc.
519 + * OpenOffice.org - a multi-platform office productivity suite
521 + * $RCSfile: xmldpimp.cxx,v $
522 + * $Revision: 1.27.134.1 $
524 + * This file is part of OpenOffice.org.
526 + * OpenOffice.org is free software: you can redistribute it and/or modify
527 + * it under the terms of the GNU Lesser General Public License version 3
528 + * only, as published by the Free Software Foundation.
530 + * OpenOffice.org is distributed in the hope that it will be useful,
531 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
532 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
533 + * GNU Lesser General Public License version 3 for more details
534 + * (a copy is included in the LICENSE file that accompanied this code).
536 + * You should have received a copy of the GNU Lesser General Public License
537 + * version 3 along with OpenOffice.org. If not, see
538 + * <http://www.openoffice.org/license.html>
539 + * for a copy of the LGPLv3 License.
541 + ************************************************************************/
543 +// MARKER(update_precomp.py): autogen include statement, do not remove
544 +#include "precompiled_sc.hxx"
548 +// INCLUDE ---------------------------------------------------------------
550 +#include "dpoutputgeometry.hxx"
551 +#include "address.hxx"
553 +#include <vector>
555 +using ::std::vector;
557 +ScDPOutputGeometry::ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter) :
558 + maOutRange(rOutRange),
559 + mnRowFields(0),
560 + mnColumnFields(0),
561 + mnPageFields(0),
562 + mnDataFields(0),
563 + mbShowFilter(bShowFilter)
567 +ScDPOutputGeometry::~ScDPOutputGeometry()
571 +void ScDPOutputGeometry::setRowFieldCount(sal_uInt32 nCount)
573 + mnRowFields = nCount;
576 +void ScDPOutputGeometry::setColumnFieldCount(sal_uInt32 nCount)
578 + mnColumnFields = nCount;
581 +void ScDPOutputGeometry::setPageFieldCount(sal_uInt32 nCount)
583 + mnPageFields = nCount;
586 +void ScDPOutputGeometry::setDataFieldCount(sal_uInt32 nCount)
588 + mnDataFields = nCount;
591 +void ScDPOutputGeometry::getColumnFieldPositions(vector<ScAddress>& rAddrs) const
593 + vector<ScAddress> aAddrs;
594 + if (!mnColumnFields)
596 + rAddrs.swap(aAddrs);
597 + return;
600 + bool bDataLayout = mnDataFields > 1;
602 + SCROW nCurRow = maOutRange.aStart.Row();
604 + if (mnPageFields)
606 + SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
607 + SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
608 + nCurRow = nRowEnd + 2;
610 + else if (mbShowFilter)
611 + nCurRow += 2;
613 + SCROW nRow = nCurRow;
614 + SCTAB nTab = maOutRange.aStart.Tab();
615 + SCCOL nColStart = maOutRange.aStart.Col() + mnRowFields + bDataLayout;
616 + SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnColumnFields-1);
618 + for (SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
619 + aAddrs.push_back(ScAddress(nCol, nRow, nTab));
620 + rAddrs.swap(aAddrs);
623 +void ScDPOutputGeometry::getRowFieldPositions(vector<ScAddress>& rAddrs) const
625 + vector<ScAddress> aAddrs;
626 + if (!mnRowFields)
628 + rAddrs.swap(aAddrs);
629 + return;
632 + SCROW nCurRow = maOutRange.aStart.Row();
634 + if (mnPageFields)
636 + SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
637 + SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
638 + nCurRow = nRowEnd + 2;
640 + else if (mbShowFilter)
641 + nCurRow += 2;
643 + nCurRow += static_cast<SCROW>(mnColumnFields);
645 + SCROW nRow = nCurRow;
646 + SCTAB nTab = maOutRange.aStart.Tab();
647 + SCCOL nColStart = maOutRange.aStart.Col();
648 + SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnRowFields-1);
650 + for (SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
651 + aAddrs.push_back(ScAddress(nCol, nRow, nTab));
652 + rAddrs.swap(aAddrs);
655 +void ScDPOutputGeometry::getPageFieldPositions(vector<ScAddress>& rAddrs) const
657 + vector<ScAddress> aAddrs;
658 + if (!mnPageFields)
660 + rAddrs.swap(aAddrs);
661 + return;
664 + SCTAB nTab = maOutRange.aStart.Tab();
665 + SCCOL nCol = maOutRange.aStart.Col();
667 + SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
668 + SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
670 + for (SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow)
671 + aAddrs.push_back(ScAddress(nCol, nRow, nTab));
672 + rAddrs.swap(aAddrs);
675 +ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAddress& rPos) const
677 + // We will ignore the table position for now.
679 + bool bDataLayout = mnDataFields > 1;
681 + SCROW nCurRow = maOutRange.aStart.Row();
683 + if (mnPageFields)
685 + SCCOL nCol = maOutRange.aStart.Col();
686 + SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
687 + SCROW nRowEnd = nRowStart + static_cast<SCCOL>(mnPageFields-1);
688 + if (rPos.Col() == nCol && nRowStart <= rPos.Row() && rPos.Row() <= nRowEnd)
689 + return Page;
691 + nCurRow = nRowEnd + 2;
693 + else if (mbShowFilter)
694 + nCurRow += 2;
696 + if (mnColumnFields)
698 + SCROW nRow = nCurRow;
699 + SCCOL nColStart = maOutRange.aStart.Col() + mnRowFields + bDataLayout;
700 + SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnColumnFields-1);
701 + if (rPos.Row() == nRow && nColStart <= rPos.Col() && rPos.Col() <= nColEnd)
702 + return Column;
704 + nCurRow += static_cast<SCROW>(mnColumnFields);
707 + if (mnRowFields)
709 + SCCOL nColStart = maOutRange.aStart.Col();
710 + SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnRowFields-1);
711 + if (rPos.Row() == nCurRow && nColStart <= rPos.Col() && rPos.Col() <= nColEnd)
712 + return Row;
715 + return None;
717 diff --git sc/source/core/data/dpsave.cxx sc/source/core/data/dpsave.cxx
718 index f41ea2c..4432eb9 100644
719 --- sc/source/core/data/dpsave.cxx
720 +++ sc/source/core/data/dpsave.cxx
721 @@ -62,6 +62,7 @@
723 using namespace com::sun::star;
724 using ::rtl::OUString;
725 +using ::rtl::OUStringHash;
726 using ::std::hash_map;
727 using ::std::auto_ptr;
729 @@ -642,6 +643,8 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
730 nHierCount = xHiers->getCount();
733 + sal_Bool bHasHiddenMember = false;
735 for (long nHier=0; nHier<nHierCount; nHier++)
737 uno::Reference<uno::XInterface> xHierarchy = ScUnoHelpFunctions::AnyToInterface( xHiers->getByIndex(nHier) );
738 @@ -734,12 +737,15 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
740 for (MemberList::const_iterator i=maMemberList.begin(); i != maMemberList.end() ; i++)
742 - rtl::OUString aMemberName = (*i)->GetName();
743 + ScDPSaveMember* pMember = *i;
744 + if (!pMember->GetIsVisible())
745 + bHasHiddenMember = true;
746 + rtl::OUString aMemberName = pMember->GetName();
747 if ( xMembers->hasByName( aMemberName ) )
749 uno::Reference<uno::XInterface> xMemberInt = ScUnoHelpFunctions::AnyToInterface(
750 xMembers->getByName( aMemberName ) );
751 - (*i)->WriteToSource( xMemberInt, nPosition );
752 + pMember->WriteToSource( xMemberInt, nPosition );
754 if ( nPosition >= 0 )
755 ++nPosition; // increase if initialized
756 @@ -751,6 +757,40 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
761 + if (xDimProp.is())
763 + uno::Any any;
764 + any <<= bHasHiddenMember;
765 + xDimProp->setPropertyValue(
766 + OUString::createFromAscii(SC_UNO_HAS_HIDDEN_MEMBER), any);
770 +void ScDPSaveDimension::UpdateMemberVisibility(const hash_map<OUString, bool, OUStringHash>& rData)
772 + typedef hash_map<OUString, bool, OUStringHash> DataMap;
773 + MemberList::iterator itrMem = maMemberList.begin(), itrMemEnd = maMemberList.end();
774 + for (; itrMem != itrMemEnd; ++itrMem)
776 + ScDPSaveMember* pMem = *itrMem;
777 + const String& rMemName = pMem->GetName();
778 + DataMap::const_iterator itr = rData.find(rMemName);
779 + if (itr != rData.end())
780 + pMem->SetIsVisible(itr->second);
784 +bool ScDPSaveDimension::HasInvisibleMember() const
786 + MemberList::const_iterator itrMem = maMemberList.begin(), itrMemEnd = maMemberList.end();
787 + for (; itrMem != itrMemEnd; ++itrMem)
789 + const ScDPSaveMember* pMem = *itrMem;
790 + if (!pMem->GetIsVisible())
791 + return true;
793 + return false;
796 // -----------------------------------------------------------------------
797 @@ -907,7 +947,7 @@ ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const String& rName)
798 return pNew;
801 -ScDPSaveDimension* ScDPSaveData::GetExistingDimensionByName(const String& rName)
802 +ScDPSaveDimension* ScDPSaveData::GetExistingDimensionByName(const String& rName) const
804 long nCount = aDimList.Count();
805 for (long i=0; i<nCount; i++)
806 @@ -1304,3 +1344,11 @@ void ScDPSaveData::BuildAllDimensionMembers(ScDPTableData* pData)
807 mbDimensionMembersBuilt = true;
810 +bool ScDPSaveData::HasInvisibleMember(const OUString& rDimName) const
812 + ScDPSaveDimension* pDim = GetExistingDimensionByName(rDimName);
813 + if (!pDim)
814 + return false;
816 + return pDim->HasInvisibleMember();
818 diff --git sc/source/core/data/dptabsrc.cxx sc/source/core/data/dptabsrc.cxx
819 index 04e75ba..2f581c0 100644
820 --- sc/source/core/data/dptabsrc.cxx
821 +++ sc/source/core/data/dptabsrc.cxx
822 @@ -1371,7 +1371,8 @@ ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) :
823 mpSubtotalName(NULL),
824 nSourceDim( -1 ),
825 bHasSelectedPage( FALSE ),
826 - pSelectedData( NULL )
827 + pSelectedData( NULL ),
828 + mbHasHiddenMember(false)
830 //! hold pSource
832 @@ -1567,6 +1568,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetIn
833 {MAP_CHAR_LEN(SC_UNO_USEDHIER), 0, &getCppuType((sal_Int32*)0), 0, 0 },
834 {MAP_CHAR_LEN(SC_UNO_LAYOUTNAME), 0, &getCppuType(static_cast<rtl::OUString*>(0)), 0, 0 },
835 {MAP_CHAR_LEN(SC_UNO_FIELD_SUBTOTALNAME), 0, &getCppuType(static_cast<rtl::OUString*>(0)), 0, 0 },
836 + {MAP_CHAR_LEN(SC_UNO_HAS_HIDDEN_MEMBER), 0, &getBooleanCppuType(), 0, 0 },
837 {0,0,0,0,0,0}
839 static uno::Reference<beans::XPropertySetInfo> aRef =
840 @@ -1649,6 +1651,8 @@ void SAL_CALL ScDPDimension::setPropertyValue( const rtl::OUString& aPropertyNam
841 if (aValue >>= aName)
842 mpSubtotalName.reset(new OUString(aName));
844 + else if (aNameStr.EqualsAscii(SC_UNO_HAS_HIDDEN_MEMBER))
845 + aValue >>= mbHasHiddenMember;
846 else
848 DBG_ERROR("unknown property");
849 @@ -1712,6 +1716,8 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const rtl::OUString& aPropert
850 aRet <<= mpLayoutName.get() ? *mpLayoutName : OUString::createFromAscii("");
851 else if (aNameStr.EqualsAscii(SC_UNO_FIELD_SUBTOTALNAME))
852 aRet <<= mpSubtotalName.get() ? *mpSubtotalName : OUString::createFromAscii("");
853 + else if (aNameStr.EqualsAscii(SC_UNO_HAS_HIDDEN_MEMBER))
854 + aRet <<= mbHasHiddenMember;
855 else
857 DBG_ERROR("unknown property");
858 diff --git sc/source/core/data/fillinfo.cxx sc/source/core/data/fillinfo.cxx
859 index 9fbeb09..53abf3e 100644
860 --- sc/source/core/data/fillinfo.cxx
861 +++ sc/source/core/data/fillinfo.cxx
862 @@ -332,6 +332,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
863 pInfo->bVOverlapped = FALSE;
864 pInfo->bAutoFilter = FALSE;
865 pInfo->bPushButton = FALSE;
866 + pInfo->bPopupButton = false;
867 + pInfo->bFilterActive = false;
868 pInfo->nRotateDir = SC_ROTDIR_NONE;
870 pInfo->bPrinted = FALSE; // view-intern
871 @@ -458,6 +460,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
872 BOOL bAutoFilter = ((nOverlap & SC_MF_AUTO) != 0);
873 BOOL bPushButton = ((nOverlap & SC_MF_BUTTON) != 0);
874 BOOL bScenario = ((nOverlap & SC_MF_SCENARIO) != 0);
875 + bool bPopupButton = ((nOverlap & SC_MF_BUTTON_POPUP) != 0);
876 + bool bFilterActive = ((nOverlap & SC_MF_HIDDEN_MEMBER) != 0);
877 if (bMerged||bHOverlapped||bVOverlapped)
878 bAnyMerged = TRUE; // intern
880 @@ -498,6 +502,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
881 pInfo->bVOverlapped = bVOverlapped;
882 pInfo->bAutoFilter = bAutoFilter;
883 pInfo->bPushButton = bPushButton;
884 + pInfo->bPopupButton = bPopupButton;
885 + pInfo->bFilterActive = bFilterActive;
886 pInfo->pLinesAttr = pLinesAttr;
887 pInfo->mpTLBRLine = pTLBRLine;
888 pInfo->mpBLTRLine = pBLTRLine;
889 @@ -512,7 +518,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
890 nCurRow >= aEmbedRange.aStart.Row() &&
891 nCurRow <= aEmbedRange.aEnd.Row();
893 - if (bPushButton || bScenario)
894 + if (bScenario)
896 pInfo->pBackground = ScGlobal::GetButtonBrushItem();
897 pThisRowInfo->bEmptyBack = FALSE;
898 diff --git sc/source/core/data/global2.cxx sc/source/core/data/global2.cxx
899 index 58b43e2..6272574 100644
900 --- sc/source/core/data/global2.cxx
901 +++ sc/source/core/data/global2.cxx
902 @@ -56,6 +56,7 @@
903 #include "sc.hrc"
904 #include "globstr.hrc"
906 +using ::std::vector;
908 // -----------------------------------------------------------------------
910 @@ -825,7 +826,6 @@ bool PivotField::operator==( const PivotField& r ) const
912 ScPivotParam::ScPivotParam()
913 : nCol(0), nRow(0), nTab(0),
914 - ppLabelArr( NULL ), nLabels(0),
915 nPageCount(0), nColCount(0), nRowCount(0), nDataCount(0),
916 bIgnoreEmptyRows(FALSE), bDetectCategories(FALSE),
917 bMakeTotalCol(TRUE), bMakeTotalRow(TRUE)
918 @@ -836,23 +836,22 @@ ScPivotParam::ScPivotParam()
920 ScPivotParam::ScPivotParam( const ScPivotParam& r )
921 : nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ),
922 - ppLabelArr( NULL ), nLabels(0),
923 nPageCount(0), nColCount(0), nRowCount(0), nDataCount(0),
924 bIgnoreEmptyRows(r.bIgnoreEmptyRows),
925 bDetectCategories(r.bDetectCategories),
926 bMakeTotalCol(r.bMakeTotalCol),
927 bMakeTotalRow(r.bMakeTotalRow)
929 - SetLabelData ( r.ppLabelArr, r.nLabels );
930 SetPivotArrays ( r.aPageArr, r.aColArr, r.aRowArr, r.aDataArr,
931 r.nPageCount, r.nColCount, r.nRowCount, r.nDataCount );
933 + SetLabelData(r.maLabelArray);
936 //------------------------------------------------------------------------
938 __EXPORT ScPivotParam::~ScPivotParam()
940 - ClearLabelData();
943 //------------------------------------------------------------------------
944 @@ -864,26 +863,10 @@ void __EXPORT ScPivotParam::Clear()
945 nTab = 0;
946 bIgnoreEmptyRows = bDetectCategories = FALSE;
947 bMakeTotalCol = bMakeTotalRow = TRUE;
948 - ClearLabelData();
949 ClearPivotArrays();
950 + maLabelArray.clear();
953 -//------------------------------------------------------------------------
955 -void __EXPORT ScPivotParam::ClearLabelData()
957 - if ( (nLabels > 0) && ppLabelArr )
959 - for ( SCSIZE i=0; i<nLabels; i++ )
960 - delete ppLabelArr[i];
961 - delete [] ppLabelArr;
962 - ppLabelArr = NULL;
963 - nLabels = 0;
967 -//------------------------------------------------------------------------
969 void __EXPORT ScPivotParam::ClearPivotArrays()
971 memset( aPageArr, 0, PIVOT_MAXPAGEFIELD * sizeof(PivotField) );
972 @@ -896,20 +879,17 @@ void __EXPORT ScPivotParam::ClearPivotArrays()
973 nDataCount = 0;
976 -//------------------------------------------------------------------------
978 -void __EXPORT ScPivotParam::SetLabelData( LabelData** pLabArr,
979 - SCSIZE nLab )
980 +void ScPivotParam::SetLabelData(const vector<ScDPLabelDataRef>& r)
982 - ClearLabelData();
984 - if ( (nLab > 0) && pLabArr )
986 - nLabels = (nLab>MAX_LABELS) ? MAX_LABELS : nLab;
987 - ppLabelArr = new LabelData*[nLabels];
988 - for ( SCSIZE i=0; i<nLabels; i++ )
989 - ppLabelArr[i] = new LabelData( *(pLabArr[i]) );
991 + vector<ScDPLabelDataRef> aNewArray;
992 + aNewArray.reserve(r.size());
993 + for (vector<ScDPLabelDataRef>::const_iterator itr = r.begin(), itrEnd = r.end();
994 + itr != itrEnd; ++itr)
996 + ScDPLabelDataRef p(new ScDPLabelData(**itr));
997 + aNewArray.push_back(p);
999 + maLabelArray.swap(aNewArray);
1002 //------------------------------------------------------------------------
1003 @@ -951,10 +931,9 @@ ScPivotParam& __EXPORT ScPivotParam::operator=( const ScPivotParam& r )
1004 bMakeTotalCol = r.bMakeTotalCol;
1005 bMakeTotalRow = r.bMakeTotalRow;
1007 - SetLabelData ( r.ppLabelArr, r.nLabels );
1008 SetPivotArrays ( r.aPageArr, r.aColArr, r.aRowArr, r.aDataArr,
1009 r.nPageCount, r.nColCount, r.nRowCount, r.nDataCount );
1011 + SetLabelData(r.maLabelArray);
1012 return *this;
1015 @@ -969,7 +948,7 @@ BOOL __EXPORT ScPivotParam::operator==( const ScPivotParam& r ) const
1016 && (bDetectCategories == r.bDetectCategories)
1017 && (bMakeTotalCol == r.bMakeTotalCol)
1018 && (bMakeTotalRow == r.bMakeTotalRow)
1019 - && (nLabels == r.nLabels)
1020 + && (maLabelArray.size() == r.maLabelArray.size())
1021 && (nPageCount == r.nPageCount)
1022 && (nColCount == r.nColCount)
1023 && (nRowCount == r.nRowCount)
1024 diff --git sc/source/core/data/makefile.mk sc/source/core/data/makefile.mk
1025 index 2abd0d8..c631bb4 100644
1026 --- sc/source/core/data/makefile.mk
1027 +++ sc/source/core/data/makefile.mk
1028 @@ -79,6 +79,7 @@ SLOFILES = \
1029 $(SLO)$/dpgroup.obj \
1030 $(SLO)$/dpobject.obj \
1031 $(SLO)$/dpoutput.obj \
1032 + $(SLO)$/dpoutputgeometry.obj \
1033 $(SLO)$/dpsave.obj \
1034 $(SLO)$/dpsdbtab.obj \
1035 $(SLO)$/dpshttab.obj \
1036 @@ -141,6 +142,7 @@ EXCEPTIONSFILES= \
1037 $(SLO)$/dpsdbtab.obj \
1038 $(SLO)$/dpobject.obj \
1039 $(SLO)$/dpoutput.obj \
1040 + $(SLO)$/dpoutputgeometry.obj \
1041 $(SLO)$/dpsave.obj \
1042 $(SLO)$/dbdocutl.obj \
1043 $(SLO)$/dptabsrc.obj \
1044 diff --git sc/source/core/data/pivot2.cxx sc/source/core/data/pivot2.cxx
1045 index d45cebf..924a5cd 100644
1046 --- sc/source/core/data/pivot2.cxx
1047 +++ sc/source/core/data/pivot2.cxx
1048 @@ -492,7 +492,7 @@ ScDataObject* ScPivotCollection::Clone() const
1050 // ============================================================================
1052 -LabelData::LabelData( const String& rName, short nCol, bool bIsValue ) :
1053 +ScDPLabelData::ScDPLabelData( const String& rName, short nCol, bool bIsValue ) :
1054 maName( rName ),
1055 mnCol( nCol ),
1056 mnFuncMask( PIVOT_FUNC_NONE ),
1057 diff --git sc/source/filter/excel/xipivot.cxx sc/source/filter/excel/xipivot.cxx
1058 index cc449b9..f225c67 100644
1059 --- sc/source/filter/excel/xipivot.cxx
1060 +++ sc/source/filter/excel/xipivot.cxx
1061 @@ -48,7 +48,9 @@
1062 #include "dpdimsave.hxx"
1063 #include "dpobject.hxx"
1064 #include "dpshttab.hxx"
1065 +#include "dpoutputgeometry.hxx"
1066 #include "scitems.hxx"
1067 +#include "attrib.hxx"
1069 #include "xltracer.hxx"
1070 #include "xistream.hxx"
1071 @@ -60,6 +62,8 @@
1072 #include "excform.hxx"
1073 #include "xltable.hxx"
1075 +#include <vector>
1077 using ::rtl::OUString;
1078 using ::com::sun::star::sheet::DataPilotFieldOrientation;
1079 using ::com::sun::star::sheet::DataPilotFieldOrientation_DATA;
1080 @@ -67,6 +71,7 @@ using ::com::sun::star::sheet::DataPilotFieldSortInfo;
1081 using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo;
1082 using ::com::sun::star::sheet::DataPilotFieldLayoutInfo;
1083 using ::com::sun::star::sheet::DataPilotFieldReference;
1084 +using ::std::vector;
1086 // ============================================================================
1087 // Pivot cache
1088 @@ -1393,6 +1398,8 @@ void XclImpPivotTable::Convert()
1090 GetDoc().GetDPCollection()->Insert( pDPObj );
1091 mpDPObj = pDPObj;
1093 + ApplyMergeFlags(aOutRange, aSaveData);
1096 void XclImpPivotTable::MaybeRefresh()
1097 @@ -1405,6 +1412,76 @@ void XclImpPivotTable::MaybeRefresh()
1101 +void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveData& rSaveData)
1103 + // Apply merge flags for varoius datapilot controls.
1105 + ScDPOutputGeometry aGeometry(rOutRange, false);
1106 + aGeometry.setColumnFieldCount(maPTInfo.mnColFields);
1107 + aGeometry.setPageFieldCount(maPTInfo.mnPageFields);
1108 + aGeometry.setDataFieldCount(maPTInfo.mnDataFields);
1110 + // Excel includes data layout field in the row field count. We need to
1111 + // subtract it.
1112 + bool bDataLayout = maPTInfo.mnDataFields > 1;
1113 + aGeometry.setRowFieldCount(maPTInfo.mnRowFields - static_cast<sal_uInt32>(bDataLayout));
1115 + ScDocument& rDoc = GetDoc();
1117 + vector<ScAddress> aPageBtns;
1118 + aGeometry.getPageFieldPositions(aPageBtns);
1119 + vector<ScAddress>::const_iterator itr = aPageBtns.begin(), itrEnd = aPageBtns.end();
1120 + for (; itr != itrEnd; ++itr)
1122 + sal_uInt16 nMFlag = SC_MF_BUTTON;
1123 + String aName;
1124 + rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
1125 + if (rSaveData.HasInvisibleMember(aName))
1126 + nMFlag |= SC_MF_HIDDEN_MEMBER;
1128 + ScMergeFlagAttr aAttr(nMFlag);
1129 + rDoc.ApplyAttr(itr->Col(), itr->Row(), itr->Tab(), aAttr);
1130 + ScMergeFlagAttr aAttr2(SC_MF_AUTO);
1131 + rDoc.ApplyAttr(itr->Col()+1, itr->Row(), itr->Tab(), aAttr2);
1134 + vector<ScAddress> aColBtns;
1135 + aGeometry.getColumnFieldPositions(aColBtns);
1136 + itr = aColBtns.begin();
1137 + itrEnd = aColBtns.end();
1138 + for (; itr != itrEnd; ++itr)
1140 + sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP;
1141 + String aName;
1142 + rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
1143 + if (rSaveData.HasInvisibleMember(aName))
1144 + nMFlag |= SC_MF_HIDDEN_MEMBER;
1145 + ScMergeFlagAttr aAttr(nMFlag);
1146 + rDoc.ApplyAttr(itr->Col(), itr->Row(), itr->Tab(), aAttr);
1149 + vector<ScAddress> aRowBtns;
1150 + aGeometry.getRowFieldPositions(aRowBtns);
1151 + itr = aRowBtns.begin();
1152 + itrEnd = aRowBtns.end();
1153 + for (; itr != itrEnd; ++itr)
1155 + sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP;
1156 + String aName;
1157 + rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
1158 + if (rSaveData.HasInvisibleMember(aName))
1159 + nMFlag |= SC_MF_HIDDEN_MEMBER;
1160 + ScMergeFlagAttr aAttr(nMFlag);
1161 + rDoc.ApplyAttr(itr->Col(), itr->Row(), itr->Tab(), aAttr);
1163 + if (bDataLayout)
1165 + --itr; // move back to the last row field position.
1166 + ScMergeFlagAttr aAttr(SC_MF_BUTTON);
1167 + rDoc.ApplyAttr(itr->Col()+1, itr->Row(), itr->Tab(), aAttr);
1171 // ============================================================================
1172 // ============================================================================
1174 diff --git sc/source/filter/inc/xipivot.hxx sc/source/filter/inc/xipivot.hxx
1175 index 813963c..d043a95 100644
1176 --- sc/source/filter/inc/xipivot.hxx
1177 +++ sc/source/filter/inc/xipivot.hxx
1178 @@ -363,6 +363,8 @@ public:
1180 void MaybeRefresh();
1182 + void ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveData& rSaveData);
1184 // ------------------------------------------------------------------------
1185 private:
1186 typedef ::std::vector< XclImpPTFieldRef > XclImpPTFieldVec;
1187 diff --git sc/source/filter/xml/xmldpimp.cxx sc/source/filter/xml/xmldpimp.cxx
1188 index 9dfcd8c..3214942 100644
1189 --- sc/source/filter/xml/xmldpimp.cxx
1190 +++ sc/source/filter/xml/xmldpimp.cxx
1191 @@ -48,6 +48,7 @@
1192 #include "dpgroup.hxx"
1193 #include "dpdimsave.hxx"
1194 #include "rangeutl.hxx"
1195 +#include "dpoutputgeometry.hxx"
1197 #include <xmloff/xmltkmap.hxx>
1198 #include <xmloff/nmspmap.hxx>
1199 @@ -126,6 +127,10 @@ ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
1200 sDataPilotTableName(),
1201 sApplicationData(),
1202 sGrandTotal(GetXMLToken(XML_BOTH)),
1203 + mnRowFieldCount(0),
1204 + mnColFieldCount(0),
1205 + mnPageFieldCount(0),
1206 + mnDataFieldCount(0),
1207 bIsNative(sal_True),
1208 bIgnoreEmptyRows(sal_False),
1209 bIdentifyCategories(sal_False),
1210 @@ -262,7 +267,13 @@ SvXMLImportContext *ScXMLDataPilotTableContext::CreateChildContext( USHORT nPref
1213 void ScXMLDataPilotTableContext::SetButtons()
1216 + ScDPOutputGeometry aGeometry(aTargetRangeAddress, bShowFilter);
1217 + aGeometry.setColumnFieldCount(mnColFieldCount);
1218 + aGeometry.setRowFieldCount(mnRowFieldCount);
1219 + aGeometry.setPageFieldCount(mnPageFieldCount);
1220 + aGeometry.setDataFieldCount(mnDataFieldCount);
1222 OUString sAddress;
1223 sal_Int32 nOffset = 0;
1224 while( nOffset >= 0 )
1225 @@ -274,7 +285,21 @@ void ScXMLDataPilotTableContext::SetButtons()
1226 sal_Int32 nAddrOffset(0);
1227 if (pDoc && ScRangeStringConverter::GetAddressFromString( aScAddress, sAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nAddrOffset ))
1229 - ScMergeFlagAttr aAttr( SC_MF_BUTTON );
1230 + ScDPOutputGeometry::FieldType eType = aGeometry.getFieldButtonType(aScAddress);
1232 + sal_Int16 nMFlag = SC_MF_BUTTON;
1233 + if (eType == ScDPOutputGeometry::Column || eType == ScDPOutputGeometry::Row)
1234 + nMFlag |= SC_MF_BUTTON_POPUP;
1236 + // Use the cell's string value to see if this field contains a
1237 + // hidden member. Isn't there a better way? GetString() is
1238 + // quite expensive...
1239 + String aCellStr;
1240 + pDoc->GetString(aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), aCellStr);
1241 + if (maHiddenMemberFields.count(aCellStr))
1242 + nMFlag |= SC_MF_HIDDEN_MEMBER;
1244 + ScMergeFlagAttr aAttr(nMFlag);
1245 pDoc->ApplyAttr( aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), aAttr );
1248 @@ -284,7 +309,7 @@ void ScXMLDataPilotTableContext::SetButtons()
1249 pDPObject->RefreshAfterLoad();
1252 -void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim)
1253 +void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim, bool bHasHiddenMember)
1255 if (pDPSave)
1257 @@ -294,6 +319,30 @@ void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim)
1258 pDPSave->GetExistingDimensionByName(pDim->GetName()) )
1259 pDim->SetDupFlag( TRUE );
1261 + if (!pDim->IsDataLayout())
1263 + switch (pDim->GetOrientation())
1265 + case sheet::DataPilotFieldOrientation_ROW:
1266 + ++mnRowFieldCount;
1267 + break;
1268 + case sheet::DataPilotFieldOrientation_COLUMN:
1269 + ++mnColFieldCount;
1270 + break;
1271 + case sheet::DataPilotFieldOrientation_PAGE:
1272 + ++mnPageFieldCount;
1273 + break;
1274 + case sheet::DataPilotFieldOrientation_DATA:
1275 + ++mnDataFieldCount;
1276 + break;
1277 + case sheet::DataPilotFieldOrientation_HIDDEN:
1278 + default:
1282 + if (bHasHiddenMember)
1283 + maHiddenMemberFields.insert(pDim->GetName());
1285 pDPSave->AddDimension(pDim);
1288 @@ -730,7 +779,8 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
1289 bIsGroupField(sal_False),
1290 bDateValue(sal_False),
1291 bAutoStart(sal_False),
1292 - bAutoEnd(sal_False)
1293 + bAutoEnd(sal_False),
1294 + mbHasHiddenMember(false)
1296 sal_Bool bHasName(sal_False);
1297 sal_Bool bDataLayout(sal_False);
1298 @@ -815,6 +865,16 @@ SvXMLImportContext *ScXMLDataPilotFieldContext::CreateChildContext( USHORT nPref
1299 return pContext;
1302 +void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember* pMember)
1304 + if (pDim)
1305 + pDim->AddMember(pMember);
1307 + if (!pMember->GetIsVisible())
1308 + // This member is hidden.
1309 + mbHasHiddenMember = true;
1312 void ScXMLDataPilotFieldContext::AddGroup(const ::std::vector<rtl::OUString>& rMembers, const rtl::OUString& rName)
1314 ScXMLDataPilotGroup aGroup;
1315 @@ -835,7 +895,7 @@ void ScXMLDataPilotFieldContext::EndElement()
1316 String sPage(sSelectedPage);
1317 pDim->SetCurrentPage(&sPage);
1319 - pDataPilotTable->AddDimension(pDim);
1320 + pDataPilotTable->AddDimension(pDim, mbHasHiddenMember);
1321 if (bIsGroupField)
1323 ScDPNumGroupInfo aInfo;
1324 diff --git sc/source/filter/xml/xmldpimp.hxx sc/source/filter/xml/xmldpimp.hxx
1325 index 25450c3..ac52bc3 100644
1326 --- sc/source/filter/xml/xmldpimp.hxx
1327 +++ sc/source/filter/xml/xmldpimp.hxx
1328 @@ -41,6 +41,8 @@
1329 #include "dpobject.hxx"
1330 #include "dpsave.hxx"
1332 +#include <hash_set>
1334 class ScXMLImport;
1335 class ScDPSaveNumGroupDimension;
1336 class ScDPSaveGroupDimension;
1337 @@ -79,6 +81,8 @@ public:
1339 class ScXMLDataPilotTableContext : public SvXMLImportContext
1341 + typedef ::std::hash_set< ::rtl::OUString, ::rtl::OUStringHash > StringSet;
1342 + StringSet maHiddenMemberFields;
1343 ScDocument* pDoc;
1344 ScDPObject* pDPObject;
1345 ScDPSaveData* pDPSave;
1346 @@ -100,6 +104,10 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext
1347 ScAddress aFilterOutputPosition;
1348 ScQueryParam aSourceQueryParam;
1349 ScMySourceType nSourceType;
1350 + sal_uInt32 mnRowFieldCount;
1351 + sal_uInt32 mnColFieldCount;
1352 + sal_uInt32 mnPageFieldCount;
1353 + sal_uInt32 mnDataFieldCount;
1354 sal_Bool bIsNative;
1355 sal_Bool bIgnoreEmptyRows;
1356 sal_Bool bIdentifyCategories;
1357 @@ -148,7 +156,7 @@ public:
1358 void SetFilterSourceRange(const ScRange& aValue) { aFilterSourceRange = aValue; }
1359 // void SetFilterIsCaseSensitive(const sal_Bool bValue) { aSourceQueryParam.bCaseSens = bValue; }
1360 // void SetFilterSkipDuplicates(const sal_Bool bValue) { aSourceQueryParam.bDuplicate = !bValue; }
1361 - void AddDimension(ScDPSaveDimension* pDim);
1362 + void AddDimension(ScDPSaveDimension* pDim, bool bHasHiddenMember);
1363 void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim);
1364 void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim);
1365 void SetButtons();
1366 @@ -301,12 +309,13 @@ class ScXMLDataPilotFieldContext : public SvXMLImportContext
1367 sal_Int32 nGroupPart;
1368 sal_Int16 nFunction;
1369 sal_Int16 nOrientation;
1370 - sal_Bool bShowEmpty;
1371 - sal_Bool bSelectedPage;
1372 - sal_Bool bIsGroupField;
1373 - sal_Bool bDateValue;
1374 - sal_Bool bAutoStart;
1375 - sal_Bool bAutoEnd;
1376 + sal_Bool bShowEmpty:1;
1377 + sal_Bool bSelectedPage:1;
1378 + sal_Bool bIsGroupField:1;
1379 + sal_Bool bDateValue:1;
1380 + sal_Bool bAutoStart:1;
1381 + sal_Bool bAutoEnd:1;
1382 + bool mbHasHiddenMember:1;
1384 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
1385 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
1386 @@ -330,7 +339,7 @@ public:
1388 void SetShowEmpty(const sal_Bool bValue) { if (pDim) pDim->SetShowEmpty(bValue); }
1389 void SetSubTotals(const sal_uInt16* pFunctions, const sal_Int16 nCount) { if(pDim) pDim->SetSubTotals(nCount, pFunctions); }
1390 - void AddMember(ScDPSaveMember* pMember) { if (pDim) pDim->AddMember(pMember); }
1391 + void AddMember(ScDPSaveMember* pMember);
1392 void SetFieldReference(const com::sun::star::sheet::DataPilotFieldReference& aRef) { if (pDim) pDim->SetReferenceValue(&aRef); }
1393 void SetAutoShowInfo(const com::sun::star::sheet::DataPilotFieldAutoShowInfo& aInfo) { if (pDim) pDim->SetAutoShowInfo(&aInfo); }
1394 void SetSortInfo(const com::sun::star::sheet::DataPilotFieldSortInfo& aInfo) { if (pDim) pDim->SetSortInfo(&aInfo); }
1395 diff --git sc/source/ui/cctrl/dpcontrol.cxx sc/source/ui/cctrl/dpcontrol.cxx
1396 new file mode 100644
1397 index 0000000..e188ab3
1398 --- /dev/null
1399 +++ sc/source/ui/cctrl/dpcontrol.cxx
1400 @@ -0,0 +1,479 @@
1401 +/*************************************************************************
1403 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1405 + * Copyright 2008 by Sun Microsystems, Inc.
1407 + * OpenOffice.org - a multi-platform office productivity suite
1409 + * $RCSfile: document.hxx,v $
1410 + * $Revision: 1.115.36.9 $
1412 + * This file is part of OpenOffice.org.
1414 + * OpenOffice.org is free software: you can redistribute it and/or modify
1415 + * it under the terms of the GNU Lesser General Public License version 3
1416 + * only, as published by the Free Software Foundation.
1418 + * OpenOffice.org is distributed in the hope that it will be useful,
1419 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1420 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1421 + * GNU Lesser General Public License version 3 for more details
1422 + * (a copy is included in the LICENSE file that accompanied this code).
1424 + * You should have received a copy of the GNU Lesser General Public License
1425 + * version 3 along with OpenOffice.org. If not, see
1426 + * <http://www.openoffice.org/license.html>
1427 + * for a copy of the LGPLv3 License.
1429 + ************************************************************************/
1431 +// MARKER(update_precomp.py): autogen include statement, do not remove
1432 +#include "precompiled_sc.hxx"
1434 +// INCLUDE ---------------------------------------------------------------
1436 +#include "dpcontrol.hxx"
1438 +#include "vcl/outdev.hxx"
1439 +#include "vcl/settings.hxx"
1440 +#include "vcl/wintypes.hxx"
1442 +using ::rtl::OUString;
1443 +using ::rtl::OUStringHash;
1444 +using ::std::vector;
1445 +using ::std::hash_map;
1447 +ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle) :
1448 + mpOutDev(pOutDev),
1449 + mpStyle(pStyle),
1450 + mbPopupButton(false),
1451 + mbHasHiddenMember(false)
1455 +ScDPFieldButton::~ScDPFieldButton()
1459 +void ScDPFieldButton::setText(const OUString& rText)
1461 + maText = rText;
1464 +void ScDPFieldButton::setBoundingBox(const Point& rPos, const Size& rSize)
1466 + maPos = rPos;
1467 + maSize = rSize;
1470 +void ScDPFieldButton::setDrawPopupButton(bool b)
1472 + mbPopupButton = b;
1475 +void ScDPFieldButton::setHasHiddenMember(bool b)
1477 + mbHasHiddenMember = b;
1480 +void ScDPFieldButton::draw()
1482 + const long nMargin = 2;
1484 + // Background
1485 + Rectangle aRect(maPos, maSize);
1486 + mpOutDev->SetLineColor(mpStyle->GetFaceColor());
1487 + mpOutDev->SetFillColor(mpStyle->GetFaceColor());
1488 + mpOutDev->DrawRect(aRect);
1490 + // Border lines
1491 + mpOutDev->SetLineColor(mpStyle->GetLightColor());
1492 + mpOutDev->DrawLine(Point(maPos), Point(maPos.X(), maPos.Y()+maSize.Height()-1));
1493 + mpOutDev->DrawLine(Point(maPos), Point(maPos.X()+maSize.Width()-1, maPos.Y()));
1495 + mpOutDev->SetLineColor(mpStyle->GetShadowColor());
1496 + mpOutDev->DrawLine(Point(maPos.X(), maPos.Y()+maSize.Height()-1),
1497 + Point(maPos.X()+maSize.Width()-1, maPos.Y()+maSize.Height()-1));
1498 + mpOutDev->DrawLine(Point(maPos.X()+maSize.Width()-1, maPos.Y()),
1499 + Point(maPos.X()+maSize.Width()-1, maPos.Y()+maSize.Height()-1));
1501 + // Field name
1502 + Font aTextFont( mpStyle->GetLabelFont() );
1503 + aTextFont.SetHeight(12);
1504 + mpOutDev->SetFont(aTextFont);
1506 + Point aTextPos = maPos;
1507 + long nTHeight = mpOutDev->GetTextHeight();
1508 + aTextPos.setX(maPos.getX() + nMargin);
1509 + aTextPos.setY(maPos.getY() + (maSize.Height()-nTHeight)/2);
1510 + mpOutDev->DrawText(aTextPos, maText);
1512 + if (mbPopupButton)
1513 + drawPopupButton();
1516 +void ScDPFieldButton::getPopupBoundingBox(Point& rPos, Size& rSize) const
1518 + long nW = maSize.getWidth()*0.5;
1519 + long nH = maSize.getHeight();
1520 + if (nW > 16)
1521 + nW = 16;
1522 + if (nH > 18)
1523 + nH = 18;
1525 + rPos.setX(maPos.getX() + maSize.getWidth() - nW);
1526 + rPos.setY(maPos.getY() + maSize.getHeight() - nH);
1527 + rSize.setWidth(nW);
1528 + rSize.setHeight(nH);
1531 +bool ScDPFieldButton::isPopupButton() const
1533 + return mbPopupButton;
1536 +void ScDPFieldButton::drawPopupButton()
1538 + Point aPos;
1539 + Size aSize;
1540 + getPopupBoundingBox(aPos, aSize);
1542 + // border lines
1543 + mpOutDev->SetLineColor(mpStyle->GetLightColor());
1544 + mpOutDev->DrawLine(aPos, Point(aPos.X(), aPos.Y()+aSize.Height()-1));
1545 + mpOutDev->DrawLine(aPos, Point(aPos.X()+aSize.Width()-1, aPos.Y()));
1547 + mpOutDev->SetLineColor(mpStyle->GetShadowColor());
1548 + mpOutDev->DrawLine(Point(aPos.X(), aPos.Y()+aSize.Height()-1),
1549 + Point(aPos.X()+aSize.Width()-1, aPos.Y()+aSize.Height()-1));
1550 + mpOutDev->DrawLine(Point(aPos.X()+aSize.Width()-1, aPos.Y()),
1551 + Point(aPos.X()+aSize.Width()-1, aPos.Y()+aSize.Height()-1));
1553 + // the arrowhead
1554 + Color aArrowColor = mbHasHiddenMember ? mpStyle->GetHighlightLinkColor() : mpStyle->GetButtonTextColor();
1555 + mpOutDev->SetLineColor(aArrowColor);
1556 + mpOutDev->SetFillColor(aArrowColor);
1557 + Point aCenter(aPos.X() + (aSize.Width() >> 1), aPos.Y() + (aSize.Height() >> 1));
1558 + Point aPos1, aPos2;
1559 + aPos1.X() = aCenter.X() - 4;
1560 + aPos2.X() = aCenter.X() + 4;
1561 + aPos1.Y() = aCenter.Y() - 3;
1562 + aPos2.Y() = aCenter.Y() - 3;
1564 + do
1566 + ++aPos1.X();
1567 + --aPos2.X();
1568 + ++aPos1.Y();
1569 + ++aPos2.Y();
1570 + mpOutDev->DrawLine(aPos1, aPos2);
1572 + while (aPos1 != aPos2);
1574 + if (mbHasHiddenMember)
1576 + // tiny little box to display in presence of hidden member(s).
1577 + Point aBoxPos(aPos.X() + aSize.Width() - 5, aPos.Y() + aSize.Height() - 5);
1578 + Size aBoxSize(3, 3);
1579 + mpOutDev->DrawRect(Rectangle(aBoxPos, aBoxSize));
1583 +// ============================================================================
1585 +ScDPFieldPopupWindow::Member::Member() :
1586 + mbVisible(true)
1590 +// ----------------------------------------------------------------------------
1592 +ScDPFieldPopupWindow::ScDPFieldPopupWindow(Window* pParent) :
1593 + FloatingWindow(pParent, (WB_SYSTEMFLOATWIN|WB_SYSTEMWINDOW|WB_NOBORDER)),
1594 + maCheck0(this, 0),
1595 + maCheck1(this, 0),
1596 + maCheck2(this, 0),
1597 + maCheck3(this, 0),
1598 + maCheck4(this, 0),
1599 + maCheck5(this, 0),
1600 + maCheck6(this, 0),
1601 + maCheck7(this, 0),
1602 + maCheck8(this, 0),
1603 + maCheck9(this, 0),
1604 + maCheck10(this, 0),
1605 + maCheck11(this, 0),
1606 + maScrollBar(this, WB_VERT),
1607 + maBtnOk(this),
1608 + maBtnCancel(this),
1609 + mpExtendedData(NULL),
1610 + mpOKAction(NULL),
1611 + mnScrollPos(0)
1613 + SetOutputSizePixel(Size(150, 280));
1614 + Size aOutSize = GetOutputSizePixel();
1616 + const StyleSettings& rStyle = GetSettings().GetStyleSettings();
1618 + mpCheckPtr.reserve(12);
1619 + mpCheckPtr.push_back(&maCheck0);
1620 + mpCheckPtr.push_back(&maCheck1);
1621 + mpCheckPtr.push_back(&maCheck2);
1622 + mpCheckPtr.push_back(&maCheck3);
1623 + mpCheckPtr.push_back(&maCheck4);
1624 + mpCheckPtr.push_back(&maCheck5);
1625 + mpCheckPtr.push_back(&maCheck6);
1626 + mpCheckPtr.push_back(&maCheck7);
1627 + mpCheckPtr.push_back(&maCheck8);
1628 + mpCheckPtr.push_back(&maCheck9);
1629 + mpCheckPtr.push_back(&maCheck10);
1630 + mpCheckPtr.push_back(&maCheck11);
1632 + Point aPos;
1633 + Size aSize;
1634 + getSectionPosSize(aPos, aSize, FIRST_LISTITEM);
1635 + Font aMemFont(rStyle.GetLabelFont());
1636 + aMemFont.SetHeight(11);
1637 + for (vector<CheckBox*>::iterator itr = mpCheckPtr.begin(), itrEnd = mpCheckPtr.end();
1638 + itr != itrEnd; ++itr)
1640 + CheckBox* p = *itr;
1641 + p->SetPosSizePixel(aPos, aSize);
1642 + p->SetFont(aMemFont);
1643 + p->SetClickHdl( LINK(this, ScDPFieldPopupWindow, CheckBoxHdl) );
1644 + aPos.Y() += 18;
1647 + getSectionPosSize(aPos, aSize, BTN_OK);
1648 + maBtnOk.SetPosSizePixel(aPos, aSize);
1649 + maBtnOk.SetFont(aMemFont);
1650 + maBtnOk.SetClickHdl( LINK(this, ScDPFieldPopupWindow, OKButtonHdl) );
1651 + maBtnOk.Show();
1653 + getSectionPosSize(aPos, aSize, BTN_CANCEL);
1654 + maBtnCancel.SetPosSizePixel(aPos, aSize);
1655 + maBtnCancel.SetFont(aMemFont);
1656 + maBtnCancel.Show();
1658 + getSectionPosSize(aPos, aSize, SCROLL_BAR_V);
1659 + maScrollBar.SetPosSizePixel(aPos, aSize);
1660 + maScrollBar.SetPageSize(mpCheckPtr.size());
1661 + maScrollBar.SetVisibleSize(mpCheckPtr.size());
1662 + maScrollBar.SetLineSize(1);
1663 + maScrollBar.SetScrollHdl( LINK(this, ScDPFieldPopupWindow, ScrollHdl) );
1664 + maScrollBar.EnableDrag(true);
1667 +vector<ScDPFieldPopupWindow::Member>& ScDPFieldPopupWindow::getMembers()
1669 + return maMembers;
1672 +void ScDPFieldPopupWindow::getSectionPosSize(Point& rPos, Size& rSize, SectionType eType) const
1674 + static const long nListBoxMargin = 5;
1675 + static const long nBottomBtnAreaHeight = 50;
1676 + static const long nInnerItemMargin = 5;
1677 + static const long nScrollBarWidth = 17;
1678 + static const long nBtnWidth = 60;
1679 + static const long nBtnHeight = 22;
1680 + static const long nBottomMargin = 10;
1682 + const Size& rWndSize = GetSizePixel();
1684 + switch (eType)
1686 + case WHOLE:
1687 + rPos = Point(0, 0);
1688 + rSize = rWndSize;
1689 + break;
1690 + case LISTBOX_AREA:
1692 + rPos = Point(nListBoxMargin, nListBoxMargin);
1693 + rSize = Size(
1694 + rWndSize.Width() - nListBoxMargin*2,
1695 + rWndSize.Height() - nListBoxMargin - nBottomBtnAreaHeight);
1697 + break;
1698 + case FIRST_LISTITEM:
1700 + rPos = Point(nListBoxMargin + nInnerItemMargin,
1701 + nListBoxMargin + nInnerItemMargin);
1702 + rSize = Size(
1703 + rWndSize.Width() - nListBoxMargin*2 - nInnerItemMargin - nScrollBarWidth - 10,
1704 + 17);
1706 + break;
1707 + case BTN_OK:
1709 + long x = (rWndSize.Width() - nBtnWidth*2)/3;
1710 + long y = rWndSize.Height() - nBottomMargin - nBtnHeight;
1711 + rPos = Point(x, y);
1712 + rSize = Size(nBtnWidth, nBtnHeight);
1714 + break;
1715 + case BTN_CANCEL:
1717 + long x = (rWndSize.Width() - nBtnWidth*2)/3*2 + nBtnWidth;
1718 + long y = rWndSize.Height() - nBottomMargin - nBtnHeight;
1719 + rPos = Point(x, y);
1720 + rSize = Size(nBtnWidth, nBtnHeight);
1722 + break;
1723 + case SCROLL_BAR_V:
1725 + long x = rWndSize.Width() - nListBoxMargin - nInnerItemMargin - nScrollBarWidth;
1726 + long y = nListBoxMargin + nInnerItemMargin;
1727 + rPos = Point(x, y);
1728 + long h = rWndSize.Height() - nListBoxMargin - nBottomBtnAreaHeight - nInnerItemMargin*2;
1729 + rSize = Size(nScrollBarWidth, h);
1731 + break;
1732 + default:
1737 +void ScDPFieldPopupWindow::resetDisplayedItems()
1739 + long nScrollPos = maScrollBar.GetThumbPos();
1740 + if (nScrollPos < 0)
1741 + return;
1743 + mnScrollPos = static_cast<size_t>(nScrollPos);
1744 + size_t nCheckCount = mpCheckPtr.size();
1745 + for (size_t i = 0; i < nCheckCount; ++i)
1747 + CheckBox* p = mpCheckPtr[i];
1748 + p->SetText(maMembers[i+mnScrollPos].maName);
1749 + TriState nNewState = maMembers[i+mnScrollPos].mbVisible ? STATE_CHECK : STATE_NOCHECK;
1750 + p->SetState(nNewState);
1754 +IMPL_LINK( ScDPFieldPopupWindow, CheckBoxHdl, CheckBox*, pCheck )
1756 + vector<CheckBox*>::const_iterator itr, itrBeg = mpCheckPtr.begin(), itrEnd = mpCheckPtr.end();
1757 + for (itr = itrBeg; itr != itrEnd; ++itr)
1759 + if (*itr == pCheck)
1761 + size_t nIndex = ::std::distance(itrBeg, itr);
1762 + maMembers[nIndex+mnScrollPos].mbVisible = !maMembers[nIndex+mnScrollPos].mbVisible;
1765 + return 0;
1768 +IMPL_LINK( ScDPFieldPopupWindow, OKButtonHdl, OKButton*, EMPTYARG )
1770 + close(true);
1771 + return 0;
1774 +IMPL_LINK( ScDPFieldPopupWindow, ScrollHdl, ScrollBar*, EMPTYARG )
1776 + resetDisplayedItems();
1777 + return 0;
1780 +ScDPFieldPopupWindow::~ScDPFieldPopupWindow()
1782 + EndPopupMode();
1785 +void ScDPFieldPopupWindow::Paint(const Rectangle& rRect)
1787 + Window::Paint(rRect);
1789 + const StyleSettings& rStyle = GetSettings().GetStyleSettings();
1790 + Color aBackColor = rStyle.GetMenuColor();
1791 + Color aBorderColor = rStyle.GetShadowColor();
1792 + Color aMemberBackColor = rStyle.GetFieldColor();
1794 + Point aPos;
1795 + Size aSize;
1797 + // Window background
1798 + SetFillColor(aBackColor);
1799 + SetLineColor(aBorderColor);
1800 + getSectionPosSize(aPos, aSize, WHOLE);
1801 + DrawRect(Rectangle(aPos,aSize));
1803 + // Member list box background
1804 + SetFillColor(aMemberBackColor);
1805 + getSectionPosSize(aPos, aSize, LISTBOX_AREA);
1806 + DrawRect(Rectangle(aPos,aSize));
1809 +void ScDPFieldPopupWindow::setMemberSize(size_t n)
1811 + maMembers.reserve(n);
1814 +void ScDPFieldPopupWindow::addMember(const OUString& rName, bool bVisible)
1816 + Member aMember;
1817 + aMember.maName = rName;
1818 + aMember.mbVisible = bVisible;
1819 + maMembers.push_back(aMember);
1822 +void ScDPFieldPopupWindow::initMembers()
1824 + size_t nMemCount = maMembers.size();
1825 + size_t nCheckCount = mpCheckPtr.size();
1826 + bool bNeedsScroll = false;
1827 + if (nMemCount > nCheckCount)
1828 + {
1829 + nMemCount = nCheckCount;
1830 + bNeedsScroll = true;
1833 + for (size_t i = 0; i < nMemCount; ++i)
1835 + CheckBox* p = mpCheckPtr[i];
1836 + p->SetText(maMembers[i].maName);
1837 + p->Show();
1838 + p->SetState(maMembers[i].mbVisible ? STATE_CHECK : STATE_NOCHECK);
1840 + if (bNeedsScroll)
1842 + maScrollBar.SetRange(Range(0, maMembers.size()));
1843 + maScrollBar.Show();
1847 +void ScDPFieldPopupWindow::getResult(hash_map<OUString, bool, OUStringHash>& rResult)
1849 + typedef hash_map<OUString, bool, OUStringHash> ResultMap;
1850 + ResultMap aResult;
1851 + vector<Member>::const_iterator itr = maMembers.begin(), itrEnd = maMembers.end();
1852 + for (; itr != itrEnd; ++itr)
1853 + aResult.insert(ResultMap::value_type(itr->maName, itr->mbVisible));
1854 + rResult.swap(aResult);
1857 +void ScDPFieldPopupWindow::close(bool bOK)
1859 + if (bOK && mpOKAction.get())
1860 + mpOKAction->execute();
1862 + EndPopupMode();
1865 +void ScDPFieldPopupWindow::setExtendedData(ExtendedData* p)
1867 + mpExtendedData.reset(p);
1870 +ScDPFieldPopupWindow::ExtendedData* ScDPFieldPopupWindow::getExtendedData()
1872 + return mpExtendedData.get();
1875 +void ScDPFieldPopupWindow::setOKAction(OKAction* p)
1877 + mpOKAction.reset(p);
1880 diff --git sc/source/ui/cctrl/makefile.mk sc/source/ui/cctrl/makefile.mk
1881 index 4cce7f6..8e8add3 100644
1882 --- sc/source/ui/cctrl/makefile.mk
1883 +++ sc/source/ui/cctrl/makefile.mk
1884 @@ -51,6 +51,7 @@ SLOFILES = \
1885 $(SLO)$/popmenu.obj \
1886 $(SLO)$/tbinsert.obj \
1887 $(SLO)$/cbuttonw.obj \
1888 + $(SLO)$/dpcontrol.obj \
1889 $(SLO)$/editfield.obj \
1890 $(EXCEPTIONSFILES)
1892 @@ -59,6 +60,7 @@ LIB1OBJFILES= \
1893 $(SLO)$/popmenu.obj \
1894 $(SLO)$/tbinsert.obj \
1895 $(SLO)$/cbuttonw.obj \
1896 + $(SLO)$/dpcontrol.obj \
1897 $(SLO)$/tbzoomsliderctrl.obj
1899 # --- Tagets -------------------------------------------------------
1900 diff --git sc/source/ui/dbgui/pvlaydlg.cxx sc/source/ui/dbgui/pvlaydlg.cxx
1901 index 4dee615..588a290 100644
1902 --- sc/source/ui/dbgui/pvlaydlg.cxx
1903 +++ sc/source/ui/dbgui/pvlaydlg.cxx
1904 @@ -64,6 +64,7 @@
1905 #include "scabstdlg.hxx" //CHINA001
1906 using namespace com::sun::star;
1907 using ::rtl::OUString;
1908 +using ::std::vector;
1910 //----------------------------------------------------------------------------
1912 @@ -391,26 +392,25 @@ void ScDPLayoutDlg::StateChanged( StateChangedType nStateChange )
1914 //----------------------------------------------------------------------------
1916 -void ScDPLayoutDlg::InitWndSelect( LabelData** ppLabelArr, long nLabels )
1917 +void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
1919 - if ( ppLabelArr )
1921 - size_t nLabelCount = static_cast< size_t >( (nLabels > MAX_LABELS) ? MAX_LABELS : nLabels );
1922 - size_t nLast = (nLabelCount > PAGE_SIZE) ? (PAGE_SIZE - 1) : (nLabelCount - 1);
1923 + size_t nLabelCount = rLabels.size();
1924 + if (nLabelCount > MAX_LABELS)
1925 + nLabelCount = MAX_LABELS;
1926 + size_t nLast = (nLabelCount > PAGE_SIZE) ? (PAGE_SIZE - 1) : (nLabelCount - 1);
1928 - aLabelDataArr.clear();
1929 - aLabelDataArr.reserve( nLabelCount );
1930 - for ( size_t i=0; i < nLabelCount; i++ )
1932 - aLabelDataArr.push_back( *ppLabelArr[i] );
1933 + aLabelDataArr.clear();
1934 + aLabelDataArr.reserve( nLabelCount );
1935 + for ( size_t i=0; i < nLabelCount; i++ )
1937 + aLabelDataArr.push_back(*rLabels[i]);
1939 - if ( i <= nLast )
1941 - aWndSelect.AddField( aLabelDataArr[i].maName, i );
1942 - aSelectArr[i].reset( new ScDPFuncData( aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask ) );
1946 + if ( i <= nLast )
1948 + aWndSelect.AddField( aLabelDataArr[i].maName, i );
1949 + aSelectArr[i].reset( new ScDPFuncData( aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask ) );
1955 @@ -506,18 +506,19 @@ void ScDPLayoutDlg::InitFocus()
1957 void ScDPLayoutDlg::InitFields()
1959 - InitWndSelect( thePivotData.ppLabelArr, static_cast<long>(thePivotData.nLabels) );
1960 + InitWndSelect(thePivotData.maLabelArray);
1961 InitWnd( thePivotData.aPageArr, static_cast<long>(thePivotData.nPageCount), TYPE_PAGE );
1962 InitWnd( thePivotData.aColArr, static_cast<long>(thePivotData.nColCount), TYPE_COL );
1963 InitWnd( thePivotData.aRowArr, static_cast<long>(thePivotData.nRowCount), TYPE_ROW );
1964 InitWnd( thePivotData.aDataArr, static_cast<long>(thePivotData.nDataCount), TYPE_DATA );
1966 + size_t nLabels = thePivotData.maLabelArray.size();
1967 aSlider.SetPageSize( PAGE_SIZE );
1968 aSlider.SetVisibleSize( PAGE_SIZE );
1969 aSlider.SetLineSize( LINE_SIZE );
1970 - aSlider.SetRange( Range( 0, static_cast<long>(((thePivotData.nLabels+LINE_SIZE-1)/LINE_SIZE)*LINE_SIZE) ) );
1971 + aSlider.SetRange( Range( 0, static_cast<long>(((nLabels+LINE_SIZE-1)/LINE_SIZE)*LINE_SIZE) ) );
1973 - if ( thePivotData.nLabels > PAGE_SIZE )
1974 + if ( nLabels > PAGE_SIZE )
1976 aSlider.SetEndScrollHdl( LINK( this, ScDPLayoutDlg, ScrollHdl ) );
1977 aSlider.Show();
1978 diff --git sc/source/ui/inc/dpcontrol.hxx sc/source/ui/inc/dpcontrol.hxx
1979 new file mode 100644
1980 index 0000000..6a28354
1981 --- /dev/null
1982 +++ sc/source/ui/inc/dpcontrol.hxx
1983 @@ -0,0 +1,193 @@
1984 +/*************************************************************************
1986 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1988 + * Copyright 2008 by Sun Microsystems, Inc.
1990 + * OpenOffice.org - a multi-platform office productivity suite
1992 + * $RCSfile: document.hxx,v $
1993 + * $Revision: 1.115.36.9 $
1995 + * This file is part of OpenOffice.org.
1997 + * OpenOffice.org is free software: you can redistribute it and/or modify
1998 + * it under the terms of the GNU Lesser General Public License version 3
1999 + * only, as published by the Free Software Foundation.
2001 + * OpenOffice.org is distributed in the hope that it will be useful,
2002 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2003 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2004 + * GNU Lesser General Public License version 3 for more details
2005 + * (a copy is included in the LICENSE file that accompanied this code).
2007 + * You should have received a copy of the GNU Lesser General Public License
2008 + * version 3 along with OpenOffice.org. If not, see
2009 + * <http://www.openoffice.org/license.html>
2010 + * for a copy of the LGPLv3 License.
2012 + ************************************************************************/
2014 +#ifndef SC_DPCONTROL_HXX
2015 +#define SC_DPCONTROL_HXX
2017 +#include "rtl/ustring.hxx"
2018 +#include "tools/gen.hxx"
2019 +#include "vcl/floatwin.hxx"
2020 +#include "vcl/button.hxx"
2021 +#include "vcl/scrbar.hxx"
2023 +#include <memory>
2024 +#include <hash_map>
2026 +class OutputDevice;
2027 +class Point;
2028 +class Size;
2029 +class StyleSettings;
2030 +class Window;
2032 +/**
2033 + * This class takes care of physically drawing field button controls inside
2034 + * data pilot tables.
2035 + */
2036 +class ScDPFieldButton
2038 +public:
2039 + ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle);
2040 + ~ScDPFieldButton();
2042 + void setText(const ::rtl::OUString& rText);
2043 + void setBoundingBox(const Point& rPos, const Size& rSize);
2044 + void setDrawPopupButton(bool b);
2045 + void setHasHiddenMember(bool b);
2046 + void draw();
2048 + void getPopupBoundingBox(Point& rPos, Size& rSize) const;
2049 + bool isPopupButton() const;
2051 +private:
2052 + void drawPopupButton();
2054 +private:
2055 + Point maPos;
2056 + Size maSize;
2057 + ::rtl::OUString maText;
2058 + OutputDevice* mpOutDev;
2059 + const StyleSettings* mpStyle;
2060 + bool mbPopupButton;
2061 + bool mbHasHiddenMember;
2064 +// ============================================================================
2066 +/**
2067 + * This class implements a popup window for field button, for quick access
2068 + * of hide-item list, and possibly more stuff related to field options.
2069 + */
2070 +class ScDPFieldPopupWindow : public FloatingWindow
2072 +public:
2073 + class ButtonEvent
2075 + public:
2076 + virtual void execute() = 0;
2077 + };
2079 + /**
2080 + * Extended data that the client code may need to store. Create a
2081 + * sub-class of this and store data there.
2082 + */
2083 + struct ExtendedData {};
2085 + /**
2086 + * Action to perform when the OK button is pressed. Create a sub-class of
2087 + * this to implement the desired action.
2088 + */
2089 + class OKAction
2091 + public:
2092 + virtual void execute() = 0;
2093 + };
2095 + explicit ScDPFieldPopupWindow(Window* pParent);
2096 + virtual ~ScDPFieldPopupWindow();
2098 + virtual void Paint(const Rectangle& rRect);
2100 + void setMemberSize(size_t n);
2101 + void addMember(const ::rtl::OUString& rName, bool bVisible);
2102 + void initMembers();
2103 + void getResult(::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rResult);
2104 + void close(bool bOK);
2106 + /**
2107 + * Set auxiliary data that the client code might need. Note that this
2108 + * popup window class manages its life time; no explicit deletion of the
2109 + * instance is needed in the client code.
2110 + */
2111 + void setExtendedData(ExtendedData* p);
2113 + /**
2114 + * Get the store auxiliary data, or NULL if no such data is stored.
2115 + */
2116 + ExtendedData* getExtendedData();
2118 + void setOKAction(OKAction* p);
2120 +private:
2121 + struct Member
2123 + ::rtl::OUString maName;
2124 + bool mbVisible;
2126 + Member();
2127 + };
2129 + ::std::vector<Member>& getMembers();
2131 + enum SectionType {
2132 + WHOLE, // entire window
2133 + LISTBOX_AREA, // box enclosing the check box items.
2134 + FIRST_LISTITEM, // first list item at the top
2135 + BTN_OK, // OK button
2136 + BTN_CANCEL, // Cancel button
2137 + SCROLL_BAR_V, // vertical scroll bar along the right edge of the list box.
2138 + };
2139 + void getSectionPosSize(Point& rPos, Size& rSize, SectionType eType) const;
2141 + void resetDisplayedItems();
2143 + DECL_LINK( CheckBoxHdl, CheckBox* );
2144 + DECL_LINK( OKButtonHdl, OKButton* );
2145 + DECL_LINK( ScrollHdl, ScrollBar* );
2147 +private:
2149 + CheckBox maCheck0;
2150 + CheckBox maCheck1;
2151 + CheckBox maCheck2;
2152 + CheckBox maCheck3;
2153 + CheckBox maCheck4;
2154 + CheckBox maCheck5;
2155 + CheckBox maCheck6;
2156 + CheckBox maCheck7;
2157 + CheckBox maCheck8;
2158 + CheckBox maCheck9;
2159 + CheckBox maCheck10;
2160 + CheckBox maCheck11;
2162 + ScrollBar maScrollBar;
2164 + OKButton maBtnOk;
2165 + CancelButton maBtnCancel;
2167 + ::std::vector<CheckBox*> mpCheckPtr;
2169 + ::std::vector<Member> maMembers;
2170 + ::std::auto_ptr<ExtendedData> mpExtendedData;
2171 + ::std::auto_ptr<OKAction> mpOKAction;
2173 + size_t mnScrollPos;
2176 +#endif
2177 diff --git sc/source/ui/inc/gridwin.hxx sc/source/ui/inc/gridwin.hxx
2178 index 2946c39..30b563b 100644
2179 --- sc/source/ui/inc/gridwin.hxx
2180 +++ sc/source/ui/inc/gridwin.hxx
2181 @@ -39,6 +39,7 @@
2182 #include <svx/sdr/overlay/overlayobject.hxx>
2184 #include <vector>
2185 +#include <memory>
2187 // ---------------------------------------------------------------------------
2189 @@ -48,6 +49,7 @@ class ScViewSelectionEngine;
2190 class ScPivot;
2191 #endif
2192 class ScDPObject;
2193 +class ScDPFieldPopupWindow;
2194 class ScOutputData;
2195 class ScFilterListBox;
2196 class AutoFilterPopup;
2197 @@ -160,6 +162,7 @@ private:
2199 ScFilterListBox* pFilterBox;
2200 FloatingWindow* pFilterFloat;
2201 + ::std::auto_ptr<ScDPFieldPopupWindow> mpDPFieldPopup;
2203 USHORT nCursorHideCount;
2205 @@ -246,6 +249,16 @@ private:
2206 void DPMouseButtonUp( const MouseEvent& rMEvt );
2207 void DPTestMouse( const MouseEvent& rMEvt, BOOL bMove );
2209 + /**
2210 + * Check if the mouse click is on a field popup button.
2211 + *
2212 + * @return bool true if the field popup menu has been launched and no
2213 + * further mouse event handling is necessary, false otherwise.
2214 + */
2215 + bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj);
2216 + void DPLaunchFieldPopupMenu(
2217 + const Point& rSrcPos, const Size& rSrcSize, const ScAddress& rPos, ScDPObject* pDPObj);
2219 void RFMouseMove( const MouseEvent& rMEvt, BOOL bUp );
2221 void PagebreakMove( const MouseEvent& rMEvt, BOOL bUp );
2222 @@ -419,6 +432,8 @@ public:
2224 void CheckNeedsRepaint();
2226 + void UpdateDPFromFieldPopupMenu();
2228 // #114409#
2229 void CursorChanged();
2230 void DrawLayerCreated();
2231 diff --git sc/source/ui/inc/pvlaydlg.hxx sc/source/ui/inc/pvlaydlg.hxx
2232 index a3e08cb..ed388d4 100644
2233 --- sc/source/ui/inc/pvlaydlg.hxx
2234 +++ sc/source/ui/inc/pvlaydlg.hxx
2235 @@ -192,7 +192,7 @@ private:
2236 private:
2237 ScDPFieldWindow& GetFieldWindow ( ScDPFieldType eType );
2238 void Init (bool bNewOutput);
2239 - void InitWndSelect ( LabelData** ppLabelArr, long nLabels );
2240 + void InitWndSelect ( const ::std::vector<ScDPLabelDataRef>& rLabels );
2241 void InitWnd ( PivotField* pArr, long nCount, ScDPFieldType eType );
2242 void InitFocus ();
2243 void InitFields ();
2244 diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
2245 index 3d7f3d4..078c55a 100644
2246 --- sc/source/ui/view/gridwin.cxx
2247 +++ sc/source/ui/view/gridwin.cxx
2248 @@ -121,6 +121,7 @@
2249 #include "cellsh.hxx"
2250 #include "tabprotection.hxx"
2251 #include "clipparam.hxx"
2252 +#include "dpcontrol.hxx"
2254 // #114409#
2255 #include <vcl/salbtype.hxx> // FRound
2256 @@ -407,6 +408,7 @@ ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhic
2257 pNoteMarker( NULL ),
2258 pFilterBox( NULL ),
2259 pFilterFloat( NULL ),
2260 + mpDPFieldPopup(NULL),
2261 nCursorHideCount( 0 ),
2262 bMarking( FALSE ),
2263 nButtonDown( 0 ),
2264 diff --git sc/source/ui/view/gridwin2.cxx sc/source/ui/view/gridwin2.cxx
2265 index c6f589e..40af470 100644
2266 --- sc/source/ui/view/gridwin2.cxx
2267 +++ sc/source/ui/view/gridwin2.cxx
2268 @@ -55,11 +55,20 @@
2269 #include "dpoutput.hxx" // ScDPPositionData
2270 #include "dpshttab.hxx"
2271 #include "dbdocfun.hxx"
2272 +#include "dpcontrol.hxx"
2274 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
2275 #include "scabstdlg.hxx" //CHINA001
2276 -using namespace com::sun::star;
2278 +#include <vector>
2279 +#include <hash_map>
2281 +using namespace com::sun::star;
2282 +using ::std::vector;
2283 +using ::std::auto_ptr;
2284 +using ::std::hash_map;
2285 +using ::rtl::OUString;
2286 +using ::rtl::OUStringHash;
2288 // STATIC DATA -----------------------------------------------------------
2290 @@ -199,6 +208,15 @@ void ScGridWindow::DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt
2291 bDPMouse = TRUE;
2292 nDPField = nField;
2293 pDragDPObj = pDPObj;
2295 + if (DPTestFieldPopupArrow(rMEvt, aPos, pDPObj))
2296 + {
2297 + // field name pop up menu has been launched. Don't activate
2298 + // field move.
2299 + bDPMouse = false;
2300 + return;
2303 DPTestMouse( rMEvt, TRUE );
2304 StartTracking();
2306 @@ -726,6 +744,115 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove )
2307 pViewData->GetView()->ResetTimer();
2310 +bool ScGridWindow::DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj)
2312 + // Get the geometry of the cell.
2313 + Point aSrcPos = pViewData->GetScrPos(rPos.Col(), rPos.Row(), eWhich);
2314 + long nSizeX, nSizeY;
2315 + pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeX, nSizeY);
2316 + Size aSrcSize(nSizeX-1, nSizeY-1);
2318 + // Check if the mouse cursor is clicking on the popup arrow box.
2319 + ScDPFieldButton aBtn(this, &GetSettings().GetStyleSettings());
2320 + aBtn.setBoundingBox(aSrcPos, aSrcSize);
2321 + Point aPopupPos;
2322 + Size aPopupSize;
2323 + aBtn.getPopupBoundingBox(aPopupPos, aPopupSize);
2324 + Rectangle aRec(aPopupPos, aPopupSize);
2325 + if (aRec.IsInside(rMEvt.GetPosPixel()))
2327 + // Mouse cursor inside the popup arrow box. Launch the field menu.
2328 + DPLaunchFieldPopupMenu(OutputToScreenPixel(aSrcPos), aSrcSize, rPos, pDPObj);
2329 + return true;
2332 + return false;
2335 +namespace {
2337 +struct DPFieldPopupData : public ScDPFieldPopupWindow::ExtendedData
2339 + ScPivotParam maDPParam;
2340 + ScDPObject* mpDPObj;
2341 + long mnDim;
2344 +class DPFieldPopupOKAction : public ScDPFieldPopupWindow::OKAction
2346 +public:
2347 + explicit DPFieldPopupOKAction(ScGridWindow* p) :
2348 + mpGridWindow(p) {}
2350 + virtual void execute()
2352 + mpGridWindow->UpdateDPFromFieldPopupMenu();
2354 +private:
2355 + ScGridWindow* mpGridWindow;
2360 +void ScGridWindow::DPLaunchFieldPopupMenu(
2361 + const Point& rSrcPos, const Size& rSrcSize, const ScAddress& rPos, ScDPObject* pDPObj)
2363 + // We need to get the list of field members.
2364 + auto_ptr<DPFieldPopupData> pDPData(new DPFieldPopupData);
2365 + pDPObj->FillLabelData(pDPData->maDPParam);
2366 + pDPData->mpDPObj = pDPObj;
2368 + USHORT nOrient;
2369 + pDPData->mnDim = pDPObj->GetHeaderDim(rPos, nOrient);
2371 + if (pDPData->maDPParam.maLabelArray.size() <= static_cast<size_t>(pDPData->mnDim))
2372 + // out-of-bound dimension ID. This should never happen!
2373 + return;
2375 + const ScDPLabelData& rLabelData = *pDPData->maDPParam.maLabelArray[pDPData->mnDim];
2377 + mpDPFieldPopup.reset(new ScDPFieldPopupWindow(this));
2378 + mpDPFieldPopup->setExtendedData(pDPData.release());
2379 + mpDPFieldPopup->setOKAction(new DPFieldPopupOKAction(this));
2380 + sal_Int32 n = rLabelData.maMembers.getLength();
2381 + mpDPFieldPopup->setMemberSize(n);
2382 + for (sal_Int32 i = 0; i < n; ++i)
2383 + mpDPFieldPopup->addMember(rLabelData.maMembers[i], rLabelData.maVisible[i]);
2384 + mpDPFieldPopup->initMembers();
2386 + mpDPFieldPopup->SetPopupModeEndHdl( LINK(this, ScGridWindow, PopupModeEndHdl) );
2387 + Rectangle aCellRect(rSrcPos, rSrcSize);
2388 + mpDPFieldPopup->StartPopupMode(aCellRect, (FLOATWIN_POPUPMODE_DOWN | FLOATWIN_POPUPMODE_GRABFOCUS));
2391 +void ScGridWindow::UpdateDPFromFieldPopupMenu()
2393 + if (!mpDPFieldPopup.get())
2394 + return;
2396 + DPFieldPopupData* pDPData = static_cast<DPFieldPopupData*>(mpDPFieldPopup->getExtendedData());
2397 + if (!pDPData)
2398 + return;
2400 + ScDPObject* pDPObj = pDPData->mpDPObj;
2401 + ScDPObject aNewDPObj(*pDPObj);
2402 + aNewDPObj.BuildAllDimensionMembers();
2403 + ScDPSaveData* pSaveData = aNewDPObj.GetSaveData();
2405 + BOOL bIsDataLayout;
2406 + String aDimName = pDPObj->GetDimName(pDPData->mnDim, bIsDataLayout);
2407 + ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(aDimName);
2408 + if (!pDim)
2409 + return;
2411 + hash_map<OUString, bool, OUStringHash> aResult;
2412 + mpDPFieldPopup->getResult(aResult);
2413 + pDim->UpdateMemberVisibility(aResult);
2415 + ScDBDocFunc aFunc(*pViewData->GetDocShell());
2416 + aFunc.DataPilotUpdate(pDPObj, &aNewDPObj, true, false);
2419 void ScGridWindow::DPMouseMove( const MouseEvent& rMEvt )
2421 DPTestMouse( rMEvt, TRUE );
2422 diff --git sc/source/ui/view/gridwin4.cxx sc/source/ui/view/gridwin4.cxx
2423 index 97f04ad..0e0742a 100644
2424 --- sc/source/ui/view/gridwin4.cxx
2425 +++ sc/source/ui/view/gridwin4.cxx
2426 @@ -73,6 +73,7 @@
2427 #include "editutil.hxx"
2428 #include "inputopt.hxx"
2429 #include "fillinfo.hxx"
2430 +#include "dpcontrol.hxx"
2431 #include "sc.hrc"
2432 #include <vcl/virdev.hxx>
2434 @@ -1205,6 +1206,8 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2
2436 aComboButton.SetOutputDevice( pContentDev );
2438 + ScDPFieldButton aDPFieldBtn(pContentDev, &GetSettings().GetStyleSettings());
2440 SCCOL nCol;
2441 SCROW nRow;
2442 SCSIZE nArrY;
2443 @@ -1320,13 +1323,13 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2
2444 nPosX -= nSizeX - 2;
2447 - pContentDev->SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
2448 - pContentDev->DrawLine( Point(nPosX,nPosY), Point(nPosX,nPosY+nSizeY-1) );
2449 - pContentDev->DrawLine( Point(nPosX,nPosY), Point(nPosX+nSizeX-1,nPosY) );
2450 - pContentDev->SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
2451 - pContentDev->DrawLine( Point(nPosX,nPosY+nSizeY-1), Point(nPosX+nSizeX-1,nPosY+nSizeY-1) );
2452 - pContentDev->DrawLine( Point(nPosX+nSizeX-1,nPosY), Point(nPosX+nSizeX-1,nPosY+nSizeY-1) );
2453 - pContentDev->SetLineColor( COL_BLACK );
2454 + String aStr;
2455 + pDoc->GetString(nCol, nRow, nTab, aStr);
2456 + aDPFieldBtn.setText(aStr);
2457 + aDPFieldBtn.setBoundingBox(Point(nPosX,nPosY), Size(nSizeX-1, nSizeY-1));
2458 + aDPFieldBtn.setDrawPopupButton(pInfo->bPopupButton);
2459 + aDPFieldBtn.setHasHiddenMember(pInfo->bFilterActive);
2460 + aDPFieldBtn.draw();