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

Andrzej Hunt andrzej at ahunt.org
Sun Mar 8 13:25:39 PDT 2015


 include/sfx2/infobar.hxx       |    6 ++++++
 sc/source/ui/view/viewfunc.cxx |   29 +++++++++++++++++++++++++----
 sfx2/source/dialog/infobar.cxx |    7 ++++++-
 3 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit 75dfdcb792b8fbd7f04b2a083eb96eac5d78c6c3
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Sun Mar 8 20:21:49 2015 +0000

    Allow jumping back to erroneous cell from unit error infobar.
    
    Change-Id: Iec10bf1cef24359180032847bb02728cd545ee0e

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 8d9dac7..9e6f458 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -31,6 +31,7 @@
 #include <editeng/scripttypeitem.hxx>
 #include <editeng/justifyitem.hxx>
 #include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
 #include <sfx2/infobar.hxx>
 #include <svl/zforlist.hxx>
 #include <svl/zformat.hxx>
@@ -2816,6 +2817,14 @@ void ScViewFunc::NotifyUnitErrorInFormula( const ScAddress& rAddress, ScDocument
 {
     SfxViewFrame* pViewFrame = GetViewData().GetViewShell()->GetFrame();
 
+    // We use the cell address as the infobar id to allow us to easily get back to the
+    // erronous cell - this saves us having to store the cell address elsewhere which
+    // would be much more complicated (e.g. by using a hidden UI element, or extending
+    // the infobar itself, etc.)
+    // It's possible that the user will request to edit a given cell from the infobar
+    // after having carried out further edits on the document (whereby any tab changes/additions/removals
+    // could change the number of the tab, with a name change being much more rare), hence having
+    // all information (including tab name) could be useful.
     OUString sTitle = SC_RESSTR( STR_UNITS_ERRORINCELL );
     sTitle = sTitle.replaceAll( "$1", rAddress.GetColRowString() );
     OUString sCellAddress = rAddress.Format( SCA_BITS, pDoc );
@@ -2830,11 +2839,23 @@ void ScViewFunc::NotifyUnitErrorInFormula( const ScAddress& rAddress, ScDocument
 IMPL_LINK( ScViewFunc, EditUnitErrorFormulaHandler, PushButton*, pButton )
 {
     SfxInfoBarWindow* pInfoBar = dynamic_cast< SfxInfoBarWindow* >( pButton->GetParent() );
-    const OUString sCell = pInfoBar->getId();
-    ScAddress aAddress;
-    aAddress.Parse( sCell );
+    const OUString sAddress = pInfoBar->getId();
+
+    pInfoBar->close();
+    pInfoBar = 0;
+
+    SfxStringItem aPosition( SID_CURRENTCELL, sAddress );
+    SfxBoolItem aUnmark( FN_PARAM_1, true ); // Removes existing selection if present.
+    GetViewData().GetDispatcher().Execute( SID_CURRENTCELL,
+                                           SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
+                                           &aPosition, &aUnmark, 0L );
+
+    // The above only selects the cell, hence we now start editing it to allow the user to directly
+    // type their modifications (this also has the benefit of highlighting the input cells in the
+    // UI making it a bit easier to see where the data is coming from).
+    ScModule* pScMod = SC_MOD();
+    pScMod->SetInputMode( SC_INPUT_TABLE );
 
-    (void) aAddress; // TODO: implement
     return 0;
 }
 
commit ed3ed9676990f0f3937eea7686a7877bd6d0cff6
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Sun Mar 8 20:19:47 2015 +0000

    Add close() to SfxInfoBarWindow.
    
    We may need to be able to close the infobar programatically
    (whereas currently it's only possible to close the infobar by pressing
     the close button), hence the need for a close method.
    
    This is needed for cases where the infobar may contain a button linked
    to an action that resolves the issue that triggered the infobar, meaning
    the infobar can be closed while that action is being carried out.
    
    Change-Id: If68f19d1ee2b2ac493d31d03393608a1f1ed6cc8

diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 0a15d33..9c20a6d 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -64,6 +64,12 @@ class SFX2_DLLPUBLIC SfxInfoBarWindow : public vcl::Window
          */
         void addButton(PushButton* pButton);
 
+        /**
+         * Close the Infobar.
+         * This ensures that the bar is correctly removed from it's container window.
+         * The Infobar cannot be accessed or used anymore after calling close().
+         */
+        void close();
     private:
         DECL_LINK( CloseHandler, void* );
 };
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index 30fda30..07e3257 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -218,9 +218,14 @@ void SfxInfoBarWindow::Resize()
     m_pMessage->SetPosSizePixel(aMessagePosition, aMessageSize);
 }
 
-IMPL_LINK_NOARG(SfxInfoBarWindow, CloseHandler)
+void SfxInfoBarWindow::close()
 {
     static_cast<SfxInfoBarContainerWindow*>(GetParent())->removeInfoBar(this);
+}
+
+IMPL_LINK_NOARG(SfxInfoBarWindow, CloseHandler)
+{
+    close();
     return 0;
 }
 


More information about the Libreoffice-commits mailing list