Issue 108876 - [From Symphony]Application.Range does not work well
Summary: [From Symphony]Application.Range does not work well
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: vba (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-03 06:46 UTC by lihuiibm
Modified: 2017-05-20 11:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Fix for this issue (17.44 KB, text/plain)
2010-02-03 06:47 UTC, lihuiibm
no flags Details
New patch for this issue. (15.25 KB, text/plain)
2010-04-30 12:56 UTC, lihuiibm
no flags Details
Test document for this issue (64.00 KB, text/plain)
2010-05-10 07:20 UTC, lihuiibm
no flags Details
New patch: Only fix the issue of Application.Range(...), Range.Parent issue does not fix in this patch (2.92 KB, patch)
2010-05-10 07:21 UTC, lihuiibm
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description lihuiibm 2010-02-03 06:46:24 UTC
1. Root Cause:
Currently, we did not support Application.Range(Range1, Range2), Range1 or
Range2 is not the range of current active sheet. We always consider these two
ranges are from the current active sheet. And Application.Range(...) does not
set the Parent property.
2. Resolution:
Add the codes for supporting shortcut: Application.Range(Range1, Range2), Range1
or Range2 is not the range of current active sheet. If Range1 and Range2 are not
in current active sheet, we do not use the active sheet, but use the sheet of
Range1 and Range2. If Range1 and Range2 are not in the same sheet, we throw an
exception. Return the Parent for Application.Range(...).
Comment 1 lihuiibm 2010-02-03 06:47:10 UTC
Created attachment 67556 [details]
Fix for this issue
Comment 2 noel.power 2010-02-22 20:26:00 UTC
why is there a new m_xParent  in ScVbaRange & ScVbaWorksheet? ( these are
already available in the base class ), the existing parent is also already
initialised in the constructor too :-/

ScVbaRange::ApplicationRange has the logic added to detect if Range1 && Range2
are ranges that are in different sheets then an exception is raised, isn't this
logic already present in ScVbaRange::Range ? ( see the special
application::Range logic when 'bForceUseInpuRangeTab' is set )  
  * the attached patch addes additional logic to test if the ranges are from a
different document, but... isn't this test equally valid for ScVbaRange::Range(
Range1, Range2 )? in other words should the test for whether Range1 & Range2 are
from difference worksheets be moved to ScVbaRange::Range?

what do you think?
Comment 3 lihuiibm 2010-04-30 11:21:25 UTC
>>why is there a new m_xParent  in ScVbaRange & ScVbaWorksheet? ( these are
already available in the base class ), the existing parent is also already
initialised in the constructor too :-/
From Hui Li: Because m_xParent in the base class is weak reference, some time
the parent of Range or Worksheet is created in C++ method, it is destructed when
step out of the method, because m_xParent is weak reference. So
Application.Range(...).Parent may be null.

>>ScVbaRange::ApplicationRange has the logic added to detect if Range1 && Range2
are ranges that are in different sheets then an exception is raised, isn't this
logic already present in ScVbaRange::Range ? ( see the special
application::Range logic when 'bForceUseInpuRangeTab' is set )  
  * the attached patch addes additional logic to test if the ranges are from a
different document, but... isn't this test equally valid for ScVbaRange::Range(
Range1, Range2 )? in other words should the test for whether Range1 & Range2 are
from difference worksheets be moved to ScVbaRange::Range?
From Hui Li: Yes, can detect if Range1 and Range2 are ranges that are in
different documents or sheets. Please see my new patch
Comment 4 lihuiibm 2010-04-30 12:56:21 UTC
Created attachment 69194 [details]
New patch for this issue.
Comment 5 noel.power 2010-05-04 10:49:03 UTC
>Because m_xParent in the base class is weak reference, some time
>the parent of Range or Worksheet is created in C++ method, it is destructed when
>step out of the method, because m_xParent is weak reference. So
>Application.Range(...).Parent may be null
Right, this is a separate problem, I suggest you open a separate issue for it.
Also. I'm sorry but I don't like the solution for getting the parent, 
 1. duplicating the parent member in the Range and Worksheet classes is very
confusing.
 2. many unnecessary worksheet objects will be created
 3. this will impact performance badly

we should either
a) make mxParent in InheritedHelperInterfaceImpl be a hard reference or
b) make sure the parent that is passed has a long life

a) is imo not a good idea, I think it will possibly introduce many cyclic
reference issues
b) is a much better idea, we should probably access Workbook/Worksheet objects
directly from basic ( where they already have the correct lifecycle ) - when
issue #111144 has a proper solution then this should hopefully be even easier,
in the mean time we can I think already access these from basic

so, in summary I think the best thing to do is to remove the getRangeParent bits
from this patch and create a new issue for that part.

The remaining part of the patch ( to do with Application.Range( Range1, Range2 )
etc. looks good to me
Comment 6 lihuiibm 2010-05-10 07:20:22 UTC
Created attachment 69389 [details]
Test document for this issue
Comment 7 lihuiibm 2010-05-10 07:21:28 UTC
Created attachment 69390 [details]
New patch: Only fix the issue of Application.Range(...), Range.Parent issue does not fix in this patch
Comment 8 lihuiibm 2010-05-10 07:26:23 UTC
I post new patch(patch_alt_removeparent.diff), only fix the issue of
Application.Range(...), do not fix the problem of Range.Parent. I created a new
issue for the problem of Range.Parent:
http://qa.openoffice.org/issues/show_bug.cgi?id=111505
Comment 9 Marcus 2017-05-20 11:29:24 UTC
Reset assigne to the default "issues@openoffice.apache.org".