Bug 120697 - Calc: Drop-down on 'Sum' button
Summary: Calc: Drop-down on 'Sum' button
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Gagandeep Singh
URL:
Whiteboard: target:6.3.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks: Calc-UX Calc-Formula-Bar
  Show dependency treegraph
 
Reported: 2018-10-19 07:42 UTC by Michael Meeks
Modified: 2019-04-21 17:31 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2018-10-19 07:42:55 UTC
The calc formula toolbar bar has a 'Sigma' button on it - this inserts a sum - which is all well and good, however - it would be nice to have a drop-down with a selection of other formulae to insert in there: SUM, AVERAGE, COUNT, etc. - similar to the selection available in the status bar for selections.

The code that inserts this item into a toolbar is here:

sc/source/ui/app/inputwin.cxx-    InsertItem      (SID_INPUT_SUM,      Image(BitmapEx(RID_BMP_INPUT_SUM)), ToolBoxItemBits::NONE, 3);

We could insert a more complex toolbar item containing a drop-down instead.
Comment 1 Michael Meeks 2018-10-19 07:52:47 UTC
Also a good idea to read the:

$ git grep -5 ToolBoxItemBits::DROPDOWN # output

and also checkout vcl/source/window/toolbox2.cxx to see how this can be populated.
Comment 2 Sumit Chauhan 2018-12-20 14:58:09 UTC
(In reply to Michael Meeks from comment #1)


(In reply to Michael Meeks from comment #0)
> The calc formula toolbar bar has a 'Sigma' button on it - this inserts a sum
> - which is all well and good, however - it would be nice to have a drop-down
> with a selection of other formulae to insert in there: SUM, AVERAGE, COUNT,
> etc. - similar to the selection available in the status bar for selections.

Is it selection available in sidebar bar ?

I have 2 mockups one is the currency dropdown menu (https://drive.google.com/file/d/1y9pUVYLlQlDGcJE09oZZYwo-hsIYN5Tt/view?usp=sharing ) and other is conditional formatting dropdown menu ( https://drive.google.com/open?id=1OEk03NWWVTlRJoyJcSE3_9_Ao896jO7t ).

We can use any of them depending on the number of functions to be added in the drop-down menu.

Would you please let me know how you want the drop-down menu to be ?
Comment 3 ranjan.purbey 2018-12-20 18:39:54 UTC
I guess Michael wants it to be similar to Microsoft Excel's AutoSum feature, and that in my opinion will be a nice and handy tool to have. I can start working on it.
Comment 4 Michael Meeks 2018-12-20 20:37:33 UTC
Sure - so I think people get the idea generally - I hoped it was fairly clear from the description ;-) The key is digging another drop-down toolbar button out of the code to see how it is done I guess.
Comment 5 Sumit Chauhan 2018-12-21 06:59:05 UTC
(In reply to ranjan.purbey from comment #3)
> I guess Michael wants it to be similar to Microsoft Excel's AutoSum feature,
> and that in my opinion will be a nice and handy tool to have. I can start
> working on it.


I was working on this issue but if you have already started, Here are my findings and code pointers.  

toolBoxItemBits::DROPDOWN  - vcl/source/window/toolbox.cxx 
                           - include/vcl/toolbox.hxx

Related forumla and sigma button files 
                       : sc/source/ui/view/tabvwshc.cxx  line :736
                       : sc/source/ui/view/viewfunc.cxx  line :673
                       : sc/source/ui/app/inputwin.cxx   line :372

Also , similar patch https://gerrit.libreoffice.org/#/c/22958/ .

Please let me know @ranjan.purbey.
Comment 6 Michael Meeks 2018-12-21 10:25:32 UTC
Hi Sumit - nice work systematically building notes on code pointers! =) that's the way to solve ~any tough problem; good stuff.
Comment 7 Sumit Chauhan 2018-12-21 11:32:28 UTC
Hey mmeeks , can you assign this bug to me. So ,that no two people are working on the same bug.
Comment 8 Xisco Faulí 2018-12-21 11:36:02 UTC
(In reply to Sumit Chauhan from comment #7)
> Hey mmeeks , can you assign this bug to me. So ,that no two people are
> working on the same bug.

Done, you have rights to do it yourself as well!
Comment 9 Xisco Faulí 2019-01-21 03:38:13 UTC Comment hidden (obsolete)
Comment 10 Sumit Chauhan 2019-01-21 11:03:15 UTC
(In reply to Xisco Faulí from comment #9)
> A polite ping, still working on this bug?

Yes , I am working but facing difficulty with UI. I will try to finish it as soon as possible.
Comment 11 Michael Meeks 2019-01-22 10:28:06 UTC
Hi Sumit - thanks for persisting with this one =) the patch in:
    https://gerrit.libreoffice.org/66701

Seems unlikely to work to me. The InputWindow in calc doesn't appear to be  handled by the framework it seems (the framework code handles all this XML / config item stuff).

Instead it would be better to focus on adding the drop-down items to the toolbar item around the line that I identified. This requires reading the toolbox headers and un-winding how the API works in this regard I think.

Possibly it means inserting a control into the toolbar that has the drop-down; may be best to try re-using the SfxCurrencyToolboxControl in this location initially.

Otherwise - what Eike said =)

I'd love to see more code reading notes and/or bits of test code you've tried for inserting custom items into the toolbar - and any success you've had there.

Thanks !
Comment 12 Tor Lillqvist 2019-03-02 08:24:19 UTC
Sumit, are you still working on this bug? There is another GSoC hopeful that wants to work on it.
Comment 13 Sumit Chauhan 2019-03-03 21:31:00 UTC
(In reply to Tor Lillqvist from comment #12)
> Sumit, are you still working on this bug? There is another GSoC hopeful that
> wants to work on it.

The formula bar is not build using glade or .ui file but using some predefined functions.This makes it much more difficult to complete. 
Currently , I am not working on this bug. Someone else can do it.
Comment 14 Gagandeep Singh 2019-03-29 17:08:56 UTC
Hi, I have been looking at the files for sometime now and I found one more patch that has been used to modify the code in some way

https://gerrit.libreoffice.org/#/c/40557/

As I am new to libreoffice, I don't know why the code modification was required other than to fix wayland issue.

So, can anyone confirm that I should implement the drop down using the current currency drop down code (changed by the above mentioned patch) or the one that was merged with the first patch:

https://gerrit.libreoffice.org/#/c/22958/

Thanks in advance
Comment 15 Gagandeep Singh 2019-03-29 20:08:13 UTC
Hi, I think there could be a better way to handle this. There exists an implementation of formula toolbar in writer where a dropdown is avaliable for autosum button.
Comment 16 Gagandeep Singh 2019-04-11 17:04:19 UTC
Hi, I have submitted the patch at : 

https://gerrit.libreoffice.org/#/c/70058/

Please review the same

Thanks!
Comment 17 Commit Notification 2019-04-21 17:31:42 UTC
Gagandeep Singh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/0ec98930888ee9f29032d12185baefc71da8489f%5E%21

bug tdf#120697

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.