### Toolkit Controls Examples (Basic Library) Source: https://github.com/apache/openoffice/blob/trunk/main/odk/examples/DevelopersGuide/examples.html This directory contains a Basic library demonstrating various toolkit controls. The library can be packaged as a UNO package and installed. After installation, it appears in the Basic IDE with modules for FileDialog, MultiPage, ProgressBar, and ScrollBar. ```Basic ' This is a placeholder for the Basic library code found in ToolkitControls. ' The actual code would be within modules like FileDialog, MultiPage, ProgressBar, ScrollBar. ' Example for FileDialog module: Sub ShowFileDialogExample MsgBox "This is a placeholder for the FileDialog example." ' Code to show a file dialog End Sub ' Example for MultiPage module: Sub ShowMultiPageDialogExample MsgBox "This is a placeholder for the MultiPage dialog example." ' Code to show a multi-page dialog End Sub ' Example for ProgressBar module: Sub ShowProgressBarExample MsgBox "This is a placeholder for the ProgressBar example." ' Code to show a progress bar dialog End Sub ' Example for ScrollBar module: Sub ShowScrollBarExample MsgBox "This is a placeholder for the ScrollBar example." ' Code to show a scroll bar dialog End Sub ``` -------------------------------- ### Java Component Example Source: https://github.com/apache/openoffice/blob/trunk/main/odk/examples/DevelopersGuide/examples.html This Java code demonstrates extending the service provider with a new factory and instantiating example components. It includes examples of simple demo components and a service provider. ```java package com.sun.star.comp.test; import com.sun.star.comp.helper.Factory; // For creating factories import com.sun.star.comp.helper.OfficeComponentLoader; // For loading components import com.sun.star.lang.XComponent; // Base interface for components import com.sun.star.lang.XInitialization; // For initializing components import com.sun.star.lang.XServiceInfo; // For service information import com.sun.star.lang.XTypeProvider; // For type information import com.sun.star.uno.Any; // For UNO Any type import com.sun.star.uno.Exception; // Base UNO exception import com.sun.star.uno.Type; // UNO Type import com.sun.star.uno.UnoRuntime; // For UNO runtime operations import com.sun.star.uno.XComponentContext; // Component context /** * This is a simple demo component which implements XTypeProvider, XServiceInfo * and an own interface XSomethingA. */ public class TestComponentA extends com.sun.star.comp.helper.OfficeComponent implements XTypeProvider, XServiceInfo { /** * The service name of this component. */ private static final String serviceName = "com.sun.star.comp.test.TestComponentA"; /** * The constructor. * * @param xContext The component context. */ public TestComponentA( XComponentContext xContext ) { super( xContext ); } /** * Returns the implementation name of this component. * * @return The implementation name. */ @Override public String getImplementationName() { return "com.sun.star.comp.test.TestComponentA"; } /** * Returns the supported service names of this component. * * @return The supported service names. */ @Override public String[] getSupportedServiceNames() { return new String[] { serviceName }; } /** * Checks if this component supports a given service. * * @param sServiceName The service name to check. * @return true if the component supports the service, false otherwise. */ @Override public boolean supportsService( String sServiceName ) { return sServiceName.equals( serviceName ); } /** * Returns the type of the component. * * @return The type of the component. */ @Override public Type getImplementationId() { return TestComponentA.static_get_implementation_id(); } /** * Returns the type of the component. * * @return The type of the component. */ public static Type static_get_implementation_id() { return new Type( "com.sun.star.comp.test.TestComponentA" ); } /** * Returns the type of the component. * * @return The type of the component. */ @Override public Type[] getTypes() { return new Type[] { new Type( "com.sun.star.lang.XTypeProvider" ), new Type( "com.sun.star.lang.XServiceInfo" ), new Type( "com.sun.star.comp.test.XSomethingA" ) }; } /** * Returns the type of the component. * * @param xType The type to check. * @return The type of the component. */ @Override public Object queryInterface( Type xType ) { if ( xType.equals( new Type( "com.sun.star.lang.XTypeProvider" ) ) || xType.equals( new Type( "com.sun.star.lang.XServiceInfo" ) ) || xType.equals( new Type( "com.sun.star.comp.test.XSomethingA" ) ) ) { return this; } return super.queryInterface( xType ); } /** * Initializes the component. * * @param aArgs The initialization arguments. * @throws Exception If an error occurs during initialization. * @throws IllegalArgumentException If the arguments are invalid. */ @Override public void initialize( Any[] aArgs ) throws Exception, IllegalArgumentException { super.initialize( aArgs ); // TODO: Add initialization code here } } ``` ```java package com.sun.star.comp.test; import com.sun.star.comp.helper.Factory; // For creating factories import com.sun.star.comp.helper.OfficeComponentLoader; // For loading components import com.sun.star.lang.XComponent; // Base interface for components import com.sun.star.lang.XInitialization; // For initializing components import com.sun.star.lang.XServiceInfo; // For service information import com.sun.star.lang.XTypeProvider; // For type information import com.sun.star.uno.Any; // For UNO Any type import com.sun.star.uno.Exception; // Base UNO exception import com.sun.star.uno.Type; // UNO Type import com.sun.star.uno.UnoRuntime; // For UNO runtime operations import com.sun.star.uno.XComponentContext; // Component context /** * This is a simple demo component which implements XTypeProvider, XServiceInfo * and an own interface XSomethingB. */ public class TestComponentB extends com.sun.star.comp.helper.OfficeComponent implements XTypeProvider, XServiceInfo { /** * The service name of this component. */ private static final String serviceName = "com.sun.star.comp.test.TestComponentB"; /** * The constructor. * * @param xContext The component context. */ public TestComponentB( XComponentContext xContext ) { super( xContext ); } /** * Returns the implementation name of this component. * * @return The implementation name. */ @Override public String getImplementationName() { return "com.sun.star.comp.test.TestComponentB"; } /** * Returns the supported service names of this component. * * @return The supported service names. */ @Override public String[] getSupportedServiceNames() { return new String[] { serviceName }; } /** * Checks if this component supports a given service. * * @param sServiceName The service name to check. * @return true if the component supports the service, false otherwise. */ @Override public boolean supportsService( String sServiceName ) { return sServiceName.equals( serviceName ); } /** * Returns the type of the component. * * @return The type of the component. */ @Override public Type getImplementationId() { return TestComponentB.static_get_implementation_id(); } /** * Returns the type of the component. * * @return The type of the component. */ public static Type static_get_implementation_id() { return new Type( "com.sun.star.comp.test.TestComponentB" ); } /** * Returns the type of the component. * * @return The type of the component. */ @Override public Type[] getTypes() { return new Type[] { new Type( "com.sun.star.lang.XTypeProvider" ), new Type( "com.sun.star.lang.XServiceInfo" ), new Type( "com.sun.star.comp.test.XSomethingB" ) }; } /** * Returns the type of the component. * * @param xType The type to check. * @return The type of the component. */ @Override public Object queryInterface( Type xType ) { if ( xType.equals( new Type( "com.sun.star.lang.XTypeProvider" ) ) || xType.equals( new Type( "com.sun.star.lang.XServiceInfo" ) ) || xType.equals( new Type( "com.sun.star.comp.test.XSomethingB" ) ) ) { return this; } return super.queryInterface( xType ); } /** * Initializes the component. * * @param aArgs The initialization arguments. * @throws Exception If an error occurs during initialization. * @throws IllegalArgumentException If the arguments are invalid. */ @Override public void initialize( Any[] aArgs ) throws Exception, IllegalArgumentException { super.initialize( aArgs ); // TODO: Add initialization code here } } ``` ```java package com.sun.star.comp.test; import com.sun.star.comp.helper.Factory; // For creating factories import com.sun.star.comp.helper.OfficeComponentLoader; // For loading components import com.sun.star.lang.XComponent; // Base interface for components import com.sun.star.lang.XInitialization; // For initializing components import com.sun.star.lang.XServiceInfo; // For service information import com.sun.star.lang.XTypeProvider; // For type information import com.sun.star.uno.Any; // For UNO Any type import com.sun.star.uno.Exception; // Base UNO exception import com.sun.star.uno.Type; // UNO Type import com.sun.star.uno.UnoRuntime; // For UNO runtime operations import com.sun.star.uno.XComponentContext; // Component context /** * This is a factory (service provider) which can create the two test components. */ public class TestServiceProvider extends Factory implements XInitialization { /** * The service name of this factory. */ private static final String serviceName = "com.sun.star.comp.test.TestServiceProvider"; /** * The constructor. * * @param xContext The component context. */ public TestServiceProvider( XComponentContext xContext ) { super( xContext ); } /** * Returns the implementation name of this factory. * * @return The implementation name. */ @Override public String getImplementationName() { return "com.sun.star.comp.test.TestServiceProvider"; } /** * Returns the supported service names of this factory. * * @return The supported service names. */ @Override public String[] getSupportedServiceNames() { return new String[] { serviceName }; } /** * Checks if this factory supports a given service. * * @param sServiceName The service name to check. * @return true if the factory supports the service, false otherwise. */ @Override public boolean supportsService( String sServiceName ) { return sServiceName.equals( serviceName ); } /** * Creates a new instance of the component with the given service name. * * @param sServiceName The service name of the component to create. * @return The created component. * @throws Exception If an error occurs during creation. */ @Override protected XComponent create( String sServiceName ) { if ( sServiceName.equals( "com.sun.star.comp.test.TestComponentA" ) ) { return new TestComponentA( getContext() ); } else if ( sServiceName.equals( "com.sun.star.comp.test.TestComponentB" ) ) { return new TestComponentB( getContext() ); } return null; } /** * Initializes the factory. * * @param aArgs The initialization arguments. * @throws Exception If an error occurs during initialization. * @throws IllegalArgumentException If the arguments are invalid. */ @Override public void initialize( Any[] aArgs ) throws Exception, IllegalArgumentException { super.initialize( aArgs ); // TODO: Add initialization code here } } ``` -------------------------------- ### Install OpenOffice Extensions on Solaris Source: https://github.com/apache/openoffice/blob/trunk/main/setup_native/source/packinfo/shellscripts_extensions.txt This script handles the installation of UNO extensions on Solaris systems. It checks for diskless service installations and uses either the 'postrun' command or directly executes 'unopkg' to synchronize and set permissions for extensions. It includes error handling for failed installations. ```shell # # Need to check diskless service install and make sure use the correct unpkg # DISKLESS_SRVC=`echo $$BASEDIR | /usr/bin/grep export/Solaris_[1-9][0-9]/usr_$${ARCH}.all` if [ "$$DISKLESS_SRVC" ]; then UNOPKG=/export/Solaris_11/usr_`uname -p`.allPRODUCTDIRECTORYNAME/program/unopkg POSTRUN=$$PKG_INSTALL_ROOT/usr_`uname -p`.all/usr/lib/postrun CLIENT_BASEDIR=$$PKG_INSTALL_ROOT/usr_$${ARCH}.all else UNOPKG=$$BASEDIR/PRODUCTDIRECTORYNAME/program/unopkg POSTRUN=$$PKG_INSTALL_ROOT/usr/lib/postrun fi # Use postrun command on Solaris where available (OpenSolaris) if [ -x $$POSTRUN ]; then ( echo "test -x \"$$CLIENT_BASEDIR/PRODUCTDIRECTORYNAME/program/unopkg\" || exit 0" echo "umask 022" echo "\"$$CLIENT_BASEDIR/PRODUCTDIRECTORYNAME/program/unopkg\" sync" echo "find \"$$CLIENT_BASEDIR/PRODUCTDIRECTORYNAME/share/prereg/bundled\" -type f -exec chmod 644 {} \;" ) | $$POSTRUN -b -c UNOPKG if [ "$$?" != "0" ]; then echo "\nERROR: Installation of UNO extensions" echo " through $$POSTRUN failed." exit 1 fi else # No postrun available, try running unopkg directly "$$UNOPKG" sync find "$$BASEDIR/PRODUCTDIRECTORYNAME/share/prereg/bundled" -type f -exec chmod 644 {} \; if [ "$$?" != "0" ]; then echo "\nERROR: Installation of UNO extensions failed." test "$$BASEDIR" = "$$CLIENT_BASEDIR" || echo "ERROR: alternate root install requires SUNWpostrun package to be installed" echo 'ERROR: Make sure the runtime requirements (operating system, patch level, architecture) are met.' exit 1 fi fi exit 0 ``` -------------------------------- ### Install OOXML Support Source: https://github.com/apache/openoffice/blob/trunk/main/oox/source/export/ooxml-export-notes.txt Command to install OOXML support. Ensure to replace \/where\/you\/want with the desired installation directory. ```bash cd instsetoo_native/util LOCALINSTALLDIR=/where/you/want dmake openoffice_en-US PKGFORMAT=installed ``` -------------------------------- ### Set and Get String Property Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/OleTest.htm Demonstrates setting and then getting a string property. It logs the input string array and the retrieved value. ```javascript oletest.AttrString= arrString; ret= oletest.AttrString; document.writeln("Setting AttrString: " + arrString.toString() + "

