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

Eike Rathke erack at redhat.com
Fri Dec 8 20:36:36 UTC 2017


 sc/source/ui/view/formatsh.cxx |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 0c003b9acf14b426ae7c4193ca24718211294e3f
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Dec 8 21:33:49 2017 +0100

    Avoid iterating over selected cells' attribute ranges
    
    Change-Id: Ieb233f6e952dfea0461976c3a7ea9df862f72969

diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 713f2938b827..cac33f075b87 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -2510,11 +2510,17 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
 {
     ScTabViewShell* pTabViewShell   = GetViewData()->GetViewShell();
     ScDocument* pDoc                = pViewData->GetDocument();
-    short nType                     = GetCurrentNumberFormatType();
     const SfxItemSet& rAttrSet      = pTabViewShell->GetSelectionPattern()->GetItemSet();
     const SfxItemState eItemState   = rAttrSet.GetItemState( ATTR_VALUE_FORMAT );
     sal_uInt32 nNumberFormat        = rAttrSet.Get(ATTR_VALUE_FORMAT).GetValue();
     SvNumberFormatter* pFormatter   = pDoc->GetFormatTable();
+                                      // If item state is default or set it
+                                      // indicates one number format so we
+                                      // don't have to iterate over all
+                                      // selected cells' attribute ranges to
+                                      // determine selected types.
+    const short nType               = (eItemState >= SfxItemState::DEFAULT ? pFormatter->GetType( nNumberFormat) :
+                                       GetCurrentNumberFormatType());
     NfIndexTableOffset nOffset      = pFormatter->GetIndexTableOffset(nNumberFormat);
 
     SfxWhichIter aIter(rSet);
commit a5d40188c6f59f3b51d1415ce1f34bf896f75c4c
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Dec 8 21:21:10 2017 +0100

    Call GetItemState() only once per WhichID loop
    
    Change-Id: Ic14015692bc934f06fb8371216ae5e3e1afe5afd

diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 5cd763ef286d..713f2938b827 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -2512,6 +2512,7 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
     ScDocument* pDoc                = pViewData->GetDocument();
     short nType                     = GetCurrentNumberFormatType();
     const SfxItemSet& rAttrSet      = pTabViewShell->GetSelectionPattern()->GetItemSet();
+    const SfxItemState eItemState   = rAttrSet.GetItemState( ATTR_VALUE_FORMAT );
     sal_uInt32 nNumberFormat        = rAttrSet.Get(ATTR_VALUE_FORMAT).GetValue();
     SvNumberFormatter* pFormatter   = pDoc->GetFormatTable();
     NfIndexTableOffset nOffset      = pFormatter->GetIndexTableOffset(nNumberFormat);
@@ -2525,7 +2526,7 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
         {
             case SID_NUMBER_THOUSANDS:
                 {
-                    bool bEnable = (SfxItemState::DONTCARE != rAttrSet.GetItemState( ATTR_VALUE_FORMAT ));
+                    bool bEnable = (SfxItemState::DONTCARE != eItemState);
                     if (bEnable)
                     {
                         bEnable = ((nType != css::util::NumberFormat::ALL) && (nType &
@@ -2552,7 +2553,7 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
             case SID_NUMBER_FORMAT:
                 // symphony version with format interpretation
                 {
-                    if(SfxItemState::DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT))
+                    if(SfxItemState::DONTCARE != eItemState)
                     {
                         bool bThousand(false);
                         bool bNegRed(false);
@@ -2596,7 +2597,7 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
             case SID_NUMBER_TYPE_FORMAT:
                 {
                     sal_Int16 aFormatCode = -1;
-                    if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SfxItemState::DEFAULT ) //Modify for more robust
+                    if ( eItemState >= SfxItemState::DEFAULT ) //Modify for more robust
                     {
                         const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
                         bool bStandard = false;


More information about the Libreoffice-commits mailing list