Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | can not set AnchorType of a control in calc via API | ||||||
---|---|---|---|---|---|---|---|
Product: | Base | Reporter: | Oliver Brinzing <oliver.brinzing> | ||||
Component: | code | Assignee: | AOO issues mailing list <issues> | ||||
Status: | REOPENED --- | QA Contact: | |||||
Severity: | Trivial | ||||||
Priority: | P3 | CC: | issues | ||||
Version: | OOo 3.1 | ||||||
Target Milestone: | --- | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Issue Type: | DEFECT | Latest Confirmation in: | --- | ||||
Developer Difficulty: | --- | ||||||
Attachments: |
|
Description
Oliver Brinzing
2004-09-02 20:03:57 UTC
Hi Frank, the attached macro doesn't work as expect. Is there any anchor type for spreadsheets? Bye Marc well, as the name suggests, css.text.TextContentAnchorType is a Writer feature. It seems that in Calc, shapes cannot be anchored via API at all. You could argue whether this is a bug (since our API should be complete, shouldn't it?) or a missing feature ... Anyway, assigning to nn, who's in charge for the Calc/API. Shapes in a spreadsheet have the property "Anchor" (can be set only after inserting the shape, modifies the position). Hi Niklas, > Shapes in a spreadsheet have the property "Anchor" this seems to be true, I can access the anchored cell ... > (can be set only after inserting the shape, modifies the position). I don't know how to *set* a new anchor "at cell", or how to set "at page" oControlShape.Anchor = oCell does not work, seems to be write protected ... Could you please provide an example ? best regards Oliver Hi, this issue is still valid for oo 2.0.2 rc1 ... Oliver verified in oo 3.1 - all controls are anchored AT_CELL. AT_PAGE can be done only via GUI. are there any plans to fix this issue ? Created attachment 62390 [details]
here's an example that works right now
FWIW, after insertion, using... oControlShape.setPropertyValue("Anchor", oCell) oControlShape.setPropertyValue("Anchor", oSheet) toggles from cell anchored to sheet anchored in the attached example Oliver, can you verify this works now? Without looking at Caolan's macro, I am pretty sure the issue is fixed: I used the API to change an object's anchor in Calc, when I fixed issue 99056, and it worked flawlessly :) i just tried: oDrawPage.add(oControlShape) oControlShape.setPropertyValue("Anchor", oSheet) this will toggle to sheet anchored - but also set the controls position to strange X/Y positions: for example: X/Y controls X/Y 100/100 0,1/0,1cm 1000/1000 1,0/0,1cm 2000/2000 2,0/0,19 cm 3000/3000 0,74/0,29cm using oControlShape.setPropertyValue("Anchor", oSheet.getCellByPosition(2,2)) will set the *anchor* to cell C3 - with shapes oPosition.X=0 and oPosition.Y=0 it works like expected. setPropertyValue("Anchor") before inserting the control has no effect in this case the control is anchored to cell... Oliver, I remember having had strange effects with the position, too. Well, at least unexpected, though perhaps explainable ... First, when you switch the anchor from a cell to the sheet, you need to get the shape's position first, and restore it after setting the Anchor property. This way, the control/shape stays where it was before changing the anchor. Otherwise, the position previously relative to the cell is now relative to the sheet, which makes the control jumping. Second, when you switch the anchor from the sheet to a cell, you also need to adjust the position, to prevent the control jumping. You might want to look into the impl_setSheetAnchorType_nothrow method in http://svn.services.openoffice.org/ooo/cws/dba32b/extensions/source/propctrlr/formgeometryhandler.cxx to see how I solved that. In any way, I would argue that the strange behavior of the position is another issue (if at all), since this one here is named "can not set AnchorType ...", which is not true anymore. Hi Frank, from my point of view it should be possible to set a control - anchored to the sheet - for example to an absolut X/Y position like 3cm/3cm at the moment it will added to the drawpage - first set all properties, than add to drawpage .. in writer there is a property "AnchorType": com.sun.star.text. TextContentAnchorType.AT_PAGE/AT_CELL which will do the job ... in calc i have to add the control to the drawpage first, change the "Anchor" form cell to sheet (cause cell is default) and than have to set the new position cause 3/3cm changed undefinitly to 0,74/0,29 cm - so as you mentionend - before - the control will move ...... this is a bit unfortune i agree we could open a new issue ... Oliver so this is the workaound for the moment: oPosition.X = 3000 oPosition.Y = 3000 [...] oDrawPage.add(oControlShape) oControlShape.setPropertyValue("Anchor", oSheet) oControlShape.setPosition(oPosition) Reset assigne to the default "issues@openoffice.apache.org". |