From ce571823e2be946308c814f600449e62f1b3a87d Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 30 Mar 2016 02:41:07 +0200 Subject: extract another function from ScDocument::FillInfo Change-Id: Ief094beebbff2bce9f087853cbda6adeeafe07fc Reviewed-on: https://gerrit.libreoffice.org/23635 Tested-by: Jenkins Reviewed-by: Markus Mohrhard (cherry picked from commit b22e51d0c60f959c2db77bd3d23119b53bd87545) Reviewed-on: https://gerrit.libreoffice.org/25290 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian --- sc/source/core/data/fillinfo.cxx | 119 +++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 54 deletions(-) (limited to 'sc') diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 486adbfd6152..ef71b30b9e36 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -338,6 +338,68 @@ void initColWidths(RowInfo* pRowInfo, ScDocument* pDoc, double fColScale, SCTAB } } +bool handleConditionalFormat(ScConditionalFormatList* pCondFormList, const std::vector rCondFormats, + CellInfo* pInfo, ScStyleSheetPool* pStlPool, + const ScAddress& rAddr, bool& bHidden, bool& bHideFormula, bool bTabProtect) +{ + bool bFound = false; + bool bAnyCondition = false; + for(std::vector::const_iterator itr = rCondFormats.begin(); + itr != rCondFormats.end() && !bFound; ++itr) + { + ScConditionalFormat* pCondForm = pCondFormList->GetFormat(*itr); + if(!pCondForm) + continue; + + ScCondFormatData aData = pCondForm->GetData( + pInfo->maCell, rAddr); + if (!aData.aStyleName.isEmpty()) + { + SfxStyleSheetBase* pStyleSheet = + pStlPool->Find( aData.aStyleName, SFX_STYLE_FAMILY_PARA ); + if ( pStyleSheet ) + { + //TODO: cache Style-Sets !!! + pInfo->pConditionSet = &pStyleSheet->GetItemSet(); + bAnyCondition = true; + + // we need to check already here for protected cells + const SfxPoolItem* pItem; + if ( bTabProtect && pInfo->pConditionSet->GetItemState( ATTR_PROTECTION, true, &pItem ) == SfxItemState::SET ) + { + const ScProtectionAttr* pProtAttr = static_cast(pItem); + bHidden = pProtAttr->GetHideCell(); + bHideFormula = pProtAttr->GetHideFormula(); + + } + bFound = true; + + } + // if style is not there, treat like no condition + } + + if(aData.pColorScale) + { + pInfo->pColorScale.reset(aData.pColorScale); + bFound = true; + } + + if(aData.pDataBar) + { + pInfo->pDataBar.reset(aData.pDataBar); + bFound = true; + } + + if(aData.pIconSet) + { + pInfo->pIconSet.reset(aData.pIconSet); + bFound = true; + } + } + + return bAnyCondition; +} + } void ScDocument::FillInfo( @@ -564,61 +626,10 @@ void ScDocument::FillInfo( pThisRowInfo->bEmptyBack = false; } - if ( bContainsCondFormat ) + if (bContainsCondFormat) { - bool bFound = false; - for(std::vector::const_iterator itr = rCondFormats.begin(); - itr != rCondFormats.end() && !bFound; ++itr) - { - ScConditionalFormat* pCondForm = pCondFormList->GetFormat(*itr); - if(!pCondForm) - continue; - - ScCondFormatData aData = pCondForm->GetData( - pInfo->maCell, ScAddress(nX, nCurRow, nTab)); - if (!aData.aStyleName.isEmpty()) - { - SfxStyleSheetBase* pStyleSheet = - pStlPool->Find( aData.aStyleName, SFX_STYLE_FAMILY_PARA ); - if ( pStyleSheet ) - { - //TODO: cache Style-Sets !!! - pInfo->pConditionSet = &pStyleSheet->GetItemSet(); - bAnyCondition = true; - - // we need to check already here for protected cells - const SfxPoolItem* pItem; - if ( bTabProtect && pInfo->pConditionSet->GetItemState( ATTR_PROTECTION, true, &pItem ) == SfxItemState::SET ) - { - const ScProtectionAttr* pProtAttr = static_cast(pItem); - bHidden = pProtAttr->GetHideCell(); - bHideFormula = pProtAttr->GetHideFormula(); - - } - bFound = true; - - } - // if style is not there, treat like no condition - } - - if(aData.pColorScale) - { - pInfo->pColorScale.reset(aData.pColorScale); - bFound = true; - } - - if(aData.pDataBar) - { - pInfo->pDataBar.reset(aData.pDataBar); - bFound = true; - } - - if(aData.pIconSet) - { - pInfo->pIconSet.reset(aData.pIconSet); - bFound = true; - } - } + bAnyCondition |= handleConditionalFormat(pCondFormList, rCondFormats, pInfo, pStlPool, ScAddress(nX, nCurRow, nTab), + bHidden, bHideFormula, bTabProtect); } if (bHidden || (bFormulaMode && bHideFormula && pInfo->maCell.meType == CELLTYPE_FORMULA)) -- cgit