/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Initialize format output entries (FormatOutputEntry) and set the data already available from output fields // (rColumnFields and rRowFields) and the pivot table format list (PivotTableFormat).
for (PivotTableFormat const& rFormat : mpFormats->getVector())
{
size_t nMaxNumberOfIndices = 1; for (autoconst& rSelection : rFormat.aSelections)
{ if (rSelection.nIndices.size() > 1)
nMaxNumberOfIndices = rSelection.nIndices.size();
}
// If column fields list is empty, but there is a data field in columns that is not part of column fields if (rColumnFields.size() == 0 && bColumnFieldIsDataOnly)
{ // Initialize column output fields to have 1 data output field
aEntry.aColumnOutputFields.resize(1);
FormatOutputField& rOutputField = aEntry.aColumnOutputFields[0];
rOutputField.nDimension = -2;
Selection const* pSelection = findSelection(rFormat, -2); if (pSelection)
fillOutputFieldFromSelection(rOutputField, *pSelection, nSelectionIndex,
aNameResolver);
} else
{
initFormatOutputField(nSelectionIndex, aEntry.aColumnOutputFields, rColumnFields,
rFormat, aNameResolver);
}
maFormatOutputEntries.push_back(aEntry);
}
}
}
void FormatOutput::insertEmptyDataColumn(SCCOL nColPos, SCROW nRowPos)
{ if (!mpFormats) return;
// Search previous entries for the name / value if (rFieldData.bContinue)
{
tools::Long nCurrent = nMemberIndex - 1; while (nCurrent >= 0 && rLineDataVector[nCurrent].maFields[nFieldIndex].bContinue)
nCurrent--;
/** Check the lines in matches and maybe matches and output */ void evaluateMatches(ScDocument& rDocument,
std::vector<std::reference_wrapper<const LineData>> const& rMatches,
std::vector<std::reference_wrapper<const LineData>> const& rMaybeMatches,
std::vector<SCCOLROW>& aRows, std::vector<SCCOLROW>& aColumns,
FormatOutputEntry const& rOutputEntry, FormatResultDirection eResultDirection)
{ // We expect that tab and pattern to be set or this method shouldn't be called at all
assert(rOutputEntry.onTab);
assert(rOutputEntry.pPattern);
if (rMatches.empty() && rMaybeMatches.empty()) return;
for (LineData const& rLineData : rLineDataVector)
{ // Can't continue if we don't have complete row/column data if (!rLineData.oLine || !rLineData.oPosition) continue;
if (rOutputEntry.eType == FormatType::Label && !bMaybeExists)
{ // Primary axis is set to column (line) then row (position)
SCCOLROW nColumn = *rLineData.oLine;
SCCOLROW nRow = *rLineData.oPosition;
// In row orientation, the primary axis is row, then column, so we need to swap if (eResultDirection == FormatResultDirection::ROW)
std::swap(nRow, nColumn);
// Set the pattern to the sheet
rDocument.ApplyPattern(nColumn, nRow, *rOutputEntry.onTab, *rOutputEntry.pPattern);
} elseif (rOutputEntry.eType == FormatType::Data)
{ if (eResultDirection == FormatResultDirection::ROW)
aRows.push_back(*rLineData.oLine); elseif (eResultDirection == FormatResultDirection::COLUMN)
aColumns.push_back(*rLineData.oLine);
}
}
}
} // end anonymous namespace
void FormatOutput::apply(ScDocument& rDocument)
{ if (!mpFormats) return;
for (autoconst& rOutputEntry : maFormatOutputEntries)
{ if (!rOutputEntry.onTab || !rOutputEntry.pPattern) continue;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.