Kaydet (Commit) 625653c8 authored tarafından Tamás Zolnai's avatar Tamás Zolnai

tdf#107711:Pivot table: filtering of non-string fields is not exported to XLSX

Same issue what we have in case of XLS filter. We need to have
the right string representation of pivot field items.

Change-Id: Ifb686ad268c61b03c7dcccc66f65e6f8247eab4f
Reviewed-on: https://gerrit.libreoffice.org/42956Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst c3609f10
......@@ -760,13 +760,24 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
std::set<size_t> aUsedCachePositions;
for (const auto & rMember : aMembers)
{
auto it = std::find_if(iCacheFieldItems_begin, iCacheFieldItems_end,
[&rMember](const ScDPItemData& arg) -> bool { return arg.GetString() == rMember.maName; });
if (it != iCacheFieldItems_end)
for (auto it = iCacheFieldItems_begin; it != iCacheFieldItems_end; ++it)
{
size_t nCachePos = it - iCacheFieldItems_begin;
aMemberSequence.emplace_back(nCachePos, !rMember.mbVisible);
aUsedCachePositions.insert(nCachePos);
OUString sFormattedName;
if (it->HasStringData() || it->IsEmpty())
{
sFormattedName = it->GetString();
}
else
{
sFormattedName = const_cast<ScDPObject&>(rDPObj).GetFormattedString(pDim->GetName(), it->GetValue());
}
if (sFormattedName == rMember.maName)
{
size_t nCachePos = it - iCacheFieldItems_begin;
aMemberSequence.emplace_back(nCachePos, !rMember.mbVisible);
aUsedCachePositions.insert(nCachePos);
break;
}
}
}
// Now add all remaining cache items as hidden
......
......@@ -31,6 +31,10 @@ namespace com { namespace sun { namespace star {
namespace oox { namespace core { class Relations; } }
class ScDPSaveDimension;
class ScDPObject;
class DateTime;
namespace oox {
namespace xls {
......@@ -76,6 +80,9 @@ public:
const css::uno::Any& getValue() const { return maValue; }
/** Returns the string representation of the item. */
OUString getName() const;
/** Returns the string representation of the item, using the actual formating. */
OUString getFormattedName(const ScDPSaveDimension& rSaveDim, ScDPObject* pObj, const DateTime& rNullDate) const;
/** Returns true if the item is unused. */
bool isUnused() const { return mbUnused; }
......
......@@ -43,6 +43,9 @@
#include "tablebuffer.hxx"
#include "unitconverter.hxx"
#include "worksheetbuffer.hxx"
#include "dpobject.hxx"
#include "dpsave.hxx"
#include "dpdimsave.hxx"
namespace oox {
namespace xls {
......@@ -230,6 +233,22 @@ OUString PivotCacheItem::getName() const
return OUString();
}
OUString PivotCacheItem::getFormattedName(const ScDPSaveDimension& rSaveDim, ScDPObject* pObj, const DateTime& rNullDate) const
{
switch( mnType )
{
case XML_m: return OUString();
case XML_s: return maValue.get< OUString >();
case XML_n: return pObj->GetFormattedString(rSaveDim.GetName(), maValue.get<double>());
case XML_i: return pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(maValue.get< sal_Int32 >()));
case XML_b: return pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(maValue.get< bool >()));
case XML_d: return pObj->GetFormattedString(rSaveDim.GetName(), maValue.get< css::util::DateTime >() - rNullDate);
case XML_e: return OUString(); // !TODO
}
OSL_FAIL( "PivotCacheItem::getFormattedName - invalid data type" );
return OUString();
}
PivotCacheItemList::PivotCacheItemList( const WorkbookHelper& rHelper ) :
WorkbookHelper( rHelper )
{
......
......@@ -52,6 +52,7 @@
#include "dpdimsave.hxx"
#include "document.hxx"
#include "documentimport.hxx"
#include "workbooksettings.hxx"
namespace oox {
namespace xls {
......@@ -547,7 +548,10 @@ void PivotTableField::convertPageField( const PTPageFieldModel& rPageField )
{
if( const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( nCacheItem ) )
{
OUString aSelectedPage = pSharedItem->getName();
ScDPObject* pDPObj = mrPivotTable.getDPObject();
ScDPSaveData* pSaveData = pDPObj->GetSaveData();
ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(pCacheField->getName());
OUString aSelectedPage = pSharedItem->getFormattedName(*pDim, pDPObj, DateTime(getWorkbookSettings().getNullDate()));
aPropSet.setProperty( PROP_SelectedPage, aSelectedPage );
}
}
......@@ -748,7 +752,7 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32
try
{
ScDPSaveMember* pMem = pDim->GetMemberByName(pSharedItem->getName());
ScDPSaveMember* pMem = pDim->GetMemberByName(pSharedItem->getFormattedName(*pDim, pDPObj, DateTime(getWorkbookSettings().getNullDate())));
pMem->SetShowDetails(aIt->mbShowDetails);
pMem->SetIsVisible(!aIt->mbHidden);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment