Bug 21444

Summary: [PATCH] Macro functions
Product: POI Reporter: Paul Krause <pkrause>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P3    
Version: 2.0-pre3   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: support for NamePtg.toFormulaString (no test cases)
src/testcases/org/apache/poi/hssf/data/SquareMacro.xls is a small Excel file that defines and uses the SQUARE macro
test case
revised SquareMacro.xls
revised patch (test cases included) against HEAD
patch against REL_2_BRANCH

Description Paul Krause 2003-07-09 19:04:56 UTC
> From: Andrew C. Oliver <acoliver@apache.org>
   > Subject: Re: function table
   > Sent: 09 Jul 2003 23:08:38

IIRC, those are "reserved" or non-implemented.  We haven't yet implemented
"macro functions"...  Shouldn't be hard to implement I suppose if we just
add a lookup for the POIFS filesystem in the event it can't lookup the
function to verify its there and just use it...Otherwise we should probably
throw an exception.

Someone should put this in bugzilla as an [RFE] Macro functions if it isn't
already there.
Comment 1 Paul Krause 2003-07-16 20:56:25 UTC
Created attachment 7337 [details]
support for NamePtg.toFormulaString (no test cases)
Comment 2 Paul Krause 2003-07-16 21:02:55 UTC
Posted a patch that makes toFormulaString work for macro functions that have 
internal names.  Test cases to follow later - this patch is huge enough already.

Issues:

1. signature change
 AbstractFunctionPtg.toFormulaString(SheetReferences) is now
 AbstractFunctionPtg.toFormulaString(Workbook).

This is an incompatible change.

2. NamePtg's field_3_zero
 Ugly hack to getSize to get around this.  See email on this topic for more 
information.


Comment 3 Paul Krause 2003-07-17 18:42:24 UTC
Created attachment 7353 [details]
src/testcases/org/apache/poi/hssf/data/SquareMacro.xls is a small Excel file that defines and uses the SQUARE macro
Comment 4 Paul Krause 2003-07-17 18:47:18 UTC
Created attachment 7354 [details]
test case
Comment 5 Andy Oliver 2003-07-24 17:07:55 UTC
Whhy no unit tests? :-(

I'm marking half this patch to be applied.. . The half with unit tests ;-)
Comment 6 Paul Krause 2003-07-24 17:25:08 UTC
The unit tests are posted separatly from the patch, but they belong together.

The procedure to follow is:
1. Apply unit tests (7354) and excel file (7353).
2. Run unit tests.  Watch them fail.
3. Apply the patch (7337).  Run the unit tests again.  They should work now.
4. Commit.

That being said, I have discovered a problem with an interaction betwen macros 
and nested IFs.  Stand by for an updated patch.  I would have posted it sooner, 
but HEAD has been massively broken since July 18.  Since it doesn't look the 
HEAD is going to get fixed anytime soon, these patches will have to be checked 
most carefully.
Comment 7 Paul Krause 2003-07-24 17:26:35 UTC
Created attachment 7495 [details]
revised SquareMacro.xls
Comment 8 Andy Oliver 2003-07-24 17:39:04 UTC
you should be doing these against the REL_2_BRANCH...
Comment 9 Paul Krause 2003-07-24 18:55:31 UTC
Created attachment 7498 [details]
revised patch (test cases included) against HEAD
Comment 10 Paul Krause 2003-07-24 19:06:08 UTC
Revised patch handles nested macros and IF/macro nesting.

Andy is right that this patch needs to be made against 2.0, but my workspace 
was pointed at HEAD.  Now that it is posted. I will follow up with another 
patch against 2.0 as soon as I reconfigure my workspace.

Procedure for this patch:
1. Install 7495 as src/testcases/org/apache/poi/hssf/data/SquareMacro.xls.
2. Patch 7498 against HEAD.
3. Build, Test, and Commit.

Avik, please note that this revised patch includes a completely rewritten 
NamePtg, including an implementation of writeBytes.  NameRecord also has a lot 
of changes, including several new accessors for reading the options field.
Comment 11 Avik Sengupta 2003-07-27 19:28:30 UTC
I'll put this in after we release 2.0pre3 this week. Dont want to destabilise
that atm. 
Comment 12 Paul Krause 2003-07-28 23:00:38 UTC
Created attachment 7555 [details]
patch against REL_2_BRANCH
Comment 13 Paul Krause 2003-07-28 23:04:46 UTC
I finally finished reconfiguring my workspace, so here is the patch against the 
release 2 branch.  This patch is completely automatic, and all the test cases 
pass, so it should be safe to apply it as is.

Procedure for this patch:
1. Install 7495 as src/testcases/org/apache/poi/hssf/data/SquareMacro.xls.
2. Patch 7555 against REL_2_BRANCH.
3. Build, Test, and Commit.

Comment 14 Avik Sengupta 2003-07-31 18:34:29 UTC
I think this is great.. however, since this is a very large patch, will apply
them after sleeping over it for a day. I think this solves a lot of our issues..
so thanks.
Comment 15 Avik Sengupta 2003-08-23 19:50:09 UTC
Checked in to REL_2_BRANCH and HEAD. Thanks a lot Paul. Please cross check.
Maybe we should have a few more testcases for the toFormulaString
implementations for named ranges and 3DAreas.