[Libreoffice-commits] core.git: sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Mar 30 04:05:00 UTC 2016


 sc/source/core/data/fillinfo.cxx |  119 +++++++++++++++++++++------------------
 1 file changed, 65 insertions(+), 54 deletions(-)

New commits:
commit b22e51d0c60f959c2db77bd3d23119b53bd87545
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Mar 30 02:41:07 2016 +0200

    extract another function from ScDocument::FillInfo
    
    Change-Id: Ief094beebbff2bce9f087853cbda6adeeafe07fc
    Reviewed-on: https://gerrit.libreoffice.org/23635
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 71d0e02..384e3ae 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<sal_uInt32> rCondFormats,
+        CellInfo* pInfo, ScStyleSheetPool* pStlPool,
+        const ScAddress& rAddr, bool& bHidden, bool& bHideFormula, bool bTabProtect)
+{
+    bool bFound = false;
+    bool bAnyCondition = false;
+    for(std::vector<sal_uInt32>::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<const ScProtectionAttr*>(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<sal_uInt32>::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<const ScProtectionAttr*>(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))


More information about the Libreoffice-commits mailing list