incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Brinzing <Oliver.Brinz...@gmx.de>
Subject Re: Is this a UNO API bug?
Date Tue, 21 Aug 2012 07:47:36 GMT
> The strange thing is this API can works fine for doc sample file.

the following code works for me with a new doc, output is: Hello 1 World!!!

public class TextfieldProblem {
	public void setTextfield(XComponent component) {
		XMultiServiceFactory serviceFactory = UnoRuntime.queryInterface(
				XMultiServiceFactory.class, component);
		XTextField pageNumberFiled = null;
		try {
			pageNumberFiled = UnoRuntime
					.queryInterface(
							XTextField.class,
							serviceFactory
									.createInstance("com.sun.star.text.textfield.PageNumber"));
			XPropertySet props = UnoRuntime.queryInterface(XPropertySet.class,
					pageNumberFiled);
			props.setPropertyValue("NumberingType",
					com.sun.star.style.NumberingType.ARABIC);
			props.setPropertyValue("SubType",
					com.sun.star.text.PageNumberType.CURRENT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		XTextDocument document = UnoRuntime.queryInterface(XTextDocument.class,
				component);
		try {
			document.getText().insertString(document.getText().getStart(),
					"Hello ", true);
			document.getText().insertTextContent(document.getText().getEnd(),
					pageNumberFiled, true);
			document.getText().insertString(document.getText().getEnd(),
					" World!!!", true);
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		}
		getTextfield(document);
	}

	public void getTextfield(XComponent xComponent) {
		XTextDocument document = UnoRuntime.queryInterface(XTextDocument.class,
				xComponent);
		String documentString = document.getText().getString();
		System.out.println(documentString);
	}
}



Regards

Oliver
-- 

GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45


Mime
View raw message