[Libreoffice-commits] core.git: Branch 'feature/unitver' - 5 commits - sc/source sfx2/source

Andrzej Hunt andrzej at ahunt.org
Sun Mar 8 14:47:37 PDT 2015


 sc/source/core/units/unitsimpl.cxx |    2 +-
 sc/source/ui/view/viewfunc.cxx     |    9 +++++++++
 sfx2/source/view/viewfrm.cxx       |    7 +++++--
 3 files changed, 15 insertions(+), 3 deletions(-)

New commits:
commit d2a249645221ae8e9c9d6c79fabf853e6b736d6f
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Sun Mar 8 21:41:37 2015 +0000

    The top row can contain unit headers too.
    
    Ooops, clearly more unit test needed.
    
    Change-Id: I0fe83a99105f0bf3a470e1b4dc89247924f8201a

diff --git a/sc/source/core/units/unitsimpl.cxx b/sc/source/core/units/unitsimpl.cxx
index 4a055d4..1c5f1bf 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -314,7 +314,7 @@ UtUnit UnitsImpl::getUnitForRef(FormulaToken* pToken, const ScAddress& rFormulaA
     // Scan UPwards from the current cell to find a header. This is since we could potentially
     // have two different sets of data sharing a column, hence finding the closest header is necessary.
     ScAddress aAddress = aInputAddress;
-    while (aAddress.Row() > 1) {
+    while (aAddress.Row() > 0) {
         aAddress.IncRow(-1);
 
         // We specifically test for string cells as intervening data cells could have
commit 2432a55d9007b729119b108713854c66f91d13af
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Sun Mar 8 21:17:34 2015 +0000

    Revert "Don't remove infobar on editing - fixing the cell does it for us."
    
    This isn't actually as great as I thought it would be - it's kinda ugly for the infobar
    to remain while we're editing. The issue remains that if the user cancels editing, the infobar
    is gone but the cell hasn't been fixed. Otoh the user is actively shooting themselves in the foot
    by doing that so do we really need to fix it?
    
    This reverts commit d1af32aeb95530979e3944cc6c43060264d6db88.
    
    Change-Id: Ib952fb751316e693a5d9144eddc8cd636960370f

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 488b6c4..3073fe6 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2847,8 +2847,15 @@ void ScViewFunc::NotifyUnitErrorInFormula( const ScAddress& rAddress, ScDocument
 
 IMPL_LINK( ScViewFunc, EditUnitErrorFormulaHandler, PushButton*, pButton )
 {
-    SfxInfoBarWindow* pInfoBar = dynamic_cast< SfxInfoBarWindow* >( pButton->GetParent() );
-    const OUString sAddress = pInfoBar->getId();
+
+    OUString sAddress;
+    {
+        // keep pInfoBar within this scope only as we'll be deleting it just below (using RemoveInfoBar)
+        SfxInfoBarWindow* pInfoBar = dynamic_cast< SfxInfoBarWindow* >( pButton->GetParent() );
+        sAddress = pInfoBar->getId();
+    }
+    SfxViewFrame* pViewFrame = GetViewData().GetViewShell()->GetFrame();
+    pViewFrame->RemoveInfoBar( sAddress );
 
     SfxStringItem aPosition( SID_CURRENTCELL, sAddress );
     SfxBoolItem aUnmark( FN_PARAM_1, true ); // Removes existing selection if present.
commit d1af32aeb95530979e3944cc6c43060264d6db88
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Sun Mar 8 20:58:32 2015 +0000

    Don't remove infobar on editing - fixing the cell does it for us.
    
    Change-Id: Ibb8dff342b779bec7b5ef6fa68a5f6cb9f220b0f

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 3073fe6..488b6c4 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2847,15 +2847,8 @@ void ScViewFunc::NotifyUnitErrorInFormula( const ScAddress& rAddress, ScDocument
 
 IMPL_LINK( ScViewFunc, EditUnitErrorFormulaHandler, PushButton*, pButton )
 {
-
-    OUString sAddress;
-    {
-        // keep pInfoBar within this scope only as we'll be deleting it just below (using RemoveInfoBar)
-        SfxInfoBarWindow* pInfoBar = dynamic_cast< SfxInfoBarWindow* >( pButton->GetParent() );
-        sAddress = pInfoBar->getId();
-    }
-    SfxViewFrame* pViewFrame = GetViewData().GetViewShell()->GetFrame();
-    pViewFrame->RemoveInfoBar( sAddress );
+    SfxInfoBarWindow* pInfoBar = dynamic_cast< SfxInfoBarWindow* >( pButton->GetParent() );
+    const OUString sAddress = pInfoBar->getId();
 
     SfxStringItem aPosition( SID_CURRENTCELL, sAddress );
     SfxBoolItem aUnmark( FN_PARAM_1, true ); // Removes existing selection if present.
commit 235ca435c65b62beeb0bf845a4ffc79ce461b873
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Sun Mar 8 20:53:17 2015 +0000

    Hide infobar when cell fixed directly.
    
    Change-Id: I2580f5def597121027d92c96cdfe1b58d3862d3f

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index c0eca60..3073fe6 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -471,6 +471,15 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
             if ( pUnits->verifyFormula( pArr, aPos, pDoc ) )
             {
                 SAL_INFO( "sc.units", "verification successful" );
+
+                // If we have fixed a previously erronous cell we need to make sure we remove
+                // the associate warning infobar. It's simplest to simply call RemoveInfoBar
+                // with the hypothetical ID, and RemoveInfoBar deals with the remaning details.
+                // (The cell address is used as it's infobar id, see NotifyUnitErrorInFormula
+                // for further details.)
+                SfxViewFrame* pViewFrame = GetViewData().GetViewShell()->GetFrame();
+                OUString sAddress = aPos.Format( SCA_BITS, pDoc );
+                pViewFrame->RemoveInfoBar( sAddress );
             }
             else
             {
commit 0a385c42046f0c69b69dcc9f1cf7d170d55a1348
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Sun Mar 8 20:52:15 2015 +0000

    Only remove infobar if it exists.
    
    It's possible to call RemoveInfoBar with an invalid/inexistant ID,
    in which case pInfoBar is NULL. There's no point then actually trying
    to remove this inexistant infobar.
    
    However, calling removeInfoBar on NULL doesn't actually cause any harm
    (in it's current implementation) as it iterates over the infobar list
    to find the relevant infobar for deletion - however it causes unnecessary
    iterations over the whole list and potential window updates.
    
    Change-Id: I64d68e95387d2743cdbec31a77d6296cd0578024

diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 48aae16..c0e8f78 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3382,8 +3382,11 @@ void SfxViewFrame::RemoveInfoBar( const OUString& sId )
     {
         SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
         SfxInfoBarWindow* pInfoBar = pInfoBarContainer->getInfoBar(sId);
-        pInfoBarContainer->removeInfoBar(pInfoBar);
-        ShowChildWindow(nId);
+        if ( pInfoBar )
+        {
+            pInfoBarContainer->removeInfoBar(pInfoBar);
+            ShowChildWindow(nId);
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list