update dev300-m57
[ooovba.git] / applied_patches / 0459-calc-dp-custom-names-ods-sc.diff
blob6158b6f6d0e61b1aaa84f366416c230eb40d5b43
1 diff --git sc/source/core/data/dptabres.cxx sc/source/core/data/dptabres.cxx
2 index e53ecb9..3e8fa12 100644
3 --- sc/source/core/data/dptabres.cxx
4 +++ sc/source/core/data/dptabres.cxx
5 @@ -1186,20 +1186,28 @@ void ScDPResultMember::ProcessData( const vector<ScDPItemData>& aChildMembers, c
8 /**
9 - * Parse subtotal string and replace all occurrences of '?' with the
10 - * caption string.
11 + * Parse subtotal string and replace all occurrences of '?' with the caption
12 + * string. Do ensure that escaped characters are not translated.
13 */
14 static String lcl_parseSubtotalName(const String& rSubStr, const String& rCaption)
16 String aNewStr;
17 xub_StrLen n = rSubStr.Len();
18 + bool bEscaped = false;
19 for (xub_StrLen i = 0; i < n; ++i)
21 sal_Unicode c = rSubStr.GetChar(i);
22 - if (c == sal_Unicode('?'))
23 + if (!bEscaped && c == sal_Unicode('\\'))
24 + {
25 + bEscaped = true;
26 + continue;
27 + }
29 + if (!bEscaped && c == sal_Unicode('?'))
30 aNewStr.Append(rCaption);
31 else
32 aNewStr.Append(c);
33 + bEscaped = false;
35 return aNewStr;
37 diff --git sc/source/filter/excel/xepivot.cxx sc/source/filter/excel/xepivot.cxx
38 index 0d43d06..043db4d 100644
39 --- sc/source/filter/excel/xepivot.cxx
40 +++ sc/source/filter/excel/xepivot.cxx
41 @@ -1035,6 +1035,31 @@ sal_uInt16 XclExpPTField::GetItemIndex( const String& rName, sal_uInt16 nDefault
43 // fill data --------------------------------------------------------------
45 +/**
46 + * Calc's subtotal names are escaped with backslashes ('\'), while Excel's
47 + * are not escaped at all.
48 + */
49 +static OUString lcl_convertCalcSubtotalName(const OUString& rName)
51 + OUStringBuffer aBuf;
52 + const sal_Unicode* p = rName.getStr();
53 + sal_Int32 n = rName.getLength();
54 + bool bEscaped = false;
55 + for (sal_Int32 i = 0; i < n; ++i)
56 + {
57 + const sal_Unicode c = p[i];
58 + if (!bEscaped && c == sal_Unicode('\\'))
59 + {
60 + bEscaped = true;
61 + continue;
62 + }
64 + aBuf.append(c);
65 + bEscaped = false;
66 + }
67 + return aBuf.makeStringAndClear();
70 void XclExpPTField::SetPropertiesFromDim( const ScDPSaveDimension& rSaveDim )
72 // orientation
73 @@ -1052,7 +1077,10 @@ void XclExpPTField::SetPropertiesFromDim( const ScDPSaveDimension& rSaveDim )
75 const rtl::OUString* pSubtotalName = rSaveDim.GetSubtotalName();
76 if (pSubtotalName)
77 - maFieldExtInfo.mpFieldTotalName.reset(new rtl::OUString(*pSubtotalName));
78 + {
79 + OUString aSubName = lcl_convertCalcSubtotalName(*pSubtotalName);
80 + maFieldExtInfo.mpFieldTotalName.reset(new rtl::OUString(aSubName));
81 + }
83 // subtotals
84 XclPTSubtotalVec aSubtotals;
85 diff --git sc/source/filter/excel/xipivot.cxx sc/source/filter/excel/xipivot.cxx
86 index fd85060..8f290c8 100644
87 --- sc/source/filter/excel/xipivot.cxx
88 +++ sc/source/filter/excel/xipivot.cxx
89 @@ -65,6 +65,7 @@
90 #include <vector>
92 using ::rtl::OUString;
93 +using ::rtl::OUStringBuffer;
94 using ::com::sun::star::sheet::DataPilotFieldOrientation;
95 using ::com::sun::star::sheet::DataPilotFieldOrientation_DATA;
96 using ::com::sun::star::sheet::DataPilotFieldSortInfo;
97 @@ -1034,6 +1035,28 @@ void XclImpPTField::ConvertDataField( ScDPSaveData& rSaveData ) const
99 // private --------------------------------------------------------------------
101 +/**
102 + * Convert Excel-encoded subtotal name to a Calc-encoded one.
103 + */
104 +static OUString lcl_convertExcelSubtotalName(const OUString& rName)
106 + OUStringBuffer aBuf;
107 + const sal_Unicode* p = rName.getStr();
108 + sal_Int32 n = rName.getLength();
109 + for (sal_Int32 i = 0; i < n; ++i)
111 + const sal_Unicode c = p[i];
112 + if (c == sal_Unicode('\\'))
114 + aBuf.append(c);
115 + aBuf.append(c);
117 + else
118 + aBuf.append(c);
120 + return aBuf.makeStringAndClear();
123 ScDPSaveDimension* XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) const
125 const String& rFieldName = GetFieldName();
126 @@ -1089,7 +1112,10 @@ ScDPSaveDimension* XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) con
128 // custom subtotal name
129 if (maFieldExtInfo.mpFieldTotalName.get())
130 - rSaveDim.SetSubtotalName(*maFieldExtInfo.mpFieldTotalName);
132 + OUString aSubName = lcl_convertExcelSubtotalName(*maFieldExtInfo.mpFieldTotalName);
133 + rSaveDim.SetSubtotalName(aSubName);
136 return &rSaveDim;
138 diff --git sc/source/filter/xml/XMLExportDataPilot.cxx sc/source/filter/xml/XMLExportDataPilot.cxx
139 index 0227b44..a06ddb2 100644
140 --- sc/source/filter/xml/XMLExportDataPilot.cxx
141 +++ sc/source/filter/xml/XMLExportDataPilot.cxx
142 @@ -68,6 +68,7 @@
144 using namespace com::sun::star;
145 using namespace xmloff::token;
146 +using ::rtl::OUString;
148 ScXMLExportDataPilot::ScXMLExportDataPilot(ScXMLExport& rTempExport)
149 : rExport(rTempExport),
150 @@ -456,7 +457,10 @@ void ScXMLExportDataPilot::WriteLayoutInfo(ScDPSaveDimension* pDim)
152 void ScXMLExportDataPilot::WriteSubTotals(ScDPSaveDimension* pDim)
154 + using sheet::GeneralFunction;
156 sal_Int32 nSubTotalCount = pDim->GetSubTotalsCount();
157 + const OUString* pLayoutName = pDim->GetSubtotalName();
158 if (nSubTotalCount > 0)
160 SvXMLElementExport aElemSTs(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTALS, sal_True, sal_True);
161 @@ -464,8 +468,11 @@ void ScXMLExportDataPilot::WriteSubTotals(ScDPSaveDimension* pDim)
162 for (sal_Int32 nSubTotal = 0; nSubTotal < nSubTotalCount; nSubTotal++)
164 rtl::OUString sFunction;
165 - ScXMLConverter::GetStringFromFunction( sFunction, (sheet::GeneralFunction)pDim->GetSubTotalFunc(nSubTotal) );
166 + GeneralFunction nFunc = static_cast<GeneralFunction>(pDim->GetSubTotalFunc(nSubTotal));
167 + ScXMLConverter::GetStringFromFunction( sFunction, nFunc);
168 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FUNCTION, sFunction);
169 + if (pLayoutName && nFunc == sheet::GeneralFunction_AUTO)
170 + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, *pLayoutName);
171 SvXMLElementExport aElemST(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTAL, sal_True, sal_True);
174 @@ -481,6 +488,9 @@ void ScXMLExportDataPilot::WriteMembers(ScDPSaveDimension* pDim)
175 for (ScDPSaveDimension::MemberList::const_iterator i=rMembers.begin(); i != rMembers.end() ; i++)
177 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, rtl::OUString((*i)->GetName()));
178 + const OUString* pLayoutName = (*i)->GetLayoutName();
179 + if (pLayoutName)
180 + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, *pLayoutName);
181 rtl::OUStringBuffer sBuffer;
182 SvXMLUnitConverter::convertBool(sBuffer, (*i)->GetIsVisible());
183 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, sBuffer.makeStringAndClear());
184 @@ -678,6 +688,10 @@ void ScXMLExportDataPilot::WriteGroupDimElements(ScDPSaveDimension* pDim, const
185 void ScXMLExportDataPilot::WriteDimension(ScDPSaveDimension* pDim, const ScDPDimensionSaveData* pDimData)
187 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SOURCE_FIELD_NAME, rtl::OUString(pDim->GetName()));
188 + const OUString* pLayoutName = pDim->GetLayoutName();
189 + if (pLayoutName)
190 + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, *pLayoutName);
192 if (pDim->IsDataLayout())
193 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IS_DATA_LAYOUT_FIELD, XML_TRUE);
194 rtl::OUString sValueStr;
195 @@ -714,6 +728,15 @@ void ScXMLExportDataPilot::WriteDimensions(ScDPSaveData* pDPSave)
199 +void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const OUString* pGrandTotal)
201 + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, bVisible ? XML_TRUE : XML_FALSE);
202 + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, eOrient);
203 + if (pGrandTotal)
204 + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, *pGrandTotal);
205 + SvXMLElementExport aElemGrandTotal(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_GRAND_TOTAL, sal_True, sal_True);
208 void ScXMLExportDataPilot::WriteDataPilots(const uno::Reference <sheet::XSpreadsheetDocument>& /* xSpreadDoc */)
210 pDoc = rExport.GetDocument();
211 @@ -784,6 +807,20 @@ void ScXMLExportDataPilot::WriteDataPilots(const uno::Reference <sheet::XSpreads
212 if ((*pDPs)[i]->GetHeaderLayout ())
213 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_HEADER_GRID_LAYOUT, XML_TRUE);
214 SvXMLElementExport aElemDP(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLE, sal_True, sal_True);
216 + // grand total elements.
218 + const OUString* pGrandTotalName = pDPSave->GetGrandTotalName();
219 + if (bRowGrand && bColumnGrand)
221 + WriteGrandTotal(XML_BOTH, true, pGrandTotalName);
223 + else
225 + WriteGrandTotal(XML_ROW, bRowGrand, pGrandTotalName);
226 + WriteGrandTotal(XML_COLUMN, bColumnGrand, pGrandTotalName);
229 rExport.CheckAttrList();
230 if ((*pDPs)[i]->IsSheetData())
232 diff --git sc/source/filter/xml/XMLExportDataPilot.hxx sc/source/filter/xml/XMLExportDataPilot.hxx
233 index 2274d8c..881e29b 100644
234 --- sc/source/filter/xml/XMLExportDataPilot.hxx
235 +++ sc/source/filter/xml/XMLExportDataPilot.hxx
236 @@ -34,6 +34,7 @@
237 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
238 #include <rtl/ustring.hxx>
239 #include "global.hxx"
240 +#include "xmloff/xmltoken.hxx"
242 class ScXMLExport;
243 class ScDocument;
244 @@ -69,6 +70,8 @@ class ScXMLExportDataPilot
245 void WriteDimension(ScDPSaveDimension* pDim, const ScDPDimensionSaveData* pDimData);
246 void WriteDimensions(ScDPSaveData* pDPSave);
248 + void WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const ::rtl::OUString* pGrandTotal);
250 public:
251 ScXMLExportDataPilot(ScXMLExport& rExport);
252 ~ScXMLExportDataPilot();
253 diff --git sc/source/filter/xml/xmldpimp.cxx sc/source/filter/xml/xmldpimp.cxx
254 index de4c7ca..cc51364 100644
255 --- sc/source/filter/xml/xmldpimp.cxx
256 +++ sc/source/filter/xml/xmldpimp.cxx
257 @@ -66,6 +66,8 @@
259 using namespace com::sun::star;
260 using namespace xmloff::token;
261 +using ::com::sun::star::uno::Reference;
262 +using ::com::sun::star::xml::sax::XAttributeList;
263 using ::rtl::OUString;
265 //------------------------------------------------------------------
266 @@ -114,6 +116,9 @@ void ScXMLDataPilotTablesContext::EndElement()
270 +ScXMLDataPilotTableContext::GrandTotalItem::GrandTotalItem() :
271 + mbVisible(false) {}
273 ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
274 USHORT nPrfx,
275 const ::rtl::OUString& rLName,
276 @@ -165,6 +170,19 @@ ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
277 case XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL :
279 sGrandTotal = sValue;
280 + if (IsXMLToken(sValue, XML_BOTH))
281 + {
282 + maRowGrandTotal.mbVisible = true;
283 + maColGrandTotal.mbVisible = true;
285 + else if (IsXMLToken(sValue, XML_ROW))
286 + {
287 + maRowGrandTotal.mbVisible = true;
289 + else if (IsXMLToken(sValue, XML_COLUMN))
290 + {
291 + maColGrandTotal.mbVisible = true;
294 break;
295 case XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS :
296 @@ -249,6 +267,11 @@ SvXMLImportContext *ScXMLDataPilotTableContext::CreateChildContext( USHORT nPref
297 nSourceType = SERVICE;
299 break;
300 + case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL:
302 + pContext = new ScXMLDataPilotGrandTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this);
304 + break;
305 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE :
307 pContext = new ScXMLSourceCellRangeContext(GetScImport(), nPrefix, rLName, xAttrList, this);
308 @@ -417,26 +440,15 @@ void ScXMLDataPilotTableContext::EndElement()
310 break;
312 - if (IsXMLToken(sGrandTotal, XML_BOTH))
314 - pDPSave->SetRowGrand(sal_True);
315 - pDPSave->SetColumnGrand(sal_True);
317 - else if (IsXMLToken(sGrandTotal, XML_ROW))
319 - pDPSave->SetRowGrand(sal_True);
320 - pDPSave->SetColumnGrand(sal_False);
322 - else if (IsXMLToken(sGrandTotal, XML_COLUMN))
324 - pDPSave->SetRowGrand(sal_False);
325 - pDPSave->SetColumnGrand(sal_True);
327 - else
329 - pDPSave->SetRowGrand(sal_False);
330 - pDPSave->SetColumnGrand(sal_False);
333 + pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
334 + pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
335 + if (maRowGrandTotal.maDisplayName.getLength())
336 + // TODO: Right now, we only support one grand total name for both
337 + // column and row totals. Take the value from the row total for
338 + // now.
339 + pDPSave->SetGrandTotalName(maRowGrandTotal.maDisplayName);
341 pDPSave->SetIgnoreEmptyRows(bIgnoreEmptyRows);
342 pDPSave->SetRepeatIfEmpty(bIdentifyCategories);
343 pDPSave->SetFilterButton(bShowFilter);
344 @@ -454,6 +466,30 @@ void ScXMLDataPilotTableContext::EndElement()
348 +void ScXMLDataPilotTableContext::SetGrandTotal(
349 + XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName)
351 + switch (eOrientation)
353 + case XML_BOTH:
354 + maRowGrandTotal.mbVisible = bVisible;
355 + maRowGrandTotal.maDisplayName = rDisplayName;
356 + maColGrandTotal.mbVisible = bVisible;
357 + maColGrandTotal.maDisplayName = rDisplayName;
358 + break;
359 + case XML_ROW:
360 + maRowGrandTotal.mbVisible = bVisible;
361 + maRowGrandTotal.maDisplayName = rDisplayName;
362 + break;
363 + case XML_COLUMN:
364 + maColGrandTotal.mbVisible = bVisible;
365 + maColGrandTotal.maDisplayName = rDisplayName;
366 + break;
367 + default:
372 ScXMLDPSourceSQLContext::ScXMLDPSourceSQLContext( ScXMLImport& rImport,
373 USHORT nPrfx,
374 const ::rtl::OUString& rLName,
375 @@ -698,6 +734,80 @@ void ScXMLSourceServiceContext::EndElement()
379 +ScXMLImport& ScXMLDataPilotGrandTotalContext::GetScImport()
381 + return static_cast<ScXMLImport&>(GetImport());
384 +ScXMLDataPilotGrandTotalContext::ScXMLDataPilotGrandTotalContext(
385 + ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName, const Reference<XAttributeList>& xAttrList,
386 + ScXMLDataPilotTableContext* pTableContext ) :
387 + SvXMLImportContext( rImport, nPrefix, rLName ),
388 + mpTableContext(pTableContext),
389 + meOrientation(NONE),
390 + mbVisible(false)
392 + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
393 + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotGrandTotalAttrTokenMap();
394 + for (sal_Int16 i = 0; i < nAttrCount; ++i)
396 + const OUString& rAttrName = xAttrList->getNameByIndex(i);
397 + const OUString& rAttrValue = xAttrList->getValueByIndex(i);
399 + OUString aLocalName;
400 + USHORT nLocalPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
401 + switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
403 + case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY:
404 + mbVisible = IsXMLToken(rAttrValue, XML_TRUE);
405 + break;
406 + case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_ORIENTATION:
407 + if (IsXMLToken(rAttrValue, XML_BOTH))
408 + meOrientation = BOTH;
409 + else if (IsXMLToken(rAttrValue, XML_ROW))
410 + meOrientation = ROW;
411 + else if (IsXMLToken(rAttrValue, XML_COLUMN))
412 + meOrientation = COLUMN;
413 + break;
414 + case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME:
415 + maDisplayName = rAttrValue;
416 + break;
417 + default:
423 +ScXMLDataPilotGrandTotalContext::~ScXMLDataPilotGrandTotalContext()
427 +SvXMLImportContext* ScXMLDataPilotGrandTotalContext::CreateChildContext(
428 + USHORT nPrefix, const ::rtl::OUString& rLocalName, const Reference<XAttributeList>& xAttrList )
430 + return NULL;
433 +void ScXMLDataPilotGrandTotalContext::EndElement()
435 + XMLTokenEnum eOrient = XML_NONE;
436 + switch (meOrientation)
438 + case BOTH:
439 + eOrient = XML_BOTH;
440 + break;
441 + case ROW:
442 + eOrient = XML_ROW;
443 + break;
444 + case COLUMN:
445 + eOrient = XML_COLUMN;
446 + break;
447 + default:
450 + mpTableContext->SetGrandTotal(eOrient, mbVisible, maDisplayName);
453 ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport& rImport,
454 USHORT nPrfx,
455 const ::rtl::OUString& rLName,
456 @@ -783,6 +893,7 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
458 sal_Bool bHasName(sal_False);
459 sal_Bool bDataLayout(sal_False);
460 + OUString aDisplayName;
461 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
462 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotFieldAttrTokenMap();
463 for( sal_Int16 i=0; i < nAttrCount; ++i )
464 @@ -801,6 +912,11 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
465 bHasName = sal_True;
467 break;
468 + case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME:
470 + aDisplayName = sValue;
472 + break;
473 case XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD :
475 bDataLayout = IsXMLToken(sValue, XML_TRUE);
476 @@ -830,7 +946,11 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
479 if (bHasName)
480 + {
481 pDim = new ScDPSaveDimension(String(sName), bDataLayout);
482 + if (aDisplayName.getLength())
483 + pDim->SetLayoutName(aDisplayName);
487 ScXMLDataPilotFieldContext::~ScXMLDataPilotFieldContext()
488 @@ -864,6 +984,12 @@ SvXMLImportContext *ScXMLDataPilotFieldContext::CreateChildContext( USHORT nPref
489 return pContext;
492 +void ScXMLDataPilotFieldContext::SetSubTotalName(const OUString& rName)
494 + if (pDim)
495 + pDim->SetSubtotalName(rName);
498 void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember* pMember)
500 if (pDim)
501 @@ -1265,6 +1391,8 @@ SvXMLImportContext *ScXMLDataPilotSubTotalsContext::CreateChildContext( USHORT n
502 void ScXMLDataPilotSubTotalsContext::EndElement()
504 pDataPilotField->SetSubTotals(pFunctions, nFunctionCount);
505 + if (maDisplayName.getLength())
506 + pDataPilotField->SetSubTotalName(maDisplayName);
509 void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction)
510 @@ -1287,6 +1415,11 @@ void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction)
514 +void ScXMLDataPilotSubTotalsContext::SetDisplayName(const OUString& rName)
516 + maDisplayName = rName;
519 ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImport,
520 USHORT nPrfx,
521 const ::rtl::OUString& rLName,
522 @@ -1313,6 +1446,8 @@ ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImpo
523 pDataPilotSubTotals->AddFunction( sal::static_int_cast<sal_Int16>(
524 ScXMLConverter::GetFunctionFromString( sValue ) ) );
526 + case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME:
527 + pDataPilotSubTotals->SetDisplayName(sValue);
528 break;
531 @@ -1410,6 +1545,10 @@ ScXMLDataPilotMemberContext::ScXMLDataPilotMemberContext( ScXMLImport& rImport,
532 bHasName = sal_True;
534 break;
535 + case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME:
537 + maDisplayName = sValue;
539 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY :
541 bDisplay = IsXMLToken(sValue, XML_TRUE);
542 @@ -1446,6 +1585,8 @@ void ScXMLDataPilotMemberContext::EndElement()
543 if (bHasName) // #i53407# don't check sName, empty name is allowed
545 ScDPSaveMember* pMember = new ScDPSaveMember(String(sName));
546 + if (maDisplayName.getLength())
547 + pMember->SetLayoutName(maDisplayName);
548 pMember->SetIsVisible(bDisplay);
549 pMember->SetShowDetails(bDisplayDetails);
550 pDataPilotField->AddMember(pMember);
551 diff --git sc/source/filter/xml/xmldpimp.hxx sc/source/filter/xml/xmldpimp.hxx
552 index ac52bc3..8f42bf1 100644
553 --- sc/source/filter/xml/xmldpimp.hxx
554 +++ sc/source/filter/xml/xmldpimp.hxx
555 @@ -83,10 +83,19 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext
557 typedef ::std::hash_set< ::rtl::OUString, ::rtl::OUStringHash > StringSet;
558 StringSet maHiddenMemberFields;
560 + struct GrandTotalItem
562 + ::rtl::OUString maDisplayName;
563 + bool mbVisible;
564 + GrandTotalItem();
565 + };
566 ScDocument* pDoc;
567 ScDPObject* pDPObject;
568 ScDPSaveData* pDPSave;
569 ScDPDimensionSaveData* pDPDimSaveData;
570 + GrandTotalItem maRowGrandTotal;
571 + GrandTotalItem maColGrandTotal;
572 rtl::OUString sDataPilotTableName;
573 rtl::OUString sApplicationData;
574 rtl::OUString sGrandTotal;
575 @@ -140,6 +149,7 @@ public:
577 virtual void EndElement();
579 + void SetGrandTotal(::xmloff::token::XMLTokenEnum eOrientation, bool bVisible, const ::rtl::OUString& rDisplayName);
580 void SetDatabaseName(const rtl::OUString& sValue) { sDatabaseName = sValue; }
581 void SetSourceObject(const rtl::OUString& sValue) { sSourceObject = sValue; }
582 void SetNative(const sal_Bool bValue) { bIsNative = bValue; }
583 @@ -262,6 +272,34 @@ public:
584 virtual void EndElement();
587 +class ScXMLDataPilotGrandTotalContext : public SvXMLImportContext
589 + enum Orientation { COLUMN, ROW, BOTH, NONE };
591 + ScXMLImport& GetScImport();
593 + ScXMLDataPilotTableContext* mpTableContext;
594 + ::rtl::OUString maDisplayName;
595 + Orientation meOrientation;
596 + bool mbVisible;
598 +public:
599 + ScXMLDataPilotGrandTotalContext(
600 + ScXMLImport& rImport, USHORT nPrefix, const ::rtl::OUString& rLName,
601 + const ::com::sun::star::uno::Reference<
602 + ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
603 + ScXMLDataPilotTableContext* pTableContext );
605 + virtual ~ScXMLDataPilotGrandTotalContext();
607 + virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
608 + const ::rtl::OUString& rLocalName,
609 + const ::com::sun::star::uno::Reference<
610 + ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
612 + virtual void EndElement();
615 class ScXMLSourceCellRangeContext : public SvXMLImportContext
617 ScXMLDataPilotTableContext* pDataPilotTable;
618 @@ -339,6 +377,7 @@ public:
620 void SetShowEmpty(const sal_Bool bValue) { if (pDim) pDim->SetShowEmpty(bValue); }
621 void SetSubTotals(const sal_uInt16* pFunctions, const sal_Int16 nCount) { if(pDim) pDim->SetSubTotals(nCount, pFunctions); }
622 + void SetSubTotalName(const ::rtl::OUString& rName);
623 void AddMember(ScDPSaveMember* pMember);
624 void SetFieldReference(const com::sun::star::sheet::DataPilotFieldReference& aRef) { if (pDim) pDim->SetReferenceValue(&aRef); }
625 void SetAutoShowInfo(const com::sun::star::sheet::DataPilotFieldAutoShowInfo& aInfo) { if (pDim) pDim->SetAutoShowInfo(&aInfo); }
626 @@ -463,6 +502,7 @@ class ScXMLDataPilotSubTotalsContext : public SvXMLImportContext
628 sal_Int16 nFunctionCount;
629 sal_uInt16* pFunctions;
630 + ::rtl::OUString maDisplayName;
632 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
633 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
634 @@ -486,6 +526,7 @@ public:
636 virtual void EndElement();
637 void AddFunction(sal_Int16 nFunction);
638 + void SetDisplayName(const ::rtl::OUString& rName);
641 class ScXMLDataPilotSubTotalContext : public SvXMLImportContext
642 @@ -543,6 +584,7 @@ class ScXMLDataPilotMemberContext : public SvXMLImportContext
643 ScXMLDataPilotFieldContext* pDataPilotField;
645 rtl::OUString sName;
646 + rtl::OUString maDisplayName;
647 sal_Bool bDisplay;
648 sal_Bool bDisplayDetails;
649 sal_Bool bHasName;
650 diff --git sc/source/filter/xml/xmlimprt.cxx sc/source/filter/xml/xmlimprt.cxx
651 index 728373e..952afcd 100644
652 --- sc/source/filter/xml/xmlimprt.cxx
653 +++ sc/source/filter/xml/xmlimprt.cxx
654 @@ -1413,6 +1413,7 @@ const SvXMLTokenMap& ScXMLImport::GetDataPilotTableElemTokenMap()
656 { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL },
657 { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE },
658 + { XML_NAMESPACE_TABLE, XML_DATA_PILOT_GRAND_TOTAL, XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL },
659 { XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY },
660 { XML_NAMESPACE_TABLE, XML_SOURCE_SERVICE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE },
661 { XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE, XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE },
662 @@ -1446,6 +1447,24 @@ const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceServiceAttrTokenMap()
663 return *pDataPilotTableSourceServiceAttrTokenMap;
666 +const SvXMLTokenMap& ScXMLImport::GetDataPilotGrandTotalAttrTokenMap()
668 + if (!pDataPilotGrandTotalAttrTokenMap)
670 + static __FAR_DATA SvXMLTokenMapEntry aDataPilotGrandTotalAttrTokenMap[] =
672 + { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY },
673 + { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_ORIENTATION },
674 + { XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME },
675 + XML_TOKEN_MAP_END
676 + };
678 + pDataPilotGrandTotalAttrTokenMap = new SvXMLTokenMap( aDataPilotGrandTotalAttrTokenMap );
681 + return *pDataPilotGrandTotalAttrTokenMap;
684 const SvXMLTokenMap& ScXMLImport::GetDataPilotTableSourceCellRangeAttrTokenMap()
686 if( !pDataPilotTableSourceCellRangeAttrTokenMap )
687 @@ -1485,6 +1504,7 @@ const SvXMLTokenMap& ScXMLImport::GetDataPilotFieldAttrTokenMap()
688 static __FAR_DATA SvXMLTokenMapEntry aDataPilotFieldAttrTokenMap[] =
690 { XML_NAMESPACE_TABLE, XML_SOURCE_FIELD_NAME, XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME },
691 + { XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME },
692 { XML_NAMESPACE_TABLE, XML_IS_DATA_LAYOUT_FIELD, XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD },
693 { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION },
694 { XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION },
695 @@ -1576,6 +1596,7 @@ const SvXMLTokenMap& ScXMLImport::GetDataPilotSubTotalAttrTokenMap()
696 static __FAR_DATA SvXMLTokenMapEntry aDataPilotSubTotalAttrTokenMap[] =
698 { XML_NAMESPACE_TABLE, XML_FUNCTION, XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION },
699 + { XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME },
700 XML_TOKEN_MAP_END
703 @@ -1608,6 +1629,7 @@ const SvXMLTokenMap& ScXMLImport::GetDataPilotMemberAttrTokenMap()
704 static __FAR_DATA SvXMLTokenMapEntry aDataPilotMemberAttrTokenMap[] =
706 { XML_NAMESPACE_TABLE, XML_NAME, XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME },
707 + { XML_NAMESPACE_TABLE, XML_DISPLAY_NAME, XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME },
708 { XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY },
709 { XML_NAMESPACE_TABLE, XML_SHOW_DETAILS, XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS },
710 XML_TOKEN_MAP_END
711 @@ -1747,6 +1769,7 @@ ScXMLImport::ScXMLImport(
712 pDataPilotTableAttrTokenMap( 0 ),
713 pDataPilotTableElemTokenMap( 0 ),
714 pDataPilotTableSourceServiceAttrTokenMap( 0 ),
715 + pDataPilotGrandTotalAttrTokenMap(NULL),
716 pDataPilotTableSourceCellRangeElemTokenMap( 0 ),
717 pDataPilotTableSourceCellRangeAttrTokenMap( 0 ),
718 pDataPilotFieldAttrTokenMap( 0 ),
719 diff --git sc/source/filter/xml/xmlimprt.hxx sc/source/filter/xml/xmlimprt.hxx
720 index 8ff4178..c441fd2 100644
721 --- sc/source/filter/xml/xmlimprt.hxx
722 +++ sc/source/filter/xml/xmlimprt.hxx
723 @@ -517,6 +517,7 @@ enum ScXMLDataPilotTableElemTokens
725 XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL,
726 XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE,
727 + XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL,
728 XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY,
729 XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE,
730 XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE,
731 @@ -532,6 +533,13 @@ enum ScXMLDataPilotTableSourceServiceAttrTokens
732 XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD
735 +enum ScXMLDataPilotGrandTotalAttrTokens
737 + XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY,
738 + XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_ORIENTATION,
739 + XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME
742 enum ScXMLDataPilotTableSourceCellRangeElemTokens
744 XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER
745 @@ -545,6 +553,7 @@ enum ScXMLDataPilotTableSourceCellRangeAttrTokens
746 enum ScXMLDataPilotFieldAttrTokens
748 XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME,
749 + XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME,
750 XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD,
751 XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION,
752 XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION,
753 @@ -580,7 +589,8 @@ enum ScXMLDataPilotSubTotalsElemTokens
755 enum ScXMLDataPilotSubTotalAttrTokens
757 - XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION
758 + XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION,
759 + XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME
762 enum ScXMLDataPilotMembersElemTokens
763 @@ -591,6 +601,7 @@ enum ScXMLDataPilotMembersElemTokens
764 enum ScXMLDataPilotMemberAttrTokens
766 XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME,
767 + XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME,
768 XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY,
769 XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS
771 @@ -751,6 +762,7 @@ class ScXMLImport: public SvXMLImport
772 SvXMLTokenMap *pDataPilotTableAttrTokenMap;
773 SvXMLTokenMap *pDataPilotTableElemTokenMap;
774 SvXMLTokenMap *pDataPilotTableSourceServiceAttrTokenMap;
775 + SvXMLTokenMap *pDataPilotGrandTotalAttrTokenMap;
776 SvXMLTokenMap *pDataPilotTableSourceCellRangeElemTokenMap;
777 SvXMLTokenMap *pDataPilotTableSourceCellRangeAttrTokenMap;
778 SvXMLTokenMap *pDataPilotFieldAttrTokenMap;
779 @@ -918,6 +930,7 @@ public:
780 const SvXMLTokenMap& GetDataPilotTableAttrTokenMap();
781 const SvXMLTokenMap& GetDataPilotTableElemTokenMap();
782 const SvXMLTokenMap& GetDataPilotTableSourceServiceAttrTokenMap();
783 + const SvXMLTokenMap& GetDataPilotGrandTotalAttrTokenMap();
784 const SvXMLTokenMap& GetDataPilotTableSourceCellRangeElemTokenMap();
785 const SvXMLTokenMap& GetDataPilotTableSourceCellRangeAttrTokenMap();
786 const SvXMLTokenMap& GetDataPilotFieldAttrTokenMap();
787 diff --git sc/source/ui/view/dbfunc3.cxx sc/source/ui/view/dbfunc3.cxx
788 index f58d9b5..c879c67 100644
789 --- sc/source/ui/view/dbfunc3.cxx
790 +++ sc/source/ui/view/dbfunc3.cxx
791 @@ -1390,7 +1390,7 @@ void ScDBFunc::UngroupDataPilot()
795 -OUString lcl_replaceMemberNameInSubtotal(const OUString& rSubtotal, const OUString& rMemberName)
796 +static OUString lcl_replaceMemberNameInSubtotal(const OUString& rSubtotal, const OUString& rMemberName)
798 sal_Int32 n = rSubtotal.getLength();
799 const sal_Unicode* p = rSubtotal.getStr();
800 @@ -1407,6 +1407,18 @@ OUString lcl_replaceMemberNameInSubtotal(const OUString& rSubtotal, const OUStri
801 aBuf.append(aWord);
802 aBuf.append(c);
804 + else if (c == sal_Unicode('\\'))
806 + // Escape a backslash character.
807 + aWordBuf.append(c);
808 + aWordBuf.append(c);
810 + else if (c == sal_Unicode('?'))
812 + // A literal '?' must be escaped with a backslash ('\');
813 + aWordBuf.append(sal_Unicode('\\'));
814 + aWordBuf.append(c);
816 else
817 aWordBuf.append(c);