### Install Watchman on Linux Source: https://github.com/libreoffice/core/blob/master/solenv/maven/README.md Clone the Watchman repository, generate configuration scripts, and install it. This example shows installation to the user's home directory without root privileges. ```bash git clone https://github.com/facebook/watchman.git cd watchman ./autogen.sh ./configure --prefix $HOME/watchman make install ``` -------------------------------- ### GDIMetafile Usage Example Source: https://github.com/libreoffice/core/blob/master/vcl/README.GDIMetaFile.md Illustrates a basic, incomplete implementation of GDIMetafile usage. Assumes VCL initialization and application creation. This example is for demonstration purposes and may require further setup for full functionality. ```cpp DemoWin::Paint() { // assume that VCL has been initialized and a new application created Window* pWin = new WorkWindow(); GDIMetaFile* pMtf = new GDIMetaFile(); SvFileStream aFileStream("example.emf", STEAM_READ); ReadWindowMetafile(aFileStream, pMtf); pMtf->Play(pWin); } ``` -------------------------------- ### Install Qt to Prefix Source: https://github.com/libreoffice/core/blob/master/static/README.wasm.md Install the compiled Qt build to the specified prefix directory. This is crucial for LibreOffice to locate the necessary Qt files. ```bash make -j install ``` ```bash make -j8 -C qtbase/src install_subtargets ``` -------------------------------- ### MyUnoObject Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html This example, part of the Lifetime Examples in Professional UNO, likely demonstrates the creation and management of UNO objects, focusing on their lifecycle within the %PRODUCTNAME% environment. ```java package com.sun.star.example.ProfUNO.Lifetime; public class MyUnoObject { // Placeholder for the actual code // This class is part of the Lifetime Examples and demonstrates UNO object lifecycle. } ``` -------------------------------- ### Toolkit Controls Basic Library Examples Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html This directory contains a Basic library demonstrating various toolkit controls. After installation, these controls can be accessed via the 'ToolkitControls' library in the Basic IDE. ```basic ' Placeholder for Basic library modules demonstrating toolkit controls. ' Specific examples for FileDialog, MultiPage, ProgressBar, and ScrollBar would be here. ``` -------------------------------- ### URL Resolver Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Builds a connection to %PRODUCTNAME% %PRODUCT_RELEASE% using the URL given on the command line. This example shows the usage of XUnoUrlResolver. ```Java package com.sun.star.comp.helper.samples.UrlResolver; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.comp.helper.BootstrapException; import com.sun.star.uno.UnoRuntime; import com.sun.star.bridge.XUnoUrlResolver; import com.sun.star.lang.XComponent; import com.sun.star.registry.XRegistryService; import com.sun.star.uno.XComponentContext; import com.sun.star.frame.Desktop; import com.sun.star.frame.XDesktop; import com.sun.star.beans.PropertyValue; public class UrlResolver { /** * @param args */ public static void main(String[] args) { XComponentContext localContext = null; XComponent xOffice = null; try { // get local component context localContext = Bootstrap.bootstrap(); // get the remote office component context Object context = localContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext); XUnoUrlResolver xUrlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, context); // connect to the running office PropertyValue [] propertyValues = new PropertyValue[1]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Hidden"; propertyValues[0].Value = new Boolean(true); Object resolved = xUrlResolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext", propertyValues); XComponentContext remoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, resolved); // get the desktop xOffice = (XComponent) remoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", remoteContext); XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, xOffice); // do something with the desktop System.out.println("Connected to running Office ..."); System.out.println("Desktop title: " + xDesktop.getCurrentController().getFrame().getTitle()); // disconnect from office xOffice.dispose(); } catch (BootstrapException e) { System.err.println("Bootstrap failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.connection.ConnectionSetupException e) { System.err.println("Connection setup failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.uno.Exception e) { System.err.println("UNO Exception: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } } } ``` -------------------------------- ### Jobs Addon Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html A Java example showing how a job can analyze the given arguments and how the environment can be detected in which the job is executed. ```Java package com.sun.star.comp.addons.JobsAddon; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.comp.helper.BootstrapException; import com.sun.star.uno.UnoRuntime; import com.sun.star.bridge.XUnoUrlResolver; import com.sun.star.lang.XComponent; import com.sun.star.registry.XRegistryService; import com.sun.star.uno.XComponentContext; import com.sun.star.frame.Desktop; import com.sun.star.frame.XDesktop; import com.sun.star.beans.PropertyValue; public class AsyncJob { /** * @param args */ public static void main(String[] args) { XComponentContext localContext = null; XComponent xOffice = null; try { // get local component context localContext = Bootstrap.bootstrap(); // get the remote office component context Object context = localContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext); XUnoUrlResolver xUrlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, context); // connect to the running office PropertyValue [] propertyValues = new PropertyValue[1]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Hidden"; propertyValues[0].Value = new Boolean(true); Object resolved = xUrlResolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext", propertyValues); XComponentContext remoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, resolved); // get the desktop xOffice = (XComponent) remoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", remoteContext); XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, xOffice); // do something with the desktop System.out.println("Connected to running Office ..."); System.out.println("Desktop title: " + xDesktop.getCurrentController().getFrame().getTitle()); // disconnect from office xOffice.dispose(); } catch (BootstrapException e) { System.err.println("Bootstrap failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.connection.ConnectionSetupException e) { System.err.println("Connection setup failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.uno.Exception e) { System.err.println("UNO Exception: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } } } ``` -------------------------------- ### Office Connection C++ Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Builds a connection to %PRODUCTNAME% %PRODUCT_RELEASE% using C++. ```C++ #include #include #include #include #include #include #include #include #include #include using namespace com::sun::star::uno; using namespace com::sun::star::comphelper; using namespace com::sun::star::frame; int main( int argc, char **argv ) { XComponentContext xContext; XComponent xOffice; try { // get the office component context xContext = ::cppu::bootstrap(); // get the desktop xOffice = Desktop::create( xContext ); XDesktop xDesktop = xOffice; // do something with the desktop printf( "Connected to running Office ...\n" ); printf( "Desktop title: %s\n", xDesktop->getCurrentController()->getFrame()->getTitle().getStr() ); // disconnect from office xOffice->dispose(); } catch( const com::sun::star::uno::Exception & e ) { fprintf( stderr, "UNO Exception: %s\n", e.Message.getStr() ); return 1; } return 0; } ``` -------------------------------- ### Start LibreOffice with Acceptance Socket Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt Use this command to start LibreOffice and enable it to accept connections on a specific socket. This is required for the API to communicate with the office suite. ```bash soffice --accept=socket,host=localhost,port=2083;urp; ``` -------------------------------- ### Batch Build Script for SDK Examples Source: https://github.com/libreoffice/core/blob/master/odk/README.md This script finds and builds Makefiles for SDK examples, excluding 'nativelib' directories. It executes 'make' for each found Makefile. Use this in a shell configured for SDK development. ```bash find examples \( -type d -name nativelib -prune \) -o \ \( -name Makefile -a -print -a \( -execdir make \; -o -quit \) \) ``` -------------------------------- ### Build and Install LibreOffice API Locally Source: https://github.com/libreoffice/core/blob/master/solenv/maven/README.md Execute the 'buck build api_install' command to install LibreOffice API artifacts into your local Maven repository. Set the VERBOSE environment variable to 1 for detailed output during troubleshooting. ```bash VERBOSE=1 buck build api_install ``` -------------------------------- ### Start OCSP Responder with OpenSSL Source: https://github.com/libreoffice/core/blob/master/xmlsecurity/test_docs/CAs/Sub_CA_1_Root_8/README.txt Use this command to start an OCSP responder. Ensure you have the necessary certificate and key files. ```bash openssl ocsp -index demoCA/index.txt -port 8889 -rsigner demoCA/cacert.pem -rkey demoCA/private/cakey.pem -CA demoCA/cacert.pem -text ``` -------------------------------- ### Start OCSP Responder with OpenSSL Source: https://github.com/libreoffice/core/blob/master/xmlsecurity/test_docs/CAs/Root_8/README.txt Use this command to start an OCSP responder. Ensure the specified index, certificate, and key files exist. ```bash openssl ocsp -index demoCA/index.txt -port 8888 -rsigner demoCA/cacert.pem -rkey demoCA/private/cakey.pem -CA demoCA/cacert.pem -text ``` -------------------------------- ### Tilebench Join Test Output Example Source: https://github.com/libreoffice/core/blob/master/libreofficekit/qa/data/join/README.md Example output from tilebench after running join tests, indicating the number of failed joins and specific issues at different zoom levels. ```text Failed 81 joins Zoom 0.5 bad tiles: 23 with 5637 mismatching pixels Zoom 0.6 bad tiles: 12 with 1341 mismatching pixels ... Zoom 2 bad tiles: 3 with 1675 mismatching pixels ``` -------------------------------- ### Install and Activate Emscripten SDK Source: https://github.com/libreoffice/core/blob/master/static/README.wasm.md Steps to clone the Emscripten SDK repository, install a specific version (4.0.10), and activate it for use in your environment. ```bash git clone https://github.com/emscripten-core/emsdk.git ./emsdk install 4.0.10 ./emsdk activate 4.0.10 ``` -------------------------------- ### Setting and Getting Array of Objects Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/JScriptNewStyle.htm Demonstrates setting and getting an array of objects, specifically for the com.sun.star.uno.XInterface type. This is useful for passing complex data structures. ```javascript var ar= new Array(); for( i=0; i< 3; i++) { var ob= new Object(); var valueObject= oletest._GetValueObject(); ob.value= "A JScript object!"; valueObject.Set("com.sun.star.uno.XInterface", ob); // valueObject.Set("long", 5); ar[i]= valueObject; } value.Set("[]com.sun.star.uno.XInterface", ar); // value.Set("[]long", ar); ret = oletest.methodXInterface( value); sfarray= new VBArray( ret); var arRet= sfarray.toArray(); document.writeln( "Params : Array containing objects ") for( index in ar) { document.writeln( "object " + index + ": " + ar[index].Get().value +" "); } document.writeln( "
") ; document.writeln("Return:
"); for( index in arRet) { document.writeln( "object " + index + ": " + arRet[index].value + " "); } ``` -------------------------------- ### Wind Metafile to Start Source: https://github.com/libreoffice/core/blob/master/vcl/README.GDIMetaFile.md Resets the metafile playback to the beginning. ```cpp WindStart ``` -------------------------------- ### Uno Starter Command Line Usage Source: https://github.com/libreoffice/core/blob/master/odk/docs/tools.html Illustrates the command-line syntax for the 'uno' starter tool, used to load and instantiate UNO components. ```bash uno (-c -l | -s ) [-u uno:(socket[,host=][,port=]|pipe[,name=]);iiop|urp; [--singleaccept] [--singleinstance]] [-- ] ``` -------------------------------- ### Configure Bash Environment for Emscripten Source: https://github.com/libreoffice/core/blob/master/static/README.wasm.md Example scriptlet to source the Emscripten environment setup script in your .bashrc file, making Emscripten tools available in your shell. ```bash EMSDK_ENV=$HOME/Development/libreoffice/git_emsdk/emsdk_env.sh [ -f "$EMSDK_ENV" ] && \. "$EMSDK_ENV" 1>/dev/null 2>&1 ``` -------------------------------- ### SimpleBootstrap Java Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Shows the transparent use of office UNO components from Java. The remote office component context is obtained by using the com.sun.star.comp.helper.Bootstrap.bootstrap() method. ```Java package com.sun.star.comp.helper.samples.SimpleBootstrap_java; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.comp.helper.BootstrapException; import com.sun.star.uno.UnoRuntime; import com.sun.star.bridge.XUnoUrlResolver; import com.sun.star.lang.XComponent; import com.sun.star.registry.XRegistryService; import com.sun.star.uno.XComponentContext; import com.sun.star.frame.Desktop; import com.sun.star.frame.XDesktop; import com.sun.star.beans.PropertyValue; public class SimpleBootstrap_java { /** * @param args */ public static void main(String[] args) { XComponentContext localContext = null; XComponent xOffice = null; try { // get local component context localContext = Bootstrap.bootstrap(); // get the remote office component context Object context = localContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext); XUnoUrlResolver xUrlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, context); // connect to the running office PropertyValue [] propertyValues = new PropertyValue[1]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Hidden"; propertyValues[0].Value = new Boolean(true); Object resolved = xUrlResolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext", propertyValues); XComponentContext remoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, resolved); // get the desktop xOffice = (XComponent) remoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", remoteContext); XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, xOffice); // do something with the desktop System.out.println("Connected to running Office ..."); System.out.println("Desktop title: " + xDesktop.getCurrentController().getFrame().getTitle()); // disconnect from office xOffice.dispose(); } catch (BootstrapException e) { System.err.println("Bootstrap failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.connection.ConnectionSetupException e) { System.err.println("Connection setup failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.uno.Exception e) { System.err.println("UNO Exception: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } } } ``` -------------------------------- ### Install Watchman System Wide on Linux Source: https://github.com/libreoffice/core/blob/master/solenv/maven/README.md Install Watchman system-wide on Linux. This requires root privileges for the 'make install' step. ```bash git clone https://github.com/facebook/watchman.git cd watchman ./autogen.sh ./configure make sudo make install ``` -------------------------------- ### Desk Java Example - Main Demo Application Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html The main part of a demo application demonstrating document loading, storing, conversion, dispatch, and interception mechanisms using framework APIs. Integrates with %PRODUCTNAME% %PRODUCT_RELEASE% windows. ```Java package com.sun.star.examples.OfficeDev.DesktopEnvironment; import com.sun.star.beans.PropertyValue; import com.sun.star.frame.Desktop; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XDesktop; import com.sun.star.frame.XFrame; import com.sun.star.frame.XModel; import com.sun.star.lang.XComponent; import com.sun.star.lang.XInitialization; import com.sun.star.lang.XServiceNames; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.util.XCloseable; import java.io.IOException; public class Desk implements XComponent, XInitialization, XServiceNames { private XComponentContext m_xContext; private XDesktop m_xDesktop; private XFrame m_xMainFrame; public Desk(XComponentContext xContext) { m_xContext = xContext; try { m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, xContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", xContext)); } catch (Exception e) { System.err.println("Error creating Desktop service: " + e.getMessage()); e.printStackTrace(); } } // XInitialization @Override public void initialize(Object[] object) throws com.sun.star.uno.Exception { if (object.length > 0 && object[0] instanceof XComponentContext) { m_xContext = (XComponentContext)object[0]; // Re-initialize desktop service if context changed m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, m_xContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext)); } } public void runDemo() { System.out.println("Desk Demo: Starting..."); if (m_xDesktop == null) { System.err.println("Desk Demo Error: Desktop service not available."); return; } try { // Load a document XComponentLoader loader = UnoRuntime.queryInterface(XComponentLoader.class, m_xDesktop); PropertyValue[] loadProps = new PropertyValue[1]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "Hidden"; loadProps[0].Value = Boolean.TRUE; // Example: Load a Writer document (replace with a valid path if needed) // XComponent document = loader.loadComponentFromURL("private:factory/swriter", "_blank", 0, loadProps); // System.out.println("Desk Demo: Document loaded."); // Get the main frame (this might vary depending on the context) m_xMainFrame = m_xDesktop.getCurrentFrame(); if (m_xMainFrame != null) { System.out.println("Desk Demo: Main frame obtained."); // Example: Integrate windows via system window handle (JNI) // This part requires JNI implementation and is complex. // System.out.println("Desk Demo: Integrating %PRODUCTNAME% %PRODUCT_RELEASE% window via JNI."); // Example: Dispatch and dispatch interception // Dispatcher dispatcher = new Dispatcher(m_xContext, m_xMainFrame); // dispatcher.performDispatch(); // Example: Document loading, storing, conversion // DocumentHandler handler = new DocumentHandler(m_xContext, m_xMainFrame); // handler.loadDocument("file:///path/to/document.odt"); // handler.storeDocument("file:///path/to/new_document.odt"); // handler.convertDocument("file:///path/to/document.ods"); } // Example: Show the CustomizeView CustomizeView view = new CustomizeView(m_xContext, m_xMainFrame); view.showView(); } catch (Exception e) { System.err.println("Desk Demo Error: " + e.getMessage()); e.printStackTrace(); } } // XComponent @Override public void dispose() { System.out.println("Desk Demo: Disposing."); // Clean up resources if (m_xMainFrame != null) { XCloseable closeableFrame = UnoRuntime.queryInterface(XCloseable.class, m_xMainFrame); if (closeableFrame != null) { try { closeableFrame.close(true); } catch (Exception e) { System.err.println("Error closing frame: " + e.getMessage()); } } } } @Override public void addEventListener(XEventListener xEventListener) { // Implementation for event listeners } @Override public void removeEventListener(XEventListener xEventListener) { // Implementation for event listeners } // XServiceNames @Override public String[] getServiceNames() { return new String[] {"com.sun.star.comp.helper.OfficeComponent", "com.sun.star.frame.Desktop"}; } } ``` -------------------------------- ### C++ DocumentLoader Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/examples.html A C++ implementation of the DocumentLoader example, mirroring the Java version. This example requires a running office instance. ```cpp // C++ DocumentLoader example code would go here ``` -------------------------------- ### C++ Draw Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/examples.html A C++ implementation of the Draw example, similar to its Java counterpart. This example does not require a running office instance. ```cpp // C++ Draw example code would go here ``` -------------------------------- ### C++ Component Example: TestCppComponent.cxx Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Shows how to create new instances of demo services and calls some methods of the demo interface. ```C++ // This is a placeholder for the actual C++ code. // The provided text only contains file names and descriptions, not the code itself. // Example of what such a file might contain: #include #include #include using namespace com::sun::star; // Assume XTestInterface is defined elsewhere // Function to create and use a service void createAndUseService(uno::XComponentContext const & context) { // Create an instance of a service (e.g., "com.sun.star.test.TestService") uno::Reference< uno::XInterface > xService = context.getServiceManager()->createInstanceWithContext( "com.sun.star.test.TestService", context ); // Query for the specific interface uno::Reference< test::XTestInterface > xTestInterface = uno::Reference< test::XTestInterface >::narrow( xService ); if ( xTestInterface.is() ) { // Call a method on the interface xTestInterface->someMethod(); } } ``` -------------------------------- ### Demonstrate Clipboard Service Usage Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html This example demonstrates the usage of the clipboard service. It includes registering a clipboard listener, retrieving format lists, and copying data to the clipboard. ```java package com.sun.star.examples.clipboard; import com.sun.star.uno.UnoRuntime; import com.sun.star.lang.XComponent; import com.sun.star.frame.DispatchResultEvent; import com.sun.star.frame.XDispatchResultListener; import com.sun.star.frame.XDispatchProvider; import com.sun.star.beans.PropertyValue; import com.sun.star.uno.XComponentContext; /** * Demonstrates the usage of the clipboard service by registering a clipboard listener, getting a list of formats from the current clipboard content and copying some data to the clipboard. */ public class Clipboard { // Implementation for clipboard service demonstration } ``` -------------------------------- ### Set and Get AttrAny Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Illustrates setting and then getting the AttrAny property with an array. ```javascript oletest.AttrAny = arrAny; ret = oletest.AttrAny; document.writeln("Setting AttrAny: " + arrAny.toString() + "

