Apache OpenOffice (AOO) Bugzilla – Issue 3408
can't change Textfields in Header/Footer of a spreadsheet
Last modified: 2013-02-24 21:09:49 UTC
When I read the content of the header in a sheet, I get as String with "???" for the Textfields, getPresentation does not work. When I set the Textfield "FileName" I can't find properties to change the content from e.g. "file:///e:/user/work/.example.sdc" to "example.sdc"
Hi Oliver, Point 1: Don't know what you mean. Could you be so kind and describe your problem a litte more precise ? What do you mean by 'getPresentation does not work'? Point 2: If you select Edit - Header / Footer from the meu bar, select the field with the path and filename and press the button for a longer time. Now select just filename and you should get only the filename instead of the full path.
Ooops, I have to be a little more precise too. So it goes : If you select Edit - Header / Footer from the meu bar, select the field with the path and filename move the mouse pointer over Button with the folder... and press the button for a longer time. Now select just filename and you should get only the filename instead of the full path. Best regards Frank
hope this will help you 'You can use the XTextFieldsSupplier interface of the header text. ' But I tried to use getPresentation and it turned out that it's not ' possible to get the presentation that way from a calc header ' filename field (neither the field command nor the presented ' content). It is always „???“, so it seems not to be implemented yet. dim pagestylename as string Dim oPageStyle as Object Dim oLeftContentText as object dim oFields as object dim oField as object dim oFieldEnum as Object oSheet = thiscomponent.getSheets.getByIndex(0) pageStyleName = oSheet.PageStyle oPageStyle = thiscomponent.getStyleFamilies.getByName("PageStyles").getByName(pageS tyleName) 'right page header is the master for right and left pages oLeftContentText = oPageStyle.RightPageHeaderContent.getLeftText oFields = oleftContentText.getTextFields oFieldEnum = oFields.createEnumeration while oFieldEnum.hasMoreElements oField = oFieldEnum.nextElement() MsgBox oField.dbg_methods print oField.getPresentation(true), oField.getPresentation(False) wend 'Could you please file a bug in the sc project on Issuezilla for the 'getPresentation problem and an enhancement request to add the 'property 'FileFormat to FileName fields in Calc? 'Dietrich
Hi Oliver, not really. But this is because your Issue seems to be a problem with the API and not really the spreadsheet. So I changed the component. Best regards Frank
It is an API issue, but not an API definition issue. Thus somebody of the calc team has to take care for this bug.
For fields like PageNumber or SheetName, getPresentation can't return a meaningful value because the header is a property of the page style, not a single page or sheet. But for DocumentTitle and FileName I think it can be changed to return the right value. The FileName field's FileFormat property can be set when inserting a new field. For an existing field this doesn't work because of an error in the ScHeaderFieldsObj implementation.
Hi, > The FileName field's FileFormat property can be set when inserting > a new field. But how can I do this ? I am using oField = oDocument.createInstance("com.sun.star.text.TextField.FileName") oText.insertTextContent(oCursor, oField, False) to insert the Textfields ... > For an existing field this doesn't work because of an > error in the ScHeaderFieldsObj implementation. regards Oliver
Just add a line like oField.FileFormat = com.sun.star.text.FilenameDisplayFormat.FULL before the insertTextContent call. If you have further questions, please ask on the mailing list, as adding a comment to an issue resets its state to "new".
Changing the format of an inserted field is fixed with sc/source/ui/unoobj/fielduno.cxx 1.10.8.1 in the calc-01 child workspace, which will be in a future 644 developer build. The getPresentation values won't be changed because a HeaderFooterContent object isn't even tied to a specific document, it's just a container for the text content.
Reopening to reassign
Reassigning to QA for verification
Restoring "fixed" state
Field 'FileName' can be changed after insertion in workspace 'calc1' => verified. Used macro: oDoc = ThisComponent oSheet = oDoc.Sheets(0) oFamilies = oDoc.StyleFamilies oFamily = oFamilies.getByName("PageStyles") oStyle = oFamily.getByName( oSheet.PageStyle ) oObj = oStyle.RightPageHeaderContent oText = oObj.LeftText oFields = oText.TextFields oField = oFields(0) print oField.FileFormat oField.FileFormat = 0 print oField.FileFormat oStyle.RightPageHeaderContent = oObj
As mentioned on the qa dev list on March 5th I will close all resolved <wontfix/duplicate/worksforme/invalid> issues. Please see this posting for details.