summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-09-06 18:52:12 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-09-06 18:55:25 +0200
commit24712398aa28b5a612a9a2bdeecd51d3eb9535e8 (patch)
treee476f91d1a1f5c00a8b2810ea32d61111c7eef17 /sc
parent8ebc294b5bbcbfe27db3718453fbfcf129329b90 (diff)
handle protection in conditional formats correctly, fdo#51636
Change-Id: I81d7369218ae8e361f15d811952a8f690a32df96
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/attarray.cxx34
-rw-r--r--sc/source/core/data/fillinfo.cxx21
-rw-r--r--sc/source/core/data/table2.cxx3
3 files changed, 52 insertions, 6 deletions
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 6cf487fb612b..bcba4dee6bec 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -1189,7 +1189,41 @@ bool ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const
{
const ScProtectionAttr* pProtect =
(const ScProtectionAttr*) &pPattern->GetItem( ATTR_PROTECTION );
+ bool bFoundTemp = false;
if ( pProtect->GetProtection() || pProtect->GetHideCell() )
+ bFoundTemp = true;
+
+ const SfxUInt32Item* pConditional =
+ (const SfxUInt32Item*) &pPattern->GetItem( ATTR_CONDITIONAL );
+ if ( pConditional->GetValue() != 0 )
+ {
+ SCROW nRowStartCond = std::max<SCROW>( nRow1, i ? pData[i-1].nRow + 1: 0 );
+ SCROW nRowEndCond = std::min<SCROW>( nRow2, pData[i].nRow );
+ bool bFoundCond = false;
+ for(SCROW nRowCond = nRowStartCond; nRowCond <= nRowEndCond && !bFoundCond; ++nRowCond)
+ {
+ const SfxItemSet* pSet = pDocument->GetCondResult( nCol, nRowCond, nTab );
+
+ const SfxPoolItem* pItem;
+ if( pSet && pSet->GetItemState( ATTR_PROTECTION, true, &pItem ) == SFX_ITEM_SET )
+ {
+ const ScProtectionAttr* pCondProtect = static_cast<const ScProtectionAttr*>(pItem);
+ if( pCondProtect->GetProtection() || pProtect->GetHideCell() )
+ bFoundCond = true;
+ }
+ else
+ {
+ // well it is not true that we found one
+ // but existing one + cell where conditional
+ // formatting does not remove it
+ // => we have a protected cell
+ bFoundCond = true;
+ }
+ }
+ bFoundTemp = bFoundCond;
+ }
+
+ if(bFoundTemp)
bFound = true;
}
if ( nMask & HASATTR_ROTATE )
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 743aa26832c5..1ee5a51c85a6 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -533,11 +533,6 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
pThisRowInfo->bEmptyBack = false;
}
- if (bHidden || ( bFormulaMode && bHideFormula && pInfo->pCell
- && pInfo->pCell->GetCellType()
- == CELLTYPE_FORMULA ))
- pInfo->bEmptyCellText = true;
-
if ( pCondForm )
{
ScCondFormatData aData = pCondForm->GetData( pInfo->pCell,
@@ -551,6 +546,17 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
//! Style-Sets cachen !!!
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 ) == SFX_ITEM_SET )
+ {
+ const ScProtectionAttr* pProtAttr = static_cast<const ScProtectionAttr*>(pItem);
+ bHidden = pProtAttr->GetHideCell();
+ bHideFormula = pProtAttr->GetHideFormula();
+
+ }
+
}
// if style is not there, treat like no condition
}
@@ -565,6 +571,11 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
}
}
+ if (bHidden || ( bFormulaMode && bHideFormula && pInfo->pCell
+ && pInfo->pCell->GetCellType()
+ == CELLTYPE_FORMULA ))
+ pInfo->bEmptyCellText = true;
+
++nArrY;
}
else if (bRowHidden && nLastHiddenRow >= 0)
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index afb9c6b26935..48cff65944d1 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1909,7 +1909,8 @@ bool ScTable::IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
bIsEditable = false;
else if ( IsProtected() && !pDocument->IsScenario(nTab) )
{
- if((bIsEditable = !HasAttrib( nCol1, nRow1, nCol2, nRow2, HASATTR_PROTECTED )) != false)
+ bIsEditable = !HasAttrib( nCol1, nRow1, nCol2, nRow2, HASATTR_PROTECTED );
+ if(bIsEditable)
{
// If Sheet is protected and cells are not protected then
// check the active scenario protect flag if this range is