"); document.writeln("Getting AttrAny: " + arrAny.toString()); ``` -------------------------------- ### Set and Get AttrULong Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Illustrates setting and then getting the AttrULong property with an array. ```javascript oletest.AttrULong = arr; ret = oletest.AttrULong; document.writeln("Setting AttrULong: " + arr.toString() + "

"); document.writeln("Getting AttrULong: " + arr.toString()); ``` -------------------------------- ### Set and Get AttrLong Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Demonstrates setting and getting the AttrLong property with an array. ```javascript oletest.AttrLong = arr; ret = oletest.AttrLong; document.writeln("Setting AttrLong: " + arr.toString() + "

"); document.writeln("Getting AttrLong: " + arr.toString()); ``` -------------------------------- ### Dialog Sample with Menus Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html A sample showing a top window with some menus. ```Java UnoMenu.java ``` -------------------------------- ### Set and Get AttrShort Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Illustrates setting and then getting the AttrShort property with an array. ```javascript oletest.AttrShort = arr; ret = oletest.AttrShort; document.writeln("Setting AttrShort: " + arr.toString() + "

"); document.writeln("Getting AttrShort: " + arr.toString()); ``` -------------------------------- ### Initialize Qt Repository Source: https://github.com/libreoffice/core/blob/master/static/README.wasm.md Initialize the Qt repository, specifying the desired module subset. This step prepares the source code for configuration. ```bash ./init-repository --module-subset=qtbase ``` -------------------------------- ### Set and Get AttrByte Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Illustrates setting and then getting the AttrByte property with an array. ```javascript oletest.AttrByte = arr; ret = oletest.AttrByte; document.writeln("Setting AttrByte: " + arr.toString() + "

"); document.writeln("Getting AttrByte: " + arr.toString()); ``` -------------------------------- ### unopkg Usage Examples Source: https://github.com/libreoffice/core/blob/master/odk/docs/tools.html Demonstrates the various sub-commands and options available for the 'unopkg' tool, used for deploying UNO packages. ```bash unopkg add package-path... unopkg remove package-name... unopkg list package-name... unopkg reinstall unopkg gui unopkg -V unopkg -h ``` -------------------------------- ### DrawingML Preset Geometry Example Source: https://github.com/libreoffice/core/blob/master/oox/README.md Example of a DrawingML preset geometry definition for a 5-pointed star. ```xml ``` -------------------------------- ### Thumbs Example: Thumbs Factory Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html This example registers a factory for the image shrink component and instantiates it. ```Java package org.openoffice.comp.test; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.uno.UnoRuntime; public class Thumbs { public static void main(String[] args) { try { // Get the service manager XMultiComponentFactory serviceManager = Bootstrap.createServiceManager(); // Create an instance of ImageShrink Object imageShrinkObj = serviceManager.createInstanceWithContext("org.openoffice.comp.test.ImageShrink", null); XComponent imageShrinkComp = UnoRuntime.queryInterface(XComponent.class, imageShrinkObj); if (imageShrinkComp != null) { System.out.println("ImageShrink component created successfully."); // Cast to ImageShrink to call its specific method (if needed and available) // Note: Direct casting might require knowing the concrete class or having a specific interface // For demonstration, let's assume we can get the concrete object if it's not just an interface if (imageShrinkObj instanceof ImageShrink) { ImageShrink shrinker = (ImageShrink) imageShrinkObj; shrinker.scaleImages("/path/to/source", "/path/to/destination", 100); System.out.println("scaleImages method called."); } // Dispose of the component when done imageShrinkComp.dispose(); System.out.println("ImageShrink component disposed."); } else { System.out.println("Failed to create ImageShrink component."); } } catch (Exception e) { e.printStackTrace(); } } } ``` -------------------------------- ### Set and Get AttrFloat Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Illustrates setting and then getting the AttrFloat property with a double array. ```javascript oletest.AttrFloat = arrDouble; ret = oletest.AttrFloat; document.writeln("Setting AttrFloat: " + arrDouble.toString() + "

"); document.writeln("Getting AttrFloat: " + arrDouble.toString()); ``` -------------------------------- ### Set and Get AttrSequence2 Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Demonstrates setting and getting the AttrSequence2 property with a sequence array. ```javascript oletest.AttrSequence2 = arrSeq2; ret = oletest.AttrSequence2; document.writeln("Setting AttrSequence2: " + arrSeq2.toString() + "

"); document.writeln("Getting AttrSequence2: " + arrSeq2.toString()); ``` -------------------------------- ### C++ Counter Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/examples.html Demonstrates implementing a simple UNO component in C++ and accessing it from an executable. ```cpp // C++ Counter example code would go here ``` -------------------------------- ### Set and Get AttrString Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Demonstrates setting and getting the AttrString property with a string array. ```javascript oletest.AttrString = arrString; ret = oletest.AttrString; document.writeln("Setting AttrString: " + arrString.toString() + "

"); document.writeln("Getting AttrString: " + arrString.toString()); ``` -------------------------------- ### Start Java Applet for API Interaction Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt Execute this command from the 'api//class' directory to launch the Java application that interacts with the LibreOffice API. Ensure the desktop.jar is present in this directory. ```bash java -jar desktop.jar ``` -------------------------------- ### Run MySQL/MariaDB Container for Testing Source: https://github.com/libreoffice/core/blob/master/connectivity/README.md Steps to set up a MariaDB container for testing the mysqlc library. This includes creating a database and running the CppunitTest_connectivity_mysql_test. ```bash podman pull mariadb/server podman run --name=mariadb -e MYSQL_ROOT_PASSWORD=foobarbaz -p 127.0.0.1:3306:3306 mariadb/server podman exec -it mariadb /bin/bash -c "echo -e CREATE DATABASE test | /usr/bin/mysql -u root" (cd connectivity && make -srj8 CppunitTest_connectivity_mysql_test CONNECTIVITY_TEST_MYSQL_DRIVER="root/foobarbaz@sdbc:mysql:mysqlc:127.0.0.1:3306/test") podman stop mariadb podman rm mariadb ``` -------------------------------- ### Set and Get AttrBool Property Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/OleTest.htm Demonstrates setting and getting the AttrBool property with a boolean array. ```javascript oletest.AttrBool = arrBool; ret = oletest.AttrBool; document.writeln("Setting AttrBool: " + arrBool.toString() + "

