Kaydet (Commit) 07249785 authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) Stephan Bergmann

SDK examples : add Python section and ToolPanel python example

correct minor css rendering too
üst 1ed632b4
......@@ -876,7 +876,8 @@ hr {
border-color: #CCCCCC;
border-spacing: 0;
border-collapse: collapse;
padding: 4; }
padding: 4;
color: #000000; }
.cell20 { width: 20%;
border-width: 2px;
......@@ -884,7 +885,8 @@ hr {
border-color: #CCCCCC;
border-spacing: 0;
border-collapse: collapse;
padding: 4; }
padding: 4;
color: #000000; }
.cell80 { width: 80%;
border-width: 2px;
......@@ -892,7 +894,8 @@ hr {
border-color: #CCCCCC;
border-spacing: 0;
border-collapse: collapse;
padding: 4; }
padding: 4;
color: #000000; }
.cell85 { width: 85%;
border-width: 2px;
......@@ -900,7 +903,8 @@ hr {
border-color: #CCCCCC;
border-spacing: 0;
border-collapse: collapse;
padding: 4; }
padding: 4;
color: #000000;}
.nothing1 { width: 20;
height: 1; }
......@@ -941,8 +945,8 @@ hr {
font-weight: bold; }
.thead { font-weight: bold;
background-image:url(../docs/images/bg_table.png);
backgorund-position: middle; }
background-color:#18a303;
background-position: middle; }
.navigate { border: 0; }
......
<html>
<head>
<title>OpenOffice.org %PRODUCT_RELEASE% SDK - Examples</title>
<title>LibreOffice %PRODUCT_RELEASE% SDK - Examples</title>
<link rel="stylesheet" type="text/css" href="../docs/sdk_styles.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="author" content="J&uuml;rgen Schmidt">
......@@ -10,7 +10,7 @@
<body class="sdkbody"><a name="examples"/>
<table class="table1" cellpadding=0>
<tr style="background-image:url(../docs/images/sdk_head-2.png); backgorund-position: bottom; ">
<td class="background" colspan="3" align="left"><img src="../docs/images/sdk_head-1.png" width="800" height="120" usemap="#Map" border="0"></td>
<td class="background" colspan="3" align="left"><img src="../docs/images/sdk_head-1.png" height="120" usemap="#Map" border="0"></td>
</tr>
<tr>
<td colspan="3"><img class="nothing10" src="../docs/images/nada.gif"></td>
......@@ -75,6 +75,11 @@
<td class="content75">Set of simple and more complex examples which
shows the use of the API from Java.</td>
</tr>
<tr valign="top">
<td class="content3"><img src="../docs/images/arrow-1.gif"></td>
<td><a href="#python_examples" title="link to the Python examples section">Python examples</a></td>
<td class="content75">Small set of examples which shows the use of the API from Python.</td>
</tr>
<tr valign="top">
<td class="content3"><img src="../docs/images/arrow-1.gif"></td>
<td><a href="#Cpp_examples" title="link to the C++ examples section">C++ examples</a></td>
......@@ -364,6 +369,60 @@
<tr>
<td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td>
</tr>
<tr>
<td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
<td>
<table class="table2">
<tr>
<td>
<table class="table3">
<tr>
<td colspan="2" class="head1"><a name="python_examples">Python examples</td>
<td align="right">
<a href="#examples" title="link to the examples overview"><img class="navigate" src="../docs/images/nav_up.png"></a>
<a href="../index.html" title="link to the SDK start page"><img class="navigate" src="../docs/images/nav_home.png"></a>
</td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="table4">
<tbody>
<tr class="thead">
<td class="cell20">Example</td>
<td class="cell80">Description</td>
</tr>
<tr>
<td class="cell20"><a href="python/toolpanel/"title="link to the source directory of the ToolPanel python axample">ToolPanelPoc</a></td>
<td class="cell80">This extension illustrates how to create a ToolPanel in Calc.</td>
</tr>
<tbody>
</table>
</td>
</tr>
<tr>
<td>
<table class="table3">
<tr>
<td colspan="3">
<p>No Additional information</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
</tr>
<tr>
<td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td>
</tr>
<tr>
<td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
<td>
......
<?xml version='1.0' encoding='UTF-8'?>
<!--# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Laurent Godard <lgodard.libre@laposte.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.-->
<oor:component-data
oor:name="CalcWindowState"
oor:package="org.openoffice.Office.UI"
xmlns:install="http://openoffice.org/2004/installation"
xmlns:oor="http://openoffice.org/2001/registry"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<node oor:name="UIElements">
<node oor:name="States">
<node oor:name="private:resource/toolpanel/myToolPanelPoc" oor:op="replace">
<prop oor:name="UIName" oor:type="xs:string">
<value> ToolPanel Proof of Concept</value>
</prop>
<prop oor:name="Visible" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
</node>
</oor:component-data>
<?xml version='1.0' encoding='UTF-8'?>
<!--# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Laurent Godard <lgodard.libre@laposte.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.-->
<oor:component-data
oor:name="Factories"
oor:package="org.openoffice.Office.UI"
xmlns:oor="http://openoffice.org/2001/registry"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<node oor:name="Registered">
<node oor:name="UIElementFactories">
<node oor:name="org.libreoffice.example.sdk.CustomToolPanel" oor:op="replace">
<prop oor:name="Type">
<value>toolpanel</value>
</prop>
<prop oor:name="Name">
<value>myToolPanelPoc</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="FactoryImplementation">
<value>org.libreoffice.example.toolpanel.pocFactory</value>
</prop>
</node>
</node>
</node>
</oor:component-data>
<?xml version="1.0" encoding="UTF-8"?>
<!--# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Laurent Godard <lgodard.libre@laposte.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.-->
<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
<manifest:file-entry
manifest:media-type="application/vnd.sun.star.uno-components"
manifest:full-path="toolpanel.component"/>
<manifest:file-entry
manifest:media-type="application/vnd.sun.star.configuration-data"
manifest:full-path="CalcWindowState.xcu"/>
<manifest:file-entry
manifest:media-type="application/vnd.sun.star.configuration-data"
manifest:full-path="Factory.xcu"/>
<manifest:file-entry
manifest:full-path="toolPanelPocBasic/"
manifest:media-type="application/vnd.sun.star.basic-library"/>
</manifest:manifest>
<?xml version="1.0" encoding="UTF-8"?>
<!--# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Laurent Godard <lgodard.libre@laposte.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.-->
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink">
<version value="0.1.0"/>
<identifier value="org.libreoffice.example.toolpanel"/>
</description>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">
global theDialog
Sub dialogOnLoad(event)
theDialog = event.source
End Sub
sub buttonClick(event)
theButton = theDialog.getControl(&quot;CommandButton1&quot;)
theTextField = theDialog.getControl(&quot;TextInfo&quot;)
colors = Array(rgb(255,0,0),rgb(0,255,0),rgb(0,0,255))
rank = getSystemTicks() mod 3
theDialog.Model.BackgroundColor = colors(rank)
theTextField.text = cstr(Now) + chr(10)+&quot;Color &quot; + cstr(rank) + &quot; randomly applied&quot;
theButton.label = &quot;Click Me to change color&quot;
end sub
</script:module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="toolPanelPocBasic" library:readonly="false" library:passwordprotected="false"/>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="toolPanelPocBasic" library:readonly="false" library:passwordprotected="false">
<library:element library:name="Module1"/>
</library:library>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Laurent Godard <lgodard.libre@laposte.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.-->
<components xmlns="http://openoffice.org/2010/uno-components">
<component loader="com.sun.star.loader.Python" uri="./toolpanel.py">
<implementation name="org.libreoffice.example.toolpanel.pocFactory">
<service name="org.libreoffice.example.toolpanel.pocFactory"/>
</implementation>
</component>
</components>
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Laurent Godard <lgodard.libre@laposte.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
# inspired from core/testautomation/extensions/optional/input/extension_sources/TaskPaneComponent
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
import uno
import unohelper
from com.sun.star.ui import XUIElementFactory
from com.sun.star.ui import XUIElement
from com.sun.star.ui.UIElementType import TOOLPANEL as unoTOOLPANEL
from com.sun.star.ui import XToolPanel
implementation_name = "org.libreoffice.example.toolpanel.pocFactory" # as defined in Factory.xcu
implementation_services = ("org.libreoffice.example.toolpanel.pocFactory",)
xdlPath = "toolpanels/poc.xdl" # the path inside the oxt
extensionID = "org.libreoffice.example.toolpanel" # as defined in description.xml
########################################################################
########################################################################
class pocToolPanel( unohelper.Base, XToolPanel ):
def __init__ ( self, xPanelWindow, ctx ):
self.ctx = ctx
self.PanelWindow = xPanelWindow
self.Window = xPanelWindow
def createAccessible( self, i_parentAccessible ):
return self.PanelWindow
########################################################################
########################################################################
class pyPanel( unohelper.Base, XUIElement ):
def __init__ ( self, ctx, xFrame, xParentWindow, url ):
self.ctx = ctx
self.xParentWindow = xParentWindow
self.toolpanel = None
self.m_panelRootWindow = None
self.Frame = xFrame
self.ResourceURL = url
self.Type = unoTOOLPANEL
def getRealInterface( self ):
if not self.toolpanel:
rootWindow = self.getOrCreatePanelRootWindow()
self.toolpanel = pocToolPanel(rootWindow, self.ctx)
return self.toolpanel
def getOrCreatePanelRootWindow( self ):
pip = self.ctx.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider" )
s = pip.getPackageLocation(extensionID)
dialogUrl = s + "/" + xdlPath
provider = self.ctx.ServiceManager.createInstanceWithContext("com.sun.star.awt.ContainerWindowProvider",self.ctx)
self.m_panelRootWindow = provider.createContainerWindow(dialogUrl,"",self.xParentWindow, None)
return self.m_panelRootWindow
def postDisposing( self ):
super.postDisposing()
if self.m_panelRootWindow:
self.m_panelRootWindow.dispose()
self.m_panelRootWindow = None
self.toolpanel = None
return
#######################################################################
#######################################################################
class pocFactory( unohelper.Base, XUIElementFactory ):
def __init__ ( self, ctx ):
self.ctx = ctx
def createUIElement( self, url, properties ):
xParentWindow = None
xFrame = None
xUIElement = None
for arg in properties:
if arg.Name == "Frame":
xFrame = arg.Value
elif arg.Name == "ParentWindow":
xParentWindow = arg.Value
if xFrame and xParentWindow:
try:
xUIElement = pyPanel(self.ctx, xFrame, xParentWindow, url)
except Exception as e:
print(e)
return xUIElement
########################################################################
########################################################################
# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper ()
# add the FormatFactory class to the implementation container,
# which the loader uses to register/instantiate the component.
g_ImplementationHelper.addImplementation (pocFactory,
implementation_name,
implementation_services,
)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="MyDialog" dlg:left="192" dlg:top="127" dlg:width="174" dlg:height="147" dlg:closeable="true" dlg:moveable="true" dlg:help-url="customcontrol1" dlg:withtitlebar="false">
<script:event script:event-name="on-focus" script:macro-name="vnd.sun.star.script:toolPanelPocBasic.Module1.dialogOnLoad?language=Basic&amp;location=application" script:language="Script"/>
<dlg:bulletinboard>
<dlg:button dlg:id="CommandButton1" dlg:tab-index="0" dlg:left="6" dlg:top="8" dlg:width="80" dlg:height="30" dlg:value="The button label">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:toolPanelPocBasic.Module1.buttonClick?language=Basic&amp;location=application" script:language="Script"/>
</dlg:button>
<dlg:textfield dlg:id="TextInfo" dlg:textarea-vertical-align="top" dlg:tab-index="1" dlg:left="6" dlg:top="48" dlg:width="80" dlg:height="59" dlg:value="a sample text" dlg:multiline="true"/>
</dlg:bulletinboard>
</dlg:window>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment