 | OO-Snippets: Add and remove header and footerCommons| Keywords | add, remove, header, footer |
|---|
| Language | ooRexx |
|---|
| Application | Writer |
|---|
| Authors | Josef Frysak (initial)
|
|---|
| Supported Versions | 2.4.1 |
|---|
| Supported OS | All |
|---|
| Question | How to toggle header and footer on and off?
|
|---|
| Answer | First get the style name of the current Page. Next get the StyleFamilies list of the document via the StyleFamiliesSupplier and retrieve the page style with the name recieved before. Now get the "XPropertySet" interface and retrieve the status of the header and footer. If they are true then set their properties to false, otherwhise set them to true. For further details see http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2008/200809_Frysak/200809_Frysak_Automating_OOo_ooRexx_Nutshells.pdf. |
|---|
x_ScriptContext = uno.getScriptContext()
if (x_ScriptContext <> .nil) then
do
x_ComponentContext = x_ScriptContext~getComponentContext
x_Desktop = x_ScriptContext~getDesktop
x_Document = x_ScriptContext~getDocument
end
else
do
x_ComponentContext = UNO.connect()
service = "com.sun.star.frame.Desktop"
s_Desktop = x_ComponentContext~getServiceManager~XMultiServiceFactory~createInstance(service)
x_Desktop = s_Desktop~XDesktop
x_Document = x_Desktop~getCurrentComponent()
end
x_TextDocument = x_Document~XTextDocument
x_Text = x_TextDocument~getText
s_CurrentController = x_TextDocument~getCurrentController()
x_TextViewCursorSupplier = s_CurrentController~XTextViewCursorSupplier
x_CurrentCursor = x_TextViewCursorSupplier~getViewCursor()
cursorproperties = x_CurrentCursor~XPropertySet
pagestylename = cursorproperties~getPropertyValue("PageStyleName")
x_StyleFamiliesSupplier = x_Document~XStyleFamiliesSupplier
x_StyleFamilies = x_StyleFamiliesSupplier~getStyleFamilies()
s_StyleFamily = x_StyleFamilies~getByName("PageStyles")
x_NameAccess = s_StyleFamily~XNameAccess
s_PageProperties = x_NameAccess~getByName(pagestylename)
pageproperties = s_PageProperties~XPropertySet
oldheader = pageproperties~getPropertyValue("HeaderIsOn")
oldfooter = pageproperties~getPropertyValue("FooterIsOn")
if oldheader then pageproperties~setPropertyValue("HeaderIsOn", .bsf~new("java.lang.Boolean", 0))
else pageproperties~setPropertyValue("HeaderIsOn", 1)
if oldfooter then pageproperties~setPropertyValue("FooterIsOn", .bsf~new("java.lang.Boolean", 0))
else pageproperties~setPropertyValue("FooterIsOn", 1)
::requires UNO.CLS
|
Changelog| Date | User | Modification |
|---|
| 2008-10-14 | 1 | Initial version |
|