You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openoffice.apache.org by bu...@apache.org on 2012/08/21 03:56:08 UTC
[Bug 120625] New: [UNO API]can't get the text of "TextField
PageNumber" by XTextDocument.getText()
https://issues.apache.org/ooo/show_bug.cgi?id=120625
Priority: P2
Bug ID: 120625
Assignee: ooo-issues@incubator.apache.org
Summary: [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Severity: normal
Issue Type: DEFECT
Classification: Code
OS: All
Reporter: zongdj001@gmail.com
Hardware: All
Status: UNCONFIRMED
Version: AOO 3.4.0
Component: code
Product: api
Build:
AOO350m1(Build:9610)
Steps:
Using UNO API do below operation.
1.Launch a odt document,
2.Create a page number field and insert into this docment
3.Get the document text
But in the step3, page number is not contained in the get text. But if I
launch a doc document, I can get the page number in step 3. Below is code
pieces.
XMultiServiceFactory sevriceFactory = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
XTextField pageNumberFiled =
(XTextField)UnoRuntime.queryInterface(XTextField.class,
sevriceFactory.createInstance("com.sun.star.text.textfield.PageNumber"));
XPropertySet props =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, pageNumberFiled);
props.setPropertyValue("NumberingType", 4);//Set page number display as
Arabic
XTextCursor xTextCursor = document.getText().createTextCursor();
xTextCursor.gotoEnd(false);
document.getText().insertTextContent(document.getText().getEnd(),
pageNumberFiled, true);
String documentString = document.getText().getString();
System.out.println(documentString);.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
--- Comment #6 from Ariel Constenla-Haile <ar...@apache.org> ---
(In reply to comment #2)
> I have 3 pages in my sample. The strange thing is if I use a doc sample
> there is not problem. So I think it's a bug of uno API.
I test with any number of pages, and it works as expected. See the test macro
in attachment 79038
The document text string is written in a new text document, in this new
document you should find the page fields text representation ("1", "2", "3",
"4", "5").
Can you attach the code you are using?
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
brinzing <ol...@gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |oliver.brinzing@gmx.de
--- Comment #4 from brinzing <ol...@gmx.de> ---
.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
--- Comment #9 from brinzing <ol...@gmx.de> ---
Created attachment 79070
--> https://issues.apache.org/ooo/attachment.cgi?id=79070&action=edit
Textfield Demo
attached demo "TextfieldProblem.java" gives me
Page # 1 from 3
Page # 2 from 3
Page # 3 from 3
with aoo3.4.1rc2 as long as i do not use the "refreshTextFields()" method or a
Thread.sleep().
with refreshTextfield() output is like:
Page # 3 from 4
Page # 2 from 4
Page # 3 from 4
strange, isn't it?
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
--- Comment #8 from zong dong jun <zo...@gmail.com> ---
Java Code as below. I have found the reason of this problem, if I add a sleep
after inert page number field, I can get the page number value.
public void createPageNumber(XComponent component) {
XMultiServiceFactory sevriceFactory = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, component);
XTextField pageNumberFiled;
try {
pageNumberFiled =
(XTextField)UnoRuntime.queryInterface(XTextField.class,
sevriceFactory.createInstance("com.sun.star.text.textfield.PageNumber"));
XPropertySet props =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, pageNumberFiled);
props.setPropertyValue("NumberingType", NumberingType.ARABIC);//Set
page number display as Arabic
props.setPropertyValue("SubType", PageNumberType.CURRENT);
document.getText().insertTextContent(document.getText().getEnd(),
pageNumberFiled, true);
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
System.out.println(document.getText().getString());
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace();
}
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
--- Comment #3 from zong dong jun <zo...@gmail.com> ---
For only I page, it works well, if page is greater than 2, it has problem.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
--- Comment #2 from zong dong jun <zo...@gmail.com> ---
I have 3 pages in my sample. The strange thing is if I use a doc sample there
is not problem. So I think it's a bug of uno API.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
zong dong jun <zo...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |automation_bug
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
--- Comment #5 from Ariel Constenla-Haile <ar...@apache.org> ---
Created attachment 79038
--> https://issues.apache.org/ooo/attachment.cgi?id=79038&action=edit
Text Document with 5 pages and a test macro
The macro inserts a page text field in every page.
The inserts the document text string in a new blank document.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
--- Comment #7 from zong dong jun <zo...@gmail.com> ---
Created attachment 79042
--> https://issues.apache.org/ooo/attachment.cgi?id=79042&action=edit
test sample
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 120625] [UNO API]can't get the text of "TextField PageNumber"
by XTextDocument.getText()
Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=120625
Ariel Constenla-Haile <ar...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |arielch@apache.org
--- Comment #1 from Ariel Constenla-Haile <ar...@apache.org> ---
(In reply to comment #0)
> Build:
> AOO350m1(Build:9610)
>
> Steps:
> Using UNO API do below operation.
> 1.Launch a odt document,
> 2.Create a page number field and insert into this docment
> 3.Get the document text
>
> But in the step3, page number is not contained in the get text. But if I
> launch a doc document, I can get the page number in step 3. Below is code
> pieces.
>
> XMultiServiceFactory sevriceFactory = (XMultiServiceFactory)
> UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
> XTextField pageNumberFiled =
> (XTextField)UnoRuntime.queryInterface(XTextField.class,
> sevriceFactory.createInstance("com.sun.star.text.textfield.PageNumber"));
>
> XPropertySet props =
> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, pageNumberFiled);
> props.setPropertyValue("NumberingType", 4);//Set page number display
> as Arabic
>
> XTextCursor xTextCursor = document.getText().createTextCursor();
> xTextCursor.gotoEnd(false);
>
> document.getText().insertTextContent(document.getText().getEnd(),
> pageNumberFiled, true);
>
>
> String documentString = document.getText().getString();
> System.out.println(documentString);.
You might be missing to set the property SubType to
com.sun.star.text.PageNumberType.CURRENT
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/textfield/PageNumber.html#SubType
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/PageNumberType.html#CURRENT
If you only have one page, and it default to
com.sun.star.text.PageNumberType.PREV, the field will always be empty.
Sample AOO Basic code:
Sub Main
Dim oDoc as Object
oDoc = ThisComponent
Dim oField as Object
oField = oDoc.createInstance("com.sun.star.text.textfield.PageNumber")
oField.setPropertyValue("SubType",
com.sun.star.text.PageNumberType.CURRENT)
oField.setPropertyValue("NumberingType",
com.sun.star.style.NumberingType.ARABIC)
Dim oText as Object
oText = oDoc.getText()
oText.insertTextContent(oText.getEnd(), oField, True)
oDoc.getTextFields().refresh()
Dim sText as String
sText = oText.getString()
End Sub
--
You are receiving this mail because:
You are the assignee for the bug.