I want to add header footer in current open document using Openoffice plugin.
there is XHeaderFooter class but I am not getting how it will work.
please help me out ..

Code: Select all
import com.sun.star.beans.PropertyVetoException;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.style.XStyle;
import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.uno.RuntimeException;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
public static void snippet(XComponentContext xComponentContext, Object oInitialTarget)
{
try
{
XStyleFamiliesSupplier xStyleFamiliesSupplier = UnoRuntime.queryInterface(
XStyleFamiliesSupplier.class, oInitialTarget);
XNameAccess xNameAccess = xStyleFamiliesSupplier.getStyleFamilies();
XNameContainer xNameContainer = UnoRuntime.queryInterface(
XNameContainer.class, xNameAccess.getByName("PageStyles"));
XNameAccess xNameAccess2 = UnoRuntime.queryInterface(
XNameAccess.class, xNameContainer);
XStyle xStyle = UnoRuntime.queryInterface(
XStyle.class, xNameAccess2.getByName("Standard"));
XPropertySet xPropSet = UnoRuntime.queryInterface(
XPropertySet.class, xStyle);
xPropSet.setPropertyValue("FooterIsOn", true);
}
catch (IllegalArgumentException e1)
{
// setPropertyValue
e1.printStackTrace();
}
catch (PropertyVetoException e2)
{
// setPropertyValue
e2.printStackTrace();
}
catch (WrappedTargetException e3)
{
// getByName, setPropertyValue
e3.printStackTrace();
}
catch (UnknownPropertyException e4)
{
// setPropertyValue
e4.printStackTrace();
}
catch (NoSuchElementException e5)
{
// getByName
e5.printStackTrace();
}
catch (RuntimeException e6)
{
// getByName
e6.printStackTrace();
}
}
https://www.openoffice.org/api/docs/com ... le-ix.htmlRushna wrote:I am looking for these two packages but I don't have idea how to implement.
Please suggest:
1) "com.sun.star.text.XHeaderFooter" and
2) "com.sun.star.text.XHeaderFooterPageStyle"
Roses are Red, Violets are Blue]
Unexpected '{' on line 32
.