"); document.writeln("Getting AttrString: " + arrString.toString()); ``` -------------------------------- ### Create test directories Source: https://github.com/apache/openoffice/blob/trunk/test/README.md Create the 'testspace' directory and the 'install' subdirectory within it if they do not already exist. These directories are used to organize test-related files and the installed office components. ```shell mkdir $SOURCE_ROOT_DIR/test/testspace ``` ```shell mkdir $SOURCE_ROOT_DIR/test/testspace/install ``` -------------------------------- ### Post-installation Script for OpenOffice Source: https://github.com/apache/openoffice/blob/trunk/main/setup_native/source/packinfo/shellscripts_brand.txt This script executes after OpenOffice is installed. It identifies the product installation location based on the operating system and creates a symbolic link to the basis layer. ```shell # echo Command after installing # searching for the PRODUCTINSTALLLOCATION for the different platforms platform=`uname -s` case $$platform in SunOS) BASISPACKAGE=apacheopenoffice-core01 BASISDIR=`pkginfo -r $$BASISPACKAGE` PRODUCTINSTALLLOCATION="$$BASEDIR" ;; Linux) BASISPACKAGE=apacheopenoffice-core01 BASISDIR=`rpm -q --queryformat "%{{INSTALLPREFIX}}" $$BASISPACKAGE` PRODUCTINSTALLLOCATION="$$RPM_INSTALL_PREFIX" ;; *) PRODUCTINSTALLLOCATION="$$BASEDIR" ;; esac # creating link to basis layer if [ -d $$BASISDIR/openoffice/basisBASISDIRECTORYVERSION ] then ln -s $$BASISDIR/openoffice/basisBASISDIRECTORYVERSION $$PRODUCTINSTALLLOCATION/PRODUCTDIRECTORYNAME/basis-link >/dev/null 2>&1 else ln -s ../openoffice/basisBASISDIRECTORYVERSION $$PRODUCTINSTALLLOCATION/PRODUCTDIRECTORYNAME/basis-link >/dev/null 2>&1 fi exit 0 ``` -------------------------------- ### Start OCSP Responder Source: https://github.com/apache/openoffice/blob/trunk/main/xmlsecurity/test_docs/CAs/Root_8/README.txt Use this command to start an OCSP responder. Ensure the specified paths for index, signer, and CA certificates are correct. ```bash openssl ocsp -index demoCA/index.txt -port 8888 -rsigner demoCA/cacert.pem -rkey demoCA/private/cakey.pem -CA demoCA/cacert.pem -text ``` -------------------------------- ### UNO Starter Command Line Usage Source: https://github.com/apache/openoffice/blob/trunk/main/odk/docs/tools.html The uno starter provides a flexible way to launch UNO components. It supports specifying components by name or service, managing registry files, and configuring network connections. ```bash uno (-c -l | -s ) [-ro ] [-ro ] ... [-rw ] [-u uno:(socket[,host=][,port=]|pipe[,name=]);iiop|urp; [--singleaccept] [--singleinstance]] [-- ] ``` -------------------------------- ### Load a Component into Apache OpenOffice (Java) Source: https://github.com/apache/openoffice/blob/trunk/main/odk/examples/DevelopersGuide/examples.html Demonstrates how to load a component into Apache OpenOffice %PRODUCT_RELEASE% using a Java application. This example requires a running office instance. ```java package ooodev.firststeps; import com.sun.star.beans.PropertyValue; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.frame.Desktop; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XDesktop; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.uno.XComponentContext; public class FirstLoadComponent { public static void main(String[] args) { try { // setup service manager XComponentContext localContext = Bootstrap.createInitialComponentContext(); XMultiComponentFactory localServiceManager = localContext.getServiceManager(); // get the remote office service manager Object desktop = localServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", localContext); XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop); XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop); // load a new document PropertyValue[] propertyValues = new PropertyValue[0]; XComponent xComponent = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, propertyValues); System.out.println("Successfully loaded a new text document."); // close the document xComponent.dispose(); } catch (Exception e) { e.printStackTrace(); } } } ``` -------------------------------- ### UNO Starter (uno.exe) Source: https://github.com/apache/openoffice/blob/trunk/main/odk/docs/tools.html The UNO-starter is used for running a component or service process and providing a runtime environment. It loads the component and instantiates it. ```APIDOC ## UNO Starter (uno.exe) ### Description Used for running a component or service process and providing a runtime environment. It loads the component and instantiates it. ### Usage `uno.exe -c -l | -s [-ro ] [-ro ] ... [-rw ] [-u uno:(socket[,host=][,port=]|pipe[,name=]);iiop|urp; [--singleaccept] [--singleinstance]] [-- ] ### Options * **``**: Specifies the network interface to be used if a machine is part of two networks. * **``**: Name of a named pipe. * **``**: Identifier for demanded called component instances. * **``**: Optional registries (e.g., c:\myreg.rdb) used by the ServiceManager. `-ro` ones are read-only; a single `-rw` one is for reading and writing and may be created if it doesn't exist. * **`--singleaccept`**: The uno starter will accept one connection, provide the component instance, and then exit. * **`--singleinstance`**: The uno starter will accept any number of connections but provide the same single component instance for each connection instead of creating a new one. ### Example `[c: ] uno.exe -c MyComponent -l mycomp.dll -r myregistry.rdb -- foo bar` `[c: ] uno.exe -s foo.bar.FooBarService -r myregistry.rdb -- foo bar` ``` -------------------------------- ### Test AttrAny2 property with Object Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/JScriptNewStyle.htm Sets and gets the AttrAny2 property with a JavaScript object, printing the set and get values. ```javascript var obj= new Object(); obj[1]= "This is index 0"; oletest.AttrAny2= obj; ret= oletest.AttrAny2; document.writeln( "set: " + obj + " get: " + ret); break; ``` -------------------------------- ### Build Apache OpenOffice from Source Source: https://github.com/apache/openoffice/blob/trunk/README.md Follow these steps to build Apache OpenOffice after cloning the repository and ensuring all prerequisites are met. Building can take several hours. Refer to the Project Wiki for a comprehensive building guide and platform-specific prerequisites. ```bash cd aoo/main autoconf ./configure ./bootstrap source *.Set.sh cd instsetoo_native build --all ``` -------------------------------- ### Test AttrAny2 property with String Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/JScriptNewStyle.htm Sets and gets the AttrAny2 property with a string value, printing both the set and get values. ```javascript i= "Hallo" oletest.AttrAny2= i; ret= oletest.AttrAny2; document.writeln( "set: " + i + " get: " + ret); break; ``` -------------------------------- ### Thumbs Example Source: https://github.com/apache/openoffice/blob/trunk/main/odk/examples/DevelopersGuide/examples.html This Java code provides a framework for a component that scales images in a directory and stores them to another directory. It includes the framework and an example that registers a factory and instantiates the component. ```java package org.openoffice.comp.test; import com.sun.star.comp.helper.OfficeComponentLoader; import com.sun.star.lang.XComponent; import com.sun.star.lang.XInitialization; import com.sun.star.lang.XServiceInfo; import com.sun.star.uno.Any; import com.sun.star.uno.Exception; import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; /** * This is a framework for a component which scales images in a directory and * stores them to another directory. This code does not really do anything, it * just contains the framework. */ public class ImageShrink extends com.sun.star.comp.helper.OfficeComponent implements XServiceInfo { /** * The service name of this component. */ private static final String serviceName = "org.openoffice.comp.test.ImageShrink"; /** * The constructor. * * @param xContext The component context. */ public ImageShrink( XComponentContext xContext ) { super( xContext ); } /** * Returns the implementation name of this component. * * @return The implementation name. */ @Override public String getImplementationName() { return "org.openoffice.comp.test.ImageShrink"; } /** * Returns the supported service names of this component. * * @return The supported service names. */ @Override public String[] getSupportedServiceNames() { return new String[] { serviceName }; } /** * Checks if this component supports a given service. * * @param sServiceName The service name to check. * @return true if the component supports the service, false otherwise. */ @Override public boolean supportsService( String sServiceName ) { return sServiceName.equals( serviceName ); } /** * Initializes the component. * * @param aArgs The initialization arguments. * @throws Exception If an error occurs during initialization. * @throws IllegalArgumentException If the arguments are invalid. */ @Override public void initialize( Any[] aArgs ) throws Exception, IllegalArgumentException { super.initialize( aArgs ); // TODO: Add initialization code here } } ``` ```java package org.openoffice.comp.test; import com.sun.star.comp.helper.Factory; import com.sun.star.comp.helper.OfficeComponentLoader; import com.sun.star.lang.XComponent; import com.sun.star.lang.XInitialization; import com.sun.star.lang.XServiceInfo; import com.sun.star.uno.Any; import com.sun.star.uno.Exception; import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; /** * This example registers a factory for the image shrink component and instantiates it. */ public class Thumbs extends Factory implements XInitialization { /** * The service name of this factory. */ private static final String serviceName = "org.openoffice.comp.test.Thumbs"; /** * The constructor. * * @param xContext The component context. */ public Thumbs( XComponentContext xContext ) { super( xContext ); } /** * Returns the implementation name of this factory. * * @return The implementation name. */ @Override public String getImplementationName() { return "org.openoffice.comp.test.Thumbs"; } /** * Returns the supported service names of this factory. * * @return The supported service names. */ @Override public String[] getSupportedServiceNames() { return new String[] { serviceName }; } /** * Checks if this factory supports a given service. * * @param sServiceName The service name to check. * @return true if the factory supports the service, false otherwise. */ @Override public boolean supportsService( String sServiceName ) { return sServiceName.equals( serviceName ); } /** * Creates a new instance of the component with the given service name. * * @param sServiceName The service name of the component to create. * @return The created component. * @throws Exception If an error occurs during creation. */ @Override protected XComponent create( String sServiceName ) { if ( sServiceName.equals( "org.openoffice.comp.test.ImageShrink" ) ) { return new ImageShrink( getContext() ); } return null; } /** * Initializes the factory. * * @param aArgs The initialization arguments. * @throws Exception If an error occurs during initialization. * @throws IllegalArgumentException If the arguments are invalid. */ @Override public void initialize( Any[] aArgs ) throws Exception, IllegalArgumentException { super.initialize( aArgs ); // TODO: Add initialization code here } } ``` -------------------------------- ### Run UNO Component with Uno Starter Source: https://github.com/apache/openoffice/blob/trunk/main/odk/docs/tools.html Use the uno starter to run a component or service process, providing a runtime environment. Specify the component by its implementation name and DLL, or by its service name. ```bash [c: ] uno.exe -c MyComponent -l mycomp.dll -r myregistry.rdb -- foo bar ``` ```bash [c: ] uno.exe -s foo.bar.FooBarService -r myregistry.rdb -- foo bar ``` -------------------------------- ### Test AttrAny2 property with Integer Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/JScriptNewStyle.htm Sets and gets the AttrAny2 property with an integer value, printing both the set and get values. ```javascript i= 100; oletest.AttrAny2= i; ret= oletest.AttrAny2; document.writeln( "set: " + i + " get: " + ret); break; ``` -------------------------------- ### Set and Get Boolean Property Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/OleTest.htm Demonstrates setting and then getting a boolean property. It logs the input array and the retrieved value. ```javascript oletest.AttrBool= arrBool; ret= oletest.AttrBool; document.writeln("Setting AttrBool: " + arrBool.toString() + "