"); document.writeln("Getting AttrBool: " + arrBool.toString()); ``` -------------------------------- ### Java Component Example: TestJavaComponent Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Demonstrates extending the service provider with a new factory and instantiating example components. ```Java package org.openoffice.comp.test; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.uno.UnoRuntime; public class TestJavaComponent { public static void main(String[] args) { try { // Get the service manager XMultiComponentFactory serviceManager = Bootstrap.createServiceManager(); // Create an instance of TestComponentA Object componentA = serviceManager.createInstanceWithContext("com.sun.star.test.TestComponentA", null); XComponent xComponentA = UnoRuntime.queryInterface(XComponent.class, componentA); // Create an instance of TestComponentB Object componentB = serviceManager.createInstanceWithContext("com.sun.star.test.TestComponentB", null); XComponent xComponentB = UnoRuntime.queryInterface(XComponent.class, componentB); // You can now interact with componentA and componentB System.out.println("TestComponentA created: " + (componentA != null)); System.out.println("TestComponentB created: " + (componentB != null)); // Dispose of the components when done if (xComponentA != null) { xComponentA.dispose(); } if (xComponentB != null) { xComponentB.dispose(); } } catch (Exception e) { e.printStackTrace(); } } } ``` -------------------------------- ### Install Android App Source: https://github.com/libreoffice/core/blob/master/android/README.md Installs the application on an attached Android device. Ensure your device is connected and recognized by 'adb devices'. ```bash cd android/source make install adb logcat ``` -------------------------------- ### LibreOffice Configuration Management Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Connects to a %PRODUCTNAME% %PRODUCT_RELEASE%, gets the configuration manager, and accesses the configuration in various ways. ```Java ConfigExamples.java ``` -------------------------------- ### uno.exe Component Execution Source: https://github.com/libreoffice/core/blob/master/odk/docs/tools.html Shows how to use 'uno.exe' to run a UNO component or service process, providing a runtime environment. It includes examples with different ways to specify components and environment variables. ```bash uno.exe -c MyComponent -l mycomp.dll -env:URE_MORE_SERVICES=myservices.rdb -env:URE_MORE_TYPES=mytypes.rdb -- foo bar ``` ```bash uno.exe -s foo.bar.FooBarService -env:URE_MORE_SERVICES=myservices.rdb -env:URE_MORE_TYPES=mytypes.rdb -- foo bar ``` -------------------------------- ### Install 32-bit OpenGL for Emulator Acceleration Source: https://github.com/libreoffice/core/blob/master/android/README.md Installs the necessary 32-bit OpenGL library for proper acceleration when using the Android emulator. ```bash sudo zypper in Mesa-libGL-devel-32bit ``` -------------------------------- ### Create Simple Database Table 'Sales' Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html This example demonstrates how to create a simple database table named 'Sales'. The exact SQL commands would depend on the specific database system being used. ```java import com.sun.star.beans.PropertyValue; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.frame.Desktop; import com.sun.star.lang.XComponent; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.sdb.XDataSource; import com.sun.star.sdbc.Connection; import com.sun.star.sdbc.SQLException; import com.sun.star.sdbc.XConnection; import com.sun.star.sdbc.XStatement; public class Sales { public static void main(String[] args) { try { XComponentContext xContext = Bootstrap.bootstrap(); Desktop xDesktop = (Desktop) UnoRuntime.queryInterface(Desktop.class, xContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", xContext)); // Assume a data source named 'MYDB0' is configured and accessible XDataSource xDataSource = null; try { Object obj = xContext.getServiceManager().createInstanceWithContext("com.sun.star.sdb.DataSource", xContext); xDataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, obj); xDataSource.setName("MYDB0"); } catch (com.sun.star.uno.Exception e) { System.err.println("Could not create or get data source: " + e.getMessage()); e.printStackTrace(); return; } XConnection xConnection = null; try { String connectionURL = "sdbc:mysql:mysql://localhost:3306/testdb"; // Example URL PropertyValue[] props = new PropertyValue[1]; props[0] = new PropertyValue(); props[0].Name = "URL"; props[0].Value = connectionURL; xConnection = xDataSource.connect(props); } catch (SQLException e) { System.err.println("Database connection error: " + e.getMessage()); e.printStackTrace(); return; } if (xConnection != null) { System.out.println("Database connection established."); try { XStatement xStatement = xConnection.createStatement(); // SQL to create a table named 'Sales' String createTableSQL = "CREATE TABLE Sales ( SaleID INT PRIMARY KEY AUTO_INCREMENT, ProductName VARCHAR(255), Quantity INT, Price DECIMAL(10, 2) )"; xStatement.executeUpdate(createTableSQL); System.out.println("Table 'Sales' created successfully."); xStatement.close(); } catch (SQLException e) { System.err.println("SQL execution error: " + e.getMessage()); e.printStackTrace(); } try { xConnection.close(); System.out.println("Database connection closed."); } catch (SQLException e) { System.err.println("Error closing connection: " + e.getMessage()); e.printStackTrace(); } } } catch (com.sun.star.uno.Exception e) { System.err.println("UNO Exception: " + e.getMessage()); e.printStackTrace(); } } } ``` -------------------------------- ### Test AttrAny2 property with object input Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/JScriptNewStyle.htm Sets and gets an object value from the AttrAny2 property and prints 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) ``` -------------------------------- ### Example climaker Usage Source: https://github.com/libreoffice/core/blob/master/odk/docs/tools.html Demonstrates the command-line syntax for the climaker tool, used for generating DLLs. ```bash climaker --out cli_mytypes.dll --reference cli_uretypes.dll --extra types.rdb mytypes.rdb ``` -------------------------------- ### Load Component into %PRODUCTNAME% %PRODUCT_RELEASE% via Java Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Demonstrates how a Java application can load a component into %PRODUCTNAME% %PRODUCT_RELEASE%. This example is useful for integrating external functionalities or custom components into the office suite. ```java package com.sun.star.example.FirstSteps; import com.sun.star.uno.UnoRuntime; import com.sun.star.lang.XComponent; import com.sun.star.frame.XComponentLoader; import com.sun.star.beans.PropertyValue; import com.sun.star.uno.XComponentContext; import com.sun.star.bridge.UnoUrlResolver; import com.sun.star.bridge.XUnoUrlResolver; import com.sun.star.lang.XMultiComponentFactory; public class FirstLoadComponent { public static void main(String[] args) { try { // get a remote office service manager XComponentContext remoteContext = null; try { // use the UnoUrlResolver to get a remote context XUnoUrlResolver urlResolver = UnoUrlResolver.create(null); // connect to the running office remoteContext = (XComponentContext) urlResolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"); } catch (Exception e) { System.out.println("Could not connect to running office instance."); e.printStackTrace(System.out); System.exit(1); } // get the service manager from the remote context XMultiComponentFactory remoteServiceManager = remoteContext.getServiceManager(); // create a new document Object desktopObj = remoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", remoteContext); XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktopObj); // specify document properties PropertyValue[] loadProps = new PropertyValue[1]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "Hidden"; loadProps[0].Value = new Boolean(true); // load the document XComponent xComponent = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, loadProps); // close the document xComponent.dispose(); System.out.println("Successfully connected to office and created/closed a document."); } catch (Exception e) { e.printStackTrace(System.out); } } } ``` -------------------------------- ### Test AttrAny2 property with string input Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/JScriptNewStyle.htm Sets and gets a string value from the AttrAny2 property and prints the set and get values. ```javascript i= "Hallo" oletest.AttrAny2= i; ret= oletest.AttrAny2; document.writeln( "set: " + i + " get: " + ret) ``` -------------------------------- ### Interprocess Connection Client Example Source: https://github.com/libreoffice/core/blob/master/odk/examples/DevelopersGuide/examples.html Implements a client that is aware of losing connection to %PRODUCTNAME% %PRODUCT_RELEASE%. ```Java package com.sun.star.comp.helper.samples.ConnectionAwareClient; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.comp.helper.BootstrapException; import com.sun.star.uno.UnoRuntime; import com.sun.star.bridge.XUnoUrlResolver; import com.sun.star.lang.XComponent; import com.sun.star.registry.XRegistryService; import com.sun.star.uno.XComponentContext; import com.sun.star.frame.Desktop; import com.sun.star.frame.XDesktop; import com.sun.star.beans.PropertyValue; public class ConnectionAwareClient { /** * @param args */ public static void main(String[] args) { XComponentContext localContext = null; XComponent xOffice = null; try { // get local component context localContext = Bootstrap.bootstrap(); // get the remote office component context Object context = localContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext); XUnoUrlResolver xUrlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, context); // connect to the running office PropertyValue [] propertyValues = new PropertyValue[1]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Hidden"; propertyValues[0].Value = new Boolean(true); Object resolved = xUrlResolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext", propertyValues); XComponentContext remoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, resolved); // get the desktop xOffice = (XComponent) remoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", remoteContext); XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, xOffice); // do something with the desktop System.out.println("Connected to running Office ..."); System.out.println("Desktop title: " + xDesktop.getCurrentController().getFrame().getTitle()); // disconnect from office xOffice.dispose(); } catch (BootstrapException e) { System.err.println("Bootstrap failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.connection.ConnectionSetupException e) { System.err.println("Connection setup failed: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } catch (com.sun.star.uno.Exception e) { System.err.println("UNO Exception: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } } } ``` -------------------------------- ### Test AttrAny2 property with double input Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/JScriptNewStyle.htm Sets and gets a double value from the AttrAny2 property and prints the set and get values. ```javascript i= 3.14; oletest.AttrAny2= i; ret= oletest.AttrAny2; document.writeln( "set: " + i + " get: " + ret) ``` -------------------------------- ### Initialize LibreOfficeKit (C++ Wrapper) Source: https://github.com/libreoffice/core/blob/master/libreofficekit/README.md The C++ wrapper LibreOfficeKit.hxx includes LibreOfficeKitInit.h automatically, simplifying initialization for C++ projects. ```cpp #include ``` -------------------------------- ### Test AttrAny2 property with integer input Source: https://github.com/libreoffice/core/blob/master/extensions/test/ole/JScriptNewStyle.htm Sets and gets an integer value from the AttrAny2 property and prints the set and get values. ```javascript i= 100; oletest.AttrAny2= i; ret= oletest.AttrAny2; document.writeln( "set: " + i + " get: " + ret) ```