"); document.writeln("Getting AttrBool: " + arrBool.toString()); ``` -------------------------------- ### C++ Component Example Source: https://github.com/apache/openoffice/blob/trunk/main/odk/examples/DevelopersGuide/examples.html This C++ code demonstrates creating new instances of demo services and calling methods of a demo interface. It includes implementations for two simple UNO services. ```cpp /* * This file is part of the Apache OpenOffice project. * * Copyright 2002-2003 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, CA 95054, USA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "TestCppComponent.hxx" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/registry/XRegistryKey.hpp" #include "com/sun/star/uno/XComponentContext.hpp" using namespace ::com::sun::star; //------------------------------------------------------------------------ // //------------------------------------------------------------------------ void SAL_CALL TestCppComponent_WriteInfo( const uno::Reference< registry::XRegistryKey >& aKey ) { // The following lines are not needed for the ProtocolHandlerAddon, but they are // required for a component to be registered in the registry. // The component is registered in the registry by the component registration // mechanism. // The component registration mechanism is described in the following document: // http://udk.openoffice.org/common/man/html/component.html } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Reference< lang::XInitialization > SAL_CALL TestCppComponent_CreateInstance( const uno::Reference< uno::XComponentContext > & aContext ) { return uno::Reference< lang::XInitialization >( new TestCppComponent( aContext ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ extern "C" uno::Reference< lang::XInitialization > SAL_CALL component_getFactory( const uno::Any & aContext, const uno::Any & aArguments ) { // The component is registered in the registry by the component registration // mechanism. The component registration mechanism is described in the // following document: // http://udk.openoffice.org/common/man/html/component.html // The following lines are not needed for the ProtocolHandlerAddon, but they are // required for a component to be registered in the registry. return uno::Reference< lang::XInitialization >( new TestCppComponent( aContext ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Reference< uno::XInterface > SAL_CALL component_getImplementationName( const uno::Reference< uno::XComponentContext > & aContext ) { return uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRING_LITERAL( "com.sun.star.comp.helper.TestCppComponent" ) ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Sequence< ::rtl::OUString > SAL_CALL component_getSupportedServiceNames( const uno::Reference< uno::XComponentContext > & aContext ) { uno::Sequence< ::rtl::OUString > aSupported( 1 ); aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRING_LITERAL( "com.sun.star.comp.helper.TestCppComponent" ) ); return aSupported; } ``` ```cpp /* * This file is part of the Apache OpenOffice project. * * Copyright 2002-2003 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, CA 95054, USA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TEST_CPP_COMPONENT_HXX #define TEST_CPP_COMPONENT_HXX #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/uno/Reference.hpp" #include "com/sun/star/uno/XComponentContext.hpp" class TestCppComponent : public lang::XInitialization, public lang::XServiceInfo { public: TestCppComponent( const uno::Reference< uno::XComponentContext > & aContext ); virtual ~TestCppComponent(); // lang::XInitialization virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArgs ) throw (uno::Exception, lang::IllegalArgumentException ); // lang::XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() throw (uno); virtual uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (uno); virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw (uno); private: uno::Reference< uno::XComponentContext > m_aContext; }; #endif // TEST_CPP_COMPONENT_HXX ``` ```cpp /* * This file is part of the Apache OpenOffice project. * * Copyright 2002-2003 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, CA 95054, USA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "service1_impl.hxx" #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/registry/XRegistryKey.hpp" #include "com/sun/star/uno/XComponentContext.hpp" using namespace ::com::sun::star; //------------------------------------------------------------------------ // //------------------------------------------------------------------------ void SAL_CALL service1_impl_WriteInfo( const uno::Reference< registry::XRegistryKey >& aKey ) { // The following lines are not needed for the ProtocolHandlerAddon, but they are // required for a component to be registered in the registry. // The component is registered in the registry by the component registration // mechanism. // The component registration mechanism is described in the following document: // http://udk.openoffice.org/common/man/html/component.html } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Reference< lang::XInitialization > SAL_CALL service1_impl_CreateInstance( const uno::Reference< uno::XComponentContext > & aContext ) { return uno::Reference< lang::XInitialization >( new service1_impl( aContext ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ extern "C" uno::Reference< lang::XInitialization > SAL_CALL component_getFactory( const uno::Any & aContext, const uno::Any & aArguments ) { // The component is registered in the registry by the component registration // mechanism. The component registration mechanism is described in the // following document: // http://udk.openoffice.org/common/man/html/component.html // The following lines are not needed for the ProtocolHandlerAddon, but they are // required for a component to be registered in the registry. return uno::Reference< lang::XInitialization >( new service1_impl( aContext ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Reference< uno::XInterface > SAL_CALL component_getImplementationName( const uno::Reference< uno::XComponentContext > & aContext ) { return uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRING_LITERAL( "com.sun.star.comp.helper.service1_impl" ) ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Sequence< ::rtl::OUString > SAL_CALL component_getSupportedServiceNames( const uno::Reference< uno::XComponentContext > & aContext ) { uno::Sequence< ::rtl::OUString > aSupported( 1 ); aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRING_LITERAL( "com.sun.star.comp.helper.service1_impl" ) ); return aSupported; } ``` ```cpp /* * This file is part of the Apache OpenOffice project. * * Copyright 2002-2003 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, CA 95054, USA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SERVICE1_IMPL_HXX #define SERVICE1_IMPL_HXX #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/uno/Reference.hpp" #include "com/sun/star/uno/XComponentContext.hpp" class service1_impl : public lang::XInitialization, public lang::XServiceInfo { public: service1_impl( const uno::Reference< uno::XComponentContext > & aContext ); virtual ~service1_impl(); // lang::XInitialization virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArgs ) throw (uno::Exception, lang::IllegalArgumentException ); // lang::XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() throw (uno); virtual uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (uno); virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw (uno); private: uno::Reference< uno::XComponentContext > m_aContext; }; #endif // SERVICE1_IMPL_HXX ``` ```cpp /* * This file is part of the Apache OpenOffice project. * * Copyright 2002-2003 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, CA 95054, USA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "service2_impl.hxx" #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/registry/XRegistryKey.hpp" #include "com/sun/star/uno/XComponentContext.hpp" using namespace ::com::sun::star; //------------------------------------------------------------------------ // //------------------------------------------------------------------------ void SAL_CALL service2_impl_WriteInfo( const uno::Reference< registry::XRegistryKey >& aKey ) { // The following lines are not needed for the ProtocolHandlerAddon, but they are // required for a component to be registered in the registry. // The component is registered in the registry by the component registration // mechanism. // The component registration mechanism is described in the following document: // http://udk.openoffice.org/common/man/html/component.html } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Reference< lang::XInitialization > SAL_CALL service2_impl_CreateInstance( const uno::Reference< uno::XComponentContext > & aContext ) { return uno::Reference< lang::XInitialization >( new service2_impl( aContext ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ extern "C" uno::Reference< lang::XInitialization > SAL_CALL component_getFactory( const uno::Any & aContext, const uno::Any & aArguments ) { // The component is registered in the registry by the component registration // mechanism. The component registration mechanism is described in the // following document: // http://udk.openoffice.org/common/man/html/component.html // The following lines are not needed for the ProtocolHandlerAddon, but they are // required for a component to be registered in the registry. return uno::Reference< lang::XInitialization >( new service2_impl( aContext ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Reference< uno::XInterface > SAL_CALL component_getImplementationName( const uno::Reference< uno::XComponentContext > & aContext ) { return uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRING_LITERAL( "com.sun.star.comp.helper.service2_impl" ) ) ); } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ uno::Sequence< ::rtl::OUString > SAL_CALL component_getSupportedServiceNames( const uno::Reference< uno::XComponentContext > & aContext ) { uno::Sequence< ::rtl::OUString > aSupported( 1 ); aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRING_LITERAL( "com.sun.star.comp.helper.service2_impl" ) ); return aSupported; } ``` ```cpp /* * This file is part of the Apache OpenOffice project. * * Copyright 2002-2003 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, CA 95054, USA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SERVICE2_IMPL_HXX #define SERVICE2_IMPL_HXX #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/uno/Reference.hpp" #include "com/sun/star/uno/XComponentContext.hpp" class service2_impl : public lang::XInitialization, public lang::XServiceInfo { public: service2_impl( const uno::Reference< uno::XComponentContext > & aContext ); virtual ~service2_impl(); // lang::XInitialization virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArgs ) throw (uno::Exception, lang::IllegalArgumentException ); // lang::XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() throw (uno); virtual uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (uno); virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw (uno); private: uno::Reference< uno::XComponentContext > m_aContext; }; #endif // SERVICE2_IMPL_HXX ``` -------------------------------- ### Test AttrAny2 property with Double Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/JScriptNewStyle.htm Sets and gets the AttrAny2 property with a double-precision floating-point value, printing both the set and get values. ```javascript i= 3.14; oletest.AttrAny2= i; ret= oletest.AttrAny2; document.writeln( "set: " + i + " get: " + ret); break; ``` -------------------------------- ### Set and Get Float Property Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/OleTest.htm Demonstrates setting and then getting a float property. It logs the input double array and the retrieved value. ```javascript oletest.AttrFloat= arrDouble; ret= oletest.AttrFloat; document.writeln("Setting AttrFloat: " + arrDouble.toString() + "

"); document.writeln("Getting AttrFloat: " + arrDouble.toString()); ``` -------------------------------- ### Display Run Help Source: https://github.com/apache/openoffice/blob/trunk/test/README.md Shows the available command-line options and usage for the test runner script. ```shell ./run -help ``` -------------------------------- ### Set and Get Sequence Property Source: https://github.com/apache/openoffice/blob/trunk/main/extensions/test/ole/OleTest.htm Demonstrates setting and then getting a property of sequence type. It logs the input sequence and the retrieved value. ```javascript oletest.AttrSequence= arrSeq; ret= oletest.AttrSequence; document.writeln("Setting AttrSequence: " + arrSeq.toString() + "

"); document.writeln("Getting AttrSequence: " + arrSeq.toString()); ```